コード例 #1
0
        //public RelationshipFilterDTO GetRelationshipFilter(int RelationshipFiltersID)
        //{
        //    List<RelationshipFilterDTO> result = new List<RelationshipFilterDTO>();
        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        var RelationshipFilters = projectContext.RelationshipSearchFilter.First(x => x.ID == RelationshipFiltersID);
        //        return ToRelationshipFilterDTO(RelationshipFilters);
        //    }
        //}
        public RelationshipFilterDTO ToRelationshipFilterDTO(RelationshipSearchFilter item)
        {
            RelationshipFilterDTO result = new RelationshipFilterDTO();

            result.ID = item.ID;
            //result.Enabled = item.Enabled;
            BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();

            //if (item.SearchRelationshipTailID != null)
            //{
            //    result.SearchRelationshipTailID = item.SearchRelationshipTailID.Value;
            //    result.SearchRelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
            //}
            result.RelationshipID          = item.RelationshipID;
            result.SearchColumnID          = item.SearchColumnID;
            result.ValueColumnID           = item.ValueColumnID;
            result.ValueRelationshipTailID = item.ValueRelationshipTailID ?? 0;
            if (item.EntityRelationshipTail != null)
            {
                result.ValueRelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
            }

            //          result.SearchRelationshipTailID = item.SearchRelationshipTailID ?? 0;
            //if (item.EntityRelationshipTail != null)
            //    result.SearchRelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);

            //foreach (var column in item.RelationshipFilterColumns)
            //{
            //    result.RelationshipFilterColumns.Add(new RelationshipFilterColumnDTO() { SearchColumnID = column.SearchColumnID, ValueColumnID = column.ValueColumnID });
            //}
            return(result);
        }
コード例 #2
0
        public List <DataMenuSettingDTO> GetDataMenusOfRelationshipTail(DR_Requester requester, int relationshipTailID)
        {
            List <EntitySearchableReportDTO> result = new List <EntitySearchableReportDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();
                var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(requester, relationshipTailID);
                return(GetDataMenuSettings(requester, relationshipTail.TargetEntityID));
            }
        }
コード例 #3
0
        public EntityStateConditionDTO ToEntityStateConditionDTO(DR_Requester requester, TableDrivedEntityStateCondition item, bool withDetails)
        {
            var result = new EntityStateConditionDTO();

            result.ID        = item.ID;
            result.FormulaID = item.FormulaID ?? 0;
            if (result.FormulaID != 0 && withDetails)
            {  //??با جزئیات؟؟........................................................................
                var bizFormula = new BizFormula();
                result.Formula = bizFormula.GetFormula(requester, item.FormulaID.Value, withDetails);
            }
            result.ColumnID = item.ColumnID ?? 0;
            if (item.Column != null)
            {
                BizColumn bizColumn = new BizColumn();
                result.Column = bizColumn.ToColumnDTO(item.Column, true);
            }
            result.Title = item.Title;
            result.RelationshipTailID = item.EntityRelationshipTailID ?? 0;
            if (item.EntityRelationshipTail != null)
            {
                BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();
                result.RelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
            }
            if (item.ValueOpoerator != null)
            {
                result.EntityStateOperator = (Enum_EntityStateOperator)item.ValueOpoerator;
            }

            foreach (var valItem in item.TableDrivedEntityStateConditionValues)
            {
                result.Values.Add(new ModelEntites.EntityStateValueDTO()
                {
                    Value = valItem.Value, SecurityReservedValue = valItem.ReservedValue == null ? SecurityReservedValue.None : (SecurityReservedValue)valItem.ReservedValue
                });
            }

            foreach (var valItem in item.TableDrivedEntityStateConditionSecuritySubject)
            {
                result.SecuritySubjects.Add(new ChildSecuritySubjectDTO {
                    SecuritySubjectID = valItem.SecuritySubjectID
                });                                                                                                        //, SecuritySubjectOperator = (Enum_SecuritySubjectOperator)valItem.SecuritySubjectOperator });
            }
            if (item.SecuritySubjectInOrNotIn == null)
            {
                result.SecuritySubjectInORNotIn = InORNotIn.In;
            }
            else
            {
                result.SecuritySubjectInORNotIn = (InORNotIn)item.SecuritySubjectInOrNotIn;
            }
            return(result);
        }
コード例 #4
0
        private LetterRelationshipTailDTO ToLetterRelationshipTailDTO(EntityLetterRelationshipTails item, bool withDetails)
        {
            LetterRelationshipTailDTO result = new LetterRelationshipTailDTO();

            result.EntityID           = item.TableDrivedEntityID;
            result.ID                 = item.TableDrivedEntityID;
            result.RelationshipTailID = item.EntityRelationshipTailID;
            if (withDetails)
            {
                BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();
                result.RelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
            }
            return(result);
        }
コード例 #5
0
        //public EntitySearchableReportDTO GetEntitySearchableReport(DR_Requester requester, int EntityReportID, bool withDetails)
        //{

        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        var dbReport = projectContext.EntitySearchableReport.First(x => x.ID == EntityReportID);
        //        if (bizEntityReport.DataIsAccessable(requester, dbReport.EntityReport))
        //        {
        //            return ToEntitySearchableReportDTO(dbReport, withDetails);
        //        }
        //        else
        //            return null;
        //    }

        //}
        public List <EntitySearchableReportDTO> GetEntityReportsOfRelationshipTail(DR_Requester requester, int entityRelationshipTailID)
        {
            List <EntitySearchableReportDTO> result = new List <EntitySearchableReportDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();
                var relationshipTail = bizEntityRelationshipTail.GetEntityRelationshipTail(requester, entityRelationshipTailID);
                var listEntityReport = projectContext.EntitySearchableReport.Where(x => x.EntityReport.TableDrivedEntityID == relationshipTail.TargetEntityID);
                foreach (var item in listEntityReport)
                {
                    var nItem = new EntitySearchableReportDTO();
                    ToEntitySearchableReportDTO(item, nItem, false);
                    result.Add(nItem);
                }
            }
            return(result);
        }
コード例 #6
0
        private FormulaItemDTO ToFormualaItemDTO(int entityID, FormulaItems dbFormulaItem)
        {
            FormulaItemDTO formulaItem = new FormulaItemDTO();

            formulaItem.ID = dbFormulaItem.ID;
            formulaItem.RelationshipIDTail = dbFormulaItem.RelationshipIDTail;
            if (!string.IsNullOrEmpty(formulaItem.RelationshipIDTail))
            {
                var bizEntityRelationshipTail = new BizEntityRelationshipTail();
                formulaItem.RelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(entityID, formulaItem.RelationshipIDTail);
            }
            formulaItem.RelationshipNameTail = dbFormulaItem.RelationshipNameTail;
            formulaItem.FormulaID            = dbFormulaItem.FormulaID ?? 0;
            formulaItem.ItemTitle            = dbFormulaItem.ItemTitle;
            if (dbFormulaItem.ColumnID != null)
            {
                formulaItem.ItemID   = dbFormulaItem.ColumnID.Value;
                formulaItem.ItemType = FormuaItemType.Column;
            }
            else if (dbFormulaItem.FormulaParameterID != null)
            {
                formulaItem.ItemID   = dbFormulaItem.FormulaParameterID.Value;
                formulaItem.ItemType = FormuaItemType.FormulaParameter;
            }
            else if (dbFormulaItem.RelationshipID != null)
            {
                formulaItem.ItemID   = dbFormulaItem.RelationshipID.Value;
                formulaItem.ItemType = FormuaItemType.Relationship;
            }

            //foreach (var dbcItem in dbFormulaItem.FormulaItems1)
            //{
            //    formulaItem.ChildFormulaItems.Add(ToFormualaItemDTO(dbcItem));
            //}

            return(formulaItem);
        }
コード例 #7
0
        public EntitySearch SaveItem(MyProjectEntities projectContext, EntitySearchDTO message, List <EntityRelationshipTail> createdRelationshipTails = null)
        {
            var dbEntitySearch = projectContext.EntitySearch.FirstOrDefault(x => x.ID == message.ID);

            if (dbEntitySearch == null)
            {
                dbEntitySearch = new DataAccess.EntitySearch();
            }
            dbEntitySearch.TableDrivedEntityID = message.TableDrivedEntityID;
            dbEntitySearch.Title = message.Title;

            //تیلهای گزارش را از روی تیلهای ستونها میسازد
            //هر دفعه پاک نشن بهتره..اصلاح بشن
            while (dbEntitySearch.EntitySearchColumns.Any())
            {
                projectContext.EntitySearchColumns.Remove(dbEntitySearch.EntitySearchColumns.First());
            }
            //while (dbEntitySearch.EntitySearchRelationshipTails.Any())
            //    projectContext.EntitySearchRelationshipTails.Remove(dbEntitySearch.EntitySearchRelationshipTails.First());
            if (createdRelationshipTails == null)
            {
                createdRelationshipTails = new List <EntityRelationshipTail>();
            }
            BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();

            foreach (var column in message.EntitySearchAllColumns)
            {
                EntitySearchColumns rColumn = new EntitySearchColumns();
                if (column.ColumnID != 0)
                {
                    rColumn.ColumnID = column.ColumnID;
                }
                else
                {
                    rColumn.ColumnID = null;
                }
                rColumn.Alias   = column.Alias;
                rColumn.Tooltip = column.Tooltip;

                rColumn.OrderID = column.OrderID;
                // rColumn.WidthUnit = column.WidthUnit;

                if (string.IsNullOrEmpty(column.CreateRelationshipTailPath))
                {
                    rColumn.EntityRelationshipTailID = column.RelationshipTailID == 0 ? (int?)null : column.RelationshipTailID;
                }
                else
                {
                    if (createdRelationshipTails.Any(x => x.TableDrivedEntityID == message.TableDrivedEntityID && x.RelationshipPath == column.CreateRelationshipTailPath))
                    {
                        rColumn.EntityRelationshipTail = createdRelationshipTails.First(x => x.TableDrivedEntityID == message.TableDrivedEntityID && x.RelationshipPath == column.CreateRelationshipTailPath);
                    }
                    else
                    {
                        var relationshipTail = bizEntityRelationshipTail.GetOrCreateEntityRelationshipTail(projectContext, message.TableDrivedEntityID, column.CreateRelationshipTailPath);
                        createdRelationshipTails.Add(relationshipTail);
                        rColumn.EntityRelationshipTail = relationshipTail;
                    }
                }


                //if (column.RelationshipTailID != 0 || !string.IsNullOrEmpty(column.RelationshipPath))
                //{
                //    int tailID = 0;
                //    if (column.RelationshipTailID != 0)
                //        tailID = column.RelationshipTailID;
                //    else
                //        tailID = bizEntityRelationshipTail.GetOrCreateEntityRelationshipTail(message.TableDrivedEntityID, column.RelationshipPath);
                //    //var relatedListReportTail = dbEntitySearch.EntitySearchRelationshipTails.FirstOrDefault(x => x.EntityRelationshipTailID == tailID);
                //    //if (relatedListReportTail == null)
                //    //{
                //    //    relatedListReportTail = new EntitySearchRelationshipTails();
                //    //    relatedListReportTail.EntityRelationshipTailID = tailID;
                //    //    dbEntitySearch.EntitySearchRelationshipTails.Add(relatedListReportTail);
                //    //}

                //    //rColumn.EntitySearchRelationshipTails = relatedListReportTail;
                //}
                dbEntitySearch.EntitySearchColumns.Add(rColumn);
            }

            if (dbEntitySearch.ID == 0)
            {
                projectContext.EntitySearch.Add(dbEntitySearch);
            }
            return(dbEntitySearch);
        }
コード例 #8
0
        public EntityListView SaveItem(MyProjectEntities projectContext, EntityListViewDTO message, List <EntityRelationshipTail> createdRelationshipTails = null)
        {
            var dbEntityListView = projectContext.EntityListView.FirstOrDefault(x => x.ID == message.ID);

            if (dbEntityListView == null)
            {
                dbEntityListView = new DataAccess.EntityListView();
            }
            dbEntityListView.TableDrivedEntityID = message.TableDrivedEntityID;
            dbEntityListView.Title = message.Title;

            //تیلهای گزارش را از روی تیلهای ستونها میسازد
            //هر دفعه پاک نشن بهتره..اصلاح بشن

            List <EntityListViewColumns> listRemove = new List <EntityListViewColumns>();

            foreach (var dbColumn in dbEntityListView.EntityListViewColumns)
            {
                if (!message.EntityListViewAllColumns.Any(x => x.RelationshipTailID == (dbColumn.EntityRelationshipTailID ?? 0) && x.ColumnID == dbColumn.ColumnID))
                {
                    listRemove.Add(dbColumn);
                }
            }
            foreach (var item in listRemove)
            {
                projectContext.EntityListViewColumns.Remove(item);
            }
            //while (dbEntityListView.EntityListViewRelationshipTails.Any())
            //    projectContext.EntityListViewRelationshipTails.Remove(dbEntityListView.EntityListViewRelationshipTails.First());
            if (createdRelationshipTails == null)
            {
                createdRelationshipTails = new List <EntityRelationshipTail>();
            }

            BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();

            foreach (var column in message.EntityListViewAllColumns)
            {
                EntityListViewColumns rColumn = null;
                if (column.ID == 0)
                {
                    rColumn = new EntityListViewColumns();
                }
                else
                {
                    rColumn = projectContext.EntityListViewColumns.First(x => x.ID == column.ID);
                }

                rColumn.ColumnID      = column.ColumnID;
                rColumn.Alias         = column.Alias;
                rColumn.OrderID       = column.OrderID;
                rColumn.Tooltip       = column.Tooltip;
                rColumn.IsDescriptive = column.IsDescriptive;
                rColumn.WidthUnit     = column.WidthUnit;
                if (string.IsNullOrEmpty(column.CreateRelationshipTailPath))
                {
                    rColumn.EntityRelationshipTailID = column.RelationshipTailID == 0 ? (int?)null : column.RelationshipTailID;
                }
                else
                {
                    if (createdRelationshipTails.Any(x => x.TableDrivedEntityID == message.TableDrivedEntityID && x.RelationshipPath == column.CreateRelationshipTailPath))
                    {
                        rColumn.EntityRelationshipTail = createdRelationshipTails.First(x => x.TableDrivedEntityID == message.TableDrivedEntityID && x.RelationshipPath == column.CreateRelationshipTailPath);
                    }
                    else
                    {
                        var relationshipTail = bizEntityRelationshipTail.GetOrCreateEntityRelationshipTail(projectContext, message.TableDrivedEntityID, column.CreateRelationshipTailPath);
                        createdRelationshipTails.Add(relationshipTail);
                        rColumn.EntityRelationshipTail = relationshipTail;
                    }
                }
                dbEntityListView.EntityListViewColumns.Add(rColumn);
            }
            if (dbEntityListView.ID == 0)
            {
                projectContext.EntityListView.Add(dbEntityListView);
            }
            return(dbEntityListView);
        }