private static void GetLogFile() { do { success = true; C.Write("Please Enter Username :\t"); string userEmail = C.Read(); stopwatch.Restart(); ApiData <List <Log_Data> > logData = C.CallService <ApiData <List <Log_Data> >, string>(Method.GET, Url.GetLog, true, "email".PairedWith(userEmail)).Result; stopwatch.Stop(); C.LogExecutionTime("GetLogFile: Download File", stopwatch); if (logData.Status) { success = true; stopwatch.Restart(); C.Save_ApiLogData(logData.Data); stopwatch.Stop(); C.LogExecutionTime("GetLogFile: Save File", stopwatch); C.Log(); C.Log("========================================================"); C.Log("Log Saved Successfully"); C.Log("========================================================"); C.Log("========================================================"); } else { success = false; C.Log("========================================================"); C.Log(logData.Message); C.Log("========================================================"); C.Read(); } } while (!success); }
private static void UpdateFile() { do { success = true; C.Write("Enter log file Path:\t"); string fileName = C.Read(); StreamReader re = File.OpenText(fileName); string fileData = re.ReadToEndAsync().Result; if (fileData.Substring(fileData.IndexOf("}") + 1, 1) != ",") { fileData = "[" + fileData.Replace("}", "},") + "]"; } List <Log_Data> data = JsonConvert.DeserializeObject <List <Log_Data> >(fileData); C.Log("Saving Log to Logging Server"); List <Log_Data> eData = new List <Log_Data>(); stopwatch.Restart(); foreach (var item in data) { var d = item.EncryptData(Encryption.PublicKey); d.LogData_Id = Encryption.DecryptText(d.LogData_Id, Encryption.PublicKey); eData.Add(d); } stopwatch.Stop(); C.LogExecutionTime("UpdateFile: Encrypt File", stopwatch); stopwatch.Restart(); bool saveData = C.CallService <bool, List <Log_Data> >(Method.POST, Url.UpdateLog, eData, HttpHeaders.Json, true).Result; stopwatch.Stop(); C.LogExecutionTime("UpdateFile: Upload File", stopwatch); if (saveData) { success = true; C.Log(); C.Log("========================================================"); C.Log("Log Uploaded Successfully"); C.Log("========================================================"); C.Log("========================================================"); } else { success = false; C.Log("========================================================"); C.Log("Error: Please try again."); C.Log("========================================================"); C.Read(); } } while (!success); }