Пример #1
0
 public FTPConnectionWrapper(FTPConnection ftp)
 {
     if (ftp != null)
     {
         this.ftp = ftp;
     }
     else
     {
         this.ftp = new FTPConnection();
     }
 }
Пример #2
0
        private void Connect()
        {
            if (connection != null && connection.IsConnected)
                return;

            connection = new FTPConnection();
            connection.Timeout = Timeout;
            connection.ServerAddress = account.Url;
            connection.UserName = account.UserName;
            connection.Password = account.Password;

            connection.Connect();
        }
Пример #3
0
 private void FtpUploader_DoWork(object sender, DoWorkEventArgs e)
 {
     this.ftp = new FTPConnection();
     try
     {
         this.args = (FtpUploaderArgs) e.Argument;
     }
     catch
     {
         this.Errors.Add(new ArgumentNullException("FtpUploader must be passed an instance of FtpUploaderArgs."));
         return;
     }
     string dir = (this.args.Platform == IsoEntryPlatform.Xbox360) ? "00007000" : "00005000";
     string str2 = string.Concat(new object[] { this.args.SourcePath, this.args.TitleID, Path.DirectorySeparatorChar, dir, Path.DirectorySeparatorChar });
     this.ftp.ServerAddress = this.args.Ip;
     this.ftp.UserName = this.args.User;
     this.ftp.Password = this.args.Pass;
     this.ftp.AutoLogin = true;
     try
     {
         this.ftp.Connect();
     }
     catch (Exception exception)
     {
         this.Errors.Add(exception);
         return;
     }
     this.ftp.ChangeWorkingDirectory("Hdd1/Content/0000000000000000");
     if (!this.dirExists(this.args.TitleID))
     {
         this.ftp.CreateDirectory(this.args.TitleID);
     }
     this.ftp.ChangeWorkingDirectory(this.args.TitleID);
     if (!this.dirExists(dir))
     {
         this.ftp.CreateDirectory(dir);
     }
     this.ftp.ChangeWorkingDirectory(dir);
     if (!this.dirExists(this.args.ContainerID + ".data"))
     {
         this.ftp.CreateDirectory(this.args.ContainerID + ".data");
     }
     else
     {
         this.clearDir(this.args.ContainerID + ".data");
     }
     if (this.fileExists(this.args.ContainerID))
     {
         this.ftp.DeleteFile(this.args.ContainerID);
     }
     base.ReportProgress(1, "Uploading GOD header...");
     FileStream srcStream = new FileStream(str2 + this.args.ContainerID, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
     this.ftp.UploadStream(srcStream, this.args.ContainerID);
     this.ftp.ChangeWorkingDirectory(this.args.ContainerID + ".data");
     int percentProgress = 0;
     string[] files = Directory.GetFiles(str2 + this.args.ContainerID + ".data");
     foreach (string str3 in files)
     {
         string remoteFile = str3.Substring(str3.LastIndexOf('\\') + 1);
         base.ReportProgress(percentProgress, "Uploading '" + remoteFile + "'...");
         FileStream stream2 = new FileStream(str3, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
         this.ftp.UploadStream(stream2, remoteFile);
         percentProgress += (int) Math.Floor((double) ((1f / ((float) files.Length)) * 100f));
     }
     this.ftp.Close();
     this.Errors.Clear();
     base.ReportProgress(100, "Uploaded");
 }
Пример #4
0
 public UtilFTP()
 {
     ftp = new FTPConnection();
 }
Пример #5
0
        public void LoadConf(XmlNode root)
        {
            XmlNode xn = null;
            try
            {
                // 读取显示属性

                log.WriteFileLog("读取产品信息");

                type = root.Attributes["type"].InnerText;
                product_id = root.Attributes["product_id"].InnerText;
                enable = bool.Parse(root.Attributes["enable"].InnerText);
                name = root.Attributes["name"].InnerText;
                funclist = root.Attributes["funclist"].InnerText;

                // 读取节点配置明细
                log.WriteFileLog("读取配置库信息");
                xn = root.SelectSingleNode("Repository");
                Repository = xn.Attributes["repo"].InnerText;
                WorkSpace = xn.Attributes["workspace"].InnerText;
                // OutDir 如果以 \ 结尾,会导致编译前台Drp时,批处理里会出现 "C:\src\", \"会被认为是转义,就报错了,
                // 这里如果,结尾是\,去掉
                if (WorkSpace[WorkSpace.Length - 1] == '\\')
                {
                    WorkSpace = WorkSpace.Substring(0, WorkSpace.Length - 1);
                }
                SvnRepo = new SvnPort(name, Repository);
                SvnRepo.Workspace = WorkSpace;

                // 读取修改单配置明细
                log.WriteFileLog("读取开发工具信息");
                xn = root.SelectSingleNode("Develop");
                DevTool = xn.Attributes["devtool"].InnerText;
                Rar = xn.Attributes["rar"].InnerText;
                OutDir = xn.Attributes["outdir"].InnerText;
                // OutDir 如果以 \ 结尾,会导致编译前台Drp时,批处理里会出现 "C:\src\", \"会被认为是转义,就报错了,
                // 这里如果,结尾是\,去掉
                if (OutDir[OutDir.Length - 1] == '\\')
                {
                    OutDir = OutDir.Substring(0, OutDir.Length - 1);
                }

                // 读取Ssh连接配置
                log.WriteFileLog("读取Ssh连接配置");
                xn = root.SelectSingleNode("SSHConn");
                Conn = new ReSSH(xn.Attributes["name"].InnerText,
                        xn.Attributes["host"].InnerText,
                        int.Parse(xn.Attributes["port"].InnerText),
                        xn.Attributes["user"].InnerText,
                        xn.Attributes["pass"].InnerText,
                        bool.Parse(xn.Attributes["restartas"].InnerText));
                Conn.localdir = OutDir;

                // 读取小球FTP路径递交配置
                log.WriteFileLog("读取小球FTP路径递交配置");
                xn = root.SelectSingleNode("CommitFtp");
                fc = new FtpConf();
                fc.host = xn.Attributes["host"].InnerText;
                fc.port = int.Parse(xn.Attributes["port"].InnerText);
                fc.user = xn.Attributes["user"].InnerText;
                fc.pass = xn.Attributes["pass"].InnerText;
                fc.ServerDir = xn.Attributes["remotedir"].Value;
                fc.LocalDir = xn.Attributes["localdir"].Value;
                if (fc.LocalDir[fc.LocalDir.Length - 1] == '\\')
                {
                    fc.LocalDir = fc.LocalDir.Substring(0, fc.LocalDir.Length - 1);
                }

                // 初始化 ftp配置
                ftp = new FTPConnection();
                ftp.ServerAddress = fc.host;
                ftp.ServerPort = fc.port;
                ftp.UserName = fc.user;
                ftp.Password = fc.pass;
                ftp.TransferType = FTPTransferType.BINARY;  // 指定 BINARY 传输,否则对于压缩包会失败
                ftp.CommandEncoding = Encoding.GetEncoding("gb2312"); // 重要,否则乱码且连接不

                log.WriteFileLog("读取对比参数");
                xn = root.SelectSingleNode("Diff");
                DiffEnable = bool.Parse(xn.Attributes["enable"].Value);
                DiffBin = xn.Attributes["bin"].Value;
                DiffArgs = xn.Attributes["args"].Value;

                log.WriteFileLog("读取Delphi编译版本配置");
                xn = root.SelectSingleNode("SpecialCom");
                SpeComs = new ArrayList();
                XmlNodeList xnl = xn.ChildNodes;
                foreach (XmlNode x in xnl)
                {
                    if (x.NodeType == XmlNodeType.Comment)
                        continue;
                    ComInfo com = new ComInfo(x.Attributes["lang"].Value,
                        int.Parse(x.Attributes["ver"].Value),
                        x.Attributes["coms"].Value);
                    SpeComs.Add(com);
                }

                // 读取数据库连接属性
                xn = root.SelectSingleNode("DB");
                xnl = xn.ChildNodes;
                foreach (XmlNode x in xnl)
                {
                    DBUser u = new DBUser(x.Attributes["name"].InnerText,
                        x.Attributes["pass"].InnerText,
                        x.Attributes["dbtns"].InnerText,
                        x.Attributes["note"].InnerText);
                    Users.Add(u);
                }

                // 读取公用递交配置
                try
                {
                    xn = root.SelectSingleNode("CommitPublic");
                    logmessage = xn.Attributes["logmessage"].Value;
                    xnl = xn.ChildNodes;
                    foreach (XmlNode x in xnl)
                    {
                        CommitPublic.Add(x.Attributes["dir"].InnerText);
                    }
                }
                catch
                {
                    log.WriteLog("无法读取公共递交资源CommitPublic!,请检查MAConf.xml配置");
                }
            }
            catch (Exception e)
            {
                log.WriteLog("加载配置失败,活动节点:" + xn.Name + e.Message, LogLevel.Error);
                throw new MissingFieldException("LoadConf");
            }
        }