ProjectQuery() public method

执行获取所有符合要求的项目信息列表
public ProjectQuery ( string dataPath, bool b, string xmlPath ) : List
dataPath string 查询的节点路径
b bool true:项目信息;false:最近一次编译信息
xmlPath string
return List
Exemplo n.º 1
0
 /// <summary>
 /// 计时器触发函数timer_Tick
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void timer_Tick(object sender, EventArgs e)
 {
     string datePath = "config/lastest";
     ProjectController projectController = new ProjectController();
     List<ProjectInfo> lastestInfos = new List<ProjectInfo>();
     lastestInfos = projectController.ProjectQuery(datePath, false, "../../../common/res/LastestInfo.xml");
     if (lastestInfos[0].Result != "running")
     {
         lastRe.Text = lastestInfos[0].Result;
     }
     buildRe.Text = lastestInfos[0].Result;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 保存信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            ProjectController projectController = new ProjectController();
            if (respoPath.Text == ""
                || projectName.Text == ""
                || Workspace.Text == ""
                || Mailto.Text == ""
                || Buildcomand.Text == "")
            {
                MessageBox.Show("请先填写完整的信息!");
            }
            else if (Username.Text == "#author#@domain.com")
            {
                MessageBox.Show("请修改默认发件人");
            }
            else
            {
                //存储前台输入的信息

                var childNodes = new Dictionary<string, string>();
                var property = new Dictionary<string, string>();
                childNodes.Add("RepositoryPath", respoPath.Text);
                childNodes.Add("WorkingDirectory", Workspace.Text);
                childNodes.Add("MailTo", Mailto.Text);
                childNodes.Add("BuildCommand", Buildcomand.Text);
                childNodes.Add("IfSlack", CheckSlack.IsChecked.ToString().ToLower());
                childNodes.Add("IfMail", CheckMail.IsChecked.ToString().ToLower());
                childNodes.Add("SlackUrl", SlackUrl.Text);
                childNodes.Add("SlackChannel", SlackChannel.Text);
                childNodes.Add("MailHost",Host.Text);
                childNodes.Add("UserName",Username.Text);
                childNodes.Add("Password",Password.Text);
                childNodes.Add("SlackUser",SLackUser.Text);
                childNodes.Add("SlackContent",SlackContent.Text);
                childNodes.Add("SlackResult", SelectResult.IsChecked.ToString().ToLower());
                childNodes.Add("SlackUpdate", SelectUpdate.IsChecked.ToString().ToLower());
                childNodes.Add("SlackCommit", SelectCommit.IsChecked.ToString().ToLower());
                childNodes.Add("GitVersion", "");
                //存储项目的类型
                if (Svn.IsChecked == true) { childNodes.Add("ProjectType","svn"); }
                if (Git.IsChecked==true)   { childNodes.Add("ProjectType","git"); }
                property.Add("Name", projectName.Text);
                property.Add("Status", "true");
                bool ifExist = false;
                //查询项目名称是否已经存在
                List<ProjectInfo> projectInfos = projectController.ProjectQuery("/config/Projects", true,
                    "../../../common/res/CIConfig.xml");
                if (projectInfos.Any(project => project.Nameproperty == projectName.Text))
                {
                    ifExist = true;
                }
                //没有存在,进行创建添加
                if (!ifExist)
                {
                    projectController.AddProject(childNodes, property, "../../../common/res/CIConfig.xml");
                    property.Clear();
                    property.Add("Name", projectName.Text);
                    MessageBox.Show("Add  " + projectController.AddProject(null, property, "../../../common/res/BuildResultLogs.xml"));
                }
                //项目名已经存在,进行覆盖
                else
                {
                    MessageBox.Show("Modify  " + projectController.ModifyProject(childNodes, property, "../../../common/res/CIConfig.xml",
                        "Projects"));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化事件,获取当前的uri路径
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InitPage(object sender, RoutedEventArgs e)
        {
            try
            {
                quesMark.ToolTip = "1.##之间的内容若包含:则:左边为成功的显示右边为失败" +
                                   "\n2.smile&smiling_imp为emoji对照英文可按需修改" +
                                   "\n3.可按需添加语句";
                ProjectController projectController = new ProjectController();
                List<ProjectInfo> list = projectController.ProjectQuery("/config/lastest", false, "../../../common/res/LastestInfo.xml");
                lastRe.Text = list[0].Result;
                index = int.Parse(list[0].Index);
                if (index != -1)
                {
                    List<ProjectInfo> projectInfos = projectController.ProjectQuery("/config/Projects", true,
                "../../../common/res/CIConfig.xml");
                    modifyProject = projectInfos[index];
                    if (modifyProject != null)
                    {
                        respoPath.Text = modifyProject.RepositoryPath;
                        projectName.Text = modifyProject.Nameproperty;
                        Workspace.Text = modifyProject.WorkDirectory;
                        Mailto.Text = modifyProject.MailTo;
                        Buildcomand.Text = modifyProject.BuildCommand;
                        CheckMail.IsChecked = Convert.ToBoolean(modifyProject.IfMail);
                        CheckSlack.IsChecked = Convert.ToBoolean(modifyProject.IfSlack);
                        Host.Text = modifyProject.MailHost;
                        Username.Text = modifyProject.UserName;
                        Password.Text = modifyProject.Password;
                        SlackUrl.Text = modifyProject.SlackUrl;
                        SlackChannel.Text = modifyProject.SlackChannel;
                        buildRe.Text = modifyProject.Result;
                        if (modifyProject.ProjectType=="git") { Git.IsChecked = true; }
                        if (modifyProject.ProjectType=="svn") { Svn.IsChecked = true; }
                    }
                    Dictionary<string, string> initIndex = new Dictionary<string, string>();
                    initIndex.Add("index", "-1");
                    projectController.ModifyProject(initIndex, null, "../../../common/res/LastestInfo.xml", "lastest");
                }

            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化项目列表显示
        /// </summary>
        public void InitProjectList()
        {
            ListView.Items.Clear();
            ProjectController projectController = new ProjectController();
            _projectInfos = projectController.ReadLog("/config/Projects", "../../../common/res/BuildResultLogs.xml");
            ProjectInfo lastestInfo = projectController.ProjectQuery("config/lastest", false,
                "../../../common/res/LastestInfo.xml").First();
            foreach (var projectInfo in _projectInfos)
            {
                var flag = projectInfo.Result;
                //如果是最近一次编译的项目,则以最近一次编译的结果为准
                if (projectInfo.Nameproperty.Equals(lastestInfo.Nameproperty))
                {
                    flag = lastestInfo.Result;
                }
                string imageSource;
                switch (flag)
                {
                    case "successful":
                        imageSource = "../images/dot_green.png";
                        break;
                    case "running":
                        imageSource = "../images/dot_yellow.png";
                        break;
                    case "failed":
                        imageSource = "../images/dot_red.png";
                        break;
                    default: imageSource = "../images/dot_black.png";
                        break;
                }
                // 每一项ListViewItem包含的控件
                var img = new Image();
                var tb = new TextBlock();
                var stp = new StackPanel();
                var lvi = new ListViewItem();

                //设置控件相关属性
                img.Width = 12;
                img.Height = 12;
                img.Source = new BitmapImage(new Uri(imageSource, UriKind.Relative));
                img.Margin = new Thickness(2, 0, 5, 0);

                tb.Text = projectInfo.Nameproperty;

                tb.Height = 12;
                stp.Orientation = Orientation.Horizontal;
                var convertFromString = ColorConverter.ConvertFromString("#999");
                if (convertFromString != null)
                    lvi.BorderBrush = new SolidColorBrush((Color)convertFromString);
                lvi.BorderThickness = new Thickness(2, 0, 2, 2);
                lvi.Height = 30;
                var fromString = ColorConverter.ConvertFromString("#eee");
                if (fromString != null)
                lvi.Background = new SolidColorBrush((Color)fromString);

                stp.Children.Add(img);
                stp.Children.Add(tb);
                lvi.Content = stp;
                ListView.Items.Add(lvi);
            }
        }