Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                switch (helper.GetParam("action").ToLower())
                {
                case "del":
                    try
                    {
                        helper.Result = Wlniao.WeChat.BLL.Rules.DelRules(helper.GetParam("Guid"));
                    }
                    catch (Exception ex)
                    {
                        helper.Result.Add("错误:" + ex.Message);
                    }
                    helper.ResponseResult();
                    break;

                case "getlist":
                    int pageIndex = 0;
                    int pageSize  = int.MaxValue;
                    try
                    {
                        pageIndex = int.Parse(helper.GetParam("pageIndex"));
                        pageSize  = int.Parse(helper.GetParam("pageSize"));
                    }
                    catch { }

                    System.DataPage <Wlniao.WeChat.Model.Rules> items = db.findPage <Wlniao.WeChat.Model.Rules>("DoMethod<>''", pageIndex, pageSize);

                    try
                    {
                        foreach (Wlniao.WeChat.Model.Rules rule in items.Results)
                        {
                            try
                            {
                            }
                            catch { }
                        }
                    }
                    catch { }
                    List <Wlniao.WeChat.Model.Rules> list = null;
                    list = items.Results;
                    if (list == null)
                    {
                        list = new List <Wlniao.WeChat.Model.Rules>();
                    }
                    helper.Response("{total:" + items.RecordCount + ",data:" + Json.ToStringList(items.Results) + "}");
                    break;
                }
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                switch (helper.GetParam("action").ToLower())
                {
                case "getnewcount":
                    int count = db.count <Wlniao.WeChat.Model.Fans>("Subscribe=1 and IsNewFans=1");
                    if (count > 0)
                    {
                        helper.Response(string.Format("document.write('<span class=\"label label-important tip-bottom\" title=\"{0} 位新增订阅者\">{0}</span>');", count));
                    }
                    else
                    {
                        this.Response.ContentType = "application/x-javascript";
                        this.Response.Write("document.write('');");
                        this.Response.End();
                    }
                    break;

                case "setnickname":
                    Wlniao.WeChat.Model.Fans fansNickName = Wlniao.WeChat.Model.Fans.findByField("StrGuid", helper.GetParam("Guid"));
                    if (fansNickName == null)
                    {
                        helper.Result.Add("Sorry,要更新的订阅者不存在或已删除!");
                    }
                    else
                    {
                        fansNickName.NickName = helper.GetParam("NickName");
                    }
                    if (fansNickName != null && fansNickName.Id > 0)
                    {
                        try
                        {
                            fansNickName.update("NickName");
                        }
                        catch
                        {
                            helper.Result.Add("Sorry,更新订阅者信息失败!");
                        }
                    }
                    helper.ResponseResult();
                    break;

                case "setallowtest":
                    Wlniao.WeChat.Model.Fans fansAllowtest = Wlniao.WeChat.Model.Fans.findByField("StrGuid", helper.GetParam("Guid"));
                    if (fansAllowtest == null)
                    {
                        helper.Result.Add("Sorry,要更新的订阅者不存在或已删除!");
                    }
                    else
                    {
                        try
                        {
                            fansAllowtest.AllowTest = Convert.ToInt32(helper.GetParam("AllowTest"));
                        }
                        catch { }
                    }
                    if (fansAllowtest != null && fansAllowtest.Id > 0)
                    {
                        try
                        {
                            fansAllowtest.update("AllowTest");
                        }
                        catch
                        {
                            helper.Result.Add("Sorry,更新订阅者信息失败!");
                        }
                    }
                    helper.ResponseResult();
                    break;

                case "getlist":
                    int pageIndex = 0;
                    int pageSize  = int.MaxValue;
                    try
                    {
                        pageIndex = int.Parse(helper.GetParam("pageIndex"));
                        pageSize  = int.Parse(helper.GetParam("pageSize"));
                    }
                    catch { }
                    string where = "Subscribe=1";
                    if (!string.IsNullOrEmpty(helper.GetParam("key")))
                    {
                        where += " and NickName like'%" + helper.GetParam("key") + "%'";
                    }
                    System.DataPage <Wlniao.WeChat.Model.Fans> items = db.findPage <Wlniao.WeChat.Model.Fans>(where, pageIndex, pageSize);

                    try
                    {
                        foreach (Wlniao.WeChat.Model.Fans fans in items.Results)
                        {
                            try
                            {
                                fans.Sid = string.IsNullOrEmpty(fans.Sid) ? "" : "已绑定";
                            }
                            catch { }
                        }
                    }
                    catch { }
                    List <Wlniao.WeChat.Model.Fans> list = null;
                    try
                    {
                        //删除新订阅标记
                        list = db.findPage <Wlniao.WeChat.Model.Fans>("IsNewFans=1", 0, int.MaxValue).Results;
                        foreach (Wlniao.WeChat.Model.Fans fans in list)
                        {
                            fans.IsNewFans = 0;
                            fans.update("IsNewFans");
                        }
                    }
                    catch { };
                    list = items.Results;
                    if (list == null)
                    {
                        list = new List <Wlniao.WeChat.Model.Fans>();
                    }
                    helper.Response("{total:" + items.RecordCount + ",data:" + Json.ToStringList(items.Results) + "}");
                    break;
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _Guid = Request["guid"];
                if (string.IsNullOrEmpty(_Guid))
                {
                    _Display = "display:none;";
                }
                else
                {
                    _DisplayNew = "display:none;";
                }
                if (helper.GetParam("type") == "auto")
                {
                    _GobackUrl       = "rulesauto.aspx";
                    _DoMethodDisplay = "display:none;";
                }
                else
                {
                    _ReContentDisplay = "display:none;";
                    _GobackUrl        = "rulesmethod.aspx";
                }
                switch (helper.GetParam("action").ToLower())
                {
                case "get":
                    Wlniao.WeChat.Model.Rules rulesGet = Wlniao.WeChat.BLL.Rules.Get(_Guid);
                    if (rulesGet == null)
                    {
                        rulesGet = new Wlniao.WeChat.Model.Rules();
                    }
                    try
                    {
                        rulesGet.ReContent = rulesGet.ReContent.Replace("\n", "<br/>");
                    }
                    catch { }
                    try
                    {
                        rulesGet.RuleHelp = rulesGet.RuleHelp.Replace("\n", "<br/>");
                    }
                    catch { }
                    helper.Response(rulesGet);
                    break;

                case "set":
                    Wlniao.WeChat.Model.Rules rulesSet = Wlniao.WeChat.BLL.Rules.Get(_Guid);
                    if (rulesSet == null)
                    {
                        rulesSet      = new Wlniao.WeChat.Model.Rules();
                        rulesSet.Guid = Guid.NewGuid().ToString();
                    }
                    rulesSet.RuleName     = helper.GetParam("RuleName");
                    rulesSet.DoMethod     = helper.GetParam("DoMethod");
                    rulesSet.ReContent    = helper.GetParam("ReContent").Replace("<br/>", "\n");
                    rulesSet.RuleHelp     = helper.GetParam("RuleHelp").Replace("<br/>", "\n");
                    rulesSet.CallBackText = helper.GetParam("CallBackText");
                    rulesSet.SendMode     = helper.GetParam("SendMode");
                    if (rulesSet.Id > 0)
                    {
                        if (Tool.GetConfiger("UseXml") == "true")
                        {
                            try
                            {
                                helper.Result.Join(System.IO.XMLHelper.UpdateData(PathHelper.Map("~/xcenter/data/wechat/rules.xml"), "Rules", System.IO.XMLHelper.CreateEqualParameter("Guid", rulesSet.Guid), System.IO.XMLHelper.CreateUpdateParameter("RuleName", rulesSet.RuleName), System.IO.XMLHelper.CreateUpdateParameter("DoMethod", rulesSet.DoMethod), System.IO.XMLHelper.CreateUpdateParameter("ReContent", rulesSet.ReContent), System.IO.XMLHelper.CreateUpdateParameter("RuleHelp", rulesSet.RuleHelp), System.IO.XMLHelper.CreateUpdateParameter("RuleHelp", rulesSet.CallBackText)));
                            }
                            catch (Exception ex)
                            {
                                helper.Result.Add("错误:" + ex.Message);
                            }
                        }
                        else
                        {
                            helper.Result = rulesSet.update();
                        }
                    }
                    else
                    {
                        if (Tool.GetConfiger("UseXml") == "true")
                        {
                            helper.Result.Join(System.IO.XMLHelper.AddData(PathHelper.Map("~/xcenter/data/wechat/rules.xml"), "Rules", System.IO.XMLHelper.CreateInsertParameter("Guid", rulesSet.Guid), System.IO.XMLHelper.CreateInsertParameter("RuleName", rulesSet.RuleName), System.IO.XMLHelper.CreateInsertParameter("DoMethod", rulesSet.DoMethod), System.IO.XMLHelper.CreateInsertParameter("ReContent", rulesSet.ReContent), System.IO.XMLHelper.CreateInsertParameter("RuleHelp", rulesSet.RuleHelp), System.IO.XMLHelper.CreateInsertParameter("CallBackText", rulesSet.CallBackText)));
                        }
                        else
                        {
                            helper.Result = rulesSet.insert();
                        }
                    }
                    helper.ResponseResult();
                    break;

                case "setcode":
                    Wlniao.WeChat.Model.RuleCode codeSet = Wlniao.WeChat.Model.RuleCode.findByField("StrGuid", _Guid);
                    if (codeSet == null)
                    {
                        helper.Result = Wlniao.WeChat.BLL.Rules.AddRuleCode(helper.GetParam("Code"), helper.GetParam("RuleGuid"), helper.GetParam("SepType"));
                    }
                    else
                    {
                        helper.Result = Wlniao.WeChat.BLL.Rules.EditRuleCode(_Guid, helper.GetParam("Code"), helper.GetParam("RuleGuid"), helper.GetParam("SepType"), helper.GetParam("Status"));
                    }
                    helper.ResponseResult();
                    break;

                case "delcode":
                    try
                    {
                        if (Wlniao.WeChat.Model.RuleCode.findByField("StrGuid", helper.GetParam("Guid")).delete() <= 0)
                        {
                            helper.Result.Add("Sorry,删除匹配项失败!");
                        }
                    }
                    catch (Exception ex)
                    {
                        helper.Result.Add("错误:" + ex.Message);
                    }
                    helper.ResponseResult();
                    break;

                case "getlist":
                    int pageIndex = 0;
                    int pageSize  = int.MaxValue;
                    try
                    {
                        pageIndex = int.Parse(helper.GetParam("pageIndex"));
                        pageSize  = int.Parse(helper.GetParam("pageSize"));
                    }
                    catch { }

                    System.DataPage <Wlniao.WeChat.Model.RuleCode> items = db.findPage <Wlniao.WeChat.Model.RuleCode>("RuleGuid='" + helper.GetParam("RuleGuid") + "'", pageIndex, pageSize);
                    List <Wlniao.WeChat.Model.RuleCode>            list  = items.Results;
                    if (list == null)
                    {
                        list = new List <Wlniao.WeChat.Model.RuleCode>();
                    }
                    foreach (Wlniao.WeChat.Model.RuleCode rulecode in list)
                    {
                        rulecode.Code = rulecode.Code.Replace("#", " ").Replace("$", " ").TrimStart().TrimEnd().Replace(" ", ",");
                    }
                    helper.Response("{total:" + items.RecordCount + ",data:" + Json.ToStringList(list) + "}");
                    break;

                case "setcontent":
                    Wlniao.WeChat.Model.RuleContent codeContent = Wlniao.WeChat.Model.RuleContent.findByField("StrGuid", _Guid);
                    if (codeContent == null)
                    {
                        helper.Result = Wlniao.WeChat.BLL.Rules.AddRuleContent(helper.GetParam("RuleGuid"), helper.GetParam("ContentType"), helper.GetParam("Title"), helper.GetParam("TextContent").Replace("<br/>", "\n"), helper.GetParam("PicUrl"), helper.GetParam("ThumbPicUrl"), helper.GetParam("MusicUrl"), helper.GetParam("LinkUrl"), helper.GetParam("ContentStatus"));
                    }
                    else
                    {
                        helper.Result = Wlniao.WeChat.BLL.Rules.EditRuleContent(_Guid, helper.GetParam("ContentType"), helper.GetParam("Title"), helper.GetParam("TextContent").Replace("<br/>", "\n"), helper.GetParam("PicUrl"), helper.GetParam("ThumbPicUrl"), helper.GetParam("MusicUrl"), helper.GetParam("LinkUrl"), helper.GetParam("ContentStatus"));
                    }
                    helper.ResponseResult();
                    break;

                case "delcontent":
                    try
                    {
                        if (Wlniao.WeChat.Model.RuleContent.findByField("StrGuid", helper.GetParam("Guid")).delete() <= 0)
                        {
                            helper.Result.Add("Sorry,删除内容失败!");
                        }
                    }
                    catch (Exception ex)
                    {
                        helper.Result.Add("错误:" + ex.Message);
                    }
                    helper.ResponseResult();
                    break;

                case "stickcontent":
                    try
                    {
                        Wlniao.WeChat.Model.RuleContent stick = Wlniao.WeChat.Model.RuleContent.findByField("StrGuid", helper.GetParam("Guid"));
                        stick.LastStick = DateTools.GetNow();
                        stick.update("LastStick");
                    }
                    catch (Exception ex)
                    {
                        helper.Result.Add("错误:" + ex.Message);
                    }
                    helper.ResponseResult();
                    break;

                case "getcontentlist":
                    pageIndex = 0;
                    pageSize  = int.MaxValue;
                    try
                    {
                        pageIndex = int.Parse(helper.GetParam("pageIndex"));
                        pageSize  = int.Parse(helper.GetParam("pageSize"));
                    }
                    catch { }

                    System.DataPage <Wlniao.WeChat.Model.RuleContent> itemsContent = db.findPage <Wlniao.WeChat.Model.RuleContent>("RuleGuid='" + helper.GetParam("RuleGuid") + "' order by LastStick desc", pageIndex, pageSize);
                    List <Wlniao.WeChat.Model.RuleContent>            listContent  = itemsContent.Results;
                    if (listContent == null)
                    {
                        listContent = new List <Wlniao.WeChat.Model.RuleContent>();
                    }
                    foreach (Wlniao.WeChat.Model.RuleContent rulecontent in listContent)
                    {
                        rulecontent.TextContent = rulecontent.TextContent.Replace("\n", "<br/>");
                    }
                    helper.Response("{total:" + itemsContent.RecordCount + ",data:" + Json.ToStringList(listContent) + "}");
                    break;

                default:
                    break;
                }
            }
        }