123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using System;
- using System.Reflection;
- using System.Web;
- using System.Web.SessionState;
- namespace iNethinkCMS.Web
- {
- public struct ResponseResult
- {
- private int code;
- public int Code
- {
- get { return code; }
- set { code = value; }
- }
- private string info;
- public string Info
- {
- get { return info; }
- set { info = value; }
- }
- private object data;
- public object Data
- {
- get { return data; }
- set { data = value; }
- }
- public ResponseResult(int code, string info, object data = null)
- {
- this.code = code;
- this.info = info;
- this.data = data;
- }
- }
- /// <summary>
- /// api 的摘要说明
- /// </summary>
- public class api : IHttpHandler, IRequiresSessionState
- {
- public bool IsReusable
- {
- get
- {
- throw new NotImplementedException();
- }
- }
- protected string json(ResponseResult rtndata)
- {
- return Newtonsoft.Json.JsonConvert.SerializeObject(rtndata);
- }
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "application/json";
- Type thisType = this.GetType();
- MethodInfo mi = thisType.GetMethod(context.Request.PathInfo.Split('/')[1]);
- try
- {
- context.Response.Write(
- json(
- (ResponseResult)
- mi.Invoke(this, new object[]{
- context
- })
- )
- );
- }
- catch (Exception e)
- {
- context.Response.Write(
- json(
- new ResponseResult(404, "Method invalid, info:" + e.Message)
- ));
- }
- }
- public ResponseResult sendVerificationCode(HttpContext context)
- {
- string tel = context.Request.QueryString["tel"];
- int code = Helper.VarifyCode.Next(tel);
- string result = Helper.Messager.Send(tel, $"欢迎试用利亚方舟影楼Erp管理软件,您的验证码是:{code}");
- return new ResponseResult(200, "Successed", code);
- }
- public ResponseResult isCodeValidate(HttpContext context)
- {
- string tel = context.Request.QueryString["tel"];
- int code = int.Parse(context.Request.QueryString["code"]);
- if (Helper.VarifyCode.isCodeValidate(tel, code))
- {
- return new ResponseResult(200, "Successed");
- }
- else
- {
- return new ResponseResult(403, "Failed");
- }
- }
- public ResponseResult ResponseConfirm(HttpContext context)
- {
- int id = Int32.Parse(context.Request.Form["id"]);
- string responsor = context.Request.Form["responsor"];
- string remark = context.Request.Form["remark"];
- BLL.BLL_Immediateuse.Responsed(id, responsor, remark);
- return new ResponseResult(200, "Successed");
- }
- public ResponseResult ApplicationForTrial(HttpContext context)
- {
- try
- {
- Model.Model_Immediateuse model = new Model.Model_Immediateuse();
- model.SJ = context.Request.Form["tel"];
- int code = int.Parse(context.Request.Form["code"]);
- if (BLL.BLL_Immediateuse.Exsits(model.SJ))
- {
- return new ResponseResult(-4, "号码已经成功提交,请不要重复提交,感谢您的支持");
- }
- else
- {
- if (Helper.VarifyCode.isCodeValidate(model.SJ, code))
- {
- model.Name = context.Request.Form["name"];
- model.lyName = context.Request.Form["lymc"];
- model.lyDZ = context.Request.Form["lydz"];
- model.lyGM = context.Request.Form["lygm"];
- model.ZW = context.Request.Form["zw"];
- model.date = DateTime.Now;
- BLL.BLL_Immediateuse bll = new BLL.BLL_Immediateuse();
- if (bll.Add(model) > 0)
- {
- Helper.Messager.Send("18602065722", $"通知:有新的用户({model.SJ})在官网登记了信息,请及时查询回复");
- Helper.Messager.Send("18607523124", $"通知:有新的用户({model.SJ})在官网登记了信息,请及时查询回复");
- return new ResponseResult(0, "Success!");
- }
- else
- {
- return new ResponseResult(-3, "系统异常,请直接与客服人员联系");
- }
- }
- else
- {
- return new ResponseResult(-1, "验证码不正确或已经失效!");
- }
- }
- }
- catch
- {
- return new ResponseResult(-2, "系统异常,请直接与客服人员联系");
- }
- }
- }
- }
|