示例#1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            string rootPath = AppDomain.CurrentDomain.BaseDirectory;

            var dir = Directory.GetParent(rootPath).Parent.Parent.Parent;

            rootPath = dir.FullName;
            var           iconContent = XMLHelper.GetXmlNodeByXpath("icon.xml", "/root/data[@name='$this.Icon']/value").InnerText;//获取左上角小图标base64内容
            DirectoryInfo theFolder   = new DirectoryInfo(rootPath);

            DirectoryInfo[] dirInfo = theFolder.GetDirectories();

            //遍历文件夹
            foreach (DirectoryInfo nextFolder in dirInfo)
            {
                FileInfo[] fileInfo = nextFolder.GetFiles();
                foreach (FileInfo nextFile in fileInfo) //遍历文件
                {
                    if (nextFile.Extension == ".resx")  //判断是资源文件的才处理
                    {
                        //设置小图标内容
                        XMLHelper.CreateOrUpdateXmlNodeByXPath(nextFile.FullName, "/root/data[@name='$this.Icon']", "value", iconContent);
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// 完成待办
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool Complete(DateTime addTime)
 {
     try
     {
         var xmlPath           = "/Todos/Todo[@Done=0][AddTime='" + addTime.ToString(TIME_TEMP) + "']";
         var xmlAttributeName  = "Done";
         var xmlAttributeValue = "1";
         if (XMLHelper.CreateOrUpdateXmlAttributeByXPath(treePath, xmlPath, xmlAttributeName, xmlAttributeValue))
         {
             xmlPath = "/Todos/Todo[AddTime='" + addTime.ToString(TIME_TEMP) + "']";
             var xmlNodeName  = "CompleteTime";
             var xmlNodeValue = DateTime.Now.ToString(TIME_TEMP);
             return(XMLHelper.CreateOrUpdateXmlNodeByXPath(treePath, xmlPath, xmlNodeName, xmlNodeValue));
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(false);
 }
示例#3
0
文件: Form2.cs 项目: vleboy/xmlupzip
        private void toXml()
        {
            string        f       = "";
            List <string> listImg = new List <string>();

            listImg = toImages();

            XMLHelper.CreateXmlDocument(xmlFileUrl, "template", "1.0", "UTF-8", "yes");
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template", "object", "", true);
            for (int i = 0; i < listImg.Count; i++)
            {
                var x = System.IO.Path.GetFileName(listImg[i]);
                if (x == "pc_main.jpg")
                {
                    XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_coverImage", "", "name", "pc_main.jpg");
                }
                if (x == "ap_main.jpg")
                {
                    XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_coverImage", "", "name", "ap_main.jpg");
                }
                if (x == "wx_main.jpg")
                {
                    XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_coverImage", "", "name", "wx_main.jpg");
                }
            }



            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_slidesImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_detailImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_serviceImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_clothShootImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_cosmeticImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_baseSampleImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "pc_processImages", "", true);



            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_slidesImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_detailImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_serviceImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_clothShootImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_cosmeticImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_baseSampleImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "ap_processImages", "", true);



            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_slidesImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_detailImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_serviceImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_clothShootImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_cosmeticImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_baseSampleImages", "", true);
            XMLHelper.CreateOrUpdateXmlNodeByXPath(xmlFileUrl, "/template/object", "wx_processImages", "", true);
            for (int i = 0; i < listImg.Count; i++)
            {
                f = System.IO.Path.GetFileName(listImg[i]);
                switch (f.Substring(0, 2))
                {
                case "pc":
                {
                    switch (f.Substring(3, 2))
                    {
                    case "sl":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/pc_slidesImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());

                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/slidesImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "de":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/pc_detailImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "se":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/pc_serviceImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/serviceImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "cl":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/pc_clothShootImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/clothShootImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/clothShootImages", "image", "", "name",f);
                    }
                    break;

                    case "co":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/pc_cosmeticImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/cosmeticImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/cosmeticImages", "image", "", "name",f);
                    }
                    break;

                    case "ba":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/pc_baseSampleImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_")+1,2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name",f);
                    }
                    break;

                    case "pr":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/pc_processImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/processImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name",f);
                    }
                    break;

                    default:
                        break;
                    }
                }
                break;

                case "ap":
                {
                    switch (f.Substring(3, 2))
                    {
                    case "sl":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/ap_slidesImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());

                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/slidesImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "de":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/ap_detailImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "se":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/ap_serviceImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/serviceImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "cl":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/ap_clothShootImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/clothShootImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/clothShootImages", "image", "", "name",f);
                    }
                    break;

                    case "co":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/ap_cosmeticImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/cosmeticImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/cosmeticImages", "image", "", "name",f);
                    }
                    break;

                    case "ba":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/ap_baseSampleImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_")+1,2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name",f);
                    }
                    break;

                    case "pr":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/ap_processImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/processImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name",f);
                    }
                    break;

                    default:
                        break;
                    }
                }
                break;

                case "wx":
                {
                    switch (f.Substring(3, 2))
                    {
                    case "sl":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/wx_slidesImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());

                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/slidesImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "de":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/wx_detailImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "se":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/wx_serviceImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/serviceImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/detailImages", "image", "", "name",f);
                    }
                    break;

                    case "cl":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/wx_clothShootImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/clothShootImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/clothShootImages", "image", "", "name",f);
                    }
                    break;

                    case "co":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/wx_cosmeticImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/cosmeticImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        // XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/cosmeticImages", "image", "", "name",f);
                    }
                    break;

                    case "ba":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/wx_baseSampleImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_")+1,2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name",f);
                    }
                    break;

                    case "pr":
                    {
                        XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/wx_processImages", "image", "", "name", f, "weight", (listImg.Count - i).ToString());
                        //XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/processImages", "image", "", "name", f, "weight", f.Substring(f.IndexOf("_") + 1, 2));
                        //  XMLHelper.CreateXmlNodeByXPath(xmlFileUrl, "/template/object/baseSampleImages", "image", "", "name",f);
                    }
                    break;

                    default:
                        break;
                    }
                }
                break;
                }
            }
        }