예제 #1
0
        /// <summary>
        /// 添加功能信息信息
        /// </summary>
        /// <param name="inputDtos">要添加的功能信息DTO信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult AddFunctions(params FunctionInputDto[] inputDtos)
        {
            inputDtos.CheckNotNull("dtos");
            OperationResult result = FunctionRepository.Insert(inputDtos,
                                                               dto =>
            {
                if (dto.Url.IsNullOrWhiteSpace())
                {
                    throw new Exception("自定义功能的URL不能为空");
                }
                if (FunctionRepository.CheckExists(m => m.Name == dto.Name))
                {
                    throw new Exception("名称为“{0}”的功能信息已存在".FormatWith(dto.Name));
                }
                if (dto.Url == null && FunctionRepository.CheckExists(m => m.Area == dto.Area && m.Controller == dto.Controller && m.Action == dto.Action))
                {
                    throw new Exception("区域“{0}”控制器“{1}”方法“{2}”的功能信息已存在".FormatWith(dto.Area, dto.Controller, dto.Action));
                }
            },
                                                               (dto, entity) =>
            {
                entity.IsCustom = true;
                if (entity.Url.IsNullOrEmpty())
                {
                    entity.Url = null;
                }
                return(entity);
            });

            if (result.ResultType == OperationResultType.Success)
            {
                IFunctionHandler handler = ServiceProvider.GetService <IFunctionHandler>();
                handler.RefreshCache();
            }
            return(result);
        }
예제 #2
0
 public TokenFactory(FunctionRepository functionRepository, NameValueProvider nameValueProvider)
     : this(new TokenSeparatorProvider(), nameValueProvider, functionRepository)
 {
 }
        public void TestGreaterThan10()
        {
            var functionRepository = new FunctionRepository();

            Assert.IsTrue(functionRepository.GreaterThan10(11));
        }
 /// <summary>
 /// 检查功能信息信息是否存在
 /// </summary>
 /// <param name="predicate">检查谓语表达式</param>
 /// <param name="id">更新的功能信息编号</param>
 /// <returns>功能信息是否存在</returns>
 public bool CheckFunctionExists(Expression <Func <Function, bool> > predicate, Guid id = new Guid())
 {
     return(FunctionRepository.CheckExists(predicate, id));
 }
예제 #5
0
 public void IsPrimeTestFailureZero()
 {
     Assert.IsFalse(FunctionRepository.IsPrime(0));
 }
예제 #6
0
 public void IsPrimeTestFailureNegativeInteger()
 {
     Assert.IsFalse(FunctionRepository.IsPrime(-2));
 }
예제 #7
0
 public void IsPrimeTestSucceed()
 {
     Assert.IsTrue(FunctionRepository.IsPrime(3));
 }
예제 #8
0
 public void CheckStringValueTestNonNumericString()
 {
     Assert.IsFalse(FunctionRepository.CheckStringValue("meh"));
 }
예제 #9
0
        public void Go()
        {
            IList <ParseError> errors;
            var fragment = new TSql120Parser(false).Parse(new StringReader(_scripts), out errors);

            if (fragment == null)
            {
                return;
            }

            var visitor = new ProcedureVisitor();

            fragment.Accept(visitor);

            using (var procedureRepository = new ProcedureRepository(DacpacPath.Get(_sourceProject)))
                using (var functionRepository = new FunctionRepository(DacpacPath.Get(_sourceProject)))
                {
                    foreach (var procedure in visitor.Procedures)
                    {
                        var browser = new SolutionBrowserForm("test " + procedure.ProcedureReference.Name.BaseIdentifier.Value.UnQuote() + " does something");
                        browser.ShowDialog();

                        var destination = browser.DestinationItem;
                        if (destination == null)
                        {
                            continue;
                        }

                        if (String.IsNullOrEmpty(DacpacPath.Get(_sourceProject)) && !File.Exists(DacpacPath.Get(_sourceProject)))
                        {
                            MessageBox.Show("Cannot find dacpac for project");
                            return;
                        }

                        var parentProjectItem = destination;

                        var name = browser.GetObjectName();

                        var proc = procedureRepository.FirstOrDefault(p => p.Name.EqualsName(procedure.ProcedureReference.Name));
                        if (proc == null)
                        {
                            MessageBox.Show(string.Format("Cannot find stored procedure {0} in project compiled dacpac", procedure.ProcedureReference.Name));
                            return;
                        }

                        var testBuilder = new ProcedureBuilder(procedure.ProcedureReference.Name.BaseIdentifier.Value.UnQuote(), name, proc);
                        var script      = testBuilder.GetScript();

                        CreateNewFile(parentProjectItem, name, script);
                    }

                    foreach (var procedure in visitor.Functions)
                    {
                        var browser = new SolutionBrowserForm("test " + procedure.Name.BaseIdentifier.Value.UnQuote() + " does something");
                        browser.ShowDialog();

                        var destination = browser.DestinationItem;
                        if (destination == null)
                        {
                            continue;
                        }

                        if (String.IsNullOrEmpty(DacpacPath.Get(_sourceProject)) && !File.Exists(DacpacPath.Get(_sourceProject)))
                        {
                            MessageBox.Show("Cannot find dacpac for project");
                            return;
                        }

                        var parentProjectItem = destination;

                        var name = browser.GetObjectName();

                        var proc = functionRepository.FirstOrDefault(p => p.Name.EqualsName(procedure.Name));
                        if (proc == null)
                        {
                            MessageBox.Show(string.Format("Cannot find stored procedure {0} in project compiled dacpac", procedure.Name));
                            return;
                        }

                        var testBuilder = new ProcedureBuilder(procedure.Name.BaseIdentifier.Value.UnQuote(), name, proc);
                        var script      = testBuilder.GetScript();

                        CreateNewFile(parentProjectItem, name, script);
                    }
                }
        }
예제 #10
0
 public SourceCodeTokenizer(FunctionRepository functionRepository, NameValueProvider nameValueProvider)
     : this(new TokenFactory(functionRepository, nameValueProvider), new TokenSeparatorProvider())
 {
 }
예제 #11
0
 /// <summary>
 /// 检查功能信息信息是否存在
 /// </summary>
 /// <param name="predicate">检查谓语表达式</param>
 /// <param name="id">更新的功能信息编号</param>
 /// <returns>功能信息是否存在</returns>
 public Task <bool> CheckFunctionExists(Expression <Func <Function, bool> > predicate, Guid id = default(Guid))
 {
     return(FunctionRepository.CheckExistsAsync(predicate, id));
 }
예제 #12
0
 public void Init()
 {
     _functions = new FunctionRepository();
 }
예제 #13
0
 public TokenFactory(ITokenSeparatorProvider tokenSeparatorProvider, NameValueProvider nameValueProvider, FunctionRepository functionRepository)
 {
     _tokenSeparatorProvider = tokenSeparatorProvider;
     _functionRepository     = functionRepository;
     _nameValueProvider      = nameValueProvider;
 }
예제 #14
0
 public void CheckStringValueTestInvalidInt()
 {
     Assert.IsFalse(FunctionRepository.CheckStringValue("1.3"));
 }
예제 #15
0
 /// <summary>
 /// 检查功能信息信息是否存在
 /// </summary>
 /// <param name="predicate">检查谓语表达式</param>
 /// <param name="id">更新的功能信息编号</param>
 /// <returns>功能信息是否存在</returns>
 public virtual Task <bool> CheckFunctionExists(Expression <Func <TFunction, bool> > predicate, TFunctionKey id = default(TFunctionKey))
 {
     return(FunctionRepository.CheckExistsAsync(predicate, id));
 }
예제 #16
0
 public void CheckStringValueTestWhiteSpace()
 {
     Assert.IsFalse(FunctionRepository.CheckStringValue("   "));
 }
예제 #17
0
 public FunctionService()
 {
     functionRepository = new FunctionRepository();
 }
예제 #18
0
 public void CheckStringValueTestNumberLargerThanInt32()
 {
     Assert.IsFalse(FunctionRepository.CheckStringValue("9000000000000000000000000"));
 }
예제 #19
0
 private ParsingConfiguration()
 {
     FunctionRepository = FunctionRepository.Create();
 }
예제 #20
0
 public void IsPrimeTestFailureNotPrimeCompositePositiveInteger()
 {
     Assert.IsFalse(FunctionRepository.IsPrime(4));
 }
 public FunctionCompilerFactory(FunctionRepository repository)
 {
     _specialCompilers.Add(typeof(If), new IfFunctionCompiler(repository.GetFunction("if")));
     _specialCompilers.Add(typeof(IfError), new IfErrorFunctionCompiler(repository.GetFunction("iferror")));
     _specialCompilers.Add(typeof(IfNa), new IfNaFunctionCompiler(repository.GetFunction("ifna")));
 }
예제 #22
0
 public void IsPrimeTestFailureOne()
 {
     Assert.IsFalse(FunctionRepository.IsPrime(1));
 }
예제 #23
0
 public Lexer(FunctionRepository functionRepository, INameValueProvider nameValueProvider)
     : this(new SourceCodeTokenizer(functionRepository, nameValueProvider), new SyntacticAnalyzer())
 {
 }
예제 #24
0
 public void CheckStringValueTestValidInt()
 {
     Assert.IsTrue(FunctionRepository.CheckStringValue("1"));
 }
예제 #25
0
 // GET api/<controller>
 public IEnumerable <FunctionInfo> Get(int roleId, int branchId)
 {
     return(FunctionRepository.GetByRoleAndBranch(roleId, branchId));
 }
예제 #26
0
        public string Render()
        {
            var    userInfo     = UserContext.GetCurrentUser();
            int    branchId     = UserContext.GetDefaultBranch();
            int    curUserId    = userInfo.UserID;
            var    lstFunctions = userInfo.IsSuperAdmin ? FunctionRepository.GetChild(0) : FunctionRepository.GetByUser(curUserId, branchId, 0);
            string retVal       = "<ul class='nav nav-list'>";

            foreach (var info in lstFunctions)
            {
                info.SetLevel(0);
                retVal += GetMenuItem(info);
            }
            retVal += "</ul>";
            return(retVal);
        }
예제 #27
0
 public void CheckStringValueTestNegativeInt()
 {
     Assert.IsTrue(FunctionRepository.CheckStringValue("-1"));
 }
예제 #28
0
 public FunctionRepositoryTests()
 {
     _target = new FunctionRepository(_dataAccess);
 }
예제 #29
0
        public void Go(){

            IList<ParseError> errors;
            var fragment = new TSql120Parser(false).Parse(new StringReader(_scripts), out errors);
            if (fragment == null)
                return;

            var visitor = new ProcedureVisitor();
            fragment.Accept(visitor);

            using (var procedureRepository = new ProcedureRepository(DacpacPath.Get(_sourceProject)))
            using (var functionRepository = new FunctionRepository(DacpacPath.Get(_sourceProject)))
            {
                foreach (var procedure in visitor.Procedures)
                {
                    var browser = new SolutionBrowserForm("test " + procedure.ProcedureReference.Name.BaseIdentifier.Value.UnQuote() + " does something");
                    browser.ShowDialog();

                    var destination = browser.DestinationItem;
                    if (destination == null)
                        continue;

                    if (String.IsNullOrEmpty(DacpacPath.Get(_sourceProject)) && !File.Exists(DacpacPath.Get(_sourceProject)))
                    {
                        MessageBox.Show("Cannot find dacpac for project");
                        return;
                    }
                    
                    var parentProjectItem = destination;
                        
                    var name = browser.GetObjectName();
                    
                    var proc = procedureRepository.FirstOrDefault(p => p.Name.EqualsName(procedure.ProcedureReference.Name));
                    if (proc == null)
                    {
                        MessageBox.Show(string.Format("Cannot find stored procedure {0} in project compiled dacpac", procedure.ProcedureReference.Name));
                        return;
                    }

                    var testBuilder = new ProcedureBuilder(procedure.ProcedureReference.Name.BaseIdentifier.Value.UnQuote(), name, proc);
                    var script = testBuilder.GetScript();

                    CreateNewFile(parentProjectItem, name , script);
                }

                foreach (var procedure in visitor.Functions)
                {
                    var browser = new SolutionBrowserForm("test " + procedure.Name.BaseIdentifier.Value.UnQuote() + " does something");
                    browser.ShowDialog();

                    var destination = browser.DestinationItem;
                    if (destination == null)
                        continue;

                    if (String.IsNullOrEmpty(DacpacPath.Get(_sourceProject)) && !File.Exists(DacpacPath.Get(_sourceProject)))
                    {
                        MessageBox.Show("Cannot find dacpac for project");
                        return;
                    }

                    var parentProjectItem = destination;

                    var name = browser.GetObjectName();

                    var proc = functionRepository.FirstOrDefault(p => p.Name.EqualsName(procedure.Name));
                    if (proc == null)
                    {
                        MessageBox.Show(string.Format("Cannot find stored procedure {0} in project compiled dacpac", procedure.Name));
                        return;
                    }

                    var testBuilder = new ProcedureBuilder(procedure.Name.BaseIdentifier.Value.UnQuote(), name, proc);
                    var script = testBuilder.GetScript();

                    CreateNewFile(parentProjectItem, name, script);
                }
            }
        }