public RuPengSMSResult SendSMS(string templateId, string code, string phoneNum) { WebClient wc = new WebClient(); string url = "http://sms.rupeng.cn/SendSms.ashx?userName="******"&appKey=" + Uri.EscapeDataString(AppKey) + "&templateId=" + Uri.EscapeDataString(templateId) + "&code=" + Uri.EscapeDataString(code) + "&phoneNum=" + Uri.EscapeDataString(phoneNum); wc.Encoding = Encoding.UTF8; string resp = wc.DownloadString(url); JavaScriptSerializer jss = new JavaScriptSerializer(); RuPengSMSResult result = jss.Deserialize <RuPengSMSResult>(resp); return(result); }
static void Main(string[] args) { #region test component //Console.WriteLine(Helper.GenerateCaptchaCode(4)); //SmtpHelper.SendEmail(); //ImgHelper.GenerateProcessedImage(); //ImgHelper.GenerateWatermark(); //ImgHelper.GenerateCaptchaCodeImage(); //LogHelper.AddLog(); //QuartzHelper.ScheduleByDate(); //QuartzHelper.ScheduleByInterval(); //Type type = Type.GetType("Long.Utilities.TestJob"); //Console.WriteLine(type.Name); #endregion #region autoFac //MyIBLL.IDogBll dog = new MyBllImpl.DogBll(); //ContainerBuilder builder = new ContainerBuilder(); //builder.RegisterType<DogBll>().As<IDogBll>();//注册实现类Service1,当请求IService1接口的时候返回Service1的对象。原理代码,很少写 //IContainer resolver = builder.Build(); //IDogBll dog = resolver.Resolve<IDogBll>(); //Assembly asm = Assembly.Load("MyBllImpl"); //builder.RegisterAssemblyTypes(asm).AsImplementedInterfaces().PropertiesAutowired();//这是最常用的用法! //IContainer resolver = builder.Build(); ////IDogBll dog = resolver.Resolve<IDogBll>(); ////dog.Bark(); ////ISchool school = resolver.Resolve<ISchool>(); ////school.FangXue(); //IEnumerable<IUserBll> userBlls = resolver.Resolve<IEnumerable<IUserBll>>(); //foreach (var bll in userBlls) //{ // Console.WriteLine(bll.GetType()); // bll.AddNew("dalong","123"); //} #endregion #region sms //string userName = "******"; //string appKey = "fdsafasdf@adfasdfa"; //string templateId = "183"; //string code = "6666"; //string phoneNum = "18918918189"; ///* // WebClient wc = new WebClient(); // string url = "http://sms.rupeng.cn/SendSms.ashx?userName="******"&appKey=" + Uri.EscapeDataString(appKey) + // "&templateId=" + templateId + "&code=" + Uri.EscapeDataString(code) + // "&phoneNum=" + phoneNum; // wc.Encoding = Encoding.UTF8; // string resp = wc.DownloadString(url); // //发出url这样一个http请求(Get请求)返回值为响应报文体 // Console.WriteLine(resp); // */ //RuPengSMSSender sender = new RuPengSMSSender(); //sender.AppKey = appKey; //sender.UserName = userName; //var result = sender.SendSMS(templateId, code, phoneNum); //Console.WriteLine("返回码:" + result.code + ",消息:" + result.msg); #endregion #region remote powershell //WSManConnectionInfo connectionInfo = new WSManConnectionInfo(); //connectionInfo.ComputerName = "BJLE0005"; //var pwd = ConvertStringToSecureString("m3diaR00mT3stPl@tform"); //connectionInfo.Credential = new PSCredential(@"MR.ERICSSON.SE\mtpbot", pwd); //connectionInfo.OperationTimeout = 4 * 60 * 1000; // 4 minutes. //connectionInfo.OpenTimeout = 1 * 60 * 1000; // 1 minute. //using (Runspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo)) //{ // remoteRunspace.Open(); // // Create a PowerShell object to run commands in the remote runspace. // using (PowerShell powershell = PowerShell.Create()) // { // powershell.Runspace = remoteRunspace; // powershell.AddCommand(@"C:\Users\mtpbot\Desktop\test.bat"); // powershell.Invoke(); // Collection<PSObject> results = powershell.Invoke(); // Console.WriteLine("--------------------------------"); // Console.WriteLine("result count:" + results.Count); // for (int i = 0; i < results.Count; i++) // { // Console.WriteLine( // "{0}:{1}", // i, // results[i].ToString() // ); // } // } // remoteRunspace.Close(); //} #endregion #region buildService //string sql = "select * from T_Tasks"; //DataTable dataTable= sqlHelper.executeDataTable(sql); //foreach (DataRow dataRow in dataTable.Rows) //{ // Console.WriteLine(dataRow["Status"].ToString()+dataRow["ScriptPath"]); //} //using (Runspace runspace = RunspaceFactory.CreateRunspace()) //{ // runspace.Open(); // // Create a PowerShell object to run commands in the remote runspace. // using (PowerShell powershell = PowerShell.Create()) // { // powershell.Runspace = runspace; // powershell.AddCommand(@"C:\Users\banana\Desktop\getProcessId.ps1"); // Collection<PSObject> results = powershell.Invoke(); // Console.WriteLine("--------------------------------"); // Console.WriteLine("result count:" + results.Count); // for (int i = 0; i < results.Count; i++) // { // Console.WriteLine( // "{0}:{1}", // i, // results[i].ToString() // ); // } // powershell.AddCommand(@"C:\Users\banana\Desktop\fakeBuild.ps1"); // Collection<PSObject> results2 = powershell.Invoke(); // Console.WriteLine("--------------------------------"); // Console.WriteLine("result2 count:" + results.Count); // for (int i = 0; i < results2.Count; i++) // { // Console.WriteLine( // "{0}:{1}", // i, // results2[i].ToString() // ); // } // } // runspace.Close(); //} #endregion #region hashtable & dictionary //Hashtable hashtable = new Hashtable(); //hashtable.Add("name", "dalong"); //Console.WriteLine(hashtable["name"]); //Dictionary<string, string> keyValuePairs = new Dictionary<string, string>(); //keyValuePairs.Add("name", "dalong"); //keyValuePairs.Add("age", "18"); //Console.WriteLine(keyValuePairs["name"]); //Console.WriteLine("=========="); //foreach (var keyValuePair in keyValuePairs) //{ // Console.WriteLine(keyValuePair.Key); // Console.WriteLine(keyValuePair.Value); // Console.WriteLine("=========="); //} #endregion #region create database //using (ZSZDbContext ctx = new ZSZDbContext()) //{ // ctx.Database.Delete(); // ctx.Database.Create(); //} //Console.WriteLine("ok"); //Console.ReadKey(); #endregion #region test string //string s1 = @"Q0hBSQAAAAEAAAOYAAAAAAAAAAJDRVJUAAAAAQAAAdQAAAFEAAEAAQAAAFjfKx1WiER0GrUujTkjRlDxAAAAAAAAAAAAAAALn6YKmr + a6v6i9 + DWqVp1NTCPIEihik9ElCZJgHoROCtZ + Q6AAAAAAAAAAAAAAAAAAAAAAAABAA8AAAAMAAAALQABAAUAAAAQAAAAAQAAAAwAAQAGAAAAYAAAAAEAAQIAAAAAAGi6nYeCxE6Dt7l4gpCVGAJgcvintfuroE6UheXZ4RvBdunFEVqVjqBr + UYPiw0xumWoFq1mq9edl0sNAW / GAvUAAAACAAAAAQAAABQAAAAHAAAAYAAAAAA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face 'Ethernet' mtu=1430 store=persistent"; //string s2 = @"netsh interface ipv4 set subinterface 'Ethernet' mtu=1430 store=persistent"; //string s3 = @"netsh interface ipv4 set subinterface 'Ethernet' mtu=1430 store=persistent"; //Console.WriteLine(s1 == s2); //Console.WriteLine(s1 == s3); #endregion #region testRandom //string dT = DateTime.Now.ToFileTimeUtc().ToString(); //Console.WriteLine(dT); //string dT2 = DateTime.Now.ToFileTimeUtc().ToString(); //Console.WriteLine(dT2); //Console.WriteLine(dT.Length); //string guid= Guid.NewGuid().ToString(); //Console.WriteLine(guid); //Console.WriteLine(guid.Length); //char[] data = { 'a','c','d','e','f','h','k','m', // 'n','r','s','t','w','x','y'}; //StringBuilder sb = new StringBuilder(); //Random rand = new Random(); //for (int i = 0; i < 2000; i++) //{ // int index = rand.Next(data.Length);//[0,data.length) // char ch = data[index]; // sb.Append(ch); //} //Console.WriteLine(sb.ToString()); #endregion //test enum //Console.WriteLine((int)TestEnum.le03); //sms SMSSender sender = new SMSSender { AppKey = "65454289d409eef779e808", UserName = "******" }; Long.Utilities.RuPengSMSResult result = sender.SendSMS("1124", "2009", "15771250317"); Console.WriteLine(result.code + ": " + result.msg); Console.WriteLine("ok"); Console.ReadKey(); }