Пример #1
0
        public Task Handle(BusinessProcessList <IBusinessProcess> notification, CancellationToken cancellationToken)
        {
            var processList = notification.OfType <TransactionUpdateModel>().ToArray();

            if (!processList.Any())
            {
                return(Task.FromResult(0));
            }

            var toUpdate = processList.Where(x => x.ShouldUpdate);

            foreach (var businessProcess in toUpdate)
            {
                var updateLinq = _db.GetTable <LaBusinessService>().Where(p =>
                                                                          p.DataAreaId == businessProcess.DataAreaId && p.StoreId == businessProcess.StoreId &&
                                                                          p.TerminalId == businessProcess.TerminalId &&
                                                                          p.TransactionId == businessProcess.TransactionId);

                var updatable = updateLinq.Set(x => x.LastUpdateTime, DateTime.Now);

                if (!string.IsNullOrWhiteSpace(businessProcess.NewTransactionId))
                {
                    updatable = updatable.Set(x => x.TransactionId, businessProcess.NewTransactionId);
                }


                updatable = updatable.Set(x => x.FiscalPrint, businessProcess.FiscalPrint);


                updatable.Update();
            }


            return(Task.FromResult(0));
        }
Пример #2
0
        public Task Handle(BusinessProcessList <IBusinessProcess> processlist, CancellationToken cancellationToken)
        {
            var processList = processlist.OfType <BusinessServiceModel>().ToArray();

            if (!processList.Any())
            {
                return(Task.FromResult(0));
            }

            var toBulkInsert = processList.Where(x => !x.ShouldUpdate).ToList();

            //var toUpdate = processList.Where(x => x.ShouldUpdate);

            try
            {
                if (toBulkInsert.Count > 0)
                {
                    if (toBulkInsert.Count > 1)
                    {
                        _db.BulkCopy(toBulkInsert);
                    }
                    else
                    {
                        _db.Insert(toBulkInsert.Single());
                    }
                }

                /*   foreach (var businessProcess in toUpdate)
                 * {
                 *     var updateLinq = _db.EASBusinessServices.Where(p =>
                 *         p.StoreId == businessProcess.StoreId && p.TerminalId == businessProcess.TerminalId &&
                 *         p.DataAreaId == businessProcess.DataAreaId &&
                 *         p.TransactionId == businessProcess.TransactionId && p.ObjectId== businessProcess.ObjectId);
                 *
                 *     var updatable = updateLinq.Set(x => x.LastUpdateTime, DateTime.Now);
                 *
                 *     if (!string.IsNullOrWhiteSpace(businessProcess.CashVoucher))
                 *         updatable = updatable.Set(x => x.CashVoucher, businessProcess.CashVoucher);
                 *     if (!string.IsNullOrWhiteSpace(businessProcess.DispatchBarcode))
                 *         updatable = updatable.Set(x => x.DispatchBarcode, businessProcess.DispatchBarcode);
                 *     if (!string.IsNullOrWhiteSpace(businessProcess.OperatorId))
                 *         updatable = updatable.Set(x => x.OperatorId, businessProcess.OperatorId);
                 *     if (businessProcess.BeginDateTime != null)
                 *         updatable = updatable.Set(x => x.BeginDateTime, businessProcess.BeginDateTime);
                 *     if (businessProcess.EndDateTime != null)
                 *         updatable = updatable.Set(x => x.EndDateTime, businessProcess.EndDateTime);
                 *
                 *
                 *     updatable.Update();
                 * }
                 */
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Task.FromResult(0));
        }
Пример #3
0
        public Task Handle(BusinessProcessList <IBusinessProcess> processlist, CancellationToken cancellationToken)
        {
            var processList = processlist.OfType <PrintReportSaverModel>().ToArray();

            if (!processList.Any())
            {
                return(Task.FromResult(0));
            }



            var reports = processList.Where(x => !x.ShouldUpdate).ToList();

            _db.BulkCopy(reports);


            return(Task.FromResult(0));
        }