Ejemplo n.º 1
0
        public DownFileResult DownLoadFile(DownFile downfile)
        {
            DownFileResult result = new DownFileResult();

            string path = savePath + @"\" + downfile.FileName;

            if (!File.Exists(path))
            {
                result.IsSuccess  = false;
                result.FileSize   = 0;
                result.Message    = "服务器不存在此文件";
                result.FileStream = new MemoryStream();
                return(result);
            }
            Stream     ms = new MemoryStream();
            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            fs.CopyTo(ms);
            ms.Position       = 0; //重要,不为0的话,客户端读取有问题
            result.IsSuccess  = true;
            result.FileSize   = ms.Length;
            result.FileStream = ms;

            fs.Flush();
            fs.Close();

            //打印日志
            _msgContent = string.Format("接收文件完毕 name={0},filesize={1}", downfile.FileName, result.FileSize);
            _info.InitLogMsg(_msgContent);
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 下载文件,有进度显示
        /// </summary>
        /// <param name="filename">下载文件名</param>
        /// <param name="action">进度0-100</param>
        /// <returns>下载成功后返回存储在本地文件路径</returns>

        public string DownLoadFile(string filename, Action <int> action)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new Exception("文件名不为空!");
            }

            //string filebufferpath = AppRootPath + @"filebuffer\";
            if (!Directory.Exists(filebufferpath))
            {
                Directory.CreateDirectory(filebufferpath);
            }
            string filepath = filebufferpath + filename;

            if (File.Exists(filepath))
            {
                File.Delete(filepath);
            }

            DownFile df = new DownFile();

            df.clientId = clientObj == null ? "" : clientObj.ClientID;
            df.DownKey  = Guid.NewGuid().ToString();
            df.FileName = filename;
            df.FileType = 0;

            FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write);

            DownLoadFile(df, fs, action);
            return(filepath);
        }
Ejemplo n.º 3
0
        void fileSend(Object packet)
        {
            DownFile df = (DownFile)packet;
            // 파일 스트림 생성
            FileStream   file = new FileStream(df.ServerPath, FileMode.Open);
            BinaryReader br   = new BinaryReader(file);

            try
            {
                //파일 size만큼 버퍼를 만들어 복사 후 전송
                byte[] bytesFile = new byte[df.size];
                bytesFile = br.ReadBytes((int)bytesFile.Length);
                m_Stream.Write(bytesFile, 0, bytesFile.Length);
                m_Stream.Flush();
            }
            catch (Exception ex)
            {
                Message("파일전송실패 : " + ex.Message);
                return;
            }
            finally
            {
                file.Close();
                br.Close();
            }
            Message("파일전송성공");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 下载文件,从升级包中
        /// </summary>
        /// <param name="filedata"></param>
        /// <param name="ms"></param>
        /// <returns></returns>
        private static DownFileResult DownLoadUpgrade(DownFile filedata, ref MemoryStream ms)
        {
            DownFileResult result = new DownFileResult();

            if (ms == null)
            {
                ms = new MemoryStream();
            }

            string path = clientupgradepath + filedata.FileName;

            if (!File.Exists(path))
            {
                result.IsSuccess  = false;
                result.FileSize   = 0;
                result.Message    = "服务器不存在此文件";
                result.FileStream = ms;
                return(result);
            }

            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            fs.CopyTo(ms);

            ms.Position       = 0; //重要,不为0的话,客户端读取有问题
            result.IsSuccess  = true;
            result.FileSize   = ms.Length;
            result.FileStream = ms;
            fs.Flush();
            fs.Close();

            return(result);
        }
Ejemplo n.º 5
0
 public DownFileResult RootDownLoadFile(DownFile downfile)
 {
     if (fileServiceClient == null)
     {
         throw new Exception("还没有创建连接!");
     }
     return(fileServiceClient.RootDownLoadFile(downfile));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="filedata"></param>
        /// <returns></returns>
        public static DownFileResult DownLoadFile(DownFile filedata)
        {
            try
            {
                if (WcfGlobal.IsDebug)
                {
                    ShowHostMsg(Color.Black, DateTime.Now, "客户端[" + filedata.clientId + "]准备下载文件...");
                }

                MemoryStream ms = new MemoryStream();

                DownFileResult result = new DownFileResult();

                if (filedata.FileType == 0)//0:filebuffer目录  1:Upgrade升级包 2:Mongodb
                {
                    result = DownLoadfilebuffer(filedata, ref ms);
                }
                else if (filedata.FileType == 1)
                {
                    result = DownLoadUpgrade(filedata, ref ms);
                }
                else if (filedata.FileType == 2)
                {
                    result = DownLoadMongodb(filedata, ref ms);
                }
                else
                {
                    result = DownLoadfilebuffer(filedata, ref ms);
                }

                if (WcfGlobal.IsDebug)
                {
                    //获取进度
                    getupdownprogress(ms, result.FileSize, (delegate(int _num)
                    {
                        ShowHostMsg(Color.Black, DateTime.Now, "客户端[" + filedata.clientId + "]下载文件进度:%" + _num);
                    }));
                }


                if (WcfGlobal.IsDebug)
                {
                    ShowHostMsg(Color.Green, DateTime.Now, "客户端[" + filedata.clientId + "]下载文件完成");
                }

                //ms.Close();
                return(result);
            }
            catch (Exception err)
            {
                //记录错误日志
                EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy");

                DownFileResult result = new DownFileResult();
                result.IsSuccess = false;
                return(result);
            }
        }
        //下载文件
        public DownFileResult DownLoadFile(DownFile filedata)
        {
            FileStream fs = null;

            try
            {
                if (WcfServerManage.IsDebug)
                {
                    ShowHostMsg(Color.Black, DateTime.Now, "客户端[" + filedata.clientId + "]准备下载文件...");
                }

                DownFileResult result = new DownFileResult();

                string path = filebufferpath + filedata.FileName;

                if (!File.Exists(path))
                {
                    result.IsSuccess  = false;
                    result.FileSize   = 0;
                    result.Message    = "服务器不存在此文件";
                    result.FileStream = new MemoryStream();
                    return(result);
                }
                Stream ms = new MemoryStream();
                fs = new FileStream(path, FileMode.Open, FileAccess.Read);
                fs.CopyTo(ms);
                ms.Position       = 0; //重要,不为0的话,客户端读取有问题
                result.IsSuccess  = true;
                result.FileSize   = ms.Length;
                result.FileStream = ms;

                fs.Flush();
                fs.Close();

                if (WcfServerManage.IsDebug)
                {
                    ShowHostMsg(Color.Green, DateTime.Now, "客户端[" + filedata.clientId + "]下载文件完成");
                }

                return(result);
            }
            catch (Exception err)
            {
                if (fs != null)
                {
                    fs.Flush();
                    fs.Close();
                }
                //记录错误日志
                EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy");

                DownFileResult result = new DownFileResult();
                result.IsSuccess = false;
                return(result);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 下载文件,从Mongodb数据库中
        /// </summary>
        /// <param name="filedata"></param>
        /// <param name="ms"></param>
        /// <returns></returns>
        private static DownFileResult DownLoadMongodb(DownFile filedata, ref MemoryStream ms)
        {
            DownFileResult result = new DownFileResult();

            if (ms == null)
            {
                ms = new MemoryStream();
            }

            return(result);
        }
        public void ChangeStatus(DownFile DownFile, string InfoList, string Clomn, string Value)
        {
            if (string.IsNullOrEmpty(InfoList))
            {
                InfoList = DownFile.Id.ToString();
            }
            int Ret = Entity.ChangeEntity <DownFile>(InfoList, Clomn, Value);

            Entity.SaveChanges();
            Response.Write(Ret);
        }
        public void Delete(DownFile DownFile, string InfoList, int?IsDel)
        {
            if (string.IsNullOrEmpty(InfoList))
            {
                InfoList = DownFile.Id.ToString();
            }
            int Ret = Entity.MoveToDeleteEntity <DownFile>(InfoList, IsDel, AdminUser.UserName);

            Entity.SaveChanges();
            Response.Write(Ret);
        }
Ejemplo n.º 11
0
        public void RootDownLoadFile(DownFile downfile, MemoryStream ms, Action <int> action)
        {
            if (downfile == null)
            {
                throw new Exception("下载文件对象不能为空!");
            }
            if (fileServiceClient == null)
            {
                throw new Exception("还没有创建连接!");
            }
            try
            {
                DownFileResult result = new DownFileResult();

                result = fileServiceClient.RootDownLoadFile(downfile);

                if (result.IsSuccess)
                {
                    if (ms == null)
                    {
                        ms = new MemoryStream();
                    }

                    int    bufferlen = 4096;
                    int    count     = 0;
                    byte[] buffer    = new byte[bufferlen];

                    if (action != null)
                    {
                        getupdownprogress(result.FileStream, result.FileSize, action);//获取进度条
                    }
                    while ((count = result.FileStream.Read(buffer, 0, bufferlen)) > 0)
                    {
                        ms.Write(buffer, 0, count);
                    }
                }
                else
                {
                    throw new Exception("下载文件失败!");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message + "\n下载文件失败!");
            }
            finally
            {
                //if (fileServiceClient != null)
                //{
                //    fileServiceClient.Close();
                //}
            }
        }
Ejemplo n.º 12
0
        public ActionResult Info(DownFile DownFile, EFPagingInfo <DownFile> p)
        {
            if (!DownFile.TId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TId == DownFile.TId);
            }
            p.OrderByList.Add("Sort", "ESC");
            IPageOfItems <DownFile> DownFileList = Entity.Selects <DownFile>(p);

            ViewBag.DownFileList = DownFileList;
            return(View());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="df">下载文件对象</param>
        /// <param name="filepath">存放下载文件的路径</param>
        /// <param name="action">进度条委托</param>
        public void DownLoadFile(DownFile df, string filepath, Action <int> action)
        {
            if (df == null)
            {
                throw new Exception("下载文件对象不能为空!");
            }

            try
            {
                DownFileResult result = new DownFileResult();

                result = fileServiceClient.DownLoadFile(df);

                if (result.IsSuccess)
                {
                    FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write);

                    int    bufferlen = 4096;
                    int    count     = 0;
                    byte[] buffer    = new byte[bufferlen];

                    if (action != null)
                    {
                        getupdownprogress(result.FileStream, result.FileSize, action);//获取进度条
                    }
                    while ((count = result.FileStream.Read(buffer, 0, bufferlen)) > 0)
                    {
                        fs.Write(buffer, 0, count);
                    }

                    //清空缓冲区
                    fs.Flush();
                    //关闭流
                    fs.Close();
                }
                else
                {
                    throw new Exception("下载文件失败!");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message + "\n下载文件失败!");
            }
            finally
            {
                //if (fileServiceClient != null)
                //{
                //    fileServiceClient.Close();
                //}
            }
        }
Ejemplo n.º 14
0
        public void PacketDownload(ref Packet packet)
        {
            DownFile df = (DownFile)packet;

            Message(df.name + " 파일을 다운로드합니다...");

            df.fi   = new FileInfo(df.ServerPath);
            df.size = df.fi.Length;

            Thread file_Send = new Thread(new ParameterizedThreadStart(fileSend));

            file_Send.Start(packet);
        }
 public ActionResult Add(DownFile DownFile)
 {
     DownFile.AddTime = DateTime.Now;
     DownFile         = Request.ConvertRequestToModel <DownFile>(DownFile, DownFile);
     if (DownFile.Pic == "System.Web.HttpPostedFileWrapper")
     {
         ViewBag.ErrorMsg = "文件格式不正确!";
         return(View("Error"));
     }
     Entity.DownFile.AddObject(DownFile);
     Entity.SaveChanges();
     return(this.Redirect(Session["Url"].ToString()));
     //BaseRedirect();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 从根节点下载文件
 /// </summary>
 /// <param name="downfile"></param>
 /// <returns></returns>
 public static DownFileResult RootDownLoadFile(DownFile downfile)
 {
     if (WcfGlobal.IsRootMNode)
     {
         return(DownLoadFile(downfile));
     }
     else
     {
         ShowHostMsg(Color.Green, DateTime.Now, "准备从根节点下载文件...");
         DownFileResult dfResult = SuperClient.superClientLink.RootDownLoadFile(downfile);
         ShowHostMsg(Color.Green, DateTime.Now, "从根节点下载文件完成");
         return(dfResult);
     }
 }
        public ActionResult Save(DownFile DownFile)
        {
            DownFile.AddTime = DateTime.Now;
            DownFile baseDownloadFile = Entity.DownFile.FirstOrDefault(n => n.Id == DownFile.Id);
            var      old = baseDownloadFile.Pic;

            baseDownloadFile = Request.ConvertRequestToModel <DownFile>(baseDownloadFile, DownFile);
            if (baseDownloadFile.Pic == "System.Web.HttpPostedFileWrapper" || baseDownloadFile.Pic == old)
            {
                ViewBag.ErrorMsg = "文件格式不正确!";
                return(View("Error"));
            }
            Entity.SaveChanges();
            return(this.Redirect(Session["Url"].ToString()));
            //BaseRedirect();
        }
Ejemplo n.º 18
0
    public string CreatHaibaowithCode(string openid, string hpic)
    {
        string   URL   = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + WeixinApiClass.GetWeiXinInf.Getaccess_token();
        string   json  = "{\"action_name\":\"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"" + openid + "\"}}}";
        string   rjson = WeixinApiClass.PostDataToUrl.PostXmlToUrl(URL, json);
        TXT_Help th    = new TXT_Help();

        //th.ReFreshTXT(rjson, "D:\\msg_err\\","c" + DateTime.Now.ToString("yyMMddHHmmssff") + ".txt");
        if (rjson.Contains("errcode"))
        {
            return("~/CodeWithOpenid/0.png");
        }
        else
        {
            JObject  jo     = JObject.Parse(rjson);
            string[] values = jo.Properties().Select(item => item.Value.ToString()).ToArray();
            string   ticket = values[0].ToString();
            string   url    = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + ticket.Trim();
            DownFile d      = new DownFile();
            string   spath  = "D://LVWEIBA//WeixinSys//Media//code//" + openid + ".jpg";
            string   npath  = "D://LVWEIBA//WeixinSys//Media//haibao//" + openid + ".jpg";
            string   hpath  = "D://LVWEIBA//WeixinSys//Media//headimg//" + openid + ".jpg";
            if (File.Exists(npath))
            {
                return("http://wx.lvwei8.com/media/haibao/" + openid + ".jpg");
            }
            else
            {
                d.DownloadFile(url, spath, 300000);     //下载二维码
                if (hpic == "")                         //如果没有头像
                {
                    d.DownloadFile(url, hpath, 300000); //下载头像
                }
                else
                {
                    d.DownloadFile(hpic, hpath, 300000);//下载头像
                }

                CodeMaker cm = new CodeMaker();
                //cm.MakeCodeWithZhiwen(spath, npath);
                cm.MakeHaibaoWithOpenid(openid);

                return("http://wx.lvwei8.com/media/haibao/" + openid + ".jpg");
            }
        }
    }
Ejemplo n.º 19
0
        /// <summary>
        /// 下载文件服务实现
        /// </summary>
        /// <param name="downfile">表示文件类型</param>
        /// <returns>文件流</returns>
        public DownFileResult DownLoadFile(DownFile downfile)
        {
            DownFileResult result = new DownFileResult();

            //string path = System.AppDomain.CurrentDomain.BaseDirectory + @"\service\" + filedata.FileName;
            string path = "";

            if (downfile.FileType.Equals("cmm", StringComparison.CurrentCultureIgnoreCase))
            {
                //path = PathManager.Instance.ReportsPath;
                // todo 测试更改目录
                path = @"D:\ServerPathRoot\blades\TestPart12\Results\cab5.CMM";
            }
            else if (downfile.FileType.Equals("rpt", StringComparison.CurrentCultureIgnoreCase))
            {
                //path = PathManager.Instance.RptFilePath;
                // todo 测试更改目录
                path = @"D:\ServerPathRoot\blades\TestPart12\Results\propsww.rpt";
            }
            else
            {
                path = string.Empty;
            }

            if (!File.Exists(path))
            {
                result.IsSuccess  = false;
                result.FileSize   = 0;
                result.Message    = "服务器不存在此文件";
                result.FileStream = new MemoryStream();
                return(result);
            }
            Stream     ms = new MemoryStream();
            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            fs.CopyTo(ms);
            ms.Position       = 0; //重要,不为0的话,客户端读取有问题
            result.IsSuccess  = true;
            result.FileSize   = ms.Length;
            result.Message    = path; // 文件在服务器上的路径
            result.FileStream = ms;

            fs.Flush();
            fs.Close();
            return(result);
        }
Ejemplo n.º 20
0
        void DownFile(string filename)
        {
            if (_proxy != null)
            {
                DownFile dfPath = new DownFile {
                    FileName = filename
                };

                long           filesize   = 0;
                bool           issuccess  = false;
                string         message    = "";
                Stream         filestream = new MemoryStream();
                DownFileResult dfresult   = _proxy.DownLoadFile(dfPath);
                filesize   = dfresult.FileSize;
                issuccess  = dfresult.IsSuccess;
                message    = dfresult.Message;
                filestream = dfresult.FileStream;

                //, out issuccess, out message, out filestream
                if (issuccess)
                {
                    if (!Directory.Exists(_savePath))
                    {
                        Directory.CreateDirectory(_savePath);
                    }

                    byte[]     buffer = new byte[filesize];
                    FileStream fs     = new FileStream(_savePath + @"\" + filename, FileMode.Create, FileAccess.Write);
                    int        count  = 0;
                    while ((count = filestream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fs.Write(buffer, 0, count);
                    }

                    //清空
                    fs.Flush();
                    //关闭流
                    fs.Close();
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
        }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //http://update.z01.com/Template/Bear/view.jpg
            if (function.isAjax())
            {
                string action = Request.Form["action"];
                string value  = Request.Form["value"];
                int    userID = buser.GetLogin().UserID;
                Response.Clear();
                switch (action)
                {
                case "getTempP":
                    Response.Write(ZipClass.GetPercent(Convert.ToInt64(Application[userID + "downTempT"]), Convert.ToInt64(Application[userID + "downTempP"])));
                    break;

                case "setdefault":
                    string tempdir = @"/Template/" + value;
                    SiteConfig.SiteOption.TemplateDir = tempdir;
                    SiteConfig.SiteOption.CssDir      = tempdir + "/style";
                    SiteConfig.Update();
                    Response.Write("");
                    break;
                }
                Response.End();
            }
            //EC.GetRemoteObj remote = new EC.GetRemoteObj();
            //remote.Urlutf8("" + serverdomain + "/api/gettemplate.aspx?menu=getprojectinfodir&proname=" + Server.UrlEncode(proname));
            if (!IsPostBack)
            {
                Panel1.Visible = true;
                LblTitle.Text  = ProName + "[作者:" + GetAuthor() + "]";
                tempname.Text  = ProName;
                string prodir = "/template/" + ProDir + "/";
                tempimg.Text = "<a class=\"lightbox\" href=\"" + serverdomain + prodir + "view.jpg\"><img src=\"" + serverdomain + prodir + "View.jpg\"></a>";
                DownFile dw          = DownFileWork;
                string   TempUrl     = serverdomain + "/template/" + ProDir + ".zip";
                string   TempZipFile = SiteConfig.SiteMapath() + "\\template\\" + ProDir + ".zip";
                TempUrl     = TempUrl.Replace(@"\\", @"\");
                TempZipFile = TempZipFile.Replace("/", @"\").Replace(@"\\", @"\");
                //function.WriteErrMsg(TempZipFile + "||||" + TempUrl);
                Application[buser.GetLogin().UserID + "downTempT"] = GetFileSize(TempUrl);
                dw.BeginInvoke(buser.GetLogin().UserID, HttpContext.Current, TempUrl, TempZipFile, null, null, null);
                Call.SetBreadCrumb(Master, "<li><a href='" + customPath2 + "Main.aspx'>工作台</a></li><li><a href='TemplateSetOfficial.aspx'>方案设置</a></li><li class=\"active\">下载方案</li>");
            }
        }
 public ActionResult Edit(DownFile DownFile)
 {
     if (DownFile.Id != 0)
     {
         DownFile = Entity.DownFile.FirstOrDefault(n => n.Id == DownFile.Id);
     }
     if (DownFile == null)
     {
         ViewBag.ErrorMsg = "数据不存在";
         return(View("Error"));
     }
     ViewBag.DownFile        = DownFile;
     ViewBag.DownFileTagList = Entity.DownFileTag.OrderBy(o => o.Sort).Where(n => n.State == 1).ToList();
     if (Request.UrlReferrer != null)
     {
         Session["Url"] = Request.UrlReferrer.ToString();
     }
     return(View());
 }
Ejemplo n.º 23
0
        //下载文件
        public DownFileResult DownLoadFile(DownFile filedata)
        {
            DownFileResult result = new DownFileResult();

            //string path = System.AppDomain.CurrentDomain.BaseDirectory + @"\service\" + filedata.FileName;
            string path = Path.Combine(ServerDirManager.Inst.ResultDirectory, filedata.FileName);

            if (!File.Exists(path))
            {
                result.IsSuccess  = false;
                result.FileSize   = 0;
                result.Message    = "服务器不存在此文件";
                result.FileStream = new MemoryStream();
                return(result);
            }

            // 判断文件是否创建完成
            var  t       = WaitForRead(path);
            bool canRead = t.Result;

            if (!canRead)
            {
                result.IsSuccess  = false;
                result.FileSize   = 0;
                result.Message    = "报告文件创建超时";
                result.FileStream = new MemoryStream();
                return(result);
            }

            Stream     ms = new MemoryStream();
            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            fs.CopyTo(ms);
            ms.Position       = 0; //重要,不为0的话,客户端读取有问题
            result.IsSuccess  = true;
            result.FileSize   = ms.Length;
            result.FileStream = ms;

            fs.Flush();
            fs.Close();
            return(result);
        }
Ejemplo n.º 24
0
        private static void downloadRemoteFile()
        {
            DownFile df = new DownFile();

            df.clientId = SuperClient.superclient.clientObj.ClientID;
            df.DownKey  = Guid.NewGuid().ToString();
            df.FileName = "update.xml";
            df.FileType = 1;
            SuperClient.superclient.DownLoadFile(df, updatexml, null);

            df          = new DownFile();
            df.clientId = SuperClient.superclient.clientObj.ClientID;
            df.DownKey  = Guid.NewGuid().ToString();
            df.FileName = "update.zip";
            df.FileType = 1;
            SuperClient.superclient.DownLoadFile(df, updatezip, (delegate(int _num)
            {
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Black, "客户端升级包下载进度:%" + _num);
            }));
        }
Ejemplo n.º 25
0
        private bool DownFileFromServer(string v)
        {
            DownFile df = new DownFile();

            df.FileType = v;
            DownFileResult res = _partConfigService.DownLoadFile(df);

            if (res.IsSuccess)
            {
                //string path = Path.GetDirectoryName(res.Message); // 在客户端建立相同的目录,记录结果信息
                // todo 调试修改路径
                string path = @"D:\Reports";
                _resultRecord.FilePath = path;
                string filename = Path.Combine(path, Path.GetFileName(res.Message));
                if (v.Equals("cmm", StringComparison.CurrentCultureIgnoreCase))
                {
                    _resultRecord.CmmFileName = Path.GetFileName(res.Message);
                }
                else
                {
                    _resultRecord.RptFileName = Path.GetFileName(res.Message);
                }

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                byte[] buffer = new byte[res.FileSize];
                using (FileStream fs = new FileStream(filename /* todo res.Message*/, FileMode.Create, FileAccess.Write))
                {
                    int count = 0;
                    while ((count = res.FileStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fs.Write(buffer, 0, count);
                    }
                    fs.Flush();
                    fs.Close();
                }
            }
            return(res.IsSuccess);
        }
Ejemplo n.º 26
0
        //从根节点下载
        private static void downloadRemotePlugin(string pluginzip, ClientLink _clientLink)
        {
            DownFile df = new DownFile();

            df.clientId = Guid.NewGuid().ToString();
            df.DownKey  = Guid.NewGuid().ToString();
            df.FileName = pluginzip;
            df.FileType = 0;
            FileStream fs = new FileStream(rootpath + pluginzip, FileMode.Create, FileAccess.Write);

            try
            {
                _clientLink.RootDownLoadFile(df, fs, (delegate(int _num) //从根节点下载
                {
                    MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Black, "插件包下载进度:%" + _num);
                }));
            }
            catch (Exception err) {
                CoreFrame.Common.MiddlewareLogHelper.WriterLog(err.Message + err.StackTrace);
            }
        }
        public ActionResult Index(DownFile DownFile, EFPagingInfo <DownFile> p, int IsFirst = 0)
        {
            if (IsFirst == 0)
            {
                PageOfItems <DownFile> DownFileList1 = new PageOfItems <DownFile>(new List <DownFile>(), 0, 10, 0, new Hashtable());
                ViewBag.DownFileList    = DownFileList1;
                ViewBag.DownFile        = DownFile;
                ViewBag.DownFileTagList = Entity.DownFileTag.OrderBy(o => o.Sort).Where(n => n.State == 1).ToList();
                ViewBag.Add             = this.checkPower("Add");
                ViewBag.Edit            = this.checkPower("Edit");
                ViewBag.Delete          = this.checkPower("Delete");
                ViewBag.Save            = this.checkPower("Save");
                return(View());
            }
            if (!DownFile.Pic.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Pic.Contains(DownFile.Pic));
            }
            if (!DownFile.TId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TId == DownFile.TId);
            }
            if (!DownFile.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == (DownFile.State == 99 ? 0 : DownFile.State));
            }
            p.OrderByList.Add("Sort", "ESC");
            IPageOfItems <DownFile> DownFileList = Entity.Selects <DownFile>(p);

            ViewBag.DownFileList    = DownFileList;
            ViewBag.DownFile        = DownFile;
            ViewBag.DownFileTagList = Entity.DownFileTag.OrderBy(o => o.Sort).Where(n => n.State == 1).ToList();
            ViewBag.Add             = this.checkPower("Add");
            ViewBag.Edit            = this.checkPower("Edit");
            ViewBag.Delete          = this.checkPower("Delete");
            ViewBag.Save            = this.checkPower("Save");
            return(View());
        }
Ejemplo n.º 28
0
        private static Version getRemoteUpdateXml()
        {
            DownFile df = new DownFile();

            df.clientId = SuperClient.superclient.clientObj.ClientID;
            df.DownKey  = Guid.NewGuid().ToString();
            df.FileName = "update.xml";
            df.FileType = 1;
            //MemoryStream update_ms = new MemoryStream();
            MemoryStream ms = new MemoryStream();

            SuperClient.superclient.DownLoadFile(df, ms, null);
            //ms.CopyTo(update_ms);
            String str = System.Text.Encoding.Default.GetString(ms.ToArray());

            ms.Close();
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.LoadXml(str);
            System.Xml.XmlNode xn  = xmlDoc.DocumentElement.SelectSingleNode("AppVersion");
            Version            ver = new Version(xn.InnerText);

            return(ver);
        }
Ejemplo n.º 29
0
        private static void downloadRemoteFile(string updatexml, string updatezip, ClientLink _clientLink)
        {
            DownFile df = new DownFile();

            df.clientId = Guid.NewGuid().ToString();
            df.DownKey  = Guid.NewGuid().ToString();
            df.FileName = updatexml;
            df.FileType = 0;
            FileStream fs = new FileStream(rootpath + updatexml, FileMode.Create, FileAccess.Write);

            _clientLink.RootDownLoadFile(df, fs, null);

            df          = new DownFile();
            df.clientId = Guid.NewGuid().ToString();
            df.DownKey  = Guid.NewGuid().ToString();
            df.FileName = updatezip;
            df.FileType = 0;
            fs          = new FileStream(rootpath + updatezip, FileMode.Create, FileAccess.Write);
            _clientLink.RootDownLoadFile(df, fs, (delegate(int _num)
            {
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Black, "升级包下载进度:%" + _num);
            }));
        }
Ejemplo n.º 30
0
 public MediaServiceCallback(DownFile d)
 {
     down = d;
 }
Ejemplo n.º 31
0
 public DownFileResult RootDownLoadFile(DownFile downfile)
 {
     return(FileManage.RootDownLoadFile(downfile));
 }