コード例 #1
0
 public static string System(string ConfigName)
 {
     if (Caches.GetCache("system_" + ConfigName) == null)
     {
         XmlDoc xml = new XmlDoc();
         xml.xmlfilePath = "~/Config/SystemConfig.config";
         DataSet ds = xml.GetDataSet();
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             Caches.SetCache("system_" + ConfigName, ds.Tables[0].Rows[0][ConfigName].ToString());
         }
     }
     return(Caches.GetCache("system_" + ConfigName).ToString());
 }
コード例 #2
0
ファイル: Mail.cs プロジェクト: soldiers1989/1.Website
        public bool sendMail(string From, string TO, string Subject, string Body)
        {
            //try
            //{
            XmlDoc  xml = new XmlDoc();
            DataSet ds;

            xml.xmlfilePath = "~/Config/MailConfig.config";
            ds = xml.GetDataSet();
            string server    = Server.ToString() != "" ? Server : ds.Tables[0].Rows[0]["SendMailServer"].ToString();
            string loginUser = LoginUser.ToString() != "" ? LoginUser : ds.Tables[0].Rows[0]["SendMailUserName"].ToString();
            string loginPass = LoginPass.ToString() != "" ? LoginUser : ds.Tables[0].Rows[0]["SendMailUserPwd"].ToString();

            From = LoginUser.ToString() != "" ? LoginUser : ds.Tables[0].Rows[0]["SendMailUserName"].ToString();

            System.Net.Mail.SmtpClient client = new SmtpClient(server);
            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential(loginUser, loginPass);
            client.DeliveryMethod        = SmtpDeliveryMethod.Network;

            System.Net.Mail.MailMessage message = new MailMessage();
            message.From    = new System.Net.Mail.MailAddress(From);
            message.Subject = Subject;
            message.Body    = Body;

            string[] temp = TO.Split(',');
            int      i;

            for (i = 0; i < temp.Length; i++)
            {
                if (temp[i].Trim() != "")
                {
                    message.To.Add(temp[i].Trim());
                }
            }
            message.BodyEncoding = System.Text.Encoding.UTF8;
            message.IsBodyHtml   = true;

            client.Send(message);
            return(true);
            //}
            //catch
            //{
            //    return false;
            //}
        }
コード例 #3
0
ファイル: weixin.cs プロジェクト: soldiers1989/1.Website
        /// <summary>
        /// 消息回复(微信信息返回)
        /// </summary>
        /// <param name="requestXML">The request XML.</param>
        private void ResponseMsg(RequestXML requestXML)
        {
            try
            {
                XmlDoc xml = new XmlDoc();
                xml.xmlfilePath = "~/Config/SystemConfig.config";
                DataSet dsc;
                dsc = xml.GetDataSet();
                string contct = dsc.Tables[0].Rows[0]["HomeDescription"].ToString();
                string resxml = "";
                //主要是调用数据库进行关键词匹配自动回复内容,可以根据自己的业务情况编写。
                //1.通常有,没有匹配任何指令时,返回帮助信息
                Requesttxt mi      = new Requesttxt();
                string     contetn = requestXML.Content;
                string     name    = requestXML.FromUserName;



                switch (requestXML.MsgType)
                {
                case "text":
                    //在这里执行一系列操作,从而实现自动回复内容.
                    ;
                    resxml += "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName>";
                    resxml += "<FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName>";
                    resxml += "<CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime>";
                    resxml += mi.gettxt3(requestXML.Content);
                    resxml += "</xml>";

                    break;

                case "location":
                    string city = GetMapInfo(requestXML.Location_X, requestXML.Location_Y);
                    if (city == "0")
                    {
                        resxml = "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName><FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName><CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[好啦,我们知道您的位置啦。您可以:222222222222222]]></Content><FuncFlag>1</FuncFlag></xml>";
                    }
                    else
                    {
                        resxml = "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName><FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName><CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[好啦,我们知道您的位置啦。您可以:3333333333333333]]></Content><FuncFlag>1</FuncFlag></xml>";
                    }
                    break;

                case "image":
                    //图文混合的消息 具体格式请见官方API“回复图文消息”
                    break;

                case "event":
                    switch (requestXML.Event)
                    {
                    case "subscribe":

                        resxml += "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName>";
                        resxml += "<FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName>";
                        resxml += "<CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime>";
                        resxml += "<MsgType><![CDATA[text]]></MsgType>";
                        resxml += "<Content><![CDATA[" + contct + "]]></Content>";
                        resxml += "</xml>";
                        break;

                    case "CLICK":
                        switch (requestXML.EventKey)
                        {
                        case "mp3":
                            resxml += "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName>";
                            resxml += "<FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName>";
                            resxml += "<CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime>";
                            resxml += "<MsgType><![CDATA[news]]></MsgType>";
                            resxml += "<ArticleCount>1</ArticleCount>";
                            resxml += "<Articles>";
                            resxml += "<item>";
                            resxml += "<Title><![CDATA[纪念杰克逊诞辰,致敬经典《Beat It》-格列佛出品]]></Title> ";
                            resxml += "<Description><![CDATA[8月29日是已故天王——迈克尔.杰克逊诞辰之日,8月29日格列佛——听的旅行攻略上线。格君将天王神曲《Beat It》改编为旅行版《Beat It》为此次上线助力。]]></Description>";
                            resxml += "<PicUrl><![CDATA[http://geliefofm.com/images/wx_jkx.jpg]]></PicUrl>";
                            resxml += "<Url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzAxMDU0MDM3NQ==&mid=207066391&idx=1&sn=210e7e1ec467ba6f7d2aae2414533fba#rd]]></Url>";
                            resxml += "</item>";
                            resxml += "</Articles>";
                            resxml += "</xml>";
                            break;

                        case "lianxiwomen":
                            resxml += "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName>";
                            resxml += "<FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName>";
                            resxml += "<CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime>";
                            resxml += "<MsgType><![CDATA[text]]></MsgType>";
                            resxml += "<Content><![CDATA[亲爱的格友,想联系,可在微信中留言。比较着急呢! ......,还可以通过以下方式。\n\n电话:13910012101\n\nQQ:1927829510]]></Content>";
                            resxml += "</xml>";
                            break;
                        }
                        break;
                    }
                    break;

                case "voice":
                    resxml += "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName>";
                    resxml += "<FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName>";
                    resxml += "<CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime>";
                    resxml += mi.gettxt3(requestXML.Recognition);
                    resxml += "</xml>";

                    break;
                }

                System.Web.HttpContext.Current.Response.Write(resxml);
                WriteToDB(requestXML);
            }
            catch
            {
                //WriteTxt("异常:" + ex.Message + "Struck:" + ex.StackTrace.ToString());
                //wx_logs.MyInsert("异常:" + ex.Message + "Struck:" + ex.StackTrace.ToString());
            }
        }