Esempio n. 1
0
        public ActionResult <string> IMPORTUSER(IFormFile excelfile)
        {
            try
            {
                var files = Request.Form.Files;
                var file  = files.FirstOrDefault();
                using (var memoryStream = new MemoryStream())
                {
                    file.CopyTo(memoryStream);
                    memoryStream.Seek(0, SeekOrigin.Begin);
                    string headrow = Request.Form["headrow"].ToString();
                    string suffix  = file.FileName.Split('.')[1];
                    Model.Result = new CommonHelp().ExcelToTable(memoryStream, int.Parse(headrow), suffix);
                }
            }
            catch (Exception ex)
            {
                Model.ErrorMsg = "IMPORTUSER导入失败";
                Model.Result   = ex.ToString();
                new JH_Auth_LogB().InsertLog("IMPORTUSER", Model.ErrorMsg + ex.StackTrace.ToString(), ex.ToString(), "", "", 0, "");
                return("");
            }


            return(ControHelp.CovJson(Model));
        }
Esempio n. 2
0
        public ActionResult <string> ExeAction(string Action, Object PostData)
        {
            Model.Action = Action;
            var           context     = _accessor.HttpContext;
            var           tokenHeader = context.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
            TokenModelJWT tokenModel  = JwtHelper.SerializeJWT(tokenHeader);

            if (new DateTimeOffset(DateTime.Now.AddMinutes(5)).ToUnixTimeSeconds() > tokenModel.Exp)
            {
                //需要更新Token
                Model.uptoken = JwtHelper.CreateJWT(tokenModel.UserName, "Admin");
            }
            JH_Auth_UserB.UserInfo UserInfo = CacheHelp.Get(tokenModel.UserName) as JH_Auth_UserB.UserInfo;
            if (UserInfo == null)
            {
                UserInfo = new JH_Auth_UserB().GetUserInfo(10334, tokenModel.UserName);
                CacheHelp.Set(tokenModel.UserName, UserInfo);
            }
            try
            {
                JObject JsonData = JObject.FromObject(PostData);
                string  P1       = JsonData["P1"] == null ? "" : JsonData["P1"].ToString();
                string  P2       = JsonData["P2"] == null ? "" : JsonData["P2"].ToString();


                // 1.Load(命名空间名称),GetType(命名空间.类名)
                Type type = Assembly.Load("QJY.API").GetType("QJY.API." + Action.Split('_')[0].ToUpper() + "Manage");
                //2.GetMethod(需要调用的方法名称)
                MethodInfo method = type.GetMethod(Action.Split('_')[1].ToUpper());
                // 3.调用的实例化方法(非静态方法)需要创建类型的一个实例
                object obj = Activator.CreateInstance(type);
                //4.方法需要传入的参数
                object[] parameters = new object[] { JsonData, Model, P1, P2, UserInfo };
                method.Invoke(obj, parameters);
                new JH_Auth_LogB().InsertLog(Model.Action, "--调用接口", "", UserInfo.User.UserName, UserInfo.User.UserRealName, UserInfo.QYinfo.ComId, "");
            }
            catch (Exception ex)
            {
                Model.ErrorMsg = Action + "接口调用失败,请检查日志";
                Model.Result   = ex.ToString();
                new JH_Auth_LogB().InsertLog(Action, Model.ErrorMsg + ex.StackTrace.ToString(), ex.ToString(), tokenModel.UserName, "", 0, "");
            }

            return(ControHelp.CovJson(Model));
        }
Esempio n. 3
0
        public ActionResult <string> XXJS()
        {
            var context = _accessor.HttpContext;

            String strCorpID = context.Request.Query["corpid"].ToString();
            string strCode   = context.Request.Query["Code"].ToString();

            try
            {
                JH_Auth_QY    jaq = new JH_Auth_QYB().GetALLEntities().FirstOrDefault();
                JH_Auth_Model jam = new JH_Auth_ModelB().GetEntity(p => p.ModelCode == strCode);
                if (jaq != null && jam != null)
                {
                    string echoString = context.Request.Query["echoStr"].ToString();
                    string signature  = context.Request.Query["msg_signature"].ToString();//企业号的 msg_signature
                    string timestamp  = context.Request.Query["timestamp"].ToString();
                    string nonce      = context.Request.Query["nonce"].ToString();

                    string decryptEchoString = "";
                    if (new MOBAPI().CheckSignature(jam.Token, signature, timestamp, nonce, jaq.corpId, jam.EncodingAESKey, echoString, ref decryptEchoString))
                    {
                        if (!string.IsNullOrEmpty(decryptEchoString))
                        {
                            Int64 v = Convert.ToInt64(decryptEchoString);
                            context.Response.Clear();

                            using (StreamWriter writer = new StreamWriter(Response.Body))
                            {
                                writer.Write(v);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Model.ErrorMsg = ex.ToString();
                CommonHelp.WriteLOG(ex.ToString());
            }

            return(ControHelp.CovJson(Model));
        }
Esempio n. 4
0
        public ActionResult <string> WXINIT()
        {
            try
            {
                var context = _accessor.HttpContext;
                #region 获取Code
                Model.ErrorMsg = "";
                string        P1         = context.Request.Query["P1"].ToString();
                string        P2         = context.Request.Query["P2"].ToString();
                string        szhlcode   = context.Request.Query["szhlcode"].ToString();
                TokenModelJWT tokenModel = JwtHelper.SerializeJWT(szhlcode);
                if (tokenModel.UserName == null)
                {
                    Model.ErrorMsg = "NOCODE";
                }
                else
                {
                    JH_Auth_UserB.UserInfo UserInfo = new JH_Auth_UserB().GetUserInfo(10334, tokenModel.UserName);
                    DataTable dtUsers = new JH_Auth_UserB().GetDTByCommand(" SELECT UserName,UserRealName,mobphone FROM JH_Auth_User where ComId='" + UserInfo.User.ComId + "'");
                    //获取选择用户需要的HTML和转化用户名需要的json数据
                    Model.Result = dtUsers;
                    JH_Auth_Common url = new JH_Auth_CommonB().GetEntity(p => p.ModelCode == P1 && p.MenuCode == P2);
                    if (url != null)
                    {
                        Model.Result1 = url.Url1;
                    }
                    Model.Result2 = UserInfo.User.UserName + "," + UserInfo.User.UserRealName + "," + UserInfo.User.BranchCode + "," + UserInfo.BranchInfo.DeptName;
                    Model.Result3 = UserInfo.QYinfo.FileServerUrl;
                    Model.Result4 = UserInfo.QYinfo.QYCode;
                }


                #endregion
            }
            catch (Exception ex)
            {
                Model.ErrorMsg = "WXINIT接口调用失败,请检查日志";
                Model.Result   = ex.ToString();
                CommonHelp.WriteLOG(ex.ToString());
            }
            return(ControHelp.CovJson(Model));
        }
Esempio n. 5
0
        public ActionResult <string> PubExeAction(string Action, Object PostData)
        {
            try
            {
                JObject JsonData = JObject.FromObject(PostData);
                string  P1       = JsonData["P1"] == null ? "" : JsonData["P1"].ToString();
                string  P2       = JsonData["P2"] == null ? "" : JsonData["P2"].ToString();
                var     function = Activator.CreateInstance(typeof(PubManage)) as PubManage;
                var     method   = function.GetType().GetMethod(Action.ToUpper());
                method.Invoke(function, new object[] { JsonData, Model, P1, P2, null });
            }
            catch (Exception ex)
            {
                Model.ErrorMsg = Action + "接口调用失败,请检查日志";
                Model.Result   = ex.ToString();
                new JH_Auth_LogB().InsertLog(Action, Model.ErrorMsg + ex.StackTrace.ToString(), ex.ToString(), "", "", 0, "");
            }

            return(ControHelp.CovJson(Model));
        }
Esempio n. 6
0
 public ActionResult <string> ISEXIST()
 {
     try
     {
         var context = _accessor.HttpContext;
         Model.ErrorMsg = "获取Code错误,请重试";
         string        szhlcode   = context.Request.Query["szhlcode"].ToString();
         TokenModelJWT tokenModel = JwtHelper.SerializeJWT(szhlcode);
         if (tokenModel.UserName == null)
         {
             Model.Result = "NOCODE";
         }
     }
     catch (Exception ex)
     {
         Model.ErrorMsg = "ISEXIST接口调用失败,请检查日志";
         Model.Result   = ex.ToString();
         CommonHelp.WriteLOG(ex.ToString());
     }
     return(ControHelp.CovJson(Model));
 }
Esempio n. 7
0
        public ActionResult <string> Login(Object PostData)
        {
            JObject JsonData = JObject.FromObject(PostData);
            string  username = JsonData["UserName"] == null ? "" : JsonData["UserName"].ToString();
            string  password = JsonData["password"] == null ? "" : JsonData["password"].ToString();
            Dictionary <string, string> results3 = JsonConvert.DeserializeObject <Dictionary <string, string> >(PostData.ToString());

            Model.ErrorMsg = "";
            JH_Auth_QY qyModel = new JH_Auth_QYB().GetALLEntities().First();

            password = CommonHelp.GetMD5(password);
            JH_Auth_User        userInfo = new JH_Auth_User();
            List <JH_Auth_User> userList = new JH_Auth_UserB().GetEntities(d => (d.UserName == username || d.mobphone == username) && d.UserPass == password).ToList();

            if (userList.Count() == 0)
            {
                Model.ErrorMsg = "用户名或密码不正确";
            }
            else
            {
                userInfo = userList[0];
                if (userInfo.IsUse != "Y")
                {
                    Model.ErrorMsg = "用户被禁用,请联系管理员";
                }
                if (Model.ErrorMsg == "")
                {
                    Model.Result  = JwtHelper.CreateJWT(username, "Admin");
                    Model.Result1 = userInfo.UserName;
                    Model.Result2 = qyModel.FileServerUrl;
                    Model.Result4 = userInfo;

                    CacheHelp.Remove(userInfo.UserName);
                }
            }


            return(ControHelp.CovJson(Model));;
        }
Esempio n. 8
0
        public ActionResult <string> ExeAction(string Action, Object PostData)
        {
            Model.Action = Action;
            var           context     = _accessor.HttpContext;
            var           tokenHeader = context.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
            TokenModelJWT tokenModel  = JwtHelper.SerializeJWT(tokenHeader);

            if (new DateTimeOffset(DateTime.Now.AddMinutes(5)).ToUnixTimeSeconds() > tokenModel.Exp)
            {
                //需要更新Token
                Model.uptoken = JwtHelper.CreateJWT(tokenModel.UserName, "Admin");
            }
            JH_Auth_UserB.UserInfo UserInfo = CacheHelp.Get(tokenModel.UserName) as JH_Auth_UserB.UserInfo;
            if (UserInfo == null)
            {
                UserInfo = new JH_Auth_UserB().GetUserInfo(10334, tokenModel.UserName);
                CacheHelp.Set(tokenModel.UserName, UserInfo);
            }
            try
            {
                JObject JsonData = JObject.FromObject(PostData);
                string  P1       = JsonData["P1"] == null ? "" : JsonData["P1"].ToString();
                string  P2       = JsonData["P2"] == null ? "" : JsonData["P2"].ToString();

                //Dictionary<string, string> results3 = JsonConvert.DeserializeObject<Dictionary<string, string>>(PostData.ToString());
                var function = Activator.CreateInstance(typeof(AuthManage)) as AuthManage;
                var method   = function.GetType().GetMethod(Action.ToUpper());
                method.Invoke(function, new object[] { JsonData, Model, P1, P2, UserInfo });
                new JH_Auth_LogB().InsertLog(Model.Action, "--调用接口", "", UserInfo.User.UserName, UserInfo.User.UserRealName, UserInfo.QYinfo.ComId, "");
            }
            catch (Exception ex)
            {
                Model.ErrorMsg = Action + "接口调用失败,请检查日志";
                Model.Result   = ex.ToString();
                new JH_Auth_LogB().InsertLog(Action, Model.ErrorMsg + ex.StackTrace.ToString(), ex.ToString(), tokenModel.UserName, "", 0, "");
            }

            return(ControHelp.CovJson(Model));
        }
Esempio n. 9
0
 public ActionResult <string> IMPORTXZ(IFormFile excelfile)
 {
     try
     {
         var files = Request.Form.Files;
         var file  = files.FirstOrDefault();
         using (var memoryStream = new MemoryStream())
         {
             file.CopyTo(memoryStream);
             memoryStream.Seek(0, SeekOrigin.Begin);
             string suffix = file.FileName.Split('.')[1];
             new XZGLManage().EXCELTOTABLEXZ(Model, memoryStream, suffix);
         }
     }
     catch (Exception ex)
     {
         Model.ErrorMsg = "IMPORTUSER导入失败";
         Model.Result   = ex.ToString();
         new JH_Auth_LogB().InsertLog("IMPORTUSER", Model.ErrorMsg + ex.StackTrace.ToString(), ex.ToString(), "", "", 0, "");
         return("");
     }
     return(ControHelp.CovJson(Model));
 }
Esempio n. 10
0
        public ActionResult <string> GetUserCodeByCode()
        {
            try
            {
                var context = _accessor.HttpContext;

                #region 获取Code
                Model.ErrorMsg = "获取Code错误,请重试";

                string strCode      = context.Request.Query["code"].ToString();
                string strCorpID    = context.Request.Query["corpid"].ToString();
                string strModelCode = context.Request.Query["funcode"].ToString();

                if (!string.IsNullOrEmpty(strCode))
                {
                    var qy = new JH_Auth_QYB().GetEntity(p => p.corpId == strCorpID);
                    if (qy != null)
                    {
                        try
                        {
                            //通过微信接口获取用户名
                            WXHelp wx       = new WXHelp(qy);
                            string username = wx.GetUserDataByCode(strCode, strModelCode);
                            if (!string.IsNullOrEmpty(username))
                            {
                                var jau = new JH_Auth_UserB().GetUserByUserName(qy.ComId, username);

                                if (jau != null)
                                {
                                    Model.ErrorMsg = "";
                                    Model.Result   = JwtHelper.CreateJWT(username, "Admin");
                                    Model.Result1  = jau.UserName;
                                    Model.Result3  = qy.FileServerUrl;
                                }
                            }
                            else
                            {
                                Model.ErrorMsg = "当前用户不存在";
                            }
                        }
                        catch (Exception ex)
                        {
                            Model.ErrorMsg = ex.ToString();
                        }
                    }
                    else
                    {
                        Model.ErrorMsg = "当前企业号未在电脑端注册";
                    }
                }
                else
                {
                    Model.ErrorMsg = "Code为空";
                }
                #endregion
            }
            catch (Exception ex)
            {
                Model.ErrorMsg = "接口调用失败,请检查日志";
                Model.Result   = ex.ToString();
                CommonHelp.WriteLOG(ex.ToString());
            }
            return(ControHelp.CovJson(Model));
        }