private static void UpdateContentTypes(Guid listId, string path, Microsoft.SharePoint.SPWeb site)
        {
            string      filename = Path.Combine(path, "schema.xml");
            XmlDocument document = new XmlDocument();

            document.Load(filename);
            if (document != null)
            {
                XmlNode node = document.DocumentElement.SelectSingleNode("MetaData/ContentTypes");
                if (node != null)
                {
                    Guid uniqueId = new Guid(document.DocumentElement.Attributes["Name"].Value);
                    foreach (Microsoft.SharePoint.SPContentType type in site.Lists.GetList(uniqueId, true).ContentTypes)
                    {
                        string strA = type.Parent.Id.ToString();
                        if ((type.Version <= 0) && ((string.Compare(strA, "0x0120", StringComparison.CurrentCulture) != 0) || (string.Compare(strA, "0x0107", StringComparison.CurrentCulture) == 0)))
                        {
                            string  xpath    = "ContentType[@ID=\"" + type.Id.ToString() + "\"]";
                            XmlNode oldChild = node.SelectSingleNode(xpath);
                            XmlNode newChild = oldChild.OwnerDocument.CreateComment(oldChild.OuterXml);
                            oldChild.ParentNode.ReplaceChild(newChild, oldChild);
                            XmlNode      node4     = oldChild.OwnerDocument.CreateElement("ContentTypeRef");
                            XmlAttribute attribute = oldChild.OwnerDocument.CreateAttribute("ID");
                            attribute.Value = strA;
                            node4.Attributes.Append(attribute);
                            newChild.ParentNode.InsertBefore(node4, newChild);
                        }
                    }
                    document.Save(filename);
                }
            }
        }
        private static void ExportListSchema(Guid listId, string exportLocation, Microsoft.SharePoint.SPWeb site)
        {
            string       listSchema = GetListSchema(site, listId);
            FileStream   stream     = File.Open(exportLocation + @"\schema.xml", FileMode.Create, FileAccess.Write);
            StreamWriter writer     = new StreamWriter(stream);

            writer.Write(listSchema);
            writer.Flush();
            writer.Close();
            stream.Close();
        }
 // Methods
 private static void _Export(Uri siteUrl, Guid listId, string exportLocation)
 {
     using (Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite(siteUrl.ToString()))
     {
         using (Microsoft.SharePoint.SPWeb web = site.OpenWeb())
         {
             ExportListSchema(listId, exportLocation, web);
             ExportListFiles(listId, exportLocation, web);
             UpdateContentTypes(listId, exportLocation, web);
             UpdateSummaryView(exportLocation);
             CommentOutExportUnsupportedFields(exportLocation);
             UpdateListSchema(listId, exportLocation, web);
             ApplyFixes(exportLocation);
         }
     }
 }
        private static string GetListSchema(Microsoft.SharePoint.SPWeb web, Guid listId)
        {
            string         str     = string.Empty;
            HttpWebRequest request = WebRequest.Create(web.Url + "/_vti_bin/owssvr.dll?Cmd=ExportList&List=" + listId.ToString("D")) as HttpWebRequest;

            request.Credentials = CredentialCache.DefaultCredentials;
            HttpWebResponse response = null;

            try
            {
                response = request.GetResponse() as HttpWebResponse;
            }
            catch (WebException)
            {
                throw;
            }
            str = new StreamReader(response.GetResponseStream()).ReadToEnd();
            response.Close();
            return(str);
        }
 private static void ExportListFiles(Guid listId, string exportLocation, Microsoft.SharePoint.SPWeb site)
 {
     Microsoft.SharePoint.SPList list = site.Lists[listId];
     if (list.RootFolder != null)
     {
         foreach (Microsoft.SharePoint.SPFile file in list.RootFolder.Files)
         {
             string path   = exportLocation + @"\" + file.Name;
             Stream stream = file.OpenBinaryStream();
             if (!IsText(file.Name))
             {
                 SaveAsFile(ReadAsByte(stream), path);
             }
             else
             {
                 SaveAsFile(ReadAsText(stream), path);
             }
             stream.Close();
         }
     }
 }
 public MelhoresPraticasComentariosRepository(Microsoft.SharePoint.SPWeb web) : base(web)
 {
 }
        private static void UpdateListSchema(Guid listId, string exportLocation, Microsoft.SharePoint.SPWeb site)
        {
            XmlNode documentElement;

            Microsoft.SharePoint.SPList list;
            string      filename = exportLocation + @"\schema.xml";
            XmlDocument document = new XmlDocument();

            document.Load(filename);
            if (document != null)
            {
                documentElement = document.DocumentElement;
                new Guid(documentElement.Attributes["Name"].Value);
                list = site.Lists.GetList(listId, true);
                if (list.EnableModeration && ((documentElement.Attributes["ModeratedList"] == null) || (documentElement.Attributes["ModeratedList"].Value.ToLower(CultureInfo.CurrentCulture) == "false")))
                {
                    XmlAttribute node = document.CreateAttribute("ModeratedList");
                    node.Value = "TRUE";
                    documentElement.Attributes.Append(node);
                }
            }
            else
            {
                return;
            }
            XmlAttribute attribute2 = document.CreateAttribute("Type");

            attribute2.Value = documentElement.Attributes["ServerTemplate"].Value;
            documentElement.Attributes.Append(attribute2);
            documentElement.Attributes.RemoveNamedItem("FeatureId");
            documentElement.Attributes.RemoveNamedItem("ServerTemplate");
            documentElement.Attributes.RemoveNamedItem("Version");
            documentElement.Attributes["Name"].Value = ReplaceUnsafeChar(documentElement.Attributes["Title"].Value);
            XmlAttribute attribute4 = document.CreateAttribute("Id");

            attribute4.Value = Guid.NewGuid().ToString();
            documentElement.Attributes.Append(attribute4);

            XmlNode       node4      = document.DocumentElement.SelectSingleNode("MetaData/Views");
            List <string> list2      = new List <string>();
            IEnumerator   enumerator = node4.GetEnumerator();

            XmlNode node5;
            string  str2;

Label_022C:
            if (enumerator.MoveNext())
            {
                goto Label_061D;
            }
            List <string> list3       = new List <string>();
            List <string> list4       = new List <string>();
            IEnumerator   enumerator2 = node4.GetEnumerator();
            XmlNode       node6;
            string        str3;
            string        str4;
            XmlAttribute  attribute5;
            int           num;

            goto Label_0493;
Label_0254:
            node6.Attributes.RemoveNamedItem("Name");
            goto Label_03E3;
Label_026B:
            if (node6.Attributes["Name"] != null)
            {
                goto Label_0254;
            }
            goto Label_03E3;
Label_0283:
            num = -1;
            int num2 = 1;

            goto Label_045C;
Label_028E:
            node6 = (XmlNode)enumerator2.Current;
            if (node6.Attributes["Url"] != null)
            {
                goto Label_038C;
            }
            goto Label_026B;
Label_02B4:
            attribute5       = document.CreateAttribute("WebPartZoneID");
            attribute5.Value = "Main";
            node6.Attributes.Append(attribute5);
            if (list3.Contains(str4))
            {
                goto Label_0283;
            }
            goto Label_0361;
Label_02EA:
            if (node6.Attributes["Url"] != null)
            {
                goto Label_03CC;
            }
            goto Label_0493;
Label_0305:
            if (node6.Attributes["Hidden"].Value.ToLower(CultureInfo.CurrentCulture) == "true")
            {
                goto Label_03B7;
            }
            goto Label_0361;
Label_0336:
            str4 = node6.Attributes["BaseViewID"].Value;
            if (str4 == "0")
            {
                goto Label_02EA;
            }
            goto Label_02B4;
Label_0361:
            list3.Add(str4);
            goto Label_0493;
Label_036F:
            node6.Attributes["Url"].Value = str3;
            goto Label_026B;
Label_038C:
            str3 = Path.GetFileName(node6.Attributes["Url"].Value);
            if (list.BaseType == Microsoft.SharePoint.SPBaseType.DocumentLibrary)
            {
                goto Label_0449;
            }
            goto Label_036F;
Label_03B7:
            list4.Add(num.ToString(CultureInfo.CurrentCulture));
            goto Label_0361;
Label_03CC:
            node6.Attributes.RemoveNamedItem("Url");
            goto Label_0493;
Label_03E3:
            if (node6.Attributes["BaseViewID"] != null)
            {
                goto Label_0336;
            }
            goto Label_0493;
Label_03FE:
            node6.Attributes["BaseViewID"].Value = Convert.ToString(num, CultureInfo.CurrentCulture);
            str4 = num.ToString(CultureInfo.CurrentCulture);
            if (node6.Attributes["Hidden"] != null)
            {
                goto Label_0305;
            }
            goto Label_0361;
Label_0449:
            str3 = "Forms/" + str3;
            goto Label_036F;
Label_045C:
            if (!list2.Contains(num2.ToString(CultureInfo.CurrentCulture)))
            {
                goto Label_0479;
            }
Label_0471:
            num2++;
            goto Label_045C;
Label_0479:
            if (!list3.Contains(num2.ToString(CultureInfo.CurrentCulture)))
            {
                goto Label_05D9;
            }
            goto Label_0471;
Label_0493:
            if (enumerator2.MoveNext())
            {
                goto Label_028E;
            }
            foreach (string str5 in list4)
            {
                XmlNode oldChild = node4.SelectSingleNode("View[@BaseViewID='" + str5 + "']");
                node4.RemoveChild(oldChild);
            }
            IEnumerator enumerator4 = document.DocumentElement.SelectSingleNode("MetaData/Forms").GetEnumerator();

            XmlNode current;
            string  fileName;

            goto Label_05AE;
Label_04FD:
            fileName = "Forms/" + fileName;
Label_050B:
            current.Attributes["Url"].Value = fileName;
            current.Attributes.RemoveNamedItem("Name");
            current.Attributes.RemoveNamedItem("Default");
            XmlAttribute attribute6 = document.CreateAttribute("WebPartZoneID");

            attribute6.Value = "Main";
            current.Attributes.Append(attribute6);
Label_05AE:
            while (enumerator4.MoveNext())
            {
                current  = (XmlNode)enumerator4.Current;
                fileName = Path.GetFileName(current.Attributes["Url"].Value);
                if (list.BaseType == Microsoft.SharePoint.SPBaseType.DocumentLibrary)
                {
                    goto Label_04FD;
                }
                goto Label_050B;
            }
            if (document.DocumentElement.SelectSingleNode("MetaData/Toolbar") == null)
            {
                XmlNode node2    = document.DocumentElement.SelectSingleNode("MetaData");
                XmlNode newChild = document.CreateElement("Toolbar");
                node2.AppendChild(newChild);
                XmlAttribute attribute3 = document.CreateAttribute("Type");
                attribute3.Value = "RelatedTasks";
                newChild.Attributes.Append(attribute3);
            }
            document.Save(filename);
            return;

Label_05D9:
            num = num2;
            goto Label_03FE;
Label_05F7:
            str2 = node5.Attributes["BaseViewID"].Value;
            list2.Add(str2);
            goto Label_022C;
Label_061D:
            node5 = (XmlNode)enumerator.Current;
            if (node5.Attributes["BaseViewID"] != null)
            {
                goto Label_05F7;
            }
            goto Label_022C;
        }
 public IPropertyBag GetPropertyBag(ConfigLevel level, Microsoft.SharePoint.SPWeb web)
 {
     throw new NotImplementedException();
 }
 public void SetWeb(Microsoft.SharePoint.SPWeb web)
 {
     throw new NotImplementedException();
 }
 protected override SPNavigationNodeCollection GetNavigationNodeCollection(Microsoft.SharePoint.SPWeb web)
 {
     return(web.Navigation.TopNavigationBar);
 }
Ejemplo n.º 11
0
 public TValue GetFromPropertyBag <TValue>(string key, Microsoft.SharePoint.SPWeb propertyBag)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
 public void SetInPropertyBag(string key, object value, Microsoft.SharePoint.SPWeb propertyBag)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
 public bool ContainsKeyInPropertyBag(string key, Microsoft.SharePoint.SPWeb propertyBag)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 public void RemoveKeyFromPropertyBag(string key, Microsoft.SharePoint.SPWeb propertyBag)
 {
     throw new NotImplementedException();
 }