Ejemplo n.º 1
0
        public async Task <ReturnResult> EditKey([FromBody] EditKey request)
        {
            if (int.Parse(request.SectionID) <= 0)
            {
                throw new AppException("栏目不能为空");
            }
            if (string.IsNullOrWhiteSpace(request.Name))
            {
                throw new AppException("名称不能为空");
            }
            KeyContent keyContent = await KeyContentManager.GetByIdAsync(int.Parse(request.ID));

            int iUID = LoginManager.GetUserID();

            if (keyContent.CreateUserID != iUID)
            {
                throw new AppException(ReturnResultStatus.Illegal, "非法操作");
            }
            var mapper = new MapperConfiguration(x => x.CreateMap <EditKey, KeyContent>()).CreateMapper();

            mapper.Map(request, keyContent);
            keyContent.CreateUserID = iUID;
            keyContent = await KeyManager.EncryptKey(keyContent);

            return(ReturnResult.ResultCalculation(() => KeyContentManager.Update(keyContent)));
        }
Ejemplo n.º 2
0
        public async Task <ReturnResult> GetKeyDetailed(int ID)
        {
            if (ID <= 0)
            {
                throw new AppException("密匙不能为空");
            }
            int        iUID       = LoginManager.GetUserID();
            KeyContent keyContent = await KeyContentManager.GetSingleAsync(x => x.CreateUserID == iUID && x.ID == ID);

            if (keyContent == null)
            {
                throw new AppException(ReturnResultStatus.Illegal, "非法操作");
            }
            keyContent = await KeyManager.DecryptKey(keyContent);

            return(new ReturnResult(ReturnResultStatus.Succeed, JsonConvert.SerializeObject(new
            {
                keyContent.ID,
                keyContent.SectionID,
                keyContent.Name,
                keyContent.UserText,
                keyContent.PasswordText,
                keyContent.UrlText,
                keyContent.IphoneText,
                keyContent.MailText,
                keyContent.OtherText,
                keyContent.Remarks,
                keyContent.IsStart,
            })));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 密匙解密
 /// </summary>
 /// <param name="request">密匙模型</param>
 /// <returns></returns>
 public async Task <KeyContent> DecryptKey(KeyContent request)
 {
     return(await Task.Run(() =>
     {
         request.UserText = !string.IsNullOrWhiteSpace(request.UserText) ? EncryptService.DesDecrypt(request.UserText, Connection.DesEncrypt_Key) : "";
         request.PasswordText = !string.IsNullOrWhiteSpace(request.PasswordText) ? EncryptService.DesDecrypt(request.PasswordText, Connection.DesEncrypt_Key) : "";
         request.UrlText = !string.IsNullOrWhiteSpace(request.UrlText) ? EncryptService.DesDecrypt(request.UrlText, Connection.DesEncrypt_Key) : "";
         request.IphoneText = !string.IsNullOrWhiteSpace(request.IphoneText) ? EncryptService.DesDecrypt(request.IphoneText, Connection.DesEncrypt_Key) : "";
         request.MailText = !string.IsNullOrWhiteSpace(request.MailText) ? EncryptService.DesDecrypt(request.MailText, Connection.DesEncrypt_Key) : "";
         request.OtherText = !string.IsNullOrWhiteSpace(request.OtherText) ? EncryptService.DesDecrypt(request.OtherText, Connection.DesEncrypt_Key) : "";
         request.Remarks = !string.IsNullOrWhiteSpace(request.Remarks) ? EncryptService.DesDecrypt(request.Remarks, Connection.DesEncrypt_Key) : "";
         return request;
     }));
 }
Ejemplo n.º 4
0
        public async Task <ReturnResult> AddKey([FromBody] CreateKey request)
        {
            if (int.Parse(request.SectionID) <= 0)
            {
                throw new AppException("栏目不能为空");
            }
            if (string.IsNullOrWhiteSpace(request.Name))
            {
                throw new AppException("名称不能为空");
            }

            int        iUID       = LoginManager.GetUserID();
            var        mapper     = new MapperConfiguration(x => x.CreateMap <CreateKey, KeyContent>()).CreateMapper();
            KeyContent keyContent = mapper.Map <KeyContent>(request);

            keyContent.CreateUserID = iUID;
            keyContent = await KeyManager.EncryptKey(keyContent);

            return(ReturnResult.ResultCalculation(() => KeyContentManager.Insert(keyContent)));
        }
Ejemplo n.º 5
0
 public ActionResult GetUserTypes()
 {
     try
     {
         var add   = new KeyContent(0, "Select a User Type");
         var items = CustomManager.GetUserTypes();
         if (items == null || !items.Any())
         {
             return(Json(new List <KeyContent> {
                 add
             }, JsonRequestBehavior.AllowGet));
         }
         var jsonitem = items.Select(o => new KeyContent(o.UserTypeId, o.Name)).ToList();
         jsonitem.Insert(0, add);
         return(Json(jsonitem, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         return(Json(new List <KeyContent>(), JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 6
0
        public ActionResult GetStationByOrganizationId(int orgId)
        {
            try
            {
                var add   = new KeyContent(0, "Select a Station");
                var items = CustomManager.GetStationByOrganizationId(orgId);

                if (!items.Any())
                {
                    return(Json(new List <KeyContent> {
                        add
                    }, JsonRequestBehavior.AllowGet));
                }
                var jsonitem = items.Select(o => new KeyContent(o.ClientStationId, o.StationName)).ToList();
                jsonitem.Insert(0, add);
                return(Json(jsonitem, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <KeyContent>(), JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 7
0
        public ActionResult GetLocalAreaByStateId(int stateId)
        {
            try
            {
                var add   = new KeyContent(0, "Select a Local Government");
                var items = CustomManager.GetLocalAreaByStateId(stateId);

                //var items = new List<LocalArea>
                //{
                //    new LocalArea
                //    {
                //        LocalAreaId = 1,
                //        Name = "Ogba/Egbema/Ndoni"
                //    },
                //    new LocalArea
                //    {
                //        LocalAreaId = 2,
                //        Name = "Omumma"
                //    },
                //};

                if (!items.Any())
                {
                    return(Json(new List <KeyContent> {
                        add
                    }, JsonRequestBehavior.AllowGet));
                }
                var jsonitem = items.Select(o => new KeyContent(o.LocalAreaId, o.Name)).ToList();
                jsonitem.Insert(0, add);
                return(Json(jsonitem, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <KeyContent>(), JsonRequestBehavior.AllowGet));
            }
        }