Пример #1
0
 public Task <IActionResult> GetEntities()
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var rows = MenuRepository.Get().ToList();
         return Json(ExcutedResult.SuccessResult(rows));
     }));
 }
Пример #2
0
 public Task <IActionResult> Delete(int id)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         MenuRepository.Delete(id, false);
         return Json(ExcutedResult.SuccessResult("成功删除一条数据。"));
     }));
 }
Пример #3
0
 public Task <IActionResult> Delete(string id)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         SysPermissionRepository.Delete(id);
         return Json(ExcutedResult.SuccessResult("成功删除一条数据。"));
     }));
 }
 public Task <IActionResult> GetMenus()
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var rows = menuRepository.GetHomeMenusByTreeView(m => m.Activable && m.Visiable && m.ParentId == 0).OrderBy(m => m.SortIndex).ToList();
         return Json(ExcutedResult.SuccessResult(rows));
     }));
 }
Пример #5
0
        /// <summary>
        /// 更新节点信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ExcutedResult UpdateNode(UpdateNodeRequestModel model)
        {
            try
            {
                var user = CurrentUser;
                if (model == null)
                {
                    throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误或无效");
                }
                model.Vefity();
                var node    = Repository.GetSingle(model.Id);
                var oldNode = node;
                if (!String.IsNullOrEmpty(model.Name))
                {
                    node.Name = model.Name;
                }
                if (!String.IsNullOrEmpty(model.HttpAddress))
                {
                    node.HttpAddress = model.HttpAddress;
                }
                node.IsSuper = model.IsSuper;
                if (model.TimeOut == default(int))
                {
                    node.TimeOut = model.TimeOut;
                }
                if (model.Priority == default(int))
                {
                    node.Priority = model.Priority;
                }
                node.QueryAlternative  = model.QueryAlternative;
                node.PlayerAlternative = model.PlayerAlternative;
                node.ServerAlternative = model.ServerAlternative;
                if (!String.IsNullOrEmpty(model.Address))
                {
                    node.Address = model.Address;
                }

                Repository.Update(node);

                OperateLog log = new OperateLog();
                log.Id             = Guid.NewGuid();
                log.ClientIp       = user.ClientIP;
                log.CreateTime     = DateTime.UtcNow;
                log.ManagerAccount = user.Mobile;
                log.ManagerId      = user.Id;
                log.OriginalValue  = JsonConvert.SerializeObject(oldNode);
                log.NewValue       = JsonConvert.SerializeObject(node);
                log.Operate        = "Update";
                log.Function       = "更新节点信息";
                _operateLogRepository.Insert(log);

                return(ExcutedResult.SuccessResult());
            }
            catch (BusinessException businessException)
            {
                return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
            }
        }
Пример #6
0
 public Task <IActionResult> Delete(string id)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var menuRepository = this.GetService <ISysMenuRepository>();
         menuRepository.Delete(id);
         return Json(ExcutedResult.SuccessResult("成功删除一条数据。"));
     }));
 }
 public Task <IActionResult> GetVueMenus()
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var rows = menuRepository
                    .GetHomeMenusByTreeView(m => m.Activable && m.Visiable && string.IsNullOrEmpty(m.ParentId))
                    .OrderBy(m => m.SortIndex).Select(ToJsonViewModel).ToList();
         return Json(ExcutedResult.SuccessResult(rows));
     }));
 }
 public Task <IActionResult> GetMenus()
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var rows = this.GetService <ISysMenuRepository>()
                    .GetHomeMenusByTreeView(m => m.Active && m.Visible && string.IsNullOrEmpty(m.ParentId))
                    .OrderBy(m => m.SortIndex).ToList();
         return Json(ExcutedResult.SuccessResult(rows));
     }));
 }
 public Task <IActionResult> Active(string id)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var entity = menuRepository.GetSingle(id);
         entity.Activable = !entity.Activable;
         menuRepository.Update(entity, false, "Activable");
         return Json(ExcutedResult.SuccessResult(entity.Activable?"OK,已成功启用。":"OK,已成功停用"));
     }));
 }
 public Task <IActionResult> Visualize(string id)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var entity = menuRepository.GetSingle(id);
         entity.Visiable = !entity.Visiable;
         menuRepository.Update(entity, false, "Visiable");
         return Json(ExcutedResult.SuccessResult("操作成功,请刷新当前网页或者重新进入系统。"));
     }));
 }
Пример #11
0
 public ExcutedResult GetTimestamp()
 {
     try
     {
         return(ExcutedResult.SuccessResult(DateTimeHelper.GetTimeStamp(DateTime.UtcNow, true)));
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
 }
Пример #12
0
 public Task <IActionResult> Active(string id)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         var menuRepository = this.GetService <ISysMenuRepository>();
         var entity = menuRepository.GetSingle(id);
         entity.Active = !entity.Active;
         menuRepository.Update(entity, "Active");
         return Json(ExcutedResult.SuccessResult(entity.Active?"OK,已成功启用。":"OK,已成功停用"));
     }));
 }
Пример #13
0
        public void PreSaveFile(string key, out ExcutedResult result)
        {
            var fileHeader = _fileHeaderRepository.FirstOrDefault(p => p.Key == key);

            if (fileHeader == null)
            {
                result = ExcutedResult.FailedResult(BusinessResultCode.FileNotExistYet, "");
                return;
            }
            result = ExcutedResult.SuccessResult(FileModel.FileHeaderToModel(fileHeader));
        }
Пример #14
0
        public ExcutedResult <TransactionDetailModel> GetTransfer(string trxId)
        {
            if (string.IsNullOrWhiteSpace(trxId))
            {
                return(ExcutedResult <TransactionDetailModel> .FailedResult(SysResultCode.ParameterInvalid, "参数无效或错误"));
            }

            var transfer = _accountServiceModel.GetTransfer(trxId);

            return(ExcutedResult <TransactionDetailModel> .SuccessResult(transfer));
        }
Пример #15
0
 public ExcutedResult <BlackContractModel> GetProposalDetail(long contractId)
 {
     try
     {
         var model = _blackContractLogic.GetProposalDetail(contractId);
         return(ExcutedResult <BlackContractModel> .SuccessResult(model));
     }
     catch (BusinessException bex)
     {
         return(ExcutedResult <BlackContractModel> .FailedResult(bex.ErrorCode, bex.Message));
     }
 }
Пример #16
0
        public ExcutedResult <PagedResults <TransferRecordModel> > GetTransferRecord(TransferQueryParams queryParams)
        {
            if (!ModelState.IsValid)
            {
                return(ExcutedResult <PagedResults <TransferRecordModel> > .FailedResult(SysResultCode.ParameterInvalid,
                                                                                         "参数无效或错误"));
            }

            var result = _accountServiceModel.GetTransferRecord(queryParams);

            return(ExcutedResult <PagedResults <TransferRecordModel> > .SuccessResult(result));
        }
Пример #17
0
 public ExcutedResult <List <BlackContractModel> > QueryProposalList()
 {
     try
     {
         var list = _blackContractLogic.GetProposalList();
         return(ExcutedResult <List <BlackContractModel> > .SuccessResult(list));
     }
     catch (BusinessException bex)
     {
         return(ExcutedResult <List <BlackContractModel> > .FailedResult(bex.ErrorCode, bex.Message));
     }
 }
 public Task <IActionResult> Edit(SysMenu menu)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         if (!ModelState.IsValid)
         {
             return Json(ExcutedResult.FailedResult("数据验证失败"));
         }
         menuRepository.Edit(menu, true);
         return Json(ExcutedResult.SuccessResult());
     }));
 }
 public Task <IActionResult> Add(SysRole model)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         if (!ModelState.IsValid)
         {
             return Json(ExcutedResult.FailedResult("数据验证失败"));
         }
         SysRoleRepository.AddAsync(model, false);
         return Json(ExcutedResult.SuccessResult());
     }));
 }
Пример #20
0
 public Task <IActionResult> Edit(TaskInfo model)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         if (!ModelState.IsValid)
         {
             return Json(ExcutedResult.FailedResult("数据验证失败"));
         }
         TaskInfoRepository.Edit(model, false);
         return Json(ExcutedResult.SuccessResult());
     }));
 }
Пример #21
0
 public ExcutedResult RefreshMemoryCache()
 {
     try
     {
         _configDataLogic.RefreshMemoryCache();
         return(ExcutedResult.SuccessResult());
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
 }
Пример #22
0
 public ExcutedResult Update([FromBody] ConfigData modle)
 {
     try
     {
         _configDataLogic.Update(modle, out var result);
         return(ExcutedResult.SuccessResult(result));
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
 }
Пример #23
0
        /// <summary>
        /// 查
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ExcutedResult QueryLanguage(LanguageQueryRequestModel model)
        {
            try
            {
                if (model == null)
                {
                    throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误或无效");
                }
                if (model.PageIndex == default(int))
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize == default(int))
                {
                    model.PageSize = 10;
                }
                DateTime startTime = default(DateTime);
                DateTime.TryParse(model.StartTime, out startTime);
                DateTime endTime = default(DateTime);
                DateTime.TryParse(model.EndTime, out endTime);
                if (string.IsNullOrEmpty(model.SortName))
                {
                    model.SortName        = "CreateTime";
                    model.IsSortOrderDesc = true;
                }

                LanguageParam languageParam = new LanguageParam();
                languageParam.Code            = model.Code;
                languageParam.Desc            = model.Desc;
                languageParam.Type            = model.Type;
                languageParam.Content         = model.Content;
                languageParam.StartTime       = startTime;
                languageParam.EndTime         = endTime;
                languageParam.PageIndex       = model.PageIndex;
                languageParam.PageSize        = model.PageSize;
                languageParam.SortName        = model.SortName;
                languageParam.IsSortOrderDesc = model.IsSortOrderDesc;

                var data = Repository.QueryLanguage(languageParam);
                return(ExcutedResult.SuccessResult(data));
            }
            catch (BusinessException businessException)
            {
                return(ExcutedResult.FailedResult(businessException.ErrorCode,
                                                  GetDescribe(businessException.ErrorCode, EnumLanguageDataType.BusinessResultCode)));
            }
            catch (Exception exception)
            {
                return(ExcutedResult.FailedResult(SysResultCode.ServerException,
                                                  GetDescribe(SysResultCode.ServerException, EnumLanguageDataType.BusinessResultCode)));
            }
        }
Пример #24
0
 /// <summary>
 /// 改
 /// </summary>
 /// <param name="model"></param>
 /// <param name="oldNotice"></param>
 /// <returns></returns>
 public ExcutedResult UpdateNoticeInfo(UpdateNoticeRequestModel model, out Notice oldNotice)
 {
     oldNotice = null;
     try
     {
         Guid guid = Guid.Empty;
         if (model == null || !Guid.TryParse(model.Id, out guid))
         {
             throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误或无效");
         }
         model.UpdateVerify();
         var notice = _noticeRepository.GetById(guid);
         oldNotice = notice;
         if (notice == null)
         {
             throw new BusinessException(BusinessResultCode.DataNotExist, "数据不存在,请刷新!");
         }
         else
         {
             if (!string.IsNullOrEmpty(model.Content) && model.Content != notice.Content)
             {
                 notice.Content = model.Content;
             }
             if (!string.IsNullOrEmpty(model.Title) && model.Title != notice.Title)
             {
                 notice.Title = model.Title;
             }
             if (model.IsShutdownSystem < 2)
             {
                 notice.IsShutdownSystem = model.IsShutdownSystem;
             }
             if (model.IsOnlyOne < 2 && model.IsOnlyOne != notice.IsOnlyOne)
             {
                 notice.IsOnlyOne = model.IsOnlyOne;
             }
             if (model.ExpireTime != default(DateTime))
             {
                 notice.CreateTime = model.ExpireTime;
             }
             _noticeRepository.Update(notice);
             return(ExcutedResult.SuccessResult());
         }
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
     catch (Exception ex)
     {
         return(ExcutedResult.FailedResult(SysResultCode.ServerException, "发生异常,请稍后再试或联系管理员"));
     }
 }
Пример #25
0
        public override void Delete(Guid id, out ExcutedResult result)
        {
            var entity = GetById(id);

            if (entity == null)
            {
                result = ExcutedResult.FailedResult(BusinessResultCode.ArgumentError, "节点不存在");
                return;
            }
            entity.State = (int)EnumState.Deleted;
            Repository.Update(entity);
            result = ExcutedResult.SuccessResult();
        }
Пример #26
0
 public Task <IActionResult> Edit(SysMenu menu)
 {
     return(Task.Factory.StartNew <IActionResult>(() =>
     {
         if (!ModelState.IsValid)
         {
             return Json(ExcutedResult.FailedResult("数据验证失败"));
         }
         var menuRepository = this.GetService <ISysMenuRepository>();
         menuRepository.Edit(menu);
         return Json(ExcutedResult.SuccessResult());
     }));
 }
Пример #27
0
        public async Task <ExcutedResult> SignOut()
        {
            try
            {
                await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

                return(ExcutedResult.SuccessResult());
            }
            catch (BusinessException businessException)
            {
                return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
            }
        }
Пример #28
0
        /// <summary>
        /// 插入新的节点
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ExcutedResult InsertNode(InsertNodeRequestModel model)
        {
            try
            {
                var user = CurrentUser;
                if (model == null)
                {
                    throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误或无效");
                }
                model.Vefity();
                Node node = new Node()
                {
                    Id                = Guid.NewGuid(),
                    ChainCode         = "EOS",
                    Name              = model.Name,
                    HttpAddress       = model.HttpAddress,
                    IsSuper           = model.IsSuper,
                    Address           = model.Address,
                    ErrorCount        = model.ErrorCount,
                    TimeOut           = model.TimeOut,
                    Priority          = model.Priority,
                    QueryAlternative  = model.QueryAlternative,
                    PlayerAlternative = model.PlayerAlternative,
                    ServerAlternative = model.ServerAlternative,
                    Deleter           = string.Empty,
                    CreateTime        = DateTime.UtcNow,
                    DeleteTime        = default(DateTime),
                    State             = (int)EnumState.Normal,
                    DeleteIp          = String.Empty,
                };
                Repository.Add(node);

                OperateLog log = new OperateLog();
                log.Id             = Guid.NewGuid();
                log.ClientIp       = user.ClientIP;
                log.CreateTime     = DateTime.UtcNow;
                log.ManagerAccount = user.Mobile;
                log.ManagerId      = user.Id;
                log.OriginalValue  = String.Empty;
                log.NewValue       = JsonConvert.SerializeObject(node);
                log.Operate        = "Insert";
                log.Function       = "插入新的节点";
                _operateLogRepository.Insert(log);

                return(ExcutedResult.SuccessResult());
            }
            catch (BusinessException businessException)
            {
                return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
            }
        }
Пример #29
0
 public ExcutedResult GetChainList()
 {
     try
     {
         var list = _chainConfigRepository.GetAll();
         var data = list.Select(p =>
                                new { p.ChainCode, p.ChainId, Logo = p.Logo.HasValue ? _filePreUrl + p.Logo.Value : "" });
         return(ExcutedResult.SuccessResult(data));
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
 }
Пример #30
0
        private ExcutedResult <IList <Permission2> > GetPermissionByPubKey(string pubKey)
        {
            var newKey = CryptoHelper.ConvertLegacyPubKey(pubKey);

            var query = _dbContext.ExecuteSqlQuery <Permission2>(
                $"select j.a->>'block_num' as block_num, j.a->>'present' as present, j.a->>'name' as name,j.a->>'owner' as owner, j.a->>'auth_keys' as auth_keys FROM (select to_jsonb(x) as a from \"chain\".\"permission\" as x) as j where j.a @> '{{\"auth_keys\":[{{\"key\":\"{newKey}\"}}]}}'");

            var result = query.GroupBy(k => new { k.name, k.owner },
                                       (k, r) => r.OrderByDescending(p => p.block_num).FirstOrDefault())
                         .Where(p => bool.Parse(p.present))
                         .ToList();

            return(ExcutedResult <IList <Permission2> > .SuccessResult(result));
        }