Esempio n. 1
0
        public Type867IntervalDetailQty ParseIntervalDetailQty(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

            if (!namespaces.TryGetValue(string.Empty, out empty))
            {
                empty = XNamespace.None;
            }

            int intervalDetailKey;
            int intervalDetailQtyKey;

            int.TryParse(element.GetChildText(empty + "IntervalDetail_Key"), out intervalDetailKey);
            int.TryParse(element.GetChildText(empty + "IntervalDetailQty_Key"), out intervalDetailQtyKey);

            var model = new Type867IntervalDetailQty
            {
                IntervalDetailKey    = intervalDetailKey,
                IntervalDetailQtyKey = intervalDetailQtyKey,
                DegreeDayFactor      = element.GetChildText(empty + "DegreeDayFactor"),
                IntervalEndDate      = element.GetChildText(empty + "IntervalEndDate"),
                IntervalEndTime      = element.GetChildText(empty + "IntervalEndTime"),
                ProcessDate          = DateTime.Now,
                ProcessFlag          = 0,
                Qualifier            = element.GetChildText(empty + "Qualifier"),
                Quantity             = element.GetChildText(empty + "Quantity"),
                RangeMax             = element.GetChildText(empty + "RangeMax"),
                RangeMin             = element.GetChildText(empty + "RangeMin"),
                ThermFactor          = element.GetChildText(empty + "ThermFactor")
            };

            return(model);
        }
Esempio n. 2
0
        public void InsertIntervalDetailQty(Type867IntervalDetailQty model)
        {
            using (var connection = new SqlConnection(_connectionString))
                using (var command = connection.CreateCommand("csp867IntervalDetailQtyInsert"))
                {
                    command.AddWithValue("@IntervalDetail_Key", model.IntervalDetailKey)
                    .AddIfNotEmptyOrDbNull("@Qualifier", model.Qualifier)
                    .AddIfNotEmptyOrDbNull("@Quantity", model.Quantity)
                    .AddIfNotEmptyOrDbNull("@IntervalEndDate", model.IntervalEndDate)
                    .AddIfNotEmptyOrDbNull("@IntervalEndTime", model.IntervalEndTime)
                    .AddWithValue("@RangeMin", model.RangeMin)
                    .AddWithValue("@RangeMax", model.RangeMax)
                    .AddWithValue("@ThermFactor", model.ThermFactor)
                    .AddWithValue("@DegreeDayFactor", model.DegreeDayFactor);

                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    command.ExecuteNonQuery();
                }
        }
Esempio n. 3
0
        private void ParseIntervalDetailQty(Prism867Context context, string[] marketFields)
        {
            switch (context.RecordType)
            {
            case "PM":
                break;

            default:
                logger.DebugFormat("Record Usage Type not found: {0}. Transaction Number \"{1}\".",
                                   context.RecordType, context.TransactionNumber);
                return;
            }

            var current = context.Current;

            if (current == null || current.ModelType != Type867Types.IntervalDetail)
            {
                throw new InvalidOperationException();
            }

            var detail = current as Type867IntervalDetail;

            if (detail == null)
            {
                throw new InvalidOperationException();
            }

            var model = new Type867IntervalDetailQty
            {
                Qualifier       = marketFields.AtIndex(2),
                Quantity        = marketFields.AtIndex(3),
                IntervalEndDate = marketFields.AtIndex(5),
                IntervalEndTime = marketFields.AtIndex(6)
            };

            detail.AddQuantity(model);
        }