コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    if (File.Exists(Constant.configPath))
                    {
                        XmlDocument xml = new XmlDocument();
                        xml.Load(Constant.configPath);
                        XmlNode root   = xml.SelectSingleNode("root");
                        string urlNode = root.SelectSingleNode("Site").Attributes[0].InnerText;
                        using (SPSite site = new SPSite(urlNode))
                        {
                            using (SPWeb web = site.RootWeb)
                            {
                                SPList descriptionList = web.Lists[Constant.BannerDescriptionTitle];
                                SPList assignmentList  = web.Lists[Constant.BannerAssignmentTitle];

                                EnableProgressBar       = Convert.ToBoolean(root.SelectSingleNode("EnableProgressBar").Attributes[0].InnerText)?"display:block":"display:none;";
                                ProgressColor           = root.SelectSingleNode("ProgressColor").Attributes[0].InnerText;
                                ProgressTitleColor      = root.SelectSingleNode("ProgressTitle").Attributes["Color"].InnerText;
                                ProgressTitleFontFamily = root.SelectSingleNode("ProgressTitle").Attributes["FontFamily"].InnerText;
                                ProgressTitleFontSize   = root.SelectSingleNode("ProgressTitle").Attributes["FontSize"].InnerText;

                                string currentSite       = SPContext.Current.Site.RootWeb.Url;
                                List <string> statusList = GetStatusList(root, assignmentList, currentSite);
                                SPQuery q = new SPQuery();
                                q.Query   = "<Where><And><Eq><FieldRef Name='" + Constant.ACSSite + "'></FieldRef><Value Type='Text'>" + currentSite + "</Value></Eq><Eq><FieldRef Name='" + Constant.ACSISArchived + "'></FieldRef><Value Type='Bool'>True</Value></Eq></And></Where>";
                                SPListItemCollection items = assignmentList.GetItems(q);
                                if (items.Count != 0)
                                {
                                    SPListItem item = items[0];
                                    Description     = GetMessage(item, descriptionList);
                                    RetrieveCurrentStatus(statusList, item);
                                }
                                else
                                {
                                    Description = string.Empty;
                                    APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.Verbose, string.Format("Can't find item in {0}. Site url:{1}", Constant.BannerAssignmentTitle, currentSite));
                                }
                                if (string.IsNullOrEmpty(Description))
                                {
                                    ShowDAndProgressBar = "display:none";
                                }
                                else
                                {
                                    ShowDAndProgressBar = "display:block";
                                }
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0011 Exception: {0}", ex.ToString()));
            }
        }
コード例 #2
0
 private void DealWithList(SPWeb web, string listTitle)
 {
     try
     {
         SPList list = web.Lists[listTitle];
         list.Delete();
     }
     catch (Exception e)
     {
         APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0007 Exception: {0}", e.ToString()));
     }
 }
コード例 #3
0
 private void DealWithDescriptionList(SPWeb web)
 {
     try
     {
         SPList list = web.Lists[Constant.BannerDescriptionTitle];
         AddColumn(list);
         AddColumnToDefaultView(list);
         DisableTitleColumn(list);
     }
     catch (Exception e)
     {
         APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0002 Exception: {0}", e.ToString()));
     }
 }
コード例 #4
0
 private void DealWithAssignmentList(SPWeb web)
 {
     try
     {
         SPList list = web.Lists[Constant.BannerAssignmentTitle];
         AddColumn(list);
         AddColumnToDefaultView(list);
         DisableTitleColumn(list);
         ChangeDisplayName(list, Constant.ACSSite, "Site Collection");
     }
     catch (Exception e)
     {
         APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0004 Exception: {0}", e.ToString()));
     }
 }
コード例 #5
0
        private void DisableTitleColumn(SPList list)
        {
            try
            {
                SPView view = list.DefaultView;

                SPField field = list.Fields.GetField("Title");
                if (field.Required)
                {
                    field.Required          = false;
                    field.ShowInNewForm     = false;
                    field.ShowInEditForm    = false;
                    field.ShowInDisplayForm = false;
                    field.Update();
                }
            }
            catch (Exception e)
            {
                APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0003 Exception: {0}", e.ToString()));
            }
        }
コード例 #6
0
 private string GetMessage(SPListItem item, SPList list)
 {
     try
     {
         SPQuery query = new SPQuery();
         if (item[Constant.ACSBannerName] == null)
         {
             return(string.Empty);
         }
         query.Query = "<Where><Eq><FieldRef Name='" + Constant.ACSName + "'></FieldRef><Value Type='Text'>" + item[Constant.ACSBannerName] + "</Value></Eq></Where>";
         SPListItemCollection items = list.GetItems(query);
         if (items.Count != 0)
         {
             SPListItem result = items[0];
             string     arg1   = item[Constant.ACSArg1] != null ? item[Constant.ACSArg1].ToString() : string.Empty;
             string     arg2   = item[Constant.ACSArg2] != null ? item[Constant.ACSArg2].ToString() : string.Empty;
             string     arg3   = item[Constant.ACSArg3] != null ? item[Constant.ACSArg3].ToString() : string.Empty;
             string     arg4   = item[Constant.ACSArg4] != null ? item[Constant.ACSArg4].ToString() : string.Empty;
             string     arg5   = item[Constant.ACSArg5] != null ? item[Constant.ACSArg5].ToString() : string.Empty;
             string     arg6   = item[Constant.ACSArg6] != null ? item[Constant.ACSArg6].ToString() : string.Empty;
             string     arg7   = item[Constant.ACSArg7] != null ? item[Constant.ACSArg7].ToString() : string.Empty;
             string     arg8   = item[Constant.ACSArg8] != null ? item[Constant.ACSArg8].ToString() : string.Empty;
             string     arg9   = item[Constant.ACSArg9] != null ? item[Constant.ACSArg9].ToString() : string.Empty;
             string     value  = result[Constant.ACSText].ToString().Replace("[Arg1]", arg1).Replace("[Arg2]", arg2).Replace("[Arg3]", arg3).Replace("[Arg4]", arg4).Replace("[Arg5]", arg5)
                                 .Replace("[Arg6]", arg6).Replace("[Arg7]", arg7).Replace("[Arg8]", arg8).Replace("[Arg9]", arg9);
             return(value);
         }
         else
         {
             return(string.Empty);
         }
     }
     catch (Exception ex)
     {
         APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0012 Exception: {0}", ex.ToString()));
         return(string.Empty);
     }
 }
コード例 #7
0
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            try
            {
                SPSite site = properties.Feature.Parent as SPSite;
                if (File.Exists(Constant.configPath))
                {
                    XmlDocument xml = new XmlDocument();
                    xml.Load(Constant.configPath);
                    XmlNode root    = xml.SelectSingleNode("root");
                    string  urlNode = root.SelectSingleNode("Site").Attributes[0].InnerText;

                    using (SPSite site1 = new SPSite(urlNode))
                    {
                        using (SPWeb web = site1.RootWeb)
                        {
                            if (web.ID == site.RootWeb.ID)
                            {
                                //DealWithDescriptionList(web);
                                //DealWithAssignmentList(web);
                            }
                            else
                            {
                                DealWithList(site.RootWeb, Constant.BannerDescriptionTitle);
                                DealWithList(site.RootWeb, Constant.BannerAssignmentTitle);
                            }
                        }
                    }
                }
                APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.Verbose, "Active banner solution for sp2010 successful");
            }
            catch (Exception e)
            {
                APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0001 Exception: {0}", e.ToString()));
            }
        }
コード例 #8
0
 private void AddColumn(SPList list)
 {
     try
     {
         if (list.Title.Equals(Constant.BannerDescriptionTitle))
         {
             AddColumnToList(Constant.ACSName, list);
             AddColumnToList(Constant.ACSText, list);
         }
         else
         {
             AddColumnToList(Constant.ACSSite, list);
             AddColumnToList(Constant.ACSISArchived, list);
             AddColumnToList(Constant.ACSBannerName, list);
             AddColumnToList(Constant.ACSArg1, list);
             AddColumnToList(Constant.ACSArg2, list);
             AddColumnToList(Constant.ACSArg3, list);
         }
     }
     catch (Exception e)
     {
         APPSLogger.Logger(Microsoft.SharePoint.Administration.TraceSeverity.High, string.Format("ACSSOLUTION0006 Exception: {0}", e.ToString()));
     }
 }