Beispiel #1
0
        public EntityCrosstabReportDTO ToEntityCrosstabReportDTO(DR_Requester requester, EntityCrosstabReport item, bool withDetails)
        {
            EntityCrosstabReportDTO result = new EntityCrosstabReportDTO();

            result.ID = item.ID;
            bizEntitySearchableReport.ToEntitySearchableReportDTO(item.EntitySearchableReport, result, withDetails);
            result.EntityListViewID = item.EntityListViewID;
            if (withDetails)
            {
                BizEntityListView bizEntityListView = new BizEntityListView();
                result.EntityListView = bizEntityListView.GetEntityListView(requester, item.EntityListViewID);
                if (result.EntityListView == null)
                {
                    throw new Exception("عدم دسترسی به لیست نمایش به شناسه" + " " + item.EntityListViewID);
                }
                BizEntityRelationshipTail bizEntityRelationshipTail = new MyModelManager.BizEntityRelationshipTail();
                foreach (var sub in item.CrosstabReportColumns)
                {
                    CrosstabReportColumnDTO rColumn = new CrosstabReportColumnDTO();
                    rColumn.ID = sub.ID;
                    rColumn.EntityListViewColumnID = sub.EntityListViewColumnsID;
                    rColumn.EntityListViewColumn   = result.EntityListView.EntityListViewAllColumns.FirstOrDefault(x => x.ID == sub.EntityListViewColumnsID);
                    if (rColumn.EntityListViewColumn == null)
                    {
                        throw new Exception("Crosstab report column" + " " + sub.ID + " " + "is not accessable!");
                    }
                    result.Columns.Add(rColumn);
                }
                foreach (var sub in item.CrosstabReportRows)
                {
                    CrosstabReportRowDTO rColumn = new CrosstabReportRowDTO();

                    rColumn.ID = sub.ID;
                    rColumn.EntityListViewColumnID = sub.EntityListViewColumnsID;
                    rColumn.EntityListViewColumn   = result.EntityListView.EntityListViewAllColumns.FirstOrDefault(x => x.ID == sub.EntityListViewColumnsID);
                    if (rColumn.EntityListViewColumn == null)
                    {
                        throw new Exception("Crosstab report row" + " " + sub.ID + " " + "is not accessable!");
                    }
                    result.Rows.Add(rColumn);
                }
                foreach (var sub in item.CrosstabReportValues)
                {
                    CrosstabReportValueDTO rColumn = new CrosstabReportValueDTO();

                    rColumn.ID = sub.ID;
                    rColumn.EntityListViewColumnID = sub.EntityListViewColumnsID;
                    rColumn.EntityListViewColumn   = result.EntityListView.EntityListViewAllColumns.First(x => x.ID == sub.EntityListViewColumnsID);
                    if (rColumn.EntityListViewColumn == null)
                    {
                        throw new Exception("Crosstab report value" + " " + sub.ID + " " + "is not accessable!");
                    }
                    rColumn.ValueFunction = (ChartReportValueFunction)sub.FunctoinType;

                    result.Values.Add(rColumn);
                }
            }

            return(result);
        }
        public EntityListReportDTO ToEntityListReportDTO(DR_Requester requester, EntityListReport item, bool withDetails)
        {
            EntityListReportDTO result = new EntityListReportDTO();

            result.ID = item.ID;
            bizEntitySearchableReport.ToEntitySearchableReportDTO(item.EntitySearchableReport, result, withDetails);
            result.EntityListViewID = item.EntityListViewID;

            if (withDetails)
            {
                BizEntityRelationshipTail bizEntityRelationshipTail = new MyModelManager.BizEntityRelationshipTail();
                BizEntityListView         bizEntityListView         = new BizEntityListView();
                result.EntityListView = bizEntityListView.GetEntityListView(requester, item.EntityListViewID);
                if (result.EntityListView == null)
                {
                    throw new Exception("عدم دسترسی به لیست نمایش به شناسه" + " " + item.EntityListViewID);
                }
                foreach (var dbSubReport in item.EntityListReportSubs1)
                {
                    EntityListReportSubsDTO subReport = new EntityListReportSubsDTO();
                    subReport.Title   = dbSubReport.Title;
                    subReport.OrderID = dbSubReport.OrderID ?? 0;
                    subReport.EntityRelationshipTailID = dbSubReport.EntityRelationshipTailID;
                    subReport.EntityListReportID       = dbSubReport.ChildEntityListReportID;
                    foreach (var subColumn in dbSubReport.EntityListReportSubsColumns)
                    {
                        EntityListReportSubsColumnsDTO rSubsColumn = new EntityListReportSubsColumnsDTO();
                        rSubsColumn.ParentEntityListViewColumnsID          = subColumn.ParentEntityListViewColumnsID;
                        rSubsColumn.ParentEntityListViewColumnAlias        = subColumn.EntityListViewColumns1.Alias ?? subColumn.EntityListViewColumns1.Column.Name;
                        rSubsColumn.ParentEntityListViewColumnRelativeName = subColumn.EntityListViewColumns1.Column.Name + (subColumn.EntityListViewColumns1.EntityRelationshipTailID ?? 0);
                        rSubsColumn.ParentEntityListViewColumnType         = (Enum_ColumnType)subColumn.EntityListViewColumns1.Column.TypeEnum;

                        rSubsColumn.ChildEntityListViewColumnsID          = subColumn.ChildEntityListViewColumnsID;
                        rSubsColumn.ChildEntityListViewColumnAlias        = subColumn.EntityListViewColumns.Alias ?? subColumn.EntityListViewColumns.Column.Name;
                        rSubsColumn.ChildEntityListViewColumnRelativeName = subColumn.EntityListViewColumns.Column.Name + (subColumn.EntityListViewColumns.EntityRelationshipTailID ?? 0);
                        rSubsColumn.ChildEntityListViewColumnType         = (Enum_ColumnType)subColumn.EntityListViewColumns.Column.TypeEnum;

                        subReport.SubsColumnsDTO.Add(rSubsColumn);
                    }
                    result.EntityListReportSubs.Add(subReport);
                }
                foreach (var sub in item.ReportGroups)
                {
                    ReportGroupDTO rColumn = new ReportGroupDTO();
                    rColumn.ID = sub.ID;
                    rColumn.ListViewColumnID     = sub.EntityListViewColumnsID;
                    rColumn.EntityListViewColumn = result.EntityListView.EntityListViewAllColumns.First(x => x.ID == sub.EntityListViewColumnsID);
                    rColumn.ColumnName           = rColumn.EntityListViewColumn.Column.Alias;
                    result.ReportGroups.Add(rColumn);
                }
            }

            return(result);
        }
        private void SetOwnerPart(DR_Requester requester, LetterTemplateDTO result, LetterTemplate ownerDbItem, bool withDetails)
        {
            result.TableDrivedEntityID = ownerDbItem.TableDrivedEntityID;
            result.Name             = ownerDbItem.Name;
            result.EntityListViewID = ownerDbItem.EntityListViewID;
            if (withDetails)
            {
                BizEntityListView bizEntityListView = new BizEntityListView();

                result.EntityListView = bizEntityListView.GetEntityListView(requester, ownerDbItem.EntityListViewID);
                if (result.EntityListView == null)
                {
                    throw new Exception("عدم دسترسی به لیست نمایش به شناسه" + " " + ownerDbItem.EntityListViewID);
                }

                BizFormula bizFormula = new BizFormula();
                foreach (var item in ownerDbItem.LetterTemplatePlainField)
                {
                    LetterTemplatePlainFieldDTO field = new LetterTemplatePlainFieldDTO();
                    field.FieldName = item.FieldName;
                    field.EntityListViewColumnsID = (item.EntityListViewColumnsID == null) ? 0 : item.EntityListViewColumnsID.Value;
                    if (field.EntityListViewColumnsID != 0)
                    {
                        field.EntityListViewColumns = result.EntityListView.EntityListViewAllColumns.First(x => x.ID == item.EntityListViewColumnsID);
                    }
                    field.FormulaID = (item.FormulaID == null) ? 0 : item.FormulaID.Value;
                    field.ID        = item.ID;
                    //if (item.ColumnID != null)
                    //    field.Type = LetterTemplateFieldType.Column;
                    //else if (item.ParameterID != null)
                    //    field.Type = LetterTemplateFieldType.Parameter;
                    //if (item.RelationshipID != null)
                    //    field.Type = LetterTemplateFieldType.RangeRelationship;

                    result.PlainFields.Add(field);
                }
                BizEntityRelationshipTail bizEntityRelationshipTail = new MyModelManager.BizEntityRelationshipTail();
                foreach (var item in ownerDbItem.LetterTemplateRelationshipField)
                {
                    LetterTemplateRelationshipFieldDTO field = new LetterTemplateRelationshipFieldDTO();
                    field.RelationshipTailID = item.EntityRelationshipTailID;
                    //field.EntityPreDefinedSearchID = (item.EntityPreDefinedSearchID == null) ? 0 : item.EntityPreDefinedSearchID.Value;
                    field.ID = item.ID;
                    field.RelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
                    //field.NextLine = item.NextLine==true;
                    field.IsRow     = item.IsRow == true;
                    field.FieldName = item.FieldName;
                    field.PartialLetterTemplateID = item.PartialLetterTemplateID;
                    field.PartialLetterTemplate   = ToPartialLetterTemplateDTO(requester, item.PartialLetterTemplate, true);
                    //field.PartialLetterTemplate = ToPartialLetterTemplate(item.PartialLetterTemplate, true);
                    result.RelationshipFields.Add(field);
                }
            }
        }