Example #1
0
 public void Write(FieldsParser information, string formName)
 {
     Variables variables = new Variables();
     SqlTransaction sqlTransaction = SqlConn.BeginTransaction();
     try
     {
         MasterConnection.SP.Execute(SqlConn, sqlTransaction, information.Master, variables);
         foreach (FieldsGroupConnection detailConnection in DetailConnections)
         {
             foreach (FieldsParser.Fields fields in information.Details)
             {
                 if (fields.NodeName == detailConnection.Name)
                 {
                     detailConnection.SP.Execute(SqlConn, sqlTransaction, fields, variables);
                 }
             }
         }
         sqlTransaction.Commit();
     }
     catch
     {
         sqlTransaction.Rollback();
         throw;
     }
 }
Example #2
0
 public void SaveToDBNew(string xml)
 {
     using (SqlConnection sqlConnection = new SqlConnection(ConfigurationSettings.AppSettings["SQLConnectionString"]))
     {
         try
         {
             sqlConnection.Open();
             FieldsParser information = new FieldsParser(xml);
             string formName = information.GetFormName();
             SqlWriter sqlWriter = new SqlWriter();
             sqlWriter.ParseXmlConfigData(ConfigurationSettings.AppSettings["FormsFieldsDefinitionXMLFile"], formName);
             information.ExplodeXML(sqlWriter.MasterNodeName, sqlWriter.DetailNodeNames);
             sqlWriter.SqlConn = sqlConnection;
             sqlWriter.Write(information, formName);
         }
         catch (Exception exception)
         {
             Console.WriteLine(exception.ToString());
         }
         finally
         {
             sqlConnection.Close();
         }
     }
 }
Example #3
0
 public void Execute(SqlConnection sqlConnection, SqlTransaction sqlTransaction, FieldsParser.Fields fields, Variables variables)
 {
     foreach (Parameter parameter in Parameters)
     {
         switch (parameter.Direction.ToUpper())
         {
             case "INPUT":
             case "INPUTOUTPUT":
                 string value = "";
                 if (parameter.Value.Length > 0)
                 {
                     value = parameter.Value;
                 }
                 else
                 {
                     if (parameter.Field.Length > 0)
                     {
                         value = fields[parameter.Field];
                     }
                     else
                     {
                         value = variables[parameter.Variable];
                     }
                 }
                 if (value != null)
                 {
                     _sqlCommand.Parameters["@" + parameter.Name].Value = value;
                 }
                 break;
         }
     }
     _sqlCommand.Connection = sqlConnection;
     _sqlCommand.Transaction = sqlTransaction;
     _sqlCommand.ExecuteNonQuery();
     foreach (Parameter parameter in Parameters)
     {
         switch (parameter.Direction.ToUpper())
         {
             case "INPUTOUTUT":
             case "OUTPUT":
                 variables[parameter.Variable] = _sqlCommand.Parameters["@" + parameter.Name].Value.ToString();
                 break;
         }
     }
 }