Ejemplo n.º 1
0
        public ActionResult Get(Guid?id, string appSystemCode, string resourceCode, string functionCode)
        {
            if (!id.HasValue)
            {
                AppSystemState appSystem;
                if (!AcDomain.AppSystemSet.TryGetAppSystem(appSystemCode, out appSystem))
                {
                    throw new ValidationException("意外的应用系统码" + appSystemCode);
                }
                CatalogState resource;
                if (!AcDomain.CatalogSet.TryGetCatalog(AcDomain.AppSystemSet.SelfAppSystem.Code + "." + resourceCode, out resource))
                {
                    throw new ValidationException("意外的资源码" + resourceCode);
                }
                FunctionState function;
                if (!AcDomain.FunctionSet.TryGetFunction(resource, functionCode, out function))
                {
                    throw new ValidationException(string.Format("非法的操作:{0}.{1}.{2}", appSystemCode, resourceCode, functionCode));
                }
                id = function.Id;
            }
            OperationHelp help = GetRequiredService <IRepository <OperationHelp> >().GetByKey(id.Value);

            if (help == null)
            {
                help = new OperationHelp()
                {
                    Id      = id.Value,
                    Content = "没有帮助"
                };
            }

            return(this.JsonResult(help));
        }
Ejemplo n.º 2
0
        public ActionResult Get(Guid? id, string appSystemCode, string resourceCode, string functionCode)
        {
            if (!id.HasValue)
            {
                AppSystemState appSystem;
                if (!AcDomain.AppSystemSet.TryGetAppSystem(appSystemCode, out appSystem))
                {
                    throw new ValidationException("意外的应用系统码" + appSystemCode);
                }
                CatalogState resource;
                if (!AcDomain.CatalogSet.TryGetCatalog(AcDomain.AppSystemSet.SelfAppSystem.Code +"." +resourceCode, out resource))
                {
                    throw new ValidationException("意外的资源码" + resourceCode);
                }
                FunctionState function;
                if (!AcDomain.FunctionSet.TryGetFunction(resource, functionCode, out function))
                {
                    throw new ValidationException(string.Format("非法的操作:{0}.{1}.{2}", appSystemCode, resourceCode, functionCode));
                }
                id = function.Id;
            }
            OperationHelp help = GetRequiredService<IRepository<OperationHelp>>().GetByKey(id.Value);
            if (help == null)
            {
                help = new OperationHelp()
                {
                    Id = id.Value,
                    Content = "没有帮助"
                };
            }

            return this.JsonResult(help);
        }
Ejemplo n.º 3
0
        public override void Handle(SaveHelpCommand command)
        {
            var operationHelpRepository = _acDomain.RetrieveRequiredService <IRepository <OperationHelp> >();
            var functionRepository      = _acDomain.RetrieveRequiredService <IRepository <Function> >();

            if (command.FunctionId == Guid.Empty)
            {
                throw new ValidationException("EmptyFunctionId");
            }
            FunctionState operation;

            if (!_acDomain.FunctionSet.TryGetFunction(command.FunctionId, out operation))
            {
                throw new ValidationException("没有Id为" + command.FunctionId + "的操作");
            }
            var  entity = operationHelpRepository.GetByKey(command.FunctionId);
            bool isNew  = false;

            if (entity == null)
            {
                isNew  = true;
                entity = new OperationHelp
                {
                    Id = command.FunctionId
                };
            }
            entity.Content   = command.Content;
            entity.IsEnabled = command.IsEnabled.HasValue ? command.IsEnabled.Value : 1;
            if (isNew)
            {
                operationHelpRepository.Add(entity);
            }
            else
            {
                operationHelpRepository.Update(entity);
            }
            operationHelpRepository.Context.Commit();
        }
Ejemplo n.º 4
0
        public ViewResultBase Helpline(Guid?id, string isInner, string appSystemCode, string resourceCode, string functionCode)
        {
            if (!id.HasValue)
            {
                AppSystemState appSystem;
                if (!AcDomain.AppSystemSet.TryGetAppSystem(appSystemCode, out appSystem))
                {
                    throw new ValidationException("意外的应用系统码" + appSystemCode);
                }
                CatalogState resource;
                if (!AcDomain.CatalogSet.TryGetCatalog(AcDomain.AppSystemSet.SelfAppSystem.Code + "." + resourceCode, out resource))
                {
                    throw new ValidationException("意外的资源码" + resourceCode);
                }
                FunctionState function;
                if (!AcDomain.FunctionSet.TryGetFunction(resource, functionCode, out function))
                {
                    throw new ValidationException(string.Format("非法的操作:{0}.{1}.{2}", appSystemCode, resourceCode, functionCode));
                }
                id = function.Id;
            }
            OperationHelp help = GetRequiredService <IRepository <OperationHelp, Guid> >().GetByKey(id.Value);

            if (help == null)
            {
                help = new OperationHelp(id.Value)
                {
                    Content = "没有帮助"
                };
            }
            if (!string.IsNullOrEmpty(isInner))
            {
                return(PartialView("Partials/Helpline", help));
            }

            return(View(help));
        }