Monday, February 11, 2008
Sample Excel Macro
Dim rng As Range
Dim counter As Integer
Dim LeftValue As String
Dim StrCell As String
Set rng = Range("A1:C8")
counter = 1
Dim Temp
For counter = 1 To rng.Rows.Count
Temp = rng.Cells(counter, 1).Value & " and " & rng.Cells(counter, 2).Value
rng.Cells(counter, 3).Value = Temp
'StrCell = rng.Cells(counter, 2).Value
'MsgBox (Temp)
Next
End Sub
Wednesday, January 30, 2008
Some Useful SharePoint Commands
To set path to stsadm:
Path = C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
-------------------------------------------
execadmsvcjobs
stsadm.exe -o execadmsvcjobs
Executes all administrative timer jobs immediately instead of waiting for the timer job to run.
-------------------------------------------
Backup Site
stsadm.exe -o backup -url http://ServerTLD:Port/PathtoSite -filename BackupFileName.dat -overwrite
-------------------------------------------
Restore Site
stsadm.exe -o restore -url http://ServerTLD:Port/PathToSite -filename BackupFileName.dat -overwrite
-------------------------------------------
Infopath Form Template
Verify:
stsadm.exe -o VerifyFormTemplate -filename c:\MyFormFolder\MyForm.xsn
Upload:
stsadm.exe -o UploadFormTemplate -filename c:\MyFormFolder\MyForm.xsn
Activate:
stsadm.exe -o ActivateFormTemplate -url http://MySiteCollection -filename c:\MyFormFolder\MyForm.xsn
Deactivate:
stsadm.exe -o DeactivateFormTemplate -url http://MySiteCollection -filename c:\MyFormFolder\MyForm.xsn
Remove:
stsadm.exe -o RemoveFormTemplate -filename c:\MyFormFolder\MyForm.xsn
-------------------------------------------
Tuesday, January 29, 2008
SharePoint List formula to calculate Month and quarter from date value.
1. Year
Formula :
=YEAR(Date)
2. Date
Formula:
=DAY(Date)
3. Month
Formula :
=IF(MONTH(Date)=1,"January","")&
IF(MONTH(Date)=2,"February","")&
IF(MONTH(Date)=3,"MARCH","")&
IF(MONTH(Date)=4,"April","")&
IF(MONTH(Date)=5,"May","")&
IF(MONTH(Date)=6,"June","")&
IF(MONTH(Date)=7,"July","")&I
F(MONTH(Date)=8,"August","")&
IF(MONTH(Date)=9,"September","")&
IF(MONTH(Date)=10,"October","")&
IF(MONTH(Date)=11,"November","")&
IF(MONTH(Date)=12,"December","")
4. Quarter
Formula:
=IF(MONTH(Date)<=3,"Q1", IF(MONTH(Date)<=6,"Q2", IF(MONTH(Date)<=9,"Q3",IF(MONTH(Date)<=12,"Q4",""))))
5. Getting Moday t0 friday date. If selects any date in the week, the calculated column fills with monday to to friday date, i.e. if selects "3/9/2009" then the calculaed field fills with "2009/03/09 - 2009/03/13".
=TEXT([Select Week]+(2-WEEKDAY([Select Week])),"YYYY/MM/DD")&" - "&TEXT([Select Week]+(6-WEEKDAY([Select Week])),"YYYY/MM/DD")
Where "Select Week" is the name of date filed. If you want any other day change the week day values 2(monday) and 6(friday)
Wednesday, December 19, 2007
XmlSerializer error while accessing an object from web service in InfoPath browser from.
Problem:
This error is happened while accessing an class (accessing the object) from web service with in a InfoPath browser from. This will work fine within Win from but with browse from hitting error. Stack trace of error as follows:
There is an error in XML document (1, 268). ---> System.Security.SecurityException: Request failed. at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderNDAWebService.Read5_NDA(Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderNDAWebService.Read14_GetNDADataResponse() at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer17.Deserialize(XmlSerializationReader reader) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) The action that failed was: Demand The type of the first permission that failed was: System.Security.PermissionSet --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at Amendment.NDA_SP.NDAWebService.GetNDAData(String NDASerialNumber) at Amendment.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e)
Solution:
Set Full trust to the form with Digital Certificate.
Tools => From Options => Security and Trust => select “Full trust” => select “Sign this Template” => Create certificate.
Monday, December 17, 2007
Creating custom timer jobs in SharePoint:
Creating custom timer jobs in SharePoint:
In sharepoint 2007 we can create custom timer jobs.
1. Create a new Class Library project in VS 2005.
2. Add reference of SharePoint.
3. Crate a new class, implement SPJobDefinition, with a blank constructor.
4. Overide Execute method and write the code to execute in this mehod.
5. Sign the assembly with strong name and deploy in GAC.
6. So the class structure will be like this.
---------------------------------------------------
using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint.Administration; namespace NDACommon { public class MyTimerJob : SPJobDefinition { public MyTimerJob () { } public MyTimerJob (string MyJobName, SPWebApplication MyWebApplication) : base(MyJobName, MyWebApplication, null, SPJobLockType.Job) { } public override void Execute(Guid targetInstanceId) { try { System.IO.File.AppendAllText(@"C:\temp\Timer.txt", "SP TimerJob : " + DateTime.Now.ToString() + "\r\n"); } catch (Exception ex) { System.IO.File.AppendAllText(@"C:\temp\Timer.txt", "SP TimerJob : " + DateTime.Now.ToString() + "\r\n"); } } } } |
---------------------------------------------------
Adding Timer Job into SharePoint
---------------------------------------------------
static void CreateJob() { SPServer myServer = SPServer.Local; SPSite mySite = new SPSite("http://server/sites/musite"); SPWebApplication myApplication = mySite.WebApplication; SPJobDefinitionCollection myJobsColl = myApplication.JobDefinitions; NDATimerJob myJob = new NDATimerJob("myCountDocsJob", myApplication); myJob.Title = "My Test Job"; SPMinuteSchedule myMinuteSchedule = new SPMinuteSchedule(); myMinuteSchedule.BeginSecond = 0; myMinuteSchedule.EndSecond = 59; myMinuteSchedule.Interval = 1; myJob.Schedule = myMinuteSchedule; myJobsColl.Add(myJob); myApplication.Update(); MessageBox.Show("Job Installed"); } |
---------------------------------------------------
Removing Timer Job from SharePoint
---------------------------------------------------
public static void DeleteJob() { SPSite mySite = new SPSite("http://server/sites/musite "); foreach (SPJobDefinition oneJob in mySite.WebApplication.JobDefinitions) { if (oneJob.Title == " My Test Job") { oneJob.Delete(); MessageBox.Show("Job Deleted"); } } } |
---------------------------------------------------
Debugging Timer Job.
Attach OSTIMER.EXE process and debug.
Wednesday, October 3, 2007
Databases using in SharePoint
SharePoint is using two types of database.
3.1. Content Database
2. 2. Configuration Database.
One web application can have up to 16 content databases. Also one content database can also can able to share across different Web applications.
A Configuration database will create when a SharePoint configuration Wizard runs.
While SharePoint configuration Wizard runs it will asks whether you want to use existing Configuration database or create new one. One SharePoint deployment (farm of front end servers) can have only one Configuration database.
Application Pool
1. Low Isolation level IIS – All web sites are working in a single process
2. Medium Isolation level IIS – Two process one is for IIS and another for all websites.
3. High Isolation level IIS – IIS and Each Websites a
Application pool is a new concept in IIS 6.0.
To achieve high isolation level in IIS the concept of application pool is using.
Each application pool will work in a different process. So we can select different application pools for each websites or web process so that it will work on different process.
Each process has an identity in OS.
Each application pool also has identity. This we can change in identity tab in the application pool property. There is preferred list( Network Service, Local System & Local Service). Network service is preferable if we are going to use any cross site resources.
Also we can assign any user name. But the user should be in the IIS_WPG user group.