Beispiel #1
0
 public static string GetFirstAvailableListViewProfile(string className)
 {
     ListViewProfile[] mas = ListViewProfile.GetSystemProfiles(className, _placeName);
     if (mas.Length == 0)
     {
         mas = ListViewProfile.GetProfiles(className, _placeName, Mediachase.IBN.Business.Security.CurrentUser.UserID);
         if (mas.Length == 0)
         {
             ListViewProfile profile = new ListViewProfile();
             profile.Id       = Guid.NewGuid().ToString();
             profile.IsPublic = true;
             profile.IsSystem = false;
             MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(className);
             profile.Name         = CHelper.GetResFileString(mc.PluralName);
             profile.FieldSetName = mc.Name;
             profile.FieldSet     = new List <string>();
             profile.FieldSet.Add(mc.TitleFieldName);
             profile.GroupByFieldName = String.Empty;
             profile.Filters          = new FilterElementCollection();
             profile.Sorting          = new SortingElementCollection();
             profile.ColumnsUI        = new ColumnPropertiesCollection();
             profile.ColumnsUI.Add(new ColumnProperties(mc.TitleFieldName, "300px", String.Empty));
             ListViewProfile.SaveCustomProfile(className, _placeName, Mediachase.IBN.Business.Security.CurrentUser.UserID, profile);
             mas = ListViewProfile.GetProfiles(className, _placeName, Mediachase.IBN.Business.Security.CurrentUser.UserID);
             if (mas.Length == 0)
             {
                 throw new Exception("ListViewProfiles are not exist!");
             }
         }
     }
     return(mas[0].Id);
 }
        private void LoadCommerceProfileViewsGroups()
        {
            ArrayList arrayList = new ArrayList();

            if (dropListUserViews.Items.Count == 0)
            {
                ListViewProfile[] systemProfiles = ListViewProfile.GetSystemProfiles(MetaClassName, "EntityList");
                List <KeyValuePair <string, string> > allCustomerViews = new List <KeyValuePair <string, string> >();
                foreach (ListViewProfile listViewProfile in systemProfiles)
                {
                    arrayList.Add((object)listViewProfile.Id);
                    string name = listViewProfile.Name;
                    if (name.StartsWith("{"))
                    {
                        name = name.Replace("{", "");
                        name = name.Replace("}", "");
                        name = name.Replace(":", "_");
                        name = LocalizationService.Current.GetString("/bvnetwork/sendmail/plugin/commerce/" + name);
                    }
                    allCustomerViews.Add(new KeyValuePair <string, string>(listViewProfile.Id, "  " + name));
                }

                ListViewProfile[] userProfiles = ListViewProfile.GetProfiles(MetaClassName, "EntityList",
                                                                             PrincipalInfo.CurrentPrincipal.GetContactId());

                foreach (ListViewProfile listViewProfile in userProfiles)
                {
                    if (!arrayList.Contains((object)listViewProfile.Id))
                    {
                        allCustomerViews.Add(new KeyValuePair <string, string>(listViewProfile.Id,
                                                                               "  " + listViewProfile.Name));
                    }
                }
                dropListUserViews.DataSource     = allCustomerViews;
                dropListUserViews.DataTextField  = "Value";
                dropListUserViews.DataValueField = "Key";
                dropListUserViews.DataBind();
            }
        }
Beispiel #3
0
        private void BindProfiles()
        {
            ddProfiles.Items.Clear();

            ArrayList list = new ArrayList();

            ListViewProfile[] mas = ListViewProfile.GetSystemProfiles(ClassName, _placeName);

            List <KeyValuePair <string, string> > summaryList = new List <KeyValuePair <string, string> >();

            foreach (ListViewProfile lvp in mas)
            {
                summaryList.Add(new KeyValuePair <string, string>(lvp.Id, "  " + CHelper.GetResFileString(lvp.Name)));
                list.Add(lvp.Id);
            }

            summaryList.Sort
            (
                delegate(KeyValuePair <string, string> kvp1,
                         KeyValuePair <string, string> kvp2)
            {
                return(Comparer <string> .Default.Compare(kvp1.Value, kvp2.Value));
            }
            );
            if (mas.Length > 0)
            {
                summaryList.Insert(0, new KeyValuePair <string, string>("-1", String.Format("[ {0} ]", GetGlobalResourceObject("IbnFramework.Incident", "SystemViews").ToString())));
            }

            ListViewProfile[] mas2 = ListViewProfile.GetProfiles(ClassName, _placeName, Mediachase.Ibn.Data.Services.Security.CurrentUserId);

            List <KeyValuePair <string, string> > summaryList2 = new List <KeyValuePair <string, string> >();

            foreach (ListViewProfile lvp in mas2)
            {
                if (!list.Contains(lvp.Id))
                {
                    summaryList2.Add(new KeyValuePair <string, string>(lvp.Id, "  " + CHelper.GetResFileString(lvp.Name)));
                }
            }

            summaryList2.Sort
            (
                delegate(KeyValuePair <string, string> kvp1,
                         KeyValuePair <string, string> kvp2)
            {
                return(Comparer <string> .Default.Compare(kvp1.Value, kvp2.Value));
            }
            );

            if (summaryList2.Count > 0)
            {
                summaryList.Add(new KeyValuePair <string, string>("-2", String.Format("[ {0} ]", GetGlobalResourceObject("IbnFramework.Incident", "UserViews").ToString())));
                summaryList.AddRange(summaryList2);
            }
            summaryList.Add(new KeyValuePair <string, string>("0", String.Format("[ {0} ]", GetGlobalResourceObject("IbnFramework.Incident", "NewIssueView").ToString())));

            ddProfiles.DataSource     = summaryList;
            ddProfiles.DataTextField  = "Value";
            ddProfiles.DataValueField = "Key";
            ddProfiles.DataBind();

            foreach (ListItem liItem in ddProfiles.Items)
            {
                if (liItem.Value == "-1" || liItem.Value == "-2")
                {
                    liItem.Enabled = false;
                    liItem.Attributes.Add("style", "color:#646464;");
                }
                if (liItem.Value == "0")
                {
                    liItem.Attributes.Add("style", "color:#333333;font-weight:bold;");
                }
            }

            HtmlLink linkRss = (HtmlLink)this.Page.FindControl("rssLink");

            if (linkRss != null)
            {
                linkRss.Href = "";
                linkRss.Attributes.Add("title", string.Empty);
            }
        }