public frmDataMenuSetting(int entityID, int dataMenuSettingID)
        {
            InitializeComponent();
            EntityID = entityID;
            SetRelationshipTails();
            SetDataViewList();
            SetDataItemReports();
            if (dataMenuSettingID == 0)
            {
                Message = new DataMenuSettingDTO();
                ShowMessage();
            }
            else
            {
                GetDataMenuSetting(dataMenuSettingID);
            }
            Entity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships);
            SetTabVisiblities();
            SetBaseTables();

            ControlHelper.GenerateContextMenu(dtgDataGridRelationships);
            ControlHelper.GenerateContextMenu(dtgDataViewRelationships);
            ControlHelper.GenerateContextMenu(dtgReportRelationships);
            ControlHelper.GenerateContextMenu(dtgDataItemReport);

            //ControlHelper.GenerateContextMenu(dtgExternalReports);
            dtgReportRelationships.RowLoaded     += DtgColumns_RowLoaded;
            dtgReportRelationships.CellEditEnded += DtgConditions_CellEditEnded;

            dtgDataViewRelationships.RowLoaded     += DtgColumns_RowLoaded;
            dtgDataViewRelationships.CellEditEnded += DtgConditions_CellEditEnded;

            dtgDataGridRelationships.RowLoaded     += DtgColumns_RowLoaded;
            dtgDataGridRelationships.CellEditEnded += DtgConditions_CellEditEnded;

            colReportRelationshipTail.EditItemClicked   += ColRelationshipTail_EditItemClicked;
            colDataViewRelationshipTail.EditItemClicked += ColRelationshipTail_EditItemClicked;
            colDataGridRelationshipTail.EditItemClicked += ColRelationshipTail_EditItemClicked;

            colDataGridRelTargetDataMenuSetting.NewItemEnabled   = true;
            colDataViewRelTargetDataMenuSetting.NewItemEnabled   = true;
            colDataGridRelTargetDataMenuSetting.EditItemEnabled  = true;
            colDataViewRelTargetDataMenuSetting.EditItemEnabled  = true;
            colDataViewRelTargetDataMenuSetting.EditItemClicked += ColDataGridRelTargetDataMenuSetting_EditItemClicked;
            colDataGridRelTargetDataMenuSetting.EditItemClicked += ColDataGridRelTargetDataMenuSetting_EditItemClicked;

            lokRelationship.SelectionChanged   += LokRelationship_SelectionChanged;
            lokDataMenuSetting.EditItemClicked += LokDataMenuSetting_EditItemClicked;
            lokDataMenuSetting.EditItemEnabled  = true;
            lokDataMenuSetting.NewItemEnabled   = true;
        }
        public void SetAreaInitializer(DataViewAreaInitializer initParam)
        {
            AreaInitializer = initParam;
            if (this is I_DataViewArea)
            {
                (this as I_DataViewArea).SetAreaInitializerSpecialized(initParam);
            }
            else if (this is I_GridViewArea)
            {
                (this as I_GridViewArea).SetAreaInitializerSpecialized(initParam);
            }

            View.EntityListViewChanged += View_EntityListViewChanged;
            View.OrderColumnsChanged   += View_OrderColumnsChanged;

            if (AreaInitializer.DataMenuSettingID != 0)
            {
                DataMenuSetting = AgentUICoreMediator.GetAgentUICoreMediator.DataMenuManager.GetDataMenuSetting(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), AreaInitializer.DataMenuSettingID);
            }
            else
            {
                DataMenuSetting = AgentUICoreMediator.GetAgentUICoreMediator.DataMenuManager.GetDefaultDataMenuSetting(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), AreaInitializer.EntityID);
            }

            if (DataMenuSetting != null && DataMenuSetting.EntityListViewID != 0)
            {
                SelectedListView = AgentUICoreMediator.GetAgentUICoreMediator.EntityListViewManager.GetEntityListView(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), DataMenuSetting.EntityListViewID);
            }
            else
            {
                SelectedListView = AgentUICoreMediator.GetAgentUICoreMediator.EntityListViewManager.GetDefaultEntityListView(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), AreaInitializer.EntityID);
            }

            SetEntitiyListViews();
            SetEntityOrderColumns();

            //ManageSecurity();
        }
 private void btnNew_Click(object sender, RoutedEventArgs e)
 {
     Message = new DataMenuSettingDTO();
     ShowMessage();
 }
Пример #4
0
        private DataMenuSettingDTO ToDataMenuSettingDTO(DR_Requester requester, DataMenuSetting entity, bool withDetails)
        {
            var result = new DataMenuSettingDTO();

            if (withDetails)
            {
                foreach (var item in entity.DataMenuSearchableReportRelationship)
                {
                    //دسترسی به خود گزارش هم کنترل شود
                    if (bizEntityRelationshipTail.DataIsAccessable(requester, item.EntityRelationshipTail))
                    {
                        if (bizEntityReport.DataIsAccessable(requester, item.EntitySearchableReport.EntityReport))
                        {
                            var tail            = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
                            var entityReportDTO = new EntitySearchableReportDTO();
                            bizEntitySearchableReport.ToEntitySearchableReportDTO(item.EntitySearchableReport, entityReportDTO, withDetails);
                            result.SearchableReportRelationships.Add(ToDataMenuSearchableReportRelationshipDTO(item, tail, entityReportDTO));
                        }
                    }
                }
                foreach (var item in entity.DataMenuDataViewRelationship)
                {
                    if (bizEntityRelationshipTail.DataIsAccessable(requester, item.EntityRelationshipTail))
                    {
                        var tail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
                        result.DataViewRelationships.Add(ToDataMenuDataViewRelationshipDTO(item, tail));
                    }
                }
                foreach (var item in entity.DataMenuGridViewRelationship)
                {
                    if (bizEntityRelationshipTail.DataIsAccessable(requester, item.EntityRelationshipTail))
                    {
                        var tail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
                        result.GridViewRelationships.Add(ToDataMenuGridViewRelationshipDTO(item, tail));
                    }
                }
                foreach (var item in entity.DataMenuDataItemReportRelationship)
                {
                    if (bizEntityReport.DataIsAccessable(requester, item.EntityDataItemReportID))
                    {
                        var entityReportDTO = new EntityDataItemReportDTO();
                        bizEntityDataItemReport.ToEntityDataItemReportDTO(item.EntityDataItemReport, entityReportDTO, false);
                        result.DataItemReports.Add(ToDataMenuDataItemReportRelationshipDTO(item, entityReportDTO));
                    }
                }
            }
            result.EntityID         = entity.TableDrivedEntityID;
            result.EntityListViewID = entity.EntityListViewID;
            result.Name             = entity.Name;
            if (entity.DataMenuForViewEntity.Any())
            {
                result.RelationshipID = entity.DataMenuForViewEntity.First().RelationshipID;
                if (withDetails)
                {
                    if (bizRelationship.DataIsAccessable(requester, entity.DataMenuForViewEntity.First().Relationship, false, true))
                    {
                        result.Relationship = bizRelationship.ToRelationshipDTO(entity.DataMenuForViewEntity.First().Relationship);
                    }
                }
                result.TargetDataMenuSettingID = entity.DataMenuForViewEntity.First().TargetDataMenuSettingID;
                if (withDetails)
                {
                    result.DataMenuSetting = ToDataMenuSettingDTO(requester, entity.DataMenuForViewEntity.First().DataMenuSetting1, false);
                }
            }
            result.ID = entity.ID;
            if (withDetails)
            {
                result.IconContent = entity.IconContent;
            }
            return(result);
        }
Пример #5
0
        //public List<EntityReportDataMenuRelationshipsDTO> GetEntityRelationshipReports(int entityID, bool withDetails)
        //{
        //    List<EntityReportDataMenuRelationshipsDTO> result = new List<EntityReportDataMenuRelationshipsDTO>();
        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        var entityReportSetting = projectContext.EntityReportDataMenuSetting.FirstOrDefault(x => x.ID == entityID);
        //        if (entityReportSetting != null)
        //        {
        //            foreach (var item in entityReportSetting.EntityReportDataMenuRelationships)
        //            {
        //                result.Add(ToEntityReportDataMenuRelationshipsDTO(item, withDetails));
        //            }
        //        }
        //    }
        //    return result;
        //}

        //private EntityReportDataMenuRelationshipsDTO ToEntityReportDataMenuRelationshipsDTO(EntityReportDataMenuRelationships dbRel, bool withDetails)
        //{

        //}



        public void UpdateEntityReportDataMenuSettings(DataMenuSettingDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                DataMenuSetting dbEntity = null;
                if (message.ID != 0)
                {
                    dbEntity = projectContext.DataMenuSetting.First(x => x.ID == message.ID);
                }
                else
                {
                    dbEntity = new DataMenuSetting();
                    projectContext.DataMenuSetting.Add(dbEntity);
                }

                while (dbEntity.DataMenuSearchableReportRelationship.Any())
                {
                    projectContext.DataMenuSearchableReportRelationship.Remove(dbEntity.DataMenuSearchableReportRelationship.First());
                }
                foreach (var item in message.SearchableReportRelationships)
                {
                    DataMenuSearchableReportRelationship dbRel = new DataMenuSearchableReportRelationship();
                    //  dbRel.RelationshipID = (item.RelationshipID == 0 ? (int?)null : item.RelationshipID);
                    dbRel.EntityRelationshipTailID = item.RelationshipTailID;
                    dbRel.EntitySearchableReportID = item.EntitySearchableReportID;
                    dbRel.Group1 = item.Group1;
                    dbEntity.DataMenuSearchableReportRelationship.Add(dbRel);
                }

                while (dbEntity.DataMenuDataViewRelationship.Any())
                {
                    projectContext.DataMenuDataViewRelationship.Remove(dbEntity.DataMenuDataViewRelationship.First());
                }
                foreach (var item in message.DataViewRelationships)
                {
                    DataMenuDataViewRelationship dbRel = new DataMenuDataViewRelationship();
                    dbRel.EntityRelationshipTailID = item.RelationshipTailID;
                    dbRel.Group1 = item.Group1;
                    if (item.TargetDataMenuSettingID != 0)
                    {
                        dbRel.TargetDataMenuSettingID = item.TargetDataMenuSettingID;
                    }
                    else
                    {
                        dbRel.TargetDataMenuSettingID = null;
                    }
                    dbEntity.DataMenuDataViewRelationship.Add(dbRel);
                }

                while (dbEntity.DataMenuGridViewRelationship.Any())
                {
                    projectContext.DataMenuGridViewRelationship.Remove(dbEntity.DataMenuGridViewRelationship.First());
                }
                foreach (var item in message.GridViewRelationships)
                {
                    DataMenuGridViewRelationship dbRel = new DataMenuGridViewRelationship();
                    dbRel.EntityRelationshipTailID = item.RelationshipTailID;
                    dbRel.Group1 = item.Group1;
                    if (item.TargetDataMenuSettingID != 0)
                    {
                        dbRel.TargetDataMenuSettingID = item.TargetDataMenuSettingID;
                    }
                    else
                    {
                        dbRel.TargetDataMenuSettingID = null;
                    }
                    dbEntity.DataMenuGridViewRelationship.Add(dbRel);
                }

                while (dbEntity.DataMenuDataItemReportRelationship.Any())
                {
                    projectContext.DataMenuDataItemReportRelationship.Remove(dbEntity.DataMenuDataItemReportRelationship.First());
                }
                foreach (var item in message.DataItemReports)
                {
                    DataMenuDataItemReportRelationship dbRel = new DataMenuDataItemReportRelationship();
                    dbRel.EntityDataItemReportID = item.EntityDataItemReportID;
                    dbRel.Group1 = item.Group1;
                    dbEntity.DataMenuDataItemReportRelationship.Add(dbRel);
                }


                while (dbEntity.DataMenuForViewEntity.Any())
                {
                    projectContext.DataMenuForViewEntity.Remove(dbEntity.DataMenuForViewEntity.First());
                }
                if (message.RelationshipID != 0 && message.TargetDataMenuSettingID != 0)
                {
                    DataMenuForViewEntity dbRel = new DataMenuForViewEntity();
                    dbRel.RelationshipID          = message.RelationshipID;
                    dbRel.TargetDataMenuSettingID = message.TargetDataMenuSettingID;
                    dbEntity.DataMenuForViewEntity.Add(dbRel);
                }



                dbEntity.TableDrivedEntityID = message.EntityID;
                dbEntity.Name             = message.Name;
                dbEntity.EntityListViewID = message.EntityListViewID;
                dbEntity.IconContent      = message.IconContent;

                //dbEntity.EntityReportDataMenuSetting.IconContent = message.IconContent;
                projectContext.SaveChanges();
            }
        }
Пример #6
0
        public DataMenuResult GetDataMenu(DR_Requester requester, DP_DataView dataItem, int dataMenuSettingID)
        {
            DataMenuResult  result      = new DataMenuResult();
            List <DataMenu> resultMenus = new List <DataMenu>();

            result.DataMenus = resultMenus;
            var entityID     = dataItem.TargetEntityID;
            var simpleEntity = bizTableDrivedEntity.GetSimpleEntity(requester, entityID);

            if (simpleEntity == null)
            {
                return(null);
            }
            DataMenuSettingDTO dataMenuSetting = null;

            if (dataMenuSettingID != 0)
            {
                dataMenuSetting = GetDataMenuSetting(requester, dataMenuSettingID, true);
            }
            else
            {
                dataMenuSetting = GetDefaultDataMenuSetting(requester, entityID, true);
            }

            if (dataMenuSetting != null)
            {
                result.DataMenuSettingName = dataMenuSetting.Name;
            }

            if (simpleEntity.IsView)
            {
                if (dataMenuSetting != null)
                {
                    if (dataMenuSetting.RelationshipID != 0 && dataMenuSetting.TargetDataMenuSettingID != 0)
                    {
                        var relationship = bizRelationship.GetRelationship(dataMenuSetting.RelationshipID);
                        var dataView     = CreateDataView(requester, dataItem, relationship);
                        return(GetDataMenu(requester, dataView, dataMenuSetting.TargetDataMenuSettingID));
                    }
                }
                //var fullEntity = bizTableDrivedEntity.GetTableDrivedEntity(requester, entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithRelationships);
                //if (fullEntity.Relationships.Any())
                //{
                //    foreach (var relationsip in fullEntity.Relationships)
                //    {
                //        var dataView = CreateDataView(dataItem, relationsip);
                //        var menu = AddMenu(result, relationsip.Alias, "", DataMenuType.ViewRel);
                //        menu.ViewRelTargetDataItem = dataView;
                //    }
                //}
            }
            else
            {
                var dataEntryRootMenu = AddMenu(resultMenus, "نمایش/اصلاح داده", "", DataMenuType.Form, dataItem);
                //آرشیو داده
                // BizArchive bizArchive = new BizArchive();
                if (bizTableDrivedEntity.DataIsAccessable(requester, entityID, new List <SecurityAction>()
                {
                    SecurityAction.ArchiveView, SecurityAction.ArchiveEdit
                }))
                {
                    var archiveRootMenu = AddMenu(resultMenus, "آرشیو", "", DataMenuType.Archive, dataItem);
                }


                //نامه های داده
                //  BizLetterTemplate bizLetterTemplate = new BizLetterTemplate();
                if (bizTableDrivedEntity.DataIsAccessable(requester, entityID, new List <SecurityAction>()
                {
                    SecurityAction.LetterView, SecurityAction.LetterEdit
                }))
                {
                    var letterRootMenu = AddMenu(resultMenus, "نامه ها", "", DataMenuType.Letter, dataItem);
                }
                //جریان کارهای مرتبط
                if (bizProcess.EntityHasAnyProcess(entityID))
                {
                    var workflowRootMenu = AddMenu(resultMenus, "جریان کار", "", DataMenuType.Workflow, dataItem);
                }



                ////لینک های داده
                //BizDataLink bizDataLink = new MyModelManager.BizDataLink();
                //var datalinks = bizDataLink.GetDataLinkByEntitiyID(requester, entityID);
                //if (datalinks.Any())
                //{
                //    var dataViewRootMenu = AddMenu(resultMenus, "لینک داده", "", DataMenuType.Folder,null);
                //    foreach (var datalink in datalinks)
                //    {
                //        var datalinkMenu = AddMenu(dataViewRootMenu.SubMenus, datalink.ReportTitle, "", DataMenuType.DataLink, dataItem);
                //        datalinkMenu.Datalink = datalink;
                //    }
                //}

                //گزارشهای داده های مرتبط

                if (dataMenuSetting != null)
                {
                    if (dataMenuSetting.SearchableReportRelationships.Any())
                    {
                        var relationshipReportRootMenu = AddMenu(resultMenus, "گزارش داده های مرتبط", "", DataMenuType.Folder, null);
                        foreach (var group in dataMenuSetting.SearchableReportRelationships.GroupBy(x => x.Group1 ?? ""))
                        {
                            DataMenu parentGroupMenu = GetGroupMenu(relationshipReportRootMenu, group.Key);
                            foreach (var rel in group)
                            {
                                var menu = AddMenu(parentGroupMenu.SubMenus, rel.SearchableReportReport.ReportTitle, "", DataMenuType.RelationshipTailSearchableReport, dataItem);
                                menu.SearchableReportRelationshipTail = rel;
                            }
                        }
                    }
                    //نمای داده های مرتبط
                    if (dataMenuSetting.DataViewRelationships.Any())
                    {
                        var dataViewRootMenu = AddMenu(resultMenus, "نمایش داده های مرتبط", "", DataMenuType.Folder, null);
                        foreach (var group in dataMenuSetting.DataViewRelationships.GroupBy(x => x.Group1 ?? ""))
                        {
                            DataMenu parentGroupMenu = GetGroupMenu(dataViewRootMenu, group.Key);
                            foreach (var rel in group)
                            {
                                var dataViewRelMenu = AddMenu(parentGroupMenu.SubMenus, rel.RelationshipTail.TargetEntityAlias, rel.RelationshipTail.EntityPath, DataMenuType.RelationshipTailDataView, dataItem);
                                dataViewRelMenu.DataviewRelationshipTail = rel.RelationshipTail;
                                dataViewRelMenu.TargetDataMenuSettingID  = rel.TargetDataMenuSettingID;
                            }
                        }
                    }
                    if (dataMenuSetting.GridViewRelationships.Any())
                    {
                        var gridViewRootMenu = AddMenu(resultMenus, "گرید داده های مرتبط", "", DataMenuType.Folder, null);
                        foreach (var group in dataMenuSetting.GridViewRelationships.GroupBy(x => x.Group1 ?? ""))
                        {
                            DataMenu parentGroupMenu = GetGroupMenu(gridViewRootMenu, group.Key);
                            foreach (var rel in group)
                            {
                                var gridViewRelMenu = AddMenu(parentGroupMenu.SubMenus, rel.RelationshipTail.TargetEntityAlias, rel.RelationshipTail.EntityPath, DataMenuType.RelationshipTailDataGrid, dataItem);
                                gridViewRelMenu.GridviewRelationshipTail = rel.RelationshipTail;
                                gridViewRelMenu.TargetDataMenuSettingID  = rel.TargetDataMenuSettingID;
                            }
                        }
                    }
                    if (dataMenuSetting.DataItemReports.Any())
                    {
                        var gridViewRootMenu = AddMenu(resultMenus, "گزارشات مورد داده", "", DataMenuType.Folder, null);
                        foreach (var group in dataMenuSetting.DataItemReports.GroupBy(x => x.Group1 ?? ""))
                        {
                            DataMenu parentGroupMenu = GetGroupMenu(gridViewRootMenu, group.Key);
                            foreach (var rel in group)
                            {
                                var gridViewRelMenu = AddMenu(parentGroupMenu.SubMenus, rel.EntityDataItemReport.ReportTitle, "", DataMenuType.DataItemReport, dataItem);
                                gridViewRelMenu.DataItemReport = rel.EntityDataItemReport;
                            }
                        }
                    }
                }
            }
            return(result);
        }