public ActionResult Login(string account, string pwd)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false,
                ReturnMsg = "用户名或密码有误"
            };

            try
            {
                var entity = _adminUserInfoService.GetByUserName(account);
                if (entity != null)
                {
                    if (entity.Password.Equals(EncryptHelper.Md5(pwd, entity.PwdSalt)))
                    {
                        _currentWebContext.SetLogin(entity, true);
                        model.IsSuccess = true;
                        model.ReturnMsg = "成功登录";
                    }
                }
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = ex.Message;
            }

            return(Json(model));
        }
Beispiel #2
0
        public ActionResult AddAdvertisingSpace(AdvertisingSpaceInfoModel paraModel)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false, ReturnMsg = "操作失败"
            };

            try
            {
                _advertisingSpaceService.Insert(new AdvertisingSpaceInfo()
                {
                    Height   = paraModel.Height,
                    Width    = paraModel.Width,
                    Sign     = Guid.NewGuid().ToString("N"),
                    Intro    = paraModel.Intro,
                    Title    = paraModel.Title,
                    TypeId   = paraModel.TypeId,
                    CreateOn = DateTime.Now
                });
                model.IsSuccess = true;
                model.ReturnMsg = "添加完成";
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = ex.Message;
            }
            return(Json(model));
        }
        public ActionResult ChangePwd(string confirmPassword)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false,
                ReturnMsg = "修改失败"
            };

            if (_currentWebContext.IsAdminUserLogined)
            {
                try
                {
                    var adminUser = _currentWebContext.LoginAdminUser;
                    var salt      = StringHelper.GetSaltStr();
                    adminUser.Password = EncryptHelper.Md5(confirmPassword, salt);
                    adminUser.PwdSalt  = salt;
                    _adminUserInfoService.Update(adminUser);
                    model.IsSuccess = true;
                    model.ReturnMsg = "修改完成,请重新登录";
                }
                catch (Exception ex)
                {
                    model.ReturnMsg = ex.Message;
                }
            }

            return(Json(model));
        }
Beispiel #4
0
        public ActionResult Add(AdminUserInfoModel paraModel)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false, ReturnMsg = "操作失败"
            };

            var salt = StringHelper.GetSaltStr();

            var pwd = EncryptHelper.Md5(paraModel.Password, salt);

            try
            {
                _adminUserInfoService.Insert(new AdminUserInfo()
                {
                    UserName = paraModel.UserName,
                    Password = pwd,
                    PwdSalt  = salt,
                    CreateOn = DateTime.Now
                });
                model.IsSuccess = true;
                model.ReturnMsg = "添加完成";
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = ex.Message;
            }
            return(Json(model));
        }
Beispiel #5
0
        public ActionResult CheckUserName(string userName)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false, ReturnMsg = "验证失败"
            };

            try
            {
                var isExists = _adminUserInfoService.IsExistUserName(userName);

                if (isExists)
                {
                    model.IsSuccess = false;
                    model.ReturnMsg = "该用户名已存在";
                }
                else
                {
                    model.IsSuccess = true;
                    model.ReturnMsg = "";
                }
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = ex.Message;
            }


            return(Json(model));
        }
Beispiel #6
0
        public BaseReturnModel SaveUserSettings(ProfileSettingsPostViewModel model, string currUserId)
        {
            BaseReturnModel ret   = new BaseReturnModel();
            UserInfo        uInfo = _dbSet.FirstOrDefault(p => p.AppUserId == currUserId);

            uInfo.PrivacySetting = (UserPrivacySetting)model.SelectedPrivacySettings;
            uInfo.FollowSetting  = (UserFollowSetting)model.SelectedFollowSettings;
            uInfo.Name           = TagHelpers.RemoveUnwantedTags(model.Name);
            uInfo.Status         = TagHelpers.RemoveUnwantedTags(model.Status);
            // uInfo.UName = model.UName;
            uInfo.Surname = TagHelpers.RemoveUnwantedTags(model.Surname);
            _dbSet.Update(uInfo);
            if (!(_entityContext.SaveChanges() == 0))
            {
                ret.IsActionSucceed = true;
            }
            return(ret);
        }
        public IActionResult SetReaded([FromBody] NotificationIds model)
        {
            BaseReturnModel ret     = new BaseReturnModel();
            var             user    = HttpContext.User;
            Claim           idClaim = User.FindFirst("sub");

            if (idClaim == null)
            {
                ret.IsActionSucceed = false;
                ret.ErrorInformation.RedirectUrl = "Auth";

                return(Ok(Json(ret)));
            }
            ret.IsActionSucceed = true;
            _notificationDataService.SetReaded(model.notificationIds);

            return(Ok(Json(ret)));
        }
Beispiel #8
0
        public BaseReturnModel RemoveComment(int commentId, string currUserId)
        {
            BaseReturnModel ret = new BaseReturnModel();
            Comment         cmd = _dbSet.FirstOrDefault(p => p.Id == commentId && p.AuthorId == currUserId);

            if (cmd == null)
            {
                ret.IsActionSucceed = false;
                return(ret);
            }
            else
            {
                cmd.IsSoftDeleted = true;
                _dbSet.Update(cmd);
                if (_context.SaveChanges() != 0)
                {
                    ret.IsActionSucceed = true;
                }
                return(ret);
            }
        }
Beispiel #9
0
        public ActionResult DeleteAdvContent(int id)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false, ReturnMsg = "操作失败"
            };

            try
            {
                _advContentInfoService.Delete(id);
                model.IsSuccess = true;
                model.ReturnMsg = "删除完成";
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = ex.Message;
            }

            return(Json(model));
        }
Beispiel #10
0
        public ActionResult EditAdvertisingSpace(AdvertisingSpaceInfoModel paraModel)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false, ReturnMsg = "操作失败"
            };

            try
            {
                _advertisingSpaceService.Update(paraModel);
                model.IsSuccess = true;
                model.ReturnMsg = "编辑完成";
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = ex.Message;
            }

            return(Json(model));
        }
Beispiel #11
0
        // 记录接口日志

        public static IRestResponse <T> PostExcute <T>(DataRow InterfaceURL, DataRow InterfaceQueue, object PostObj) where T : class, new()
        {
            if (string.IsNullOrEmpty(InterfaceURL["Url"].ToString()))
            {
                throw new ApplicationException("接口地址未配置!");
            }
            var client  = new RestClient(InterfaceURL["Url"].ToString());
            var request = new RestRequest(Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddJsonBody(PostObj);
            request.AddHeader("Content-Type", "application/json; charset=utf-8");

            var content = client.Execute <T>(request);

            var interfaceCode = string.Empty;

            if (InterfaceURL["Url"].ToString().Contains("="))
            {
                interfaceCode = InterfaceURL["Url"].ToString().Split('=')[1];
            }

            string requestBody  = content.Request.JsonSerializer.Serialize(PostObj);
            string responseBody = content.Content;


            if (content.StatusCode != System.Net.HttpStatusCode.OK)
            {
                BDO     bd    = new BDO(null, null, "SYS_InterfaceLog", "1<>1");
                DataRow drBat = bd.NewRow();
                drBat["IsIn"]            = 0;
                drBat["LogTime"]         = DateTime.Now;
                drBat["SerialNo"]        = InterfaceQueue["SerialNo"];
                drBat["FunctionName"]    = InterfaceQueue["FunctionName"];
                drBat["InterfaceName"]   = InterfaceQueue["InterfaceName"];
                drBat["interfaceCode"]   = interfaceCode;
                drBat["RequestBody"]     = requestBody;
                drBat["ResponseBody"]    = responseBody;
                drBat["ResponseCode"]    = "E";
                drBat["ResponseMessage"] = content.Content;
                bd.Rows.Add(drBat);
                DataRowsSaveResult drsr = bd.SaveToDB(null, null);
            }
            else
            {
                var ResponseCode    = string.Empty;
                var ResponseMessage = string.Empty;
                var ZGUID           = string.Empty;
                var isSendMialToSAP = false;//是否发送邮件 added by haijun 2018-4-18
                try
                {
                    BaseReturnModel model = Newtonsoft.Json.JsonConvert.DeserializeObject <BaseReturnModel>(responseBody);
                    if (model == null)
                    {
                        throw new ApplicationException("返回信息解析失败:" + InterfaceURL["Url"].ToString() + "->" + responseBody);
                    }
                    if (content.Data == null)
                    {
                        content.Data = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(responseBody);
                    }

                    //added by haijun
                    if (model.HEAD != null)
                    {
                        if (!String.IsNullOrEmpty(model.HEAD.ZTYPE))
                        {
                            if (model.HEAD.ZTYPE == "E")
                            {
                                isSendMialToSAP = true;
                            }
                        }
                    }
                    if (model.ITEM != null && model.ITEM.Count > 0 && !isSendMialToSAP)
                    {
                        var items = model.ITEM.Where(i => i.ZTYPE == "E");
                        if (items.Any())
                        {
                            isSendMialToSAP = true;
                        }
                    }

                    if (model.HEAD != null && !string.IsNullOrEmpty(model.HEAD.ZTYPE))
                    {
                        ResponseCode    = model.HEAD.ZTYPE;
                        ResponseMessage = model.HEAD.ZMESSAGE;
                        ZGUID           = model.HEAD.ZGUID;
                    }
                    else if (model.ITEM != null && model.ITEM.Count > 0)
                    {
                        var items = model.ITEM.Where(i => i.ZTYPE == "E");
                        ResponseCode = items.Any() ? "E" : "S";
                        if (items.Any())
                        {
                            ResponseMessage = string.Join(";", items.Select(s => s.ZMESSAGE).ToList());
                        }
                        else
                        {
                            ResponseMessage = model.ITEM.First().ZMESSAGE;
                        }

                        ZGUID = model.ITEM.First().ZGUID;
                    }
                }
                catch (Exception ex)
                {
                    ResponseCode    = "N/A";
                    ResponseMessage = string.IsNullOrEmpty(responseBody) ? ex.Message : responseBody;
                }


                BDO     bd    = new BDO(null, null, "SYS_InterfaceLog", "1<>1");
                DataRow drBat = bd.NewRow();
                drBat["IsIn"]            = 0;
                drBat["LogTime"]         = DateTime.Now;
                drBat["SerialNo"]        = InterfaceQueue["SerialNo"];
                drBat["FunctionName"]    = InterfaceQueue["FunctionName"];
                drBat["InterfaceName"]   = InterfaceQueue["InterfaceName"];
                drBat["interfaceCode"]   = interfaceCode;
                drBat["RequestBody"]     = requestBody;
                drBat["ResponseBody"]    = responseBody;
                drBat["ResponseCode"]    = ResponseCode;
                drBat["ResponseMessage"] = string.IsNullOrEmpty(ResponseMessage) ? "" : ResponseMessage;
                bd.Rows.Add(drBat);
                DataRowsSaveResult drsr = bd.SaveToDB(null, null);
            }

            return(content);
        }
Beispiel #12
0
        public ActionResult EditAdvContent(AdvContentInfoModel paraModel, FormCollection form)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = false, ReturnMsg = "操作失败"
            };

            try
            {
                var entityModel = _advContentInfoService.GetById(paraModel.Id);

                entityModel.AdvertisingSpaceInfoSign = paraModel.AdvertisingSpaceInfoSign;
                entityModel.Title              = paraModel.Title;
                entityModel.Order              = paraModel.Order;
                entityModel.Intro              = paraModel.Intro;
                entityModel.TargetType         = paraModel.TargetType;
                entityModel.ContentJsonKeyword = paraModel.ContentJsonKeyword;
                entityModel.Price              = paraModel.Price;
                entityModel.BeginDatetime      = paraModel.BeginDatetime;
                entityModel.EndDateTime        = paraModel.EndDateTime;
                entityModel.Type = paraModel.Type;

                switch (paraModel.Type)
                {
                case AdvContentInfoType.Word:
                    var wordModel = new AdvContentWordModel()
                    {
                        WordTitle = form["WordTitle"],
                        WordSize  = form["WordSize"],
                        WordColor = form["WordColor"],
                        WordLink  = form["WordLink"]
                    };
                    entityModel.ContentJson = JsonConvert.SerializeObject(wordModel);
                    break;

                case AdvContentInfoType.Pic:
                    var picModel = new AdvContentPicModel()
                    {
                        PicUrl      = form["PicUrl"],
                        PicImageAlt = form["PicImageAlt"],
                        PicLink     = form["PicLink"]
                    };
                    entityModel.ContentJson = JsonConvert.SerializeObject(picModel);
                    break;

                default:
                    break;
                }

                _advContentInfoService.Update(entityModel);

                model.IsSuccess = true;
                model.ReturnMsg = "编辑完成";
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = ex.Message;
            }

            return(Json(model));
        }
Beispiel #13
0
        public IHttpActionResult ShareInfoAES(dynamic obj)
        {
            var model = new BaseReturnModel()
            {
                IsSuccess = true,
                ReturnMsg = "解密成功"
            };

            try
            {
                WebLogHelper.WebLog(JsonConvert.SerializeObject(obj));
                var rijndaelCipher = new RijndaelManaged();
                rijndaelCipher.Mode = CipherMode.CBC;

                rijndaelCipher.Padding = PaddingMode.PKCS7;

                rijndaelCipher.KeySize = 128;

                rijndaelCipher.BlockSize = 128;
                //WebLogHelper.WebLog(obj.encryptedData.Value);
                byte[] Data = Convert.FromBase64String(obj.encryptedData.Value);
                //WebLogHelper.WebLog(obj.sessionKey.Value);
                byte[] pwdBytes = Convert.FromBase64String(obj.sessionKey.Value);

                byte[] keyBytes = new byte[16];

                int len = pwdBytes.Length;

                if (len > keyBytes.Length)
                {
                    len = keyBytes.Length;
                }

                System.Array.Copy(pwdBytes, keyBytes, len);

                rijndaelCipher.Key = keyBytes;
                //WebLogHelper.WebLog(obj.iv.Value);
                rijndaelCipher.IV = Convert.FromBase64String(obj.iv.Value);

                var transform = rijndaelCipher.CreateDecryptor();

                byte[] plainText = transform.TransformFinalBlock(Data, 0, Data.Length);

                var resultStr = Encoding.UTF8.GetString(plainText);

                if (!string.IsNullOrEmpty(resultStr))
                {
                    //WebLogHelper.WebLog(resultStr);
                    var result = JsonConvert.DeserializeObject <ShareInfoAESModel>(resultStr);
                    if (result == null || result.watermark == null || result.watermark.appid == null)
                    {
                        throw new MyProException(resultStr + "解密结果反序列后结果有误");
                    }

                    var baseSetting = this.baseSettingService.GetLast();
                    if (!baseSetting.AppId.Equals(result.watermark.appid))
                    {
                        throw new MyProException("不是当前小程序对应的appid");
                    }
                    return(Json(result));
                }
                else
                {
                    throw new MyProException("解密结果为空");
                }
            }
            catch (Exception ex)
            {
                model.IsSuccess = false;
                model.ReturnMsg = "操作失败,详情请查看日志";
                WebLogHelper.WebErrorLog("ShareInfoAES", ex);
                return(Json(model));
            }
        }