Exemple #1
0
        /// <summary>
        /// 添加正式版本发布记录
        /// </summary>
        /// <param name="ProjectCode">项目编号</param>
        /// <returns></returns>
        public ActionResult ReleaseFormalAdd(string id)
        {
            ProjectModel model = new ProjectModel();

            model.Release.ID        = Guid.NewGuid().ToString();
            model.Release.ProjectID = id;
            model.Release.Status    = "发布中";
            model.Release.AddTime   = DateTime.Now;
            model.Release.Operator  = CurrentUser.FullName;
            model.Release.Type      = "正式版本";

            //svn地址验证
            var project       = _projectservice.GetById(id);
            var testSvnUri    = project.ProjectSvnURL;        //测试版本
            var releaseSvnUri = project.ProjectSvnURLRelease; //正式版本
            var svnService    = new SvnService();

            if (!svnService.IsExistsUri(releaseSvnUri))
            {
                ErrorNotification("正式版本svn地址不正确");
            }
            else
            {
                int num = _releaseService.InsertPro(model.Release);
                if (num > 0)
                {
                    SuccessNotification("项目已成功进入待发布状态");
                    return(Redirect(Url.Action("projectreleaseinfo", "project", new { id = id })));
                }
                else
                {
                    ErrorNotification("项目进入待发布状态失败");
                    return(Redirect(Url.Action("projectreleaseinfo", "project", new { id = id })));
                }
            }
            return(Redirect(Url.Action("projectreleaseinfo", "project", new { id = id })));
        }
Exemple #2
0
        /// <summary>
        /// svn代码获取
        /// </summary>
        /// <param name="svnuri">svn地址</param>
        static void SVNUpdate(string svnuri, out string logmessage, out long reversion)
        {
            logmessage = "";
            reversion  = 0;
            long clientVersion = -1;

            using (SvnClient client = new SvnClient())
            {
                try
                {
                    var localpath = WorkPath + @"\" + ProjCode + @"\" + BranchName;
                    var username  = ConfigHelper.GetValue("SVNUser");
                    var pwd       = ConfigHelper.GetValue("SVNpwd");
                    client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(username, pwd);
                    //notiny = "正在检查本地版本...";
                    //ShowInfo();
                    //SvnInfoEventArgs clientInfo;
                    //bool okc = SC.GetInfo(local, out clientInfo);
                    //if (oks && okc) //如果客户端服务端都会成功, 则对比服务器版本, 否则返回true 执行更新命令
                    //{
                    //    result = (serverInfo.Revision > clientInfo.Revision);
                    //}

                    //如果项目不存在则checkout,否则进行update
                    if (!Directory.Exists(localpath))
                    {
                        client.CheckOut(new Uri(svnuri), localpath);
                        Console.WriteLine("svn checkout success");
                    }
                    else
                    {
                        SvnInfoEventArgs serverInfo;
                        SvnInfoEventArgs clientInfo;
                        SvnUriTarget     repos = new SvnUriTarget(svnuri);
                        SvnPathTarget    local = new SvnPathTarget(localpath);
                        SvnUpdateArgs    args  = new SvnUpdateArgs();
                        args.Depth = SvnDepth.Infinity;
                        var  svnService = new SvnService();
                        long version    = 0;

                        var msg = "";
                        args.Notify += delegate(object sender, SvnNotifyEventArgs e)
                        {
                            //if (svnService.GetNotifyAction(e.Action) == "添加")
                            //{
                            //    msg += "\r\n添加" + e.FullPath;
                            //}
                            //if (svnService.GetNotifyAction(e.Action) == "更新删除")
                            //{
                            //    msg += "\r\n删除:" + e.FullPath;
                            //}
                            //if (svnService.GetNotifyAction(e.Action) == "更新修改")
                            //{
                            //    msg += "\r\n修改" + e.FullPath;
                            //}
                            msg    += "\r\n" + (svnService.GetNotifyAction(e.Action)) + ":" + e.FullPath;
                            version = e.Revision;
                            Console.WriteLine(msg);
                        };


                        client.GetInfo(repos, out serverInfo);
                        client.GetInfo(local, out clientInfo);
                        clientVersion = clientInfo.Revision;



                        //if (clientVersion < version)//客户端version必须小于服务端才更新
                        //{


                        //client.Resolve(localpath, SvnAccept.Base);//解决冲突
                        ////解决冲突
                        //Collection<SvnStatusEventArgs> statuses;
                        //client.GetStatus(localpath, out statuses);

                        //foreach (var item in statuses)
                        //{
                        //    if (item.Conflicted)
                        //    {
                        //        client.Resolve(item.FullPath, SvnAccept.Working);
                        //        Console.WriteLine("处理冲突文件:" + item.FullPath);
                        //        logmessage += "处理冲突文件:" + item.FullPath;
                        //    }
                        //}


                        client.CleanUp(localpath);

                        SvnRevertArgs revertArgs = new SvnRevertArgs()
                        {
                            Depth = SvnDepth.Infinity
                        };                                                                           //撤销本地所做的修改
                        client.Revert(localpath, revertArgs);
                        client.Update(localpath, args);

                        //获取消息
                        Collection <SvnLogEventArgs> logitems;
                        //if (version > 0 && clientVersion < version)
                        logmessage += "变更文件:" + msg;

                        if (version > 0 && clientVersion < version)
                        {
                            reversion = version;
                            client.GetLog(new Uri(svnuri), new SvnLogArgs(new SvnRevisionRange(clientVersion + 1, version)), out logitems);
                            //client.GetLog(new Uri(svnuri), new SvnLogArgs(new SvnRevisionRange(version, version)), out logitems);
                            foreach (var logentry in logitems)
                            {
                                string author  = logentry.Author;
                                string message = logentry.LogMessage;
                                //DateTime checkindate = logentry.Time;
                                logmessage += string.Format("\r\n提交人:{0} ,日志: {1}", author, message);
                            }
                        }
                        //}
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    logmessage = ex.ToString();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// svn代码获取
        /// </summary>
        /// <param name="svnuri">svn地址</param>
        static void SVNUpdate(string svnuri, out string logmessage, out long reversion)
        {
            logmessage = "";
            reversion  = 0;
            using (SvnClient client = new SvnClient())
            {
                var localpath = "d:\\sharpsvn";
                localpath = @"E:\project\ccms\CCMS_V7_HBYD_R";
                var username = "";
                var pwd      = "";
                client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(username, pwd);
                //如果项目不存在则checkout,否则进行update
                if (!Directory.Exists(localpath))
                {
                    client.CheckOut(new Uri(svnuri), localpath);
                    // Console.WriteLine("svn checkout success");
                }
                else
                {
                    SvnInfoEventArgs serverInfo;
                    SvnInfoEventArgs clientInfo;
                    SvnUriTarget     repos = new SvnUriTarget(svnuri);
                    SvnPathTarget    local = new SvnPathTarget(localpath);
                    SvnUpdateArgs    args  = new SvnUpdateArgs();
                    args.Depth = SvnDepth.Infinity;
                    var  svnService    = new SvnService();
                    long version       = 0;
                    long clientVersion = -1;
                    var  msg           = "";
                    args.Notify += delegate(object sender, SvnNotifyEventArgs e)
                    {
                        //if (svnService.GetNotifyAction(e.Action) == "添加")
                        //{
                        //    msg += "\r\n添加" + e.FullPath;
                        //}
                        //if (svnService.GetNotifyAction(e.Action) == "更新删除")
                        //{
                        //    msg += "\r\n删除:" + e.FullPath;
                        //}
                        //if (svnService.GetNotifyAction(e.Action) == "更新修改")
                        //{
                        //    msg += "\r\n修改" + e.FullPath;
                        //}
                        msg    += "\r\n" + (svnService.GetNotifyAction(e.Action)) + ":" + e.FullPath;
                        version = e.Revision;
                    };


                    client.GetInfo(repos, out serverInfo);
                    client.GetInfo(local, out clientInfo);
                    clientVersion = clientInfo.Revision;

                    //if (clientVersion < version)//客户端version必须小于服务端才更新
                    //{
                    client.CleanUp(localpath);

                    SvnRevertArgs args2 = new SvnRevertArgs()
                    {
                        Depth = SvnDepth.Infinity
                    };


                    client.Revert(localpath, args2);
                    client.Update(localpath, args);

                    //获取消息
                    Collection <SvnLogEventArgs> logitems;
                    //if (version > 0 && clientVersion < version)
                    if (msg.Length > 5)
                    {
                        reversion   = version;
                        logmessage += "\r\n变更文件:" + msg;
                        client.GetLog(new Uri(svnuri), new SvnLogArgs(new SvnRevisionRange(clientVersion + 1, version)), out logitems);
                        // client.GetLog(new Uri(svnuri), new SvnLogArgs(new SvnRevisionRange(version, version)), out logitems);
                        foreach (var logentry in logitems)
                        {
                            string author  = logentry.Author;
                            string message = logentry.LogMessage;
                            //DateTime checkindate = logentry.Time;
                            logmessage += "\r\n";
                            logmessage += string.Format("提交人:{0} ,日志: {1}", author, message) + "\r\n";
                        }
                    }
                    //}


                    // Console.WriteLine(string.Format("serverInfo revision of {0} is {1}", repos, serverInfo.Revision));
                    //Console.WriteLine(string.Format("clientInfo revision of {0} is {1}", local, clientInfo.Revision));
                    // Console.WriteLine("代码获取成功");
                }
            }//
        }
Exemple #4
0
        private void Enlist()
        {
            //Step 1.Set Global Environments
            GlobalEnvironment.DDKHome = txtDDKPath.Text;

            //Step 2.Enlist From Server
            String enlistLocalPath = txtEnlistmentPath.Text.TrimEnd('\\');
            String winDDKHomePath  = txtDDKPath.Text.TrimEnd('\\');

            if (!Directory.Exists(enlistLocalPath))
            {
                try
                {
                    Directory.CreateDirectory(enlistLocalPath);
                }
                catch
                {
                    MessageBox.Show("Invalid Path!", "Enlist Wizard",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            //Check if it exits normally
            Boolean runSuccessfully = SvnService.SvnCheckoutWorkspace(this.accountName, this.password, enlistLocalPath);

            if (!runSuccessfully)
            {
                MessageBox.Show("Svn Checkout Failed", "Enlist Wizard",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Step 3.Modify Razzle.bat
            String razzleFile            = enlistLocalPath + RazzleFilePath.RAZZLETEMPLATE_BAT_FILEPATH;
            int    razzleIndex           = GlobalEnvironment.RazzleCount + 1;
            String destRazzleBatName     = String.Format(@"\Razzle_{0}.bat", razzleIndex);
            String destRazzleBatPathName = Environment.GetFolderPath(Environment.SpecialFolder.System) +
                                           destRazzleBatName;
            StreamReader sr      = new StreamReader(razzleFile);
            String       content = sr.ReadToEnd();

            sr.Close();

            //Step 3.1 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_ENLISTMENT_PROJ_ROOT_STRING, enlistLocalPath + @"\MadDog");
            //Step 3.2 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_RAZZLE_INDEX, razzleIndex.ToString());
            //Step 3.3 Replace %%WINDDK_HOME%% in Razzle.bat
            //BUG FIX - Can't set WinDDKHome in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_WINDDKHOME_STRING, winDDKHomePath);
            //Step 3.4 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_CURRENT_USER_STRING, this.accountName);

            StreamWriter sw = new StreamWriter(destRazzleBatPathName);

            sw.Write(content);
            sw.Close();

            //Step 4.Create User specified environment
            String fullUserEnvFolder = enlistLocalPath + RazzleFilePath.RAZZLE_USER_ENVBAT_FOLDERPATH + this.accountName;
            String defaultEnvFolder  = enlistLocalPath + RazzleFilePath.RAZZLETEMPLATE_USER_ENV_FILEPATH;

            if (!Directory.Exists(fullUserEnvFolder))
            {
                try
                {
                    Directory.CreateDirectory(fullUserEnvFolder);
                    foreach (String filePath in Directory.GetFiles(defaultEnvFolder))
                    {
                        String fileName = Path.GetFileName(filePath);
                        File.Copy(filePath, fullUserEnvFolder + @"\" + fileName);
                    }
                    SvnService.SvnAddFolder(this.accountName, this.password, fullUserEnvFolder);
                }
                catch
                {
                    MessageBox.Show("Invalid User Enviroment Path,Try a different Account Name", "Enlist Wizard",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            //Step 5.Create Shortcut on the desktop.
            String shortCutFileName = Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) +
                                      String.Format(@"\Razzle_{0}.lnk", razzleIndex);

            //Step 5.1 Set Razzle Build Env x86 Checked in Default.
            ShortcutHelper.CreateShortcut(shortCutFileName,
                                          destRazzleBatPathName,
                                          RazzleFilePath.RAZZLE_BAT_DEFAULT_PARAMETER,
                                          enlistLocalPath);

            //Step 6. Increment Razzle_Count Value
            GlobalEnvironment.IncreaseRazzleCount();

            MessageBox.Show("Enlist successfully");
        }