예제 #1
0
        public BoxManage(HttpSessionStateBase session)
        {
            db = new QDLogisticsEntities();

            TimeZoneConvert = new TimeZoneConvert();
            Session         = session;
        }
예제 #2
0
파일: OrderPreset.cs 프로젝트: leeleonis/QD
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                if (Orders != null)
                {
                    Orders.Dispose();
                }
                if (Packages != null)
                {
                    Packages.Dispose();
                }
                if (Items != null)
                {
                    Items.Dispose();
                }
                if (Preset != null)
                {
                    Preset.Dispose();
                }
            }

            db       = null;
            Session  = null;
            disposed = true;
        }
예제 #3
0
        public OrderSyncController()
        {
            db = new QDLogisticsEntities();

            SyncOn = DateTime.UtcNow;
            Today  = new TimeZoneConvert().ConvertDateTime(EnumData.TimeZone.EST);
        }
예제 #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (db != null)
         {
             db.Dispose();
             db = null;
         }
     }
 }
예제 #5
0
파일: OrderPreset.cs 프로젝트: leeleonis/QD
        public OrderPreset(HttpSessionStateBase session, Orders order)
        {
            db       = new QDLogisticsEntities();
            Orders   = new GenericRepository <Orders>(db);
            Packages = new GenericRepository <Packages>(db);
            Items    = new GenericRepository <Items>(db);
            Preset   = new GenericRepository <Preset>(db);

            PresetList      = db.Preset.AsNoTracking().Where(p => p.IsEnable && p.IsVisible).OrderBy(p => p.Type).OrderBy(p => p.Priority).ToList();
            MethodOfService = db.Services.AsNoTracking().Where(s => s.IsEnable.Value && s.ShippingMethod.HasValue).ToDictionary(s => s.ServiceCode, s => s.ShippingMethod.Value);
            MethodOfService.Add("Expedited", 9);
            this.Order   = order;
            this.Session = session;
        }
예제 #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
            }

            db.Dispose();
            db       = null;
            disposed = true;
        }
예제 #7
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: 處置受控狀態 (受控物件)。
                }

                // TODO: 釋放非受控資源 (非受控物件) 並覆寫下方的完成項。
                // TODO: 將大型欄位設為 null。

                db       = null;
                itemData = null;

                disposedValue = true;
            }
        }
예제 #8
0
        protected virtual void Dispose(bool disposing)
        {
            if (Disposed)
            {
                return;
            }

            if (disposing)
            {
            }

            db.Dispose();
            db              = null;
            boxData         = null;
            TimeZoneConvert = null;
            Session         = null;
            Disposed        = true;
        }
예제 #9
0
        public Winit_API(CarrierAPI Api)
        {
            db = new QDLogisticsEntities();

            if (Api == null)
            {
                Api = db.CarrierAPI.AsNoTracking().FirstOrDefault(api => api.Id.Equals(17));

                if (Api == null)
                {
                    throw new Exception("Carrier Api not found!");
                }
            }

            api_url      = string.Format("http://{0}.winit.com.cn/ADInterface/api", Api.IsTest ? "erp.sandbox" : "api");
            api_key      = Api.ApiKey;
            api_userName = Api.ApiAccount;
            api_password = Api.ApiPassword;
            api_token    = _Get_Token();
        }
예제 #10
0
        public SyncProcess(HttpSessionStateBase Session)
        {
            db            = new QDLogisticsEntities();
            Orders        = new GenericRepository <Orders>(db);
            Addresses     = new GenericRepository <Addresses>(db);
            Payments      = new GenericRepository <Payments>(db);
            Packages      = new GenericRepository <Packages>(db);
            Items         = new GenericRepository <Items>(db);
            BundleItems   = new GenericRepository <BundleItems>(db);
            SerialNumbers = new GenericRepository <SerialNumbers>(db);
            PurchaseItems = new GenericRepository <PurchaseItemReceive>(db);

            SyncOn = DateTime.UtcNow;
            Today  = new TimeZoneConvert().ConvertDateTime(EnumData.TimeZone.EST);

            this.Session = Session;
            string UserName = MyHelp.get_session("ApiUserName", Session, "*****@*****.**").ToString();
            string Password = MyHelp.get_session("ApiPassword", Session, "timfromweypro").ToString();

            SCWS = new SC_WebService(UserName, Password);
        }
예제 #11
0
 public CompanyController()
 {
     db        = new QDLogisticsEntities();
     Companies = new GenericRepository <Companies>(db);
 }
예제 #12
0
 public CheckSessionAttribute()
 {
     db = new QDLogisticsEntities();
 }
예제 #13
0
 public CaseEventController()
 {
     db = new QDLogisticsEntities();
 }
예제 #14
0
 public OverviewController()
 {
     db = new QDLogisticsEntities();
 }
예제 #15
0
파일: OrderPreset.cs 프로젝트: leeleonis/QD
        private void Dispatch(Packages package)
        {
            if (Order.StatusCode.Value.Equals((int)OrderStatusCode.InProcess) && Order.PaymentStatus.Equals((int)OrderPaymentStatus.Charged))
            {
                ThreadTask threadTask = new ThreadTask(string.Format("訂單下載 - 自動提交訂單【{0}】至待出貨區", Order.OrderID), Session);
                MyHelp.Log("Orders", Order.OrderID, string.Format("訂單下載 - 自動提交訂單【{0}】至待出貨區", Order.OrderID), Session);

                package.ProcessStatus = (int)EnumData.ProcessStatus.鎖定中;
                Packages.Update(package, package.ID);

                lock (Factory)
                {
                    threadTask.AddWork(Factory.StartNew(Session =>
                    {
                        threadTask.Start();

                        string message = "";
                        using (QDLogisticsEntities db = new QDLogisticsEntities())
                        {
                            IRepository <Packages> Packages       = new GenericRepository <Packages>(db);
                            IRepository <PickProduct> PickProduct = new GenericRepository <PickProduct>(db);

                            Packages packageData = Packages.Get(package.ID);

                            try
                            {
                                HttpSessionStateBase session = (HttpSessionStateBase)Session;
                                SC_WebService SCWS           = new SC_WebService("*****@*****.**", "timfromweypro");

                                if (!SCWS.Is_login)
                                {
                                    throw new Exception("SC is not login");
                                }

                                OrderStateInfo order = SCWS.Get_OrderStatus(packageData.OrderID.Value);

                                if ((int)order.PaymentStatus == package.Orders.PaymentStatus)
                                {
                                    ShipProcess shipProcess = new ShipProcess(SCWS);

                                    MyHelp.Log("Orders", packageData.OrderID, "提交至待出貨區", session);

                                    /***** 上傳Item出貨倉 *****/
                                    var SC_order = SCWS.Get_OrderData(packageData.OrderID.Value).Order;
                                    var SC_items = SC_order.Items.Where(i => i.PackageID.Equals(packageData.ID)).ToArray();
                                    foreach (var item in SC_items)
                                    {
                                        if (!db.Skus.AsNoTracking().Any(s => s.Sku.Equals(item.ProductID)))
                                        {
                                            throw new Exception(string.Format("系統尚未有品號 {0} 資料!", item.ProductID));
                                        }

                                        item.ShipFromWareHouseID = packageData.Items.First(i => i.IsEnable == true && i.ID == item.ID).ShipFromWarehouseID.Value;
                                        SCWS.Update_OrderItem(SC_items.First(i => i.ID.Equals(item.ID)));
                                    }
                                    MyHelp.Log("Orders", packageData.OrderID, "更新訂單包裹的出貨倉", session);

                                    /***** 更新客戶地址 *****/
                                    var address = SC_order.ShippingAddress;
                                    DataProcess.SetAddressData(packageData.Orders.Addresses, address, SC_order.BillingAddress);

                                    /***** 檢查運送國家 *****/
                                    if (!string.IsNullOrEmpty(packageData.Method.CountryData))
                                    {
                                        var countryData = JsonConvert.DeserializeObject <Dictionary <string, bool> >(packageData.Method.CountryData);
                                        if (!countryData.ContainsKey(packageData.Orders.Addresses.CountryCode.ToUpper()))
                                        {
                                            throw new Exception(string.Format("訂單【{0}】國家名稱不合,請重新確認", packageData.OrderID));
                                        }

                                        if (!countryData[packageData.Orders.Addresses.CountryCode.ToUpper()])
                                        {
                                            throw new Exception(string.Format("訂單【{0}】不可寄送至國家{1}", packageData.OrderID, packageData.Orders.Addresses.CountryName));
                                        }
                                    }

                                    shipProcess.Init(packageData);
                                    var result = shipProcess.Dispatch();

                                    if (result.Status)
                                    {
                                        MyHelp.Log("Orders", packageData.OrderID, "訂單提交完成", session);

                                        if (packageData.Items.First(i => i.IsEnable.Value).ShipWarehouses.Name.Equals("TWN"))
                                        {
                                            int[] itemIDs = packageData.Items.Where(i => i.IsEnable.Value).Select(i => i.ID).ToArray();
                                            List <PickProduct> pickList = PickProduct.GetAll(true).Where(p => itemIDs.Contains(p.ItemID.Value)).ToList();
                                            foreach (Items item in packageData.Items.Where(i => i.IsEnable == true))
                                            {
                                                PickProduct pick = pickList.FirstOrDefault(pk => pk.ItemID == item.ID);

                                                if (pick != null)
                                                {
                                                    pick.IsEnable  = true;
                                                    pick.IsPicked  = false;
                                                    pick.IsMail    = false;
                                                    pick.QtyPicked = 0;
                                                    DataProcess.setPickProductData(pick, item);
                                                    PickProduct.Update(pick, pick.ID);
                                                }
                                                else
                                                {
                                                    pick = new PickProduct()
                                                    {
                                                        IsEnable = true
                                                    };
                                                    DataProcess.setPickProductData(pick, item);
                                                    PickProduct.Create(pick);
                                                }
                                            }
                                            PickProduct.SaveChanges();
                                        }

                                        packageData.ProcessStatus = (int)EnumData.ProcessStatus.待出貨;
                                    }
                                    else
                                    {
                                        message = result.Message;
                                        packageData.ProcessStatus = (int)EnumData.ProcessStatus.訂單管理;
                                    }
                                }
                                else
                                {
                                    message = "Payment status is different";
                                    packageData.Orders.StatusCode = (int)OrderStatusCode.OnHold;
                                    packageData.ProcessStatus     = (int)EnumData.ProcessStatus.訂單管理;
                                }

                                Packages.Update(packageData, packageData.ID);
                                Packages.SaveChanges();
                            }
                            catch (Exception e)
                            {
                                message = e.InnerException != null && !string.IsNullOrEmpty(e.InnerException.Message) ? e.InnerException.Message : e.Message;
                                packageData.ProcessStatus = (int)EnumData.ProcessStatus.訂單管理;

                                if (!string.IsNullOrEmpty(package.WinitNo))
                                {
                                    Winit_API winit = new Winit_API();
                                    winit.CancelOutboundOrder(package.WinitNo);
                                    package.WinitNo = null;
                                }

                                Packages.Update(packageData, packageData.ID);
                                Packages.SaveChanges();
                            }
                        }

                        return(message);
                    }, Session));
                }
            }
        }
예제 #16
0
 public DropShipController()
 {
     db = new QDLogisticsEntities();
 }
예제 #17
0
 public ShippingController()
 {
     db         = new QDLogisticsEntities();
     Carriers   = new GenericRepository <Carriers>(db);
     CarrierAPI = new GenericRepository <CarrierAPI>(db);
 }
예제 #18
0
 public InventoryController()
 {
     db = new QDLogisticsEntities();
 }
예제 #19
0
 public TaskController()
 {
     db = new QDLogisticsEntities();
 }
예제 #20
0
 public MainController()
 {
     db         = new QDLogisticsEntities();
     AdminUsers = new GenericRepository <AdminUsers>(db);
 }
예제 #21
0
 public PresetController()
 {
     db = new QDLogisticsEntities();
 }
예제 #22
0
 public WarehouseController()
 {
     db         = new QDLogisticsEntities();
     Warehouses = new GenericRepository <Warehouses>(db);
     Method     = new GenericRepository <ShippingMethod>(db);
 }
예제 #23
0
 public GenericRepository(QDLogisticsEntities db)
 {
     this.db    = db;
     this.dbSet = db.Set <TEntity>();
 }
예제 #24
0
 public ProductController()
 {
     db          = new QDLogisticsEntities();
     Skus        = new GenericRepository <Skus>(db);
     ProductType = new GenericRepository <ProductType>(db);
 }
예제 #25
0
 public GroupController()
 {
     db          = new QDLogisticsEntities();
     AdminGroups = new GenericRepository <AdminGroups>(db);
     Menu        = new GenericRepository <Menu>(db);
 }