Beispiel #1
0
        public HttpResponseMessage Login(JObject jData)
        {
            //定义
            ResponseResult obj      = new ResponseResult();
            dynamic        json     = jData;
            string         username = json.phone;
            string         password = json.password;
            string         appId    = json.appId;
            var            model    = GetLoginModel(username, password);

            if (model != null)
            {
                if (ValidateTicket(model.token))
                {
                    obj.Token = model.token;
                }
                else
                {
                    var token = Guid.NewGuid().ToString("N");
                    model.token      = token;
                    model.expireDate = DateTime.Now.AddDays(7);
                    obj.Token        = token;
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        UtilSysLog.NewLogErre(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.ToString());
                    }
                }
                obj.status = "0";
                obj.msg    = "ok";
                obj.data   = JsonHelp.ObjectToString(model);
                UtilSysLog.NewLogInfo(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "用户登录", "Login", appId, "Account");
            }
            else
            {
                obj.status = "2";
                obj.msg    = "用户名或密码错误";
                obj.data   = "";
                obj.Token  = "";
                UtilSysLog.NewLogInfo(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "用户名或密码错误", "Login", appId, "Account");
            }
            var resultObj = JsonConvert.SerializeObject(obj, Formatting.Indented);
            HttpResponseMessage result = new HttpResponseMessage {
                Content = new StringContent(resultObj, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(result);
        }
Beispiel #2
0
        public HttpResponseMessage Create(JObject jData)
        {
            ReturnResult obj      = new ReturnResult();
            dynamic      json     = jData;
            string       appId    = json.appId;
            string       token    = json.token;
            string       clientId = json.clientId;
            string       type     = json.type;
            string       model    = json.model;
            string       name     = json.name;
            string       sn       = json.sn;
            string       code     = json.code;

            try
            {
                Equipment data = new Equipment();
                data.appId    = appId;
                data.clientId = clientId;
                data.token    = token;
                data.type     = type;
                data.model    = model;
                data.name     = name;
                data.sn       = sn;
                data.code     = code;

                db.Equipment.Add(data);
                db.SaveChanges();


                obj.status = "0";
                obj.msg    = "ok";
                obj.data   = "设备入库";
                UtilSysLog.NewLogInfo(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "设备入库!", "Create", appId, "Equipment");
            }
            catch (Exception ex)
            {
                obj.status = "6";
                obj.msg    = "失败";
                obj.data   = "";
                UtilSysLog.NewLogErre(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.ToString());
            }


            var resultObj = JsonConvert.SerializeObject(obj);
            HttpResponseMessage result = new HttpResponseMessage {
                Content = new StringContent(resultObj, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(result);
        }
Beispiel #3
0
        public HttpResponseMessage Create(JObject jData)
        {
            ReturnResult obj       = new ReturnResult();
            dynamic      json      = jData;
            string       appId     = json.appId;
            string       token     = json.token;
            string       parent    = json.parent;
            string       name      = json.name;
            string       shortname = json.shortname;
            string       level     = json.level;
            string       type      = json.type;

            District model = new District();

            model.appId       = appId;
            model.token       = token;
            model.parent      = parent;
            model.name        = name;
            model.shortname   = shortname;
            model.level       = level;
            model.type        = type;
            model.createDate  = DateTime.Now;
            model.description = "";


            try
            {
                db.District.Add(model);
                db.SaveChanges();

                obj.status = "0";
                obj.msg    = "ok";
                obj.data   = model.Id.ToString();
                UtilSysLog.NewLogInfo(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "区域创建!", "Create", appId, "District");
            }
            catch (Exception ex)
            {
                obj.status = "6";
                obj.msg    = "失败";
                obj.data   = "";
                UtilSysLog.NewLogErre(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.ToString());
            }

            var resultObj = JsonConvert.SerializeObject(obj);
            HttpResponseMessage result = new HttpResponseMessage {
                Content = new StringContent(resultObj, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(result);
        }
Beispiel #4
0
        public HttpResponseMessage Create(JObject jData)
        {
            ReturnResult obj      = new ReturnResult();
            dynamic      json     = jData;
            string       token    = json.token;
            string       appId    = json.appId;
            string       clientId = json.clientId;
            string       name     = json.name;
            string       status   = json.status;
            string       module   = json.module;
            string       contacts = json.contacts;
            string       phone    = json.phone;
            string       email    = json.email;
            string       address  = json.address;
            Merchant     model    = new Merchant();

            model.address    = address;
            model.clientId   = clientId;
            model.token      = token;
            model.name       = name;
            model.status     = status;
            model.module     = module;
            model.email      = email;
            model.phone      = phone;
            model.appId      = appId;
            model.contacts   = contacts;
            model.createDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            try
            {
                db.Merchant.Add(model);
                db.SaveChanges();
                obj.status = "0";
                obj.msg    = "成功";
                obj.data   = model.Id.ToString();
                UtilSysLog.NewLogInfo(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "创建商户", "Create", appId, "Merchant");
            }
            catch (Exception ex)
            {
                obj.status = "6";
                obj.msg    = "失败";
                obj.data   = "";
                UtilSysLog.NewLogErre(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.ToString());
            }
            var resultObj = JsonConvert.SerializeObject(obj);
            HttpResponseMessage result = new HttpResponseMessage {
                Content = new StringContent(resultObj, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(result);
        }
Beispiel #5
0
        public HttpResponseMessage Create(JObject jData)
        {
            NodeList     model = new NodeList();
            ReturnResult obj   = new ReturnResult();
            dynamic      json  = jData;

            model.appId       = json.appId;
            model.contacts    = json.contacts;
            model.createDate  = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            model.description = "";
            model.name        = json.name;
            model.parent      = json.parent;
            model.phone       = json.phone;
            model.token       = json.token;
            model.type        = json.type;

            try
            {
                db.NodeList.Add(model);
                db.SaveChanges();

                obj.status = "0";
                obj.msg    = "ok";
                obj.data   = model.Id.ToString();
                UtilSysLog.NewLogInfo(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "节点创建!", "Create", json.appId, "Node");
            }
            catch (Exception ex)
            {
                obj.status = "6";
                obj.msg    = "失败";
                obj.data   = "";
                UtilSysLog.NewLogErre(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.ToString());
            }


            var resultObj = JsonConvert.SerializeObject(obj);
            HttpResponseMessage result = new HttpResponseMessage {
                Content = new StringContent(resultObj, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(result);
        }
Beispiel #6
0
        public static void SetAppIdlog(string appid, string controller, string action)
        {
            YLApiEntities db       = new YLApiEntities();
            AppIdLog      appidlog = new AppIdLog();

            appidlog.appId      = appid;
            appidlog.actionName = action;
            appidlog.addTime    = DateTime.Now;
            appidlog.controller = controller;
            appidlog.remark     = "";
            try
            {
                db.AppIdLog.Add(appidlog);
                db.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }