Esempio n. 1
0
        /// <summary>
        /// 根据字段的XML获取不同类型字段显示到页面
        /// </summary>
        /// <param name="Val">此字段的值</param>
        /// <param name="Xml">xml文档信息</param>
        /// <returns></returns>
        public static string GetType(object Val, object Xml)
        {
            string Results = "";
            XmlDoc xml     = new XmlDoc();

            xml.xmlfileInfo = Xml.ToString();
            int    Type      = StringDeal.ToInt(xml.GetValue("/FieldInfo/FieldType"));
            string Field     = xml.GetValue("/FieldInfo/FieldName");
            string CssClass  = xml.GetValue("/FieldInfo/Validator");
            string useTitles = xml.GetValue("/FieldInfo/useTitles");

            if (String.IsNullOrEmpty(Val.ToString()))
            {
                Val = xml.GetValue("/FieldInfo/Default");
            }
            switch (Type)
            {
            case 1:
                #region 单行文本
                Results = "<input id='" + Field + "' name='" + Field + "' class='input " + CssClass + "' title='" + useTitles + "' value=\"" + StringDeal.StrFormat(Val) + "\" maxlength='" + xml.GetValue("/FieldInfo/MaxLength") + "' size='" + xml.GetValue("/FieldInfo/Size") + "' />";
                break;

                #endregion
            case 2:
                #region 多行文本
                Results = "<textarea name='" + Field + "' id='" + Field + "' style='width:" + xml.GetValue("/FieldInfo/Width") + "px; height:" + xml.GetValue("/FieldInfo/Height") + "px;' class='" + CssClass + "' title='" + useTitles + "'>" + Val + "</textarea>";
                break;

                #endregion
            case 3:
                #region 编辑器
                string Editor = "";
                if (xml.GetValue("/FieldInfo/Editor") == "1")
                {
                    Editor = "Mini";
                }
                else if (xml.GetValue("/FieldInfo/Editor") == "2")
                {
                    Editor = "Simple";
                }
                else
                {
                    Editor = "Default";
                }

                Results  = "<script type='text/javascript'>\n";
                Results += "window.onload = function()\n";
                Results += "{";
                Results += "    var sBasePath = '/WebEditor/';\n";
                Results += "    var oFCKeditor = new FCKeditor( '" + Field + "' );\n";
                Results += "    oFCKeditor.BasePath	= sBasePath ;\n";
                Results += "    oFCKeditor.ToolbarSet = '" + Editor + "';\n";
                Results += "    oFCKeditor.Config['SkinPath'] = sBasePath+'editor/skins/silver/';\n";
                Results += "    oFCKeditor.Width = '" + xml.GetValue("/FieldInfo/Width") + "';\n";
                Results += "    oFCKeditor.Height = '" + xml.GetValue("/FieldInfo/Height") + "';\n";
                Results += "    oFCKeditor.ReplaceTextarea();\n";
                Results += "}\n";
                Results += "    </script>\n";
                Results += "<textarea name='" + Field + "' id='" + Field + "' class='" + CssClass + "' title='" + useTitles + "'>" + Val + "</textarea>";
                break;

                #endregion
            case 4:
                #region  拉菜单,多选,单选
                string[] Arry        = xml.GetValue("/FieldInfo/Options").Split('|');
                string   OptionsType = xml.GetValue("/FieldInfo/OptionsType");
                if (Arry.Length > 0 && !String.IsNullOrEmpty(OptionsType))
                {
                    if (OptionsType == "select")
                    {
                        Results += "<select name='" + Field + "' id='" + Field + "' class='" + CssClass + "' title='" + useTitles + "'>";
                        Results += "<option value=''>请选择</option>";
                        foreach (string I in Arry)
                        {
                            Results += "<option value=\"" + I + "\"" + StringDeal.GetSelected(Val, I);
                            Results += ">" + I + "</option>/n";
                        }
                        Results += "</select>";
                    }
                    else
                    {
                        for (int I = 0; I < Arry.Length; I++)
                        {
                            Results += "<input type='" + OptionsType + "' id='" + Field + I + "' name='" + Field + "' value=\"" + Arry[I] + "\"" + StringDeal.GetChecked(Val, Arry[I]) + ">" + Arry[I];
                        }
                    }
                }
                break;

                #endregion
            case 5:
                #region 数字
                Results += "<input type='text' class='input " + CssClass + "' title='" + useTitles + "' maxlength='16' size='5' name='" + Field + "' id='" + Field + "' value=\"" + Val + "\" />";
                break;

                #endregion
            case 6:
                #region 日期/时间日期
                string onFocus = "";
                if (xml.GetValue("/FieldInfo/DateTime") == "yyyy-mm-dd")
                {
                    onFocus = "setDay(this);";
                    if (Val.ToString() == "getdate()")
                    {
                        Val = DateTime.Today.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        Val = StringDeal.GetDateTime(Val, "yyyy-MM-dd");
                    }
                }
                else
                {
                    onFocus = "setDayHM(this);";
                    if (Val.ToString() == "getdate()")
                    {
                        Val = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    }
                    else
                    {
                        Val = StringDeal.GetDateTime(Val, "yyyy-MM-dd HH:mm");
                    }
                }
                Results += "<input readonly='readonly' type='text' onclick=\"" + onFocus + "\" class='input " + CssClass + "' title='" + useTitles + "' maxlength='25' size='25' name='" + Field + "' id='" + Field + "' value=\"" + Val + "\" />";
                Results += "<script language=\"javascript\" type=\"text/javascript\" src='../js/calendar.js'></script>";
                break;

                #endregion
            case 7:
                #region 图片上传
                //string UploadPhotoPath = xml.GetValue("/FieldInfo/UploadPhotoPath");
                //string UploadPhotoSize = xml.GetValue("/FieldInfo/UploadPhotoSize");
                //string UploadPhotoType = xml.GetValue("/FieldInfo/UploadPhotoType");
                //string Mark = xml.GetValue("/FieldInfo/Mark");
                //string Thumb = xml.GetValue("/FieldInfo/Thumb");
                Results += "<input type='text' id='" + Field + "' readonly='readonly' class='input2 " + CssClass + "' name='" + Field + "' value=\"" + StringDeal.StrFormat(Val) + "\" /> <input type=\"button\" class=\"divbutton\" value=\"图片上传\" onclick=\"UploadImage('" + Field + "','" + GetConfig.System("ManagePath") + "');\" />";
                break;

                #endregion
            case 8:
                #region 文件上传
                //string UploadFilePath = xml.GetValue("/FieldInfo/UploadPhotoPath");
                //string UploadFileSize = xml.GetValue("/FieldInfo/UploadPhotoSize");
                string UploadFileType = xml.GetValue("/FieldInfo/UploadImageType");
                Results += "<input type=\"text\" id=\"" + Field + "\" readonly=\"readonly\" class=\"input2 " + CssClass + "\" name=\"" + Field + "\" value=\"" + StringDeal.StrFormat(Val) + "\" /> <input type=\"button\" class=\"divbutton\" value=\"文件上传\" onclick=\"UploadFile('" + Field + "','" + GetConfig.System("ManagePath") + "','" + UploadFileType + "');\" />";
                break;
                #endregion
            }
            return(Results);
        }
Esempio n. 2
0
        /// <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());
            }
        }