Inheritance: System.Web.UI.Page
コード例 #1
0
        public static async Task <APIResult> RemoveHistoryItem(APIReport report)
        {
            APIResult result = new APIResult();

            using (var request = new HttpRequestMessage(HttpMethod.Delete, $"{URL}/History/RemoveHistoryItem/"))
            {
                var json = DataContractSerializer.SerializeObject(report);
                using (var stringContent = new StringContent(json))
                {
                    request.Content = stringContent;
                    httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    try
                    {
                        using (var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead, CancellationToken.None).ConfigureAwait(false))
                        {
                            if (response.StatusCode != HttpStatusCode.OK)
                            {
                                var responseContent = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

                                StreamReader reader = new StreamReader(responseContent);
                                result.ErrorMessage = DataContractSerializer.DeserializeObject <string>(reader.ReadToEnd());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        result.ErrorMessage = $"The Server is Unavailable. Please, contact with the server administrator. Error occured: {ex.Message}";
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        public JsonResult GetChartData()
        {
            string    error  = "";
            string    token  = GetToken();
            UserModel um     = GetUser();
            var       result = APIReport.GetFrequentItemsHod(token, um.Deptid, out error);

            return(Json(new
            {
                labels = result.Select(x => x.description).ToArray(),
                data = result.Select(x => x.Quantity).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetItemTrendData(int d1, int d2, int d3, int catid)
        {
            string    error = "";
            UserModel um    = GetUser();
            string    token = GetToken();

            List <TrendAnalysisModel> result = APIReport.GetItemTrendsByDeptCategory(token, d1, d2, d3, catid, out error);

            int[] past2mon = new int[] { result[2].Dept1Data, result[2].Dept2Data, result[2].Dept3Data };
            int[] past1mon = new int[] { result[1].Dept1Data, result[1].Dept2Data, result[1].Dept3Data };
            int[] current  = new int[] { result[0].Dept1Data, result[0].Dept2Data, result[0].Dept3Data };

            return(Json(new
            {
                p2 = past2mon,
                p1 = past1mon,
                cur = current
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetItemUsageData(int s1, int s2, int s3, int item)
        {
            string    error = "";
            UserModel um    = GetUser();
            string    token = GetToken();

            List <ItemUsageModel> result = APIReport.GetItemUsage(token, s1, s2, s3, item, out error);

            int[] past2mon = new int[] { result[2].Sup1Data, result[2].Sup2Data, result[2].Sup3Data };
            int[] past1mon = new int[] { result[1].Sup1Data, result[1].Sup2Data, result[1].Sup3Data };
            int[] current  = new int[] { result[0].Sup1Data, result[0].Sup2Data, result[0].Sup3Data };

            return(Json(new
            {
                p2 = past2mon,
                p1 = past1mon,
                cur = current
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Index()
        {
            string             token      = GetToken();
            UserModel          um         = GetUser();
            string             error      = "";
            List <POCountList> reportData = new List <POCountList>();

            List <AdjustmentModel> adjs = new List <AdjustmentModel>();

            List <SupplierModel> sups = new List <SupplierModel>();

            List <PurchaseOrderModel> pos = new List <PurchaseOrderModel>();

            List <InventoryDetailModel> invs = new List <InventoryDetailModel>();

            try
            {
                reportData = APIReport.GetPoForfiveMonths(token, out error);

                // adjustment count
                adjs = APIAdjustment.GetAdjustmentByStatus(token, ConAdjustment.Active.PENDING, out error);
                if (adjs == null)
                {
                    ViewBag.AdjCount = 0;
                }
                else
                {
                    ViewBag.AdjCount = adjs.Where(x => x.Raisedto == um.Userid).Count();
                }

                sups = APISupplier.GetSupplierByStatus(ConSupplier.Active.ACTIVE, token, out error);
                if (sups == null)
                {
                    ViewBag.SupCount = 0;
                }
                else
                {
                    ViewBag.SupCount = sups.Count;
                }

                // purchase order count
                pos = APIPurchaseOrder.GetPurchaseOrderByStatus(ConPurchaseOrder.Status.PENDING, token, out error);
                if (pos == null)
                {
                    ViewBag.POCount = 0;
                }
                else
                {
                    ViewBag.POCount = pos.Count;
                }

                // item restock level needed count
                invs = APIInventory.GetAllInventoryDetails(token, out error);
                if (invs == null)
                {
                    ViewBag.RestockCount = 0;
                }
                else
                {
                    ViewBag.RestockCount = invs.Where(x => x.RecommendedOrderQty > 0).Count();
                }
                return(View("Index", reportData));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
        }