Wednesday, April 13, 2016

sharepoint site restore error unable to open content database


sharepoint site restore error unable to open content database. Error at restore the .bak file














Tuesday, April 5, 2016

Run the sharepoint designer workflow by c# code in .net

 Running the Designer workflow by c# code
 =========================================================
SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPSite osite = new SPSite(SPContext.Current.Web.Url))
                using (SPWeb oweb = osite.OpenWeb())
                {
                    osite.AllowUnsafeUpdates = true;
                    SPList oListSecScore = oweb.Lists.TryGetList("Active Appraisals");
                    SPListItemCollection oListColl = oListSecScore.Items;
                    SPListItem oListItem = oListColl.Add();

                    oListItem["Title"] = "Appraisal_" + appraisalyr + "_" + ddlStaffId.SelectedValue;
                    oListItem["SubmitterCmnt1"] = txtSubmitterCmt.Text.Trim();

                    SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();
                    SPFieldUserValue usertoadd = General.ConvertLoginAccount(pendinguser);
                    usercollection.Add(usertoadd);
                    oListItem["PendingUser"] = usercollection;

                    SPFieldUserValueCollection userstaff = new SPFieldUserValueCollection();
                    SPFieldUserValue useraddstaff = General.ConvertLoginAccount(ddlStaffId.SelectedValue);
                    userstaff.Add(useraddstaff);
                    oListItem["Staff"] = userstaff;                
                 
                    oListItem.Update();
                    SPWorkflowAssociationCollection associationCollection = oListSecScore.WorkflowAssociations;
                    foreach (SPWorkflowAssociation association in associationCollection)
                    {
                        if (association.Name == "PendingUserWF")
                        {
                            association.AutoStartChange = true;
                            association.AutoStartCreate = true;
                            association.AssociationData = String.Empty;
                            osite.WorkflowManager.StartWorkflow(oListItem, association, association.AssociationData);
                        }
                    }

                    osite.AllowUnsafeUpdates = false;

                }
            });