예제 #1
0
        /// <summary>
        /// 대시보드 테이블 업무 영역을 반환한다.
        /// </summary>
        public FormTableSection SelectFormTableSection(Guid formId, Guid formSectionId)
        {
            string procCommandName = "up_FormTableSection_Select";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);
                Connection.AddInParameter(command, "FormID", DbType.Guid, formId);
                Connection.AddInParameter(command, "FormSectionID", DbType.Guid, formSectionId);

                using (DataSet ds = Connection.ExecuteDataSet(command))
                {
                    ValidateTableCount(ds, 4);

                    // 1. 업무 영역
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        var formSection = FormTableSection.ParseFrom(ds.Tables[0].Rows[0]);

                        // 2. 파일 템플릿 정보
                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            formSection.FileTemplate = DataFileTemplate.ParseFrom(ds.Tables[1].Rows[0]);
                        }

                        // 3. 파일 소스 정보
                        if (ds.Tables[2].Rows.Count > 0)
                        {
                            formSection.FileSource = DataFileSource.ParseFrom(ds.Tables[2].Rows[0]);
                        }

                        // 4. 데이터 업로더 정보
                        foreach (DataRow dr in ds.Tables[3].Rows)
                        {
                            var uploader = DataFileSourceUploader.ParseFrom(dr);
                            formSection.FileSourceUploaders[uploader.UserId] = uploader;
                        }

                        return(formSection);
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }
예제 #2
0
        /// <summary>
        /// 페이징 처리된 대시보드 테이블 업무 영역을 반환한다.
        /// </summary>
        public PagedModel <FormTableSection> SelectFormTableSectionPagedList(PagingOption option)
        {
            string procCommandName = "up_FormTableSection_SelectPagedList";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);
                Connection.AddInParameter(command, "PageNumber", DbType.Int32, option.PageNumber);
                Connection.AddInParameter(command, "PageCount", DbType.Int32, option.PageCount);
                Connection.AddInParameter(command, "SortBy", DbType.String, option.SortBy);
                Connection.AddInParameter(command, "OrderBy", DbType.String, option.OrderBy.ToEnumMemberString());

                using (DataSet ds = Connection.ExecuteDataSet(command))
                {
                    ValidateTableCount(ds, 4);

                    var result = new PagedModel <FormTableSection>(option)
                    {
                        PagingOption = option
                    };
                    int totalCount = 0;

                    // 1. 업무 영역
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        var formSection = FormTableSection.ParseFrom(dr, out totalCount);
                        result.Items.Add(formSection);
                    }

                    // 2. 파일 템플릿 정보
                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        var fileTemplate = DataFileTemplate.ParseFrom(dr);
                        var formSections = result.Items.FindAll(o => o.FileTemplateId == fileTemplate.FileTemplateId);
                        if (formSections.Any())
                        {
                            formSections.ForEach(o =>
                            {
                                o.FileTemplate = fileTemplate;
                            });
                        }
                    }

                    // 3. 파일 소스 정보
                    foreach (DataRow dr in ds.Tables[2].Rows)
                    {
                        var fileSource   = DataFileSource.ParseFrom(dr);
                        var formSections = result.Items.FindAll(o => o.FormId == fileSource.FormId && o.FormSectionId == fileSource.FormSectionId);
                        if (formSections.Any())
                        {
                            formSections.ForEach(o =>
                            {
                                o.FileSource = fileSource;
                            });
                        }
                    }

                    // 4. 데이터 업로더 정보
                    foreach (DataRow dr in ds.Tables[3].Rows)
                    {
                        var uploader     = DataFileSourceUploader.ParseFrom(dr);
                        var formSections = result.Items.FindAll(o => o.FormId == uploader.FormId && o.FormSectionId == uploader.FormSectionId);
                        if (formSections.Any())
                        {
                            formSections.ForEach(o =>
                            {
                                o.FileSourceUploaders[uploader.UserId] = uploader;
                            });
                        }
                    }

                    result.TotalCount = totalCount;

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }
예제 #3
0
        /// <summary>
        /// 대시보드 테이블 업무 영역 리스트를 반환한다.
        /// </summary>
        /// <param name="queryUserId">값이 있는 경우, 해당 유저가 접근 가능한 데이터만 반환</param>
        /// <param name="fileSourceDateRanges">값이 있는 경우, 해당 날짜의 데이터 파일 소스 정보를 반환</param>
        public IEnumerable <FormTableSection> SelectFormTableSectionList(Guid?formId, string queryUserId = null, List <DataDateRange> fileSourceDateRanges = null)
        {
            string procCommandName = "up_FormTableSection_SelectList";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);

                if (formId.HasValue)
                {
                    Connection.AddInParameter(command, "FormID", DbType.Guid, formId.Value);
                }

                Connection.AddInParameter(command, "QueryUserID", DbType.String, queryUserId);

                if (fileSourceDateRanges != null)
                {
                    // 특정한 날짜 범위 내의 데이터 소스 값만 반환하기 위해 날짜 범위를 DB에 전달한다.
                    using (var spParamDateRanges = new DataTable()) // type_DataSourceDateRanges
                    {
                        spParamDateRanges.Columns.Add("UploadInterval", typeof(string));
                        spParamDateRanges.Columns.Add("BeginDate", typeof(DateTimeOffset));
                        spParamDateRanges.Columns.Add("EndDate", typeof(DateTimeOffset));
                        spParamDateRanges.Columns.Add("IsCurrentData", typeof(bool));

                        foreach (var dateRange in fileSourceDateRanges)
                        {
                            spParamDateRanges.Rows.Add(new object[]
                            {
                                dateRange.UploadInterval,
                                dateRange.BeginDate,
                                dateRange.EndDate,
                                dateRange.IsCurrentData
                            });
                        }

                        var param = command.Parameters.AddWithValue("SourceDateRanges", spParamDateRanges);
                        param.SqlDbType = SqlDbType.Structured;
                    }
                }

                using (DataSet ds = Connection.ExecuteDataSet(command))
                {
                    ValidateTableCount(ds, 4);

                    var result = new List <FormTableSection>();

                    // 1. 업무 영역
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        var formSection = FormTableSection.ParseFrom(dr);
                        result.Add(formSection);
                    }

                    // 2. 파일 템플릿 정보
                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        var fileTemplate = DataFileTemplate.ParseFrom(dr);
                        var formSections = result.FindAll(o => o.FileTemplateId == fileTemplate.FileTemplateId);
                        if (formSections.Any())
                        {
                            formSections.ForEach(o =>
                            {
                                o.FileTemplate = fileTemplate;
                            });
                        }
                    }

                    // 3. 파일 소스 정보
                    foreach (DataRow dr in ds.Tables[2].Rows)
                    {
                        var  fileSource    = DataFileSource.ParseFrom(dr);
                        bool isCurrentData = dr.Get <bool>("IsCurrentData");

                        var formSections = result.FindAll(o => o.FormId == fileSource.FormId && o.FormSectionId == fileSource.FormSectionId);
                        if (formSections.Any())
                        {
                            formSections.ForEach(o =>
                            {
                                if (isCurrentData)
                                {
                                    o.FileSource = fileSource;
                                }
                                else
                                {
                                    o.PrevFileSource = fileSource;
                                }
                            });
                        }
                    }

                    // 4. 데이터 업로더 정보
                    foreach (DataRow dr in ds.Tables[3].Rows)
                    {
                        var uploader     = DataFileSourceUploader.ParseFrom(ds.Tables[3].Rows[0]);
                        var formSections = result.FindAll(o => o.FormId == uploader.FormId && o.FormSectionId == uploader.FormSectionId);
                        if (formSections.Any())
                        {
                            formSections.ForEach(o =>
                            {
                                o.FileSourceUploaders[uploader.UserId] = uploader;
                            });
                        }
                    }

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }