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 void StopSession(bool unsubscribe) { Context.Timer.Timer.GetInstance().StopTimer(); ErrorTimer.GetInstance().StopTimer(); if (unsubscribe) { ActivityProcessor.GetInstance().UnsubscribeFromMouseKeyEvents(); } int delta = TimingHelper.CalcTimestampDelta(CurrentContext .GetInstance().Session.StartTimestamp, TimingHelper.GetCurrentTimestamp()); //if (delta < CommonConst.DELAY) // return; CurrentContext.GetInstance().Session.PostTime = delta; CurrentContext.GetInstance().Session.StopTime = delta; ThreadPool.QueueUserWorkItem(new WaitCallback((s) => { /*LogController.GetInstance().LogData(LogController. * GetInstance().LogFormat.GetSessionLine("StopSession() -- mode 1: IsSessionDataLocked: " + * CurrentContext.GetInstance().IsSessionDataLocked.ToString()));*/ //while (CurrentContext.GetInstance().IsSessionDataLocked) // Thread.Sleep(1000); /*LogController.GetInstance().LogData(LogController. * GetInstance().LogFormat.GetSessionLine("StopSession() -- mode 2: IsSessionDataLocked: " + * CurrentContext.GetInstance().IsSessionDataLocked.ToString()));*/ //CurrentContext.GetInstance().IsSessionDataLocked = true; CacheStrategyExecutor.GetInstance().CacheStrategy.PostCurrentSession(CurrentContext .GetInstance().Session.StartTimestamp.ToString()); CacheStrategyExecutor.GetInstance().CacheStrategy.PostOldSessions(CurrentContext .GetInstance().Session.StartTimestamp.ToString()); // CurrentContext.GetInstance().IsSessionDataLocked = false; /*LogController.GetInstance().LogData(LogController. * GetInstance().LogFormat.GetSessionLine("StopSession() -- mode 3: IsSessionDataLocked: " + * CurrentContext.GetInstance().IsSessionDataLocked.ToString()));*/ _NotificationHandler.SessionStopped(); })); }
private SessionController() { _ServerApiProvider = ServerApiFactory.CreateServerApiProvider(); ErrorTimer.GetInstance().InitTimer(this); }
public string GetErrorTimerInterval() { return(ErrorTimer.GetInstance().GetCurrentInterval().ToString()); }