Ejemplo n.º 1
0
        public Type650ServiceMeter[] ListServiceMeters(int serviceKey)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("esp_650ServiceMeterList"))
                {
                    command.AddWithValue("@Service_Key", serviceKey);

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

                    var collection = new List <Type650ServiceMeter>();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new Type650ServiceMeter
                            {
                                ServiceKey      = serviceKey,
                                ServiceMeterKey = reader.GetInt32("ServiceMeter_Key"),
                            };

                            reader.TryGetString("MeterNumber", x => item.MeterNumber = x);

                            collection.Add(item);
                        }

                        return(collection.ToArray());
                    }
                }
        }
Ejemplo n.º 2
0
        public int InsertServiceMeter(Type650ServiceMeter model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp650ServiceMeterInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@Service_Key", model.ServiceKey)
                    .AddIfNotEmptyOrDbNull("@MeterNumber", model.MeterNumber)
                    .AddOutParameter("@ServiceMeter_Key", SqlDbType.Int, out keyParameter);

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

                    command.ExecuteNonQuery();

                    if (keyParameter.Value == null)
                    {
                        throw new Exception();
                    }

                    var meterKey = (int)keyParameter.Value;
                    model.ServiceMeterKey = meterKey;

                    return(meterKey);
                }
        }
Ejemplo n.º 3
0
        public Type650ServiceMeter ParseServiceMeter(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

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

            var model = new Type650ServiceMeter
            {
                MeterNumber = element.GetChildText(empty + "MeterNumber"),
            };

            return(model);
        }
Ejemplo n.º 4
0
        public void ParseServiceMeter(Prism650Context context, string[] marketFields)
        {
            var current = context.Current;

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

            var service = current as Type650Service;

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

            var model = new Type650ServiceMeter
            {
                MeterNumber = marketFields.AtIndex(2),
            };

            service.AddMeter(model);
        }