private List <RptField> getSummarizeFieldList(List <RptFieldInfo> list)
        {
            List <RptField> userSummarizeFieldList = new List <RptField>();

            foreach (RptFieldInfo summarizeField in list)
            {
                RptField newSummarizeField = (new RptField
                {
                    ID = summarizeField.ID,
                    ReportFieldID = summarizeField.ReportFieldID,
                    ReportID = summarizeField.ReportID,
                    Name = summarizeField.Name,
                    SQLName = summarizeField.SQLName,
                    DataType = (DataTypeEnum)summarizeField.DataType,
                    ColumnOrder = summarizeField.ColumnOrder,
                    ColumnWidthFactor = summarizeField.ColumnWidthFactor,
                    SortOrder = summarizeField.SortOrder,
                    SortDirection = (SortDirectionEnum)summarizeField.SortDirection,
                    GroupOrder = summarizeField.GroupOrder,
                    GroupSummaryExpression = summarizeField.GroupSummaryExpression,
                    IncludePageBreak = summarizeField.IncludePageBreak,
                    IsDisplayInReport = summarizeField.IsDisplayInReport,
                    IsGroupByDefault = summarizeField.IsGroupByDefault,
                    FieldValueExpression = summarizeField.FieldValueExpression
                });

                userSummarizeFieldList.Add(newSummarizeField);
            }

            return(userSummarizeFieldList);
        }
        private List <RptField> getUserReportFieldList(bool saveAsNew, List <RptFieldInfo> list)
        {
            List <RptField> fields = new List <RptField>();

            foreach (RptFieldInfo rptFieldInfo in list)
            {
                if (rptFieldInfo.IsUsed || rptFieldInfo.SortOrder > 0 || rptFieldInfo.IsGroupByDefault)
                {
                    RptField rptField = (new RptField
                    {
                        ID = saveAsNew ? rptFieldInfo.ReportFieldID : rptFieldInfo.ID,
                        ReportFieldID = rptFieldInfo.ReportFieldID,
                        RptFieldID = rptFieldInfo.RptFieldInfoID,
                        ReportID = rptFieldInfo.ReportID,
                        Name = rptFieldInfo.Name,
                        SQLName = rptFieldInfo.SQLName,
                        DataType = (DataTypeEnum)rptFieldInfo.DataType,
                        ColumnOrder = rptFieldInfo.ColumnOrder,
                        ColumnWidthFactor = rptFieldInfo.ColumnWidthFactor,
                        SortOrder = rptFieldInfo.SortOrder,
                        SortDirection = (SortDirectionEnum)rptFieldInfo.SortDirection,
                        GroupOrder = rptFieldInfo.GroupOrder,
                        GroupSummaryExpression = rptFieldInfo.GroupSummaryExpression,
                        IncludePageBreak = rptFieldInfo.IncludePageBreak,
                        IsDisplayInReport = rptFieldInfo.IsDisplayInReport,
                        IsGroupByDefault = rptFieldInfo.IsGroupByDefault,
                        IsUsed = rptFieldInfo.IsUsed,
                        IsGroupable = rptFieldInfo.IsGroupable,
                        IsSummarizable = rptFieldInfo.IsSummarizable,
                        FieldValueExpression = rptFieldInfo.FieldValueExpression,
                        CoverageCode = rptFieldInfo.CoverageCode,
                        IsClientSpecificCode = rptFieldInfo.IsClientSpecificCode
                    });
                    fields.Add(rptField);
                }
            }

            return(fields);
        }
示例#3
0
        private int updateUserReportFields(int userReportID, List <RptField> fields, int userId, List <RptField> summarizeFields)
        {
            ReportProjectDBEntities entities = new ReportProjectDBEntities();

            UserReport ur = entities.UserReport.Where(urp => urp.UserReportID == userReportID).First();

            var userReportFielList = from fv in entities.UserReportField
                                     .Include("UserReport")
                                     where fv.UserReport.UserReportID == userReportID
                                     select fv;


            foreach (var field in userReportFielList)
            {
                if (!fields.Any(f => f.RptFieldID == field.UserReportFieldID))
                {
                    entities.UserReportField.DeleteObject(field);
                }
                else
                {
                    RptField myfield = fields.First(f => f.RptFieldID == field.UserReportFieldID);

                    string sortdir = "A";
                    if (myfield.SortDirection == SortDirectionEnum.Descending)
                    {
                        sortdir = "D";
                    }

                    UserReportField urf = new UserReportField();

                    field.ColumnOrder      = myfield.ColumnOrder;
                    field.SortOrder        = myfield.SortOrder;
                    field.SortDirection    = sortdir;
                    field.GroupOrder       = myfield.GroupOrder;
                    field.CustomName       = myfield.Name;
                    field.IncludePageBreak = myfield.IncludePageBreak;
                    field.CoverageCode     = myfield.CoverageCode;
                }
            }

            //Add New UserReportFields
            foreach (RptField field in fields)
            {
                if (field.RptFieldID == field.ReportFieldID)
                {
                    if (field.IsUsed || field.SortOrder > 0)
                    {
                        string sortdir = "A";
                        if (field.SortDirection == SortDirectionEnum.Descending)
                        {
                            sortdir = "D";
                        }

                        UserReportField urf = new UserReportField();

                        urf.UserReport       = ur;
                        urf.ReportField      = entities.ReportField.Where(r => r.ReportFieldID == field.RptFieldID).First();
                        urf.CreatedByUserID  = userId;
                        urf.CreatedDate      = DateTime.Now;
                        urf.ColumnOrder      = field.ColumnOrder;
                        urf.CustomName       = field.Name;
                        urf.SortDirection    = sortdir;
                        urf.SortOrder        = field.SortOrder;
                        urf.GroupOrder       = field.GroupOrder;
                        urf.IncludePageBreak = field.IncludePageBreak;
                        urf.CoverageCode     = field.CoverageCode;
                        entities.AddToUserReportField(urf);
                    }
                }
            }

            entities.SaveChanges();

            saveUserReportSummarizeFields(summarizeFields, entities, ur, userId);

            return(ur.UserReportID);
        }