protected Source GetCurrentSource(Microsoft.SharePoint.SPSite site, SearchResultDefinition definition)
        {
            FederationManager federationManager = null;
            SearchObjectOwner searchOwner       = null;

            return(GetCurrentSource(site, definition, out federationManager, out searchOwner));
        }
 private void GetAllListData(string selectedsite)
 {
     using (SPOM.SPSite siteselected = new SPOM.SPSite(selectedsite))
     {
         List <ListProperties> listpropcollection = new List <ListProperties>();
         foreach (SPOM.SPWeb web in siteselected.AllWebs)
         {
             foreach (SPOM.SPList list in web.Lists)
             {
                 ListProperties listprops = new ListProperties();
                 listprops.ListTitle     = list.Title;
                 listprops.ItemCount     = list.ItemCount;
                 listprops.FolderCount   = list.Folders != null ? list.Folders.Count : 0;
                 listprops.FieldCount    = list.Fields != null ? list.Fields.Count : 0;
                 listprops.ViewCount     = list.Views != null ? list.Views.Count : 0;;
                 listprops.WorkFlowCount = list.WorkflowAssociations != null ? list.WorkflowAssociations.Count : 0;
                 listpropcollection.Add(listprops);
             }
             if (web != null)
             {
                 web.Dispose();
             }
         }
         GridView1.DataSource = listpropcollection;
         GridView1.DataBind();
     }
 }
        private void GetAllListData(string selectedsite)
        {
            using (SPOM.SPSite siteselected = new SPOM.SPSite(selectedsite))
            {
                List<ListProperties> listpropcollection = new List<ListProperties>();
                foreach (SPOM.SPWeb web in siteselected.AllWebs)
                {
                    foreach (SPOM.SPList list in web.Lists)
                    {
                        ListProperties listprops = new ListProperties();
                        listprops.ListTitle = list.Title;
                        listprops.ItemCount = list.ItemCount;
                        listprops.FolderCount = list.Folders != null ? list.Folders.Count : 0;
                        listprops.FieldCount = list.Fields != null ? list.Fields.Count : 0;
                        listprops.ViewCount = list.Views != null ? list.Views.Count : 0; ;
                        listprops.WorkFlowCount = list.WorkflowAssociations != null ? list.WorkflowAssociations.Count : 0;
                        listpropcollection.Add(listprops);

                    }
                    if (web != null)
                    {
                        web.Dispose();
                    }
                }
                GridView1.DataSource = listpropcollection;
                GridView1.DataBind();
            }
        }
 /// <summary>
 /// Generates a sample document ID used in the search box.
 /// </summary>
 public override string GetSampleDocumentIdText(Microsoft.SharePoint.SPSite site)
 {
     return(string.Format(DOCID_FORMAT,
                          "55DA526F",
                          "FD9D4836",
                          "FD0910DC",
                          "15B4AD8A",
                          "ABDC1A45"));
 }
Exemple #5
0
 /// <summary>Retrieves the ID of the site.</summary>
 /// <returns>The ID of the site.</returns>
 string WebId()
 {
     using (Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite(URL))
     {
         using (Microsoft.SharePoint.SPWeb web = site.OpenWeb())
         {
             return(web.ID.ToString());
         }
     }
 }
        private void DeploySearchResult(object modelHost, Microsoft.SharePoint.SPSite site, SearchResultDefinition definition)
        {
            FederationManager federationManager = null;
            SearchObjectOwner searchOwner       = null;

            var currentSource = GetCurrentSource(site, definition, out federationManager, out searchOwner);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioning,
                Object           = currentSource,
                ObjectType       = typeof(Source),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            if (currentSource == null)
            {
                currentSource      = federationManager.CreateSource(searchOwner);
                currentSource.Name = definition.Name;

                if (definition.ProviderId.HasValue)
                {
                    currentSource.ProviderId = definition.ProviderId.Value;
                }
                else
                {
                    currentSource.ProviderId = GetProviderByName(federationManager, definition.ProviderName).Id;
                }
            }

            currentSource.Description = definition.Description ?? string.Empty;
            currentSource.CreateQueryTransform(new QueryTransformProperties(), definition.Query);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioned,
                Object           = currentSource,
                ObjectType       = typeof(Source),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            currentSource.Commit();

            if (definition.IsDefault)
            {
                federationManager.UpdateDefaultSource(currentSource.Id, searchOwner);
            }
        }
        protected Source GetCurrentSource(Microsoft.SharePoint.SPSite site, SearchResultDefinition definition,
                                          out FederationManager federationManager,
                                          out SearchObjectOwner searchOwner)
        {
            var context        = SPServiceContext.GetContext(site);
            var searchAppProxy = context.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;

            federationManager = new FederationManager(searchAppProxy);
            searchOwner       = new SearchObjectOwner(SearchObjectLevel.SPSite, site.RootWeb);

            return(federationManager.GetSourceByName(definition.Name, searchOwner));
        }
Exemple #8
0
        static void Main(string[] args)
        {
            string RootSiteCollections = System.Configuration.ConfigurationSettings.AppSettings["RootSiteCollection"];
            //int i = 0;
            int j = 0;

            Microsoft.SharePoint.SPSite siteColl = null;
            StringBuilder sbFields = new StringBuilder();
            StringBuilder sbVals   = new StringBuilder();

            StreamWriter sw = null;

            foreach (string siteCollection in RootSiteCollections.Split(','))
            {
                siteColl = new SPSite(siteCollection.Trim());
                foreach (SPWeb web in siteColl.AllWebs)
                {
                    Console.WriteLine("Processing site " + web.Url);
                    sbFields.Length = 0;


                    foreach (SPList list in web.Lists)
                    {
                        Console.WriteLine("Processing list " + list.ID);
                        sbVals.Length = 0;
                        if (list.BaseType == SPBaseType.DocumentLibrary && list.Hidden == false)
                        {
                            j = 0;
                            foreach (SPItem item in list.Items)
                            {
                                Console.WriteLine("Processing item " + item.ID);
                                if (j == 0)
                                {
                                    sbFields.Append("SourcePath");
                                    sbFields.Append(',');
                                    sbFields.Append("UniqueId");
                                    sbFields.Append(',');
                                    sbFields.Append("SiteURL");
                                    sbFields.Append(',');
                                }

                                sbVals.Append(item["URL Path"].ToString().Replace(',', ' '));
                                sbVals.Append(',');

                                sbVals.Append(item["UniqueId"].ToString());
                                sbVals.Append(',');


                                sbVals.Append(web.Url);
                                sbVals.Append(',');

                                foreach (SPField field in item.Fields)
                                {
                                    try
                                    {
                                        if (field.Hidden == false && field.Sealed == false)
                                        {
                                            if (j == 0)
                                            {
                                                sbFields.Append(field.ToString());
                                                sbFields.Append(',');
                                            }

                                            if (!string.IsNullOrEmpty(item[field.ToString()].ToString()))
                                            {
                                                sbVals.Append(item[field.ToString()].ToString().Replace(',', ' '));
                                            }
                                            else
                                            {
                                                sbVals.Append(" ");
                                            }

                                            sbVals.Append(',');
                                        }
                                    }
                                    catch { }
                                }
                                //remove last ','
                                if (sbFields.Length > 0)
                                {
                                    sbFields.Length = sbFields.Length - 1;
                                }
                                if (sbVals.Length > 0)
                                {
                                    sbVals.Length = sbVals.Length - 1;
                                }
                                // add new lines
                                sbFields.Append(@"
"); sbVals.Append(@"
");
                                j++;
                            }
                        }
                        sbFields.Append(sbVals.ToString());
                        sbFields.Append(@"
");
                    }

                    sw = new StreamWriter(@"c:\metadata_" + web.Url.Substring(web.Url.LastIndexOf(@"/") + 1) + @".csv");

                    sw.Write(sbFields.ToString());
                    sw.Write(sbVals.ToString());
                    sw.Flush();
                    sw.Close();
                }
            }
        }
Exemple #9
0
        // This does not work
        static void Main(string[] args)
        {
            if (args.Length < 5 || args.Length > 6)
            {
                Console.WriteLine("Maps a SPField to a specific point in the Managed Metadata tree (Taxonomy tree).");
                Console.ResetColor();
                Console.WriteLine(
                    string.Format(
                        "Usage: {0} {1} {2} {3} {4} {5} {6}",
                        System.AppDomain.CurrentDomain.FriendlyName,
                        "http://localhost:51001",
                        "TaxChalmersDepartment",
                        "TaxChalmersDepartmentHiddenFieldID",
                        "Chalmers.se",
                        "\"Chalmers Institutions Enterprise Taxonomy\"",
                        "Departments"

                        )
                    );
                Console.WriteLine("The Term (Departments in the example above) is not mandatory.\nIf obmitted will the field be mapped to the termset.");
                Console.WriteLine(
                    string.Format(
                        "Usage: {0} {1} {2} {3} {4} {5} {6}",
                        System.AppDomain.CurrentDomain.FriendlyName,
                        "http://localhost:51001",
                        "TaxChalmersDepartment",
                        "{FE44AD5C-5DF8-4846-A623-A3C693FF07A5}",
                        "Chalmers.se",
                        "\"Chalmers Institutions Enterprise Taxonomy\"",
                        "Departments"
                        )
                    );
                Console.WriteLine(
                    string.Format(
                        "Usage: {0} {1} {2} {3} {4} {5} {6}",
                        System.AppDomain.CurrentDomain.FriendlyName,
                        "http://localhost:51001",
                        "TaxChalmersDepartment",
                        "{FE44AD5C-5DF8-4846-A623-A3C693FF07A5}",
                        "Chalmers.se",
                        "\"Chalmers Institutions Enterprise Taxonomy\"",
                        ""
                        )
                    );


                return;
            }

            Dictionary <string, string> suppliedParams = new Dictionary <string, string>();

            suppliedParams.Add("server", args[0]);
            suppliedParams.Add("fieldName", args[1]);
            suppliedParams.Add("hiddenFieldGUID", args[2]);

            suppliedParams.Add("group", args[3]);
            suppliedParams.Add("termSet", args[4]);
            if (args.Length == 6)
            {
                suppliedParams.Add("term", args[5]);
            }
            else
            {
                suppliedParams.Add("term", args[4]);
            }

            using (SPSite oSite = new Microsoft.SharePoint.SPSite(suppliedParams["server"]))
            {
                var       session   = new TaxonomySession(oSite);
                TermStore termStore = session.TermStores[0];
                Guid      TaxChalmersDepartmentHiddenFieldID = new Guid(suppliedParams["hiddenFieldGUID"]);

                SetupTaxonomyField(
                    oSite,
                    termStore,
                    suppliedParams["group"],
                    suppliedParams["termSet"],

                    suppliedParams["term"],
                    suppliedParams["fieldName"],
                    TaxChalmersDepartmentHiddenFieldID);
            }
        }