예제 #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;
         }
     }
 }
예제 #2
0
 /// <summary>
 /// 执行添加项目操作
 /// </summary>
 /// <param name="childNodes">Projects节点下的节点集</param>
 /// <param name="property">Projects的节点属性集</param>
 /// <param name="xmlConfigPath">添加Projects的xml文件</param>
 /// <returns></returns>
 public string AddProject(Dictionary<string,string> childNodes  ,Dictionary<string,string> property,
     string xmlConfigPath)
 {
     XmlDao xmlDao = new XmlDao();
     string result = "";
     Dictionary<string,string> projectNode = new Dictionary<string, string>();
     projectNode.Add("Projects",null);
     XElement xElement = xmlDao.AddXElement(projectNode, property, xmlConfigPath);
     result = xmlDao.AddXNode(childNodes, xElement, xmlConfigPath);
     return result;
 }
예제 #3
0
 /// <summary>
 /// 激活或者关闭项目
 /// </summary>
 /// <param name="nodePath">路径</param>
 /// <param name="name">项目名字</param>
 /// <param name="value">修改后的名字</param>
 /// <returns></returns>
 public string ActiveClose(Dictionary<string,string> project,Dictionary<string,string> property,string nodePath,string xmlConfigPath)
 {
     XmlDao xmlDao = new XmlDao();
     try
     {
         XElement xElement = xmlDao.SelectOneXElement(project, xmlConfigPath, nodePath);
         xmlDao.XNodeAttributes(property, xElement, xmlConfigPath);
         return "successful";
     }
     catch(Exception exception)
     {
         MessageBox.Show(exception.Message);
         return "failed";
     }
 }
예제 #4
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;
     }
 }
예제 #5
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;
     }
 }
예제 #6
0
 /// <summary>
 /// 执行保存已经修改的ConfigInfo
 /// </summary>
 /// <param name="configInfo">传入configInfo实例对象</param>
 /// <param name="xmlConfigPath">修改的xml文件</param>
 /// <returns></returns>
 public string SaveConfig(ConfigInfo configInfo,string xmlConfigPath)
 {
     string modifyPath = "preferences";
     string result = "";
     var value = new Dictionary<string, string>();
     value.Add("SvnPath",configInfo.Svnpath);
     value.Add("UpdateInterval",configInfo.Updateinterval);
     value.Add("StandarOutput",configInfo.StandarOutput);
     value.Add("ServiceSwitch", configInfo.ServiceSwitch);
     try
     {
         XmlDao xmlDao = new XmlDao();
         XElement xElement = xmlDao.SelectOneXElement(null, xmlConfigPath, modifyPath);
         result = xmlDao.ModifyXNode(value, xElement, xmlConfigPath);
         return result;
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         result = "failed";
         return result;
     }
 }
예제 #7
0
 /// <summary>
 /// 存储Log(按版本号增加Log节点
 /// </summary>
 /// <param name="value">需要修改的子节点的键值对</param>
 /// <param name="property">需要筛选的属性值的键值对</param>
 /// <param name="xmlPath">xml文件的路径</param>
 /// <param name="nodePath">节点的路径</param>
 /// <returns></returns>
 public string SaveLog(ProjectInfo projectInfo, Dictionary<string, string> property, string xmlPath,
     string nodePath)
 {
     XmlDao xmlDao = new XmlDao();
     var logInfo = new Dictionary<string,string>();
     var logProperty = new Dictionary<string,string>();
     logInfo.Add("Log",projectInfo.Log);
     logProperty.Add("Revision",projectInfo.Revision);
     logProperty.Add("Result",projectInfo.Result);
     logProperty.Add("Time",DateTime.Now.ToString());
     string result = "";
     XElement xElement = xmlDao.SelectOneXElement(property, xmlPath, nodePath);
     xmlDao.AddXNode(logInfo, xElement, xmlPath);
     xElement = xmlDao.SelectOneXElement(property, xmlPath, nodePath);
     result = xmlDao.XNodeAttributes(logProperty, xElement.Elements("Log").Last(), xmlPath);
     return result;
 }
예제 #8
0
        /// <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>();
            XmlDao xmlDao = new XmlDao();
            if (b)
            {
                try
                {

                    XmlNodeList xmlNodeList = xmlDao.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;
                        projectInfos.Add(projectInfo);
                    }
                    return projectInfos;
                }
                catch (Exception)
                {
                    return projectInfos;
                }
            }
            else
            {
                ProjectInfo projectInfo = new ProjectInfo();
                XmlNodeList xmlNodeList = xmlDao.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;
            }
        }
예제 #9
0
 /// <summary>
 /// 执行修改项目动态内容的操作(现有的,只修改不增加)
 /// </summary>
 /// <param name="value">需要修改的子节点的键值对</param>
 /// <param name="property">需要筛选的属性值的键值对</param>
 /// <param name="xmlPath">xml文件的路径</param>
 /// <param name="nodePath">节点的路径</param>
 /// <returns></returns>
 public string ModifyProject(Dictionary<string, string> projects, Dictionary<string, string> property,
     string xmlPath, string nodePath)
 {
     XmlDao xmlDao = new XmlDao();
     string result = "";
     XElement xElement = xmlDao.SelectOneXElement(property, xmlPath, nodePath);
     result = xmlDao.ModifyXNode(projects, xElement, xmlPath);
     return result;
 }
예제 #10
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);
 }
예제 #11
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);
 }
예제 #12
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;
     }
 }