public static string convertSerializedJSON(ProblemTracker record) { JSON_Objects.ProblemRecordJSON recordJSON = new JSON_Objects.ProblemRecordJSON(); recordJSON.id = record.id; recordJSON.index = ProblemList.IndexOf(record); recordJSON.affectedService = record.affectedService; recordJSON.leadTicket = record.leadTicket; recordJSON.startDateTime = record.startDateTime.ToString(); recordJSON.endDateTime = record.endDateTime.ToString(); recordJSON.description = record.description; recordJSON.problemCondition = record.ProblemCondition_id; recordJSON.plannedEndDateTime = record.plannedEndDateTime.ToString(); recordJSON.reportedBy = record.reportedBy; recordJSON.plannedStartDateTime = record.plannedStartDateTime.ToString(); if (record.plannedImpact_id != null) { recordJSON.plannedImpact = (int)record.plannedImpact_id; } if (record.actualImpact_id != null) { recordJSON.actualImpact = (int)record.actualImpact_id; } var json = new JavaScriptSerializer().Serialize(recordJSON); return(json); }
public static void updateDoc(JSON_Objects.ProblemRecordJSON doc) { ProblemTracker newRecord = convertToDBAO(doc); using (var curDB = new HelpDesk_DB()) { //update old document to historic ProblemTracker oldRecord = ProblemList[doc.index]; var originalDoc = curDB.ProblemTrackers.Find(oldRecord.id); originalDoc.ProblemStatus_id = 1; //historic //Transfer persisting information to new record newRecord.Original_id = oldRecord.Original_id; curDB.SaveChanges(); } using (var curDB = new HelpDesk_DB()) { curDB.ProblemTrackers.Add(newRecord); curDB.SaveChanges(); //update problemtracker list ProblemList = curDB.ProblemTrackers.Where(p => p.ProblemStatus_id == 2).ToList(); } log(); }
public static string getLastProblem() { ProblemTracker record = ProblemList.Last(); string problemJSON = convertSerializedJSON(record); return(problemJSON); }
public static string getProblem(int index) { ProblemTracker record = ProblemList[index]; string problemJSON = convertSerializedJSON(record); return(problemJSON); }
public static void addNewProblem(ProblemTracker record) { using (var curDb = new HelpDesk_DB()) { curDb.ProblemTrackers.Add(record); curDb.SaveChanges(); //rebuild problem list for find references ProblemList = curDb.ProblemTrackers.Where(p => p.ProblemStatus_id == 2).ToList(); } log(); }
public static List <string> refreshProblemTables() { List <string> problemListJSON = new List <string>(); using (var curDB = new HelpDesk_DB()) { List <ProbTrackLog> recentLogList = curDB.ProbTrackLogs.Where(p => p.dateTime >= refreshTimeStamp).ToList(); foreach (ProbTrackLog log in recentLogList) { int problemID = log.Problemtracker_id; ProblemTracker problem = curDB.ProblemTrackers.First(p => p.id == problemID); problemListJSON.Add(convertSerializedJSON(problem)); } } //update refresh time refreshTimeStamp = DateTime.Now; return(problemListJSON); }
public static ProblemTracker convertToDBAO(JSON_Objects.ProblemRecordJSON JSON) { ProblemTracker problemRecord = new ProblemTracker(); problemRecord.affectedService = JSON.affectedService; problemRecord.leadTicket = JSON.leadTicket; if (JSON.startDateTime != "") { problemRecord.startDateTime = DateTime.Parse(JSON.startDateTime); } if (JSON.endDateTime != "") { problemRecord.endDateTime = DateTime.Parse(JSON.endDateTime); } problemRecord.description = JSON.description; problemRecord.ProblemCondition_id = JSON.problemCondition; if (JSON.plannedEndDateTime != "") { problemRecord.plannedEndDateTime = DateTime.Parse(JSON.plannedEndDateTime); } problemRecord.reportedBy = JSON.reportedBy; if (JSON.plannedStartDateTime != "") { problemRecord.plannedStartDateTime = DateTime.Parse(JSON.plannedStartDateTime); } if (JSON.plannedImpact != 0) { problemRecord.plannedImpact_id = JSON.plannedImpact; } if (JSON.actualImpact != 0) { problemRecord.actualImpact_id = JSON.actualImpact; } problemRecord.ProblemStatus_id = 2; return(problemRecord); }
public static void submit(JSON_Objects.ProblemRecordJSON doc) { ProblemTracker problemRecord = convertToDBAO(doc); addNewProblem(problemRecord); }