protected void Page_Load(object sender, EventArgs e) { string response = ""; try { string body = GetValue("Body"); string from = GetValue("From"); string city = GetValue("FromCity"); string state = GetValue("FromState"); string zip = GetValue("FromZip"); string country = GetValue("FromCountry"); if (string.IsNullOrEmpty(body) == false && string.IsNullOrEmpty(from) == false) { //Refactor this! DomainLogic ugitFitDataTracker = new UGFClassFactory().CreateUGFDomainMgr(); response = ugitFitDataTracker.ProcessTextMessageReceived(country, state, city, from, body, this.IsTestWebPage); } } catch (Exception exp) { response = "Error: " + exp.Message + "<br/><br/>"; Exception expInner = exp.InnerException; while (expInner != null) { response += expInner.Message + "<br/><br/>"; expInner = expInner.InnerException; } } if (response.isNullOrEmpty()) { response = "Response is null? idk why!"; } if (!string.IsNullOrEmpty(response)) { int length = response.Length; Response.Clear(); Response.ContentType = "text/xml"; if (this.IsTestWebPage) { response += string.Format(" (text length: {0})", length); } string twilioResponse = string.Format("<Response><Sms>{0}</Sms></Response>", response); Response.Write(twilioResponse); } }
protected void Page_Load(object sender, EventArgs e) { string response = ""; try { string body = GetValue("Body"); string from = GetValue("From"); string city = GetValue("FromCity"); string state = GetValue("FromState"); string zip = GetValue("FromZip"); string country = GetValue("FromCountry"); if (string.IsNullOrEmpty(body) == false && string.IsNullOrEmpty(from) == false) { //Refactor this! DomainLogic ugitFitDataTracker = new UGFClassFactory().CreateUGFDomainMgr(); response = ugitFitDataTracker.ProcessTextMessageReceived(country, state, city, from, body, this.IsTestWebPage); } } catch (Exception exp) { try { string path = string.Format("Error: {0}", exp.Message); //string.IsNullOrEmpty } catch { }//I"ll response = "An unexpected error occurred"; } if (!string.IsNullOrEmpty(response)) { int length = response.Length; Response.Clear(); Response.ContentType = "text/xml"; if (this.IsTestWebPage) { response += string.Format(" (text length: {0})", length); } string twilioResponse = string.Format("<Response><Sms>{0}</Sms></Response>", response); Response.Write(twilioResponse); } }
protected void Page_Load(object sender, EventArgs e) { //This page will display the possible commands. string result = "commands: createDb, createRequests, sendTrackingRequests, phone, TRCount, seedDB, connString "; try { if (this.GetBoolValue("connString")) { if (this.CommandIsAllowed("connString")) { result = new UGFClassFactory().CreateRepository().DataSource; } } if (this.GetBoolValue("createDb")) { if (this.CommandIsAllowed("createDb")) { UGFSeeder.DropAndRecreateEntireDatabase(); result = "Database Created"; } else { result = "Cannot call createDb in this environment"; } } if (this.GetBoolValue("seedDB")) { if (this.CommandIsAllowed("seedDB")) { UGFSeeder.SeedExistingDatabase(); result = "Seeded"; } else { result = "Cannot call this command."; } } if (GetBoolValue("createRequests")) { if (this.CommandIsAllowed("createRequests")) { string phoneNumber = GetValue("phone"); int numberOfRequests = GetIntValue("TRCount"); UGitFit.DAL.UGFSeeder.CreateTrackingRequests(phoneNumber, numberOfRequests); result = "crateRequests done."; } else { result = "Cannot call createRequests in this environment."; } } if (GetBoolValue("sendTrackingRequests")) { if (this.CommandIsAllowed("sendTrackingRequests")) { UGitFit.TrackingDomain.DomainLogic logic = new DomainLogic(new UGitFit.DAL.UGFContext()); logic.SendScheduledTexts(null); result = "Scheduled Tracking Requests Processed"; } else { result = "Cannot call sendTrackingRequests in this environment"; } } } catch (Exception exp) { result = "Error: " + exp.Message + "<br/><br/>"; Exception expInner = exp.InnerException; while (expInner != null) { result += expInner.Message + "<br/><br/>"; expInner = expInner.InnerException; } } Response.Write(string.Format("<result>{0}</result>", result)); }
protected void Page_Load(object sender, EventArgs e) { //This page will display the possible commands. string result = "commands: createDb, createRequests, sendTrackingRequests, phone, TRCount, seedDB, connString "; try { if (this.GetBoolValue("connString")) { if (this.CommandIsAllowed("connString")) { result = new UGFClassFactory().CreateRepository().DataSource; } } int id = GetIntValue("Id", 0); if (id > 0) { string name = GetValue("name"); string value = GetValue("value"); if (name.isNullOrEmpty() == false && value.isNullOrEmpty() == false) { new UGitFit.DAL.UGFContext().ExecuteEmbeddedSQL(string.Format("INSERT INTO TestTable (Id, Name, Value) Values ({0},'{1}','{2}')", id, name, value)); } } if (this.GetBoolValue("createDb")) { if (this.CommandIsAllowed("createDb")) { UGFSeeder.DropAndRecreateEntireDatabase(); result = "Database Created"; } else { result = "Cannot call createDb in this environment"; } } if (this.GetBoolValue("seedDB")) { if (this.CommandIsAllowed("seedDB")) { UGFSeeder.SeedExistingDatabase(); result = "Seeded"; } else { result = "Cannot call this command."; } } if (GetBoolValue("createRequests")) { if (this.CommandIsAllowed("createRequests")) { string phoneNumber = GetValue("phone"); int numberOfRequests = GetIntValue("TRCount"); UGitFit.DAL.UGFSeeder.CreateTrackingRequests(phoneNumber, numberOfRequests); result = "crateRequests done."; } else { result = "Cannot call createRequests in this environment."; } } if (GetBoolValue("sendTrackingRequests")) { if (this.CommandIsAllowed("sendTrackingRequests")) { UGitFit.TrackingDomain.DomainLogic logic = new DomainLogic(new UGitFit.DAL.UGFContext()); List <TextToSend> sentTexts = logic.SendScheduledTexts(null); result = TextToSend.ListToXMLString(sentTexts); Response.Clear(); Response.ContentType = "text/xml"; } else { result = "Cannot call sendTrackingRequests in this environment"; } } } catch (Exception exp) { result = "Error: " + exp.Message + "<br/><br/>"; Exception expInner = exp.InnerException; while (expInner != null) { result += expInner.Message + "<br/><br/>"; expInner = expInner.InnerException; } } Response.Write(string.Format("<result>{0}</result>", result)); }