public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}"); try { JObject data = await req.Content.ReadAsAsync <JObject>(); log.Verbose($"received data :={data}", "JE.RMS.Services.AssignUserRoles"); List <SqlParameter> objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@userID", Convert.ToInt32(data.SelectToken("UserID").ToString().TrimStart('{').TrimEnd('}')))); objprm.Add(new SqlParameter("@userName", data.SelectToken("UserName").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@firstName", data.SelectToken("FirstName").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@lastName", data.SelectToken("LastName").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@email", data.SelectToken("Email").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@createdBy", Convert.ToInt32(data.SelectToken("CreatedBy").ToString().TrimStart('{').TrimEnd('}')))); objprm.Add(new SqlParameter("@updatedBy", Convert.ToInt32(data.SelectToken("UpdatedBy").ToString().TrimStart('{').TrimEnd('}')))); objprm.Add(new SqlParameter("@isActive", data.SelectToken("IsActive").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@roleID", Convert.ToInt32(data.SelectToken("RoleID").ToString().TrimStart('{').TrimEnd('}')))); log.Verbose($"calling sp", "JE.RMS.Services.AssignUserRoles"); var obj = MSSQLConnection.ExecuteStoredProcedure <string>(Common.Constants.USPContstants.AssignUserRoles, objprm); log.Verbose($"received response:={obj}", "JE.RMS.Services.AssignUserRoles"); return(req.CreateResponse(HttpStatusCode.OK, obj)); } catch (Exception ex) { log.Error($"Exception ={ex}"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public static void start(String ip, String port, String databasename, String username, String password, int type) { DBType databasetype = DBType.CubridDB; dbfrom = new DBStringBuilder(databasetype, ip, port, databasename, username, password); //MessageBox.Show(type+""); try { if (type == 1) { csql = CubridSQLConnection.getConnection(); csql.connectionString = dbfrom; MessageBox.Show(csql.OpenConnection() ? "erfolgreich" : "gescheitert"); cs = csql.getConn(); } else if (type == 2) { ms = MSSQLConnection.getConnection(); ms.connectionString = dbfrom; MessageBox.Show(ms.OpenConnection() ? "erfolgreich" : "gescheitert"); } else { // os.CloseConnection(); os = OracleSQLConnection.getConnection(); os.connectionString = dbfrom; MessageBox.Show(os.OpenConnection() ? "erfolgreich" : "gescheitert"); } Console.Out.WriteLine(dbfrom.ToString()); } catch (Exception e) { if (e.Message.Contains("Failed to connect to")) { MessageBox.Show("Invalid Databasename"); } else if (e.Message.Contains("Cannot connect to")) { MessageBox.Show("Invalid port or address"); } else if (e.Message.Contains("password")) { MessageBox.Show("Invalid password"); } else if (e.Message.Contains("User")) { MessageBox.Show("Invalid username"); } else { MessageBox.Show("An unexpected error occured"); // MessageBox.Show(e.ToString()); } close(); } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}"); try { JObject data = await req.Content.ReadAsAsync <JObject>(); log.Verbose($"received data :={data}", "JE.RMS.Services.GetJurisdictionList"); List <SqlParameter> objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@countryIDs", data.SelectToken("countryID").ToString().TrimStart('{').TrimEnd('}'))); log.Verbose($"calling sp", "JE.RMS.Services.GetJurisdictionList"); List <Common.Model.Jurisdiction> obj = MSSQLConnection.ExecuteStoredProcedure <Common.Model.Jurisdiction>(Common.Constants.USPContstants.GetJurisdictionList, objprm); log.Verbose($"received response:={obj}", "JE.RMS.Services.GetJurisdictionList"); return(req.CreateResponse(HttpStatusCode.OK, obj)); } catch (Exception ex) { log.Error($"Exception ={ex}"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public void migrate() { mt.migrateTables(os, ms, cs); os = null; ms = null; cs = null; }
/// <summary>Initializes the store, ensuring that an instance of the server is running and a database is attached.</summary> protected override void InternalInitialize() { DbConnectionStringBuilder builder = new DbConnectionStringBuilder(); builder.ConnectionString = ConnectionString; if (builder.ContainsKey("MultipleActiveResultSets")) { _supportsMARS = "True" == ((string)builder["MultipleActiveResultSets"]); } _supportsUpdatableCursor = false; if (_shouldEnsureDatabase) { string databaseName = null; if (builder.ContainsKey("Initial Catalog")) { databaseName = (string)builder["Initial Catalog"]; builder["Initial Catalog"] = "master"; } else if (builder.ContainsKey("Database")) { databaseName = (string)builder["Database"]; builder["Database"] = "master"; } if (!String.IsNullOrEmpty(databaseName)) { if (!Parser.IsValidIdentifier(databaseName)) { throw new ArgumentException("Database name specified in store connection string is not a valid identifier."); } try { #if USESQLCONNECTION using (MSSQLConnection connection = new MSSQLConnection(builder.ConnectionString)) { connection.Execute(String.Format("if not exists (select * from sysdatabases where name = '{0}') create database {0}", databaseName)); #else SqlConnection connection = new SqlConnection(builder.ConnectionString); connection.Open(); SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = String.Format("if not exists (select * from sysdatabases where name = '{0}') create database {0}", databaseName); command.ExecuteNonQuery(); #endif } } catch { // Do not rethrow, this does not necessarily indicate failure, let the non-existence of the database throw later } } } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}", "JE.RMS.Services.DMEEUserToCustomer"); // Get request body try { using (HttpClient httpClient = new HttpClient()) { //Add Basic Authentication header httpClient.BaseAddress = new System.Uri(ConfigurationManager.AppSettings["EnergyEarthBaseUrl"].ToString()); var auth = Encoding.ASCII.GetBytes(ConfigurationManager.AppSettings["EEUserName"].ToString() + ":" + ConfigurationManager.AppSettings["EEPassword"].ToString()); httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(auth)); string GetUsersUrl = ConfigurationManager.AppSettings["GetUsersUrl"].ToString(); //Get Users from Energy Earth API var response = await httpClient.GetAsync(GetUsersUrl); //Convert Users from Energy earth to Customer List Model var customerList = JsonConvert.DeserializeObject <EECustomerList>(await response.Content.ReadAsStringAsync()); log.Verbose("Started migration of EE users to Customer Table", "JE.RMS.Services.DMEEUserToCustomer"); foreach (var customer in customerList.Users) { List <SqlParameter> CustomerParams = new List <SqlParameter>(); CustomerParams.Add(new SqlParameter("@Email", customer.Email)); CustomerParams.Add(new SqlParameter("@FirstName", customer.FirstName)); CustomerParams.Add(new SqlParameter("@LastName", customer.LastName)); CustomerParams.Add(new SqlParameter("@CompanyName", customer.CompanyName)); CustomerParams.Add(new SqlParameter("@UniqueID", customer.UserID)); CustomerParams.Add(new SqlParameter("@AccountAcceptanceDate", customer.AccountAcceptanceDate)); CustomerParams.Add(new SqlParameter("@StartingPointBalance", customer.StartingPointBalance)); CustomerParams.Add(new SqlParameter("@AvailablePointBalance", customer.AvailablePointBalance)); CustomerParams.Add(new SqlParameter("@AvailablePointBalanceDollars", customer.AvailablePointBalanceDollars)); CustomerParams.Add(new SqlParameter("@NumberofTransactions", customer.NumberofTransactions)); CustomerParams.Add(new SqlParameter("@AccountStatus", customer.AccountStatus)); CustomerParams.Add(new SqlParameter("@NextRewardDueDate", customer.NextRewardDueDate)); CustomerParams.Add(new SqlParameter("@ProgramName", customer.Program)); var RMSRewardID = MSSQLConnection.ExecuteStoredProcedure <string>(USPContstants.SaveCustomerFromEnergyEarth, CustomerParams); } log.Verbose("Completed migration of EE users to Customer Table", "JE.RMS.Services.DMEEUserToCustomer"); return(response); } } catch (Exception ex) { log.Error("Something went wrong while DMEEUserToCustomer", ex, "JE.RMS.Services.DMEEUserToCustomer"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public static async void Run(TimerInfo updateCustomerExtendedTimer, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# Timer trigger function processed a request", "JE.RMS.Services.ScheduledUpdateCustomerExtended"); try { log.Verbose($"Update Customer Extended started on : {DateTime.Now.ToString()}", "JE.RMS.Services.ScheduledUpdateCustomerExtended"); //Get All Customer Unique IDs List <string> ListCustomerUniqueIDs = MSSQLConnection.ExecuteStoredProcedure <string>(Common.Constants.USPContstants.GetAllCustomerUniqueID).ToList(); //Fetch Customers and update customer extended foreach (var uniqueId in ListCustomerUniqueIDs) { using (HttpClient httpClient = new HttpClient()) { //Add Basic Authentication header httpClient.BaseAddress = new Uri(ConfigurationManager.AppSettings["GetUserFunctionUrl"].ToString()); string GetUserFunctionUrl = ConfigurationManager.AppSettings["GetUserFunctionCode"].ToString() + uniqueId; var response = await httpClient.GetAsync(GetUserFunctionUrl); if (response.IsSuccessStatusCode) { var responseUser = JsonConvert.DeserializeObject <CustomerExtendedList>(await response.Content.ReadAsStringAsync()); var userData = responseUser.Users.FirstOrDefault(); List <SqlParameter> CustomerExtendedParams = new List <SqlParameter>(); CustomerExtendedParams.Add(new SqlParameter("@CustomerID", string.Empty)); CustomerExtendedParams.Add(new SqlParameter("@UniqueID", uniqueId)); CustomerExtendedParams.Add(new SqlParameter("@AccountAcceptanceDate", userData.AccountAcceptanceDate)); CustomerExtendedParams.Add(new SqlParameter("@StartingPointBalance", userData.StartingPointBalance)); CustomerExtendedParams.Add(new SqlParameter("@AvailablePointBalance", userData.AvailablePointBalance)); CustomerExtendedParams.Add(new SqlParameter("@AvailablePointBalanceDollars", userData.AvailablePointBalanceDollars)); CustomerExtendedParams.Add(new SqlParameter("@NumberofTransactions", userData.NumberofTransactions)); CustomerExtendedParams.Add(new SqlParameter("@AccountStatus", userData.AccountStatus)); CustomerExtendedParams.Add(new SqlParameter("@NextRewardDueDate", userData.NextRewardDueDate)); var customerExtendedID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveCustomerExtended, CustomerExtendedParams); } else { errormessage.Add(response.Content.ReadAsStringAsync().Result); } } } log.Verbose($"Update Customer Extended completed on : {DateTime.Now.ToString()}", "JE.RMS.Services.ScheduledUpdateCustomerExtended"); } catch (Exception ex) { log.Error("Something went wrong while UpdateCustomerExtended", ex, "JE.RMS.Services.ScheduledUpdateCustomerExtended"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); } }
private void btnInsert_Click(object sender, EventArgs e) { cmds[0] = tbQuery1.Text; cmds[1] = tbQuery2.Text; if (rbMySQL.Checked == true) { MySQLConnection MySQLCon = new MySQLConnection(); MySQLCon.MySQLServer = tbServidor.Text; MySQLCon.MySQLPort = tbPort.Text; MySQLCon.MySQLUser = tbUser.Text; MySQLCon.MySQLPass = tbPass.Text; MySQLCon.TransacaoMySQL(cmds); } else if (rbMSSQL.Checked == true) { MSSQLConnection MSSQLCon = new MSSQLConnection(); MSSQLCon.MSSQLServer = tbServidor.Text; MSSQLCon.MSSQLPort = tbPort.Text; MSSQLCon.MSSQLUser = tbUser.Text; MSSQLCon.MSSQLPass = tbPass.Text; MSSQLCon.TransacaoMSSQL(cmds); } else if (rbPgSQL.Checked == true) { PgSQLConnection PgSQLCon = new PgSQLConnection(); PgSQLCon.PgSQLServer = tbServidor.Text; PgSQLCon.PgSQLPort = tbPort.Text; PgSQLCon.PgSQLUser = tbUser.Text; PgSQLCon.PgSQLPass = tbPass.Text; PgSQLCon.TransacaoPgSQL(cmds); } else if (rbFirebird.Checked == true) { FirebirdConnection FirebirdCon = new FirebirdConnection(); FirebirdCon.FirebirdServer = tbServidor.Text; FirebirdCon.FirebirdPort = tbPort.Text; FirebirdCon.FirebirdUser = tbUser.Text; FirebirdCon.FirebirdPass = tbPass.Text; FirebirdCon.TransacaoFirebird(cmds); } else { MessageBox.Show("ERRO"); } }
public void testSequence() { DBStringBuilder mssqlconnecitonString = new DBStringBuilder(DBType.MSSQL, "84.115.153.150", "1433", "testdb", "SA", "Migrate01"); MSSQLConnection mssql = MSSQLConnection.getConnection(); mssql.connectionString = mssqlconnecitonString; mssql.OpenConnection(); Sequence sequence = mssql.GetSequences()[0]; Console.Out.WriteLine(sequence.ToString()); }
public static void Run(TimerInfo evaluateRewardsTrxTimer, ICollector <string> errormessage, TraceWriter log) { if (evaluateRewardsTrxTimer.IsPastDue) { log.Verbose("Timer is running late!", "JE.RMS.Services.GetRewardsTrxReceived"); } try { List <SqlParameter> objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@RewardTrxStatus", "Received")); List <GetRewardsRequest> lstRewardsTrx = MSSQLConnection.ExecuteStoredProcedure <GetRewardsRequest>(USPContstants.GetRewardsTrx, objprm).ToList(); log.Verbose($"Get RewardsTrx Received:={lstRewardsTrx.Count}", "JE.RMS.Services.GetRewardsTrxReceived"); // Retrieve storage account from connection string CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["jermsstorage_STORAGE"].ToString()); // Create the queue client CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); // Retrieve a reference to a queue CloudQueue queue = queueClient.GetQueueReference("rewardfulfillmentrequestqueue"); // Create the queue if it doesn't already exist. queue.CreateIfNotExists(); foreach (GetRewardsRequest item in lstRewardsTrx) { var reqObject = JsonConvert.SerializeObject(item); log.Verbose($"Push message in a queue:= {reqObject}", "JE.RMS.Services.GetRewardsTrxReceived"); // Create a message and add it to the queue. CloudQueueMessage message = new CloudQueueMessage(reqObject.ToString()); queue.AddMessage(message); //Call stored procedure to Save RewardTrxChangeLog List <SqlParameter> RewardTrxChangeLogParams = new List <SqlParameter>(); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardsTrxID", item.RewardTrxID.ToString())); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardTrxStatus", "Received - Ready for fulfillment")); RewardTrxChangeLogParams.Add(new SqlParameter("@Comment", string.Empty)); RewardTrxChangeLogParams.Add(new SqlParameter("@RMSRewardID", null)); var RewardTrxChangeLogID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveRewardTrxChangeLog, RewardTrxChangeLogParams); } log.Verbose($"C# Timer trigger function executed at: {DateTime.Now}", "JE.RMS.Services.GetRewardsTrxReceived"); } catch (Exception ex) { log.Error($"Exception ={ex}", ex, "JE.RMS.Services.GetRewardsTrxReceived"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); } }
public static void Run(string errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request"); try { //JObject data = await req.Content.ReadAsAsync<JObject>(); List <SqlParameter> objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@message", errormessage)); List <Common.Model.SystemLog> obj = MSSQLConnection.ExecuteStoredProcedure <Common.Model.SystemLog>(Common.Constants.USPContstants.SystemLogs, objprm); log.Verbose($"Save systemlog successfully."); } catch (System.Exception ex) { log.Error($"Exception ={ex}"); } }
/// <summary> /// Executes a transaction (a sequence of SQL sentences) from /// <para/>the "buffer". After completion of the "buffer" excecution, /// <para/>the "buffer" is cleared and buffering is disabled. /// </summary> public void EndBufferMSSQL() { if (buffer) { buffer = false; using (SqlTransaction trans = MSSQLConnection.BeginTransaction()) { using (SqlCommand command = new SqlCommand(sql_entry, MSSQLConnection, trans)) { command.CommandText = sql_entry; command.ExecuteNonQuery(); } trans.Commit(); } sql_entry = string.Empty; } }
public IDBConnection GetConnection(ConnectionEnum value) { IDBConnection result = null; switch (value) { case ConnectionEnum.MSSQL: result = new MSSQLConnection(); break; case ConnectionEnum.Oracle: result = new OracleConnection(); break; } return(result); }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}"); try { JObject data = await req.Content.ReadAsAsync <JObject>(); log.Verbose($"received data :={data}", "JE.RMS.Services.GetCustomers"); List <SqlParameter> objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@pageNumber", Convert.ToInt32(data.SelectToken("pageNumber").ToString().TrimStart('{').TrimEnd('}')))); objprm.Add(new SqlParameter("@pageSize", Convert.ToInt32(data.SelectToken("pageSize").ToString().TrimStart('{').TrimEnd('}')))); objprm.Add(new SqlParameter("@searchText", data.SelectToken("searchText") == null?"" : data.SelectToken("searchText").ToString().TrimStart('{').TrimEnd('}'))); log.Verbose($"calling sp", "JE.RMS.Services.GetCustomers"); List <Common.Model.Customer> retobj = MSSQLConnection.ExecuteStoredProcedure <Common.Model.Customer>(Common.Constants.USPContstants.GetCustomers, objprm); Common.Model.CustomerList obj = new Common.Model.CustomerList(); if (retobj.Count > 0) { obj.TotalRows = retobj.FirstOrDefault().TotalRows; } else { obj.TotalRows = 0; } obj.Users = new List <Common.Model.Customer>(); obj.Users = retobj; log.Verbose($"received response:={obj}", "JE.RMS.Services.GetCustomers"); var CustomerResponse = req.CreateResponse(HttpStatusCode.OK); CustomerResponse.Content = new StringContent(JsonConvert.SerializeObject(obj), System.Text.Encoding.UTF8, "application/json"); return(CustomerResponse); //return req.CreateResponse(HttpStatusCode.OK, obj); } catch (Exception ex) { log.Error($"Exception ={ex}"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public void addSeq(MSSQLConnection ms, OracleSQLConnection os, CUBRIDConnection cs) { List <Sequence> seqs; List <String> seqsc; if (ms == null) { seqsc = os.getSequences(); for (int i = 0; i < seqsc.Count; i++) { String sql = seqsc[i]; try { CUBRIDCommand cc = new CUBRIDCommand(sql, cs); cc.ExecuteNonQuery(); } catch (Exception e) { // MessageBox.Show(e + ""); } } } else { seqs = ms.GetSequences(); for (int i = 0; i < seqs.Count; i++) { Sequence q = seqs[i]; String sql = "Create serial " + q.sequenceName + " start with " + q.startNumber + " increment by " + q.increment + " minvalue " + q.minValue + " maxvalue " + q.maxValue + " cache " + q.cache; try { CUBRIDCommand cc = new CUBRIDCommand(sql, cs); cc.ExecuteNonQuery(); } catch (Exception e) { // MessageBox.Show(e + ""); } } } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger GetRoles function processed a request. RequestUri={req.RequestUri}", "JE.RMS.Services.GetRoles"); try { var roles = MSSQLConnection.ExecuteStoredProcedure <Role>(Common.Constants.USPContstants.GetRoles); log.Verbose($"received response:={roles}", "JE.RMS.Services.GetRoles"); return(req.CreateResponse(HttpStatusCode.OK, roles)); } catch (Exception ex) { log.Error("Something went wrong while GetRoles", ex, "JE.RMS.Services.GetRoles"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public static void Run(FulfillmentResponse responsemessage, ICollector <string> errormessage, TraceWriter log) { try { log.Verbose($"C# trigger queue function processed a request. inputmessage={responsemessage}", "JE.RMS.Services.OnRewardsResponseRecieved"); #region Update Audit Fields //Update timestapm in Audit fields List <SqlParameter> AuditParam = new List <SqlParameter>(); AuditParam.Add(new SqlParameter("@RMSRewardID", responsemessage.RMSRewardID)); var RMSRewardID = MSSQLConnection.ExecuteStoredProcedure <string>(USPContstants.UpdateAuditFieldsInRewardsTrx, AuditParam); log.Verbose($"FulfillmentResponseTimestamp updated successfully. RMSRewardID={RMSRewardID[0]}", "JE.RMS.Services.OnRewardsResponseRecieved"); string RewardTrxStatus = "Fulfillment completed"; if (responsemessage.Status == "Fail") { RewardTrxStatus = "Error"; } List <SqlParameter> MessageLogParams = new List <SqlParameter>(); MessageLogParams.Add(new SqlParameter("@RMSRewardID", responsemessage.RMSRewardID)); MessageLogParams.Add(new SqlParameter("@MessageType", MessageType.RewardFulfillmentResponse.GetDescription())); MessageLogParams.Add(new SqlParameter("@IPAddress", responsemessage.ClientIP)); MessageLogParams.Add(new SqlParameter("@Message", JsonConvert.SerializeObject(responsemessage))); MessageLogParams.Add(new SqlParameter("@RewardsTrxID", null)); var ErrorMessageLogID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveMessageLog, MessageLogParams); log.Verbose($"MessageLog stored successfully. MessageLogID={ErrorMessageLogID[0]}", "JE.RMS.Services.ProcessFulfillmentForEnergyEarth"); ////Call stored procedure to Save RewardTrxChangeLog List <SqlParameter> RewardTrxChangeLogParams = new List <SqlParameter>(); RewardTrxChangeLogParams.Add(new SqlParameter("@RMSRewardID", responsemessage.RMSRewardID)); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardTrxStatus", RewardTrxStatus)); RewardTrxChangeLogParams.Add(new SqlParameter("@Comment", string.Empty)); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardsTrxID", null)); var RewardTrxChangeLogID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveRewardTrxChangeLog, RewardTrxChangeLogParams); log.Verbose($"RewardTrxChangeLog stored successfully. RewardTrxChangeLogID={RewardTrxChangeLogID[0]}", "JE.RMS.Services.OnRewardsResponseRecieved"); #endregion } catch (Exception ex) { log.Error($"Exception ={ex}", ex, "JE.RMS.Services.OnRewardsRequestRecieved"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); } }
public void addViews(MSSQLConnection ms, OracleSQLConnection os, CUBRIDConnection cs) { List <String> views; if (ms == null) { views = os.getViews(); } else { views = ms.getViews(); } for (int i = 0; i < views.Count; i++) { try { String sql = views[i]; if (sql.Contains("dbo.object ")) { sql = sql.Replace("dbo.object ", "_object "); } sql = sql.Replace("dbo.", ""); sql = sql.Replace("WITH SCHEMABINDING ", " "); sql = sql + ";"; // MessageBox.Show(sql); CUBRIDCommand cmd = new CUBRIDCommand(sql, cs); cmd.ExecuteNonQuery(); } catch (Exception e) { if (e.Message.Contains("already exists")) { MessageBox.Show("View konnte nicht erstellt werden."); } else { // MessageBox.Show(e + ""); } } } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}"); try { JObject data = await req.Content.ReadAsAsync <JObject>(); log.Verbose($"calling sp", "JE.RMS.Services.GetProgramCodes"); List <Common.Model.Program> obj = MSSQLConnection.ExecuteStoredProcedure <Common.Model.Program>(Common.Constants.USPContstants.GetPrograms); log.Verbose($"received response:={obj}", "JE.RMS.Services.GetProgramCodes"); return(req.CreateResponse(HttpStatusCode.OK, obj)); } catch (Exception ex) { log.Error($"Exception ={ex}"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}", "JE.RMS.Services.SubmitRewardsRequest"); try { // Get request body /*JObject data = await req.Content.ReadAsAsync<JObject>(); * string FulfillmentChannel = (string)data.SelectToken("FulfillmentChannel");*/ string ChannelCode = req.GetQueryNameValuePairs().FirstOrDefault(q => string.Compare(q.Key, "ChannelCode", true) == 0).Value; if (!string.IsNullOrEmpty(ChannelCode)) { //Call stored procedure to Update RewardTrx List <SqlParameter> FulfillmentChanneParams = new List <SqlParameter>(); FulfillmentChanneParams.Add(new SqlParameter("@FulfillmentChannel", ChannelCode)); var FulfillmentChannelID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.GetFulfillmentChannelID, FulfillmentChanneParams); if (FulfillmentChannelID.Count == 0) { return(req.CreateResponse(HttpStatusCode.BadRequest, "Invalid channel code.")); } log.Verbose($"FulfillmentChannelID={FulfillmentChannelID[0]}", "JE.RMS.Services.GetRewardFulfillmentRequest"); RewardFulfillmentResponseList res = new RewardFulfillmentResponseList(); RewardFulfillmentResponseList resp = GetMessagesFromSubscription(FulfillmentChannelID[0], res, log); return(req.CreateResponse(HttpStatusCode.OK, resp)); } else { return(req.CreateResponse(HttpStatusCode.BadRequest, "Required ChannelCode as request parameters.")); } } catch (Exception ex) { log.Error($"Exception ={ex}", ex, "JE.RMS.Services.SubmitRewardsRequest"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}"); try { // Get request body JObject data = await req.Content.ReadAsAsync <JObject>(); log.Verbose($"received data :={data}", "JE.RMS.Services.SearchRewardsTrx"); List <SqlParameter> objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@startDate", data.SelectToken("startDate").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@endDate", data.SelectToken("endDate").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@ssUniqueID", data.SelectToken("ssUniqueID").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@email", data.SelectToken("email").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@sourceSystem", data.SelectToken("sourceSystem").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@countryids", data.SelectToken("countryids").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@jurisdiction", data.SelectToken("jurisdiction").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@transType", data.SelectToken("transType").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@transStatus", data.SelectToken("transStatus").ToString().TrimStart('{').TrimEnd('}'))); objprm.Add(new SqlParameter("@pageNumber", Convert.ToInt32(data.SelectToken("pageNumber").ToString().TrimStart('{').TrimEnd('}')))); objprm.Add(new SqlParameter("@pageSize", Convert.ToInt32(data.SelectToken("pageSize").ToString().TrimStart('{').TrimEnd('}')))); log.Verbose($"calling sp", "JE.RMS.Services.SearchRewardsTrx"); var obj = MSSQLConnection.ExecuteStoredProcedure <Common.Model.SearchRewardTrx>(Common.Constants.USPContstants.SearchRewardsTrx, objprm); log.Verbose($"received response:={obj}", "JE.RMS.Services.SearchRewardsTrx"); return(req.CreateResponse(HttpStatusCode.OK, obj)); } catch (Exception ex) { log.Error($"Exception ={ex}"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public static void closeConnection() { try { if (ms != null) { ms.CloseConnection(); ms = null; } else if (os != null) { os.CloseConnection(); os = null; } else if (csql != null) { csql.CloseConnection(); csql = null; } }catch (Exception e) { } }
public void migrateTables(OracleSQLConnection os, MSSQLConnection ms, CUBRIDConnection cs) { String cols = ""; if (ms == null) { tables = os.GetAllTables(); } else { tables = ms.getTables(); } for (int i = 0; i < tables.Count; i++) { cols = ""; //MessageBox.Show(cols); if (ms == null) { infos = os.getInfo(tables[i]); } else { infos = ms.getInfo(tables[i]); } pks = ""; for (int j = 0; j < infos.Count; j++) { // MessageBox.Show(cols); String name = infos[j].columnname; String type = infos[j].datatype + ""; if (type == DataType.NUMBER + "") { type = "numeric"; } Boolean nullable = infos[j].nullable; Boolean pk = infos[j].isPrimaryKey; if (pk) { pks += "[" + name + "],"; cols += "[" + name + "] " + type + ","; } else { if (!nullable) { cols += "[" + name + "] " + type + " not null " + ","; } else { cols += "[" + name + "] " + type + ","; } } // MessageBox.Show(cols); } if (pks.Length == 0) { insert = "Create Table [" + tables[i] + "]( " + cols.Substring(0, cols.Length - 1) + ");\n"; } if (pks.Length > 0) { insert = "Create Table [" + tables[i] + "]( " + cols + "Primary key (" + pks.Substring(0, pks.Length - 1) + ")" + ");\n"; } try { // MessageBox.Show(insert); CUBRIDCommand cmd = new CUBRIDCommand(insert, cs); cmd.ExecuteNonQuery(); gettableData(tables[i] + "", ms, os, cs); } catch (Exception e) { if ((e + "").Contains("OBJECT")) { int index = insert.IndexOf("["); String substring1 = insert.Substring(index + 1); String substring2 = insert.Substring(0, 14); insert = substring2 + "_" + substring1; CUBRIDCommand cmd = new CUBRIDCommand(insert, cs); cmd.ExecuteNonQuery(); } else { MessageBox.Show(e + ""); } gettableData(tables[i] + "", ms, os, cs); } pks = ""; cols = ""; } for (int i = 0; i < tables.Count; i++) { if (ms == null) { constraints = os.getConstraintsFromTable(tables[i]); } else { constraints = ms.getConstraintsFromTable(tables[i]); // MessageBox.Show(tables[i] + " - " + constraints.Count); } for (int j = 0; j < constraints.Count; j++) { if (!tables[i].ToLower().Equals("object") && !constraints[j].FKtableName.ToLower().Equals("object")) { if ((constraints[j].constraintType + "").Equals("ForeignKey")) { String stat = "Alter table [" + tables[i] + "] add foreign key(" + constraints[j].columnName + ")" + " references [" + constraints[j].FKtableName + "](" + constraints[j].FKcolumnName + ");\n"; altertablestatement += stat; } else if ((constraints[j].constraintType + "").Contains("Unique")) { if (os != null) { } else { String stat = "Alter table [" + tables[i] + "] add unique(" + constraints[j].columnName + ");"; // altertablestatement += stat; } } else { String stat = "Alter table [" + tables[i] + "] add constraint " + constraints[j].constraintName + " check (" + constraints[j].Condition + ");"; altertablestatement += stat; // MessageBox.Show(altertablestatement); } } } } //addViews(ms,os,cs); // MessageBox.Show(insert); // MessageBox.Show(altertablestatement); try { // MessageBox.Show(altertablestatement); CUBRIDCommand cmd2 = new CUBRIDCommand(altertablestatement, cs); cmd2.ExecuteNonQuery(); addViews(ms, os, cs); addSeq(ms, os, cs); } catch (Exception e) { if (e.Message.Contains("already defined")) { MessageBox.Show(e.Message); altertablestatement = ""; } else { MessageBox.Show(e + ""); } } }
public static async void Run(TimerInfo rewardsResponseTimer, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# timer function processed a request.", "JE.RMS.Services.ScheduledReadRewardsRequestRecieved"); try { //Service bus queue names and connection stringsAllFulfillmentResponseSubscription var connectionString = ConfigurationManager.AppSettings["MyServiceBusReader"].ToString(); SubscriptionClient AllFulfillmentResponseSubscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, "fulfillmentresponse", "AllFulfillmentResponseSubscription"); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); int BatchSize = Convert.ToInt32(ConfigurationManager.AppSettings["RewardFulfillmentResponseBatchSize"]); IEnumerable <BrokeredMessage> RecievedMessage = null; long MessageCount = namespaceManager.GetSubscription("fulfillmentresponse", "AllFulfillmentResponseSubscription").MessageCount; if (MessageCount > 0) { RecievedMessage = AllFulfillmentResponseSubscriptionClient.ReceiveBatch(BatchSize); } log.Verbose($"After the reading of queue message = {MessageCount}", "JE.RMS.Services.ScheduledReadRewardsRequestRecieved"); List <Guid> messageLockTokenList = new List <System.Guid>(); if (RecievedMessage != null && RecievedMessage.Count() > 0) { foreach (BrokeredMessage message in RecievedMessage) { var responsemessage = message.GetBody <FulfillmentResponse>(); //var responsemessage = JsonConvert.DeserializeObject<FulfillmentResponse>(raw); log.Verbose($"C# trigger queue function processed a request. inputmessage={responsemessage}", "JE.RMS.Services.OnRewardsResponseRecieved"); #region Update Audit Fields //Update timestapm in Audit fields List <SqlParameter> AuditParam = new List <SqlParameter>(); AuditParam.Add(new SqlParameter("@RMSRewardID", responsemessage.RMSRewardID)); var RMSRewardID = MSSQLConnection.ExecuteStoredProcedure <string>(USPContstants.UpdateAuditFieldsInRewardsTrx, AuditParam); log.Verbose($"FulfillmentResponseTimestamp updated successfully. RMSRewardID={RMSRewardID[0]}", "JE.RMS.Services.OnRewardsResponseRecieved"); string RewardTrxStatus = "Fulfillment completed"; if (responsemessage.Status == "Fail") { RewardTrxStatus = "Error"; } List <SqlParameter> MessageLogParams = new List <SqlParameter>(); MessageLogParams.Add(new SqlParameter("@RMSRewardID", responsemessage.RMSRewardID)); MessageLogParams.Add(new SqlParameter("@MessageType", MessageType.RewardFulfillmentResponse.GetDescription())); MessageLogParams.Add(new SqlParameter("@IPAddress", responsemessage.ClientIP)); MessageLogParams.Add(new SqlParameter("@Message", JsonConvert.SerializeObject(responsemessage))); MessageLogParams.Add(new SqlParameter("@RewardsTrxID", null)); var ErrorMessageLogID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveMessageLog, MessageLogParams); log.Verbose($"MessageLog stored successfully. MessageLogID={ErrorMessageLogID[0]}", "JE.RMS.Services.ProcessFulfillmentForEnergyEarth"); ////Call stored procedure to Save RewardTrxChangeLog List <SqlParameter> RewardTrxChangeLogParams = new List <SqlParameter>(); RewardTrxChangeLogParams.Add(new SqlParameter("@RMSRewardID", responsemessage.RMSRewardID)); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardTrxStatus", RewardTrxStatus)); RewardTrxChangeLogParams.Add(new SqlParameter("@Comment", string.Empty)); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardsTrxID", null)); var RewardTrxChangeLogID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveRewardTrxChangeLog, RewardTrxChangeLogParams); log.Verbose($"RewardTrxChangeLog stored successfully. RewardTrxChangeLogID={RewardTrxChangeLogID[0]}", "JE.RMS.Services.OnRewardsResponseRecieved"); #endregion messageLockTokenList.Add(message.LockToken); } AllFulfillmentResponseSubscriptionClient.CompleteBatch(messageLockTokenList); } } catch (Exception ex) { log.Error($"Exception ={ex}", ex, "JE.RMS.Services.OnRewardsRequestRecieved"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); } }
/// <summary> /// The most important method in LangLib. This creates the database, /// <para/>the tables to it (MESSAGES, FORMITEMS, CULTURES). /// <para/><para/>Also the FallBackCulture is updated for the underlying form/window. /// <para/>Messages from the given <paramref name="messageResource"/> are inserted to /// <para/>the database if their don't exists. /// <para/><para/>The table fields FORMITEMS.INUSE and MESSAGES.INUSE are updated /// <para/>for the FallBackCulture. /// </summary> /// <param name="messageResource">A resource name that contains the application /// <para/>messages in the fall FallBackCulture language. /// <para/>For example if I have an application which assembly name is /// <para/>LangLibTestWinforms and it has a .resx file called Messages /// <para/>I would give this parameter a value of "LangLibTestWinforms.Messages".</param> /// <param name="culture">The culture to use for the localization. /// <para/>If no culture is given the current system culture is used and /// <para/>the FallBackCulture is used as fallback culture.</param> /// <param name="loadItems">To load language items or not.</param> public void InitalizeLanguageMSSQL(string messageResource, CultureInfo culture = null, bool loadItems = true) { if (culture == null) { culture = CultureInfo.CurrentCulture; } if (!Design) { try { DateTime dt = DateTime.Now; if (!Directory.Exists(DataDir)) { Directory.CreateDirectory(DataDir); } if (MSSQLConnection == null) { string connStr = dbConnectionStr == string.Empty ? string.Format("Persist Security Info=False;User ID={3};Password={4};Initial Catalog={2};Server={0};", dbHost, dbPort, dbName, dbUser, dbPassword) : dbConnectionStr; MSSQLConnection = new SqlConnection(connStr); MSSQLConnection.Open(); } if (!tablesCreated && !dbNoTables) { using (SqlCommand command = new SqlCommand(TableCreateMessages, MSSQLConnection)) { command.ExecuteNonQuery(); } using (SqlCommand command = new SqlCommand(TableCreateFormItems, MSSQLConnection)) { command.ExecuteNonQuery(); } using (SqlCommand command = new SqlCommand(TableCreateCultures, MSSQLConnection)) { command.ExecuteNonQuery(); } tablesCreated = true; } if (!culturesInserted && !loadItems) { string sql = string.Empty; CultureInfo[] allCultures; allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures); foreach (CultureInfo ci in allCultures) { sql += InsertCulture(ci); } using (SqlTransaction trans = MSSQLConnection.BeginTransaction()) { using (SqlCommand command = new SqlCommand(sql, MSSQLConnection, trans)) { command.CommandText = sql; command.ExecuteNonQuery(); } trans.Commit(); } culturesInserted = true; } if (!loadItems) { GetGuiObjets(fallBackCulture); if (!langUseUpdated) { using (SqlTransaction trans = MSSQLConnection.BeginTransaction()) { using (SqlCommand command = new SqlCommand("UPDATE " + Schema + "FORMITEMS SET INUSE = 0 WHERE CULTURE = '" + fallBackCulture + "' ", MSSQLConnection, trans)) { command.ExecuteNonQuery(); } trans.Commit(); } langUseUpdated = true; } SaveLanguageItems(this.BaseInstance, fallBackCulture); } if (loadItems) { List <string> localProps = LocalizedPropsMSSQL(AppForm, CultureInfo.CurrentCulture); GetGuiObjets(CultureInfo.CurrentCulture, localProps); LoadLanguageItems(CultureInfo.CurrentCulture); } if (!loadItems) { SaveMessages(messageResource, Assembly.GetExecutingAssembly(), ref MSSQLConnection); } ts = ts.Add((DateTime.Now - dt)); } catch (Exception ex) { if (ex.GetType() == typeof(MissingManifestResourceException)) // This is fun. The user actually gets some help from the exception message ;-) { throw new LangLibException(string.Format("Missing resource '{0}'.{1}Perhaps {2}.[Resource file name] would do,{3}without the .resx file extension.", messageResource, Environment.NewLine, GetAssemblyName(this.appType), Environment.NewLine)); } else { throw; } } } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, ICollector <string> errormessage, TraceWriter log) { log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}", "JE.RMS.Services.SubmitRewardFulfillmentResponse"); try { string clientIP = ((HttpContextWrapper)req.Properties["MS_HttpContext"]).Request.UserHostAddress; log.Verbose($"clientIP:={clientIP}", "JE.RMS.Services.SubmitRewardFulfillmentResponse"); string Message = await req.Content.ReadAsStringAsync(); var RewardFulfillmentResponse = JsonConvert.DeserializeObject <FulfillmentResponse>(Message); if (RewardFulfillmentResponse == null) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Null Request object.")); } JSchema schema = JSchema.Parse(RewardRequestSchema.FulfillmentResponseSchema); IList <string> messages; JObject inputJSON = JObject.Parse(Message); bool valid = inputJSON.IsValid(schema, out messages); log.Info($"Valid ={valid}"); log.Info($"Validation message ={messages}"); var messageJSON = ""; if (messages.Count > 0) { messageJSON = JsonConvert.SerializeObject(messages); } List <SqlParameter> validateParam = new List <SqlParameter>(); validateParam.Add(new SqlParameter("@RMSRewardID", RewardFulfillmentResponse.RMSRewardID)); var RMSRewardIDCount = MSSQLConnection.ExecuteStoredProcedure <int>(USPContstants.ValidateRMSRewardID, validateParam).FirstOrDefault(); if (RMSRewardIDCount == 0) { messageJSON = messageJSON + RewardFulfillmentResponse.RMSRewardID + " does not exist or fulfillment already processed. Path: RMSRewardID;"; } if (!string.IsNullOrEmpty(messageJSON)) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, messageJSON)); } var connectionString = ConfigurationManager.AppSettings["MyServiceBusReader"].ToString(); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); #region Create Subscrptions for the first time //// Create a "AllFulfillmentResponseSubscription" for all subscription. if (!namespaceManager.SubscriptionExists("fulfillmentresponse", "AllFulfillmentResponseSubscription")) { namespaceManager.CreateSubscription("fulfillmentresponse", "AllFulfillmentResponseSubscription"); } #endregion RewardFulfillmentResponse.ClientIP = clientIP; var FulfillmentResponseTopicClient = TopicClient.CreateFromConnectionString(connectionString, "fulfillmentresponse"); BrokeredMessage message = new BrokeredMessage(RewardFulfillmentResponse); //Send message to Topic FulfillmentResponseTopicClient.Send(message); #region Update Audit Fields //Update timestapm in Audit fields List <SqlParameter> AuditParam = new List <SqlParameter>(); AuditParam.Add(new SqlParameter("@RMSRewardID", RewardFulfillmentResponse.RMSRewardID)); var RMSRewardID = MSSQLConnection.ExecuteStoredProcedure <string>(USPContstants.UpdateAuditFieldsInRewardsTrx, AuditParam); log.Verbose($"FulfillmentResponseTimestamp updated successfully. RMSRewardID={RMSRewardID[0]}", "JE.RMS.Services.SubmitRewardFulfillmentResponse"); #endregion var Status = "Success"; return(req.CreateResponse(HttpStatusCode.OK, new { Status }, JsonMediaTypeFormatter.DefaultMediaType)); } catch (Exception ex) { log.Error($"Exception ={ex}", ex, "JE.RMS.Services.SubmitRewardFulfillmentResponse"); errormessage.Add(JsonConvert.SerializeObject(ex).ToString()); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, "Fail", ex)); } }
private static EvaluateRuleResponse EvaluateRewardsTrxMessage(string rewardfulfillmentrequest, TraceWriter log) { //Get FulFillmentRule from DB var FulfillmentRulesList = MSSQLConnection.ExecuteStoredProcedure <FulfillmentRules>(USPContstants.GetFulfillmentRules, null); var lstRewardsTrx = JsonConvert.DeserializeObject <GetRewardsRequest[]>(rewardfulfillmentrequest); foreach (GetRewardsRequest item in lstRewardsTrx) { List <SqlParameter> objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@Email", item.Email)); objprm.Add(new SqlParameter("@ProductID", item.ProductID)); objprm.Add(new SqlParameter("@ProgramID", item.ProgramID)); objprm.Add(new SqlParameter("@RewardTrxID", item.RewardTrxID)); var FulfillmentDataPerCust = MSSQLConnection.ExecuteStoredProcedure <FulfillmentRules>(USPContstants.GetFulFillmentDataPerCustomer, objprm); item.RewardTrxStatus = string.Empty; string Comment = string.Empty; if (item.TransactionType == TransactionTypeEnum.ProgramUpdateSourceSystem.GetDescription() || item.TransactionType == TransactionTypeEnum.Qualify.GetDescription() || item.TransactionType == TransactionTypeEnum.Reactivate.GetDescription() || item.TransactionType == TransactionTypeEnum.Terminate.GetDescription()) { objprm = new List <SqlParameter>(); objprm.Add(new SqlParameter("@FulfillmentChannel", FulfillmentChannel.EnergyEarth.GetDescription())); var FulfillmentChannelID = MSSQLConnection.ExecuteStoredProcedure <int>(USPContstants.GetFulfillmentChannelID, objprm).FirstOrDefault(); item.FulfillmentChannelID = FulfillmentChannelID; item.RewardTrxStatus = "Ready for fulfillment"; } else { foreach (FulfillmentRules fulfillmentRule in FulfillmentRulesList) { if (fulfillmentRule.ProductID == item.ProductID && fulfillmentRule.ProgramID == item.ProgramID) { item.RewardTrxStatus = "Ready for fulfillment"; if (item.IsFulfillImmediate == true) { item.RewardTrxStatus = RewardTrxStatusEnum.ReadyForFulfillmentImmediate.GetDescription(); } if (fulfillmentRule.RequireApproval) { item.RewardTrxStatus = "Waiting for approval"; Comment = "Reward Trx is Waiting for approval."; } else if (fulfillmentRule.MaxOccurrencePerYear > 0 && FulfillmentDataPerCust[0].MaxOccurrencePerYear >= fulfillmentRule.MaxOccurrencePerYear) { item.RewardTrxStatus = "Rejected - System"; Comment = "Max occurrence per year is exceeds."; } else if (fulfillmentRule.MaxOccurrencePerCustomer > 0 && FulfillmentDataPerCust[0].MaxOccurrencePerCustomer >= fulfillmentRule.MaxOccurrencePerCustomer) { item.RewardTrxStatus = "Rejected - System"; Comment = "Max occurrence per customer is exceeds."; } else if (fulfillmentRule.MaxRewardValue > 0 && item.ProductValue > fulfillmentRule.MaxRewardValue) { item.RewardTrxStatus = "Rejected - System"; Comment = "Max reward value is exceeds."; } else if (fulfillmentRule.MaxCumulativeRewardValuePerYear > 0 && FulfillmentDataPerCust[0].MaxCumulativeRewardValuePerYear + item.ProductValue > fulfillmentRule.MaxCumulativeRewardValuePerYear) { item.RewardTrxStatus = "Rejected - System"; Comment = "Max cumulative reward value per year is exceeds."; } if (fulfillmentRule.FulfillmentChannelID > 0) { item.FulfillmentChannelID = fulfillmentRule.FulfillmentChannelID; } else { item.RewardTrxStatus = string.Empty; } break; } } } if (item.RewardTrxStatus != string.Empty) { //Call stored procedure to Update RewardTrx List <SqlParameter> RewardTrxParams = new List <SqlParameter>(); RewardTrxParams.Add(new SqlParameter("@RewardTrxID", item.RewardTrxID)); RewardTrxParams.Add(new SqlParameter("@FulfillmentChannelID", item.FulfillmentChannelID)); log.Verbose($"item.FulfillmentChannelID={item.FulfillmentChannelID}", "JE.RMS.Services.EvaluateRewardsTrx"); var RewardTrxID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.UpdateFulfillmentChannelIDInRewardsTrx, RewardTrxParams); log.Verbose($"RewardTrx updated successfully. RewardTrID={RewardTrxID[0]}", "JE.RMS.Services.EvaluateRewardsTrx"); //Call stored procedure to Save RewardTrxChangeLog List <SqlParameter> RewardTrxChangeLogParams = new List <SqlParameter>(); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardsTrxID", item.RewardTrxID.ToString())); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardTrxStatus", item.RewardTrxStatus)); RewardTrxChangeLogParams.Add(new SqlParameter("@Comment", Comment)); RewardTrxChangeLogParams.Add(new SqlParameter("@RMSRewardID", null)); var RewardTrxChangeLogID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveRewardTrxChangeLog, RewardTrxChangeLogParams); log.Verbose($"RewardTrxChangeLog stored successfully. RewardTrxChangeLogID={RewardTrxChangeLogID[0]}", "JE.RMS.Services.EvaluateRewardsTrx"); } else { item.RewardTrxStatus = "Validation Error"; Comment = $"No fulfillment rule found for Program Code: { item.ProgramName } and Product Code: { item.ProductCode}. "; //Call stored procedure to Save RewardTrxChangeLog List <SqlParameter> RewardTrxChangeLogParams = new List <SqlParameter>(); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardsTrxID", item.RewardTrxID.ToString())); RewardTrxChangeLogParams.Add(new SqlParameter("@RewardTrxStatus", RewardTrxStatusEnum.ValidationError.GetDescription())); RewardTrxChangeLogParams.Add(new SqlParameter("@Comment", Comment)); RewardTrxChangeLogParams.Add(new SqlParameter("@RMSRewardID", null)); var RewardTrxChangeLogID = MSSQLConnection.ExecuteStoredProcedure <long>(USPContstants.SaveRewardTrxChangeLog, RewardTrxChangeLogParams); log.Verbose($"RewardTrxChangeLog stored successfully. RewardTrxChangeLogID={RewardTrxChangeLogID[0]}", "JE.RMS.Services.EvaluateRewardsTrx"); } Response.Comment = Comment; Response.RequestID = item.RequestId; Response.Status = item.RewardTrxStatus; } return(Response); }
public static void close() { os = null; ms = null; cs = null; }
public void gettableData(String tablename, MSSQLConnection ms, OracleSQLConnection os, CUBRIDConnection cs) { String data = ""; if (os == null) { dt = ms.getDataFromTable(tablename); } else { dt = os.getDataFromTable(tablename); } foreach (DataRow row in dt.Rows) { Object[] array = row.ItemArray; for (int i = 0; i < array.Length; i++) { // MessageBox.Show(array[i].GetType()+""); if ((array[i].GetType() + "").Contains("Date")) { data += "to_date(" + "'" + (array[i] + "").Substring(0, 10) + "'" + "," + "'dd.mm.yyyy'" + ")" + ","; } else if ((array[i].GetType() + "").Contains("varchar") || (array[i].GetType() + "").Contains("String")) { String assist = array[i] + ""; if ((array[i] + "").Contains("'")) { assist = assist.Replace("'", "''"); } data += "'" + assist + "'" + ","; } else { if ((array[i] + "").Equals("")) { data += "null,"; } else { if ((array[i] + "").Contains(",")) { array[i] = (array[i] + "").Replace(",", "."); } data += array[i] + ","; } } } data = data.Substring(0, data.Length - 1); String insert = ""; if (tablename.Equals("OBJECT")) { insert = "Insert into [" + "_" + tablename + "] Values(" + data + ");"; } else { insert = "Insert into [" + tablename + "] Values(" + data + ");"; } try { CUBRIDCommand cmd = new CUBRIDCommand(insert, cs); cmd.ExecuteNonQuery(); } catch (Exception e) { MessageBox.Show(e + ""); MessageBox.Show(insert); } data = ""; } //String insert = "Insert into " + tablename + " Values(" + ")"; }
public void TestInitialize() { mssql = MSSQLConnection.getConnection(); mssql.connectionString = mssqlconnecitonString; mssql.OpenConnection(); }