Ejemplo n.º 1
0
        public static RedirectionApplication GetApplicationByName(string appName)
        {
            var     web   = SPContext.Current.Web.Site.RootWeb;
            var     list  = web.Lists[Constants.FileTypesList];
            SPQuery query = new SPQuery();

            query.Query = string.Format(@"<Where>                                             
                                             <Eq>
                                               <FieldRef Name=""{0}""/>
                                                 <Value Type=""Text"">{1}</Value>
                                             </Eq>                                              
                                           </Where>", "AppInternalName", appName);
            SPListItemCollection items = list.GetItems(query);

            if ((items != null) && items.Count > 0)
            {
                SPListItem             item = items[0];
                RedirectionApplication app  = new RedirectionApplication()
                {
                    InternalName = appName,
                    DisplayName  = (string)item["AppDisplayName"],
                    FarmName     = (string)item["FarmName"]
                };
                return(app);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public static void AddFileType(string fileType, RedirectionApplication redirectionApp)
        {
            var web  = SPContext.Current.Web.Site.RootWeb;
            var list = web.Lists[Constants.FileTypesList];

            var addedItem = list.Items.Add();

            addedItem["Title"]           = fileType;
            addedItem["AppInternalName"] = redirectionApp.InternalName;
            addedItem["AppDisplayName"]  = redirectionApp.DisplayName;
            addedItem["FarmName"]        = redirectionApp.FarmName;

            addedItem.Update();
        }