示例#1
0
 /// <summary>
 /// 执行开启选中的工程节点,使之处于激活状态
 /// </summary>
 private void btnActive_Click(object sender, RoutedEventArgs e)
 {
     ProjectController projectController = new ProjectController();
     var name = new Dictionary<string, string>();
     var property = new Dictionary<string, string>();
     name.Add("Name",projectName.Text);
     property.Add("Status", "true");
     MessageBox.Show("Active " + projectController.ActiveClose(name, property, "Projects", "../../../common/res/CIConfig.xml"));
 }
示例#2
0
 /// <summary>
 /// 手动编译
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnBuild_Click(object sender, RoutedEventArgs e)
 {
     ProjectController projectController = new ProjectController();
     if (respoPath.Text == "" || projectName.Text == "" || Workspace.Text == "" ||
         Host.Text == "" || Mailto.Text == "" || Buildcomand.Text == "")
     {
         MessageBox.Show("请先填写完整的信息!");
     }
     else
     {
         ProjectInfo projectInfo = new ProjectInfo();
         projectInfo.Workdirectory = Workspace.Text;
         projectInfo.Repositorypath = respoPath.Text;
         projectInfo.MailTo = Mailto.Text;
         projectInfo.Buildcommand = Buildcomand.Text;
         string buildResult = "";
         string time = "";
         Task buildTask = new Task(() =>
         {
             projectInfo.BuildTime = DateTime.Now.ToString();
             log = projectController.Build(projectInfo.Buildcommand, projectInfo.Workdirectory, out buildResult,
                 out err,out time);
             Dispatcher.BeginInvoke(new Action(() =>
             {
                 duration = time;
                 logs.Text = "编译信息" + log + "\n" + this.logs.Text + "\n";
                 lastRe.Text = buildResult;
                 //检验是否存储信息(最近一次编译信息,以及后台存储信息)
                 Dictionary<string, string> lastProject = new Dictionary<string, string>();
                 //修改存储最近完成项目信息的xml文件
                 lastProject.Add("projectName", projectName.Text);
                 lastProject.Add("buildTime", projectInfo.BuildTime);
                 lastProject.Add("duration", projectInfo.Duration);
                 lastProject.Add("result", buildResult);
                 projectController.ModifyProject(lastProject, null,
                     "../../../common/res/LastestInfo.xml", "lastest");
             }));
         });
         buildTask.Start();
     }
 }
示例#3
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;
 }
示例#4
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);
            }
        }
示例#5
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"));
                }
            }
        }
示例#6
0
 /// <summary>
 ///  执行删除选中的工程节点
 /// </summary>
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     ProjectController projectController = new ProjectController();
     var xmlConfigPath = new[] { "../../../common/res/CIConfig.xml", "../../../common/res/BuildResultLogs.xml" };
     var result = projectController.DeleteProject("/config/Projects", projectName.Text, xmlConfigPath);
     MessageBox.Show("Delete " + result);
     if (result == "successful")
     {
         index = new int();
         modifyProject = null;
         respoPath.Text = "";
         projectName.Text = "";
         Workspace.Text = "";
         Mailto.Text = "";
         Buildcomand.Text = "";
         CheckMail.IsChecked = false;
         CheckSlack.IsChecked = false;
         Host.Text = "";
         Username.Text = "";
         Password.Text = "";
         SlackUrl.Text = "";
         SlackChannel.Text = "";
         buildRe.Text = "";
     }
 }
示例#7
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);
            }
        }
示例#8
0
        //当点击listviewitem时(鼠标离开listview)执行停止timer操作
        private void ListView_OnLostMouseCapture(object sender, MouseEventArgs e)
        {
            //_timer.Stop();
            ////用户在5s之内选择执行操作否则进行listview的刷新
            //Task waitSecs = new Task(() =>
            //{
            //    ListView.LostMouseCapture -= ListView_OnLostMouseCapture;
            //    Thread.Sleep(5000);
            //});
            //waitSecs.Start();
            //Task task = waitSecs.ContinueWith(t =>
            //{
            //    ListView.LostMouseCapture += ListView_OnLostMouseCapture;
            //    _timer.Stop();
            //    _timer.Start();
            //});

            ProjectController projectController = new ProjectController();
            var index = ListView.SelectedIndex;
            Dictionary<string, string> indexValue = new Dictionary<string, string>();
            indexValue.Add("index", index.ToString());
            projectController.ModifyProject(indexValue, null, "../../../common/res/LastestInfo.xml", "lastest");
            //跳转指定的page
            var navigationService = NavigationService;
            if (navigationService != null)
                navigationService.Navigate(new Uri("/LuckyCI;component/pages/AddPage.xaml", UriKind.Relative));
        }
示例#9
0
 /// <summary>
 /// 初始化日志显示
 /// </summary>
 private void InitDetailLogs()
 {
     AllLog.Text = "";
     ProjectController projectController = new ProjectController();
     //获取log信息
     List<ProjectInfo> logs = projectController.ReadLog("/config/Projects", "../../../common/res/BuildResultLogs.xml");
     foreach (var proLog in logs)
     {
         AllLog.Text += proLog.Nameproperty + "编译日志" + "\n" + proLog.Log + "\n";
     }
 }