/// <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); }
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)); }
public void IsPrimeTestFailureZero() { Assert.IsFalse(FunctionRepository.IsPrime(0)); }
public void IsPrimeTestFailureNegativeInteger() { Assert.IsFalse(FunctionRepository.IsPrime(-2)); }
public void IsPrimeTestSucceed() { Assert.IsTrue(FunctionRepository.IsPrime(3)); }
public void CheckStringValueTestNonNumericString() { Assert.IsFalse(FunctionRepository.CheckStringValue("meh")); }
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); } } }
public SourceCodeTokenizer(FunctionRepository functionRepository, NameValueProvider nameValueProvider) : this(new TokenFactory(functionRepository, nameValueProvider), new TokenSeparatorProvider()) { }
/// <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)); }
public void Init() { _functions = new FunctionRepository(); }
public TokenFactory(ITokenSeparatorProvider tokenSeparatorProvider, NameValueProvider nameValueProvider, FunctionRepository functionRepository) { _tokenSeparatorProvider = tokenSeparatorProvider; _functionRepository = functionRepository; _nameValueProvider = nameValueProvider; }
public void CheckStringValueTestInvalidInt() { Assert.IsFalse(FunctionRepository.CheckStringValue("1.3")); }
/// <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)); }
public void CheckStringValueTestWhiteSpace() { Assert.IsFalse(FunctionRepository.CheckStringValue(" ")); }
public FunctionService() { functionRepository = new FunctionRepository(); }
public void CheckStringValueTestNumberLargerThanInt32() { Assert.IsFalse(FunctionRepository.CheckStringValue("9000000000000000000000000")); }
private ParsingConfiguration() { FunctionRepository = FunctionRepository.Create(); }
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"))); }
public void IsPrimeTestFailureOne() { Assert.IsFalse(FunctionRepository.IsPrime(1)); }
public Lexer(FunctionRepository functionRepository, INameValueProvider nameValueProvider) : this(new SourceCodeTokenizer(functionRepository, nameValueProvider), new SyntacticAnalyzer()) { }
public void CheckStringValueTestValidInt() { Assert.IsTrue(FunctionRepository.CheckStringValue("1")); }
// GET api/<controller> public IEnumerable <FunctionInfo> Get(int roleId, int branchId) { return(FunctionRepository.GetByRoleAndBranch(roleId, branchId)); }
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); }
public void CheckStringValueTestNegativeInt() { Assert.IsTrue(FunctionRepository.CheckStringValue("-1")); }
public FunctionRepositoryTests() { _target = new FunctionRepository(_dataAccess); }
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); } } }