Example #1
0
        /// <summary>
        /// 判断是不是有更新,并返回最新的版本号
        /// </summary>
        /// <param name="latestVersion"></param>
        /// <returns></returns>
        public static bool GetLatestVersionNumber(out string latestVersion)
        {
            bool isUpdate = false;

            latestVersion = null;

            string content = WebTools.Download("http://zugger.codeplex.com");

            if (!string.IsNullOrEmpty(content))
            {
                Match match = VersionReg.Match(content);

                if (match.Success)
                {
                    latestVersion = match.Groups["key"].Value;

                    Version version       = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                    string  currentVerson = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);

                    if (latestVersion != currentVerson)
                    {
                        isUpdate = true;
                    }
                }
            }

            return(isUpdate);
        }
Example #2
0
        private List <int> GetProjectId()
        {
            List <int> projectIds = new List <int>();

            try
            {
                ApplicationConfig appconfig = IOHelper.LoadIsolatedData();

                //string json = string.Format(appconfig.GetProjectUrl, productId);

                string json = WebTools.Download(string.Format("{0}&{1}={2}", appconfig.GetAllProjectUrl, SessionName, SessionID));

                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")
                                {
                                    projectIds.Add(j["id"].Value <int>());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                logger.Error(string.Format("GetProjectId Error: {0}", exp.ToString()));
            }

            return(projectIds);
        }
Example #3
0
        private List <int> GetProductId()
        {
            List <int> productIds = new List <int>();

            try
            {
                ApplicationConfig appconfig = IOHelper.LoadIsolatedData();

                string json = WebTools.Download(string.Format("{0}&{1}={2}", appconfig.GetProductUrl, SessionName, SessionID));

                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["products"] != null)
                        {
                            jsObj = JsonConvert.DeserializeObject(jsObj["products"].ToString()) as JObject;
                            JProperty jp = jsObj.First as JProperty;

                            while (jp != null)
                            {
                                productIds.Add(System.Convert.ToInt32(jp.Name));
                                jp = jp.Next as JProperty;
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                logger.Error(string.Format("GetProductId Error: {0}", exp.ToString()));
            }

            return(productIds);
        }
Example #4
0
        private bool CheckRequesetType()
        {
            bool result = false;

            //ApplicationConfig config = IOHelper.LoadIsolatedData();

            string configUrl = appconfig.GetPMSConfigUrl;

            //string configUrl = config.BuildPMSConfigUrl(txtPMSUrl.Text.Trim());

            try
            {
                string json = WebTools.Download(configUrl);
                if (json != null && json.IndexOf("requestType") != -1)
                {
                    var jsObj = JsonConvert.DeserializeObject(json) as JObject;

                    if (jsObj != null && jsObj["requestType"].Value <string>().ToUpper() == "GET")
                    {
                        appconfig.IsPATH_INFORequest = false;
                        result = true;
                    }
                    else if (jsObj != null && jsObj["requestType"].Value <string>().ToUpper() == "PATH_INFO")
                    {
                        appconfig.IsPATH_INFORequest = true;
                        result = true;
                    }
                }
                else
                {
                    lbConnStatus.Content = "无法获得PMS请求类型";
                }
            }
            catch (Exception exp)
            {
                logger.Error(string.Format("GetPMSConfig Error:{0}", exp.ToString()));
                lbConnStatus.Content = "PMS地址错误";
            }

            return(result);
        }
Example #5
0
        //private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public static bool GetSession(string loginurl, ref string sessionname, ref string sessionid, ref string randomnum)
        {
            bool isSuccess = false;

            try
            {
                //请求得到session
                string content = WebTools.Download(loginurl);

                if (!string.IsNullOrEmpty(content))
                {
                    var jsObj = JsonConvert.DeserializeObject(content) as JObject;

                    if (jsObj != null && jsObj["status"].Value <string>() == "success")
                    {
                        content = jsObj["data"].Value <string>();

                        jsObj = JsonConvert.DeserializeObject(content) as JObject;

                        if (jsObj.ToString().IndexOf("sessionID") != -1)
                        {
                            //得到session,赋值
                            sessionname = jsObj["sessionName"].Value <string>();
                            sessionid   = jsObj["sessionID"].Value <string>();
                            randomnum   = jsObj["rand"].Value <string>();

                            isSuccess = true;
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                //logger.Error(string.Format("GetSession Error: {0}", exp.ToString()));
            }

            return(isSuccess);
        }
Example #6
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);
        }
Example #7
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);
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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);
        }