Exemplo n.º 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;
 }
Exemplo n.º 2
0
        public string GetGroupFieldForView(ListViewProfile lvp)
        {
            if (_pc[_pc[ProjectListViewNameKey] + "_" + ProjectListGroupFieldKey] == null)
            {
                _pc[_pc[ProjectListViewNameKey] + "_" + ProjectListGroupFieldKey] = lvp.GroupByFieldName;
            }

            if (!Page.IsPostBack)
                _pc[_pc[ProjectListViewNameKey] + "_" + ProjectListGroupFieldKey] = lvp.GroupByFieldName;

            return _pc[_pc[ProjectListViewNameKey] + "_" + ProjectListGroupFieldKey];
        }
Exemplo n.º 3
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            InitializeGlobalContext();

            // Subscribe to transaction events
            DatabaseTransactionBridge.Init();
            Mediachase.Ibn.Lists.AlertManager.Init();

            // Code that runs on application startup
            Application["ComponentArtWebUI_AppKey"] = "This edition of ComponentArt Web.UI is licensed for Instant Business Network application only.";

            //InitializeDatabase();

            ControlPathResolver current = new ControlPathResolver();

            current.Init(new string[] {
                "~/Apps/MetaDataBase/Primitives/"
                , "~/Apps/MetaUI/Primitives/"
                , "~/Apps/MetaUIEntity/Primitives/"
                , "~/Apps/Security/Primitives/"
                , "~/Apps/BusinessProcess/Primitives/"
                , "~/Apps/TimeTracking/Primitives/"
                , "~/Apps/ListApp/Primitives/"
                , "~/Apps/ClientManagement/Primitives/"
                , "~/Apps/DocumentManagement/Primitives/"
                , "~/Apps/ReportManagement/Primitives/"
                , "~/Apps/IbnDirectory/Primitives/"
                , "~/Apps/Calendar/Primitives/"
                , "~/Apps/Administration/Primitives/"
                , "~/Apps/WidgetEngine/Primitives/"
            });
            ControlPathResolver.Current = current;

            McScriptLoader mcLoader = new McScriptLoader();

            mcLoader.Init();
            McScriptLoader.Current = mcLoader;


            Mediachase.Ibn.Data.Services.Security.PrincipalGroupsResolving = Mediachase.IBN.Business.User.GetListSecureGroupAllArray;

            Mediachase.IbnNext.TimeTracking.TimeTrackingManager.Init();

            ListViewProfile.Init();

            FormController.Init();
        }
Exemplo n.º 4
0
        private void BindSavedValues()
        {
            ListViewProfile profile = ListViewProfile.Load(_className, _uid, _placeName);

            txtTitle.Text      = profile.Name;
            cbIsPublic.Checked = profile.IsPublic;
            int weight = 0;

            foreach (string name in profile.FieldSet)
            {
                ListItem liItem = ListSelector.Items.FindByValue(name);
                if (liItem != null)
                {
                    liItem.Selected = true;
                    liItem.Attributes.Add("Weight", (weight++).ToString());
                }
            }
        }
Exemplo n.º 5
0
        protected void grdMain_RowCommand(object source, DataGridCommandEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (e.CommandName == ConstDeleteCommand)
            {
                string id = e.CommandArgument.ToString();
                ListViewProfile.DeleteCustomProfile(ClassName, id, PlaceName);
            }
            else if (e.CommandName == ConstResetCommand)
            {
                string id = e.CommandArgument.ToString();
                //TODO - reset
            }

            CHelper.RequireDataBind();
        }
Exemplo n.º 6
0
        private void CreateRelation(string primaryClassName, string relatedClassName, string fieldName, string fieldFriendlyName, bool allowNulls, string sectionName, string displayText, string displayOrder, MetaFormSelector mfs)
        {
            if (sectionName == notSetValue || ListManager.MetaClassIsList(primaryClassName))
            {
                sectionName  = string.Empty;
                displayText  = string.Empty;
                displayOrder = string.Empty;
            }

            MetaField newField = MetaDataWrapper.CreateReference(primaryClassName, relatedClassName, fieldName, fieldFriendlyName, allowNulls, sectionName, displayText, displayOrder);

            //add to the forms
            if (newField != null)
            {
                List <FormDocument> metaForms = mfs.MetaForms;
                foreach (FormDocument fd in metaForms)
                {
                    if (HistoryManager.MetaClassIsHistory(fd.MetaClassName) && !HistoryManager.IsSupportedField(fd.MetaClassName, newField.Name))
                    {
                        continue;
                    }
                    FormController.AddMetaPrimitive(fd.MetaClassName, fd.Name, newField.Name);
                }

                List <string> profiles = mfs.ListProfiles;
                foreach (string profId in profiles)
                {
                    string          placeName = "EntityList";
                    ListViewProfile profile   = ListViewProfile.Load(primaryClassName, profId, placeName);
                    if (profile != null)
                    {
                        profile.FieldSet.Add(newField.Name);
                        profile.ColumnsUI.Add(new ColumnProperties(newField.Name, "200px", String.Empty));

                        ListViewProfile.SaveSystemProfile(primaryClassName, placeName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, profile);
                    }
                }
            }
        }
Exemplo n.º 7
0
        internal void SaveListViewProfiles()
        {
            foreach (MetaViewPreferenceInfo preferenceInfo in _preferences)
            {
                ListViewProfile profile = new ListViewProfile();

                profile.Id = Guid.NewGuid().ToString("D");
                profile.Name = "{IbnFramework.ListInfo:lvpGeneralView}";
                profile.IsPublic = true;
                profile.FieldSet.AddRange(_availableFieldNames);

                // Build columns list
                foreach (ColumnInfo columnInfo in preferenceInfo.GetColumns())
                {
                    profile.ColumnsUI.Add(new ColumnProperties(columnInfo.Name, columnInfo.Width.ToString(CultureInfo.InvariantCulture), string.Empty));
                }

                string placeName = (_metaClassName.EndsWith("_History", StringComparison.Ordinal)) ? "ItemHistoryList" : "EntityList";

                ListViewProfile.SaveSystemProfile(_metaClassName, placeName, -1, profile);
            }
        }
        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();
            }
        }
Exemplo n.º 9
0
        internal void SaveListViewProfiles()
        {
            foreach (MetaViewPreferenceInfo preferenceInfo in _preferences)
            {
                ListViewProfile profile = new ListViewProfile();

                profile.Id       = Guid.NewGuid().ToString("D");
                profile.Name     = "{IbnFramework.ListInfo:lvpGeneralView}";
                profile.IsPublic = true;
                profile.FieldSet.AddRange(_availableFieldNames);

                // Build columns list
                foreach (ColumnInfo columnInfo in preferenceInfo.GetColumns())
                {
                    profile.ColumnsUI.Add(new ColumnProperties(columnInfo.Name, columnInfo.Width.ToString(CultureInfo.InvariantCulture), string.Empty));
                }

                string placeName = (_metaClassName.EndsWith("_History", StringComparison.Ordinal)) ? "ItemHistoryList" : "EntityList";

                ListViewProfile.SaveSystemProfile(_metaClassName, placeName, -1, profile);
            }
        }
Exemplo n.º 10
0
        protected override void ExecuteInternal(IProgressMessenger progressMessenger)
        {
            using (var scope = DataContext.Current.MetaModel.BeginEdit(MetaClassManagerEditScope.SystemOwner, Mediachase.BusinessFoundation.Data.Meta.Management.AccessLevel.System))
            {
                var manager = DataContext.Current.MetaModel;
                var changeTrackingManifest  = ChangeTrackingManager.CreateModuleManifest();
                var recentReferenceManifest = RecentReferenceManager.CreateModuleManifest();
                var contactMetaClass        = manager.MetaClasses[ContactEntity.ClassName];

                var demoUserMenu = MetaEnum.Create("DemoUserMenu", "Show in Demo User Menu", false);
                MetaEnum.AddItem(demoUserMenu, 1, "Never", 1);
                MetaEnum.AddItem(demoUserMenu, 2, "Always", 2);
                MetaEnum.AddItem(demoUserMenu, 3, "Commerce Only", 3);

                using (var builder = new MetaFieldBuilder(contactMetaClass))
                {
                    builder.CreateEnumField("ShowInDemoUserMenu", "{Customer:DemoUserMenu}", "DemoUserMenu", true, "1", false);
                    builder.CreateText("DemoUserTitle", "{Customer:DemoUserTitle}", true, 100, false);
                    builder.CreateText("DemoUserDescription", "{Customer:DemoUserDescription}", true, 500, false);
                    builder.SaveChanges();
                }

                AddMetaFieldToForms(contactMetaClass, contactMetaClass.Fields["ShowInDemoUserMenu"]);
                AddMetaFieldToForms(contactMetaClass, contactMetaClass.Fields["DemoUserTitle"]);
                AddMetaFieldToForms(contactMetaClass, contactMetaClass.Fields["DemoUserDescription"]);

                var giftCardClass = manager.CreateMetaClass("GiftCard", "{Customer:GiftCard}", "{Customer:GiftCard}", "cls_GiftCard", PrimaryKeyIdValueType.Guid);
                ModuleManager.Activate(giftCardClass, changeTrackingManifest);
                using (var builder = new MetaFieldBuilder(giftCardClass))
                {
                    builder.CreateText("GiftCardName", "{Customer:GiftCardName}", false, 100, false);
                    builder.CreateCurrency("InitialAmount", "{Customer:InitialAmount}", true, 0, true);
                    builder.CreateCurrency("RemainBalance", "{Customer:RemainBalance}", true, 0, true);
                    builder.CreateText("RedemptionCode", "{Customer:RedemptionCode}", true, 100, false);
                    builder.CreateCheckBoxBoolean("IsActive", "{Customer:IsActive}", true, true, "{Customer:IsActive}");
                    giftCardClass.Fields[MetaClassManager.GetPrimaryKeyName(giftCardClass.Name)].FriendlyName = "{GlobalMetaInfo:PrimaryKeyId}";
                    var contactReference = builder.CreateReference("Contact", "{Customer:CreditCard_mf_Contact}", true, "Contact", false);
                    contactReference.Attributes.Add(McDataTypeAttribute.ReferenceDisplayBlock, "InfoBlock");
                    contactReference.Attributes.Add(McDataTypeAttribute.ReferenceDisplayText, "{Customer:GiftCard}");
                    contactReference.Attributes.Add(McDataTypeAttribute.ReferenceDisplayOrder, "10000");
                    builder.SaveChanges();
                }
                giftCardClass.AddPermissions();

                AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["GiftCardName"]);
                AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["InitialAmount"]);
                AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["RemainBalance"]);
                AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["RedemptionCode"]);
                AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["IsActive"]);
                AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["ContactId"]);

                scope.SaveChanges();
            }

            var contactProfile = @"<ListViewProfile xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                    <Id>{54a649a9-302f-48bd-b657-11ca3604fda9}</Id>
                    <Name>{Customer:AllContacts}</Name>
                    <IsSystem>true</IsSystem>
                    <IsPublic>true</IsPublic>
                    <FieldSetName>Contacts</FieldSetName>
                   <FieldSet>
                    <string>FullName</string>
                    <string>Email</string>
                    <string>LastOrder</string>
                    <string>NumberOfOrders</string>
                    <string>NumberOfReviews</string>
                    <string>Points</string>
                    <string>ShowInDemoUserMenu</string>
                    <string>DemoUserTitle</string>
                  </FieldSet>
                  <GroupByFieldName />
                  <Filters />
                  <Sorting />
                  <ColumnsUI>
                    <Column field=""FullName"" width=""150"" />
                    <Column field=""Email"" width=""150"" />
                    <Column field=""LastOrder"" width=""150"" />
                    <Column field=""NumberOfOrders"" width=""150"" />
                    <Column field=""NumberOfReviews"" width=""150"" />
                    <Column field=""Points"" width=""150"" />
                    <Column field=""ShowInDemoUserMenu"" width=""150"" />
                    <Column field=""DemoUserTitle"" width=""150"" />
                  </ColumnsUI>
                </ListViewProfile>";

            var contactviewProfile = (ListViewProfile)_listViewProfileXmlSerializer.Deserialize(new StringReader(contactProfile));

            ListViewProfile.SaveSystemProfile("Contact", "EntityList", Guid.NewGuid(), contactviewProfile);

            using (var stream = new FileStream(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Customers.xml"), FileMode.Open))
            {
                ProcessCustomers(stream);
                ProcessOrganizations(stream);
            }
        }
Exemplo n.º 11
0
        private void BindSavedValues()
        {
            ListViewProfile profile = ListViewProfile.Load(_className, _uid, String.Empty);

            CHelper.SafeSelect(ddFieldSets, profile.FieldSetName);
            CHelper.SafeSelect(ddGroupField, String.IsNullOrEmpty(profile.GroupByFieldName) ? Incident.AvailableGroupField.NotSet.ToString() : profile.GroupByFieldName);
            txtTitle.Text      = profile.Name;
            cbIsPublic.Checked = profile.IsPublic;

            #region Filters
            FilterElementCollection fec = profile.Filters;
            foreach (FilterElement fe in fec)
            {
                switch (fe.Source)
                {
                case Incident.ProjectFilterKey:
                    CHelper.SafeSelect(ddlProject, fe.Value.ToString());
                    break;

                case Incident.ManagerFilterKey:
                    CHelper.SafeSelect(ddManager, fe.Value.ToString());
                    break;

                case Incident.ResponsibleFilterKey:
                    CHelper.SafeSelect(ddResponsible, fe.Value.ToString());
                    break;

                case Incident.CreatorFilterKey:
                    CHelper.SafeSelect(ddCreatedBy, fe.Value.ToString());
                    break;

                case Incident.PriorityFilterKey:
                    CHelper.SafeSelect(ddPriority, fe.Value.ToString());
                    break;

                case Incident.IssueBoxFilterKey:
                    CHelper.SafeSelect(ddIssBox, fe.Value.ToString());
                    break;

                case Incident.TypeFilterKey:
                    CHelper.SafeSelect(ddType, fe.Value.ToString());
                    break;

                case Incident.ClientFilterKey:
                    PrimaryKeyId orgUid     = PrimaryKeyId.Empty;
                    PrimaryKeyId contactUid = PrimaryKeyId.Empty;
                    Incident.GetContactId(fe.Value.ToString(), out orgUid, out contactUid);
                    if (orgUid != PrimaryKeyId.Empty)
                    {
                        try {
                            Mediachase.Ibn.Core.Business.BusinessManager.Load(OrganizationEntity.GetAssignedMetaClassName(), orgUid);
                            ClientControl.ObjectId   = orgUid;
                            ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                        }
                        catch { }
                    }
                    else if (contactUid != PrimaryKeyId.Empty)
                    {
                        try
                        {
                            Mediachase.Ibn.Core.Business.BusinessManager.Load(ContactEntity.GetAssignedMetaClassName(), contactUid);
                            ClientControl.ObjectId   = contactUid;
                            ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                        }
                        catch { }
                    }
                    break;

                case Incident.StatusFilterKey:
                    CHelper.SafeSelect(ddState, fe.Value.ToString());
                    break;

                case Incident.SeverityFilterKey:
                    CHelper.SafeSelect(ddSeverity, fe.Value.ToString());
                    break;

                case Incident.GenCategoryTypeFilterKey:
                    CHelper.SafeSelect(ddGenCatType, fe.Value.ToString());
                    //todo - gen category filter view
                    break;

                case Incident.GenCategoriesFilterKey:
                    string[] mas = fe.Value.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in mas)
                    {
                        CHelper.SafeMultipleSelect(lbGenCats, s);
                    }
                    //todo - gen category filter view
                    break;

                case Incident.IssueCategoryTypeFilterKey:
                    CHelper.SafeSelect(ddIssCatType, fe.Value.ToString());
                    //todo - gen category filter view
                    break;

                case Incident.IssueCategoriesFilterKey:
                    string[] mas1 = fe.Value.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in mas1)
                    {
                        CHelper.SafeMultipleSelect(lbIssCats, s);
                    }
                    //todo - gen category filter view
                    break;

                case Incident.UnansweredFilterKey:
                    cbOnlyNewMess.Checked = bool.Parse(fe.Value.ToString());
                    break;

                case Incident.OverdueFilterKey:
                    cbOnlyOverdue.Checked = bool.Parse(fe.Value.ToString());
                    break;

                default:
                    break;
                }
            }
            #endregion
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region PreInit Parameters
            //получить ListViewProfiles и заполнить поля _isGroupSet и _groupFieldName
            _profileName = GetProfileName(_pc, _className);
            ListViewProfile lvp = ListViewProfile.Load(_className, _profileName, _placeName);
            if (lvp == null)
            {
                _profileName = GetFirstAvailableListViewProfile(_className);
                SetProfileName(_pc, _className, _profileName);
                lvp = ListViewProfile.Load(_className, _profileName, _placeName);
            }
            _isGroupSet     = !String.IsNullOrEmpty(lvp.GroupByFieldName);
            _groupFieldName = GetGroupFieldForProfile(lvp);
            #endregion

            //для вида с группировкой показываем левую панель
            if (_isGroupSet)
            {
                DockLeft.DefaultSize = 230;
            }
            else
            {
                DockLeft.DefaultSize = 0;
            }

            //для вида с группировкой показываем левую панель
            //if (lvp.Filters.Count > 0)
            //{
            //    trFilterText.Visible = true;
            //    DockTop.DefaultSize = 101;
            //}
            //else
            //{
            trFilterText.Visible = false;
            DockTop.DefaultSize  = 74;
            //}

            #region Init MCGrid, Toolbar
            grdMain.ChangingEntityGridColumnHeader += new ChangingEntityGridColumnHeaderEventHandler(grdMain_ChangingEntityGridColumnHeader);
            //инициализируем грид
            grdMain.ClassName   = _className;
            grdMain.ViewName    = _viewName;
            grdMain.PlaceName   = _placeName;
            grdMain.ProfileName = _profileName;

            ctrlGridEventUpdater.ClassName = _className;
            ctrlGridEventUpdater.ViewName  = _viewName;
            ctrlGridEventUpdater.PlaceName = _placeName;
            ctrlGridEventUpdater.GridId    = grdMain.GridClientContainerId;

            //инициализируем тулбар
            MainMetaToolbar.ClassName   = _className;
            MainMetaToolbar.ViewName    = _viewName;
            MainMetaToolbar.PlaceName   = _placeName;
            MainMetaToolbar.ToolbarMode = Mediachase.Ibn.Web.UI.MetaUI.Toolbar.MetaToolbar.Mode.ListViewUI;
            #endregion

            if (!Page.IsPostBack)
            {
                //устанавливаем в key-textbox запомненные значения
                BindSavedValues();
                //биндим если надо группы в левой панели
                BindGroupDataList();
            }

            int folderId = GetCurrentFolderId();
            CHelper.AddToContext("ListFolderId", folderId);

            //биндим датагрид
            BindDataGrid(!Page.IsPostBack);

            //set header text
            if (!Page.IsPostBack)
            {
                BindBlockHeader();
            }

            #region CommandManager PreLoad
            CommandManager cm = CommandManager.GetCurrent(this.Page);
            cm.AddCommand(_className, _viewName, _placeName, "MC_ListApp_ChangeFolderTree");
            #endregion
        }
Exemplo n.º 13
0
        public static string GetHistorySystemListViewProfile(string historyClassName, string placeName)
        {
            ListViewProfile[] mas = ListViewProfile.GetSystemProfiles(historyClassName, placeName);
            if (mas.Length == 0)
            {
                ListViewProfile profile = new ListViewProfile();
                profile.Id = Guid.NewGuid().ToString();
                profile.IsPublic = true;
                profile.IsSystem = true;
                MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(historyClassName);
                profile.Name = CHelper.GetResFileString(mc.PluralName);
                profile.FieldSetName = mc.Name;

                MetaClass mc2 = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(HistoryManager.GetOriginalMetaClassName(historyClassName));
                HistoryMetaClassInfo historyInfo = HistoryManager.GetInfo(mc2);
                Collection<string> selectedFields = historyInfo.SelectedFields;

                profile.FieldSet = new List<string>();
                profile.ColumnsUI = new ColumnPropertiesCollection();
                profile.FieldSet.Add(ChangeDetectionService.ModifiedFieldName);
                profile.FieldSet.Add(mc2.TitleFieldName);
                profile.ColumnsUI.Add(new ColumnProperties(ChangeDetectionService.ModifiedFieldName, "200px", String.Empty));
                profile.ColumnsUI.Add(new ColumnProperties(mc2.TitleFieldName, "200px", String.Empty));
                foreach (string fieldName in selectedFields)
                {
                    if (fieldName == mc2.TitleFieldName || fieldName == ChangeDetectionService.ModifiedFieldName)
                        continue;
                    profile.FieldSet.Add(fieldName);
                    profile.ColumnsUI.Add(new ColumnProperties(fieldName, "200px", String.Empty));
                }
                profile.GroupByFieldName = String.Empty;
                FilterElementCollection fec = new FilterElementCollection();
                FilterElement fe = new FilterElement();
                fe.ValueIsTemplate = true;
                fe.Source = "ObjectId";
                fe.Value = "{QueryString:ObjectId}";
                fec.Add(fe);
                profile.Filters = fec;
                profile.Sorting = new SortingElementCollection();

                ListViewProfile.SaveSystemProfile(historyClassName, placeName, Mediachase.IBN.Business.Security.CurrentUser.UserID, profile);
                mas = ListViewProfile.GetSystemProfiles(historyClassName, placeName);
                if (mas.Length == 0)
                    throw new Exception("ListViewProfiles are not exist!");
            }
            return mas[0].Id;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Handles the ServerClick event of the SaveButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void SaveButton_ServerClick(object sender, EventArgs e)
        {
            if (FormatList.Items.Count < 0)
            {
                throw new Exception("Format is not specified");
            }

            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            Mediachase.Ibn.Data.Meta.Management.AttributeCollection attr = new Mediachase.Ibn.Data.Meta.Management.AttributeCollection();
            string sDefaultValue = String.Empty;

            if (MainPlaceHolder.Controls.Count > 0)
            {
                IManageControl control = MainPlaceHolder.Controls[0] as IManageControl;

                if (control != null)
                {
                    sDefaultValue = control.GetDefaultValue(AllowNullsCheckBox.Checked);
                    attr          = control.FieldAttributes;
                }
            }

            if (!AllowNullsCheckBox.Checked && sDefaultValue == String.Empty)
            {
                ErrorMessage.Text = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "ErrorMessage_AllowNulls").ToString();
                return;
            }

            if (sDefaultValue == null)
            {
                sDefaultValue = String.Empty;
            }

            string sFriendlyName = FriendlyNameTextBox.Text.Trim();

            if (mf == null)
            {
                string sName;
                if (!AutogenerateSystemNames)
                {
                    sName = NameTextBox.Text.Trim();
                }
                else
                {
                    // Generate the field name as the number of seconds elapsed since 2000-01-01
                    sName = String.Format(CultureInfo.InvariantCulture, "Field{0}", CHelper.GetDateDiffInSeconds(DateTime.UtcNow, new DateTime(2000, 1, 1)));
                }

                try
                {
                    string typeName = FormatList.SelectedValue;
                    //NewEnum
                    if (attr.ContainsKey("NewEnum"))
                    {
                        string    name         = attr["EnumName"].ToString();
                        string    friendlyname = attr["EnumFriendlyName"].ToString();
                        bool      isPrivate    = (bool)attr["EnumPrivate"];
                        DataTable dt           = (DataTable)attr["EnumDataSource"];

                        attr.Remove("NewEnum");
                        attr.Remove("EnumName");
                        attr.Remove("EnumFriendlyName");
                        attr.Remove("EnumPrivate");
                        attr.Remove("EnumDataSource");

                        MetaFieldType type = MetaEnum.Create(name, friendlyname, false);
                        if (isPrivate)
                        {
                            type.Attributes.Add(McDataTypeAttribute.EnumPrivate, mc.Name);
                        }

                        SortedList sl = new SortedList();
                        foreach (DataRow dr in dt.Rows)
                        {
                            sl.Add((int)dr["OrderId"], dr["Name"].ToString().Trim());
                        }

                        foreach (int i in sl.Keys)
                        {
                            MetaEnum.AddItem(type, sl[i].ToString(), i);
                        }

                        typeName = type.Name;
                    }
                    //NewMultiEnum
                    if (attr.ContainsKey("NewMultiEnum"))
                    {
                        string    name         = attr["EnumName"].ToString();
                        string    friendlyname = attr["EnumFriendlyName"].ToString();
                        bool      isPrivate    = (bool)attr["EnumPrivate"];
                        DataTable dt           = (DataTable)attr["EnumDataSource"];

                        attr.Remove("NewMultiEnum");
                        attr.Remove("EnumName");
                        attr.Remove("EnumFriendlyName");
                        attr.Remove("EnumPrivate");
                        attr.Remove("EnumDataSource");

                        MetaFieldType type = MetaEnum.Create(name, friendlyname, true);
                        if (isPrivate)
                        {
                            type.Attributes.Add(McDataTypeAttribute.EnumPrivate, mc.Name);
                        }

                        SortedList sl = new SortedList();
                        foreach (DataRow dr in dt.Rows)
                        {
                            sl.Add((int)dr["OrderId"], dr["Name"].ToString().Trim());
                        }

                        foreach (int i in sl.Keys)
                        {
                            MetaEnum.AddItem(type, sl[i].ToString(), i);
                        }

                        typeName = type.Name;
                    }

                    MetaFieldType mft = DataContext.Current.MetaModel.RegisteredTypes[FormatList.SelectedValue];
                    if (mft != null && mft.McDataType == McDataType.Enum &&
                        attr.ContainsKey("EnumFriendlyName"))
                    {
                        mft.FriendlyName = attr["EnumFriendlyName"].ToString();
                        attr.Remove("EnumFriendlyName");
                    }

                    MetaField newField = null;
                    if (FieldTypeList.SelectedValue == McDataType.Reference.ToString())
                    {
                        newField = MetaDataWrapper.CreateReference(mc, attr, sName, sFriendlyName, AllowNullsCheckBox.Checked);
                        if (attr.ContainsKey(McDataTypeAttribute.ReferenceUseSecurity))
                        {
                            Mediachase.Ibn.Data.Services.Security.AddObjectRolesFromReference(newField);
                        }
                    }
                    else if (FieldTypeList.SelectedValue == McDataType.ReferencedField.ToString())
                    {
                        newField = MetaDataWrapper.CreateReferencedField(mc, attr, sName, sFriendlyName);
                    }
                    else if (FieldTypeList.SelectedValue == McDataType.BackReference.ToString())
                    {
                        newField = MetaDataWrapper.CreateBackReference(mc, attr, sName, sFriendlyName);
                    }
                    else
                    {
                        newField = MetaDataWrapper.CreateMetaField(mc, attr, sName, sFriendlyName, typeName, AllowNullsCheckBox.Checked, sDefaultValue);
                    }

                    //add to the forms
                    if (newField != null)
                    {
                        List <FormDocument> metaForms = mfs.MetaForms;
                        foreach (FormDocument fd in metaForms)
                        {
                            if (HistoryManager.MetaClassIsHistory(fd.MetaClassName) && !HistoryManager.IsSupportedField(mc.Name, newField.Name))
                            {
                                continue;
                            }
                            FormController.AddMetaPrimitive(fd.MetaClassName, fd.Name, newField.Name);
                        }

                        List <string> profiles = mfs.ListProfiles;
                        foreach (string profId in profiles)
                        {
                            string          placeName = "EntityList";
                            ListViewProfile profile   = ListViewProfile.Load(mc.Name, profId, placeName);
                            if (profile != null)
                            {
                                profile.FieldSet.Add(newField.Name);
                                profile.ColumnsUI.Add(new ColumnProperties(newField.Name, "200px", String.Empty));

                                ListViewProfile.SaveSystemProfile(mc.Name, placeName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, profile);
                            }
                        }

                        //using (MetaClassManagerEditScope editScope = DataContext.Current.MetaModel.BeginEdit())
                        //{
                        //    List<string> metaViews = mfs.MetaViews;
                        //    foreach (string viewName in metaViews)
                        //    {
                        //        MetaView metaView = DataContext.Current.MetaModel.MetaViews[viewName];
                        //        if (HistoryManager.MetaClassIsHistory(metaView.MetaClassName) && !HistoryManager.IsSupportedField(metaView.MetaClassName, newField.Name))
                        //            continue;
                        //        McMetaViewPreference pref = UserMetaViewPreference.Load(metaView, (int)DataContext.Current.CurrentUserId);
                        //        if (pref == null || pref.Attributes.Count == 0)
                        //        {
                        //            McMetaViewPreference.CreateDefaultUserPreference(metaView);
                        //            pref = UserMetaViewPreference.Load(metaView, (int)DataContext.Current.CurrentUserId);
                        //        }
                        //        int counter = metaView.AvailableFields.Count;
                        //        metaView.AvailableFields.Add(metaView.MetaClass.Fields[newField.Name]);
                        //        pref.SetAttribute<int>(newField.Name, McMetaViewPreference.AttrIndex, counter);
                        //        pref.SetAttribute<int>(newField.Name, McMetaViewPreference.AttrWidth, 100);
                        //    }

                        //    editScope.SaveChanges();
                        //}
                    }

                    Response.Redirect(String.Format("{0}?class={1}", ReturnUrl, mc.Name), true);
                }
                catch (MetaFieldAlreadyExistsException)
                {
                    ErrorLabel.Text    = String.Format(GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "FieldExistsErrorMessage").ToString(), "'" + sName + "'");
                    ErrorLabel.Visible = true;
                }

                /*              catch (SqlException sqlException)
                 *                              {
                 *                                      if (sqlException.Number == 1505)	// Duplication key
                 *                                              ErrorLabel.Text = ex.Message;
                 *                                      else
                 *                                              ErrorLabel.Text = ex.Message;
                 *                                      ErrorLabel.Visible = true;
                 *                              }
                 */
            }
            else             // Update
            {
                MetaFieldType mft = DataContext.Current.MetaModel.RegisteredTypes[FormatList.SelectedValue];
                if (mft.McDataType == McDataType.Enum && attr.ContainsKey("EnumFriendlyName"))
                {
                    mft.FriendlyName = attr["EnumFriendlyName"].ToString();
                    attr.Remove("EnumFriendlyName");
                }

                if (FieldTypeList.SelectedValue == McDataType.Reference.ToString() ||
                    FieldTypeList.SelectedValue == McDataType.BackReference.ToString() ||
                    FieldTypeList.SelectedValue == McDataType.ReferencedField.ToString())
                {
                    MetaDataWrapper.UpdateMetaFieldFriendlyName(mf, sFriendlyName);
                }
                else
                {
                    MetaDataWrapper.UpdateMetaField(mf, attr, sFriendlyName, sDefaultValue);
                }

                Response.Redirect(String.Format("{0}?class={1}", ReturnUrl, mc.Name), true);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Resolves the list view profile.
        /// </summary>
        private void ResolveListViewProfile()
        {
            this.CurrentProfile = null;

            if (!string.IsNullOrEmpty(this.Parameters.CurrentView))
            {
                this.CurrentProfile = ListViewProfile.Load(this.Parameters.ClassName, this.Parameters.CurrentView, "EntityList");
            }
        }
Exemplo n.º 16
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                ListViewProfile profile;
                if (!String.IsNullOrEmpty(_uid))
                    profile = ListViewProfile.Load(_className, _uid, _placeName);
                else
                    profile = new ListViewProfile();
                //fields
                List<string> fields = new List<string>();
                ColumnPropertiesCollection coll = new ColumnPropertiesCollection();
                List<ListItem> items = ListSelector.GetSelectedItems();
                foreach (ListItem item in items)
                {
                    fields.Add(item.Value);
                    coll.Add(new ColumnProperties(item.Value, "150", String.Empty));
                }
                profile.FieldSet = fields;
                profile.ColumnsUI = coll;

                string uid = (!String.IsNullOrEmpty(_uid)) ? _uid : Guid.NewGuid().ToString();
                profile.Id = uid;

                profile.Name = txtTitle.Text;
                profile.ReadOnly = false;

                int currentUserId = Mediachase.Ibn.Data.Services.Security.CurrentUserId;

                if (_isSystem)
                {
                    profile.IsSystem = true;
                    profile.IsPublic = true;
                    ListViewProfile.SaveSystemProfile(_className, _placeName, currentUserId, profile);
                }
                else
                {
                    profile.IsSystem = false;
                    profile.IsPublic = cbIsPublic.Checked;
                    ListViewProfile.SaveCustomProfile(_className, _placeName, currentUserId, profile);
                }
                SaveFilters(uid);

                CommandParameters cp = new CommandParameters(_commandName);
                cp.CommandArguments = new System.Collections.Generic.Dictionary<string, string>();
                cp.AddCommandArgument("ViewUid", uid);
                cp.AddCommandArgument("ClassName", _className);
                cp.AddCommandArgument("PlaceName", _placeName);
                Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString());
            }
        }
Exemplo n.º 17
0
        private void BindSavedValues()
        {
            ListViewProfile profile = ListViewProfile.Load(_className, _uid, String.Empty);

            CHelper.SafeSelect(ddFieldSets, profile.FieldSetName);
            CHelper.SafeSelect(ddGroupField, String.IsNullOrEmpty(profile.GroupByFieldName) ? Project.AvailableGroupField.NotSet.ToString() : profile.GroupByFieldName);
            txtTitle.Text      = profile.Name;
            cbIsPublic.Checked = profile.IsPublic;

            #region Filters
            FilterElementCollection fec = profile.Filters;
            foreach (FilterElement fe in fec)
            {
                switch (fe.Source)
                {
                case Project.StatusFilterKey:
                    CHelper.SafeSelect(ddStatus, fe.Value.ToString());
                    break;

                case Project.PhaseFilterKey:
                    CHelper.SafeSelect(ddPrjPhases, fe.Value.ToString());
                    break;

                case Project.TypeFilterKey:
                    CHelper.SafeSelect(ddType, fe.Value.ToString());
                    break;

                case Project.PriorityFilterKey:
                    CHelper.SafeSelect(ddPriority, fe.Value.ToString());
                    break;

                case Project.StartDateFilterKey:
                    switch (fe.Type)
                    {
                    case FilterElementType.GreaterOrEqual:
                        CHelper.SafeSelect(ddSDType, "1");
                        dtcStartDate.SelectedDate = DateTime.Parse(fe.Value.ToString(), CultureInfo.InvariantCulture);
                        break;

                    case FilterElementType.LessOrEqual:
                        CHelper.SafeSelect(ddSDType, "2");
                        dtcStartDate.SelectedDate = DateTime.Parse(fe.Value.ToString(), CultureInfo.InvariantCulture);
                        break;

                    case FilterElementType.Equal:
                        CHelper.SafeSelect(ddSDType, "3");
                        dtcStartDate.SelectedDate = DateTime.Parse(fe.Value.ToString(), CultureInfo.InvariantCulture);
                        break;

                    default:
                        CHelper.SafeSelect(ddSDType, "0");
                        break;
                    }
                    break;

                case Project.EndDateFilterKey:
                    switch (fe.Type)
                    {
                    case FilterElementType.GreaterOrEqual:
                        CHelper.SafeSelect(ddFDType, "1");
                        dtcEndDate.SelectedDate = DateTime.Parse(fe.Value.ToString(), CultureInfo.InvariantCulture);
                        break;

                    case FilterElementType.LessOrEqual:
                        CHelper.SafeSelect(ddFDType, "2");
                        dtcEndDate.SelectedDate = DateTime.Parse(fe.Value.ToString(), CultureInfo.InvariantCulture);
                        break;

                    case FilterElementType.Equal:
                        CHelper.SafeSelect(ddFDType, "3");
                        dtcEndDate.SelectedDate = DateTime.Parse(fe.Value.ToString(), CultureInfo.InvariantCulture);
                        break;

                    default:
                        break;
                    }
                    break;

                case Project.ManagerFilterKey:
                    CHelper.SafeSelect(ddManager, fe.Value.ToString());
                    break;

                case Project.ExecManagerFilterKey:
                    CHelper.SafeSelect(ddExeManager, fe.Value.ToString());
                    break;

                case Project.ClientFilterKey:
                    PrimaryKeyId orgUid     = PrimaryKeyId.Empty;
                    PrimaryKeyId contactUid = PrimaryKeyId.Empty;
                    Incident.GetContactId(fe.Value.ToString(), out orgUid, out contactUid);
                    if (orgUid != PrimaryKeyId.Empty)
                    {
                        ClientControl.ObjectId   = orgUid;
                        ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                    }
                    else if (contactUid != PrimaryKeyId.Empty)
                    {
                        ClientControl.ObjectId   = contactUid;
                        ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                    }
                    break;

                case Project.GenCategoryTypeFilterKey:
                    CHelper.SafeSelect(ddGenCatType, fe.Value.ToString());
                    break;

                case Project.GenCategoriesFilterKey:
                    string[] mas = fe.Value.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in mas)
                    {
                        CHelper.SafeMultipleSelect(lbGenCats, s);
                    }
                    break;

                case Project.ProjectCategoryTypeFilterKey:
                    CHelper.SafeSelect(ddPrjCatType, fe.Value.ToString());
                    break;

                case Project.ProjectCategoriesFilterKey:
                    string[] mas1 = fe.Value.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in mas1)
                    {
                        CHelper.SafeMultipleSelect(lbPrjCats, s);
                    }
                    break;

                case Project.PortfolioTypeFilterKey:
                    CHelper.SafeSelect(ddPrjGrpType, fe.Value.ToString());
                    break;

                case Project.PortfoliosFilterKey:
                    string[] mas2 = fe.Value.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in mas2)
                    {
                        CHelper.SafeMultipleSelect(lbPrjGrps, s);
                    }
                    break;

                case Project.MyParticipationOnlyFilterKey:
                    chkOnlyForUser.Checked = bool.Parse(fe.Value.ToString());
                    break;

                default:
                    break;
                }
            }
            #endregion
        }
Exemplo n.º 18
0
        private void CopyViewPreferencesFrom45()
        {
            // Retrieve meta view for list
            ListViewProfile profile = null;

            ListViewProfile[] views = ListViewProfile.GetSystemProfiles(_metaClass47.Name, "EntityList");
            if (views.Length > 0)
            {
                profile = views[0];
            }

            if (profile == null)
            {
                //Create meta view
                profile          = new ListViewProfile();
                profile.Id       = Guid.NewGuid().ToString("D");
                profile.Name     = "{IbnFramework.ListInfo:lvpGeneralView}";
                profile.IsPublic = true;
                //defaultView = MD47.DataContext.Current.MetaModel.CreateMetaView(_metaClass47.Name, _metaClass47.Name, _metaClass47.FriendlyName, new string[] { });
            }

            //Try to load default meta view preference
            //Mediachase.Ibn.Core.McMetaViewPreference defaultPreference = Mediachase.Ibn.Core.UserMetaViewPreference.LoadDefault(defaultView);
            //if (defaultPreference == null)
            //{
            //    // Create preference
            //    Mediachase.Ibn.Core.McMetaViewPreference.CreateDefaultPreference(defaultView);
            //    defaultPreference = Mediachase.Ibn.Core.UserMetaViewPreference.LoadDefault(defaultView);
            //}

            Dictionary <string, MD47.Meta.Management.MetaField> fields47 = new Dictionary <string, MD47.Meta.Management.MetaField>();

            foreach (MD47.Meta.Management.MetaField field47 in _metaClass47.Fields)
            {
                fields47.Add(field47.Name, field47);
            }

            List <ColumnInfo> columns = new List <ColumnInfo>();

            foreach (MD45.Configurator.MetaField field45 in _metaClass45.MetaFields)
            {
                if (field45.Enabled)
                {
                    string fieldName47 = GetFieldName47ByFieldName45(field45.Name);
                    if (fields47.ContainsKey(fieldName47))
                    {
                        ColumnInfo column = new ColumnInfo(fieldName47);

                        column.Index = field45.Weight;
                        if (field45.Weight != 0)
                        {
                            column.Width = field45.Width;
                        }
                        else
                        {
                            column.Width = 150;
                        }

                        columns.Add(column);
                    }
                }
            }

            columns.Sort();

            foreach (ColumnInfo column in columns)
            {
                profile.FieldSet.Add(column.Name);
                profile.ColumnsUI.Add(new ColumnProperties(column.Name, column.Width.ToString(CultureInfo.InvariantCulture), string.Empty));
            }

            ListViewProfile.SaveSystemProfile(_metaClass47.Name, "EntityList", -1, profile);
        }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(ClassName))
            {
                throw new ArgumentNullException("ClassName is Required!");
            }
            #region PreInit Parameters
            mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName);

            //получить ListViewProfiles и заполнить поле _isGroupSet
            _profileName = GetProfileName(_pc, ClassName);
            lvp          = ListViewProfile.Load(ClassName, _profileName, _placeName);
            if (lvp == null)
            {
                _profileName = GetFirstAvailableListViewProfile(ClassName);
                SetProfileName(_pc, ClassName, _profileName);
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);
            }
            _isGroupSet = !String.IsNullOrEmpty(lvp.GroupByFieldName);
            #endregion

            //для вида с группировкой показываем левую панель
            if (_isGroupSet)
            {
                DockLeft.DefaultSize = 230;
            }
            else
            {
                DockLeft.DefaultSize = 0;
            }

            //для вида с группировкой показываем левую панель
            //if (lvp.Filters.Count > 0)
            //{
            //    trFilterText.Visible = true;
            //    DockTop.DefaultSize = 101;
            //}
            //else
            //{
            trFilterText.Visible = false;
            DockTop.DefaultSize  = 74;
            //}

            #region Init MCGrid, Toolbar
            grdMain.ChangingEntityGridColumnHeader += new ChangingEntityGridColumnHeaderEventHandler(grdMain_ChangingEntityGridColumnHeader);
            //инициализируем грид
            grdMain.ClassName   = ClassName;
            grdMain.ViewName    = ViewName;
            grdMain.PlaceName   = _placeName;
            grdMain.ProfileName = _profileName;

            ctrlGridEventUpdater.ClassName = ClassName;
            ctrlGridEventUpdater.ViewName  = ViewName;
            ctrlGridEventUpdater.PlaceName = _placeName;
            ctrlGridEventUpdater.GridId    = grdMain.GridClientContainerId;

            //инициализируем тулбар
            MainMetaToolbar.ClassName   = ClassName;
            MainMetaToolbar.ViewName    = ViewName;
            MainMetaToolbar.PlaceName   = _placeName;
            MainMetaToolbar.ToolbarMode = Mediachase.Ibn.Web.UI.MetaUI.Toolbar.MetaToolbar.Mode.ListViewUI;
            #endregion

            if (!Page.IsPostBack)
            {
                //биндим дропдауны
                BindDefaultValues();
                //устанавливаем в дропдаунах и key-textbox запомненные значения
                BindSavedValues();
                //биндим если надо группы в левой панели
                BindGroupDataList();
            }

            if (String.Compare(Request["Export"], ExportMode.Excel.ToString(), true) == 0)
            {
                ExportExcel();
            }
            else if (String.Compare(Request["Export"], ExportMode.Xml.ToString(), true) == 0)
            {
                ExportXML();
            }
            else if (String.Compare(Request["Export"], ExportMode.Vcf.ToString(), true) == 0 &&
                     String.Compare(ClassName, ContactEntity.GetAssignedMetaClassName(), true) == 0)
            {
                ExportVCF();
            }
            else
            {
                BindDataGrid(!Page.IsPostBack);
            }

            //set header text
            if (!Page.IsPostBack)
            {
                BindBlockHeader();
            }

            #region CommandManager PreLoad
            CommandManager cm = CommandManager.GetCurrent(this.Page);
            cm.AddCommand(ClassName, ViewName, _placeName, "MC_MUI_ProfileEdited");
            cm.AddCommand(ClassName, ViewName, _placeName, "MC_MUI_ExportTrue");
            #endregion
        }
Exemplo n.º 20
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);
            }
        }
Exemplo n.º 21
0
        public override void DataBind()
        {
            CHelper.AddToContext(_httpContextClassNameKey, ClassName);
            CHelper.AddToContext(_httpContextFilterFieldNameKey, FilterFieldName);
            CHelper.AddToContext(_httpContextFilterFieldValueKey, Request["ObjectId"]);

            if (String.IsNullOrEmpty(ProfileName))
            {
                MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName);
                ListViewProfile[] list = ListViewProfile.GetSystemProfiles(ClassName, PlaceName);
                if (list.Length == 0)
                {
                    list = ListViewProfile.GetSystemProfiles(ClassName, "EntityList");
                    if (list.Length == 0)
                    {
                        list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        if (list.Length == 0)
                        {
                            ListViewProfile lvp = new ListViewProfile();
                            lvp.Id = Guid.NewGuid().ToString();
                            lvp.IsPublic = true;
                            lvp.IsSystem = true;
                            lvp.Name = CHelper.GetResFileString(mc.FriendlyName);
                            lvp.ColumnsUI.Add(new ColumnProperties(mc.TitleFieldName, "150px", String.Empty));
                            lvp.FieldSet.Add(mc.TitleFieldName);
                            lvp.Filters = new FilterElementCollection();
                            ListViewProfile.SaveSystemProfile(ClassName, PlaceName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, lvp);
                            list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        }
                    }
                }
                ProfileName = list[0].Id;
            }
            grdMain.ClassName = ClassName;
            grdMain.ViewName = ViewName;
            grdMain.PlaceName = PlaceName;
            grdMain.ProfileName = ProfileName;
            grdMain.ShowCheckboxes = ShowCheckBoxes;
            FilterElementCollection fec = new FilterElementCollection();
            fec.Add(FilterElement.EqualElement(FilterFieldName, Request["ObjectId"]));
            grdMain.AddFilters = fec;
            grdMain.DataBind();

            ctrlGridEventUpdater.ClassName = ClassName;
            ctrlGridEventUpdater.ViewName = ViewName;
            ctrlGridEventUpdater.PlaceName = PlaceName;
            ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId;

            MainMetaToolbar.ClassName = ClassName;
            MainMetaToolbar.ViewName = ViewName;
            MainMetaToolbar.PlaceName = PlaceName;
            MainMetaToolbar.DataBind();
        }
Exemplo n.º 22
0
        private DataGrid PrepareExportGrid()
        {
            EntityObject[] list = GetEntityObjectListForExport();

            DataTable dt = new DataTable();

            dgExport.Columns.Clear();

            ListViewProfile lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);

            foreach (string fieldName in lvp.FieldSet)
            {
                MetaField field = Mediachase.Ibn.Web.UI.Controls.Util.FormController.GetMetaField(ClassName, fieldName);
                if (field == null)
                {
                    continue;
                }
                BoundColumn bc = new BoundColumn();
                bc.HeaderText = CHelper.GetResFileString(field.FriendlyName);
                string dataField = fieldName;

                if (field.IsReference)
                {
                    if (fieldName.ToLower().EndsWith("id"))
                    {
                        dataField = fieldName.Substring(0, fieldName.Length - 2);
                        if (dt.Columns.Contains(dataField))
                        {
                            continue;
                        }

                        dt.Columns.Add(new DataColumn(dataField, typeof(string)));
                    }
                    else
                    {
                        if (dt.Columns.Contains(dataField))
                        {
                            continue;
                        }

                        dt.Columns.Add(new DataColumn(fieldName, typeof(string)));
                    }
                }
                else
                {
                    if (dt.Columns.Contains(dataField))
                    {
                        continue;
                    }

                    dt.Columns.Add(new DataColumn(fieldName, typeof(string)));
                }


                bc.DataField = dataField;
                dgExport.Columns.Add(bc);
            }

            MakeDataViewFromList(dt, list);

            DataView dv = dt.DefaultView;

            dgExport.Visible    = true;
            dgExport.DataSource = dv;
            dgExport.DataBind();

            return(dgExport);
        }
Exemplo n.º 23
0
        private EntityObject[] GetEntityObjectListForExport()
        {
            string variant = "0";

            if (Request["variant"] != null)
            {
                variant = Request["variant"];
            }

            SortingElementCollection sec = new SortingElementCollection();

            if (_pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)] != null)
            {
                string             sort = _pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)];
                SortingElementType set  = SortingElementType.Asc;
                if (sort.IndexOf(" DESC") >= 0)
                {
                    sort = sort.Substring(0, sort.IndexOf(" DESC"));
                    set  = SortingElementType.Desc;
                }

                sec.Add(new SortingElement(sort, set));
            }

            int pageSize = 10;

            if (_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)] != null)
            {
                pageSize = Convert.ToInt32(_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)].ToString());
                if (pageSize == -1)
                {
                    pageSize = 10000;
                }
            }
            int pageIndex = 0;

            if (_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"] != null)
            {
                pageIndex = int.Parse(_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"]);
            }

            ListViewProfile lvp = null;

            switch (variant)
            {
            case "1":                           //OnlyView
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);
                if (sec.Count == 0)
                {
                    sec = lvp.Sorting;
                }
                return(BusinessManager.List(ClassName, lvp.Filters.ToArray(), sec.ToArray()));

            case "2":                           //Only Visible
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);

                FilterElementCollection fec = new FilterElementCollection(lvp.Filters.ToArray());

                if (!String.IsNullOrEmpty(txtSearch.Text))
                {
                    FilterElement fe = CHelper.GetSearchFilterElementByKeyword(txtSearch.Text, ClassName);
                    fec.Add(fe);
                }

                EntityObject[]      list    = BusinessManager.List(ClassName, fec.ToArray(), sec.ToArray());
                List <EntityObject> newList = new List <EntityObject>();
                int start  = pageIndex * pageSize;
                int finish = start + pageSize;
                for (int i = start; i <= finish && i < list.Length; i++)
                {
                    newList.Add(list[i]);
                }
                return(newList.ToArray());

            case "3":                           //Only Selected
                string              values           = Request["ids"];
                string[]            selectedElements = values.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                List <PrimaryKeyId> listPkey         = new List <PrimaryKeyId>();
                foreach (string elem in selectedElements)
                {
                    string       id  = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0];
                    PrimaryKeyId key = PrimaryKeyId.Parse(id);
                    if (key != PrimaryKeyId.Empty)
                    {
                        listPkey.Add(key);
                    }
                }
                FilterElementCollection fecPkey = new FilterElementCollection();
                foreach (PrimaryKeyId id in listPkey)
                {
                    FilterElement fe = FilterElement.EqualElement(FilterElement.PrimaryKeyFieldName, id);
                    fecPkey.Add(fe);
                }
                FilterElement orFilter = new OrBlockFilterElement(fecPkey.ToArray());
                fecPkey.Clear();
                fecPkey.Add(orFilter);

                return(BusinessManager.List(ClassName, fecPkey.ToArray(), sec.ToArray()));

            default:                            //All
                return(BusinessManager.List(ClassName, (new FilterElementCollection()).ToArray(), sec.ToArray()));
            }
        }
Exemplo n.º 24
0
        public string GetGroupFieldForProfile(ListViewProfile lvp)
        {
            if (_pc[_pc[_className + "_" + ProfileNameKey] + "_" + GroupFieldKey] == null)
            {
                _pc[_pc[_className + "_" + ProfileNameKey] + "_" + GroupFieldKey] = lvp.GroupByFieldName;
            }

            if (!Page.IsPostBack)
                _pc[_pc[_className + "_" + ProfileNameKey] + "_" + GroupFieldKey] = lvp.GroupByFieldName;

            return _pc[_pc[_className + "_" + ProfileNameKey] + "_" + GroupFieldKey];
        }
Exemplo n.º 25
0
        public override void DataBind()
        {
            CHelper.AddToContext(_httpContextBridgeClassNameKey, BridgeClassName);
            CHelper.AddToContext(_httpContextClassNameKey, ClassName);
            CHelper.AddToContext(_httpContextFilter1FieldNameKey, Filter1FieldName);
            CHelper.AddToContext(_httpContextFilter1FieldValueKey, Request["ObjectId"]);
            CHelper.AddToContext(_httpContextFilter2FieldNameKey, Filter2FieldName);

            MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName);

            if (String.IsNullOrEmpty(ProfileName))
            {
                ListViewProfile[] list = ListViewProfile.GetSystemProfiles(ClassName, PlaceName);
                if (list.Length == 0)
                {
                    list = ListViewProfile.GetSystemProfiles(ClassName, "EntityList");
                    if (list.Length == 0)
                    {
                        list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        if (list.Length == 0)
                        {
                            ListViewProfile lvp = new ListViewProfile();
                            lvp.Id = Guid.NewGuid().ToString();
                            lvp.IsPublic = true;
                            lvp.IsSystem = true;
                            lvp.Name = CHelper.GetResFileString(mc.FriendlyName);
                            lvp.ColumnsUI.Add(new ColumnProperties(mc.TitleFieldName, "150px", String.Empty));
                            lvp.FieldSet.Add(mc.TitleFieldName);
                            lvp.Filters = new FilterElementCollection();
                            ListViewProfile.SaveSystemProfile(ClassName, PlaceName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, lvp);
                            list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        }
                    }
                }
                ProfileName = list[0].Id;
            }
            grdMain.ClassName = ClassName;
            grdMain.ViewName = ViewName;
            grdMain.PlaceName = PlaceName;
            grdMain.ProfileName = ProfileName;
            grdMain.ShowCheckboxes = ShowCheckBoxes;

            MetaClass bridgeClass = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(BridgeClassName);
            string pkName = SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name;
            string bridgeTableName = bridgeClass.DataSource.PrimaryTable;
            FilterElementCollection fec = new FilterElementCollection();
            FilterElement fe = new FilterElement(pkName, FilterElementType.In,
                String.Format("(SELECT [{0}] FROM [{1}] WHERE [{2}]='{3}')",
                            Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"]));
            //FilterElement fe = new FilterElement(String.Empty, FilterElementType.Custom,
            //    String.Format("[t01].[{0}] IN (SELECT [{1}] FROM [{2}] WHERE [{3}]='{4}')",
            //                pkName, Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"]));
            fec.Add(fe);
            grdMain.AddFilters = fec;
            grdMain.DataBind();

            ctrlGridEventUpdater.ClassName = ClassName;
            ctrlGridEventUpdater.ViewName = ViewName;
            ctrlGridEventUpdater.PlaceName = PlaceName;
            ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId;

            MainMetaToolbar.ClassName = ClassName;
            MainMetaToolbar.ViewName = ViewName;
            MainMetaToolbar.PlaceName = PlaceName;
            MainMetaToolbar.DataBind();
        }
Exemplo n.º 26
0
        public override void DataBind()
        {
            CHelper.AddToContext(_httpContextBridgeClassNameKey, BridgeClassName);
            CHelper.AddToContext(_httpContextClassNameKey, ClassName);
            CHelper.AddToContext(_httpContextFilter1FieldNameKey, Filter1FieldName);
            CHelper.AddToContext(_httpContextFilter1FieldValueKey, Request["ObjectId"]);
            CHelper.AddToContext(_httpContextFilter2FieldNameKey, Filter2FieldName);

            MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName);

            if (String.IsNullOrEmpty(ProfileName))
            {
                ListViewProfile[] list = ListViewProfile.GetSystemProfiles(ClassName, PlaceName);
                if (list.Length == 0)
                {
                    list = ListViewProfile.GetSystemProfiles(ClassName, "EntityList");
                    if (list.Length == 0)
                    {
                        list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        if (list.Length == 0)
                        {
                            ListViewProfile lvp = new ListViewProfile();
                            lvp.Id       = Guid.NewGuid().ToString();
                            lvp.IsPublic = true;
                            lvp.IsSystem = true;
                            lvp.Name     = CHelper.GetResFileString(mc.FriendlyName);
                            lvp.ColumnsUI.Add(new ColumnProperties(mc.TitleFieldName, "150px", String.Empty));
                            lvp.FieldSet.Add(mc.TitleFieldName);
                            lvp.Filters = new FilterElementCollection();
                            ListViewProfile.SaveSystemProfile(ClassName, PlaceName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, lvp);
                            list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        }
                    }
                }
                ProfileName = list[0].Id;
            }
            grdMain.ClassName      = ClassName;
            grdMain.ViewName       = ViewName;
            grdMain.PlaceName      = PlaceName;
            grdMain.ProfileName    = ProfileName;
            grdMain.ShowCheckboxes = ShowCheckBoxes;

            MetaClass bridgeClass       = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(BridgeClassName);
            string    pkName            = SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name;
            string    bridgeTableName   = bridgeClass.DataSource.PrimaryTable;
            FilterElementCollection fec = new FilterElementCollection();
            FilterElement           fe  = new FilterElement(pkName, FilterElementType.In,
                                                            String.Format("(SELECT [{0}] FROM [{1}] WHERE [{2}]='{3}')",
                                                                          Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"]));

            //FilterElement fe = new FilterElement(String.Empty, FilterElementType.Custom,
            //    String.Format("[t01].[{0}] IN (SELECT [{1}] FROM [{2}] WHERE [{3}]='{4}')",
            //                pkName, Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"]));
            fec.Add(fe);
            grdMain.AddFilters = fec;
            grdMain.DataBind();

            ctrlGridEventUpdater.ClassName = ClassName;
            ctrlGridEventUpdater.ViewName  = ViewName;
            ctrlGridEventUpdater.PlaceName = PlaceName;
            ctrlGridEventUpdater.GridId    = grdMain.GridClientContainerId;

            MainMetaToolbar.ClassName = ClassName;
            MainMetaToolbar.ViewName  = ViewName;
            MainMetaToolbar.PlaceName = PlaceName;
            MainMetaToolbar.DataBind();
        }
Exemplo n.º 27
0
        public void BindData(string metaClassName)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("DisplayName", typeof(string)));
            dt.Columns.Add(new DataColumn("ClassName", typeof(string)));
            dt.Columns.Add(new DataColumn("IsForm", typeof(string)));

            bool isBaseFormAdded        = false;
            bool isGeneralViewFormAdded = false;
            bool isShortViewFormAdded   = false;

            // ListApp Fix: we don't use ShortViewForm for lists
            bool isList = ListManager.MetaClassIsList(metaClassName);

            if (isList)
            {
                isShortViewFormAdded = true;
            }

            string[] forms = MetaUIManager.GetMetaFormList(metaClassName);
            foreach (string name in forms)
            {
                if ((name == FormController.CreateFormType || name == FormController.ShortViewFormType) && isList)
                {
                    continue;
                }
                AddRow(dt, metaClassName, name, String.Empty, true, false);

                if (name == FormController.BaseFormType)
                {
                    isBaseFormAdded = true;
                }
                if (name == FormController.GeneralViewFormType)
                {
                    isGeneralViewFormAdded = true;
                }
                if (name == FormController.ShortViewFormType)
                {
                    isShortViewFormAdded = true;
                }
            }

            // Edit Form
            if (!isBaseFormAdded)
            {
                AddRow(dt, metaClassName, FormController.BaseFormType, String.Empty, true, false);
            }

            // View Form
            if (!isGeneralViewFormAdded)
            {
                AddRow(dt, metaClassName, FormController.GeneralViewFormType, String.Empty, true, false);
            }

            // Short View Form
            if (!isShortViewFormAdded)
            {
                AddRow(dt, metaClassName, FormController.ShortViewFormType, String.Empty, true, false);
            }

            if (ListManager.IsHistoryActivated(metaClassName))
            {
                string[] formsHistory = MetaUIManager.GetMetaFormList(HistoryManager.GetHistoryMetaClassName(metaClassName));
                foreach (string name in formsHistory)
                {
                    if (name != FormController.GeneralViewHistoryFormType && isList)
                    {
                        continue;
                    }
                    AddRow(dt, HistoryManager.GetHistoryMetaClassName(metaClassName), name, String.Empty, true, true);
                }
            }

            ListViewProfile[] list = ListViewProfile.GetSystemProfiles(metaClassName, "EntityList");
            foreach (ListViewProfile lvp in list)
            {
                AddRow(dt, metaClassName, lvp.Id, lvp.Name, false, false);
            }
            //string[] views = MetaUIManager.GetMetaViewList(metaClassName);
            //foreach (string name in views)
            //    AddRow(dt, metaClassName, name, false, false);

            grdMain.DataKeyField = "Name";
            grdMain.DataSource   = dt.DefaultView;
            grdMain.DataBind();
        }