private string PrepareDataAndPostSession(string sessionId, bool appendData, ref NameValueCollection postParams) { //CacheProcessor.CreateDecryptedImages(sessionId); //List<string> decryptedImagePaths = new List<string>(CacheProcessor.GetDecryptedImagePaths(sessionId)); //if (decryptedImagePaths == null || decryptedImagePaths.Count <= 0) // return string.Empty; CacheProcessor.DecryptData(sessionId); List <string> loadedData = CacheProcessor.LoadData(sessionId); if ((loadedData == null || loadedData.Count <= 0) && !appendData) { CacheProcessor.DeleteSessionFolder(sessionId); return("EMPTY_FOLDER"); } CacheProcessor.CreateDecryptedImages(sessionId); List <string> decryptedImagePaths = new List <string>(CacheProcessor.GetDecryptedImagePaths(sessionId)); if (appendData) { postParams = _ServerApiProvider.AppendPostSessionParams(loadedData, CurrentContext.GetInstance().Session, CurrentContext.GetInstance().LoginData); } else { postParams = _ServerApiProvider.CreatePostSessionParams(loadedData); } string postUrl = _ServerApiProvider.CreatePostSessionUrl(); if (!WebProcessor.CheckInternetConnection()) { ErrorTimer.GetInstance().StartTimer(); return("CONNECTION_FAIL"); } return(WebProcessor.UploadFileWithParams(postUrl, _ServerApiProvider.PrepareFilesData(decryptedImagePaths, "screenshot_files[]", "image/jpeg"), postParams)); /* MOCK */ /*FAKE++; * * if (FAKE == 0) * return WebProcessor.UploadFileWithParams(postUrl, * _ServerApiProvider.PrepareFilesData(decryptedImagePaths), postParams); * else if (FAKE > 0 && FAKE < 3) * return "FAIL"; * else * return WebProcessor.UploadFileWithParams(postUrl, * _ServerApiProvider.PrepareFilesData(decryptedImagePaths), postParams);*/ /* MOCK */ }
public string SendBugReport(string report, bool isCrashReport) { if (!WebProcessor.CheckInternetConnection()) { return("Internet Connection Error"); } string url = SessionController.GetInstance().ServerApiProvider.CreateBugReportUrl(); string email = "*****@*****.**"; if (CurrentContext.GetInstance().LoginData != null && !string.IsNullOrEmpty(CurrentContext.GetInstance().LoginData.Login)) { email = CurrentContext.GetInstance().LoginData.Login; } else { string regEmail = string.Empty; RegistryProcessor.GetFromRegistry(CommonConst.REGISTRY_PATH, CommonConst.EMAIL_VALUE_NAME, ref regEmail, RegistryProcessor.RegistryParts.HKEY_CURRENT_USER); if (!string.IsNullOrEmpty(regEmail)) { email = regEmail; } } string currVersion = "1.00"; if (CurrentContext.GetInstance().VersionData != null) { currVersion = CurrentContext.GetInstance().VersionData.CurrentVersion.ToString(); } string token = CommonConst.BUG_REPORT_TOKEN; string logFile = LogController.GetInstance().IsLogFileExists(); NameValueCollection postParams = new NameValueCollection(); postParams.Add("from", email); postParams.Add("body", report); postParams.Add("tracker_version", currVersion); postParams.Add("token", token); if (isCrashReport) { postParams.Add("crash_report", "1"); } List <string> logFilePath = new List <string>(); logFilePath.Add(logFile); string resp = WebProcessor.UploadFileWithParams(url, SessionController.GetInstance().ServerApiProvider. PrepareFilesData(logFilePath, "activity_log", "text/plain"), postParams); LogController.GetInstance().LogData(LogController. GetInstance().LogFormat.GetNavigationLine("Server reply: " + resp)); return(resp); }