public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db) { string user_name = context.Request.Params.Get("user_name"); if (isNull(user_name)) { return(new PagedData("CreateNewProject.ashx expects a user_name")); } ProjectInformation newProject = new ProjectInformation(); newProject.locked = true; //start the project off as locked by the user who created it newProject.user_name = user_name; // db.ProjectInformations.InsertOnSubmit(newProject); db.SubmitChanges(); //create the new project so we can have a new project_id with which to create new records in other tables //create a new record in dependent tables MISNew newMISNew = new MISNew(); newMISNew.project_id = newProject.project_id; db.MISNews.InsertOnSubmit(newMISNew); db.SubmitChanges(); MISNewDelivery newMISDelivery = new MISNewDelivery(); newMISDelivery.mis_new_id = newMISNew.mis_new_id; db.MISNewDeliveries.InsertOnSubmit(newMISDelivery); MISUpdate newMISUpdate = new MISUpdate(); newMISUpdate.project_id = newProject.project_id; newMISUpdate.description = ""; db.MISUpdates.InsertOnSubmit(newMISUpdate); db.SubmitChanges(); MISUpdateDeliveryChange newMISUpdateDeliveryChange = new MISUpdateDeliveryChange(); newMISUpdateDeliveryChange.mis_update_id = newMISUpdate.mis_update_id; db.MISUpdateDeliveryChanges.InsertOnSubmit(newMISUpdateDeliveryChange); ProdInstallationBuffet prodBuffet = new ProdInstallationBuffet(); prodBuffet.project_id = newProject.project_id; db.ProdInstallationBuffets.InsertOnSubmit(prodBuffet); PromptWorksheet promptWorksheet = new PromptWorksheet(); promptWorksheet.project_id = newProject.project_id; promptWorksheet.prompt_worksheet = ""; promptWorksheet.prompt_summary = ""; db.PromptWorksheets.InsertOnSubmit(promptWorksheet); SWDSchedule swdSchedule = new SWDSchedule(); swdSchedule.project_id = newProject.project_id; db.SWDSchedules.InsertOnSubmit(swdSchedule); TrafficRequirement trafficRequirement = new TrafficRequirement(); trafficRequirement.project_id = newProject.project_id; db.TrafficRequirements.InsertOnSubmit(trafficRequirement); UatProdInstall uatProdInstall = new UatProdInstall(); uatProdInstall.project_id = newProject.project_id; db.UatProdInstalls.InsertOnSubmit(uatProdInstall); db.SubmitChanges(); //insert a history note that the project was created ProjectHistory historyNote = new ProjectHistory(); historyNote.project_id = newProject.project_id; historyNote.user_name = user_name; historyNote.description = "Project created"; historyNote.date = DateTime.Today.ToString("yyyy-MM-dd"); db.ProjectHistories.InsertOnSubmit(historyNote); db.SubmitChanges(); return(new PagedData(new { newProject.project_id })); }
public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db) { IQueryable <ProjectInformation> q = db.ProjectInformations; System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding); var jsonSerializer = new JsonSerializer(); JObject blob = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd()))); string intro = "The Traffic & Routing page had the following modifications: "; string logBuilder = ""; string filter = context.Request.Params.Get("project_id"); string username = context.Request.Params.Get("user_name"); string permission = context.Request.Params.Get("permission"); if (!isNull(filter)) { TrafficRequirement record = db.TrafficRequirements.Single(a => a.project_id.Equals(int.Parse(filter))); if (blob["trafficroutingAverageCallDuration"] != null) { if (record.avg_call_duration != (String)blob["trafficroutingAverageCallDuration"]) { logBuilder += "Average Call Duration changed from \"" + record.avg_call_duration + "\" -> \"" + (String)blob["trafficroutingAverageCallDuration"] + "\"; "; } record.avg_call_duration = (String)blob["trafficroutingAverageCallDuration"]; } if (blob["trafficroutingBusyHourCallPercentage"] != null) { if (record.busy_hour_call_percentage != (String)blob["trafficroutingBusyHourCallPercentage"]) { logBuilder += "Busy-Hour Call % changed from \"" + record.busy_hour_call_percentage + "\" -> \"" + (String)blob["trafficroutingBusyHourCallPercentage"] + "\"; "; } record.busy_hour_call_percentage = (String)blob["trafficroutingBusyHourCallPercentage"]; } if (blob["trafficroutingBusyHourCalls"] != null) { if (record.busy_hour_calls != (String)blob["trafficroutingBusyHourCalls"]) { logBuilder += "Busy-Hour Calls changed from \"" + record.busy_hour_calls + "\" -> \"" + (String)blob["trafficroutingBusyHourCalls"] + "\"; "; } record.busy_hour_calls = (String)blob["trafficroutingBusyHourCalls"]; } if (blob["trafficroutingIncludedInForecast"] != null) { if (record.forecast != (((String)blob["trafficroutingIncludedInForecast"]) == "yes" ? true : false)) { logBuilder += "Included in Forecast changed from \"" + record.forecast + "\" -> \"" + (String)blob["trafficroutingIncludedInForecast"] + "\"; "; } record.forecast = (((String)blob["trafficroutingIncludedInForecast"]) == "yes" ? true : false); } if (blob["trafficroutingIncrementalCallsPerMonth"] != null) { if (record.calls_month != (String)blob["trafficroutingIncrementalCallsPerMonth"]) { logBuilder += "Incremental Calls / Mo. changed from \"" + record.calls_month + "\" -> \"" + (String)blob["trafficroutingIncrementalCallsPerMonth"] + "\"; "; } record.calls_month = (String)blob["trafficroutingIncrementalCallsPerMonth"]; } if (blob["trafficroutingIncrementalMinutesPerMonth"] != null) { if (record.min_month != (String)blob["trafficroutingIncrementalMinutesPerMonth"]) { logBuilder += "Incremental Min. / Mo. changed from \"" + record.min_month + "\" -> \"" + (String)blob["trafficroutingIncrementalMinutesPerMonth"] + "\"; "; } record.min_month = (String)blob["trafficroutingIncrementalMinutesPerMonth"]; } db.SubmitChanges(); // if (permission != "PM") // { if (logBuilder != "") { logBuilder = logBuilder.Replace("False", "no"); logBuilder = logBuilder.Replace("True", "yes"); } intro = (intro + logBuilder); intro = intro.Trim(); if (intro.LastIndexOf(";") == intro.Length - 1) { intro = intro.Substring(0, intro.Length - 1); } ChangeLog newLog = new ChangeLog(); newLog.project_id = Convert.ToInt32(filter); newLog.time = DateTime.Now.ToShortTimeString(); newLog.date = DateTime.Now.ToShortDateString(); newLog.tab = "Traffic & Routing"; newLog.user_name = username; newLog.description = intro; if ((!db.ChangeLogs.Contains(newLog)) && (logBuilder.Length > 0)) { db.ChangeLogs.InsertOnSubmit(newLog); db.SubmitChanges(); } // } return(new PagedData("Traffic requirements saved")); } return(new PagedData("UpdateTrafficRouting.ashx required a project_id")); }