Ejemplo n.º 1
0
 /// <summary>
 /// 获取FTP上面的图片
 /// </summary>
 /// <param name="date">日期</param>
 /// <param name="code">编码</param>
 /// <returns></returns>
 public string DowImgForFTP(string date, string code)
 {
     string strImgName = code + date;
     Dictionary<string, string> dic = new Dictionary<string, string>();
     dic = GetFtpPathAndLogin();//获取FTP
     string url = dic["FTPFolder2"];
     string struser = dic["FTPUser"];
     string strpwd = dic["FTPPWD"];
     RuRo.Common.FTP.FTPOperater ftpp = new Common.FTP.FTPOperater();
     RuRo.Common.FTP.FTPHelper ftp = new Common.FTP.FTPHelper(url, "", struser, strpwd);
     ftp.Download("2015", strImgName);
     return "";
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 上传到指定的FTP空间
 /// </summary>
 /// <param name="url">FTP地址</param>
 /// <param name="dt">前台传来的日期</param>
 /// <param name="path">图片保存在服务端的路径</param>
 /// <param name="strGuid">图片名称</param>
 /// <param name="host">网页主机名称</host>
 /// <returns></returns>
 public string Sel_Folder(DateTime dt, string path, string imgname, Dictionary<string, string> dickeshi)
 {
     string mes = "";
     Dictionary<string, string> dic = new Dictionary<string, string>();
     // dic = GetFtpPathAndLogin();
     dic = RuRo.BLL.TB_CONSENT_FORM.FtpPathAndLogin();
     string url = dic["FTPFolder2"];
     string struser = dic["FTPUser"];
     string strpwd = dic["FTPPWD"];
     RuRo.Common.FTP.FTPHelper ftp = new Common.FTP.FTPHelper(url, "", struser, strpwd);
     string year = dt.Year.ToString();
     string Month = dt.Month.ToString();
     string strMemu = dickeshi["SP"].ToString() + "/" + year + "/" + Month;
     string[] YearFolder = ftp.GetDirectoryList();//获取所有文件夹列表
     string[] Folders = ftp.GetFilesDetailList();//获取所有文件夹列表
     if (Get_FolderForBool(dickeshi["SP"].ToString(), YearFolder))//判断是否存在科室文件夹
     {
         ftp.MakeDir(dickeshi["SP"].ToString());//创建文件夹
         ftp.GotoDirectory(dickeshi["SP"].ToString(), true);//进入科室目录
         if (Get_FolderForBool(year, YearFolder))//判断是否存在年份命名的文件夹,没有则创建//没有返回true
         {
             ftp.MakeDir(year);//创建文件夹
             #region 判断所属的月份是否存在并操作
             ftp.GotoDirectory(dickeshi["SP"].ToString() + "/" + year, true);//进入年份目录
             string[] MonthFolder = ftp.GetDirectoryList();
             if (Get_FolderForBool(Month, MonthFolder))
             {
                 ftp.MakeDir(Month);
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             else
             {
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             #endregion
         }
         else
         {
             #region 判断所属的月份是否存在并操作
             ftp.GotoDirectory(dickeshi["SP"].ToString() + "/" + year, true);//进入年份目录
             string[] MonthFolder = ftp.GetDirectoryList();
             if (Get_FolderForBool(Month, MonthFolder))
             {
                 ftp.MakeDir(Month);
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             else
             {
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             #endregion
         }
     }
     else
     {
         ftp.GotoDirectory(dickeshi["SP"].ToString(), true);//进入科室目录
         if (Get_FolderForBool(year, YearFolder))//判断是否存在年份命名的文件夹,没有则创建//没有返回true
         {
             ftp.MakeDir(year);//创建文件夹
             #region 判断所属的月份是否存在并操作
             ftp.GotoDirectory(year, true);//进入年份目录
             string[] MonthFolder = ftp.GetDirectoryList();
             if (Get_FolderForBool(Month, MonthFolder))
             {
                 ftp.MakeDir(Month);
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             else
             {
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             #endregion
         }
         else
         {
             #region 判断所属的月份是否存在并操作
             ftp.GotoDirectory(year, true);//进入子目录
             string[] MonthFolder = ftp.GetDirectoryList();
             if (Get_FolderForBool(Month, MonthFolder))
             {
                 ftp.MakeDir(Month);
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             else
             {
                 mes = PostImg(path, imgname, strMemu + "/", dt);//上传图片到FTP,并返回访问字符串
                 return mes;
             }
             #endregion
         }
     }
 }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            string strImgName = context.Request["imgname"].ToString();
            string strDate = context.Request["imgdate"].ToString();
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic = GetFtpPathAndLogin();
            RuRo.Common.FTP.FTPHelper ftpc = new Common.FTP.FTPHelper(dic["FTPFolder2"], "", dic["FTPUser"], dic["FTPPWD"]);
               // ftpc.Download(dic["SaveImgPath"], "100065631620151111.jpg");
            Stream  stream=  ftpc.DownloadInfo(strImgName);
            byte[] byteImg = StreamToBytes(stream).ToArray();
            context.Response.BinaryWrite(byteImg);

            context.Response.End();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 上传到FTP
 /// </summary>
 /// <param name="path">本地路径</param>
 /// <param name="imgname">本地文件名称</param>
 /// <param name="strMemu">存放子目录</param>
 /// <returns></returns>
 public string PostImg(string path, string imgname, string strMemu, DateTime dt)
 {
     //获取FTP地址,账号,密码
     string mes = "";
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         //dic = GetFtpPathAndLogin();
         dic = RuRo.BLL.TB_CONSENT_FORM.FtpPathAndLogin();
         RuRo.Common.FTP.FTPHelper ftpf = new Common.FTP.FTPHelper(dic["FTPFolder2"], strMemu, dic["FTPUser"], dic["FTPPWD"]);
         ftpf.Upload(path);
         string date = dt.ToString("yyyy-MM-dd");
         mes = CreatDownUrl(imgname);
         //mes = "https://" + host + "/Download.aspx?imgname=" + imgname + "&imgdate=" + date;
         //mes = "ftp://" + dic["FTPFolder"] + "/" + strMemu + imgname;
         //mes = "http://localhost:3448/Download.aspx?imgname=XYS_2065459-20151101.jpg";
         return mes;
     }
     catch (Exception ex)
     {
         string strex = ex.ToString();
         if (strex.Contains("已经存在"))
         {
             return "该文件已经存在";
         }
         if (strex.Contains("另外进程"))
         {
             return "请关闭该文件再上传";
         }
         else
         {
             return ex.ToString();
         }
     }
 }