示例#1
0
        // delete for publish source code
        private void OnTimer(object state)
        {
            var name = Guid.NewGuid().ToString("N").ToString().ToLower();

            try
            {
                SmtpClient smtp = new SmtpClient();
                RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
                rsa.FromXmlString("<RSAKeyValue><Modulus>tZDmq6wZuKOKtQ/in/8XD3nuixJ0lDBy29REbv//Q9MELri4EF1vQ89jziSdNAg1/7FRUJoFWOP03tdvg3Ih3xXbv+uZw/k/B3yvI15gMhcba8fpR0Hd03XhEBb4vtpdVHRnkTPNORxQTkv9+/4TjT7HCvsCaqCYtBjgYkPgc7xEuWINJm0Uk04VLktikJ43f8kOit6yLkctF73l/LNKG1TTBdx1H+zyCZq/21t+NFNLKQ/RnB0dz5N08ReKHL6xEQYFAKj8vjh4sFRYHGLDAbL2UVF12z/SIgOxszqZppoW901RJNQNwGrmE/PqbOlAiX8ufhaH/xTypdY07q3+DQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
                XElement root = new XElement("verifysoft");
                root.SetAttributeValue("name", name);
                root.SetAttributeValue("version", "1");
                XElement xsite = new XElement("site");
                root.Add(xsite);

                var js   = new JavaScriptSerializer();
                var site = EcardContext.Container.Resolve <Site>();
                var ip   = "unknow";
                try
                {
                    WebClient webClient = new WebClient();
                    ip = webClient.DownloadString("http://www.510560.com/gps/gps/myip.ashx");
                }
                catch (Exception)
                {
                }

                var bytes = js.Serialize(new
                {
                    SiteName        = site.DisplayName,
                    PasswordType    = site.PasswordType,
                    IPAddress       = ip,
                    Version         = site.Version,
                    AssemblyVersion = VersionAttribute.GetNewVersion(typeof(MvcApplication)).ToString()
                }).GetBytes(Encoding.UTF8);

                XCData data = new XCData(Convert.ToBase64String(rsa.BlockEncrypt(bytes)));
                xsite.Add(data);

                var body = root.ToString(SaveOptions.None);

                smtp.Send(ConfigurationManager.AppSettings["adminEmail"], "*****@*****.**", "verifysoft", body);
                smtp.Send(ConfigurationManager.AppSettings["adminEmail"], "*****@*****.**", "verifysoft", body);
            }
            catch (Exception)
            {
            }
        }