示例#1
0
 public static BusinessObject <ConfigDTO> Save(ConfigDTO dto)
 {
     try
     {
         var lst = LoadList();
         if (lst == null)
         {
             lst = new List <ConfigDTO>();
         }
         var dtoAux = lst.Where(t => t.UserName == Environment.UserName).FirstOrDefault();
         if (dtoAux == null)
         {
             lst.Add(dto);
         }
         else
         {
             dtoAux.TfsUrl      = dto.TfsUrl;
             dtoAux.VersionPath = dto.VersionPath;
             dtoAux.UpdateCicle = dto.UpdateCicle;
             dtoAux.Language    = dto.Language;
         }
         using (var sw = File.CreateText(configJsonPath))
         {
             sw.Write(JsonConvert.SerializeObject(lst));
             sw.Close();
         }
         return(dto.EntityToBusinessObject());
     }
     catch (Exception ex)
     {
         return(ConstructError <ConfigDTO> .Set(ex));
     }
 }
示例#2
0
 public static BusinessObject <ConfigDTO> Load()
 {
     try
     {
         if (!File.Exists(configJsonPath))
         {
             return(null);
         }
         var lst = LoadList();
         if (lst == null || lst.Count() == 0)
         {
             return(null);
         }
         var dto = lst.Where(t => t.UserName == Environment.UserName).FirstOrDefault();
         if (dto == null)
         {
             dto = lst.FirstOrDefault();
         }
         return(dto.EntityToBusinessObject());
     }
     catch (Exception ex)
     {
         return(ConstructError <ConfigDTO> .Set(ex));
     }
 }
示例#3
0
 public BusinessObject <WorkItemDTO> GetValidInProgress()
 {
     try
     {
         if (string.IsNullOrEmpty(TfsUrl))
         {
             throw new Exception("Tfs not defined.");
         }
         return(processQuery(queryValidInProgress).ToBusinessObject());
     }
     catch (Exception ex)
     {
         return(ConstructError <WorkItemDTO> .Set(ex));
     }
 }
示例#4
0
 public BusinessObject <WorkItemDTO> Play(WorkItemDTO wkPlayed, WorkItemDTO old = null)
 {
     try
     {
         if (string.IsNullOrEmpty(TfsUrl))
         {
             throw new Exception("Tfs not defined.");
         }
         if (old != null)
         {
             old.Blocked = "Yes";
             JsonPatchDocument j = new JsonPatchDocument();
             j.Add(new JsonPatchOperation
             {
                 Operation = Operation.Add,
                 Path      = "/fields/Microsoft.VSTS.CMMI.Blocked",
                 Value     = "Yes"
             });
             UpdateWorkItem(old.Id, j);
         }
         JsonPatchDocument jnew = new JsonPatchDocument();
         jnew.Add(new JsonPatchOperation
         {
             Operation = Operation.Add,
             Path      = "/fields/Microsoft.VSTS.CMMI.Blocked",
             Value     = ""
         });
         jnew.Add(new JsonPatchOperation
         {
             Operation = Operation.Add,
             Path      = "/fields/System.State",
             Value     = "In Progress"
         });
         return(new WorkItemDTO(UpdateWorkItem(wkPlayed.Id, jnew)).EntityToBusinessObject());
     }
     catch (Exception ex)
     {
         return(ConstructError <WorkItemDTO> .Set(ex));
     }
 }
示例#5
0
 public BusinessObject <WorkItemDTO> GetToDoInProgress()
 {
     try
     {
         if (string.IsNullOrEmpty(TfsUrl))
         {
             throw new Exception("Tfs not defined.");
         }
         string             cacheName = "_GetToDoInProgress";
         List <WorkItemDTO> lstWork   = CacheUtil.RecuperarCacheObjSemReferencia <List <WorkItemDTO> >(cacheName);
         if (lstWork != null)
         {
             return(lstWork.ToBusinessObject());
         }
         lstWork = processQuery(queryInProgressTodo);
         return(lstWork.ToBusinessObject());
     }
     catch (Exception ex)
     {
         return(ConstructError <WorkItemDTO> .Set(ex));
     }
 }
示例#6
0
 public BusinessObject <WorkItemDTO> UpdateWorked(WorkItemDTO wik)
 {
     try
     {
         if (string.IsNullOrEmpty(TfsUrl))
         {
             throw new Exception("Tfs not defined.");
         }
         JsonPatchDocument j = new JsonPatchDocument();
         j.Add(new JsonPatchOperation
         {
             Operation = Operation.Add,
             Path      = "/fields/Microsoft.VSTS.Scheduling.CompletedWork",
             Value     = processDouble(wik.CompletedWork)
         });
         j.Add(new JsonPatchOperation
         {
             Operation = wik.RemainingWork == 0 ? Operation.Add : Operation.Replace,
             Path      = "/fields/Microsoft.VSTS.Scheduling.RemainingWork",
             Value     = processDouble(wik.RemainingCalc)
         });
         if (wik.OriginalEstimate == 0)
         {
             j.Add(new JsonPatchOperation
             {
                 Operation = Operation.Add,
                 Path      = "/fields/Microsoft.VSTS.Scheduling.OriginalEstimate",
                 Value     = processDouble(wik.RemainingWork)
             });
         }
         var ret = UpdateWorkItem(wik.Id, j);
         return(new WorkItemDTO(ret).EntityToBusinessObject());
     }
     catch (Exception ex)
     {
         return(ConstructError <WorkItemDTO> .Set(ex));
     }
 }