예제 #1
0
        public override bool Action()
        {
            bool isSuccess = false;

            NewItemCount = 0;

            try
            {
                ApplicationConfig appconfig = IOHelper.LoadIsolatedData();

                string json = WebTools.Download(string.Format("{0}&{1}={2}", appconfig.GetBugUrl, 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["bugs"] != null)
                        {
                            JArray jsArray = (JArray)JsonConvert.DeserializeObject(jsObj["bugs"].ToString());

                            foreach (var j in jsArray)
                            {
                                BugItem bi = new BugItem()
                                {
                                    priority = j["pri"].Value <string>()
                                    ,
                                    Severity = j["severity"].Value <string>()
                                    ,
                                    ID = j["id"].Value <int>()
                                    ,
                                    Title = Util.EscapeXmlTag(j["title"].Value <string>())
                                    ,
                                    OpenDate = j["openedDate"].Value <string>()
                                    ,
                                    LastEdit = j["lastEditedDate"].Value <string>()
                                    ,
                                    Tip = "Bug"
                                };

                                if (!ItemCollectionBackup.Contains(bi.ID))
                                {
                                    NewItemCount = NewItemCount == 0 ? bi.ID : (NewItemCount > 0 ? -2 : NewItemCount - 1);
                                }

                                itemsList.Add(bi);
                            }

                            if (OnNewItemArrive != null &&
                                NewItemCount != 0)
                            {
                                OnNewItemArrive(ItemType.Bug, NewItemCount);
                            }
                        }

                        isSuccess = true;

                        ItemCollectionBackup.Clear();
                    }
                }
            }
            catch (Exception exp)
            {
                logger.Error(string.Format("GetBug Error: {0}", exp.ToString()));
            }

            return(isSuccess);
        }
예제 #2
0
        public override bool Action()
        {
            bool isSuccess = false;

            NewItemCount = 0;

            try
            {
                ApplicationConfig appconfig = IOHelper.LoadIsolatedData();

                string json      = WebTools.Download(string.Format("{0}&{1}={2}", appconfig.GetAllToDoUrl, 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["todos"] != null)
                        {
                            JArray jsArray = (JArray)JsonConvert.DeserializeObject(jsObj["todos"].ToString());

                            foreach (var j in jsArray)
                            {
                                //显示未关闭
                                if (j["status"].Value <string>() != "closed" && j["status"].Value <string>() != "done")
                                {
                                    ToDoItem ti = new ToDoItem()
                                    {
                                        Priority = Convert.Pri(j["pri"].Value <string>())
                                        ,
                                        ID = j["id"].Value <int>()
                                        ,
                                        Title = Util.EscapeXmlTag(j["name"].Value <string>())
                                        ,
                                        Tip = "Project"
                                        ,
                                        Type = Convert.Status(j["type"].Value <string>())
                                        ,
                                        Status = Convert.Status(j["status"].Value <string>())
                                    };

                                    if (!ItemCollectionBackup.Contains(ti.ID))
                                    {
                                        NewItemCount = NewItemCount == 0 ? ti.ID : (NewItemCount > 0 ? -2 : NewItemCount - 1);
                                    }

                                    itemsList.Add(ti);
                                }
                            }
                        }
                        isSuccess = true;
                    }
                }
            }
            catch (Exception exp)
            {
                logger.Error(string.Format("GetProjectId Error: {0}", exp.ToString()));
            }

            return(isSuccess);
        }
예제 #3
0
        public override bool Action()
        {
            bool isSuccess = false;

            NewItemCount = 0;

            List <int> productIds = GetProductId();
            //string[] jsonList = new string[productIds.Count];
            List <string> jsonList = new List <string>();


            try
            {
                ApplicationConfig appconfig = IOHelper.LoadIsolatedData();

                //for (int i = 0; i < productIds.Count; i++)
                //{
                List <int> projectIds = GetProjectId();
                //string[] projectList = new string[productIds.Count];

                for (int j = 0; j < projectIds.Count; j++)
                {
                    string json = string.Format(appconfig.GetUnclosedTaskUrl, projectIds[j]);
                    json = WebTools.Download(string.Format("{0}&{1}={2}", json, SessionName, SessionID));

                    jsonList.Add(json);
                }
                //}

                bool isNewJson = IsNewJson(string.Concat(jsonList));

                if (!isNewJson)
                {
                    return(true);
                }

                ItemCollectionBackup.AddRange(itemsList.Select(f => f.ID));
                itemsList.Clear();

                foreach (string strjson in jsonList)
                {
                    string json = strjson;

                    if (!string.IsNullOrEmpty(json) && isNewJson)
                    {
                        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)
                            {
                                json = jsObj["tasks"].ToString();
                                if (json == "[]")
                                {
                                    continue;
                                }

                                jsObj = JsonConvert.DeserializeObject(json) as JObject;

                                JToken record = jsObj as JToken;
                                foreach (JProperty jp in record)
                                {
                                    var taskp = jp.First;
                                    if (taskp["status"].Value <string>() != "cancel")
                                    {
                                        TaskItem ti = new TaskItem()
                                        {
                                            Priority = Convert.Pri(taskp["pri"].Value <string>())
                                            ,
                                            ID = taskp["id"].Value <int>()
                                            ,
                                            Title = Util.EscapeXmlTag(taskp["name"].Value <string>())
                                            ,
                                            Deadline = taskp["deadline"].Value <string>()
                                            ,
                                            Tip = "Task"
                                            ,
                                            Type = Convert.Type(taskp["type"].Value <string>())
                                            ,
                                            Status = Convert.Status(taskp["status"].Value <string>())
                                            ,
                                            Progress = taskp["progress"].Value <string>() + "%"
                                        };

                                        if (!ItemCollectionBackup.Contains(ti.ID))
                                        {
                                            NewItemCount = NewItemCount == 0 ? ti.ID : (NewItemCount > 0 ? -2 : NewItemCount - 1);
                                        }

                                        itemsList.Add(ti);
                                    }
                                }
                            }
                            isSuccess = true;
                        }
                    }
                }
                if (OnNewItemArrive != null && NewItemCount != 0)
                {
                    OnNewItemArrive(ItemType.Task, NewItemCount);
                }
                ItemCollectionBackup.Clear();
            }
            catch (Exception exp)
            {
                logger.Error(string.Format("GetUnclosedTask Error:{0}", exp.ToString()));
            }

            return(isSuccess);
        }
예제 #4
0
        public override bool Action()
        {
            bool isSuccess = false;

            NewItemCount = 0;

            List <int> productIds = GetProductId();

            string[] jsonList = new string[productIds.Count];

            try
            {
                ApplicationConfig appconfig = IOHelper.LoadIsolatedData();

                for (int i = 0; i < productIds.Count; i++)
                {
                    string json = string.Format(appconfig.GetUnclosedBugUrl, productIds[i]);
                    json = WebTools.Download(string.Format("{0}&{1}={2}", json, SessionName, SessionID));

                    jsonList[i] = json;
                }

                bool isNewJson = IsNewJson(string.Concat(jsonList));

                if (!isNewJson)
                {
                    return(true);
                }

                ItemCollectionBackup.AddRange(itemsList.Select(f => f.ID));
                itemsList.Clear();

                foreach (string strjson in jsonList)
                {
                    string json = strjson;

                    if (!string.IsNullOrEmpty(json) && isNewJson)
                    {
                        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["bugs"] != null)
                            {
                                JArray jsArray = (JArray)JsonConvert.DeserializeObject(jsObj["bugs"].ToString());

                                foreach (var j in jsArray)
                                {
                                    //unclosedBug 显示未关闭
                                    if (j["status"].Value <string>() != "closed")//&& j["status"].Value<string>() != "resolved"
                                    {
                                        BugItem bi = new BugItem()
                                        {
                                            Priority = Convert.Pri(j["pri"].Value <string>())
                                            ,
                                            Severity = Convert.Severity(j["severity"].Value <string>())
                                            ,
                                            ID = j["id"].Value <int>()
                                            ,
                                            Title = Util.EscapeXmlTag(j["title"].Value <string>())
                                            ,
                                            OpenDate = j["openedDate"].Value <string>()
                                            ,
                                            LastEdit = j["lastEditedDate"].Value <string>()
                                            ,
                                            Tip = "未关闭的Bug"
                                            ,
                                            Confirmed = Convert.Confirmed(j["confirmed"].Value <string>())
                                            ,
                                            Resolution = Convert.Resolution(j["resolution"].Value <string>())
                                        };

                                        if (!ItemCollectionBackup.Contains(bi.ID))
                                        {
                                            NewItemCount = NewItemCount == 0 ? bi.ID : (NewItemCount > 0 ? -2 : NewItemCount - 1);
                                        }

                                        itemsList.Add(bi);
                                    }
                                }
                            }

                            isSuccess = true;
                        }
                    }
                }

                if (OnNewItemArrive != null &&
                    NewItemCount != 0)
                {
                    OnNewItemArrive(ItemType.Bug, NewItemCount);
                }

                ItemCollectionBackup.Clear();
            }
            catch (Exception exp)
            {
                logger.Error(string.Format("GetUnclosedBug Error: {0}", exp.ToString()));
            }

            return(isSuccess);
        }
예제 #5
0
        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);
        }