Пример #1
0
 public static IEnumerable <IBarcode> Read(ShoppingCart cart, string id)
 {
     try
     {
         List <IBarcode> result   = null;
         var             fileName = string.Format("SaleDetails{0}.JSON", id);
         var             filePath = Path.Combine(MachinesSettings.CachePath, fileName);
         if (File.Exists(filePath))
         {
             using (StreamReader sr = new StreamReader(filePath))
             {
                 var json = sr.ReadToEnd();
                 result = JsonConvert.DeserializeObject <List <IBarcode> >(json, new BarcodeConverter());
             }
         }
         if (result != null && result.Count() > 0)
         {
             cart.Clear();
             cart.OrderList = result;
             cart.ResetProduct(SaleStatus.Normal);
         }
         var suspendList = SuspendList.Factory(cart.MachineInformation.StoreId, cart.MachineInformation.MachineSn, cart.MachineInformation.CompanyId, MachinesSettings.CachePath);
         suspendList.RemoveAll(o => o.Id == id);
         suspendList.Save(MachinesSettings.CachePath, cart.MachineInformation.StoreId, cart.MachineInformation.MachineSn, cart.MachineInformation.CompanyId);
         File.Delete(filePath);
         return(result);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #2
0
 public static SuspendList Remove(ShoppingCart cart, string id)
 {
     try
     {
         var suspendList = SuspendList.Factory(cart.MachineInformation.StoreId, cart.MachineInformation.MachineSn, cart.MachineInformation.CompanyId, MachinesSettings.CachePath);
         var fileName    = string.Format("SaleDetails{0}.JSON", id);
         var filePath    = Path.Combine(MachinesSettings.CachePath, fileName);
         suspendList.RemoveAll(o => o.Id == id);
         suspendList.Save(MachinesSettings.CachePath, cart.MachineInformation.StoreId, cart.MachineInformation.MachineSn, cart.MachineInformation.CompanyId);
         File.Delete(filePath);
         return(suspendList);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #3
0
 public static void Suspend(ShoppingCart cart)
 {
     try
     {
         var statistics = cart.GetSaleStatistics();
         var details    = new SuspendDetails()
         {
             Id          = KeyFactory.SuspendKeyFactory(cart.MachineInformation.CompanyId, cart.MachineInformation.StoreId, cart.MachineInformation.MachineSn, cart.MachineInformation.DeviceSn),
             Amount      = statistics.Receivable,
             Count       = statistics.Num,
             SuspendDate = DateTime.Now,
             OrderSN     = cart.OrderSN
         };
         var suspendList = SuspendList.Factory(cart.MachineInformation.StoreId, cart.MachineInformation.MachineSn, cart.MachineInformation.CompanyId, MachinesSettings.CachePath);
         suspendList.Add(details);
         suspendList.Save(MachinesSettings.CachePath, cart.MachineInformation.StoreId, cart.MachineInformation.MachineSn, cart.MachineInformation.CompanyId);
         Save(cart, MachinesSettings.CachePath, details.Id);
         cart.Clear();
     }
     catch (Exception ex)
     {
         throw;
     }
 }