Пример #1
0
        public ActionResult showvss()
        {
            var         version     = PressRequest.GetQueryInt("v");
            VSSDatabase vssDatabase = new VSSDatabaseClass();
            var         VSSini      = GetValue("VSSini");
            var         VSSuser     = GetValue("VSSuser");
            var         VSSpwd      = GetValue("VSSpwd");
            var         CCMS_PRJ    = GetValue("CCMS_PRJ");
            var         CCMS_Local  = GetValue("CCMS_Local");
            var         ccmsversion = "";

            vssDatabase.Open(@VSSini, VSSuser, VSSpwd);
            VSSItem vssitem = vssDatabase.get_VSSItem(CCMS_PRJ, false);

            var s = "";

            s = string.Format("<br/>\n{0} contains:", vssitem.Spec);


            foreach (VSSItem vssItem in vssitem.get_Items(false))
            {
                s += string.Format("<br/>--{0}", vssItem.Name);
                var versions = vssitem.get_Versions();

                foreach (VSSVersion v in versions)
                {
                    s += "<br/>----" + v.Username + "," + v.Date + "," + v.VersionNumber;
                }
            }

            return(Content(s));
        }
Пример #2
0
        public ActionResult GetCode()
        {
            ViewBag.Title = "Utry持续集成平台";
            //VSSDatabase vssDatabase = new VSSDatabase();
            //try { vssDatabase.Open(txtDbPath.Text, txtAccount.Text, txtPasswd.Text); }
            //catch { MessageBox.Show("Can't login to the VSS database"); return; }
            //try { VSSItem vssitem = vssDatabase.get_VSSItem(txtItemPath.Text, false);
            //    VSSItem vssitemVersion = vssitem.get_Version(int.Parse(txtVersion.Text));
            //    string localPath = txtLocalpath.Text; vssitemVersion.Get(ref localPath, 0);
            //    if (File.Exists(txtLocalpath.Text)) { MessageBox.Show("Succeed!"); } }
            //catch { MessageBox.Show("Download failed"); }

            VSSDatabase vssDatabase = new VSSDatabaseClass();
            //var VSSini = GetValue("VSSini");
            var VSSini     = ConfigHelper.GetValue("VSSini");
            var VSSuser    = ConfigHelper.GetValue("VSSuser");
            var VSSpwd     = ConfigHelper.GetValue("VSSpwd");
            var CCMS_PRJ   = ConfigHelper.GetValue("CCMS_PRJ");
            var CCMS_Local = ConfigHelper.GetValue("CCMS_Local");

            //WorkGroupNetwork iss = new WorkGroupNetwork("ccms", "ip", "ccms");

            vssDatabase.Open(@VSSini, VSSuser, VSSpwd);
            VSSItem vssitem = vssDatabase.get_VSSItem(CCMS_PRJ, false);


            var code = Request["txtCode"];

            code = code.Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "").Replace("新增", "").Replace("修改", "");

            string[] files = code.Split('\n');

            foreach (string file in files)
            {
                var    vfile     = file.Replace("\r", "").Replace(" ", "").Trim();
                var    localfile = vfile.Replace("/", "\\");
                string vssfile   = CCMS_PRJ + vfile;
                string localFile = CCMS_Local + localfile;

                VSSItem vssFolder = vssDatabase.get_VSSItem(vssfile, false);

                //更新之前先删除文件
                if (System.IO.File.Exists(localFile))
                {
                    System.IO.FileInfo f = new System.IO.FileInfo(localFile);
                    f.Attributes = FileAttributes.Normal;
                    f.Delete();
                }
                vssFolder.Get(localFile, 0);//获取到本地文件夹
            }

            //iss.Dispose();
            //VSSItem vssitemVersion = vssitem.get_Version(1);
            //string s = "c:\\JobMate.sln";
            //vssitemVersion.Get(ref s, 0);
            ViewBag.Tip = "获取代码成功";
            return(Redirect("?act=success"));
        }
Пример #3
0
        static void Main(string[] args)
        {
            string projectName = args[0];
            string userName = "******";

            string vssPath = SSDIR;
            VSSDatabaseClass vss = new VSSDatabaseClass();
            vss.Open(vssPath + @"\srcsafe.ini", userName, userName);
            VSSItem sourceItem = vss.get_VSSItem("$/Projects/" + projectName, false);

            Console.WriteLine(userName + " pending checkins for " + projectName + ":");
            int total = GetItems(sourceItem);
            Console.WriteLine(total.ToString() + " total changes.");
        }
Пример #4
0
        // constructor
        public ScriptEngine(Server sqlserver, // sql server
                            dbClass currentDB,
                                              // root in VSS under which items are created
                            System.Windows.Forms.ToolStripLabel databasename,
                            System.Windows.Forms.ToolStripLabel objectname,
                            string localScriptPath
                            )
        {
            string vssRootPath = currentDB.VssProjectParent;

            m_vssDatabase = new VSSDatabaseClass();
            m_vssDatabase.Open(currentDB.VssIniFile, currentDB.VssLogin, currentDB.VssPw);

            m_sqlserver   = sqlserver;
            m_vssRootPath = vssRootPath;
            m_vssRoot     = m_vssDatabase.get_VSSItem(vssRootPath, false);

            m_workingFolder  = localScriptPath;
            m_workingFolder += "\\DBScriptManager";
            System.IO.Directory.CreateDirectory(m_workingFolder);
            dname = databasename; oname = objectname;
        }
Пример #5
0
 public void Open()
 {
     vssDatabase.Open(dbPath, username, password);
 }
Пример #6
0
        public ActionResult GetCheckListCode()
        {
            var         version     = PressRequest.GetQueryInt("v");
            VSSDatabase vssDatabase = new VSSDatabaseClass();
            var         VSSini      = GetValue("VSSini");
            var         VSSuser     = GetValue("VSSuser");
            var         VSSpwd      = GetValue("VSSpwd");
            var         CCMS_PRJ    = GetValue("CCMS_PRJ");
            var         CCMS_Local  = GetValue("CCMS_Local");
            var         ccmsversion = "";
            var         ids         = PressRequest.GetFormString("ItemId");
            bool        success     = true;

            try
            {
                vssDatabase.Open(@VSSini, VSSuser, VSSpwd);
                VSSItem vssitem = vssDatabase.get_VSSItem(CCMS_PRJ, false);
            }
            catch (COMException ex)
            {
                ErrorNotification("VSS连接失败");
                success = false;
            }

            if (ids != "")
            {
                var idarr = ids.TrimEnd(',').Split(',');

                foreach (var id in idarr)
                {
                    var checkitem = _checkItemService.GetCheckItem(id);
                    var codelist  = TypeConverter.ObjectToString(checkitem.CodeList);

                    if (version == 7)
                    {
                        codelist    = codelist.Replace("CCMS_V6", "CCMS_V7");
                        ccmsversion = "CCMS_V7";
                    }
                    if (version == 6)
                    {
                        codelist    = codelist.Replace("CCMS_V7", "CCMS_V6");
                        ccmsversion = "CCMS_V6";
                    }

                    var      codefile = codelist.Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "").Replace("新增", "").Replace("修改", "");
                    string[] files    = codefile.Split('\n');
                    foreach (string file in files)
                    {
                        var    vfile     = file.Replace("\r", "").Replace(" ", "").Trim();
                        var    localfile = vfile.Replace("/", "\\");
                        string vssfile   = CCMS_PRJ + vfile;
                        string localFile = CCMS_Local + localfile;

                        try
                        {
                            VSSItem vssFolder = vssDatabase.get_VSSItem(vssfile, false);
                            //更新之前先删除文件
                            if (System.IO.File.Exists(localFile))
                            {
                                System.IO.FileInfo f = new System.IO.FileInfo(localFile);
                                f.Attributes = FileAttributes.Normal;//解除只读权限
                                f.Delete();
                            }
                            vssFolder.Get(localFile, 0);//获取到本地文件夹

                            #region 自动添加到工程文件
                            var vbproj      = "";
                            var projectName = "";

                            if (localfile.EndsWith(".aspx"))
                            {
                                vbproj      = "SCH.vbproj";
                                projectName = CCMS_Local + ccmsversion + @"\web\" + vbproj;
                            }
                            if (localfile.EndsWith(".vb") && localfile.IndexOf(".aspx") < 0)
                            {
                                var t1       = localfile.Substring(ccmsversion.Length, localfile.Length - ccmsversion.Length);
                                var foldname = t1.Substring(1, t1.LastIndexOf(@"\") - 1);
                                vbproj      = foldname + ".vbproj";
                                projectName = CCMS_Local + ccmsversion + @"\" + foldname + @"\" + vbproj;
                            }

                            if (!string.IsNullOrEmpty(projectName))
                            {
                                Project project = new Project();
                                project.Load(projectName);

                                var foldname = localfile.Substring(0, localfile.LastIndexOf(@"\"));
                                var include  = localfile.Substring(foldname.LastIndexOf(@"\") + 1, localfile.Length - foldname.LastIndexOf(@"\") - 1);

                                var isnew = true;
                                foreach (BuildItemGroup itemGroup in project.ItemGroups)
                                {
                                    foreach (BuildItem item in itemGroup)
                                    {
                                        if ((item.Include.ToLower() == include.ToLower()) || (include.ToLower().LastIndexOf(item.Include.ToLower()) > 0))
                                        {
                                            isnew = false;
                                            break;
                                        }
                                    }
                                }
                                if (isnew && localfile.EndsWith(".aspx"))
                                {
                                    var includedesigner = include + ".designer.vb";
                                    var includevb       = include + ".vb";

                                    var itemGroup = project.AddNewItemGroup();
                                    var buildItem = itemGroup.AddNewItem("Content", include);

                                    var buildItemdesigner = itemGroup.AddNewItem("Compile", includedesigner);
                                    var filename          = include.Substring(include.LastIndexOf(@"\") + 1, include.Length - include.IndexOf(@"\") - 1);
                                    buildItemdesigner.SetMetadata("DependentUpon", filename);

                                    var buildItemvb = itemGroup.AddNewItem("Compile", includevb);
                                    buildItemvb.SetMetadata("DependentUpon", filename);
                                    buildItemvb.SetMetadata("SubType", "ASPXCodebehind");
                                    project.Save(projectName);
                                }
                                else if (isnew && localfile.EndsWith(".vb") && vbproj != "SCH.vbproj") //非web工程
                                {
                                    var itemGroup = project.AddNewItemGroup();
                                    var buildItem = itemGroup.AddNewItem("Compile", include.Substring(include.IndexOf(@"\") + 1));
                                    project.Save(projectName);
                                }
                            }

                            #endregion
                        }
                        catch (COMException ex)
                        {
                            ErrorNotification("代码不存在:" + file);
                            success = false;
                        }
                    }

                    checkitem.GetVssCnt += 1;//增加获取次数
                    _checkItemService.UpdateCheckItem(checkitem, null);
                }
                if (success)
                {
                    SuccessNotification("获取代码成功");
                }
            }
            else
            {
                ErrorNotification("获取代码失败");
            }
            // return Redirect(Url.Action("deploylist", "checkitem"));
            var url = PressRequest.GetUrlReferrer();
            return(Redirect(url));
        }