示例#1
0
 public ResponseSerializer BatchDelete([FromBody] BatchNumber batchNumber)
 {
     return(new ResponseSerializer(
                200,
                "success",
                this._deviceBus.BatchDeleteDevice(batchNumber.number)));
 }
 public ResponseSerializer BatchDelete([FromBody] BatchNumber batchNumber)
 {
     return(new ResponseSerializer(
                200,
                "success",
                this._gatewayBus.BatchDeleteGateway(batchNumber.number)));
 }
示例#3
0
        public void FillBatches()
        {
            if (IsDraft())
            {
                FillBatchesForDraft();
                return;
            }

            BatchNumbes = new List <BatchNumber>();

            var batches = B1Helper.GetBatchNumbers(
                DBName, ItemCode, WhsCode, DocEntry, LineNum, ObjType);

            if (batches.IsEmpty() && BaseType != eDocumentObjectType.oNone)
            {
                batches = B1Helper.GetBatchNumbers(
                    DBName, ItemCode, WhsCode, BaseEntry, BaseLine, BaseType);
            }

            foreach (var batch in batches)
            {
                var newBath = new BatchNumber(DBName);

                if (!newBath.GetByKey(batch.ItemCode, batch.WhsCode, batch.BatchNum))
                {
                    continue;
                }

                newBath.Quantity = batch.Quantity;
                BatchNumbes.Add(newBath);
            }
        }
示例#4
0
 public ResponseSerializer BatchDelete([FromBody] BatchNumber batchNumber)
 {
     return(new ResponseSerializer(
                200,
                "success",
                this._thresholdBus.BatchDeleteThreshold(batchNumber.number)));
 }
示例#5
0
        public override string ToString()
        {
            var info = new StringBuilder();

            info.Append(base.ToString());
            info.Append("CurrencyName: ").AppendLine(CurrencyName);
            info.Append("TransactionsCount: ").AppendLine(TransactionsCount.ToString());
            info.Append("BatchNumber: ").AppendLine(BatchNumber.ToString());
            info.Append("TransactionTotalAmount: ").AppendLine(TransactionTotalAmount.ToString());

            return(info.ToString());
        }
        public async Task BatchDeleteSuccess(int[] Number)
        {
            var data = new BatchNumber
            {
                number = Number
            };
            var content  = new StringContent(data.ToJson(), Encoding.UTF8, "text/json");
            var response = await this._httpClient.PostAsync("api/device/batch/devices", content);

            var result = response.Content.ReadAsStringAsync().Result;

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Contains("\"c\":200,\"m\":\"success\",\"d\":" + Number.Length, result);
        }
示例#7
0
        public override string ToString()
        {
            var info = new StringBuilder();

            info.Append("Terminal ID: ").AppendLine(TerminalId);
            info.Append("Merchant id: ").AppendLine(MerchantId);
            info.Append("Payment Datetime: ").AppendLine(PaymentDatetime);
            info.Append("CurrencyName: ").AppendLine(CurrencyName);
            info.Append("TransactionsCount: ").AppendLine(TransactionsCount.ToString());
            info.Append("BatchNumber: ").AppendLine(BatchNumber.ToString());
            info.Append("TransactionsTotalAmount: ").AppendLine(TransactionsTotalAmount.ToString());

            return(info.ToString());
        }
示例#8
0
        public async Task DoWork(BatchNumber batchNumber, CancellationToken cancellationToken)
        {
            using (IServiceScope scope = _scopeFactory.CreateScope())
            {
                IRepository <BatchNumber> batchNumberRepository = scope.ServiceProvider.GetRequiredService <IRepository <BatchNumber> >();

                await batchNumberRepository.ReloadAsync(batchNumber);

                batchNumber.Product = await _client.MultiplyNumber(batchNumber.Number);

                await batchNumberRepository.UpdateAsync(batchNumber);

                await Task.Run(() => UnitDone?.Invoke(this, new NumberProcessedEventArgs(batchNumber, cancellationToken)));
            }
        }
示例#9
0
        /// <summary>
        /// Pega um lote
        /// </summary>
        /// <param name="pItemCode">Código do Item</param>
        /// <param name="pWhsCode">Código do Depósito</param>
        /// <param name="pBatchNumber">Código do Lote</param>
        /// <param name="pCompanyDB">Empresa</param>
        /// <returns></returns>
        public static BatchNumber GetBatchNumber(string pItemCode, string pWhsCode, string pBatchNumber, string pCompanyDB)
        {
            pCompanyDB.CheckForArgumentNull("pCompanyDb");
            pWhsCode.CheckForArgumentNull("pWhsCode");
            pItemCode.CheckForArgumentNull("pItemCode");
            pBatchNumber.CheckForArgumentNull("pItemCode");

            BatchNumber batch = new BatchNumber(pCompanyDB);

            if (!batch.GetByKey(pItemCode, pWhsCode, pBatchNumber))
            {
                throw new Exception(
                          string.Format(
                              DontFindText3Key, BatchNumberObjectName, pBatchNumber,
                              ItemObjectName, pItemCode,
                              WarehouseObjectName, pWhsCode));
            }

            return(batch);
        }
示例#10
0
        public override string ToString()
        {
            var info = new StringBuilder();

            info.Append(base.ToString());
            info.Append("Approved amount: ").AppendLine(ApprovedAmount.ToString());
            info.Append("Approved Amount Currency: ").AppendLine(ApprovedAmountCurrency);
            info.Append("Batch number: ").AppendLine(BatchNumber.ToString());
            info.Append("Receipt number: ").AppendLine(ReceiptNumber.ToString());
            info.Append("RRN: ").AppendLine(ReturnReferenceNumber);
            info.Append("Authorization code: ").AppendLine(AuthorizationCode);
            info.Append("Card number: ").AppendLine(CardNumber);
            info.Append("Card holder name: ").AppendLine(CardHolderName);
            info.Append("Card company: ").AppendLine(CardCompany);
            info.Append("EMV Application Label: ").AppendLine(EmvApplicationLabel);
            info.Append("EMV Application ID: ").AppendLine(EmvApplicationId);
            info.Append("Transaction Flag: ").AppendLine(TransactionFlag.ToString());
            info.Append("Is Pin Used: ").AppendLine(IsPinUsed.ToString());

            return(info.ToString());
        }
示例#11
0
        public async Task DoWork(Batch batch, CancellationToken cancellationToken)
        {
            await foreach (int number in _client.GenerateNumbers(batch.Count))
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                using (IServiceScope scope = _scopeFactory.CreateScope())
                {
                    IRepository <BatchNumber> batchNumberRepository = scope.ServiceProvider.GetRequiredService <IRepository <BatchNumber> >();
                    BatchNumber batchNumber = new BatchNumber {
                        BatchId = batch.Id, Number = number
                    };
                    await batchNumberRepository.InsertAsync(batchNumber);

                    await Task.Run(() => UnitDone?.Invoke(this, new NumberProcessedEventArgs(batchNumber, cancellationToken)));
                }
            }
        }
 public NumberProcessedEventArgs(BatchNumber batchNumber, CancellationToken cancellationToken)
 {
     BatchNumber       = batchNumber;
     CancellationToken = cancellationToken;
 }
示例#13
0
        private int DownloadEmail(Imap imap, MailboxProfile profile, String storagePath)
        {
            int count = 0;

            // Build the MailQuery
            var query = new MailQuery(String.IsNullOrEmpty(profile.ImapQuery) ? "('Deleted' = 'False')" : String.Format("({0}&('Deleted' = 'False'))", profile.ImapQuery));

            // Get all messages matching to the query
            var infos = imap.ListMessages(query);

            // If there are any messages to process, then process them
            if (infos.Any())
            {
                ConfigLogger.Instance.LogInfo("ImapCollector", String.Format("Downloading {0} message{1} from {2}.", infos.Count, infos.Count == 1 ? "" : "s", profile.Description));

                // Download each message
                foreach (var info in infos)
                {
                    if (!timer.Enabled)
                    {
                        break;
                    }

                    // Just check to ensure its valid
                    if (info.Deleted || String.IsNullOrWhiteSpace(info.UniqueId))
                    {
                        continue;
                    }

                    // Track the start time for debug purposes
                    var start = DateTime.Now;

                    MailMessage message = null;

                    try
                    {
                        // Download the message
                        message = imap.FetchMessage(info.UniqueId);

                        // Calculate the time taken to fetch the message
                        var fetchTime = DateTime.Now.Subtract(start);

                        // Process the message (So long as the fetch succeeded)
                        if (message != null)
                        {
                            // Setup the data context
                            using (var ctx = new EmailImportDataContext())
                            {
                                long emailID = 0;

                                // Truncate the subject to avoid data commit errors
                                message.Subject = Truncate(message.Subject, 500);

                                // Check for duplicate
                                if (IsDuplicate(ctx, profile.MailboxGUID, message, ref emailID))
                                {
                                    // Log the duplicate error
                                    ConfigLogger.Instance.LogWarning("ImapCollector", String.Format("Message already downloaded, moved to duplicate folder (existing EmailID = {0}).", emailID));

                                    // Move the message to the duplicate sub folder
                                    imap.MoveMessage(info.UniqueId, "Duplicate", true, false);
                                }
                                else
                                {
                                    // Create an instance of the email database object
                                    var email = new Email();

                                    // Assign properties
                                    email.MailboxGUID  = profile.MailboxGUID;
                                    email.DateSent     = message.DateSent();
                                    email.DateReceived = message.DateReceived();
                                    email.From         = message.From.GetAddressOrDisplayName();
                                    email.MessageID    = message.MessageId;
                                    if (CreditCardHelper.ExistsCCNumber(message.Subject))
                                    {
                                        email.Subject = CreditCardHelper.MaskCCNumbers(message.Subject, '#');
                                    }
                                    else
                                    {
                                        email.Subject = message.Subject;
                                    }
                                    email.Timestamp = DateTime.Now;

                                    // Create the dated storage path
                                    var path = Path.Combine(storagePath, email.Timestamp.Value.ToString("yyyyMMdd"));
                                    FileSystemHelper.CreateDirectory(path);

                                    // Insert the new record
                                    ctx.Emails.InsertOnSubmit(email);

                                    // Submit the email (we need to get the email ID)
                                    using (TransactionScope scope = new TransactionScope())
                                    {
                                        // Initial submit of changes
                                        ctx.SubmitChanges();

                                        // Build the mail message file name
                                        email.MessageFilePath = Path.Combine(path, String.Format("{0:00000000}.eml", email.EmailID));

                                        // Save to disk (delete anything that already exists)
                                        message.Save(email.MessageFilePath, MessageFormat.Eml);

                                        // Get the batch number - THIS SHOULD NEVER HAPPEN IN A MULTI THREAD SCENARIO WITHOUT A LOCK
                                        var batchNumber = ctx.BatchNumbers.SingleOrDefault(b => b.Group == profile.Group);

                                        // If there is no batchNumber defined yet, create and insert one
                                        if (batchNumber == null)
                                        {
                                            batchNumber       = new BatchNumber();
                                            batchNumber.Group = profile.Group;
                                            ctx.BatchNumbers.InsertOnSubmit(batchNumber);
                                        }

                                        // Init to 0 if null
                                        if (!batchNumber.Value.HasValue)
                                        {
                                            batchNumber.Value = 0;
                                        }

                                        // Set the new batch number to this email
                                        email.BatchNumber = String.Format(String.IsNullOrWhiteSpace(profile.BatchNumberFormat) ? "{0:00000000}" : profile.BatchNumberFormat, ++batchNumber.Value);

                                        // Final submit of updates
                                        ctx.SubmitChanges();

                                        // Finally, commit to the database
                                        scope.Complete();
                                    }

                                    // Move the email to the archive (if this fails, but the download is complete this
                                    // will just result in a duplicate next time round if the deleted flag is not set)
                                    imap.MoveMessage(info.UniqueId, "Archive", true, false);

                                    // Log message level download stats
                                    ConfigLogger.Instance.LogDebug("ImapCollector", String.Format("Message downloaded (EmailID = {0}, Fetch Time = {1}s, Total Time = {2}s).", email.EmailID, (int)fetchTime.TotalSeconds, (int)DateTime.Now.Subtract(start).TotalSeconds));

                                    // Increment the download count
                                    count++;
                                }
                            }
                        }
                    }
                    catch (OutOfMemoryException)
                    {
                        throw;
                    }
                    catch (Exception e)
                    {
                        ConfigLogger.Instance.LogError("ImapCollector", e);
                    }
                    finally
                    {
                        if (message != null)
                        {
                            message.Dispose();
                        }
                    }
                }
            }

            return(count);
        }