示例#1
0
        public Boolean DeletePack(int v)
        {
            // 输出递交包,到本地集成环境处理,需要使用ftp连接
            FTPConnection ftp = MAConf.instance.Configs[ProductId].ftp;
            FtpConf       fc  = MAConf.instance.Configs[ProductId].fc;

            // 强制重新连接,防止时间长了就断掉了
            if (ftp.IsConnected == false)
            {
                try
                {
                    ftp.Connect();
                }
                catch (Exception e)
                {
                    log.WriteErrorLog("连接FTP服务器失败,错误信息:" + e.Message);
                }
            }

            if (ftp.DirectoryExists(RemoteDir) == false)
            {
                System.Windows.Forms.MessageBox.Show("FTP路径" + RemoteDir + "不存在!");
                return(false);
            }

            //ftp.ChangeWorkingDirectory(fc.ServerDir);
            ftp.DeleteFile(RemoteFile);

            return(true);
        }
示例#2
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");
            }
        }
示例#3
0
        // 获取FTP递交信息
        public Boolean QueryFTP()
        {
            log.WriteInfoLog("查询FTP目录信息...");
            // 输出递交包,到本地集成环境处理,需要使用ftp连接
            FTPConnection ftp = MAConf.instance.Configs[ProductId].ftp;
            FtpConf       fc  = MAConf.instance.Configs[ProductId].fc;
            string        s;

            // 强制重新连接,防止时间长了就断掉了
            if (ftp.IsConnected == false)
            {
                try
                {
                    ftp.Connect();
                }
                catch (Exception e)
                {
                    log.WriteErrorLog("连接FTP服务器失败,错误信息:" + e.Message);
                    return(false);
                }
            }

            // 取递交版本信息,确认要输出哪个版本的压缩包,确保只刷出最大的版本
            // 这个地方,应该是如果存在集成的文件夹,就刷出集成的文件夹,
            // 对于V1,是全部都需要集成,对于Vn(n>1),只集成变动的部分就可以了
            if (ftp.DirectoryExists(RemoteDir) == false)
            {
                System.Windows.Forms.MessageBox.Show("FTP路径" + RemoteDir + "不存在!");
                return(false);
            }
            ftp.ChangeWorkingDirectory(fc.ServerDir);

            // 不使用 true 列举不出目录,只显示文件,很奇怪
            //string[] files = ftp.GetFiles(fc.ServerDir + ap.CommitPath, true);
            string[] files = ftp.GetFiles(RemoteDir);

            log.WriteInfoLog("查询FTP目录信息...完成");

            #region 确定修改单基本属性
            // 检查是否存在集成*的文件夹
            // 获取当前的版本信息,先标定版本信息
            SubmitL.Clear();
            ScmL.Clear();
            ScmSrc.Clear();
            foreach (string f in files) //查找子目录
            {
                // 跳过 src-V*.rar 之类的东东
                if (f.IndexOf("集成-src-V") >= 0 || f.IndexOf("集成-Src-V") >= 0)
                {
                    ScmSrc.Add(f);
                }
                else if (f.IndexOf(MainNo) < 0)
                {
                    continue;
                }
                else if (f.IndexOf("集成") == 0)
                {
                    ScmL.Add(f);
                }
                else
                {
                    SubmitL.Add(f);
                }
            }

            string currVerFile = string.Empty;// 20111123054-国金短信-李景杰-20120117-V3.rar
            if (SubmitL.Count > 0)
            {
                SubmitL.Sort();
                s           = SubmitL[SubmitL.Count - 1].ToString();
                currVerFile = s;
                // 取递交版本号
                // 20111207012-委托管理-高虎-20120116-V13.rar --> 20111207012-委托管理-高虎-20120116-V13 -> 13
                s         = s.Substring(0, s.LastIndexOf('.'));
                SubmitVer = int.Parse(s.Substring(s.LastIndexOf('V') + 1));
            }
            else
            {
                SubmitVer = 0;
            }

            // 生成一些上次集成的变量,需要把上次的覆盖到本次来
            if (ScmL.Count > 1)  // 重复集成
            {
                ScmL.Sort();
                s = ScmL[ScmL.Count - 1].ToString();
                // 取递交版本号
                // 20111207012-委托管理-高虎-20120116-V13.rar --> 20111207012-委托管理-高虎-20120116-V13 -> 13
                s        = s.Substring(0, s.LastIndexOf('.'));
                ScmVer   = int.Parse(s.Substring(s.LastIndexOf('V') + 1));
                ScmedVer = ScmVer;
                // 如果存在对应的src文件夹,一并删除掉
                if (ScmVer == SubmitVer)
                {
                    ScmL.RemoveAt(ScmL.Count - 1);

                    if (ScmSrc.Count > 1)
                    {
                        ScmSrc.Sort();
                        if (ScmSrc.IndexOf("集成-src-V" + ScmVer + ".rar") >= 0 ||
                            ScmSrc.IndexOf("集成-Src-V" + ScmVer + ".rar") >= 0)
                        {
                            ScmSrc.RemoveAt(ScmSrc.Count - 1);
                        }
                    }
                }
            }


            string dir = Path.GetFileNameWithoutExtension(currVerFile);

            //AmendDir = LocalDir + "\\" + dir;
            SCMAmendDir = Path.Combine(LocalDir, "集成-" + dir);

            ScmVer     = SubmitVer;
            LocalFile  = Path.Combine(LocalDir, currVerFile);
            RemoteFile = LocalFile.Replace(LocalDir, RemoteDir);

            SCMLocalFile  = Path.Combine(SCMAmendDir, "集成-" + currVerFile);
            SCMRemoteFile = SCMLocalFile.Replace(SCMAmendDir, RemoteDir);

            SrcRar          = Path.Combine(SCMAmendDir, "src-V" + ScmVer.ToString() + ".rar");
            SCMSrcRar       = Path.Combine(SCMAmendDir, "集成-src-V" + ScmVer.ToString() + ".rar");
            SCMRemoteSrcRar = SCMSrcRar.Replace(SCMAmendDir, RemoteDir);

            if (ScmL.Count > 0)
            {
                ScmL.Sort();
                s   = ScmL[ScmL.Count - 1].ToString();
                dir = Path.GetFileNameWithoutExtension(s);
                // 上次数据
                SCMLastAmendDir   = Path.Combine(LocalDir, dir);
                SCMLastLocalFile  = Path.Combine(SCMLastAmendDir, s);
                ScmLastRemoteFile = Path.Combine(RemoteDir, s);

                // 取递交版本号
                // 20111207012-委托管理-高虎-20120116-V13.rar --> 20111207012-委托管理-高虎-20120116-V13 -> 13
                s                   = s.Substring(0, s.LastIndexOf('.'));
                SCMLastVer          = int.Parse(s.Substring(s.LastIndexOf('V') + 1));
                SCMLastLocalSrcRar  = Path.Combine(SCMLastAmendDir, "集成-src-V" + SCMLastVer.ToString() + ".rar");
                ScmLastRemoteSrcRar = Path.Combine(RemoteDir, "集成-src-V" + SCMLastVer.ToString() + ".rar");
            }
            else
            {
                SCMLastVer = 0;
            }

            if (ScmedVer == 0)
            {
                ScmedVer = SCMLastVer;
            }

            if (ScmSrc.Count > 0)
            {
                ScmSrc.Sort();
                s = ScmSrc[ScmSrc.Count - 1].ToString();
                SCMLastLocalSrcRar  = Path.Combine(SCMLastAmendDir, s);
                ScmLastRemoteSrcRar = Path.Combine(RemoteDir, s);
            }

            // 决定是新集成还是修复集成还是重新集成
            if (ScmVer == 0 || (ScmVer == 1 && SubmitVer == 1))  // 第一次集成
            {
                scmtype = ScmType.NewScm;
            }
            else if (SCMLastVer <= SubmitVer) // 重新集成也当成修复集成
            {
                scmtype = ScmType.BugScm;     // 修复集成
            }
            #endregion

            return(true);
        }
示例#4
0
文件: MAConf.cs 项目: radtek/wscope
        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");
            }
        }