예제 #1
0
        /// <summary>
        /// 下载单个文件
        /// </summary>
        /// <param name="item"></param>
        private void WriteFile(FileInfos item)
        {
            if (item == null)
            {
                CurView.ShowMessage("没有需要更新的文件");
                return;
            }

            ServiceRequest request = new  ServiceRequest();

            request.ServiceName = "FileUpdate";
            request.MethodName  = "CurReadFile";
            request.Parameters  = new object[] { item.FilePath };
            base.ServiceProxy.RequestService <byte[]>(request, DataType.Binary, (message) =>
            {
                byte[] curbyte = message;
                //本地临时临时文件夹,用于存储文件
                WorkPath = Path.Combine(TempFolder, item.FilePath);
                CurWriteFile(curbyte, WorkPath);

                DateTime date;
                if (DateTime.TryParseExact(item.FileModifyTime, "yyyy-MM-dd HH:mm:ss", new System.Globalization.CultureInfo("zh-CN"), System.Globalization.DateTimeStyles.None, out date))
                {
                    System.IO.File.SetLastWriteTime(WorkPath, date);
                }

                //循环下载文件
                FileInfos curInfos = GetfilePath();
                if (curInfos != null)
                {
                    WriteFile(curInfos);
                }
                else
                {
                    //用于标注下载完成
                    if (IsMustRestart)
                    {
                        CurView.ShowMessage("_S200File_Completed");
                    }
                    else
                    {
                        CurView.ShowMessage("_S200File_Completed_Hidden");
                    }
                }
            });
        }
예제 #2
0
        public void GetFiles(IAuctionMainFormView view, bool isNotify, string path)
        {
            this.CurView        = view;
            this.IsNotifyNoFile = isNotify;
            ServiceRequest request = new  ServiceRequest();

            request.ServiceName = "FileUpdate";
            request.MethodName  = "CurGetAllFiles";
            request.Parameters  = new object[] { };
            base.ServiceProxy.RequestService <List <FileInfos> >(request, DataType.Json, (message) =>
            {
                #region 每次重新查询文件目录的时候清空CurListInfos

                if (CurListInfos != null)
                {
                    CurListInfos.Clear();
                }

                #endregion

                List <FileInfos> curInfos = message;
                foreach (var item in curInfos)
                {
                    CurSearchFiles(item.FilePath, item.FileModifyTime, path);
                }

                //对比本地文件得出需要更新的列表
                List <FileInfos> localFile = CurListInfos;

                _index = 0;
                if (localFile != null)
                {
                    IsMustRestart = CurListInfos.Exists(o => o.FilePath.ToLower().EndsWith(".dll") || o.FilePath.ToLower().EndsWith(".exe"));
                    DowlaodFile();
                }
                else
                {
                    if (isNotify)
                    {
                        CurView.ShowMessage("没有需要更新的文件");
                    }
                }
            });
        }