public void ShowEmptyHistory(Activity activity) { activity.RunOnUiThread(() => { var item = new DataObject(string.Empty); var items = new List<DataObject> { item }; Items = items; }); }
public void PostAdditionalInfo(DataObject data) { Status = ServerStatus.Starting; StopPost(); WorkerThread = new CommThread(this, data); WorkerThread.Name = "AddInfoThread"; WorkerThread.PostType = PostType.AdditionalInformation; WorkerThread.Start(); }
public void PostAnalysis(DataObject data) { Status = ServerStatus.Starting; StopPost(); WorkerThread = new CommThread(this, data); WorkerThread.Name = "PostAnalysisThread"; WorkerThread.PostType = PostType.Analysis; WorkerThread.Start(); }
public void LoadData(DataObject dataObject) { Stop(); Status = StorageStatus.Starting; WorkerThread = new StorageThread(this); WorkerThread.Name = "LoadThread"; WorkerThread.InitializeStorageInteraction(StorageRequestType.Load, dataObject); WorkerThread.Start(); }
public bool MergeData(DataObject data) { if (Id == data.Id) { if (!string.IsNullOrEmpty(data.Class)) Class = data.Class; if (!string.IsNullOrEmpty(data.Tags)) Tags = data.Tags; if (!string.IsNullOrEmpty(data.PicturePath)) PicturePath = data.PicturePath; if (!string.IsNullOrEmpty(data.AudioPath)) AudioPath = data.AudioPath; return true; } Log.Error(Tag, "Not able to merge: id is not equal."); return false; }
private void StoreSuccessful(DataObject data) { _dataObjects = new List<DataObject>(); _dataObjects.Add(data); Status = StorageStatus.StoreSuccessful; }
private string CopyPictureToStorage(DataObject data) { if (data.PicturePath == null) { Log.Error(ThreadTag, "cannot copy audio to storage: invalid path"); return null; } if (data.PicturePath == string.Empty) return ""; var newPath = _storagePath + PictureDirPath + data.PictureName; if (!System.IO.File.Exists(data.PicturePath)) { Log.Error(ThreadTag, "Picture file to move does not exist."); return null; } System.IO.File.Move(data.PicturePath, newPath); if (System.IO.File.Exists(newPath)) { System.IO.File.Delete(data.PicturePath); return newPath; } Log.Error(ThreadTag, "Move picture file failed."); return null; }
private string CopyAudioToStorage(DataObject data) { if (string.IsNullOrEmpty(data.AudioPath)) { Log.Error(ThreadTag, "cannot copy audio to storage: invalid path"); return null; } var newPath = _storagePath + AudioDirPath + data.AudioName; if (!System.IO.File.Exists(data.AudioPath)) { Log.Error(ThreadTag, "Audio file to move does not exist."); return null; } if (newPath == data.AudioPath) { return newPath; } System.IO.File.Move(data.AudioPath, newPath); if (System.IO.File.Exists(newPath)) { System.IO.File.Delete(data.AudioPath); return newPath; } Log.Error(ThreadTag, "Move audio file failed."); return null; }
private DataObject CopyToStorage(DataObject dataObject) { var newAudioPath = CopyAudioToStorage(dataObject); if (string.IsNullOrEmpty(newAudioPath)) { Log.Error(ThreadTag, "CopyAudioToStorage failed."); return null; } dataObject.AudioPath = newAudioPath; var newPicturePath = CopyPictureToStorage(dataObject); if (newPicturePath == null) { Log.Error(ThreadTag, "CopyPictureToStorage failed."); return null; } dataObject.PicturePath = newPicturePath; //_service.WriteSuccessful(); return dataObject; }
private void ResolveContextMenuItemAction(int menuItemIndex, DataObject listItem) { switch ((HistoryItemContextMenuItemType) menuItemIndex) { case HistoryItemContextMenuItemType.Edit: ((TabbedActivity) Activity).StartFeedbackActivity(listItem); break; case HistoryItemContextMenuItemType.Delete: ((TabbedActivity) Activity).DeleteData(listItem); break; case HistoryItemContextMenuItemType.DeleteHistory: ((TabbedActivity) Activity).DeleteAllData(); break; default: throw new ArgumentOutOfRangeException(); } }
public void StartFeedbackActivity(DataObject data = null) { if (data != null) CurrentData = data; if (CurrentData == null) { Log.Error(Tag, "Tried to start FeedbackActivity but CurrentData was null"); return; } var feedbackIntent = new Intent(this, typeof(FeedbackActivity)); feedbackIntent.PutExtra("Id", CurrentData.Id); StartActivityForResult(feedbackIntent, (int)ActivityRequestCode.FeedbackActivityFinished); }
public void DeleteData(DataObject data) { StorageService.DeleteData(data); }
private void InitializeDeleteRequest(DataObject data) { if (data == null) { Log.Error(ThreadTag, "Initialization failed: data was null."); return; } _data = data; RequestType = StorageRequestType.Delete; }
public void InitializeStorageInteraction(StorageRequestType requestType, DataObject data = null) { switch (requestType) { case StorageRequestType.Store: InitializeStoreRequest(data); break; case StorageRequestType.LoadAll: InitializeLoadAllRequest(); break; case StorageRequestType.Load: InitializeLoadRequest(data); break; case StorageRequestType.DeleteAll: InitializeDeleteAllRequest(); break; case StorageRequestType.Delete: InitializeDeleteRequest(data); break; case StorageRequestType.None: RequestType = StorageRequestType.None; Log.Debug(ThreadTag, "InitializeStorageInteraction with None called."); break; default: throw new ArgumentOutOfRangeException("requestType"); } }
private void SendingSuccessful(DataObject data) { _resultObject = data; Status = ServerStatus.SendingSuccessful; }
public CommThread(ServerCommService service, DataObject data) { _service = service; _addInfoUri = new Uri(_service.ApplicationContext.Resources.GetString(Resource.String.AddInfoServerAddress)); _analysisUri = new Uri(_service.ApplicationContext.Resources.GetString(Resource.String.AnalysisServerAddress)); _data = data; PostType = PostType.None; }
private void WriteToNewFile() { var dataObject = new DataObject(_data.Id, _data.DeviceInfo); if (!dataObject.MergeData(_data)) { Log.Error(ThreadTag, "WriteToNewFile: merge failed data."); _service.WriteFailed(); RequestStop(); return; } StoreData(dataObject); }
//private DataObject EvaluateDeserializedObject(DataObject dataObject) //{ // if (dataObject != null) return dataObject; // Log.Error(ThreadTag, "Read object from file failed."); // return null; //} private void StoreData(DataObject dataObject) { dataObject = CopyToStorage(dataObject); if (dataObject == null) { Log.Error(ThreadTag, "CopyToStorageFailed."); _service.StoreFailed(); RequestStop(); return; } var writeFlag = WriteToFile(dataObject); if (!writeFlag) { Log.Error(ThreadTag, "WriteToFile failed."); _service.StoreFailed(); RequestStop(); return; } _service.StoreSuccessful(dataObject); RequestStop(); }
private string GenerateNewDataObject() { var idStr = DateTime.UtcNow.ToString(Resources.GetString(Resource.String.DateCulture)); CurrentData = new DataObject(idStr, Build.Model); return CurrentData.Id; }
private bool WriteToFile(DataObject dataObject) { var serializer = new DataContractJsonSerializer(typeof (DataObject)); try { using (var memStream = new MemoryStream()) { serializer.WriteObject(memStream, dataObject); return WriteToFileOutputStream(memStream); } } catch (Exception e) { Log.Error("StorageThread", e.Message + e.StackTrace); _service.WriteFailed(); RequestStop(); return false; } }
private void ExtractExtraContent() { if (Intent == null) { Log.Error(Tag, "Cannot initialize _data, Intent was null"); return; } CurrentData = new DataObject(Intent.GetStringExtra("Id")); }
public ServerCommEventArgs(ServerStatus status, DataObject data = null) { Status = status; Data = data; }