Exemplo n.º 1
0
        /// <summary>
        /// Delete the current DashboardParameters based on the DashboardParameters ID passed in the DashboardParametersModel
        /// </summary>
        /// <param name="id">
        /// The identifier.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult DeleteDashboardParameters(int id)
        {
            using (var bal = new DashboardParametersBal())
            {
                // Get DashboardParameters model object by current DashboardParameters ID
                DashboardParameters model = bal.GetDashboardParametersById(id);
                int      userId           = Helpers.GetLoggedInUserId();
                var      list             = new List <DashboardParametersCustomModel>();
                DateTime currentDate      = Helpers.GetInvariantCultureDateTime();

                // Check If DashboardParameters model is not null
                if (model != null)
                {
                    int corporateid = Helpers.GetSysAdminCorporateID();
                    int facilityid  = Helpers.GetDefaultFacilityId();

                    model.ModifiedBy   = userId;
                    model.ModifiedDate = currentDate;

                    model.CorporateId = corporateid;
                    model.FacilityId  = facilityid;

                    // Update Operation of current DashboardParameters
                    list = bal.DeleteDashboardParameters(model);

                    // return deleted ID of current DashboardParameters as Json Result to the Ajax Call.
                }

                // Pass the ActionResult with List of DashboardParametersViewModel object to Partial View DashboardParametersList
                return(this.PartialView(PartialViews.DashboardParametersList, list));
            }
        }
Exemplo n.º 2
0
        public KPIReport GetKPIReport(DashboardParameters para)
        {
            DashboardDataHelper rdHelper  = new DashboardDataHelper();
            KPIReport           kPIReport = new KPIReport();

            var TotalUnits       = rdHelper.GetTotalUnits(para);
            var UnitsWithinRange = rdHelper.GetUnitsWithinWeightRange(para);

            decimal Precision = 0;

            if (TotalUnits != 0)
            {
                Precision = (UnitsWithinRange / TotalUnits) * 100;
            }

            var UnitsWithinFillTimeLimits = rdHelper.GetUnitsWithinFillTimeLimits(para);

            decimal Performance = 0;

            if (TotalUnits != 0)
            {
                Performance = (UnitsWithinFillTimeLimits / TotalUnits) * 100;
            }


            kPIReport.Precision   = Math.Round(Precision, 2);
            kPIReport.Performance = Math.Round(Performance);
            kPIReport.Efficiency  = Math.Round((Performance + Precision) / 2, 2);


            return(kPIReport);
        }
        public List <DensityTrend> GetDensityTrend([FromBody] DashboardParameters para)
        {
            DashboardData       reportData   = new DashboardData();
            List <DensityTrend> densityTrend = reportData.GetBatchDensityTrend(para);

            return(densityTrend);
        }
        public KPIReport GetKPIReport([FromBody] DashboardParameters para)
        {
            DashboardData reportData = new DashboardData();
            KPIReport     kPIReport  = reportData.GetKPIReport(para);


            return(kPIReport);
        }
Exemplo n.º 5
0
        public DashboardReport GetDashboardReport([FromBody] DashboardParameters para)
        {
            DashboardData   reportData      = new DashboardData();
            DashboardReport dashboardReport = reportData.GetDashboardReport(para);


            return(dashboardReport);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get the details of the current DashboardParameters in the view model by ID
        /// </summary>
        /// <param name="id">
        /// The identifier.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult GetDashboardParametersDetails(int id)
        {
            using (var bal = new DashboardParametersBal())
            {
                // Call the AddDashboardParameters Method to Add / Update current DashboardParameters
                DashboardParameters current = bal.GetDashboardParametersById(id);

                // Pass the ActionResult with the current DashboardParametersViewModel object as model to PartialView DashboardParametersAddEdit
                return(this.Json(current));
            }
        }
        public PartialViewResult GetCharts(DashboardParameters parameters)
        {
            ProductAssetCharts model = new ProductAssetCharts();
            var client  = new RestClient(CommonFunctions.GetAPIPath() + "Dashboard/GetChartData");
            var request = new RestRequest(Method.POST);

            request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(parameters), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            model = JsonConvert.DeserializeObject <ProductAssetCharts>(response.Content);
            return(PartialView("_ProductAssetDetails", model));
        }
        public PartialViewResult GetSlidersData(DashboardParameters parameters)
        {
            Slider model   = new Slider();
            var    client  = new RestClient(CommonFunctions.GetAPIPath() + "Dashboard/GetSliderDetails");
            var    request = new RestRequest(Method.POST);

            request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(parameters), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            model.Details = JsonConvert.DeserializeObject <List <Slider> >(response.Content);
            return(PartialView("_SliderDetails", model));
        }
Exemplo n.º 9
0
        public List <DensityTrend> GetBatchDensityTrend(DashboardParameters para)
        {
            IQueryable <TransactionLog> result = _db.TransactionLogs;
            string rptStartDate = "";
            string rptEndDate   = "";

            if (para.ProductCode != "All")
            {
                result = result.Where(p => p.ProductCode == para.ProductCode);
            }
            if (para.Duration == 0)
            {
                DateTime dateTimeFrom = DateHelper.StartOfDay(DateTime.Now).ToUniversalTime();
                DateTime dateTimeTo   = DateHelper.EndOfDay(DateTime.Now).ToUniversalTime();
                result = result.Where(p => (p.TransactionDate >= dateTimeFrom && p.TransactionDate <= dateTimeTo));

                rptStartDate.ToString();
                rptEndDate = dateTimeTo.ToString();
            }
            else
            {
                DateTime start = DateHelper.StartDate(para.Duration);
                DateTime end   = DateHelper.EndDate(para.Duration);

                DateTime dateTimeFrom = DateHelper.StartOfDay(start).ToUniversalTime();
                DateTime dateTimeTo   = DateHelper.EndOfDay(end).ToUniversalTime();

                result = result.Where(p => (p.TransactionDate >= dateTimeFrom && p.TransactionDate <= dateTimeTo));
                rptStartDate.ToString();
                rptEndDate = dateTimeTo.ToString();
            }

            List <DensityTrend> data = result
                                       .Where(p => p.ClientId == para.ClientId)
                                       .GroupBy(p => new { p.BatchCode }, (key, group) => new
            {
                BatchCode = key.BatchCode,
                Result    = group.ToList()
            })
                                       .Select(s => new DensityTrend
            {
                BatchCode  = s.BatchCode,
                startDate  = rptStartDate,
                endDate    = rptEndDate,
                avgDensity = s.Result.Average(p => p.ProductDensity)
            }).ToList();

            return(data.ToList());
        }
Exemplo n.º 10
0
        /// <summary>
        /// Method to Delete the Entity in the database.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public List <DashboardParametersCustomModel> DeleteDashboardParameters(DashboardParameters model)
        {
            using (var rep = UnitOfWork.DashboardParametersRepository)
            {
                if (model.ParameterId > 0)
                {
                    var current = rep.GetSingle(model.ParameterId);

                    rep.Delete(model.ParameterId);
                }

                var list = GetDashboardParametersList(model.CorporateId, model.FacilityId);
                return(list);
            }
        }
        public async Task <PartialViewResult> GetCashFlowTable(DashboardParameters param)
        {
            CashFlowData model        = new CashFlowData();
            JsonResponse jsonResponse = new JsonResponse();
            var          client       = new RestClient(CommonFunctions.GetAPIPath() + "Dashboard/GetCashFlowDataSummary");
            var          request      = new RestRequest(Method.POST);

            request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(param), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            jsonResponse            = JsonConvert.DeserializeObject <JsonResponse>(response.Content);
            model.cashFlowDatasList = JsonConvert.DeserializeObject <List <CashFlowData> >(jsonResponse.Data.ToString());
            model.LastUpdatedOn     = jsonResponse.LastUpdatedOn;
            HttpContext.Session.SetObject("CashGridData", model.cashFlowDatasList);
            return(PartialView("_CashFlowDataTable", model));
        }
        /// <summary>
        /// Method for getting Software mapping list
        /// </summary>
        /// <param name="param"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>'Session has not been configured for this application or request.'

        public JsonResult GetAssetSummary(DashboardParameters param)
        {
            JsonResponse jsonResponse = new JsonResponse();
            var          client       = new RestClient(CommonFunctions.GetAPIPath() + "Dashboard/GetAssetDataSummary");
            var          request      = new RestRequest(Method.POST);

            request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(param), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            jsonResponse = JsonConvert.DeserializeObject <JsonResponse>(response.Content);
            IEnumerable <AssetData> summary = JsonConvert.DeserializeObject <IEnumerable <AssetData> >(jsonResponse.Data.ToString());

            HttpContext.Session.SetObject("GridData", summary);

            int totalconsumable = summary.Count();
            var sortDirection   = HttpContext.Request.Query["sSortDir_0"]; // asc or desc
            var sortColumnIndex = Convert.ToInt32(HttpContext.Request.Query["iSortCol_0"]);

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                summary = summary.Where(z => z.AssetClass.ToLower().Contains(param.sSearch.ToLower()));
            }
            summary = sortColumnIndex switch
            {
                0 => sortDirection == "asc" ? summary.OrderBy(z => z.AssetClass) : summary.OrderByDescending(z => z.AssetClass),
                1 => sortDirection == "asc" ? summary.OrderBy(z => z.ValueAtCost) : summary.OrderByDescending(z => z.ValueAtCost),
                2 => sortDirection == "asc" ? summary.OrderBy(z => z.MarketValue) : summary.OrderByDescending(z => z.MarketValue),
                3 => sortDirection == "asc" ? summary.OrderBy(z => z.Weightage) : summary.OrderByDescending(z => z.Weightage),
                _ => sortDirection == "desc" ? summary.OrderBy(z => z.UnrealizedGL) : summary.OrderByDescending(z => z.UnrealizedGL),
            };
            int filteredconsumableCount = summary.Count();

            if (param.iDisplayLength > 0)
            {
                summary = summary.Skip(param.iDisplayStart).Take(param.iDisplayLength);
            }
            return(Json(new
            {
                param.sEcho,
                iTotalRecords = totalconsumable,
                iTotalDisplayRecords = filteredconsumableCount,
                aaData = summary
            }));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Method to add/Update the Entity in the database.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public List <DashboardParametersCustomModel> SaveDashboardParameters(DashboardParameters model)
        {
            using (var rep = UnitOfWork.DashboardParametersRepository)
            {
                if (model.ParameterId > 0)
                {
                    var current = rep.GetSingle(model.ParameterId);
                    model.CreatedBy   = current.CreatedBy;
                    model.CreatedDate = current.CreatedDate;
                    rep.UpdateEntity(model, model.ParameterId);
                }
                else
                {
                    rep.Create(model);
                }

                var list = GetDashboardParametersList(model.CorporateId, model.FacilityId);
                return(list);
            }
        }
        public decimal GetUnitsWithinFillTimeLimits(DashboardParameters para)
        {
            IQueryable <TransactionLog> result = _db.TransactionLogs;

            if (para.Plant != "All")
            {
                result = result.Where(p => p.PlantId == para.Plant);
            }
            if (para.FillingMachine != "All")
            {
                result = result.Where(p => p.MachineName == para.FillingMachine);
            }
            if (para.ProductCode != "All")
            {
                result = result.Where(p => p.ProductCode == para.ProductCode);
            }
            if (para.Duration == 0)
            {
                DateTime dateTimeFrom = DateHelper.StartOfDay(DateTime.Now).ToUniversalTime();
                DateTime dateTimeTo   = DateHelper.EndOfDay(DateTime.Now).ToUniversalTime();
                result = result.Where(p => (p.TransactionDate >= dateTimeFrom && p.TransactionDate <= dateTimeTo));
            }
            else
            {
                DateTime start = DateHelper.StartDate(para.Duration);
                DateTime end   = DateHelper.EndDate(para.Duration);

                DateTime dateTimeFrom = DateHelper.StartOfDay(start).ToUniversalTime();
                DateTime dateTimeTo   = DateHelper.EndOfDay(end).ToUniversalTime();

                result = result.Where(p => (p.TransactionDate >= dateTimeFrom && p.TransactionDate <= dateTimeTo));
            }

            var data = result
                       .Where(p => p.ClientId == para.ClientId && p.ActualFillTime <= p.ExpectedFillTime);


            return(data.Count());
        }
Exemplo n.º 15
0
        /// <summary>
        /// Add New or Update the DashboardParameters based on if we pass the DashboardParameters ID in the
        ///     DashboardParametersViewModel object.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// returns the newly added or updated ID of DashboardParameters row
        /// </returns>
        public ActionResult SaveDashboardParameters(DashboardParameters model)
        {
            // Initialize the newId variable
            int      userId      = Helpers.GetLoggedInUserId();
            DateTime currentDate = Helpers.GetInvariantCultureDateTime();
            var      list        = new List <DashboardParametersCustomModel>();

            // Check if Model is not null
            if (model != null)
            {
                int corporateid = Helpers.GetSysAdminCorporateID();
                int facilityid  = Helpers.GetDefaultFacilityId();
                model.CorporateId = corporateid;
                model.FacilityId  = facilityid;

                using (var bal = new DashboardParametersBal())
                {
                    if (model.ParameterId > 0)
                    {
                        model.ModifiedBy   = userId;
                        model.ModifiedDate = currentDate;
                    }
                    else
                    {
                        model.CreatedBy   = userId;
                        model.CreatedDate = currentDate;
                    }

                    // Call the AddDashboardParameters Method to Add / Update current DashboardParameters
                    list = bal.SaveDashboardParameters(model);
                }
            }

            // Pass the ActionResult with List of DashboardParametersViewModel object to Partial View DashboardParametersList
            return(this.PartialView(PartialViews.DashboardParametersList, list));
        }
Exemplo n.º 16
0
        public DashboardReport GetDashboardReport(DashboardParameters para)
        {
            IQueryable <TransactionLog> result = _db.TransactionLogs;

            if (para.Plant != "All")
            {
                result = result.Where(p => p.PlantId == para.Plant);
            }
            if (para.FillingMachine != "All")
            {
                result = result.Where(p => p.MachineName == para.FillingMachine);
            }
            if (para.ProductCode != "All")
            {
                result = result.Where(p => p.ProductCode == para.ProductCode);
            }
            if (para.Duration == 0)
            {
                DateTime dateTimeFrom = DateHelper.StartOfDay(DateTime.Now).ToUniversalTime();
                DateTime dateTimeTo   = DateHelper.EndOfDay(DateTime.Now).ToUniversalTime();
                result = result.Where(p => (p.TransactionDate >= dateTimeFrom && p.TransactionDate <= dateTimeTo));
            }
            else
            {
                DateTime start = DateHelper.StartDate(para.Duration);
                DateTime end   = DateHelper.EndDate(para.Duration);

                DateTime dateTimeFrom = DateHelper.StartOfDay(start).ToUniversalTime();
                DateTime dateTimeTo   = DateHelper.EndOfDay(end).ToUniversalTime();

                result = result.Where(p => (p.TransactionDate >= dateTimeFrom && p.TransactionDate <= dateTimeTo));
            }

            ///.Where(p => (p.TransactionDate >= para.DateFrom && p.TransactionDate <= para.DateTo))

            var data = result
                       .Where(p => p.ClientId == para.ClientId)
                       .GroupBy(p => p.ProductCode)
                       .Select(s => new DashboardReport
            {
                Units           = s.Count(),
                RequiredWeight  = s.Sum(p => p.TargetWeight),
                ActualWeight    = s.Sum(p => p.ActualWeight),
                AverageWeight   = s.Average(p => p.ActualWeight),
                PercDiffWeight  = ((s.Sum(p => p.ActualWeight) - s.Sum(p => p.TargetWeight)) / s.Sum(p => p.TargetWeight)) * 100,
                AverageFillTime = s.Average(p => p.ActualFillTime)
            }).FirstOrDefault();

            if (data == null)
            {
                data = new DashboardReport
                {
                    Units           = 0,
                    RequiredWeight  = 0,
                    ActualWeight    = 0,
                    AverageWeight   = 0,
                    PercDiffWeight  = 0,
                    AverageFillTime = 0
                };
            }

            return((DashboardReport)data);
        }