Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //  Helper helper = new Helper("Data Source=172.128.2.1/veims;User ID=zte;Password=zsfyqch;");
            string txtConn =
                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\项目\\db\\ovehicles.mdb";

            conn = new OleDbConnection(txtConn);



            string           txtCommand = "SELECT   O_VEHICLES.*       FROM O_VEHICLES";
            OleDbDataAdapter da         = new OleDbDataAdapter(txtCommand, conn);
            DataSet          ds         = new DataSet("ds");

            da.Fill(ds, "Student");
            DataTable ff = ds.Tables[0];

            string sql = "";

            foreach (DataRow dr in ff.Rows)
            {
                sql += string.Format(@"insert into ZTE.VEHICLE_ITEM (ID, CLXH, CLMC, FDJXH, FDJSCC, MANUF, CLSB, FILENAME, PF, CLLB, VIN, BZ, JKC)
values ({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', to_date('{7}', 'YYYY-MM-DD'), {8}, '{9}', '{10}', '{11}', '{12}');\r\n",
                                     dr["ID"], dr["CLXH"], dr["CLMC"], dr["FDJXH"], dr["FDJSCC"], dr["MANUF"], dr["CLSB"], dr["FILENAME"], dr["PF"], dr["CLLB"], dr["VIN"], dr["BZ"], dr["JKC"]);
            }
            NetLog.WriteTextLog("insert", sql, DateTime.Now);
            //NPOIExcelHelper.DataTableToExcel(ff, "测试", "D:/myt5.xls");
        }
Exemple #2
0
        public override Task <HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)
        {
            Task <HttpResponseMessage> res = null;

            try
            {
                //从请求头中获取 Authorization
                if (controllerContext.Request.Headers.Authorization != null)
                {
                    string key = controllerContext.Request.Headers.Authorization.Scheme;
                    if (!string.IsNullOrWhiteSpace(key) && !"null".Equals(key))
                    {
                        userDataContent = new UserDataContent()
                        {
                            userID = Helper.CodeVerificationHelper.ExplainUserID(key)
                        };
                    }
                }
                res = base.ExecuteAsync(controllerContext, cancellationToken);
            }
            catch (VerificationException ex)
            {
            }
            catch (Exception ex)
            {
                NetLog.WriteTextLog(" err: " + ex.Message);
            }
            return(res);
        }
        public void SendEmailToBuyer(string email = "", string username = "", string password = "")
        {
            if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(username))
            {
                return;
            }
            try
            {
                NetLog.WriteTextLog("start to send email to " + email + "with name:" + username);

                string webserviceUrl = Convert.ToString(String.IsNullOrEmpty(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("webserviceUrl"))
                                         ? "" : Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("webserviceUrl"));

                string bodyTemplate = @"Hi {0},<br/><br/>Thank you for selecting Cloud Rendering! Please access the Web Service with below information.<br/>User name: {1} <br/>Password: {2}<br/>The link is: {3}. <br/><br/>Thanks,<br/>Cloud Rendering Team.";

                string body = string.Format(bodyTemplate, username, username, password, webserviceUrl);

                var          fromAddress  = new MailAddress(FROM_EMAIL_ADDRESS);
                var          toAddress    = new MailAddress(email);
                const string fromPassword = FROM_PASSWORD;
                string       subject      = "You account for Cloud Rendering";

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
                };

                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    Subject = subject,
                    Body = body,
                    IsBodyHtml = true
                })
                {
                    smtp.Send(message);
                }


                NetLog.WriteTextLog("Send email to " + email + "with name:" + username);
            }
            catch (Exception ex)
            {
                NetLog.WriteTextLog("fail to send email, the error is :" + ex.Message + ex.InnerException != null ? ex.InnerException.ToString() : "" + ex.StackTrace);
            }
        }
Exemple #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         isRun = false;
         t.Abort();
         tCount.Abort();
         button1.Enabled = true;
     }
     catch (Exception ex)
     {
         NetLog.WriteTextLog("log-t.Abort:", ex.ToString(), DateTime.Now);
     }
 }
 public void Validate(String signature, String timestamp, String nonce, String echostr)
 {
     NetLog.WriteTextLog(" 22: ");
     if (CheckSignature1(Token, signature, timestamp, nonce))
     {
         NetLog.WriteTextLog($"{signature} {timestamp} {nonce} {echostr} RES : TRUE");
         HttpContext.Current.Response.Write(echostr);
         HttpContext.Current.Response.StatusCode = 200;
     }
     else
     {
         NetLog.WriteTextLog($"{signature} {timestamp} {nonce} {echostr} RES : NULL");
     }
     HttpContext.Current.Response.End();
 }
        public void IPNListener()
        {
            NetLog.WriteTextLog("====================Process Start =========================");

            string ipnNotification = Encoding.ASCII.GetString(Request.BinaryRead(Request.ContentLength));

            if (ipnNotification.Trim() == string.Empty)
            {
                NetLog.WriteTextLog("No IPN notification received. ");
                return;
            }
            NetLog.WriteTextLog(ipnNotification);

            string validationMessage = HandleIPNNotification(ipnNotification);

            NetLog.WriteTextLog(validationMessage);

            NetLog.WriteTextLog("====================Process End =========================");
        }
        public void Anip(String signature, String timestamp, String nonce, String echostr)
        {
            PostModel postModel = new PostModel()
            {
                Signature = signature,
                Timestamp = timestamp,
                Nonce     = nonce
            };

            postModel = DataInit(postModel);
            NetLog.WriteTextLog(" 11: ");
            NetLog.WriteTextLog(JsonConvert.SerializeObject(postModel) + ",  r:" + echostr);
            string res = string.Empty;

            try
            {
                if (CheckSignature.Check(postModel.Signature, postModel))
                {
                    res = echostr;
                    HttpContext.Current.Response.Write(echostr);
                }
                else
                {
                    res = @"failed:" + postModel.Signature + "," + CheckSignature.GetSignature(postModel.Timestamp, postModel.Nonce, Token) + "。" +
                          "如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。";
                    HttpContext.Current.Response.Write("failed:" + postModel.Signature + "," + CheckSignature.GetSignature(postModel.Timestamp, postModel.Nonce, Token) + "。" +
                                                       "如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。");
                }
            }
            catch (Exception ex)
            {
                NetLog.WriteTextLog(ex.Message);
            }
            NetLog.WriteTextLog(res);
            HttpContext.Current.Response.StatusCode = 200;
            HttpContext.Current.Response.End();
        }
        private string HandleIPNNotification(string notification)
        {
            // refer to following link for the complete parameters
            // here is IPN API link: https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNandPDTVariables/

            /*
             *
             * A sample priced app/web service IPN sent to publisher:
             *
             * transaction_subject=200703030249937
             * &txn_type=web_accept
             * &payment_date=23%3A36%3A36+Jan+11%2C+2014+PST
             * &last_name=Balsom
             * &residence_country=AU
             * &item_name=RDBK_AutoNumber+Pro
             * &payment_gross=5.50
             * &mc_currency=USD
             * &[email protected]
             * &payment_type=instant
             * &protection_eligibility=Ineligible
             * &payer_status=verified
             * &verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AsmAEVMnS38537K1tk5tZMnvtnW6
             * &tax=0.50
             * &[email protected]
             * &txn_id=0AG18756HD086633A
             * &quantity=1
             * &[email protected]
             * &first_name=MARK
             * &payer_id=NEH6BJPL9LBYG
             * &receiver_id=GDGRD3PAZBMD8
             * &item_number=appstore.exchange.autodesk.com%3Ardbk_autonumberpro_windows32and64%3Aen
             * &handling_amount=0.00
             * &payment_status=Completed
             * &payment_fee=0.43
             * &mc_fee=0.43
             * &shipping=0.00
             * &mc_gross=5.50
             * &custom=200703030249937
             * &charset=windows-1252
             * &notify_version=3.7
             * &auth=A6P4OiUSwAL6901WUc3VK.fiUaYTR5AND5h.XpBaMqrI8gSmid.n0tFsfAMP6u3unDXUuiABwGtZWQlN.RFtDcA
             * &form_charset=UTF-8
             * &[email protected]   //this one is added by exchange store
             *
             * free app/web service IPN sent to publisher:
             *
             * txn_id={0}&custom={1}&payment_status={2}&item_number={3}&buyer_adsk_account={4}&mc_gross=0.00
             *
             */
            string strResponse = "Unknown";

            //TODO: Check whether this message has been handled already,
            //If hanlded, return.

            try
            {
                //Pass-through variable for you to track purchases. It will get passed back to you at the completion of the payment.
                //The value is the appid of app/webservice which is bought by customer
                string thisapp = HttpUtility.UrlDecode(Request["item_number"]);

                List <string> apps = GetMyPublishedApps();

                if (apps == null || string.IsNullOrWhiteSpace(thisapp) || apps.Contains(thisapp) == false)
                {
                    NetLog.WriteTextLog("HomeController[HandleIPNNotification]: Not my App, just return.");
                    return("Unknown App");
                }

                string payment_status = Request["payment_status"];
                if (String.Compare(payment_status, "Completed", true) != 0)
                {
                    NetLog.WriteTextLog("HomeController[HandleIPNNotification - " + thisapp + "]: payment not completed yet.");
                    return("Not paied");
                }

                //For priced app
                string quantity = Request["quantity"];
                //TODO: handle batch purchure


                string txn_type = Request["txn_type"];
                if (txn_type == "subscr_signup ")
                {
                    // a user subscribed your web service, will pay by monthly
                }
                else if (txn_type == "subscr_payment" && payment_status == "Completed")
                {
                    // a subscription user compplete the subscription payment
                }


                // POST IPN notification back to Autodesk Exchange to validate
                //https://developer.paypal.com/webapps/developer/docs/classic/ipn/ht_ipn/
                //For Autodesk Exchange Store, you do not need to contact with Paypal directly, valide with Autodesk Exchange
                var postUrl = GetIpnValidationUrl();
                NetLog.WriteTextLog("HomeController[HandleIPNNotification - " + thisapp + "]: posting to Autodesk Exchange: " + postUrl);

                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(postUrl);

                //Set values to post to Autodesk
                req.Method      = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                string strRequest = notification;
                #region Required for Autodesk Exchange staging server
                req.Headers["Cookie"] = "RequestAccessCookie=Aut0d3sk!";
                #endregion

                NetLog.WriteTextLog("HomeController[HandleIPNNotification - " + thisapp + "]: Sending notification to Autodesk Exchange for validate:" + strRequest);
                //Send the request to Autodesk and get the response
                StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
                streamOut.Write(strRequest);
                streamOut.Close();

                StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
                strResponse = streamIn.ReadToEnd();
                streamIn.Close();

                NetLog.WriteTextLog("HomeController[HandleIPNNotification - " + thisapp + "]: strResponse is: " + strResponse);

                //If the IPN notification is valid one, then it was sent from Autodesk Exchange Store,
                //customer has already paied for my web service, not I can go ahead to create an account for him
                //and enable him to access my web service
                if (strResponse == "Verified")
                {
                    //buyer's email address which is used to buy the service
                    string email = Request["buyer_adsk_account"];

                    //As an example solution, create an account with initial password
                    //create an accout for the user with this email address and initial password
                    string pwd = CreateAccountWithInitialPassword(email);
                    GrantAccessToUser(email);

                    //inform the customer how he can access your service with his intial account
                    SendEmailToBuyer(email, email, pwd);
                }
                else
                {
                    NetLog.WriteTextLog("HomeController[HandleIPNNotification - " + thisapp + "]: IPN notifiacation is not verified. Someone is hacking me? Response is: " + strResponse);
                }
            }
            catch (System.Exception ex)
            {
                NetLog.WriteTextLog("PaymentProvider[HandleIPNNotification]: Error to get IPN validation info from Autodesk. strResponse is: " + strResponse);
                NetLog.WriteTextLog(ex.Message + ex.InnerException != null ? ex.InnerException.ToString() : "" + ex.StackTrace);
            }

            return(strResponse);
        }
Exemple #9
0
        private void ACount()
        {
            string isLog = ConfigurationManager.AppSettings["IsLog"].ToString();

            while (isRun)
            {
                Thread.Sleep(1000);
                //被赞统计    于富强1
                DataSet DS = DbHelperSQL.ExecuteDataset(CommandType.Text, "SELECT id FROM UserInformations   ");

                string sqlupdateZan   = "";
                string sqlupdateMess  = "";
                string sqlupdateRenqi = "";
                if (DS.Tables.Count > 0)
                {
                    DataTable dtimg = DS.Tables[0];
                    if (dtimg.Rows.Count > 0)
                    {
                        foreach (DataRow drr in dtimg.Rows)
                        {
                            sqlupdateZan += string.Format(@" update [UserInformations] set int1=(
  select sum(ReviewVolume) zan   from [PictureInformation] where  PictureID in(
 select id from [PictureMainInformation] where UserID='{0}')
 )
 where id='{0}';", drr["id"]);

                            //我的粉丝  别人关注了我,就是我的粉丝  也就是说picid=我的用户id
                            sqlupdateMess += string.Format(@" 
  update [UserInformations] set int2=(
   select count(picid) from OptionInfo 
 where picid='{0}'  and types=3 
 )
 where id='{0}';", drr["id"]);
                            //关注,我关注了那些图片   也就说userid=我的用户id
                            sqlupdateRenqi += string.Format(@" 
  update [UserInformations] set int3=(
   select count(userid) from OptionInfo 
 where userid='{0}'  and types=3 
 )
 where id='{0}';", drr["id"]);
                        }

                        if (isLog == "true")
                        {
                            NetLog.WriteTextLog("sqlupdateZan:", sqlupdateZan, DateTime.Now);
                            NetLog.WriteTextLog("sqlupdateMess:", sqlupdateMess, DateTime.Now);
                            NetLog.WriteTextLog("sqlupdateRenqi:", sqlupdateRenqi, DateTime.Now);
                        }
                        try
                        {
                            DbHelperSQL.ExecuteNonQuery(CommandType.Text, sqlupdateZan);
                            DbHelperSQL.ExecuteNonQuery(CommandType.Text, sqlupdateMess);
                            DbHelperSQL.ExecuteNonQuery(CommandType.Text, sqlupdateRenqi);
                        }
                        catch (Exception ex)
                        {
                            NetLog.WriteTextLog("ACount-log:", ex.ToString(), DateTime.Now);
                        }
                    }
                }



                DS = DbHelperSQL.ExecuteDataset(CommandType.Text, "SELECT id FROM PictureMainInformation   ");

                sqlupdateZan   = "";
                sqlupdateMess  = "";
                sqlupdateRenqi = "";
                if (DS.Tables.Count > 0)
                {
                    DataTable dtimg = DS.Tables[0];
                    if (dtimg.Rows.Count > 0)
                    {
                        foreach (DataRow drr in dtimg.Rows)
                        {
                            sqlupdateZan += string.Format(@" update [PictureMainInformation] set int1=(
   select sum(ReviewVolume)  from [dbo].[PictureInformation]  where PictureID='{0}'
 )
 where id='{0}';", drr["id"]);


                            sqlupdateMess += string.Format(@" 
  update [PictureMainInformation] set int2=(
  select sum(ReviewInforNumber) from [dbo].[PictureInformation]  where PictureID='{0}'
 )
 where id='{0}';", drr["id"]);
                        }

                        if (isLog == "true")
                        {
                            NetLog.WriteTextLog("单组sqlupdateMess:", sqlupdateMess, DateTime.Now);
                            NetLog.WriteTextLog("单组sqlupdateZan:", sqlupdateZan, DateTime.Now);
                        }
                        try
                        {
                            DbHelperSQL.ExecuteNonQuery(CommandType.Text, sqlupdateZan);
                            DbHelperSQL.ExecuteNonQuery(CommandType.Text, sqlupdateMess);
                        }
                        catch (Exception ex)
                        {
                            NetLog.WriteTextLog("ACount单组-log:", ex.ToString(), DateTime.Now);
                        }
                    }
                }
            }
        }
Exemple #10
0
        private void A()
        {
            string paths = ConfigurationManager.AppSettings["imgpath"].ToString();  //ConfigurationManager.ConnectionStrings["blue"].ConnectionString;
            string isLog = ConfigurationManager.AppSettings["IsLog"].ToString();

            while (isRun)
            {
                Thread.Sleep(100);
                DataSet DS        = DbHelperSQL.ExecuteDataset(CommandType.Text, "SELECT * FROM [PictureMainInformation] WHERE BlueValue=0 ");
                string  sqlupdate = "";
                if (DS.Tables.Count > 0)
                {
                    DataTable dtimg = DS.Tables[0];
                    if (dtimg.Rows.Count > 0)
                    {
                        foreach (DataRow drr in dtimg.Rows)
                        {
                            List <Statistics.MajorColor> MCc;
                            int PixelAmount = 0;
                            try
                            {
                                #region
                                MCc = Statistics.PrincipalColorAnalysis((Bitmap)Bitmap.FromFile(paths + drr["str2"]), 20, 24);
                                if (MCc != null)
                                {
                                    dt = new DataTable();
                                    DataColumn dc = new DataColumn("a");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("颜色");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("百分比");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("数量");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("RGB");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("RGB灰度值");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("R减G");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("R减B");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("G减B");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("饱和度");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("明度");
                                    dt.Columns.Add(dc);
                                    dc = new DataColumn("色相");
                                    dt.Columns.Add(dc);
                                    for (int i = 0; i < MCc.Count; i++)
                                    {
                                        DataRow dr = dt.NewRow();
                                        dr["a"]   = i;
                                        dr["颜色"]  = IntToColor(MCc[i].Color);
                                        dr["百分比"] = (double)MCc[i].Amount / PixelAmount;
                                        dr["数量"]  = MCc[i].Amount;
                                        dr["RGB"] = IntToColorValue(MCc[i].Color);
                                        string[] DD = IntToColorValueCCC(MCc[i].Color).Split(',');
                                        dr["RGB灰度值"] = DD[0];
                                        dr["R减G"]    = DD[1];
                                        dr["R减B"]    = DD[2];
                                        dr["G减B"]    = DD[3];
                                        dr["饱和度"]    = DD[4];
                                        dr["明度"]     = DD[5];
                                        dr["色相"]     = DD[6];
                                        if (Convert.ToInt32(DD[1]) < 0 && Convert.ToInt32(DD[2]) < 0 && Convert.ToInt32(DD[3]) < 0)
                                        {
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    dt.DefaultView.Sort = "色相 desc";
                                    dt = dt.DefaultView.ToTable();

                                    if (dt.Rows.Count > 0)
                                    {
                                        int bluevalue = BlueScore(dt);
                                        if (bluevalue == 0)
                                        {
                                            bluevalue = 1;
                                        }
                                        sqlupdate += "update PictureMainInformation set BlueValue=" + bluevalue + " where ID='" + drr["ID"] + "'; ";
                                    }
                                    else
                                    {
                                        sqlupdate += "update PictureMainInformation set BlueValue=1    where ID='" + drr["ID"] + "'; ";
                                    }
                                    //if (dt.Rows.Count > 0)
                                    //{
                                    //    int ss = Convert.ToInt32(dt.Rows[0]["色相"]);
                                    //    int bluevalue = 1;
                                    //    if (ss >= 220)
                                    //    {
                                    //        bluevalue = 100;
                                    //    }
                                    //    else if (ss < 220&&ss>=210)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(95, 99);
                                    //    }
                                    //    else if (ss < 210 && ss >= 200)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(90, 94);
                                    //    }
                                    //    else if (ss < 200 && ss >= 190)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(85, 89);
                                    //    }
                                    //    else if (ss < 190 && ss >= 180)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(80, 84);
                                    //    }
                                    //    else if (ss < 180 && ss >= 170)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(75, 79);
                                    //    }
                                    //    else if (ss < 170 && ss >= 160)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(70, 74);
                                    //    }
                                    //    else if (ss < 160 && ss >= 150)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(65, 59);
                                    //    }
                                    //    else if (ss < 150 && ss >= 140)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(60, 64);
                                    //    }
                                    //    else if (ss < 140 && ss >= 130)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(55, 59);
                                    //    }
                                    //    else if (ss < 130 && ss >= 120)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(50, 54);
                                    //    }
                                    //    else if (ss < 120 && ss >= 110)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(45, 49);
                                    //    }
                                    //    else if (ss < 110 && ss >= 100)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(40, 44);
                                    //    }
                                    //    else if (ss < 100 && ss >= 90)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(35, 39);
                                    //    }
                                    //    else if (ss < 90 && ss >= 80)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(30, 34);
                                    //    }
                                    //    else if (ss < 80 && ss >= 70)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(25, 29);
                                    //    }
                                    //    else if (ss < 70 && ss >= 60)
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(20, 24);
                                    //    }
                                    //    else
                                    //    {
                                    //        Random rd = new Random();

                                    //        bluevalue = rd.Next(1, 19);

                                    //    }

                                    //    sqlupdate += "update PictureMainInformation set BlueValue=" + bluevalue + " where ID='" + drr["ID"] + "'; ";


                                    //}
                                    //else
                                    //{
                                    //    Random rd = new Random();


                                    //    sqlupdate += "update PictureMainInformation set BlueValue=" + rd.Next(1, 19) + " where ID='" + drr["ID"] + "'; ";
                                    //}


                                    //dataGridView1.Sort(dataGridView1.Columns["色相"], ListSortDirection.Descending);
                                }
                                #endregion
                            }
                            catch (Exception ex)
                            {
                                NetLog.WriteTextLog("log:", ex.ToString(), DateTime.Now);
                            }
                        }
                        if (isLog == "true")
                        {
                            NetLog.WriteTextLog("log:", sqlupdate, DateTime.Now);
                        }
                        DbHelperSQL.ExecuteNonQuery(CommandType.Text, sqlupdate);
                    }
                }
            }
        }
        public HttpResponseMessage Post()
        {
            var requestQueryPairs = Request.GetQueryNameValuePairs().ToDictionary(k => k.Key, v => v.Value);

            if (requestQueryPairs.Count == 0 ||
                !requestQueryPairs.ContainsKey("timestamp") ||
                !requestQueryPairs.ContainsKey("signature") ||
                !requestQueryPairs.ContainsKey("nonce") ||
                !CheckSignature.Check(requestQueryPairs["signature"], requestQueryPairs["timestamp"],
                                      requestQueryPairs["nonce"], Token))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "未授权请求"));
            }
            PostModel postModel = new PostModel
            {
                Signature = requestQueryPairs["signature"],
                Timestamp = requestQueryPairs["timestamp"],
                Nonce     = requestQueryPairs["nonce"]
            };

            postModel.Token          = Token;
            postModel.EncodingAESKey = EncodingAESKey; //根据自己后台的设置保持一致
            postModel.AppId          = AppId;          //根据自己后台的设置保持一致

            //v4.2.2之后的版本,可以设置每个人上下文消息储存的最大数量,防止内存占用过多,如果该参数小于等于0,则不限制
            var maxRecordCount = 10;

            //自定义MessageHandler,对微信请求的详细判断操作都在这里面。
            var messageHandler = new CustomMessageHandler(Request.Content.ReadAsStreamAsync().Result, postModel);


            try
            {
                #if DEBUG
                NetLog.WriteTextLog(messageHandler.RequestDocument.ToString());
                if (messageHandler.UsingEcryptMessage)
                {
                    NetLog.WriteTextLog(messageHandler.EcryptRequestDocument.ToString());
                }
                #endif

                /* 如果需要添加消息去重功能,只需打开OmitRepeatedMessage功能,SDK会自动处理。
                 * 收到重复消息通常是因为微信服务器没有及时收到响应,会持续发送2-5条不等的相同内容的RequestMessage*/
                messageHandler.OmitRepeatedMessage = true;

                //执行微信处理过程
                messageHandler.Execute();

        #if DEBUG
                if (messageHandler.ResponseDocument != null)
                {
                    NetLog.WriteTextLog(messageHandler.ResponseDocument.ToString());
                }

                if (messageHandler.UsingEcryptMessage)
                {
                    //记录加密后的响应信息
                    NetLog.WriteTextLog(messageHandler.FinalResponseDocument.ToString());
                }
#endif

                var resMessage = Request.CreateResponse(HttpStatusCode.OK);
                resMessage.Content = new StringContent(messageHandler.ResponseDocument.ToString());
                resMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xml");

                return(resMessage);
            }
            catch (Exception ex)
            {
                NetLog.WriteTextLog("处理微信请求出错:" + ex.Message);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "处理微信请求出错"));
            }
        }