Example #1
0
        /// <summary>
        /// 执行检出操作
        /// </summary>
        /// <param name="repositoryPath">svn服务器路径</param>
        /// <param name="workDirectory">工程本地工作路径</param>
        /// <param name="svnPath">本地svn路径</param>
        /// <param name="checkResult">检出操作的结果</param>
        /// <returns>返回检出操作的日志</returns>
        public string CheckOut(string repositoryPath, string workDirectory, out string checkResult, string xmlConfigPath)
        {
            string      err;
            string      time;
            XmlDao      xmlDao      = new XmlDao();
            XmlNodeList xmlNodeList = xmlDao.XmlQuery("config/preferences/SvnPath", xmlConfigPath);
            string      svnPath     = xmlNodeList[0].InnerText;

            using (SvnClient client = new SvnClient())
            {
                Tools  tools       = new Tools();
                string checkOutLog = "";
                try
                {
                    client.CheckOut(new Uri(repositoryPath), workDirectory);
                    string args = "checkout " + repositoryPath + " " + workDirectory;
                    checkOutLog = tools.BuildProject(svnPath, args, null, out err, out time);
                    checkResult = "successful";
                    return(checkOutLog);
                }
                catch (Exception ex)
                {
                    checkResult = " failed";
                    checkOutLog = ex.Message;
                    return(checkOutLog);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 查询配置信息
        /// </summary>
        /// <param name="dataPath">节点路径</param>
        /// <param name="xmlConfigPath">查询的xml文件路径</param>
        /// <returns></returns>
        public ConfigInfo ConfigQuery(string dataPath, string xmlConfigPath)
        {
            ConfigInfo configInfo = new ConfigInfo();
            XmlDao     xmlDao     = new XmlDao();

            try
            {
                XmlNodeList xmlNodeList = xmlDao.XmlQuery(dataPath, xmlConfigPath);
                configInfo.Svnpath        = xmlNodeList[0].SelectSingleNode("SvnPath").InnerText;
                configInfo.Updateinterval = xmlNodeList[0].SelectSingleNode("UpdateInterval").InnerText;
                configInfo.StandarOutput  = xmlNodeList[0].SelectSingleNode("StandarOutput").InnerText;
                configInfo.ServiceSwitch  = xmlNodeList[0].SelectSingleNode("ServiceSwitch").InnerText;
                return(configInfo);
            }
            catch (Exception)
            {
                return(configInfo);
            }
        }
Example #3
0
        /// <summary>
        /// 获取gitlab信息
        /// </summary>
        /// <param name="dataPath">节点路径</param>
        /// <param name="xmlConfigPath">xml路径</param>
        /// <returns></returns>
        public GitInfo GitInfoQuery(string dataPath, string xmlConfigPath)
        {
            GitInfo gitlabInfo = new GitInfo();
            XmlDao  xmlDao     = new XmlDao();

            try
            {
                XmlNodeList xmlNodeList = xmlDao.XmlQuery(dataPath, xmlConfigPath);
                gitlabInfo.Username     = xmlNodeList[0].SelectSingleNode("Username").InnerText;
                gitlabInfo.Password     = xmlNodeList[0].SelectSingleNode("Password").InnerText;
                gitlabInfo.Emailaddress = xmlNodeList[0].SelectSingleNode("Email").InnerText;
                gitlabInfo.Gitreversion = xmlNodeList[0].SelectSingleNode("GitReversion").InnerText;
                return(gitlabInfo);
            }
            catch (Exception)
            {
                return(gitlabInfo);
            }
        }
Example #4
0
        /// <summary>
        /// 执行更新操作
        /// </summary>
        /// <param name="workDirectory">工程本地工作路径</param>
        /// <param name="svnPath">svn程序的路径</param>
        /// <param name="updateResult">更新操作的结果</param>
        /// <returns>返回更新操作的日志</returns>
        public string Update(string workDirectory, out string updateResult, string xmlConfigPath)
        {
            string      err;
            string      time;
            Tools       tools       = new Tools();
            XmlDao      xmlDao      = new XmlDao();
            XmlNodeList xmlNodeList = xmlDao.XmlQuery("config/preferences/SvnPath", xmlConfigPath);
            string      svnPath     = xmlNodeList[0].InnerText;
            string      updateLog   = "";

            try
            {
                string args = "update --accept tf" + " " + workDirectory;
                updateLog    = tools.BuildProject(svnPath, args, null, out err, out time);
                updateResult = "successful";
                return(updateLog);
            }
            catch (Exception ex)
            {
                updateResult = "failed";
                updateLog    = ex.Message;
                return(updateLog);
            }
        }
        /// <summary>
        /// 执行获取所有符合要求的项目信息列表
        /// </summary>
        /// <param name="dataPath">查询的节点路径</param>
        /// <param name="b">true:项目信息;false:最近一次编译信息</param>
        /// <returns>返回查寻完毕的信息列表</returns>
        public List <ProjectInfo> ProjectQuery(string dataPath, bool b, string xmlPath)
        {
            List <ProjectInfo> projectInfos = new List <ProjectInfo>();

            //检测infostatics中有没有包括提交的项目,分别赋值
            if (xmlPath.Contains("InfoStatics.xml"))
            {
                XmlNodeList xmlNodeList = dao.XmlQuery(dataPath, xmlPath);
                if (xmlNodeList.Count != 0)
                {
                    foreach (XmlNode xmlNode in xmlNodeList)
                    {
                        ProjectInfo projectInfo = new ProjectInfo();
                        projectInfo.Nameproperty = xmlNode.Attributes["Name"].Value;
                        projectInfos.Add(projectInfo);
                    }
                }
                return(projectInfos);
            }
            else
            {
                if (b)
                {
                    try
                    {
                        XmlNodeList xmlNodeList = dao.XmlQuery(dataPath, xmlPath);
                        foreach (XmlNode xmlNode in xmlNodeList)
                        {
                            ProjectInfo projectInfo = new ProjectInfo();
                            projectInfo.Statusproperty = xmlNode.Attributes["Status"].Value;
                            projectInfo.Nameproperty   = xmlNode.Attributes["Name"].Value;
                            projectInfo.BuildCommand   = xmlNode.SelectSingleNode("BuildCommand").InnerText;
                            projectInfo.RepositoryPath = xmlNode.SelectSingleNode("RepositoryPath").InnerText;
                            projectInfo.WorkDirectory  = xmlNode.SelectSingleNode("WorkingDirectory").InnerText;
                            projectInfo.MailTo         = xmlNode.SelectSingleNode("MailTo").InnerText;
                            projectInfo.IfMail         = xmlNode.SelectSingleNode("IfMail").InnerText;
                            projectInfo.IfSlack        = xmlNode.SelectSingleNode("IfSlack").InnerText;
                            projectInfo.SlackUrl       = xmlNode.SelectSingleNode("SlackUrl").InnerText;
                            projectInfo.MailHost       = xmlNode.SelectSingleNode("MailHost").InnerText;
                            projectInfo.UserName       = xmlNode.SelectSingleNode("UserName").InnerText;
                            projectInfo.Password       = xmlNode.SelectSingleNode("Password").InnerText;
                            projectInfo.SlackChannel   = xmlNode.SelectSingleNode("SlackChannel").InnerText;
                            projectInfo.SlackUser      = xmlNode.SelectSingleNode("SlackUser").InnerText;
                            projectInfo.SlackContent   = xmlNode.SelectSingleNode("SlackContent").InnerText;
                            projectInfo.SelectResult   = xmlNode.SelectSingleNode("SlackResult").InnerText;
                            projectInfo.SelectCommit   = xmlNode.SelectSingleNode("SlackCommit").InnerText;
                            projectInfo.SelectUpdate   = xmlNode.SelectSingleNode("SlackUpdate").InnerText;
                            projectInfo.GitVersion     = xmlNode.SelectSingleNode("GitVersion").InnerText;
                            projectInfo.ProjectType    = xmlNode.SelectSingleNode("ProjectType").InnerText;
                            projectInfos.Add(projectInfo);
                        }
                        return(projectInfos);
                    }
                    catch (Exception)
                    {
                        return(projectInfos);
                    }
                }
                else
                {
                    ProjectInfo projectInfo = new ProjectInfo();
                    XmlNodeList xmlNodeList = dao.XmlQuery(dataPath, xmlPath);
                    projectInfo.Nameproperty = xmlNodeList[0].SelectSingleNode("projectName").InnerText;
                    projectInfo.BuildTime    = xmlNodeList[0].SelectSingleNode("buildTime").InnerText;
                    projectInfo.Duration     = xmlNodeList[0].SelectSingleNode("duration").InnerText;
                    projectInfo.Result       = xmlNodeList[0].SelectSingleNode("result").InnerText;
                    projectInfo.Index        = xmlNodeList[0].SelectSingleNode("index").InnerText;
                    projectInfos.Add(projectInfo);
                    return(projectInfos);
                }
            }
        }
Example #6
0
        /// <summary>
        /// 查询配置信息
        /// </summary>
        /// <param name="nodePath"></param>
        /// <returns></returns>
        public XmlNodeList FindConfigInfo(string nodePath, string xmlConfigPath)
        {
            XmlDao dao = new XmlDao();

            return(dao.XmlQuery(nodePath, xmlConfigPath));
        }
Example #7
0
        /// <summary>
        /// 获取人名对应表
        /// </summary>
        /// <param name="nodePath">人名对应表节点路径</param>
        /// <param name="xmlPath">存放对应表的xml文件路径</param>
        /// <returns></returns>
        public XmlNodeList AcquireSlackPeople(string nodePath, string xmlPath)
        {
            XmlDao dao = new XmlDao();

            return(dao.XmlQuery(nodePath, xmlPath));
        }