Exemplo n.º 1
0
        public ActionResult ListDetailedDeliveryReport(int channel, int postman, int postcode, int deliveryroute, int status, string fromdate, string todate, int?page)
        {
            int currentPageIndex = page.HasValue ? page.Value : 1;

            ViewBag.currentPageIndex = currentPageIndex;
            ViewBag.PageSize         = page_size;
            ReturnDelivery returndelivery = new ReturnDelivery();

            returndelivery     = apiRepository.ListDeliveryReport(channel, postman, postcode, deliveryroute, status, common.DateToInt(fromdate), common.DateToInt(todate), page_size, currentPageIndex);
            ViewBag.total      = returndelivery.Total;
            ViewBag.total_page = (returndelivery.Total + page_size - 1) / page_size;
            return(View(returndelivery.ListDeliveryReport));
        }
Exemplo n.º 2
0
        public ReturnDelivery ListDeliveryReport(int channel, int postman, int postcode, int deliveryroute, int status, int fromdate, int todate, int page_size, int page_index)
        {
            ReturnDelivery returndelivery = new ReturnDelivery();

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConfigurationManager.AppSettings["URI"]);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    //var byteArray = Encoding.ASCII.GetBytes(ConfigurationManager.AppSettings["Username"] + ":" + ConfigurationManager.AppSettings["Password"]);
                    //client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
                    var _response = client.GetAsync("api/Delivery?channel=" + channel + "&&postman=" + postman + "&&status=" + status + "&&from_date=" + fromdate + "&&to_date=" + todate + "&&delivery_post_code=" + postcode + "&&delivery_route_code=" + deliveryroute + "&&page_size=" + page_size + "&&page_index=" + page_index).Result;
                    returndelivery = _response.Content.ReadAsAsync <ReturnDelivery>().Result;
                }
            }
            catch (Exception ex)
            {
                // LogAPI.LogToFile(LogFileType.EXCEPTION, "ApiRepository.Post_E1E2_DS: " + ex.Message);
            }
            return(returndelivery);
        }
Exemplo n.º 3
0
        public ReturnDelivery DELIVERY_DEPART_DETAIL(int channel, int post_man, int status, int from_date, int to_date, int delivery_post_code, int delivery_route_code, int page_size, int page_index)
        {
            MetaData       _metadata       = new MetaData();
            Convertion     common          = new Convertion();
            ReturnDelivery _returnDelivery = new ReturnDelivery();

            switch (channel)
            {
            case 0:
                _metadata.channel = "Tất cả"; break;

            case 1:
                _metadata.channel = "EmsEnterprise"; break;

            case 2:
                _metadata.channel = "SmartPhone"; break;
            }
            if (post_man == 0)
            {
                _metadata.postman = "Tất cả";
            }
            else
            {
                _metadata.postman = "Bưu tá: " + post_man.ToString();
            }

            switch (status)
            {
            case 0:
                _metadata.status = "Tất cả"; break;

            case 1:
                _metadata.status = "Thành công"; break;

            case 2:
                _metadata.status = "Không thành công"; break;
            }
            _metadata.from_to_date = "Từ ngày " + common.Convert_Date(from_date) + " đến ngày " + common.Convert_Date(to_date);
            if (delivery_post_code == 0)
            {
                _metadata.delivery_post_code = "Tất cả";
            }
            else
            {
                _metadata.delivery_post_code = "Bưu cục phát: " + delivery_post_code;
            }

            if (delivery_route_code == 0)
            {
                _metadata.delivery_route_code = "Tất cả";
            }
            else
            {
                _metadata.delivery_route_code = "Tuyến phát: " + delivery_route_code;
            }
            _returnDelivery.MetaData = _metadata;
            List <DeliveryDetail> listDeliveryDetail = null;
            DeliveryDetail        oDeliveryDetail    = null;

            try
            {
                // Gọi vào DB để lấy dữ liệu.
                using (OracleCommand cmd = new OracleCommand())
                {
                    cmd.Connection  = Helper.OraDCOracleConnection;
                    cmd.CommandText = Helper.SchemaName + "DELIVERY_PKG.DELIVERY_DEPART_DETAIL";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new OracleParameter("P_DELIVERY_POST_CODE", OracleDbType.Int32)).Value  = delivery_post_code;
                    cmd.Parameters.Add(new OracleParameter("P_DELIVERY_ROUTE_CODE", OracleDbType.Int32)).Value = delivery_route_code;
                    cmd.Parameters.Add(new OracleParameter("P_STATUS", OracleDbType.Int32)).Value     = status;
                    cmd.Parameters.Add(new OracleParameter("P_FROM_DATE", OracleDbType.Int32)).Value  = from_date;
                    cmd.Parameters.Add(new OracleParameter("P_TO_DATE", OracleDbType.Int32)).Value    = to_date;
                    cmd.Parameters.Add(new OracleParameter("P_CHANNEL", OracleDbType.Int32)).Value    = channel;
                    cmd.Parameters.Add(new OracleParameter("P_POSTMAN", OracleDbType.Int32)).Value    = post_man;
                    cmd.Parameters.Add(new OracleParameter("P_PAGE_INDEX", OracleDbType.Int32)).Value = page_index;
                    cmd.Parameters.Add(new OracleParameter("P_PAGE_SIZE", OracleDbType.Int32)).Value  = page_size;
                    cmd.Parameters.Add("P_TOTAL", OracleDbType.Int32, 0, ParameterDirection.Output);
                    cmd.Parameters.Add("P_RETURN_CODE", OracleDbType.Int32, 0, ParameterDirection.Output);
                    cmd.Parameters.Add("P_OUT_CURSOR", OracleDbType.RefCursor, null, ParameterDirection.Output);
                    OracleDataReader dr = Helper.ExecuteDataReader(cmd, Helper.OraDCOracleConnection);
                    if (float.Parse(cmd.Parameters["P_RETURN_CODE"].Value.ToString()) > 0)
                    {
                        if (dr.HasRows)
                        {
                            listDeliveryDetail = new List <DeliveryDetail>();
                            while (dr.Read())
                            {
                                oDeliveryDetail                     = new DeliveryDetail();
                                oDeliveryDetail.CHANNEL             = dr["CHANNEL"].ToString();
                                oDeliveryDetail.LADING_CODE         = dr["MAE1"].ToString();
                                oDeliveryDetail.DELIVERY_DATE_TIME  = dr["DELIVERY_DATE_TIME"].ToString();
                                oDeliveryDetail.SYSTEM_DATE_TIME    = dr["SYSTEM_DATE_TIME"].ToString();
                                oDeliveryDetail.DELIVERY_RESULT     = dr["DELIVERY_RESULT"].ToString();
                                oDeliveryDetail.REASON              = dr["REASON"].ToString();
                                oDeliveryDetail.FEE                 = Convert.ToInt32(dr["FEE"].ToString());
                                oDeliveryDetail.AMOUNT              = Convert.ToInt32(dr["AMOUNT"].ToString());
                                oDeliveryDetail.DELIVERY_POST_CODE  = Convert.ToInt32(dr["DELIVERY_POST_CODE"].ToString());
                                oDeliveryDetail.DELIVERY_ROUTE_CODE = Convert.ToInt32(dr["DELIVERY_ROUTE_CODE"].ToString());
                                oDeliveryDetail.COME_DATE           = dr["COME_DATE"].ToString();
                                oDeliveryDetail.REMAIN_DATE         = dr["REMAIN_DATE"].ToString();
                                oDeliveryDetail.POSTMAN_ID          = dr["POST_MAN"].ToString();
                                oDeliveryDetail.SERVICE_TYPE        = dr["DV"].ToString();
                                oDeliveryDetail.ID_PROCESS          = int.Parse(dr["ID"].ToString());
                                listDeliveryDetail.Add(oDeliveryDetail);
                            }
                            _returnDelivery.Code               = "00";
                            _returnDelivery.Message            = "Lấy dữ liệu thành công.";
                            _returnDelivery.Total              = Convert.ToInt32(cmd.Parameters["P_TOTAL"].Value.ToString());
                            _returnDelivery.ListDeliveryReport = listDeliveryDetail;
                        }
                    }
                    else
                    {
                        _returnDelivery.Code               = "01";
                        _returnDelivery.Message            = "Không tồn tại bản ghi nào.";
                        _returnDelivery.Total              = 0;
                        _returnDelivery.ListDeliveryReport = null;
                    }
                }
            }
            catch
            {
                _returnDelivery.Code               = "99";
                _returnDelivery.Message            = "Lỗi xử lý dữ liệu";
                _returnDelivery.Total              = 0;
                _returnDelivery.ListDeliveryReport = null;
            }
            return(_returnDelivery);
        }