public void SaveOrUpdateProcess(RunningProcess process)
 {
     var processFromStorage = (ProcessTableEntity)processesTable.Execute(TableOperation.Retrieve<ProcessTableEntity>(process.Name, process.Started.Date.ToString(ProcessTableEntity.RowKeyDateFormat))).Result;
     if (processFromStorage == null)
         SaveNewProcess(process);
     else
         UpdateExistingProcess(processFromStorage, process);
 }
        public void SaveNewProcess(RunningProcess p)
        {
            var processToInsert = new ProcessTableEntity
            {
                PartitionKey = p.Name,
                RowKey = p.Started.Date.ToString(ProcessTableEntity.RowKeyDateFormat)
            };

            try
            {
                processToInsert.AddRunTimes(p.Started, p.Stopped);
                processesTable.Execute(TableOperation.Insert(processToInsert));
            }
            catch (Exception e)
            {
                logger.Error(e);
            }
        }
 private void UpdateExistingProcess(ProcessTableEntity processFromStorage, RunningProcess p)
 {
     try
     {
         processFromStorage.AddRunTimes(p.Started, p.Stopped);
         processesTable.Execute(TableOperation.Replace(processFromStorage));
     }
     catch (Exception e)
     {
         logger.Error(e);
     }
 }
 private void SaveProcessAndRemoveFromStaticList(RunningProcess p)
 {
     p.Stopped = DateTime.Now;
     Program.Processes.Remove(p);
     storage.SaveOrUpdateProcess(p);
 }