Пример #1
0
        public string UploadFile()
        {
            HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            int aa = files.Count;

            int             _pictype = FormString.IntSafeQ("pictype");
            HttpPostedFile  file     = System.Web.HttpContext.Current.Request.Files[0];
            CertificateType _certype = (CertificateType)_pictype;

            if (file != null)
            {
                byte[] bytes = null;
                using (var binaryReader = new BinaryReader(file.InputStream))
                {
                    bytes = binaryReader.ReadBytes(file.ContentLength);
                }
                FtpUtil _ftp        = new FtpUtil();
                string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.Certifacate.ToString(), "behind_" + memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), Guid.NewGuid().ToString());
                string  dicpathfull = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));
                string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                _ftp.UploadFile(certifapath, bytes, true);
                return(dicpathfull);
            }
            return("");
        }
        public string MemUploadImg()
        {
            HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            int             aa       = files.Count;
            int             _pictype = FormString.IntSafeQ("pictype");
            HttpPostedFile  file     = System.Web.HttpContext.Current.Request.Files[0];
            CertificateType _certype = (CertificateType)_pictype;

            if (file != null)
            {
                byte[] bytes = null;
                using (var binaryReader = new BinaryReader(file.InputStream))
                {
                    bytes = binaryReader.ReadBytes(file.ContentLength);
                }
                FtpUtil _ftp        = new FtpUtil();
                Random  _rd         = new Random();
                string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, _certype.ToString(), memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), _rd.Next(100000, 999999).ToString());
                string  dicpathfull = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));
                string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                _ftp.UploadFile(certifapath, bytes, true);
                return("{\"jsonrpc\" : \"2.0\", \"result\" : null, \"pic_raw\" : \"" + dicpathfull + "\"}");
            }

            return("");
        }
        public void TestInitliaze()
        {
            if (TestContext.TestName == "SftpPollAsyncPositive")
            {
                rootFolder = Guid.NewGuid().ToString();
            }
            else
            {
                rootFolder = string.Empty;
            }

            baseTransportDestinationTestHelper             = new BaseTransportDestinationTestHelper <SFTPController>(true, rootfolderpath: rootFolder);
            baseTransportDestinationTestHelperForMultiFact = new BaseTransportDestinationTestHelper <SFTPController>(true, true, true, rootfolderpath: rootFolder);
            FtpUtil ftpUtil = new FtpUtil(true);

            if (isControllerTest)
            {
                (baseTransportDestinationTestHelper.ftpConnectorTest as FileBasedProtocolConnectorControllerTest <SFTPController>).controller.AcceptAnySSHServerHostKey = true;
                sftpConnectorTest = new FileBasedProtocolConnectorControllerTest <SFTPController>(true);
                (sftpConnectorTest as FileBasedProtocolConnectorControllerTest <SFTPController>).controller.AcceptAnySSHServerHostKey = true;
            }
            else
            {
                sftpConnectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(ftpUtil.GetNameValueCollection(false, true));
            }
        }
Пример #4
0
        public Result GetOrderRec(string orderNo)
        {
            Result result = new Result();

            result.Message = "暂未生成相应的回执";
            try
            {
                FtpUtil ftp         = new FtpUtil("", "name", "password");
                string  ftpResponse = "";
                Stream  stream      = ftp.FileStream("", ref ftpResponse);
                // 设置当前流的位置为流的开始,防止读取位置错误造成无法读取完整流的内容
                stream.Seek(0, SeekOrigin.Begin);
                using (StreamReader reader = new StreamReader(stream))
                {
                    string data = reader.ReadToEnd();
                    // 接收回执
                    if (data.Contains("OrderRec"))
                    {
                        OrderRec orderRec = Util.Serialization.SerializationUtil.XmlDeserialize <OrderRec>(data);
                        if (orderRec.orderNo == orderNo)
                        {
                            // TODO:更新订单推送状态
                            result.Status = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Пример #5
0
    public override void Process()
    {
        try
        {
            Start = String.IsNullOrEmpty(Request["start"]) ? 0 : Convert.ToInt32(Request["start"]);
            Size  = String.IsNullOrEmpty(Request["size"]) ? Config.GetInt("imageManagerListSize") : Convert.ToInt32(Request["size"]);
        }
        catch (FormatException)
        {
            State = ResultState.InvalidParam;
            WriteResult();
            return;
        }


        var buildingList = new List <String>();
        var listArray    = new List <String>();

        try
        {
            FtpUtil _ftp = new FtpUtil();
            //int _storeid = CookieBLL.GetStoreIdCookie();
            int    _memid    = 3;
            string localPath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.ProductDescription.ToString(), "Behind_" + _memid.ToString(), DateTime.Now.Year.ToString());
            listArray = _ftp.GetFileList(localPath);

            for (var i = 0; i < listArray.Count; i++)
            {
                listArray[i] = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.ProductDescription.ToString(), "Behind_" + _memid.ToString(), DateTime.Now.Year.ToString(), listArray[i]);
            }

            //var localPath = Server.MapPath(PathToList);

            //buildingList.AddRange(Directory.GetFiles(localPath, "*", SearchOption.AllDirectories)
            //    .Where(x => SearchExtensions.Contains(Path.GetExtension(x).ToLower()))
            //    .Select(x => PathToList + x.Substring(localPath.Length).Replace("\\", "/")));
            //Total = buildingList.Count;
            //FileList = buildingList.OrderBy(x => x).Skip(Start).Take(Size).ToArray();

            FileList = listArray.ToArray();
            Total    = listArray.Count;
        }
        catch (UnauthorizedAccessException)
        {
            State = ResultState.AuthorizError;
        }
        catch (DirectoryNotFoundException)
        {
            State = ResultState.PathNotFound;
        }
        catch (IOException)
        {
            State = ResultState.IOError;
        }
        finally
        {
            WriteResult();
        }
    }
Пример #6
0
        /// <summary>
        /// 海关商检反馈信息
        /// </summary>
        /// <returns></returns>
        public override string[] GetIcpOutResult()
        {
            FtpUtil ftp = new FtpUtil(config.GZJCIcpInfoTrade.FtpUrl, config.GZJCIcpInfoTrade.FtpName, config.GZJCIcpInfoTrade.FtpPassword);

            string[] inflist = null;
            inflist = ftp.GetFileList(config.GZJCIcpInfoTrade.FtpUrl + "out");
            return(inflist);
        }
Пример #7
0
        /// <summary>
        /// 下载报文
        /// </summary>
        /// <param name="type"></param>
        /// <param name="localDir"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public override string DownResultFileData(string localDir, string filePath)
        {
            FtpUtil ftp = new FtpUtil(config.GZJCIcpInfoTrade.FtpUrl, config.GZJCIcpInfoTrade.FtpName, config.GZJCIcpInfoTrade.FtpPassword);
            string  msg = "";

            ftp.DownloadFile(config.GZJCIcpInfoTrade.FtpUrl + "out/" + filePath, localDir, out msg);
            return(msg);
        }
Пример #8
0
        public void TestMethod1()
        {
            // bool isCon = FtpUtil.Connect("ftp://192.168.123.128:21/", "root", "root");
            bool result = FtpUtil.UploadFile("D:/image/02.jpg", "ftp://192.168.123.128:21", "root", "root");

            if (result)
            {
            }
        }
Пример #9
0
        public void TestMethod2()
        {
            // bool isCon = FtpUtil.Connect("ftp://192.168.123.128:21", "root", "root");
            bool result = FtpUtil.DeleteFile("01.jpg", "ftp://192.168.123.128:21", "root", "root");

            if (result)
            {
            }
        }
Пример #10
0
        public void TestMethod3()
        {
            // bool isCon = FtpUtil.Connect("ftp://192.168.123.128:21", "root", "root");
            bool result = FtpUtil.DownloadFile("E://Xiaomi/", "01.jpg", "ftp://192.168.123.128:21/test", "root", "root");

            if (result)
            {
            }
        }
Пример #11
0
 public TranData(string datapath, string zippath, string tranSql, string hostname, string uid, string pwd, string ftpdir)
 {
     this.datapath = datapath;
     FileUtil.createPath(datapath);
     this.zippath = zippath;
     FileUtil.createPath(zippath);
     this.tranSql = tranSql;
     dao          = new DaoUtil();
     ftputil      = new FtpUtil(hostname, uid, pwd, ftpdir);
 }
Пример #12
0
        private async Task ROSASTradeAsync(SoapDocument soapDocument)
        {
            string message = string.Empty;
            string xmlStr  = soapDocument.Args.FirstOrDefault(o => o.LocalName == "serviceParas")?.Value;

            try
            {
                var xmlServiceParas = XmlConvert.DeserializeObject <HebeiESBServiceParas>(xmlStr);

                if (xmlServiceParas == null || xmlServiceParas.ProvinceData.Count() == 0)
                {
                    throw new Exception("解析serviceParas失败");
                }

                bool isSuccess = true;
                var  ftpConfig = AppSettings.FtpSection.FirstOrDefault(o => o.Provider == "HebeiESB");
                foreach (var p in xmlServiceParas.ProvinceData)
                {
                    if (string.IsNullOrWhiteSpace(p.Path))
                    {
                        continue;
                    }
                    var success = await FtpUtil.Download(new FtpConfig
                    {
                        Host           = p.Ip,
                        UserName       = p.User,
                        Password       = p.Password,
                        Port           = 21,
                        RemotePath     = p.Path,
                        BaseDirectory  = ftpConfig.BaseDirectory,
                        LocalDirectory = ftpConfig.LocalDirectory,
                        RenameFormat   = ftpConfig.RenameFormat,
                        CategoryMaps   = ftpConfig.CategoryMaps
                    });

                    isSuccess &= success;
                    string successString = success ? "成功" : "失败";
                    message += string.Format($"下载{successString}:ftp://{p.User}:{p.Password}@{p.Ip}{p.Path}", p, successString);
                }

                if (!isSuccess)
                {
                    await ErrorRequestAsync(null, message);
                }
                else
                {
                    await SuccessRequestAsync(null, message : message);
                }
            }
            catch (Exception ex)
            {
                Logger.Error($"[HBESBService]ROSASTrade异常:--{ex.Message}", ex);
                await ErrorRequestAsync(null, ex.Message);
            }
        }
Пример #13
0
        /// <summary>
        /// 获取订单商检回执
        /// </summary>
        /// <returns></returns>
        public override Result GetOrderRec()
        {
            Result result = new Result();

            try
            {
                FtpUtil ftp = new FtpUtil(config.GZJCIcpInfoTrade.FtpUrl, config.GZJCIcpInfoTrade.FtpName, config.GZJCIcpInfoTrade.FtpPassword);

                string[] fileList = GetIcpOutResult();

                if (fileList != null)
                {
                    foreach (string fileTxt in fileList)
                    {
                        string msg    = "";
                        Stream stream = ftp.FileStream(config.GZJCIcpInfoTrade.FtpUrl + fileTxt, ref msg);
                        //设置当前流的位置为流的开始,防止读取位置错误造成无法读取完整流的内容
                        stream.Seek(0, SeekOrigin.Begin);
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string txt = reader.ReadToEnd();

                            //接收回执
                            if (fileTxt.Contains("KJDOCREC_"))
                            {
                                Hyt.Model.Icp.GZBaiYunJiChang.Goods.DOCREC.DocRec DocRec = Hyt.Util.Serialization.SerializationUtil.XmlDeserialize <Hyt.Model.Icp.GZBaiYunJiChang.Goods.DOCREC.DocRec>(txt);
                                //更新平台回执信息
                                if (DocRec.Declaration.OrgMessageType == "KJ881111")
                                {
                                    IcpBo.Instance.UpdatePlatDocRecByMessageID(DocRec.Declaration.OrgMessageID, txt, DocRec.Declaration.Status);
                                }
                                //更新商检回执信息
                                if (DocRec.Declaration.OrgMessageType == "881111")
                                {
                                    IcpBo.Instance.UpdateCiqDocRecByMessageID(DocRec.Declaration.OrgMessageID, txt, DocRec.Declaration.Status);
                                }
                            }
                        }
                    }
                    result.Status  = true;
                    result.Message = "获取成功";
                }
                else
                {
                    result.Status  = true;
                    result.Message = "暂未生成相应的回执";
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Пример #14
0
        private void FtpSend()
        {
            var files = XmlFactory.DonePath.ToArray();

            if (files.Length > 0)
            {
                var ftp = new FtpUtil(Public.FtpConPara);
                ftp.FtpUploadFileForMulti(files);
                LogUtils.InfoLog("Files发送成功:" + string.Join(",", files));
            }
        }
Пример #15
0
        public string CreateStyle()
        {
            string str = "wqweqdasdadq121312";

            byte[]  bytes       = System.Text.Encoding.Default.GetBytes(str);
            FtpUtil _ftp        = new FtpUtil();
            string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.Certifacate.ToString(), "behind_" + memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), Guid.NewGuid().ToString());
            string  dicpathfull = dicpath + ".html";
            string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);

            _ftp.UploadFile(certifapath, bytes, true);
            return(dicpathfull);
        }
        public void SftpValidateNegativeTestInvalidCipher()
        {
            string  fileName   = Guid.NewGuid().ToString();
            string  folderPath = Guid.NewGuid().ToString();
            FtpUtil ftpUtil    = new FtpUtil(true);

            NameValueCollection namevalue = ftpUtil.GetNameValueCollection(false, true);

            namevalue.Add("AcceptAnySSHServerHostKey", "true");
            namevalue.Add("EncryptCipher", "Des");

            IFTPConnectorTest connectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(namevalue);
            var message = connectorTest.UploadFile(Constants.UploadContents, folderPath, fileName);

            Assert.AreEqual(message.StatusCode, HttpStatusCode.BadRequest, "Could not validate correctly");
        }
        public void SftpValidateNegativeTestForVerifyPrivateKeyMultiFactAuthServerInvalidUser()
        {
            string  fileName   = Guid.NewGuid().ToString();
            string  folderPath = Guid.NewGuid().ToString();
            FtpUtil ftpUtil    = new FtpUtil(true, true);

            NameValueCollection namevalue = ftpUtil.GetNameValueCollection(false, true);

            namevalue.Add("AcceptAnySSHServerHostKey", "true");
            namevalue.Add("PrivateKey", Environment.CurrentDirectory + "/MultiFactorAuth.ppk");

            IFTPConnectorTest connectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(namevalue);

            var message = connectorTest.GetFile(folderPath, fileName);

            Assert.AreEqual(message.StatusCode, HttpStatusCode.BadRequest, "Could not validate correctly");
        }
        public void SftpValidateNegativeTestForServerAddress()
        {
            string  folderPath = Guid.NewGuid().ToString();
            FtpUtil ftpUtil    = new FtpUtil(true);

            NameValueCollection namevalue = ftpUtil.GetNameValueCollection(false, true);

            namevalue.Add("AcceptAnySSHServerHostKey", "false");
            namevalue.Set("SftpServerAddress", string.Empty);

            this.AddAuthenticationDetailsToIsolatedStorage(AuthenticationType.Password, namevalue["FtpUserName"], namevalue["FtpPassword"], MultiFactorAuthPpkResourceName, "rsa2048");
            IFTPConnectorTest connectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(namevalue);

            var message = connectorTest.ListFile(folderPath);

            Assert.AreEqual(message.StatusCode, HttpStatusCode.BadRequest, "Could not validate correctly");
        }
        public void SftpValidateNegativeTestForInvalidEncryptCipher()
        {
            string  fileName   = Guid.NewGuid().ToString();
            string  folderPath = Guid.NewGuid().ToString();
            FtpUtil ftpUtil    = new FtpUtil(true);

            NameValueCollection namevalue = ftpUtil.GetNameValueCollection(false, true);

            namevalue.Add("EncryptCipher", Guid.NewGuid().ToString());

            this.AddAuthenticationDetailsToIsolatedStorage(AuthenticationType.Password, namevalue["FtpUserName"], namevalue["FtpPassword"], MultiFactorAuthPpkResourceName, ftpUtil.SftpPrivateKeyPassword);
            IFTPConnectorTest connectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(namevalue);

            var message = connectorTest.DeleteFile(folderPath, fileName);

            Assert.AreEqual(message.StatusCode, HttpStatusCode.BadRequest, "Could not validate correctly");
        }
        public void SftpValidateNegativeInvalidUsername()
        {
            string  fileName   = Guid.NewGuid().ToString();
            string  folderPath = Guid.NewGuid().ToString();
            FtpUtil ftpUtil    = new FtpUtil(true);

            NameValueCollection namevalue = ftpUtil.GetNameValueCollection(false, true);

            namevalue.Add("AcceptAnySSHServerHostKey", "true");
            namevalue.Set("FtpUserName", Guid.NewGuid().ToString());

            this.AddAuthenticationDetailsToIsolatedStorage(AuthenticationType.Password, namevalue["FtpUserName"], namevalue["FtpPassword"], MultiFactorAuthPpkResourceName, namevalue["PrivateKeyPassword"]);
            IFTPConnectorTest connectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(namevalue);

            var message = connectorTest.UploadFile(Constants.UploadContents, folderPath, fileName);

            Assert.AreEqual(message.StatusCode, HttpStatusCode.BadRequest, "Could not validate correctly");
        }
        public void SftpValidateNegativeTestForVerifyPrivateKey()
        {
            string              fileName   = Guid.NewGuid().ToString();
            string              folderPath = Guid.NewGuid().ToString();
            FtpUtil             ftpUtil    = new FtpUtil(true);
            NameValueCollection namevalue  = ftpUtil.GetNameValueCollection(false, true);

            namevalue.Add("AcceptAnySSHServerHostKey", "true");
            namevalue.Add("PrivateKey", Environment.CurrentDirectory + "/rsa2048.ppk");
            namevalue.Add("PrivateKeyPassword", Guid.NewGuid().ToString());
            namevalue.Add("FtpPassword", Guid.NewGuid().ToString());

            this.AddAuthenticationDetailsToIsolatedStorage(AuthenticationType.MultiFactor, namevalue["FtpUserName"], namevalue["FtpPassword"], Rsa2048ResourceName, namevalue["PrivateKeyPassword"]);
            IFTPConnectorTest connectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(namevalue);

            var message = connectorTest.GetFile(folderPath, fileName);

            Assert.AreEqual(message.StatusCode, HttpStatusCode.BadRequest, "Could not validate correctly");
        }
Пример #22
0
        public string UploadLicense()
        {
            int    memid    = CookieBLL.GetRegisterCookie();
            string memcodes = "";

            if (memid <= 0)
            {
                if (System.Web.HttpContext.Current.Session[CommonKey.MobileNoRegister] != null && System.Web.HttpContext.Current.Session[CommonKey.MobileYZCode] != null)
                {
                    memcodes = System.Web.HttpContext.Current.Session[CommonKey.MobileNoRegister].ToString();
                }
            }
            else
            {
                memcodes      = memid.ToString();
                ViewBag.MemId = memid;
            }
            if (!string.IsNullOrEmpty(memcodes))
            {
                HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
                int             aa       = files.Count;
                int             _pictype = FormString.IntSafeQ("pictype");
                HttpPostedFile  file     = System.Web.HttpContext.Current.Request.Files[0];
                CertificateType _certype = (CertificateType)_pictype;
                if (file != null)
                {
                    byte[] bytes = null;
                    using (var binaryReader = new BinaryReader(file.InputStream))
                    {
                        bytes = binaryReader.ReadBytes(file.ContentLength);
                    }
                    FtpUtil _ftp        = new FtpUtil();
                    Random  _rd         = new Random();
                    string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.Certifacate.ToString(), memcodes, DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), _rd.Next(100000, 999999).ToString());
                    string  dicpathfull = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));
                    string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                    _ftp.UploadFile(certifapath, bytes, true);
                    //return dicpathfull;
                    return("{\"jsonrpc\" : \"2.0\", \"result\" : null, \"pic_raw\" : \"" + dicpathfull + "\"}");
                }
            }
            return("");
        }
        public void SftpValidatePositiveTestValidAesCipher()
        {
            string        folderPath    = Guid.NewGuid().ToString();
            FTPTestHelper ftpTestHelper = new FTPTestHelper(true);

            ftpTestHelper.CreateFolder(folderPath);
            FtpUtil ftpUtil = new FtpUtil(true);

            NameValueCollection namevalue = ftpUtil.GetNameValueCollection(false, true);

            namevalue.Add("AcceptAnySSHServerHostKey", "true");
            namevalue.Add("EncryptCipher", "Aes");

            this.AddAuthenticationDetailsToIsolatedStorage(AuthenticationType.Password, namevalue["FtpUserName"], namevalue["FtpPassword"], MultiFactorAuthPpkResourceName, ftpUtil.SftpPrivateKeyPassword);
            IFTPConnectorTest connectorTest = new FileBasedProtocolConnectorClientTest <SFTPController>(namevalue);

            var message = connectorTest.ListFile(folderPath);

            Assert.AreEqual(message.StatusCode, HttpStatusCode.OK, "Could not validate correctly");
        }
Пример #24
0
        /// <summary>
        /// 上传用户头像
        /// </summary>
        /// <param name="imgBase64"></param>
        /// <returns>状态</returns>
        /// <remarks>2013-8-29 杨浩 添加</remarks>
        public Result UploadAvatar(string imgBase64)
        {
            byte[] buffer = Convert.FromBase64String(imgBase64);
            var    ms     = new MemoryStream(buffer);

            //上传到FTP的路径
            string ftpPath = string.Format("{0}/{1}/{2}.jpg", FtpImageServer, BLL.Web.ProductThumbnailType.CustomerFace, CurrentUser.SysNo);
            //上传
            var ftp = new FtpUtil(FtpImageServer, FtpUserName, FtpPassword);

            ftp.Upload(ms, ftpPath);
            ms.Dispose();

            return(new Result
            {
                Status = true,
                StatusCode = 1,
                Message = "头像上传成功"
            });
        }
Пример #25
0
        /// <summary>
        /// 海关商检反馈信息
        /// </summary>
        /// <returns></returns>
        public override string[] GetCustomsOutResult(Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型 type)
        {
            FtpUtil ftp = new FtpUtil(config.NSIcpInfo.FtpUrl, config.NSIcpInfo.FtpName, config.NSIcpInfo.FtpPassword);

            string[] inflist = null;
            switch (type)
            {
            case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品检查:
                inflist = ftp.GetFileList(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.REPORT/out");
                break;

            case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品订单:
                inflist = ftp.GetFileList(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBEBTRADE.REPORT/out");
                break;

            case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品审核报文:
                inflist = ftp.GetFileList(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.AUDIT/out");
                break;
            }
            return(inflist);
        }
Пример #26
0
        private void NotifyIpChanged(string oldIp, string newIp)
        {
            log.Debug(string.Format("Notifying that the IP has changed. OLD: {0} - NEW: {1}", oldIp, newIp));

            string ftpPath = ConfigurationManager.AppSettings["ftpPath"];
            string ftpUser = ConfigurationManager.AppSettings["ftpUser"];
            string ftpPwd  = ConfigurationManager.AppSettings["ftpPwd"];

            try
            {
                FtpUtil.UploadText(ftpPath, ftpUser, ftpPwd, newIp);
            }
            catch (UriFormatException ex)
            {
                throw new ArgumentException(string.Format("Verify the ftpPath setting within appSettings section is correct; it commonly should start with \"ftp://\" - ftpPath: {0}", ftpPath), ex);
            }
            catch (WebException ex)
            {
                throw new ArgumentException(string.Format("Verify both ftpUser and ftpPwd settings within appSettings section are correct - ftpUser: {0} - ftpPwd: {0}", ftpUser, ftpPwd), ex);
            }
        }
Пример #27
0
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="img">图片信息</param>
        /// <returns>上传结果</returns>
        /// <remarks>2013-09-10 朱成果 实现</remarks>
        public Result SaveRmaImg(UpGradeRmaImage img)
        {
            var result = new Result()
            {
                Status = true
            };

            try
            {
                if (img.FileData != null)
                {
                    using (var ms = new MemoryStream(img.FileData))
                    {
                        string filePath = "RMA/" + img.FileName;
                        var    ftp      = new FtpUtil(FtpImageServer, FtpUserName, FtpPassword);
                        var    flg      = ftp.Upload(ms, FtpImageServer + filePath);//FTP上传
                        if (flg)
                        {
                            result.Message = img.ImageUrl = filePath;//图片存相对路径方便迁移
                        }
                    }
                }
                ////退换货图片
                //if (!string.IsNullOrEmpty(img.ImageUrl))
                //{
                //    BLL.RMA.RmaBo.Instance.InsertRMAImg(new RcReturnImage()
                //    {
                //        ImageUrl = img.ImageUrl,
                //        ReturnSysNo = img.ReturnSysNo
                //    });
                //}
            }
            catch (Exception ex)
            {
                result.Message = "图片上传错误";
                result.Status  = false;
            }
            return(result);
        }
Пример #28
0
        public string UploadImageFileForBit()
        {
            int    _pictype = QueryString.IntSafeQ("pictype");
            string filename = QueryString.SafeQ("name");

            using (Stream filesStream = System.Web.HttpContext.Current.Request.InputStream)
            {
                CertificateType _certype = (CertificateType)_pictype;
                byte[]          bytes    = new byte[filesStream.Length];
                filesStream.Read(bytes, 0, bytes.Length);
                // 设置当前流的位置为流的开始
                filesStream.Seek(0, SeekOrigin.Begin);
                FtpUtil _ftp        = new FtpUtil();
                Random  _rd         = new Random();
                string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, _certype.ToString(), memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), _rd.Next(100000, 999999).ToString());
                string  dicpathfull = dicpath + filename.Substring(filename.LastIndexOf("."));
                string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                _ftp.UploadFile(certifapath, bytes, true);
                return("{\"jsonrpc\" : \"2.0\", \"result\" : null, \"pic_raw\" : \"" + dicpathfull + "\"}");
            }

            return("");
        }
Пример #29
0
        /// <summary>
        /// 下载xml文件
        /// 2015-10-09 王耀发 创建
        /// </summary>
        /// <param name="RequestText"></param>
        public static string DownloadXmlFile(string RequestText)
        {
            //RequestText = "{\"FileName\":\"880020201510101023450000.xml\"}";
            var     jsonObject      = JObject.Parse(RequestText);
            string  FileName        = jsonObject["FileName"].ToString();
            string  _ftpImageServer = ApiConfig.FtpUrl + "DOWNLOAD/";
            string  _ftpUserName    = ApiConfig.FtpUserName;
            string  _ftpPassword    = ApiConfig.FtpPassword;
            FtpUtil ftp             = new FtpUtil(_ftpImageServer, _ftpUserName, _ftpPassword);
            string  msg             = "";

            ftp.DownloadFile(_ftpImageServer + FileName, HttpContext.Current.Server.MapPath("~/Xml"), out msg);
            StreamReader objReader = new StreamReader(HttpContext.Current.Server.MapPath("~/Xml") + "\\" + FileName);
            string       sLine     = objReader.ReadToEnd();

            objReader.Close();
            //删除对应文件
            if (File.Exists(HttpContext.Current.Server.MapPath("~/Xml") + "\\" + FileName))
            {
                File.Delete(HttpContext.Current.Server.MapPath("~/Xml") + "\\" + FileName);
            }
            return(AESHelper.Decrypt(sLine));
        }
Пример #30
0
        public void ProcessRawPackagesFromFtpServer()
        {
            // Can support process local file if web server, ftp server, file download server on the same physical machine
            string fileServerIpAddress = GetFileServerIpAddress();
            int    fileServerPort      = GetFileServerPort();

            string serverUrl = FtpUtil.GetFileServerUrl(fileServerIpAddress, 21, "subset");

            FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(serverUrl);

            ftpRequest.Method      = WebRequestMethods.Ftp.ListDirectory;
            ftpRequest.Credentials = FtpUtil.GetFileServerCredential();

            FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();

            string[] directoryOrFileNames;
            using (Stream responseStream = ftpResponse.GetResponseStream())
            {
                StreamReader reader = new StreamReader(responseStream);
                string       result = reader.ReadToEnd();
                directoryOrFileNames = String.IsNullOrEmpty(result) ? null : result.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            }

            List <string> filteredResult = new List <string>();

            for (int i = 0; i < directoryOrFileNames.Length; i++)
            {
                string fileName = directoryOrFileNames[i];
                if (fileName.EndsWith(".zip"))
                {
                    string serverFileFullPath = string.Format("{0}/{1}", serverUrl, fileName);
                    FtpUtil.ProcessSourceFileFromFTPServer(serverFileFullPath, @"C:\GmuTemp");
                }
            }

            // Upload processed file back to ftp server
        }