Beispiel #1
0
        /// <summary>
        /// Xóa theo ID
        /// </summary>
        /// <param name="orderExportId"></param>
        public void Delete(string orderExportId)
        {
            OrderExport orderExport = GetOrderExportById(orderExportId);

            _context.OrderExports.Remove(orderExport);
            SaveChanges();
        }
Beispiel #2
0
        public IHttpActionResult OrderExport([FromBody] OrderExport orderExport)
        {
            if (existReferenceNumber(orderExport.Header.ReferenceNumber, WmsOperation.Order))
            {
                return(BadRequest("ReferenceNumber exist:" + orderExport.Header.ReferenceNumber));
            }

            foreach (var orderExportLines in orderExport.OrderExportLines)
            {
                var currentDateTime = DateTime.Now;
                OrderLineConfirmWms orderLineConfirmWms = new OrderLineConfirmWms()
                {
                    WmsDate = currentDateTime
                };
                Mapper.Map <OrderExportHeader, OrderLineConfirmWms>(orderExport.Header, orderLineConfirmWms);
                Mapper.Map <OrderExportLine, OrderLineConfirmWms>(orderExportLines, orderLineConfirmWms);
                db.OrderLineConfirmWms.Add(orderLineConfirmWms);

                var salesOrderLines = db.SalesOrderLines.FirstOrDefault(x => x.SalesOrderId.ToString() == orderExport.Header.OrderCode && x.SalesOrderLineNo.ToString() == orderExportLines.OrderLineNo);
                salesOrderLines.RecivedQty = Int32.Parse(orderExportLines.CheckedQuantity);
                salesOrderLines.LastUpdate = currentDateTime;
                salesOrderLines.LastAuthor = "Wms";
                db.SaveChanges();
            }
            return(Ok());
        }
Beispiel #3
0
        /// <summary>
        /// Tạo ID kế tiếp
        /// </summary>
        /// <returns></returns>
        public string NextId()
        {
            var orderExports = GetOrderExports();

            if (orderExports != null)
            {
                OrderExport orderExport = orderExports.LastOrDefault();
                if (orderExport != null)
                {
                    string lastId = orderExport.OrderExportID.Remove(0, 3);
                    string orderExportId;
                    if (!string.IsNullOrEmpty(lastId))
                    {
                        int nextId = int.Parse(lastId) + 1;
                        orderExportId = string.Format("XK{0}", nextId.ToString(CultureInfo.InvariantCulture).PadLeft(5, '0'));
                    }
                    else
                    {
                        orderExportId = string.Format("XK0000{0}", 1);
                    }
                    return(orderExportId);
                }
                return(string.Format("XK0000{0}", 1));
            }
            return(string.Format("XK0000{0}", 1));
        }
Beispiel #4
0
        public async Task UpdateOrderExport(int orderExportId, OrderExport orderExport, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            orderExport.OrderExportId = orderExportId;

            await _orderExportRepository.Edit(orderExport, cancellationToken);
        }
Beispiel #5
0
        public bool CheckOrderExportIdExit(string orderExportId)
        {
            OrderExport orderExport = GetOrderExportById(orderExportId);

            if (orderExport != null)
            {
                return(false);
            }
            return(true);
        }
Beispiel #6
0
 /// <summary>
 /// Lưu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(gridLookUpEditEmployees.Text))
     {
         gridLookUpEditEmployees.Properties.Appearance.BorderColor = System.Drawing.Color.Red;
         XtraMessageBox.Show("Vui lòng chọn Nhân viên!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         gridLookUpEditEmployees.Focus();
     }
     else
     {
         string employeeSelect = gridLookUpEditEmployees.EditValue.ToString();
         string employeeId     = null;
         if (!string.IsNullOrEmpty(employeeSelect))
         {
             employeeId = employeeSelect;
         }
         var orderExport = new OrderExport()
         {
             OrderExportID = txtOrderExportID.Text,
             EmployeeID    = employeeId,
             ExportDate    = dateEditExportDate.DateTime,
             Total         = Convert.ToInt32(_total),
             //Price = Convert.ToInt32(_price),
             IsActive = true,
         };
         try
         {
             _orderExportService.Add(orderExport);
             foreach (Cart cart in _order.Carts)
             {
                 InsertOrderExportDetail(txtOrderExportID.Text, cart.ProductId, cart.Quantity, cart.Price, cart.Total);
                 _inventoryService.InsertOrUpdateInventoryExport(cart.ProductId, cart.Quantity, txtOrderExportID.Text);
             }
             if (_order.Carts.Count > 0)
             {
                 _order.Carts.Clear();
             }
             XtraMessageBox.Show("Xuất kho thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             gridControlStockExport.DataSource = null;
             ResetProductControls();
             ResetSupplierControls();
             EnabledButtonSaveAndPrint(false);
             // Tạo tiếp ID
             txtOrderExportID.Text = _orderExportService.NextId();
         }
         catch (SqlException ex)
         {
             XtraMessageBox.Show(string.Format("Lỗi! \n {0}", ex.Message), "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         catch (Exception ex)
         {
             XtraMessageBox.Show(string.Format("Lỗi! \n {0}", ex.Message), "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #7
0
        public async Task <OrderExport> CreateOrderExport(DataFormat dataFormat, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var orderExport = new OrderExport {
                DataFormat = dataFormat, ExportStatus = OrderExportStatus.Waiting
            };
            await _orderExportRepository.Add(orderExport, cancellationToken);

            await _bus.Publish(new OrderExportEvent { OrderExportId = orderExport.OrderExportId, DataFormat = dataFormat }, cancellationToken);

            return(orderExport);
        }
Beispiel #8
0
        /// <summary>
        /// Экспорт всех заказов
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> OrderExport()
        {
            TimeSpan diff = DateTime.Now - LastReportsRequest();

            if (diff.Minutes > 1)
            {
                InsertReportsRequest();
                OrderExport export = new OrderExport();

                await SendDocument(new FileToSend { Content = export.Export(), Filename = "Orders.csv" }, "Все заказы в БД");

                return(OkResult);
            }

            else
            {
                await SendMessage(new BotMessage { TextMessage = "Не более одного запроса в минуту" });

                return(base.OkResult);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Cập nhật thông tin
 /// </summary>
 /// <param name="orderExport"></param>
 public void Update(OrderExport orderExport)
 {
     _context.OrderExports.Attach(orderExport);
     _context.Entry(orderExport).State = EntityState.Modified;
     SaveChanges();
 }
Beispiel #10
0
 /// <summary>
 /// Thêm mới
 /// </summary>
 /// <param name="orderExport"></param>
 /// <returns></returns>
 public void Add(OrderExport orderExport)
 {
     _context.OrderExports.Add(orderExport);
     SaveChanges();
 }
Beispiel #11
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                Console.WriteLine("OrderExport Iteruje dla OrderExport");

                string host     = ConfigurationManager.AppSettings["FtpHostSyncToXL"].ToString();
                string username = ConfigurationManager.AppSettings["UserSyncToXL"].ToString();
                string pass     = ConfigurationManager.AppSettings["PasswdSyncToXL"].ToString();
                var    ftp      = new FTP(host, username, pass);

                string outLocal = ConfigurationManager.AppSettings["LocalOUTPathSyncToXL"].ToString();
                string inFTP    = ConfigurationManager.AppSettings["FTPINPathSyncToXL"].ToString();
                ftp.Recive(inFTP, outLocal, "-ORDERS.txt");

                Console.WriteLine("OrderExport Pobrałem z FTP-a");


                string[] filePaths = Directory.GetFiles(outLocal);

                foreach (var file in filePaths)
                {
                    if (!Path.GetFileName(file).EndsWith("-ORDERS.txt"))
                    {
                        continue;
                    }
                    Console.WriteLine("OrderExport Przetwarzam plik" + file);

                    var stringList = new CoherentDataList <StringOrderExport>(file);
                    var listOut    = new List <OrderExport>();

                    string    ConStr = ConfigurationManager.AppSettings["DBConString"].ToString();
                    DBContext DB     = new DBContext(ConStr);

                    var syncXL = new SyncXL();

                    foreach (StringOrderExport el in stringList.List)
                    {
                        var toSend = new OrderExport(el);

                        listOut.Add(toSend);
                    }
                    syncXL.SendToXL(file, listOut);
                    Console.WriteLine("OrderExport Wysyłam do XL-a");

                    File.Move(file, file + "_" + Guid.NewGuid() + "_" + ".BACKUP.txt");

                    foreach (StringOrderExport el in stringList.List)
                    {
                        var toSend = new OrderExport(el);

                        toSend.CreationDate = DateTime.Now;
                        toSend.File         = Path.GetFileName(file);
                        toSend.Status       = "OrderExport Pobrano z FTP, Przetworzono i Wysłano do XL-a";

                        DB.OrderExport.Add(toSend);
                    }

                    DB.SaveChanges();
                    Console.WriteLine("OrderExport dodano do bazy plik " + file);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                using (StreamWriter writetext = new StreamWriter("OrderExport_" + "Error.txt"))
                {
                    writetext.WriteLine(ex.ToString());
                }

                Thread.Sleep(1 * 60 * 1000);

                SimpleTriggerImpl retryTrigger = new SimpleTriggerImpl(Guid.NewGuid().ToString());
                retryTrigger.Description  = "RetryTrigger";
                retryTrigger.RepeatCount  = 0;
                retryTrigger.JobKey       = context.JobDetail.Key;                             // connect trigger with current job
                retryTrigger.StartTimeUtc = DateBuilder.NextGivenSecondDate(DateTime.Now, 30); // Execute after 30 seconds from now
                context.Scheduler.ScheduleJob(retryTrigger);                                   // schedule the trigger

                //  JobExecutionException jex = new JobExecutionException(ex, false);
                //  throw jex;
            }
            //                var syncXL = new SyncXL();
            //                syncXL.Send(file,listOut);
        }