March 02, 2012

Could not save the list changes to the server - Sharepoint Designer 2010

Or when you create a new form, but you just see Save and Cancel Button and nothing else.

Resolution: Empty the Recylce Bin

File Upload Control Explained

http://msdn.microsoft.com/en-us/library/ms454491.aspx

http://www.codeproject.com/Articles/20023/ASP-NET-2-0-FileUpload-Server-Control


if (FileUpload1.HasFile)
            {
                Hashtable reqProperties = new Hashtable();
                reqProperties.Add("vti_title", "Test");
                String fileToUpload = FileUpload1.PostedFile.FileName;
                String documentLibraryName = "Submissions";
                Stream fStream = FileUpload1.PostedFile.InputStream;
                byte[] contents = new byte[fStream.Length];
                SPFolder myLibrary = SPContext.Current.Web.Folders[documentLibraryName];
                SPFile spfile = myLibrary.Files.Add(FileUpload1.FileName, contents, reqProperties, true);
            }

Central Admin rendering without CSS and scripts

February 24, 2012

SharePoint Designer Workflow to create Pages in Pages Library


Issue#1 : The workflow could not create the list item
1. Create a page with the content type you want to create via Workflow normally
Note: Go to Pages Library --> Add your custom content type --> Documents --> New Document --> Select your content type.
2. With SharePoint Designer open the directory, highlight the file you created and choose export - then save it to somewhere on your computer
3. Go back to the List you will create the items in, and under "List Settings" click on the content type in question then choose "Advanced Settings"
4. Choose "Upload a new document template" browse to the saved file and upload it
5. Now you can create the WF in SPD - the "Path and Name" can be set normally - no need for adding relative paths, if you set it to "Something" it will create it as "Something.aspx" under the wiki library for example - content type should be of course the one we modified.

Issue#2 : The workflow could not check in the list item. Make sure the item is already checked out.

February 23, 2012

Preventing provisioning duplicate Web Parts instances on Feature reactivation

http://blog.mastykarz.nl/preventing-provisioning-duplicate-web-parts-instances-on-feature-reactivation/


using (SPSite site = new SPSite("http://sharepoint"))
{
  SPList list = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
  SPListItemCollection items = list.Items;
  List<string> webParts = new List<string>();

  // find the right Page Layout
  foreach (SPListItem item in items)
  {
    if (item.Name.Equals("CustomPageLayout.aspx",
      StringComparison.CurrentCultureIgnoreCase))
    {
      SPFile file = item.File;
      // get the Web Part Manager for the Page Layout
      SPLimitedWebPartManager wpm =
        file.GetLimitedWebPartManager(PersonalizationScope.Shared);
      // iterate through all Web Parts and remove duplicates
      while (wpm.WebParts.Count > 0)
      {
        StringBuilder sb = new StringBuilder();
        XmlWriterSettings xws = new XmlWriterSettings();
        xws.OmitXmlDeclaration = true;
        XmlWriter xw = XmlWriter.Create(sb, xws);
        System.Web.UI.WebControls.WebParts.WebPart wp =
          wpm.WebParts[0];
        wpm.ExportWebPart(wp, xw);
        xw.Flush();
        string md5Hash = getMd5Hash(sb.ToString());
        if (webParts.Contains(md5Hash))
          wpm.DeleteWebPart(wp);
        else
          webParts.Add(md5Hash);
      }
    }
  }
}

If Statement in One Line

($myvalue == 10) ? "the value is 10": "the value is not 10";

SonarQube with Jenkins Setup using Docker Images

https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...