示例#1
0
        private void ParseSwitch(Prism867Context context, string[] marketFields)
        {
            context.RecordType = GetRecordType(context, marketFields, 0);

            var current = context.Current;

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

            var header = current as Type867Header;

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

            var model = new Type867Switch
            {
                TypeCode    = context.RecordType,
                MeterNumber = marketFields.AtIndex(2),
                SwitchDate  = marketFields.AtIndex(3)
            };

            context.PushModel(model);
            header.AddSwitch(model);
        }
示例#2
0
        public int InsertSwitch(Type867Switch model)
        {
            using (var connection = new SqlConnection(_connectionString))
                using (var command = connection.CreateCommand("csp867SwitchInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@867_Key", model.HeaderKey)
                    .AddIfNotEmptyOrDbNull("@TypeCode", model.TypeCode)
                    .AddIfNotEmptyOrDbNull("@MeterNumber", model.MeterNumber)
                    .AddIfNotEmptyOrDbNull("@SwitchDate", model.SwitchDate)
                    .AddOutParameter("@Switch_Key", SqlDbType.Int, out keyParameter);

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

                    command.ExecuteNonQuery();

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

                    var key = (int)keyParameter.Value;
                    model.SwitchKey = key;

                    return(key);
                }
        }
示例#3
0
 public int InsertSwitch(Type867Switch model)
 {
     return(-1);
 }