public override bool Action() { bool isSuccess = false; NewItemCount = 0; try { ApplicationConfig appconfig = IOHelper.LoadIsolatedData(); string json = WebTools.Download(string.Format("{0}&{1}={2}", appconfig.GetTaskUrl, SessionName, SessionID)); if (!string.IsNullOrEmpty(json) && IsNewJson(json)) { ItemCollectionBackup.AddRange(itemsList.Select(f => f.ID)); itemsList.Clear(); var jsObj = JsonConvert.DeserializeObject(json) as JObject; if (jsObj != null && jsObj["status"].Value <string>() == "success") { json = jsObj["data"].Value <string>(); jsObj = JsonConvert.DeserializeObject(json) as JObject; if (jsObj["tasks"] != null) { JArray jsArray = (JArray)JsonConvert.DeserializeObject(jsObj["tasks"].ToString()); foreach (var j in jsArray) { if (j["status"].Value <string>() != "done" && j["status"].Value <string>() != "cancel") { TaskItem ti = new TaskItem() { Priority = Convert.Pri(j["pri"].Value <string>()) , ID = j["id"].Value <int>() , Title = Util.EscapeXmlTag(j["name"].Value <string>()) , Deadline = j["deadline"].Value <string>() , Tip = "Task" , Type = Convert.Type(j["type"].Value <string>()) , Status = Convert.Status(j["status"].Value <string>()) , Progress = j["hours"]["progress"].Value <string>() + "%" }; if (!ItemCollectionBackup.Contains(ti.ID)) { NewItemCount = NewItemCount == 0 ? ti.ID : (NewItemCount > 0 ? -2 : NewItemCount - 1); } itemsList.Add(ti); } } if (OnNewItemArrive != null && NewItemCount != 0) { OnNewItemArrive(ItemType.Task, NewItemCount); } } isSuccess = true; ItemCollectionBackup.Clear(); } } } catch (Exception exp) { logger.Error(string.Format("GetTask Error:{0}", exp.ToString())); } return(isSuccess); }
public override bool Action() { bool isSuccess = false; NewItemCount = 0; try { ApplicationConfig appconfig = IOHelper.LoadIsolatedData(); string json = WebTools.Download(string.Format("{0}&{1}={2}", appconfig.GetAllProjectUrl, SessionName, SessionID)); bool isNewJson = IsNewJson(string.Concat(json)); if (!isNewJson) { return(true); } ItemCollectionBackup.AddRange(itemsList.Select(f => f.ID)); itemsList.Clear(); if (!string.IsNullOrEmpty(json)) { var jsObj = JsonConvert.DeserializeObject(json) as JObject; if (jsObj != null && jsObj["status"].Value <string>() == "success") { json = jsObj["data"].Value <string>(); jsObj = JsonConvert.DeserializeObject(json) as JObject; if (jsObj["projectStats"] != null) { JArray jsArray = (JArray)JsonConvert.DeserializeObject(jsObj["projectStats"].ToString()); foreach (var j in jsArray) { //显示未关闭 if (j["status"].Value <string>() != "closed" && j["status"].Value <string>() != "resolved") { ProjectItem pi = new ProjectItem() { Priority = Convert.Pri(j["pri"].Value <string>()) , ID = j["id"].Value <int>() , Title = Util.EscapeXmlTag(j["name"].Value <string>()) , Tip = "Project" , Status = Convert.Status(j["status"].Value <string>()) , Progress = j["hours"]["progress"].Value <string>() + "%" }; if (!ItemCollectionBackup.Contains(pi.ID)) { NewItemCount = NewItemCount == 0 ? pi.ID : (NewItemCount > 0 ? -2 : NewItemCount - 1); } itemsList.Add(pi); } } } isSuccess = true; } } } catch (Exception exp) { logger.Error(string.Format("GetProjectId Error: {0}", exp.ToString())); } return(isSuccess); }