116 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			116 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Collections;
							 | 
						|||
| 
								 | 
							
								using System.Data; 
							 | 
						|||
| 
								 | 
							
								using System.IO;
							 | 
						|||
| 
								 | 
							
								using System.Security.Cryptography;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Diagnostics;
							 | 
						|||
| 
								 | 
							
								using System.Reflection;
							 | 
						|||
| 
								 | 
							
								using System.Web;
							 | 
						|||
| 
								 | 
							
								using System.Xml;
							 | 
						|||
| 
								 | 
							
								 
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace DeiNiu.Wms.CE.Util
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								 
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    public class Utils
							 | 
						|||
| 
								 | 
							
								    {  
							 | 
						|||
| 
								 | 
							
								        public static string Encrypt(string password)//<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
							 | 
						|||
| 
								 | 
							
								            Byte[] hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
							 | 
						|||
| 
								 | 
							
								            return BitConverter.ToString(hashedBytes);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public static void buildCombox(int flag,System.Windows.Forms.ComboBox combox)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            DataRow[] drs = WmsConstants.dictionary.Select(string.Format("flag ={0}",flag));
							 | 
						|||
| 
								 | 
							
								            int parentId = 0;
							 | 
						|||
| 
								 | 
							
								            foreach (DataRow dr in drs)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                parentId = Convert.ToInt32(dr["id"].ToString());
							 | 
						|||
| 
								 | 
							
								                break;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (parentId == 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            combox.Items.Clear();
							 | 
						|||
| 
								 | 
							
								            CombItem c = new CombItem();
							 | 
						|||
| 
								 | 
							
								            c.name = "--<2D><>ѡ<EFBFBD><D1A1>--";
							 | 
						|||
| 
								 | 
							
								         
							 | 
						|||
| 
								 | 
							
								            combox.Items.Add(c); 
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            drs = WmsConstants.dictionary.Select(string.Format("parentId ={0}", parentId));
							 | 
						|||
| 
								 | 
							
								            foreach (DataRow dr in drs)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                CombItem ci = new CombItem();
							 | 
						|||
| 
								 | 
							
								                ci.name = dr["name"].ToString();
							 | 
						|||
| 
								 | 
							
								                ci.id = Convert.ToInt32(dr["id"].ToString());
							 | 
						|||
| 
								 | 
							
								                combox.Items.Add(ci); 
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            combox.SelectedIndex = 0;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public class CombItem
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								           public int id;
							 | 
						|||
| 
								 | 
							
								           public string name;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								           public override string ToString(){
							 | 
						|||
| 
								 | 
							
								               return name;
							 | 
						|||
| 
								 | 
							
								           }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public static string readHost()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            string xmlPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\settings.xml";
							 | 
						|||
| 
								 | 
							
								            XmlDocument objXmlDoc = new XmlDocument();
							 | 
						|||
| 
								 | 
							
								            objXmlDoc.Load(xmlPath);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            //XmlDocument xd = new XmlDocument();
							 | 
						|||
| 
								 | 
							
								            //xd.Load("set.xml");
							 | 
						|||
| 
								 | 
							
								            XmlNode xn = objXmlDoc.SelectSingleNode("/Root/Host");
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            return xn.InnerText.ToString();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public static bool writHostToXml(string address)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            try
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                string Path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\settings.xml";
							 | 
						|||
| 
								 | 
							
								                XmlDocument Doc = new XmlDocument();
							 | 
						|||
| 
								 | 
							
								                Doc.Load(Path);
							 | 
						|||
| 
								 | 
							
								                XmlNode ip = (XmlNode)Doc.SelectSingleNode("/Root/Host");
							 | 
						|||
| 
								 | 
							
								                ip.InnerText = address;
							 | 
						|||
| 
								 | 
							
								                Doc.Save(Path);
							 | 
						|||
| 
								 | 
							
								                return true;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            catch
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return false;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								  
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 |