当前位置: 首页>>代码示例>>C#>>正文


C# StreamReader.GetString方法代码示例

本文整理汇总了C#中System.IO.StreamReader.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.GetString方法的具体用法?C# StreamReader.GetString怎么用?C# StreamReader.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StreamReader的用法示例。


在下文中一共展示了StreamReader.GetString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleRequest

 public void HandleRequest(HttpListenerContext context)
 {
     NameValueCollection query;
     using (StreamReader rdr = new StreamReader(context.Request.InputStream))
     {
         query = HttpUtility.ParseQueryString(rdr.ReadToEnd());
     }
     int offset = int.Parse(query["offset"]);
     using (Database dbx = new Database())
     {
         var cmd = dbx.CreateQuery();
         cmd.CommandText = "SELECT * FROM info ORDER BY date DESC LIMIT 1 OFFSET @off;";
         cmd.Parameters.AddWithValue("@off", offset);
         using (var rdr = cmd.ExecuteReader())
         {
             rdr.Read();
             var page = new PageItem()
             {
             };
             page.Name = rdr.GetString("name");
             List<string> contents = new List<string>();
             if (rdr.GetInt32("newsType") == 0)
             {
                 foreach (var i in rdr.GetString("contents").Split('&'))
                 {
                     contents.Add(i);
                 }
                 page.ContentType = 0;
                 page.ContentLines = contents.ToArray();
             }
             else
             {
                 foreach (var i in rdr.GetString("contents").Split('&'))
                     contents.Add(i);
                 page.ContentType = rdr.GetInt32("newsType");
                 page.ContentLines = contents.ToArray();
             }
             DateTime time = rdr.GetDateTime("date");
             page.Date = time.ToString("g");
             if (!rdr.IsDBNull(rdr.GetOrdinal("link")) && rdr.GetString("link") != "")
             {
                 page.Link = rdr.GetString("link");
             }
             byte[] fff = Encoding.ASCII.GetBytes(page.ToString());
             context.Response.OutputStream.Write(fff, 0, fff.Length);
             context.Response.Close();
         }
         dbx.Dispose();
     }
 }
开发者ID:RiiggedMPGH,项目名称:Owl-Realms-Source,代码行数:50,代码来源:Handlers.cs

示例2: HandleRequest

        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (StreamReader rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());
            using (var db = new Database())
            {
                var acc = db.GetAccount(int.Parse(query["accountId"]));
                var chr = db.LoadCharacter(acc, int.Parse(query["charId"]));

                var cmd = db.CreateQuery();
                cmd.CommandText = @"SELECT time, killer, firstBorn FROM death WHERE [email protected] AND [email protected];";
                cmd.Parameters.AddWithValue("@accId", query["accountId"]);
                cmd.Parameters.AddWithValue("@charId", query["charId"]);
                int time;
                string killer;
                bool firstBorn;
                using (var rdr = cmd.ExecuteReader())
                {
                    rdr.Read();
                    time = Database.DateTimeToUnixTimestamp(rdr.GetDateTime("time"));
                    killer = rdr.GetString("killer");
                    firstBorn = rdr.GetBoolean("firstBorn");
                }

                using (StreamWriter wtr = new StreamWriter(context.Response.OutputStream))
                    wtr.Write(chr.FameStats.Serialize(acc, chr, time, killer, firstBorn));
            }
        }
开发者ID:lcnvdl,项目名称:rotmg-server,代码行数:29,代码来源:fame.cs

示例3: IsSatisfiedBy

        public ConventionResult IsSatisfiedBy(DatabaseSpecimen databaseSpecimen)
        {
            var resourceName = GetType().FullName + ".sql";

            var assembly =
                GetType().Assembly.GetManifestResourceNames().Contains(resourceName) ?
                GetType().Assembly : typeof(DatabaseConventionSpecification).Assembly;

            string script; 
            using (var stream = assembly.GetManifestResourceStream(resourceName))
            using (var reader = new StreamReader(stream))
            {
                script = reader.ReadToEnd();
            }

            if (string.IsNullOrWhiteSpace(script))
            {
                throw new InvalidOperationException("Resource identified did not contain any SQL script.");
            }

            var failures = new List<string>();
            using (IDbConnection dbConnection = new SqlConnection(databaseSpecimen.ConnectionString))
            {
                dbConnection.Open();
                var command = dbConnection.CreateCommand();
                command.CommandText = script;

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        failures.Add(reader.GetString(0));
                    }
                }
            }

            if (failures.Any())
            {
                return ConventionResult.NotSatisfied(DatabaseConventionResultIdentifier,
                    FailureMessage + Environment.NewLine +
                    failures.Aggregate((x, y) => x + Environment.NewLine + y));
            }

            return ConventionResult.Satisfied(DatabaseConventionResultIdentifier);
        }
开发者ID:Rophuine,项目名称:Conventional,代码行数:45,代码来源:DatabaseConventionSpecification.cs

示例4: HandleRequest

        public override void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            if (query.AllKeys.Length == 0)
            {
                string queryString = string.Empty;
                string currUrl = context.Request.RawUrl;
                int iqs = currUrl.IndexOf('?');
                if (iqs >= 0)
                {
                    query =
                        HttpUtility.ParseQueryString((iqs < currUrl.Length - 1)
                            ? currUrl.Substring(iqs + 1)
                            : String.Empty);
                }
            }

            using (var db = new Database(Program.Settings.GetValue("conn")))
            {
                Account acc = db.GetAccount(int.Parse(query["accountId"]));
                Char chr = db.LoadCharacter(acc, int.Parse(query["charId"]));

                MySqlCommand cmd = db.CreateQuery();
                cmd.CommandText = @"SELECT time, killer, firstBorn FROM death WHERE [email protected] AND [email protected];";
                cmd.Parameters.AddWithValue("@accId", query["accountId"]);
                cmd.Parameters.AddWithValue("@charId", query["charId"]);
                int time;
                string killer;
                bool firstBorn;
                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    rdr.Read();
                    time = Database.DateTimeToUnixTimestamp(rdr.GetDateTime("time"));
                    killer = rdr.GetString("killer");
                    firstBorn = rdr.GetBoolean("firstBorn");
                }

                using (var wtr = new StreamWriter(context.Response.OutputStream))
                    wtr.Write(chr.FameStats.Serialize(Program.GameData, acc, chr, time, killer, firstBorn));
            }
        }
开发者ID:Club559,项目名称:Travs-Domain-Server,代码行数:44,代码来源:fame.cs

示例5: HandleRequest

        public override void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            if (query.AllKeys.Length == 0)
            {
                string queryString = string.Empty;
                string currUrl = context.Request.RawUrl;
                int iqs = currUrl.IndexOf('?');
                if (iqs >= 0)
                {
                    query =
                        HttpUtility.ParseQueryString((iqs < currUrl.Length - 1)
                            ? currUrl.Substring(iqs + 1)
                            : String.Empty);
                }
            }

            byte[] status = null;

            string span = "";
            switch (query["timespan"])
            {
                case "week":
                    span = "(time >= DATE_SUB(NOW(), INTERVAL 1 WEEK))";
                    break;
                case "month":
                    span = "(time >= DATE_SUB(NOW(), INTERVAL 1 MONTH))";
                    break;
                case "all":
                    span = "TRUE";
                    break;
                default:
                    status = Encoding.UTF8.GetBytes("<Error>Invalid fame list</Error>");
                    break;
            }
            string ac = "FALSE";
            if (query["accountId"] != null)
                ac = "([email protected] AND [email protected])";

            if (status == null)
            {

                XmlDocument doc = new XmlDocument();
                var root = doc.CreateElement("FameList");

                var spanAttr = doc.CreateAttribute("timespan");
                spanAttr.Value = query["timespan"];
                root.Attributes.Append(spanAttr);

                doc.AppendChild(root);

                using (var db = new Database(Program.Settings.GetValue("conn")))
                {
                    var cmd = db.CreateQuery();
                    cmd.CommandText = @"SELECT * FROM death WHERE " + span + @" OR " + ac +
                                      @" ORDER BY totalFame DESC LIMIT 10;";
                    if (query["accountId"] != null)
                    {
                        cmd.Parameters.AddWithValue("@accId", query["accountId"]);
                        cmd.Parameters.AddWithValue("@charId", query["charId"]);
                    }
                    using (var rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            var elem = doc.CreateElement("FameListElem");

                            var accIdAttr = doc.CreateAttribute("accountId");
                            accIdAttr.Value = rdr.GetInt32("accId").ToString();
                            elem.Attributes.Append(accIdAttr);
                            var chrIdAttr = doc.CreateAttribute("charId");
                            chrIdAttr.Value = rdr.GetInt32("chrId").ToString();
                            elem.Attributes.Append(chrIdAttr);

                            root.AppendChild(elem);

                            var nameElem = doc.CreateElement("Name");
                            nameElem.InnerText = rdr.GetString("name");
                            elem.AppendChild(nameElem);
                            var objTypeElem = doc.CreateElement("ObjectType");
                            objTypeElem.InnerText = rdr.GetString("charType");
                            elem.AppendChild(objTypeElem);
                            var tex1Elem = doc.CreateElement("Tex1");
                            tex1Elem.InnerText = rdr.GetString("tex1");
                            elem.AppendChild(tex1Elem);
                            var tex2Elem = doc.CreateElement("Tex2");
                            tex2Elem.InnerText = rdr.GetString("tex2");
                            elem.AppendChild(tex2Elem);
                            var skinElem = doc.CreateElement("Skin");
                            skinElem.InnerText = rdr.GetString("skin");
                            elem.AppendChild(skinElem);
                            var equElem = doc.CreateElement("Equipment");
                            equElem.InnerText = rdr.GetString("items");
                            elem.AppendChild(equElem);
                            var fameElem = doc.CreateElement("TotalFame");
                            fameElem.InnerText = rdr.GetString("totalFame");
                            elem.AppendChild(fameElem);
//.........这里部分代码省略.........
开发者ID:Club559,项目名称:Travs-Domain-Server,代码行数:101,代码来源:list.cs

示例6: HandleRequest

        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            byte[] status = null;

            string span = "";
            switch (query["timespan"])
            {
                case "week":
                    span = "(time >= DATE_SUB(NOW(), INTERVAL 1 WEEK))";
                    break;
                case "month":
                    span = "(time >= DATE_SUB(NOW(), INTERVAL 1 MONTH))";
                    break;
                case "all":
                    span = "TRUE";
                    break;
                default:
                    status = Encoding.UTF8.GetBytes("<Error>Invalid fame list</Error>");
                    break;
            }
            string ac = "FALSE";
            if (query["accountId"] != null)
                ac = "([email protected] AND [email protected])";

            if (status == null)
            {
                var doc = new XmlDocument();
                XmlElement root = doc.CreateElement("FameList");

                XmlAttribute spanAttr = doc.CreateAttribute("timespan");
                spanAttr.Value = query["timespan"];
                root.Attributes.Append(spanAttr);

                doc.AppendChild(root);

                using (var db = new Database())
                {
                    MySqlCommand cmd = db.CreateQuery();
                    cmd.CommandText = @"SELECT * FROM death WHERE " + span + @" OR " + ac +
                                      @" ORDER BY totalFame DESC LIMIT 20;";
                    if (query["accountId"] != null)
                    {
                        cmd.Parameters.AddWithValue("@accId", query["accountId"]);
                        cmd.Parameters.AddWithValue("@charId", query["charId"]);
                    }
                    using (MySqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            XmlElement elem = doc.CreateElement("FameListElem");

                            XmlAttribute accIdAttr = doc.CreateAttribute("accountId");
                            accIdAttr.Value = rdr.GetInt32("accId").ToString();
                            elem.Attributes.Append(accIdAttr);
                            XmlAttribute chrIdAttr = doc.CreateAttribute("charId");
                            chrIdAttr.Value = rdr.GetInt32("chrId").ToString();
                            elem.Attributes.Append(chrIdAttr);

                            root.AppendChild(elem);

                            XmlElement nameElem = doc.CreateElement("Name");
                            nameElem.InnerText = rdr.GetString("name");
                            elem.AppendChild(nameElem);
                            XmlElement objTypeElem = doc.CreateElement("ObjectType");
                            objTypeElem.InnerText = rdr.GetString("charType");
                            elem.AppendChild(objTypeElem);
                            XmlElement tex1Elem = doc.CreateElement("Tex1");
                            tex1Elem.InnerText = rdr.GetString("tex1");
                            elem.AppendChild(tex1Elem);
                            XmlElement tex2Elem = doc.CreateElement("Tex2");
                            tex2Elem.InnerText = rdr.GetString("tex2");
                            elem.AppendChild(tex2Elem);
                            XmlElement equElem = doc.CreateElement("Equipment");
                            equElem.InnerText = rdr.GetString("items");
                            elem.AppendChild(equElem);
                            XmlElement fameElem = doc.CreateElement("TotalFame");
                            fameElem.InnerText = rdr.GetString("totalFame");
                            elem.AppendChild(fameElem);
                        }
                    }
                    db.Dispose();
                }

                var settings = new XmlWriterSettings();
                settings.OmitXmlDeclaration = true;
                using (XmlWriter wtr = XmlWriter.Create(context.Response.OutputStream))
                    doc.Save(wtr);
            }
        }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:93,代码来源:list.cs

示例7: HandleRequest

        public override void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            MD5 md5Hash = MD5.Create();

            string url = Program.Settings.GetValue("webUrl");

            string accessKey = "name:" + query["guid"] + "pass:" + query["password"];
            string hash = GetMd5Hash(md5Hash, accessKey);

            using (var db = new Database(Program.Settings.GetValue("conn")))
            {
                db.InsertEmail(query["guid"], query["password"], hash);

                MySqlCommand cmd = db.CreateQuery();
                cmd.CommandText = "SELECT id, uuid, name, email FROM accounts WHERE [email protected]";
                cmd.Parameters.AddWithValue("@uuid", query["guid"]);
                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (!rdr.HasRows) return;
                    rdr.Read();

                    string to = rdr.GetString("email").ToLower();
                    string from = "[email protected]";
                    var message = new MailMessage(from, to);
                    message.Subject = "Email Verification for : " + rdr.GetString("uuid");
                    string htmlBody =
                        @"
            <html>
            <body style='font-family: 'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif;font-size: 13px;line-height: 20px;color: #333;margin:0;padding:0;'>
            <table cellspacing='0' cellpadding='0' border='0' width='100%'>
            <tr style='background: #3f3f3f'>
            <td class='navbar navbar-inverse' align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:auto;margin:0;padding:0;'>
                    <tr class='navbar navbar-inverse'>
                        <td><a style='margin:0px -3px;text-decoration:none;display: block;padding: 20px;font-size: 20px;font-weight: 200;color: rgb(241,241,241);text-shadow: 0px -1px 1px rgba(0, 0, 0, 0.55);' href='http://forum.kithio.com'>Forums</a></li></ul></td>
                    </tr>
                </table>
            </td>
            </tr>
            <tr style='background: #d6d6d6;'>
            <td align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:960px;margin-top:15px;'>
                    <tr>
                        <th colspan='2'><h1 style='margin: 10px 0px;font-family: inherit;font-weight: bold;line-height: 40px;font-size: 36px;color: inherit;text-rendering: optimizelegibility;margin-bottom: 35px;'>Email Verification</h1></th>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Account Name : </p></td><td style='width:58%;'><b>" +
                        rdr.GetString("uuid") + @"</b></td>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Character Name : </p></td><td style='width:58%;'><b>" +
                        rdr.GetString("name") + @"</b></td>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Email Address : </p></td><td style='width:58%;'><b style='color:#0063CA;text-decoration:none;'>" +
                        rdr.GetString("email") + @"</b></td>
                    </tr>
                    <tr>
                        <td colspan='2' align='center'>
                            <hr style='margin: 10px 0px;margin-top:35px;border-right: 0px none;border-left: 0px none;-moz-border-top-colors: none;-moz-border-right-colors: none;-moz-border-bottom-colors: none;-moz-border-left-colors: none;border-image: none;border-width: 1px 0px;border-style: solid none;border-color: #EEE -moz-use-text-color #FFF;'>
                            <p style='line-height: 20px;color: #333;font-size: 13px;'>
                                <a style='color: #0063CA;text-decoration: none;' href='http://" + url + @"/verify.php?email=" +
                        rdr.GetString("email").Replace("@", "%40") + @"&key=" + hash + @"'>
                                    <b><h3 style='font-size: 24px;line-height: 40px;margin-top: 30px;margin-bottom:20px;'>Click Here to Verify your Email Address</h3></b>
                                </a>
                            </p>
                        </td>
                    </tr>
                </table>
            </td>
            </tr>
            <tr style='background: #d6d6d6;'>
            <td align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:960px;'>
                    <tr>
                        <td align='center' style='font-size:12pt;'>
                            <hr style='border-right: 0px none;border-left: 0px none;-moz-border-top-colors: none;-moz-border-right-colors: none;-moz-border-bottom-colors: none;-moz-border-left-colors: none;border-image: none;border-width: 1px 0px;border-style: solid none;border-color: #EEE -moz-use-text-color #FFF;'>
                            <p style='height:80px;margin-bottom:35px;'><b>Copyright &copy; 2014 | <a style='color: #0063CA;text-decoration:none;' href='http://forum.kithio.com'>Kithio</a></b></p>
                        </td>
                    </tr>
                </table>
            </td>
            </tr>
            </table>
            </body>
            </html>
            ";
                    message.Body = htmlBody;
                    message.IsBodyHtml = true;
                    var client = new SmtpClient();
                    // Credentials are necessary if the server requires the client
                    // to authenticate before it will send e-mail on the client's behalf.
                    client.Port = 587;
                    client.Host = "smtp.mandrillapp.com";
                    client.Credentials = new NetworkCredential("[email protected]", "xI7YXXrmtLC5BdwIEzsG0w");

//.........这里部分代码省略.........
开发者ID:Club559,项目名称:Travs-Domain-Server,代码行数:101,代码来源:sendVerifyEmail.cs

示例8: HandleRequest

        public override void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            if (query.AllKeys.Length == 0)
            {
                string queryString = string.Empty;
                string currUrl = context.Request.RawUrl;
                int iqs = currUrl.IndexOf('?');
                if (iqs >= 0)
                {
                    query =
                        HttpUtility.ParseQueryString((iqs < currUrl.Length - 1)
                            ? currUrl.Substring(iqs + 1)
                            : String.Empty);
                }
            }

            using (var db = new Database(Program.Settings.GetValue("conn")))
            {
                var cmd = db.CreateQuery();

                string user = query["guid"];

                string owner = "";
                bool isOwner = false;

                cmd.CommandText = "SELECT guid FROM sprites WHERE [email protected] LIMIT 1";
                cmd.Parameters.AddWithValue("@id", query["id"]);

                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (!rdr.HasRows) return;
                    rdr.Read();

                    owner = rdr.GetString("guid");

                    if (user == owner)
                    {
                        isOwner = true;
                    }
                }
                byte[] status = Encoding.UTF8.GetBytes("<Error>You can't delete this sprite</Error>");
                if (isOwner)
                {
                    cmd = db.CreateQuery();
                    cmd.CommandText = "DELETE FROM sprites WHERE([email protected] AND [email protected]) LIMIT 1";
                    cmd.Parameters.AddWithValue("@id", query["id"]);
                    cmd.Parameters.AddWithValue("@guid", owner);

                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        status = Encoding.UTF8.GetBytes("<Success/>");
                    }
                    context.Response.OutputStream.Write(status, 0, status.Length);
                    return;
                }

                context.Response.OutputStream.Write(status, 0, status.Length);
            }
        }
开发者ID:Club559,项目名称:Travs-Domain-Server,代码行数:63,代码来源:delete.cs

示例9: download_commands

        //download commands from the database
        private void download_commands()
        {
            MySqlConnection connection = new MySqlConnection();
            connection.ConnectionString = ConnectionInfo.mysqlLogin;
            MySqlDataReader reader = null;
            MySqlCommand command = new MySqlCommand("SELECT * FROM `BotCommands`", connection);
            try
            {
                connection.Open();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    list_of_commands.Add(new chat_command(reader.GetString(1), reader.GetString(2)));
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                if (connection != null)
                {
                    connection.Close();
                }
            }
        }
开发者ID:Mayumu,项目名称:HonokaBot,代码行数:33,代码来源:TwitchBot.cs

示例10: HandleRequest

        public override void HandleRequest(HttpListenerContext context)
        {
            var rand = new Random();
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db = new Database(Program.Settings.GetValue("conn")))
            {
                byte[] status;

                var password = CreatePassword(rand.Next(8, 12));

                if (!db.HasEmail(query["email"]))
                    status = Encoding.UTF8.GetBytes("<Error>Account not found</Error>");
                else if (!IsValidEmail(query["email"]))
                    status = Encoding.UTF8.GetBytes("<Error>Invalid email address</Error>");
                else
                {
                    MySqlCommand cmd = db.CreateQuery();
                    cmd.CommandText = "UPDATE accounts SET password=SHA1(@password) WHERE [email protected];";
                    cmd.Parameters.AddWithValue("@email", query["email"]);
                    cmd.Parameters.AddWithValue("@password", password);

                    if (cmd.ExecuteNonQuery() == 0)
                        status = Encoding.UTF8.GetBytes("<Error>Could not reset account password!</Error>");
                    else
                    {
                        cmd = db.CreateQuery();
                        cmd.CommandText = "SELECT id, uuid, name, email FROM accounts WHERE [email protected]";
                        cmd.Parameters.AddWithValue("@email", query["email"]);
                        using (MySqlDataReader rdr = cmd.ExecuteReader())
                        {
                            if (!rdr.HasRows) return;
                            rdr.Read();

                            var to = rdr.GetString("email").ToLower();
                            const string @from = "[email protected]";
                            var message = new MailMessage(from, to)
                            {
                                Subject = "Email Verification for : " + rdr.GetString("name")
                            };
                            string htmlBody =
                                @"
            <html>
            <body style='font-family: 'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif;font-size: 13px;line-height: 20px;color: #333;margin:0;padding:0;'>
            <table cellspacing='0' cellpadding='0' border='0' width='100%'>
            <tr style='background: #3f3f3f'>
            <td class='navbar navbar-inverse' align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:auto;margin:0;padding:0;'>
                    <tr class='navbar navbar-inverse'>
                        <td><a style='margin:0px -3px;text-decoration:none;display: block;padding: 20px;font-size: 20px;font-weight: 200;color: rgb(241,241,241);text-shadow: 0px -1px 1px rgba(0, 0, 0, 0.55);' class='brand' href='http://zerorealms.com'>Home Page</a></td>
                        <td><a style='margin:0px -3px;text-decoration:none;display: block;padding: 20px;font-size: 20px;font-weight: 200;color: rgb(241,241,241);text-shadow: 0px -1px 1px rgba(0, 0, 0, 0.55);' href='http://forum.zerorealms.com'>Forums</a></li></ul></td>
                    </tr>
                </table>
            </td>
            </tr>
            <tr style='background: #d6d6d6;'>
            <td align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:960px;margin-top:15px;'>
                    <tr>
                        <th colspan='2'><h1 style='margin: 10px 0px;font-family: inherit;font-weight: bold;line-height: 40px;font-size: 36px;color: inherit;text-rendering: optimizelegibility;margin-bottom: 35px;'>Forgot Password</h1></th>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Account Name : </p></td><td style='width:58%;'><b>" +
                                rdr.GetString("uuid") + @"</b></td>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Character Name : </p></td><td style='width:58%;'><b>" +
                                rdr.GetString("name") + @"</b></td>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>Email Address : </p></td><td style='width:58%;'><b style='color:#0063CA;text-decoration:none;'>" +
                                rdr.GetString("email") + @"</b></td>
                    </tr>
                    <tr style='height:80px;'>
                        <td colspan='2' align='center' style='width:100%;'><p style='font-weight:600;color:#474747;'>A password reset has been requested for the account described above.<br />We've generated a new password for your account that is active immediately.<br />Please use the password shown below when you login.</p></td>
                    </tr>
                    <tr style='height:40px;'>
                        <td align='right' style='width:42%;'><p style='font-weight:600;color:#474747;'>New Password : </p></td><td style='width:58%;'><b style='color:#0063CA;text-decoration:none;'>" +
                                password + @"</b></td>
                    </tr>
                </table>
            </td>
            </tr>
            <tr style='background: #d6d6d6;'>
            <td align='center'>
                <table width='650px' cellspacing='0' cellpadding='3' class='container' style='width:960px;'>
                    <tr>
                        <td align='center' style='font-size:12pt;'>
                            <hr style='border-right: 0px none;border-left: 0px none;-moz-border-top-colors: none;-moz-border-right-colors: none;-moz-border-bottom-colors: none;-moz-border-left-colors: none;border-image: none;border-width: 1px 0px;border-style: solid none;border-color: #EEE -moz-use-text-color #FFF;'>
                            <p style='height:80px;margin-bottom:35px;'><b>Copyright &copy; 2013-2014 | <a style='color: #0063CA;text-decoration:none;' href='http://zerorealms.com'>ZeroRealms.com</a> - Lucifer</b></p>
                        </td>
                    </tr>
                </table>
            </td>
            </tr>
            </table>
            </body>
            </html>";
//.........这里部分代码省略.........
开发者ID:Club559,项目名称:Travs-Domain-Server,代码行数:101,代码来源:forgotPassword.cs


注:本文中的System.IO.StreamReader.GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。