public async Task <ActionResult> Create(CodeView view) { CodeRepository codeRepo; try { using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger)) { codeRepo = new CodeRepository(settings, logger, dbc); if (ModelState.IsValid) { await codeRepo.Add(view.Code); return(RedirectToAction("Index", "Code")); } view.CodeCategories = CodeCategory.GetList(); return(View("Create", view)); } } catch (Exception ex) { throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace); } }
public async Task <ActionResult> Create() { ProjectView view = new ProjectView() { Project = new Project(), ProjectTypes = new List <Code>(), StatusTypes = new List <Code>() }; CodeRepository codeRepo; try { using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger)) { codeRepo = new CodeRepository(settings, logger, dbc); view.Project = new Project() { Active = true }; view.ProjectTypes = (await codeRepo.FindAllByCategory(CodeCategory.PROJECT_TYPE)).ToList(); view.StatusTypes = (await codeRepo.FindAllByCategory(CodeCategory.STATUS)).ToList(); } } catch (Exception ex) { throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace); } return(View("Create", view)); }
public QuestionController(MerlinReadContext readContext, CodeRepository codes, QuestionService service, QuestionRules rules) { this.readContext = readContext; this.codes = codes; this.service = service; this.rules = rules; }
public async Task <ActionResult> Create(ProjectView view) { ProjectRepository projectRepo; CodeRepository codeRepo; try { using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger)) { codeRepo = new CodeRepository(settings, logger, dbc); if (ModelState.IsValid) { projectRepo = new ProjectRepository(settings, logger, dbc); await projectRepo.Add(view.Project); return(RedirectToAction("Index", "Project")); } // Only get here if couldn't add project and all tasks view.ProjectTypes = (await codeRepo.FindAllByCategory(CodeCategory.PROJECT_TYPE)).ToList(); view.StatusTypes = (await codeRepo.FindAllByCategory(CodeCategory.STATUS)).ToList(); return(View("Create", view)); } } catch (Exception ex) { throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace); } }
public CodeController(CodeRules rules, CodeRepository repos, MerlinReadContext readContext, MerlinReadStore readStore) { this.rules = rules; this.repos = repos; this.readContext = readContext; this.readStore = readStore; }
public async Task <ActionResult> Edit(int id) { ProjectRepository projectRepo; CodeRepository codeRepo; ProjectView view = new ProjectView() { Project = new Project() { Active = true }, ProjectTypes = new List <Code>(), StatusTypes = new List <Code>() }; try { using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger)) { projectRepo = new ProjectRepository(settings, logger, dbc); codeRepo = new CodeRepository(settings, logger, dbc); view.Project = await projectRepo.FindByPKView(new PrimaryKey() { Key = id, IsIdentity = true }); view.ProjectTypes = (await codeRepo.FindAllByCategory(CodeCategory.PROJECT_TYPE)).ToList(); view.StatusTypes = (await codeRepo.FindAllByCategory(CodeCategory.STATUS)).ToList(); } } catch (Exception ex) { throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace); } return(View("Edit", view)); }
public async Task <ActionResult> Edit(int id) { CodeRepository codeRepo; CodeView view = new CodeView() { Code = new Code() { Active = true }, CodeCategories = new List <CodeCategory>() }; try { using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger)) { codeRepo = new CodeRepository(settings, logger, dbc); view.Code = await codeRepo.FindByPKView(new PrimaryKey() { Key = id, IsIdentity = true }); view.CodeCategories = CodeCategory.GetList(); } } catch (Exception ex) { throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace); } return(View("Edit", view)); }
protected override void Arrange() { base.Arrange(); base.Act(); CodeRepository.Stub(x => x.GetLocation()).Return(Location); ReadAndExcludeCodes.Stub(x => x.Read(Location)).Return(UnpresentableCodes); DtoPresentator.Stub(x => x.Present(UnpresentableCodes)).Return(Expected); }
public BaseService(HappContext dbContext) { emrRepository = new EMRRepository(dbContext); codeRepository = new CodeRepository(dbContext); queriseRepository = new QueriseRepository(dbContext); sessionRepository = new SessionRepository(dbContext); doctorRepository = new DoctorRepository(dbContext); patientRepository = new PatientRepository(dbContext); }
public void Execute(IJobExecutionContext context) { using (var testRepository = new TestRepository()) { using (var codeRepository = new CodeRepository()) { using (var resultRepository = new ResultRepository()) { ICompiler compiler = new CSharpCompiler(); var processBuilder = new ProcessBuilder(); var runer = new Runer(); List<Code> codes = codeRepository.ExtractAll().ToList(); codes.ForEach(item => { if (!compiler.TryCompile(item.Text, @"F://test.exe")) { resultRepository.Add(new TestDatabase.Entities.Result(item.Id, "compilation error")); } else { var tests = testRepository.GetTestsByTaskId(item.TaskId).ToList(); for (var i = 0; i < tests.Count; i++) { var proc = processBuilder.Create(@"F://test.exe"); string output; try { if (!runer.TryGetResult(proc, tests[i].Input, out output)) { resultRepository.Add(new TestDatabase.Entities.Result(item.Id, "out of time on test " + (i + 1).ToString())); return; } } catch (Exception e) { resultRepository.Add(new TestDatabase.Entities.Result(item.Id, "out of memory on test " + (i + 1).ToString())); return; } if (output == tests[i].Output) continue; resultRepository.Add(new TestDatabase.Entities.Result(item.Id, "wrong answer on test " + (i + 1).ToString())); return; } resultRepository.Add(new TestDatabase.Entities.Result(item.Id, "success")); } }); } } } }
public void TestInitialize() { transactionScope = new TransactionScope(); dbContext = new HappContext(); repository = new CodeRepository(dbContext); code = new Code() { Cprikey = priKey, Cpubkey = pubKey, SessionKey = sessionKey }; }
public IEnumerable <string> LoadTables(long userId) { IEnumerable <string> toRet; if (!CacheHelper.Get(Module + "_TableNames", out toRet)) { var codeRepository = new CodeRepository(); toRet = codeRepository.LoadTables(); if (toRet != null) { CacheHelper.Add(Module + "_TableNames", toRet, BlCommon.DefaultTimeOut()); } } return(toRet); }
public OutbreakService(MerlinWriteContext writeContext, ISequenceGenerator sequenceGenerator, OutbreakRepository outbreakEventsRepository, CodeRepository codeRepository, IUsernameProvider usernameProvider, SurveyService surveyService, EmailService emailService) { this.writeContext = writeContext; this.sequenceGenerator = sequenceGenerator; this.outbreakEventsRepository = outbreakEventsRepository; this.codeRepository = codeRepository; this.usernameProvider = usernameProvider; this.surveyService = surveyService; this.emailService = emailService; }
public AuthenticateService( IConfiguration configuration, UserRepository userRepository, CryptoHelper cryptoHelper, ITokenService tokenService, TokenRepository tokenRepository, CodeRepository codeRepository, ICodeService codeService ) { _userRepository = userRepository; _cryptoHelper = cryptoHelper; _tokenService = tokenService; _tokenRepository = tokenRepository; _codeRepository = codeRepository; _codeService = codeService; _secretKey = configuration["AppSettings:Secret"]; }
public async Task <ActionResult> Index() { CodeRepository codeRepo; IPager <Code> pager = null; try { using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger)) { codeRepo = new CodeRepository(settings, logger, dbc); pager = await codeRepo.FindAllView(new Pager <Code>() { PageNbr = 0, PageSize = 20 }); } } catch (Exception ex) { logger.LogError(ex.Message); } return(View(pager)); }
public async Task <ActionResult> IpAddressEdit(int ipid) { var model = await serverRepo.GetIpAddressAsync(ipid); var PartyList = new List <SelectListItem>(); var party = await partyRepo.GetPartyListAsync(); var party2 = new SelectList(party, "PartyID", "name"); PartyList.AddRange(party2); ViewBag.PartyList = PartyList; var BeLongList = new List <SelectListItem>(); var belong = await CodeRepository.CreateInstance().GetCodesListAsync(ECodesTypeId.IpAddressBeLong); var belong2 = new SelectList(belong, "Code", "Text"); BeLongList.AddRange(belong2); ViewBag.BeLongList = BeLongList; return(View(model)); }
public static Dictionary <string, string> LoadTable(long userId, string tableName, string toRetColumn = "Value1", string relCode = "") { var user = BlUser.LoadSingle(userId); toRetColumn = (toRetColumn == "Value1" || CheckEmpty.String(toRetColumn) == "") ? user.LanguageId == 1 ? "Value1" : "Value2" : toRetColumn; List <Code> results; if (!CacheHelper.Get(Module + "_Table_" + tableName + "_" + relCode, out results)) { var codeRepository = new CodeRepository(); var predicate = PredicateBuilder.True <Code>(); predicate = predicate.And(p => p.TableName == tableName); predicate = predicate.And(p => p.Status); if (relCode != "") { predicate = predicate.And(p => p.RelCode == relCode); } results = codeRepository.LoadSearch(predicate); if (results != null) { CacheHelper.Add(Module + "_Table_" + tableName + "_" + relCode, results, BlCommon.DefaultTimeOut()); } } Dictionary <string, string> toRet = null; if (results != null) { toRet = results.ToDictionary(k => k.CodeName, v => v.GetType().GetProperty(toRetColumn).GetValue(v, null).ToString()); } return(toRet); }
public static Code LoadSingle(long userId, string tableName, string codeName, bool notFromCache = false) { var toRet = new Code { TableName = tableName, CodeName = codeName }; if (!CacheHelper.Get(Module + "_" + toRet.TableName + "_" + toRet.CodeName, out toRet) || notFromCache) { var codeRepository = new CodeRepository(); toRet = codeRepository.LoadSingle(tableName, codeName); if (toRet != null) { if (tableName == "_System" && codeName == "DefaultTimeOut") { CacheHelper.Add(Module + "_" + toRet.TableName + "_" + toRet.CodeName, toRet, Convert.ToInt32(toRet.Value1)); } else { CacheHelper.Add(Module + "_" + toRet.TableName + "_" + toRet.CodeName, toRet, BlCommon.DefaultTimeOut()); } } } return(toRet); }
public async Task <IActionResult> Get(int id) { CodeRepository codeRepo; Code code; try { using (DBConnection dbc = new DBConnection(settings.Database.ConnectionString, logger)) { codeRepo = new CodeRepository(settings, logger, dbc); code = await codeRepo.FindByPKView(new PrimaryKey() { Key = id, IsIdentity = true }); } } catch (Exception ex) { throw (Exception)Activator.CreateInstance(ex.GetType(), ex.Message + ex.StackTrace); } return(View("Details", code)); }
public SurveyAnswerRules(MerlinReadContext readContext, CodeRepository codeRepository) { this.readContext = readContext; this.codeRepository = codeRepository; }
public CodeService(SqlConnection sqlconnection) { _repository = new CodeRepository(sqlconnection); }
public LayoutRepository(MerlinReadContext readContext, CodeRepository codeRepos) { this.readContext = readContext; this.codeRepos = codeRepos; }
public CodeService(CodeRepository codeRepository, CodeConfiguration codeConfiguration) { _codeRepository = codeRepository; _codeConfiguration = codeConfiguration; }
public CodeBll(ApiDbContext context) { repo = new CodeRepository(context); }