Example #1
0
        /// <summary>
        /// 获取信息
        /// </summary>
        /// <returns></returns>
        private List <TreeNode> QueryNode(SoftVersion softVersion)
        {
            var ds = ManagerPool.Singleton.ExecuteQuery("select * from updatesoft where version='" + softVersion.Version + "'");;
            var dt = ds.Tables[0];

            dt.TableName = "updatesoft";
            return(dt.ToEntityList <TreeNode>());
        }
Example #2
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        private ViewModel LoadData(SoftVersion softVersion)
        {
            var nodes = new List <TreeNode>
            {
                new TreeNode()
                {
                    Name = "soft", ParentID = -1, NodeID = 0
                }
            };

            //
            nodes.AddRange(QueryNode(softVersion));
            //
            return(new ViewModel(CurVersion, nodes));
        }
Example #3
0
        /// <summary>
        /// 开始下载
        /// </summary>
        private void Updown(SoftVersion softVersion)
        {
            DirectoryInfo info = new DirectoryInfo(CureentPath);

            if (!info.Exists)
            {
                info.Create();
            }
            //
            var result = LoadData(softVersion);

            foreach (var node in result.TreeNodes)
            {
                UpdownFile(node);
            }
            if (tasks.Count > 0)
            {
                Task.WaitAll(tasks.ToArray());
                tasks.Clear();
            }
        }
Example #4
0
        /// <summary>
        /// 检测版本
        /// </summary>
        public void Check()
        {
            SoftVersion ver     = null;
            var         lastVer = GetLatest();

            if (lastVer == null || lastVer.Count == 0)
            {
                //没有任何版本信息则移除
                return;
            }
            else
            {
                //本地已经是最新版本就不检测了
                if (CurVersion == lastVer[0].Version && MaxVsersionID == lastVer[0].VersionID)
                {
                    return;
                }
            }
            if (Version == "latest")
            {
                var r = lastVer;
                if (r != null && r.Count > 0)
                {
                    ver = r[0];
                    if (ver.Version == CurVersion && ver.VersionID == MaxVsersionID)
                    {
                        //已经更新过了
                        return;
                    }
                    if (ver.Clear)
                    {
                        Clear();
                    }
                }
            }
            else
            {
                var r = QueryVersion();
                if (r != null && r.Count > 0)
                {
                    ver = r.FindLast(x => x.Version == Version);
                    var max = r.FindAll(x => x.Version.CompareTo(Version) > 0 && x.Clear);
                    if (max != null && max.Count > 0)
                    {
                        CurVersion = "";
                        Clear();
                    }
                }
            }
            if (ver != null)
            {
                //比较,版本不同或者更新了文件,则比较
                if (ver.Version != CurVersion || ver.VersionID != MaxVsersionID)
                {
                    //
                    Updown(ver);
                }
                LastVersion = ver;
            }
            else
            {
                //没有找到该版本了,则清空全部下载最新版本

                var r = lastVer;
                if (r != null && r.Count > 0)
                {
                    ver = r[0];
                }
                if (CurVersion == ver.Version && ver.VersionID == MaxVsersionID)
                {
                    //已经是最新的了
                    return;
                }
                Clear();
                Updown(ver);
                LastVersion = ver;
            }
            //
            ILargerStore store = StoreFactory.GetStore();

            if (store != null)
            {
                while (!store.GetDownloadComplete())
                {
                    Thread.Sleep(1000);
                }
            }
        }