public void UpdateResourceState(int resourceId, int stateId)
 {
     if (resourceId == 0) return;
     using (var w = WorkspaceFactory.Create())
     {
         var csid = w.Last<ResourceStateValue>(x => x.ResoruceId == resourceId);
         if (csid == null || csid.StateId != stateId)
         {
             var v = new ResourceStateValue { ResoruceId = resourceId, Date = DateTime.Now, StateId = stateId };
             w.Add(v);
             w.CommitChanges();
         }
     }
 }
Exemple #2
0
 public void UpdateResourceState(int resourceId, string stateName, string state)
 {
     if (resourceId == 0) return;
     using (var w = WorkspaceFactory.Create())
     {
         var stateValue = w.Single<ResourceStateValue>(x => x.ResoruceId == resourceId);
         if (stateValue == null)
         {
             stateValue = new ResourceStateValue { ResoruceId = resourceId };
             w.Add(stateValue);
         }
         stateValue.SetStateValue(stateName, state);
         w.CommitChanges();
     }
 }