예제 #1
0
        public JsonResult InsertExceldata()
        {
            var result           = new ModelJsonResult <ModelInsertExcelData>();
            var modelInsertExcel = new ModelInsertExcelData();

            try
            {
                string inYear = Request["year"];

                HttpFileCollectionBase files = Request.Files;


                if (files == null || 0.Equals(files.Count))
                {
                    result.SetError("No File Data To Load");
                    return(Json(result));
                }

                var fb = files[0];

                if (fb == null || fb.InputStream == null)
                {
                    result.SetError("No File Data To Load");
                    return(Json(result));
                }
                string exttension = System.IO.Path.GetExtension(fb.FileName);
                if (!(new string[] { ".xls", ".xlsx" }).Contains(exttension))
                {
                    result.SetError("File Type Not In xls or xlsx");
                    return(Json(result));
                }

                insertExcelRiskManagementData(
                    pFileStream: fb.InputStream,
                    pStrUploadBy: User.Identity.Name,
                    pIntYear: inYear.GetInt(),
                    pModelResult: modelInsertExcel
                    );
                result.SetResultValue(modelInsertExcel);

                return(Json(result));
            }
            catch (Exception ex)
            {
                result.SetException(ex);
                return(Json(result));
            }
        }
예제 #2
0
        public JsonResult IsDuplicateExcelData()
        {
            var    result = new ModelJsonResult <bool>();
            string inYear = Request["year"];

            HttpFileCollectionBase files = Request.Files;

            if (files == null || 0.Equals(files.Count))
            {
                result.SetError("No File Data To Load");
                return(Json(result));
            }

            var fb = files[0];

            if (fb == null || fb.InputStream == null)
            {
                result.SetError("No File Data To Load");
                return(Json(result));
            }

            string exttension = System.IO.Path.GetExtension(fb.FileName);

            if (!(new string[] { ".xls", ".xlsx" }).Contains(exttension))
            {
                result.SetError("File Type Not In xls or xlsx");
                return(Json(result));
            }

            var  dto                = new DTO.DtoRisk();
            bool isDuplicate        = false;
            var  listRiskManagement = dto.ReadExcelRiskManagementImport(
                pStreamExcel: fb.InputStream,
                pIntYear: inYear.GetInt(),
                pStrUploadBy: User.Identity.Name
                );

            isDuplicate = dto.GetListRiskManagementImportDuplicate(listRiskManagement).Any();
            result.SetResultValue(isDuplicate);

            return(Json(result));
        }
예제 #3
0
        private ModelJsonResult <ModelOmIndex> GetData(string pStrYear, string pStrMonth, string[] pArrRegion, string mode)
        {
            ModelJsonResult <ModelOmIndex> result = new ModelJsonResult <ModelOmIndex>();

            try
            {
                // Inint
                ModelOmIndex modelOm          = new ModelOmIndex();
                DtoOM        dto              = new DtoOM();
                int          _intMonth        = pStrMonth == null ? DateTime.Now.Month : pStrMonth.GetInt();
                int          intYear          = pStrYear == null ? DateTime.Now.Year : pStrYear.GetInt();
                int          intMonth         = mode.Equals("yearly") ? 12 : _intMonth;
                var          maintenanceLevel = dto.GetListMaintenanceLevelColor();

                // Master Data
                modelOm.ListRegion = dto.GetListRegion()
                                     .OrderBy(x => x.REGION_NAME.Length)
                                     .ThenBy(x => x.REGION_NAME)
                                     .ToList();
                modelOm.Mode   = mode;
                modelOm.Year   = intYear;
                modelOm.Month  = intMonth;
                modelOm.Master = new ModelOMMaster
                {
                    Pipeline         = dto.GetPipelineActivity(),
                    MaintenanceLevel = maintenanceLevel
                };

                // Summary
                List <ModelMonitoringResults> listPipeline     = dto.GetListOMPipelineHistory(intMonth, intYear, pArrRegion, true);
                List <ModelPlanYearly>        listPipelinePlan = dto.GetListOMPipelinePlanYearly(intYear, pArrRegion);
                List <ModelMonitoringResults> listGate         = dto.GetListOMGateHistory(intMonth, intYear, pArrRegion, true);
                List <ModelPlanYearly>        listGatePlan     = dto.GetListOMGatePlanYearly(intYear, pArrRegion);
                List <ModelMonitoringResults> listMeter        = dto.GetListOMMeterHistory(intMonth, intYear, pArrRegion, true);
                List <ModelPlanYearly>        listMeterPlan    = dto.GetListOMMeterPlanYearly(intYear, pArrRegion);

                modelOm.Summary = new ModelOMSummary
                {
                    Pipeline = new ModelOMSummaryPipeline(intMonth, listPipeline, mode, listPipelinePlan),
                    Gate     = new ModelOMSummaryMaintenanceLevel(intMonth, intYear, listGate, mode, listGatePlan),
                    Meter    = new ModelOMSummaryMaintenanceLevel(intMonth, intYear, listMeter, mode, listMeterPlan),
                };

                modelOm.Completion = new ModelOMCompletion
                {
                    Pipeline = new ModelOMCompletionPipeline(intMonth, listPipeline, mode),
                    Gate     = new ModelOMCompletionMaintenanceLevel(intMonth, intYear, listGate, mode),
                    Meter    = new ModelOMCompletionMaintenanceLevel(intMonth, intYear, listMeter, mode),
                };

                ModelOMAccumulated accumulated = new ModelOMAccumulated();

                accumulated.getPipeline(intMonth, intYear, listPipeline, mode);
                accumulated.getGate(intMonth, intYear, listGate, mode);
                accumulated.getMeter(intMonth, intYear, listMeter, mode);
                modelOm.Accumulated = accumulated;

                result.SetResultValue(modelOm);
                dto = null;
                GC.Collect();
            }
            catch (Exception ex)
            {
                throw ex;
                //result.SetException(ex);
            }

            return(result);
        }