public void ParseError(PrismCustomerInfoContext context, string[] fields) { var current = context.Current; if (current == null || current.ModelType != TypeCustomerInfoTypes.File) { throw new InvalidOperationException(); } var file = current as TypeCustomerInfoFile; if (file == null) { throw new InvalidOperationException(); } var recordTypeId = 2; var recordTypeIndicator = fields[0]; if (recordTypeIndicator.Equals("ER1", StringComparison.OrdinalIgnoreCase)) { recordTypeId = 1; } var model = new TypeCustomerInfoErrorRecord { RecordTypeId = recordTypeId, RecordId = fields.AtIndexInt(4), ErrorMessage = fields.AtIndex(6), FieldName = fields.AtIndex(5), PremNo = fields.AtIndex(2), }; file.AddError(model); }
public int InsertErrorRecord(TypeCustomerInfoErrorRecord model) { using (var connection = new SqlConnection(connectionString)) using (var command = connection.CreateCommand("esp_CustomerBillingFileErrorRecordInsert")) { SqlParameter keyParameter; command .AddWithValue("@CustomerBillingFileID", model.FileId) .AddWithValue("@CustomerBillingFileRecordID", model.RecordId) .AddWithValue("@RecordTypeID", model.RecordTypeId) .AddIfNotEmptyOrDbNull("@FieldName", model.FieldName) .AddIfNotEmptyOrDbNull("@ErrorMessage", model.ErrorMessage) .AddWithValue("@ClearedFlag", model.IsCleared) .AddWithValue("@ClearedDate", model.ClearedDate) .AddWithValue("@UserId", model.UserId) .AddIfNotEmptyOrDbNull("@EsiId", model.PremNo) .AddOutParameter("@CustomerBillingFileErrorRecordID", SqlDbType.Int, out keyParameter); if (connection.State != ConnectionState.Open) { connection.Open(); } command.ExecuteNonQuery(); if (keyParameter.Value == null) { throw new Exception(); } var errorRecordId = (int)keyParameter.Value; model.ErrorRecordId = errorRecordId; return(errorRecordId); } }