예제 #1
0
        public IHttpActionResult AddNewCategory(ReportCategoryModel reportCategoryModel)
        {
            int          result = 0;
            ActionStatus status = new ActionStatus();

            try
            {
                result = reportService.AddNewCategory(reportCategoryModel, permission);
            }
            catch (ReportServiceException ex)
            {
                status.Number = (int)ex.ErrorCodeService;
            }
            catch (BaseException ex)
            {
                status.Number = (int)ex.ErrorCode;
            }

            catch (Exception ex)
            {
                status.Number = -1;
                logger.Error("Exception in Report/AddNewCategory: {0} \r\n {1}", ex.ToString(), ex.StackTrace);
            }
            if (status.Number != -1)
            {
                return(Ok(new { result = result, Status = status }));
            }
            else
            {
                return(InternalServerError());
            }
        }
예제 #2
0
        public IHttpActionResult GetSpecificCategory(int categoryId)
        {
            ReportCategoryModel reportCategoryModel = null;
            ActionStatus        status = new ActionStatus();

            try
            {
                reportCategoryModel = reportService.GetSpecificCategorywithSub(categoryId, permission);

                if (reportCategoryModel == null)
                {
                    throw new NoDataFoundException();
                }
            }
            catch (BaseException ex)
            {
                status.Number = (int)ex.ErrorCode;
            }
            catch (Exception ex)
            {
                status.Number = -1;
                logger.Error("Exception in Report/GetSpecificCategory: {0} \r\n {1}", ex.ToString(), ex.StackTrace);
            }
            if (status.Number != -1)
            {
                return(Ok(new { reportCategoryModel = reportCategoryModel, Status = status }));
            }
            else
            {
                return(InternalServerError());
            }
        }
        private TreeViewItemTool CreateTreeItem(ReportCategoryModel category)
        {
            TreeViewItemTool result = new TreeViewItemTool {
                Header = category.CategoryName, Tag = category.CategoryId
            };

            return(result);
        }
        private TreeViewItemTool CreateTreeItem(ReportCategoryModel category)
        {
            TreeViewItemTool result = new TreeViewItemTool {
                Header = category.CategoryName, Tag = category.CategoryId
            };

            result.Selected += this.TreeViewItemSelection_Changed;

            return(result);
        }
예제 #5
0
        public IHttpActionResult MetaData()
        {
            Kapsch.Core.Reports.Models.ReportMetaDataModel x = new ReportMetaDataModel();

            var reportDefinitions = new List <ReportDefinitionModel>();
            var libraryPath       = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/ReportDefinitions");

            foreach (string file in Directory.GetFiles(libraryPath, "*.dll"))
            {
                Assembly assembly = Assembly.LoadFile(file);
                foreach (Type ti in assembly.GetTypes().Where(f => typeof(IReportDefinition).IsAssignableFrom(f) && !f.IsInterface))
                {
                    var reportDefinition = Activator.CreateInstance(ti) as IReportDefinition;
                    reportDefinitions.Add(
                        new ReportDefinitionModel
                    {
                        CategoryName       = reportDefinition.CategoryName,
                        SubCategoryName    = reportDefinition.SubCategoryName,
                        ReportName         = reportDefinition.ReportName,
                        ExportTypes        = reportDefinition.ExportTypes,
                        ParameterTypes     = reportDefinition.ParameterTypes,
                        RequiredAccessRole = reportDefinition.RequiredAccessRole
                    });
                }
            }

            var reportMetaDataModel = new ReportMetaDataModel();

            foreach (var reportCategoryGroup in reportDefinitions.GroupBy(f => f.CategoryName))
            {
                var reportCategoryModel = new ReportCategoryModel();
                reportCategoryModel.CategoryName = reportCategoryGroup.Key;

                foreach (var reportSubCategoryGroup in reportCategoryGroup.GroupBy(f => f.SubCategoryName))
                {
                    var reportSubCategoryModel = new ReportSubCategoryModel();
                    reportSubCategoryModel.SubCategoryName   = reportSubCategoryGroup.Key;
                    reportSubCategoryModel.ReportDefinitions = reportSubCategoryGroup.ToList();

                    reportCategoryModel.ReportSubCategories.Add(reportSubCategoryModel);
                }

                reportMetaDataModel.ReportCategories.Add(reportCategoryModel);
            }

            return(Ok(reportMetaDataModel));
        }
        public void UpdateReportCategory(ReportCategoryModel model)
        {
            ReportCategory existing = this.dataContext
                                      .ReportCategories
                                      .Where(rx => rx.CategoryId == model.CategoryId)
                                      .FirstOrDefault();

            if (existing == null)
            {
                existing = model.CopyToObject(new ReportCategory()) as ReportCategory;

                this.dataContext.ReportCategories.Add(existing);
            }
            else
            {
                existing = model.CopyToObject(existing) as ReportCategory;
            }

            this.dataContext.SaveChanges();

            model = existing.CopyToObject(model) as ReportCategoryModel;
        }
        private void AddCategory_Cliked(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                string caption = this.SelectedCategory == null ? "Parent Category" : $"Child Category for {this.SelectedCategory.Header}";

                if (InputBox.ShowDialog(this.GetParentWindow(), true, "New Category", caption).IsFalse())
                {
                    return;
                }

                ReportTablesRepository repo = new ReportTablesRepository();

                long?nullLong = null;

                ReportCategoryModel model = new ReportCategoryModel
                {
                    CategoryName     = InputBox.Result,
                    IsActive         = true,
                    ParentCategoryId = this.SelectedCategory == null ? nullLong : this.SelectedCategory.Tag.ToInt64()
                };

                repo.UpdateReportCategory(model);

                if (this.SelectedCategory == null)
                {
                    this.uxCategoryTree.Items.Add(this.CreateTreeItem(model));
                }
                else
                {
                    this.SelectedCategory.Items.Add(this.CreateTreeItem(model));
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.InnerExceptionMessage());
            }
        }
예제 #8
0
        private void MergeNewValuesWithOriginal(ReportCategoryModel modelFromView)
        {
            //***************************The values that are display only will not be posted back so need to get them from session**************************

            ReportCategoryModel OriginalValuesFromSession = sessionManager.CurrentReportCategory;
        }