Exemple #1
0
        /// <summary>
        /// 添加栏目函数
        /// </summary>
        /// <param name="xmlpath">XML栏目文件</param>
        /// <param name="XmlData">为空 "" </param>
        /// <![CDATA[调用方法 XmlFileAllNodes(Server.MapPath("treeout.xml"), "")]]>
        /// <returns></returns>
        public string XmlFileAllNodes(string xmlpath, String XmlData)
        {
            System.Xml.XmlDataDocument MyXml = new System.Xml.XmlDataDocument();
            if (XmlData == "")
            {
                MyXml.Load(xmlpath);//得到XML数据
            }
            else
            {
                MyXml.LoadXml(XmlData);
            }

            for (int i = 0; i < MyXml.DocumentElement.ChildNodes.Count; i++)
            {
                try
                {                                         //得到树状结构
                    if (XmlFileAllNodesCloumnLvTemp == 0) //一级节点
                    {
                        System.Web.HttpContext.Current.Response.Write(TextData.EStr(XmlFileAllNodesCloumnLvTemp, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + XmlFileAllNodesColumnsIDTemp + MyXml.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("Cont").Value + XmlFileAllNodesCloumnLvTemp + "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<br/>");
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Response.Write(TextData.EStr(XmlFileAllNodesCloumnLvTemp, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") + XmlFileAllNodesColumnsIDTemp + MyXml.DocumentElement.ChildNodes[i].Attributes.GetNamedItem("Cont").Value + XmlFileAllNodesCloumnLvTemp + "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<br/>");
                        //如果是子节点
                    }
                    XmlFileAllNodesColumnsIDTemp += 1;
                    XmlFileAllNodesCloumnLvTemp++;
                    XmlFileAllNodes(xmlpath, MyXml.DocumentElement.ChildNodes[i].OuterXml);//得到这个XML文件下的所有子节点
                    XmlFileAllNodesCloumnLvTemp--;
                }
                catch (System.Xml.XmlException)//这里如是最下层就不进行下一次的调用自己了
                {
                }
            }
            return("");
        }
        public void ConfigShouldBeTheSameWithOrWithoutPreProcessor()
        {
            const string projectName1 = "SpaceCheck";
            const string projectName2 = "SpaceCheckPreProcessor";
            const string projectName3 = "SpaceCheckPreProcessorNewLines";


            string IntegrationFolder = System.IO.Path.Combine("scenarioTests", projectName1);
            string CCNetConfigFile   = System.IO.Path.Combine("IntegrationScenarios", "SpacesInBuildArgsOfTask.xml");

            string Project1StateFile = new System.IO.FileInfo(projectName1 + ".state").FullName;
            string Project2StateFile = new System.IO.FileInfo(projectName2 + ".state").FullName;
            string Project3StateFile = new System.IO.FileInfo(projectName3 + ".state").FullName;


            Log("Clear existing state file, to simulate first run : " + Project1StateFile);
            System.IO.File.Delete(Project1StateFile);

            Log("Clear existing state file, to simulate first run : " + Project2StateFile);
            System.IO.File.Delete(Project2StateFile);


            Log("Clear integration folder to simulate first run");
            if (System.IO.Directory.Exists(IntegrationFolder))
            {
                System.IO.Directory.Delete(IntegrationFolder, true);
            }


            CCNet.Remote.Messages.ProjectRequest pr1 = new CCNet.Remote.Messages.ProjectRequest(null, projectName1);
            CCNet.Remote.Messages.ProjectRequest pr2 = new CCNet.Remote.Messages.ProjectRequest(null, projectName2);
            CCNet.Remote.Messages.ProjectRequest pr3 = new CCNet.Remote.Messages.ProjectRequest(null, projectName3);


            CCNet.Remote.Messages.DataResponse dr1;
            CCNet.Remote.Messages.DataResponse dr2;
            CCNet.Remote.Messages.DataResponse dr3;


            Log("Making CruiseServerFactory");
            CCNet.Core.CruiseServerFactory csf = new CCNet.Core.CruiseServerFactory();
            Log("Making cruiseServer with config from :" + CCNetConfigFile);
            using (var cruiseServer = csf.Create(true, CCNetConfigFile))
            {
                Log("Starting cruiseServer");
                try
                {
                    cruiseServer.Start();
                }
                catch (Exception e)
                {
                    Log(e.ToString());
                }

                dr1 = cruiseServer.GetProject(pr1);
                dr2 = cruiseServer.GetProject(pr2);
                dr3 = cruiseServer.GetProject(pr3);

                Log("Stopping cruiseServer");
                cruiseServer.Stop();

                System.Threading.Thread.Sleep(250); // give time to stop the build
            }

            var pr1config = dr1.Data;
            var pr2config = dr2.Data.Replace("<name>SpaceCheckPreProcessor</name>", "<name>SpaceCheck</name>");         // give project the same name
            var pr3config = dr3.Data.Replace("<name>SpaceCheckPreProcessorNewLines</name>", "<name>SpaceCheck</name>"); // give project the same name;

            // load back as xml to we can use a standard way to reformat it a known way back to string
            // makes it easier to compare
            var xd1 = new System.Xml.XmlDataDocument();

            xd1.LoadXml(pr1config);
            xd1.PreserveWhitespace = false;
            var r1 = xd1.InnerText;

            var xd2 = new System.Xml.XmlDataDocument();

            xd2.LoadXml(pr2config);
            xd2.PreserveWhitespace = false;
            var r2 = xd2.InnerText;


            var xd3 = new System.Xml.XmlDataDocument();

            xd3.LoadXml(pr3config);
            xd3.PreserveWhitespace = false;
            var r3 = xd3.InnerText;


            Assert.AreEqual(xd1, xd2);
            Assert.AreEqual(xd1, xd3);
        }
        public void ConfigShouldBeTheSameWithOrWithoutPreProcessor()
        {
            const string projectName1 = "SpaceCheck";
            const string projectName2 = "SpaceCheckPreProcessor";
            const string projectName3 = "SpaceCheckPreProcessorNewLines";


            string IntegrationFolder = System.IO.Path.Combine("scenarioTests", projectName1);
            string CCNetConfigFile = System.IO.Path.Combine("IntegrationScenarios", "SpacesInBuildArgsOfTask.xml");

            string Project1StateFile = new System.IO.FileInfo(projectName1 + ".state").FullName;
            string Project2StateFile = new System.IO.FileInfo(projectName2 + ".state").FullName;
            string Project3StateFile = new System.IO.FileInfo(projectName3 + ".state").FullName;


            Log("Clear existing state file, to simulate first run : " + Project1StateFile);
            System.IO.File.Delete(Project1StateFile);

            Log("Clear existing state file, to simulate first run : " + Project2StateFile);
            System.IO.File.Delete(Project2StateFile);


            Log("Clear integration folder to simulate first run");
            if (System.IO.Directory.Exists(IntegrationFolder)) System.IO.Directory.Delete(IntegrationFolder, true);


            CCNet.Remote.Messages.ProjectRequest pr1 = new CCNet.Remote.Messages.ProjectRequest(null, projectName1);
            CCNet.Remote.Messages.ProjectRequest pr2 = new CCNet.Remote.Messages.ProjectRequest(null, projectName2);
            CCNet.Remote.Messages.ProjectRequest pr3 = new CCNet.Remote.Messages.ProjectRequest(null, projectName3);


            CCNet.Remote.Messages.DataResponse dr1;
            CCNet.Remote.Messages.DataResponse dr2;
            CCNet.Remote.Messages.DataResponse dr3;


            Log("Making CruiseServerFactory");
            CCNet.Core.CruiseServerFactory csf = new CCNet.Core.CruiseServerFactory();
            Log("Making cruiseServer with config from :" + CCNetConfigFile);
            using (var cruiseServer = csf.Create(true, CCNetConfigFile))
            {
                Log("Starting cruiseServer");
                try
                {
                    cruiseServer.Start();

                }
                catch (Exception e)
                {
                    Log(e.ToString());
                }

                dr1 = cruiseServer.GetProject(pr1);
                dr2 = cruiseServer.GetProject(pr2);
                dr3 = cruiseServer.GetProject(pr3);

                Log("Stopping cruiseServer");
                cruiseServer.Stop();

                System.Threading.Thread.Sleep(250); // give time to stop the build
            }

            var pr1config = dr1.Data;
            var pr2config = dr2.Data.Replace("<name>SpaceCheckPreProcessor</name>", "<name>SpaceCheck</name>"); // give project the same name
            var pr3config = dr3.Data.Replace("<name>SpaceCheckPreProcessorNewLines</name>", "<name>SpaceCheck</name>"); // give project the same name;

            // load back as xml to we can use a standard way to reformat it a known way back to string
            // makes it easier to compare
            var xd1 = new System.Xml.XmlDataDocument();
            xd1.LoadXml(pr1config);
            xd1.PreserveWhitespace = false;
            var r1 = xd1.InnerText;

            var xd2 = new System.Xml.XmlDataDocument();
            xd2.LoadXml(pr2config);
            xd2.PreserveWhitespace = false;
            var r2 = xd2.InnerText;


            var xd3 = new System.Xml.XmlDataDocument();
            xd3.LoadXml(pr3config);
            xd3.PreserveWhitespace = false;
            var r3 = xd3.InnerText;


            Assert.AreEqual(xd1, xd2);
            Assert.AreEqual(xd1, xd3); 



        }
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg  = e.CommandArgument.ToString();
            var tabId = TabId;
            var param = new string[4];

            if (_uid != "")
            {
                param[0] = "uid=" + _uid;
            }
            var navigationData = new NavigationData(PortalId, "AdminOrders");
            var cmd            = e.CommandName.ToLower();
            var resxpath       = StoreSettings.NBrightBuyPath() + "/App_LocalResources/Notification.ascx.resx";
            var emailoption    = "";

            switch (cmd)
            {
            case "entrydetail":
                param[0] = "eid=" + cArg;
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "movetoorder":
                param[0] = "";
                if (Utils.IsNumeric(cArg))
                {
                    var obj = ModCtrl.Get(Convert.ToInt32(cArg));
                    obj.TypeCode = "ORDER";
                    ModCtrl.Update(obj);
                    var ordData = new OrderData(obj.ItemID);
                    ordData.OrderStatus = "010";
                    ordData.CreatedDate = DateTime.Now.ToString("O");
                    ordData.OrderNumber = obj.ItemID.ToString();
                    ordData.AddAuditMessage(DnnUtils.GetLocalizedString("movetoordermsg.Text", "/DesktopModules/NBright/NBrightBuyCartReview/Themes/config/resx", Utils.GetCurrentCulture()), "msg", UserInfo.Username, "False");
                    ordData.Save();
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "return":
                param[0] = "";
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "search":
                var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                navigationData.Build(strXml, _templSearch);
                navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpSearch);
                navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch);
                navigationData.Save();
                if (StoreSettings.Current.DebugModeFileOut)
                {
                    strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                    var xmlDoc = new System.Xml.XmlDataDocument();
                    xmlDoc.LoadXml(strXml);
                    xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "resetsearch":
                // clear cookie info
                navigationData.Delete();
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "orderby":
                navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                navigationData.Save();
                break;

            case "viewclient":
                param[1] = "ctrl=clients";
                if (Utils.IsNumeric(cArg))
                {
                    var cartData = new CartData(Convert.ToInt32(cArg));
                    param[0] = "uid=" + cartData.UserId.ToString("");
                }
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "delete":
                if (Utils.IsNumeric(cArg))
                {
                    ModCtrl.Delete(Convert.ToInt32(cArg));
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;
            }
        }