private void Buttonlz_Click_3(object sender, RoutedEventArgs e) { entity.Setter setter = new entity.Setter(); setter.Pk_Set_Id = 1; setter.Set_Language = entity.Setter.SET_LANGUAGE_CHINA; setter.Set_OrganizationName = "1"; setter.Set_OrganizationPhone = "2"; setter.Set_OrganizationSort = "3"; setter.Set_PhotoLocation = "4"; entity.Setter setter2 = new entity.Setter(); setter2.Pk_Set_Id = 1; setter2.Set_Language = entity.Setter.SET_LANGUAGE_CHINA; setter2.Set_OrganizationName = "1"; setter2.Set_OrganizationPhone = "2"; setter2.Set_OrganizationSort = "3"; setter2.Set_PhotoLocation = "4"; List <entity.Setter> list = new List <entity.Setter>(); list.Add(setter); list.Add(setter2); //string str = JsonTools.List2JSONStr<entity.Setter>(list); string str = JsonTools.List2JSONStrNew(list); System.Windows.MessageBox.Show(str); }
//获得AES加密 private void Button_Click_15(object sender, RoutedEventArgs e) { SetterService setterService = new SetterService(); entity.Setter setter = setterService.getSetter(); MessageBox.Show(setter.Set_Unique_Id); }
//获得aes加密insert private void Button_Click_14(object sender, RoutedEventArgs e) { string mac = System.Text.Encoding.Default.GetString(AesUtil.Encrypt(System.Text.Encoding.Default.GetBytes("00:16:3E:0C:B2:B3"), ProtocolConstant.USB_DOG_PASSWORD)); //string mac = AesUtil.AesEncrypt("E4:02:9B:55:8E:30", "E4:02:9B:55:8E:30"); SetterService setterService = new SetterService(); entity.Setter setter = new entity.Setter(); setter.Set_Unique_Id = mac; setterService.InsertSetter(setter); //MessageBox.Show(mac); }
/// <summary> /// 测试激活 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_16(object sender, RoutedEventArgs e) { SetterDAO setterDAO = new SetterDAO(); //获取mac地址 StringBuilder stringBuilder = new StringBuilder(); //string strMac = CommUtil.GetMacAddress(); // List<string> Macs = CommUtil.GetMacByWMI(); List <string> Macs = CommUtil.GetMacByIPConfig(); foreach (string mac in Macs) { string prefix = "物理地址. . . . . . . . . . . . . : "; string Mac = mac.Substring(prefix.Length - 1); stringBuilder.Append(Mac); } //Console.WriteLine("==================="+stringBuilder.ToString()); //MessageBox.Show("===================" + stringBuilder.ToString()); entity.Setter setter = new entity.Setter(); //mac地址先变为byte[]再aes加密 byte[] byteMac = Encoding.GetEncoding("GBK").GetBytes(stringBuilder.ToString()); byte[] AesMac = AesUtil.Encrypt(byteMac, ProtocolConstant.USB_DOG_PASSWORD); //存入数据库 //setter.Set_Unique_Id = Encoding.GetEncoding("GBK").GetString(AesMac); setter.Set_Unique_Id = ProtocolUtil.BytesToString(AesMac); /*AES解密 * byte[] a = ProtocolUtil.StringToBcd(setter.Set_Unique_Id); * byte[] b = AesUtil.Decrypt(a, ProtocolConstant.USB_DOG_PASSWORD); * Console.WriteLine(Encoding.GetEncoding("GBK").GetString(b));*/ //默认照片路径,激活时获取(路径中不要有汉字) string basePath = System.AppDomain.CurrentDomain.BaseDirectory; string path = ConfigurationManager.AppSettings["PicPath"]; setter.Set_PhotoLocation = basePath + path; setter.Set_Language = 1; setter.Pk_Set_Id = 1; //设置版本号 setter.Set_Version = CommUtil.GetCurrentVersion(); if (!Directory.Exists(@setter.Set_PhotoLocation)) { Directory.CreateDirectory(@setter.Set_PhotoLocation);//不存在就创建目录 } /*if (Directory.Exists(@setter.Set_PhotoLocation)) { //存在就删除 * Directory.Delete(@setter.Set_PhotoLocation, true); * Directory.CreateDirectory(@setter.Set_PhotoLocation); * }*/ setterDAO.InsertOneMacAdress(setter); }
private void Buttonlz_Click_2(object sender, RoutedEventArgs e) { entity.Setter setter = new entity.Setter(); setter.Pk_Set_Id = 1; setter.Set_Language = entity.Setter.SET_LANGUAGE_CHINA; setter.Set_OrganizationName = "1"; setter.Set_OrganizationPhone = "2"; setter.Set_OrganizationSort = "3"; setter.Set_PhotoLocation = "4"; //自封装 //string str = JsonTools.Obj2JSONStr<entity.Setter>(setter); //blog string str = JsonTools.Obj2JSONStrNew(setter); System.Windows.MessageBox.Show(str); }