Beispiel #1
0
        public List <InventoryQuantity> SelectInventoryQuantitiesBySaleItem(int saleItemID)
        {
            List <InventoryQuantity> saleItemInventory = new List <InventoryQuantity>();

            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_inventory_quantities_by_sale_item", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@SaleItemID", SqlDbType.Int);
            cmd.Parameters["@SaleItemID"].Value = saleItemID;

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var item = new InventoryQuantity();
                        item.InventoryItemName = reader.GetString(0);
                        item.Quantity          = reader.GetDecimal(1);

                        saleItemInventory.Add(item);
                    }
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(saleItemInventory);
        }
Beispiel #2
0
        public void Execute(IJobExecutionContext context)
        {
            var notificationEmail = Settings.GetNotificationEmail();

            Logger.Instance.Info($"Job started: {GetType().Name}");
            var tasks = new Tasks();

            tasks.StartTask(JobName);

            var inventoryQuantities = new InventoryQuantity();

            if (inventoryQuantities.Publish(out var publishDetails))
            {
                Logger.Instance.Info("Inventory Quantities Published");
                tasks.SetStatus(JobName, "Success");

                if (!string.IsNullOrWhiteSpace(notificationEmail))
                {
                    Mail.SendProcessCompleteEmail(notificationEmail, publishDetails, $"{JobName} Publish",
                                                  response => Logger.Instance.Info(response));
                }
            }
            else
            {
                Logger.Instance.Error("Inventory Quantities failed to publish. No API Key was found");
                tasks.SetStatus(JobName, "Failed");

                if (!string.IsNullOrWhiteSpace(notificationEmail))
                {
                    Mail.SendProcessCompleteEmail(notificationEmail, $"{JobName} Publish failed, please check logs or contact support", $"{JobName} Publish",
                                                  response => Logger.Instance.Info(response));
                }
            }

            tasks.EndTask(JobName);
            Logger.Instance.Info($"Job finished: {GetType().Name}");
        }