public void Update(WorkUnit workUnit)
 {
     MongoCollection<WorkUnit> coll = _mongoDatabase.GetCollection<WorkUnit>("workunit");
     var query = Query.And(Query.EQ("PartitionKey", workUnit.PartitionKey), Query.EQ("RowKey", workUnit.RowKey));
     var docUpdate = MongoDB.Driver.Builders.Update.Replace<WorkUnit>(workUnit);
     coll.Update(query, docUpdate);
 }
 public void Save(WorkUnit workUnit)
 {
     MongoCollection<WorkUnit> coll = _mongoDatabase.GetCollection<WorkUnit>("workunit");
     coll.Insert(workUnit);
 }
        public void Update(WorkUnit workUnit)
        {
            _tableClient.CreateTableIfNotExist(WORK_UNIT_TABlE_NAME);
            // select info for given workunit

            if (_tableClient.DoesTableExist(WORK_UNIT_TABlE_NAME))
            {
                _dataContext.UpdateObject(workUnit);
                _dataContext.SaveChanges();
            }
        }
 public void Save(WorkUnit workUnit)
 {
     _tableClient.CreateTableIfNotExist(WORK_UNIT_TABlE_NAME);
     // if table exists
     if (_tableClient.DoesTableExist(WORK_UNIT_TABlE_NAME))
     {
         // add client info record
         _dataContext.AddObject(WORK_UNIT_TABlE_NAME, workUnit);
         _dataContext.SaveChanges();
     }
 }
Ejemplo n.º 5
0
        public void UpdateLocalStatus(FoldingClientStatus status)
        {
            WorkUnit workUnit = _clientDataRepo.GetWorkUnit(ApplicationSettings.InstanceId, WorkUnit.MakeKey(status.Name, status.Tag, status.DownloadTime));

            // if it's a new one, add it
            if (workUnit == null)
            {
                workUnit = new WorkUnit(status.Name, status.Tag, status.DownloadTime, ApplicationSettings.InstanceId) { Progress = status.Progress, StartTime = DateTime.UtcNow };
                _clientDataRepo.Save(workUnit);
            }

            // otherwise, update it
            else
            {
                workUnit.Progress = status.Progress;
                if (workUnit.Progress == 100)
                    workUnit.CompleteTime = DateTime.UtcNow;
                _clientDataRepo.Update(workUnit);
            }
        }
Ejemplo n.º 6
0
        public void UpdateLocalStatus(FoldingClientStatus status)
        {
            var cloudStorageAccount =
                CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));

            // ensure workunit table exists
            var cloudClient = new CloudTableClient(
                cloudStorageAccount.TableEndpoint.ToString(),
                cloudStorageAccount.Credentials);
            cloudClient.CreateTableIfNotExist("workunit");

            // select info for given workunit
            var ctx = new ClientDataContext(
                    cloudClient.BaseUri.ToString(),
                    cloudClient.Credentials);
            var workUnit = (from w in ctx.WorkUnits.ToList<WorkUnit>()
                            where w.PartitionKey == RoleEnvironment.CurrentRoleInstance.Id &&
                              w.RowKey == w.MakeKey(status.Name, status.Tag, status.DownloadTime)
                            select w).FirstOrDefault<WorkUnit>();

            // if it's a new one, add it
            if (workUnit == null)
            {
                workUnit = new WorkUnit(status.Name, status.Tag, status.DownloadTime, RoleEnvironment.CurrentRoleInstance.Id) { Progress = status.Progress, StartTime = DateTime.UtcNow };
                ctx.AddObject("workunit", workUnit);
            }

            // otherwise, update it
            else
            {
                workUnit.Progress = status.Progress;
                if (workUnit.Progress == 100)
                    workUnit.CompleteTime = DateTime.UtcNow;
                ctx.UpdateObject(workUnit);
            }
            ctx.SaveChanges();
        }