Ejemplo n.º 1
0
        public commonresponse ChangeLicense([FromBody] changelicenserequest input)
        {
            //  highlevel.LogRequest("ChangeLicense", "ChangeLicense", Request.HttpContext.Connection.RemoteIpAddress.ToString());
            if (input == null)
            {
                return(new commonresponse {
                    status = responseStatus.requesterror
                });
            }
            var accinfo = highlevel.GetInfoByToken(Request.Headers);

            if (accinfo.status != responseStatus.ok)
            {
                return(accinfo);
            }
            var identity = accinfo.Identity;
            var btype    = accinfo.businessType;

            if (input.lost)
            {
                if (!savePic(input.sign_pic, picType.sign_pic, identity, btype))
                {
                    return new commonresponse {
                               status = responseStatus.fileprocesserror
                    }
                }
                ;
            }
            else
            {
                if (!savePic(input.license_pic, picType.driver, identity, btype))
                {
                    return new commonresponse {
                               status = responseStatus.fileprocesserror
                    }
                }
                ;
            }
            if (!savePic(input.id_back, picType.id_back, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            if (!savePic(input.id_front, picType.id_front, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            if (!savePic(input.id_inhand, picType.id_inhand, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            if (!savePic(input.hukou_pic, picType.hukou_pic, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            return(new commonresponse {
                status = responseStatus.ok
            });
        }
Ejemplo n.º 2
0
        public commonresponse ChangeLicense([FromBody] changelicenserequest input)
        {
            LogRequest("ChangeLicense", "ChangeLicense", Request.HttpContext.Connection.RemoteIpAddress.ToString());
            if (input == null)
            {
                return(new commonresponse {
                    status = responseStatus.requesterror
                });
            }
            var btype    = businessType.basicinfo;
            var identity = string.Empty;

            try
            {
                var htoken = Request.Headers["token"].First();
                if (string.IsNullOrEmpty(htoken))
                {
                    return(new commonresponse {
                        status = responseStatus.tokenerror
                    });
                }
                var found = false;

                foreach (var a in tokens)
                {
                    if (a.Token == htoken)
                    {
                        identity = a.idinfo.Identity;
                        btype    = a.idinfo.businessType;
                        found    = true;
                        break;
                    }
                }
                if (!found)
                {
                    var redisdb     = highlevel.redis.GetDatabase();
                    var cacheidinfo = redisdb.StringGet(htoken);
                    if (cacheidinfo == "nil")
                    {
                        return(new commonresponse {
                            status = responseStatus.tokenerror
                        });
                    }
                    var ci = JsonConvert.DeserializeObject <idinfo>(cacheidinfo);
                    identity = ci.Identity;
                    btype    = ci.businessType;
                }
            }
            catch (Exception ex)
            {
                return(new commonresponse {
                    status = responseStatus.tokenerror
                });
            }

            // if (string.IsNullOrEmpty(input.id_back))
            // {
            //     return new commonresponse { status = responseStatus.imageerror };
            // }
            if (input.lost)
            {
                if (!savePic(input.sign_pic, picType.sign_pic, identity, btype))
                {
                    return new commonresponse {
                               status = responseStatus.fileprocesserror
                    }
                }
                ;
            }
            else
            {
                if (!savePic(input.license_pic, picType.driver, identity, btype))
                {
                    return new commonresponse {
                               status = responseStatus.fileprocesserror
                    }
                }
                ;
            }
            if (!savePic(input.id_back, picType.id_back, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            if (!savePic(input.id_front, picType.id_front, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            if (!savePic(input.id_inhand, picType.id_inhand, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            if (!savePic(input.hukou_pic, picType.hukou_pic, identity, btype))
            {
                return new commonresponse {
                           status = responseStatus.fileprocesserror
                }
            }
            ;
            return(new commonresponse {
                status = responseStatus.ok
            });
        }