ModifyProject() public method

执行修改项目动态内容的操作(现有的,只修改不增加)
public ModifyProject ( string>.Dictionary projects, string>.Dictionary property, string xmlPath, string nodePath ) : string
projects string>.Dictionary 需要修改的项目的键值对
property string>.Dictionary 需要筛选的属性值的键值对
xmlPath string xml文件的路径
nodePath string 节点的路径
return string
Beispiel #1
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);
             Dictionary<string, string> setValue = new Dictionary<string, string>();
             setValue.Add("Name", _svnController.GetLocalInfo(projectInfo).Author.Split('\\')[1]);
             if (buildResult == "successful")
             {
                 _projectController.CommitStat("success", setValue, "config/Member", "../../../common/res/InfoStatics.xml");
             }
             else if (buildResult == "failed")
             {
                 _projectController.CommitStat("failure", setValue, "config/Member", "../../../common/res/InfoStatics.xml");
             }
             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();
     }
 }
Beispiel #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"));
                }
            }
        }
Beispiel #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);
            }
        }
        //当点击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));
        }