Esempio n. 1
0
 public object AddRecord(string tableName, Dictionary <string, object> col_val, bool needIdentity, string connKey)
 {
     try
     {
         using (CmdOnPoolGenerator gen = new CmdOnPoolGenerator(connKey))
         {
             DbCommand cmd = gen.CreateCommand(new CustomizedCommand()
             {
                 ColumnsData = col_val, FilteredColumnsData = null, CommandType = CustomizedCommandType.New, ConnectionString = connKey, DataProvider = DataProvider.SqlServer, TableName = tableName
             }, needIdentity);
             if (needIdentity)
             {
                 return(gen.DatabaseInstance.ExecuteScalar(cmd));
             }
             else
             {
                 gen.DatabaseInstance.ExecuteNonQuery(cmd);
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 public long AddNewSingleOrder(Guid callbackID, string username, Dictionary <string, object> data, Dictionary <string, object> details)
 {
     try
     {
         using (CmdOnPoolGenerator gen = new CmdOnPoolGenerator(ConStrongKeys.FixDbCon))
         {
             DbCommand cmdOrder = gen.CreateCommand(new CustomizedCommand()
             {
                 ColumnsData = data, FilteredColumnsData = null, CommandType = CustomizedCommandType.New, ConnectionString = SystemConfigurations.GetConnectionString(ConStrongKeys.FixDbCon), DataProvider = DataProvider.SqlServer, TableName = "Orders"
             }, true);
             using (System.Transactions.TransactionScope tran = new System.Transactions.TransactionScope())
             {
                 long orderID = Convert.ToInt64(gen.DatabaseInstance.ExecuteScalar(cmdOrder));
                 details.Add(SingleOrdDetailsProps.OrderID, orderID);
                 DbCommand cmdOrdersDetail = gen.CreateCommand(new CustomizedCommand()
                 {
                     ColumnsData = details, FilteredColumnsData = null, CommandType = CustomizedCommandType.New, ConnectionString = SystemConfigurations.GetConnectionString(ConStrongKeys.FixDbCon), DataProvider = DataProvider.SqlServer, TableName = "Orders_Details"
                 }, false);
                 gen.DatabaseInstance.ExecuteNonQuery(cmdOrdersDetail);
                 DbCommand   cmdSub = gen.DatabaseInstance.GetSqlStringCommand(string.Format("INSERT INTO [SessionOrders] (SessionID,Username, ReqOrdID, OrdID, SubscriptionDateTime) Values (@SubscriberID, @username,@RequesterOrderID, @OrderID, @SubscriptionDateTime)"));
                 DbParameter para1  = cmdSub.CreateParameter();
                 para1.ParameterName = "@SubscriberID";
                 para1.Value         = callbackID;
                 cmdSub.Parameters.Add(para1);
                 DbParameter para2 = cmdSub.CreateParameter();
                 para2.ParameterName = "@RequesterOrderID";
                 para2.Value         = (Guid)data[SingleOrderProperties.RequesterOrderID];
                 cmdSub.Parameters.Add(para2);
                 DbParameter para3 = cmdSub.CreateParameter();
                 para3.ParameterName = "@OrderID";
                 para3.Value         = orderID;
                 cmdSub.Parameters.Add(para3);
                 DbParameter para4 = cmdSub.CreateParameter();
                 para4.ParameterName = "@SubscriptionDateTime";
                 para4.Value         = data[SingleOrderProperties.PlacementDateTime];
                 cmdSub.Parameters.Add(para4);
                 DbParameter para5 = cmdSub.CreateParameter();
                 para5.ParameterName = "@Username";
                 para5.Value         = username;
                 cmdSub.Parameters.Add(para5);
                 gen.DatabaseInstance.ExecuteNonQuery(cmdSub);
                 tran.Complete();
                 return(orderID);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
 public int UpdateRecord(string tableName, Dictionary <string, object> col_val, Dictionary <string, object> keys, string conString)
 {
     try
     {
         using (CmdOnPoolGenerator gen = new CmdOnPoolGenerator(conString))
         {
             DbCommand cmd = gen.CreateCommand(new CustomizedCommand()
             {
                 ColumnsData = col_val, FilteredColumnsData = keys, CommandType = CustomizedCommandType.Update, ConnectionString = SystemConfigurations.GetConnectionString(conString), DataProvider = DataProvider.SqlServer, TableName = tableName
             }, false);
             return(gen.DatabaseInstance.ExecuteNonQuery(cmd));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 4
0
 public void UpdateOrderDetails(Dictionary <string, object> updates, Dictionary <string, object> keys, Dictionary <string, object> ordersDetails_columns_values)
 {
     using (CmdOnPoolGenerator gen = new CmdOnPoolGenerator(ConStrongKeys.FixDbCon))
     {
         DbCommand cmdOrders = gen.CreateCommand(new CustomizedCommand()
         {
             ColumnsData = updates, FilteredColumnsData = keys, CommandType = CustomizedCommandType.Update, ConnectionString = SystemConfigurations.GetConnectionString(ConStrongKeys.FixDbCon), DataProvider = DataProvider.SqlServer, TableName = "Orders"
         }, true);
         DbCommand cmdOrdersDetails = gen.CreateCommand(new CustomizedCommand()
         {
             ColumnsData = ordersDetails_columns_values, FilteredColumnsData = null, CommandType = CustomizedCommandType.New, ConnectionString = SystemConfigurations.GetConnectionString(ConStrongKeys.FixDbCon), DataProvider = DataProvider.SqlServer, TableName = "Orders_Details"
         }, false);
         using (System.Transactions.TransactionScope tran = new System.Transactions.TransactionScope())
         {
             gen.DatabaseInstance.ExecuteNonQuery(cmdOrders);
             gen.DatabaseInstance.ExecuteNonQuery(cmdOrdersDetails);
             tran.Complete();
         }
     }
 }