public AttachmentController(CommonContext commonContext, RedisCache cache, IOptions <AppSettings> appSettings, AccountContext accountCtx, FileService _fileService) : base(commonContext, cache, appSettings) { _accountCtx = accountCtx; fileService = _fileService; _appSettings = appSettings.Value; }
public CitationsController(CommonContext commonContext, RedisCache redisCache, IServiceProvider serviceProvider, IOptions <AppSettings> appSettings, CommonAccountService commonAccountSvc, CitationService citationSvc, FileService fileSvc) : base(commonContext, redisCache, serviceProvider, appSettings) { _commonAccountSvc = commonAccountSvc; _citationSvc = citationSvc; _fileSvc = fileSvc; }
public async Task <IActionResult> Create(PartitionViewModel model) { if (ModelState.IsValid) { var nameAlreadyExists = CommonContext.Partitions.Any(x => x.Name.ToLower() == model.Name.ToLower()); if (nameAlreadyExists) { // duplicate partition name ModelState.AddModelError(string.Empty, "Name already exsits."); return(View(model)); } var partition = new Partition(); partition.Name = model.Name; partition.ConnectionString = Cryptography.Encrypt(model.ConnectionString); partition.CreateUserId = User.GetLoggedInUserId().Value; partition.UpdateUserId = partition.CreateUserId = User.GetLoggedInUserId().Value; //put dude in the database using (var tx = CommonContext.Database.BeginTransaction()) { CommonContext.Partitions.Add(partition); await CommonContext.SaveChangesAsync(); tx.Commit(); } return(RedirectToAction("Index")); } return(View(model)); }
public OrganizationDirectorySteps(TestConfiguration config, CommonContext commonContext, KeyManager keyManager, OrgClientContext orgClientContext) { _config = config; _commonContext = commonContext; _keyManager = keyManager; _orgClientContext = orgClientContext; }
public TicketWorkFlowService(RedisCache cache, FileService _fileService, IHostingEnvironment environment, CommonContext commonCtx, IOptions <AppSettings> appSettings) { this._fileService = _fileService; _env = environment; _commonCtx = commonCtx; _appSettings = appSettings.Value; }
public CitizensController(CommonContext commonContext, IServiceProvider serviceProvider, RedisCache redisCache, IOptions <AppSettings> appSettings, AccountContext accountCtx) : base(commonContext, serviceProvider, redisCache, appSettings) { _commonContext = commonContext; _appSettings = appSettings.Value; _accountCtx = accountCtx; }
public AccountActionFilterImpl(CommonContext commonContext, AccountContext accountContext, RedisCache cache, UserService userSvc, CommonAccountService commonAccountSvc, IHostingEnvironment env) { _cache = cache; _userSvc = userSvc; _commonAccountSvc = commonAccountSvc; _env = env; }
public OrganizationServiceSteps( CommonContext commonContext, OrgClientContext orgClientContext) { _orgClientContext = orgClientContext; _commonContext = commonContext; }
public async Task <IActionResult> ForgetPassword(ForgetPassword model) { if (ModelState.IsValid) { CommonUser user = await _commonUserSvc.CheckUser(model.Email); if (user != null) { string token = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); var callbackUrl = Url.Action("ResetPassword", "User", new { code = token }); using (var tx = CommonContext.Database.BeginTransaction()) { user.Token = token; user.TokenUtc = DateTime.UtcNow; CommonContext.Users.Update(user); await CommonContext.SaveChangesAsync(); tx.Commit(); } _logger.Error($"Sending Email email:{model.Email} callback:{callbackUrl}"); bool result = await _mailSvc.SendPasswordResetEmail(model.Email, callbackUrl); _logger.Error($"Email Sent:"); } ViewBag.SucessMessage = "Please check your email for a link to reset your password"; return(View()); } return(View(model)); }
public CitationReceiptController(CommonContext commonContext, RedisCache redisCache, IServiceProvider serviceProvider, IOptions <AppSettings> appSettings, AccountContext accountContext, AccountDbContextFactory factoryContext) : base(commonContext, redisCache, serviceProvider, appSettings) { _accountCtx = accountContext; _factoryCtx = factoryContext; _commonContext = commonContext; }
public DirectoryDeviceSteps(CommonContext commonContext, OrgClientContext orgClient, DirectoryClientContext directoryClientContext, AppiumContext appiumContext) { _commonContext = commonContext; _directoryClientContext = directoryClientContext; _appiumContext = appiumContext; _orgClientContext = orgClient; }
public CitationService(CommonContext commonCtx, RedisCache cache, AccountContext accountContext, GeoCodeService geoCodeSvc) { _commonCtx = commonCtx; _cache = cache; _geoCodeService = geoCodeSvc; _accountCtx = accountContext; }
public void SelectAttachModified() { Logger.Log.Error("### SelectAttachModified #############################################"); t_Account account = null; using (var context = new CommonContext()) { account = (from row in context.Account select row).Take(1).ToList().Single(); account.Cash += 1; account.Gold += 1; } // attach 이후 변경이 되어야 업데이트가 가능하다. using (var context = new CommonContext()) { context.Account.Attach(account); account.Cash += 1; account.Gold += 1; context.SaveChanges(); } using (var context = new CommonContext()) { context.Entry(account).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } Logger.Log.Debug("##"); }
public async Task <IActionResult> Edit(CityModel model) { if (ModelState.IsValid) { var cityExists = await CommonContext.Cities.Where(x => x.Name.ToLower() == model.Name.ToLower() && x.Id != model.Id).AnyAsync(); if (cityExists) { ModelState.AddModelError(nameof(model.Name), "This name already exists."); return(View(model)); } var city = await CommonContext.Cities.SingleAsync(m => m.Id == model.Id); city.County = model.County; city.Latitude = model.Latitude; city.Longitude = model.Longitude; city.Name = model.Name; city.State = model.State; city.StateCode = model.StateCode; city.TimeZone = model.TimeZone; city.Type = model.Type; city.UpdateUserId = User.GetLoggedInUserId().Value; CommonContext.Cities.Update(city); await CommonContext.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }
public WarningQuizService(RedisCache cache, IHostingEnvironment environment, CommonContext commonCtx, IOptions <AppSettings> appSettings, CitationService citationSvc) { _env = environment; _commonCtx = commonCtx; _appSettings = appSettings.Value; _citationSvc = citationSvc; }
// [ValidateAntiForgeryToken] public ActionResult Create(IFormCollection collection) { var authorId = int.Parse(collection["AuthorId"]); //var photo = Request.Files[0].InputStream.FileName; //var photo = GetImageFromRequest(); if (authorId != 0) { using (var db = new CommonContext()) { var post = new Post { Author = db.users.Find(authorId), createdDate = DateTime.Now, LikeCount = 0, Text = collection["Text"], ImageURL = collection["ImageURL"] }; db.posts.Add(post); db.SaveChanges(); } } return(Details(authorId)); }
public AccountsController(CommonContext commonContext, RedisCache cache, CommonAccountService commonAccountService, IOptions <AppSettings> appSettings, AccountContext accountCtx, IHostingEnvironment env) : base(commonContext, cache, appSettings) { _accountCtx = accountCtx; _env = env; _commonAccountSvc = commonAccountService; }
protected virtual bool AuthorizeCore(RequestContext requestContext) { var authenticated = requestContext.HttpContext.User.Identity.IsAuthenticated; if (authenticated && RequiredAdministrator) { using (CommonContext db = new CommonContext()) { User user = db.Users.Include("Roles.PermissionItems").FirstOrDefault(c => c.UserName == requestContext.HttpContext.User.Identity.Name); if (user == null) { return(false); } else { if (user.IsAdministrator.HasValue && user.IsAdministrator.Value) { return(true); } else { return(false); } } } } else { return(authenticated); } }
/// <summary> /// 检查应用接入的数据完整性 /// 1)检查timestamp 与系统时间是否相差在合理时间内,如10分钟。 /// 2)将appSecret、timestamp、nonce三个参数进行字典序排序 /// 3)将三个参数字符串拼接成一个字符串进行SHA1加密 /// 4)加密后的字符串可与signature对比,若匹配则标识该次请求来源于某应用端,请求是合法的。 /// </summary> /// <param name="signature">加密签名内容</param> /// <param name="timestamp">时间戳</param> /// <param name="nonce">随机字符串</param> /// <param name="appid">应用接入Id</param> /// <returns></returns> public CheckResult ValidateSignature(string signature, string timestamp, string nonce, string appid) { CheckResult result = new CheckResult { Errmsg = "数据完整性检查不通过" }; #region 校验签名参数的来源是否正确 #region 加密后的字符串可与signature对比 string[] arrTmp = { appid, timestamp, nonce }; Array.Sort(arrTmp); string tmpStr = string.Join("", arrTmp); // tmpStr = EncryptHelper.HashString(tmpStr + ConstHelper.UnlockingKey, "MD5"); tmpStr = CommonContext.MD5Encrupt(tmpStr + ConstHelper.UnlockingKey).ToLower(); #endregion if (tmpStr == signature && ValidateUtil.IsNumber(timestamp)) { DateTime dtTime = DateTimeHelper.StampToDateTime(timestamp); double minutes = DateTime.Now.Subtract(dtTime).TotalMinutes; if (minutes > _timspanExpiredMinutes) { result.Errmsg = "签名时间戳失效"; result.Success = false; } else { result.Errmsg = "检验成功"; result.Success = true; } #endregion } return(result); }
public BaseController(CommonContext commonContext, IServiceProvider serviceProvider, RedisCache cache, IOptions <AppSettings> appSettings) { CommonContext = commonContext; _cache = cache; _serviceProvider = serviceProvider; AppSettings = appSettings.Value; }
/// <summary> /// 生产一个数据库上下文 /// </summary> /// <param name="handleType"></param> /// <returns></returns> internal CommonContext Manufacture(HandleType handleType, Type handleClass) { ManufactureCache MCModel = CacheList.FindLast(p => p.HandleClass == handleClass); if (handleType == HandleType.读 && MCModel != null && MCModel.UseWriteTime != null && (DateTime.Now - ((DateTime)MCModel.UseWriteTime)).TotalSeconds <= SyncDelayTime) { //读取的时候检测如果距离上一次对该表写入的时间间隔不超过设置的延迟(秒)则继续用上一次写的数据库上下文进行读取数据 return(new CommonContext(MCModel.Context.ConnectionString, MCModel.Context.Service)); } else { ManufactureDeploy MDModel; if (handleType == HandleType.读) { //读数据库 MDModel = Extract(ServiceType.只读); } else { //写数据库 MDModel = Extract(ServiceType.读写); } //抽取数据库实例 var context = new CommonContext(MDModel.ConnectionString, MDModel.ServiceTypeEnum, handleClass); context.SaveChangesEvent += Context_SaveChangesEvent; return(context); } }
public AttachmentController(CommonContext commonContext, IServiceProvider serviceProvider, RedisCache redisCache, IOptions <AppSettings> appSettings, AccountContext accountCtx, CommonUserService commonUserSvc, FileService fileService) : base(commonContext, serviceProvider, redisCache, appSettings) { _commonUserSvc = commonUserSvc; _accountCtx = accountCtx; _fileService = fileService; _appSettings = appSettings.Value; }
public CommonController(CommonContext commonContext, RedisCache cache, IOptions <AppSettings> appSettings, CommonAccountService commonAccountSvc, CommonUserService commonUserSvc, AccountContext accountCtx, MailService mailSvc) : base(commonContext, cache, appSettings) { _accountCtx = accountCtx; _commonAccountSvc = commonAccountSvc; _commonUserSvc = commonUserSvc; _mailSvc = mailSvc; }
public void LogSystemError(SystemErrorLog Log) { using (CommonContext con = new CommonContext()) { con.SystemErrorLog.Add(Log); con.SaveChanges(); } }
public Response <User> Delete(string nombre) { var userToDelete = CommonContext.GetInstance().Users.Where(u => u.Email.Equals(nombre)).FirstOrDefault(); CommonContext.GetInstance().Users.Remove(userToDelete); return(new Response <User> { IsSuccess = true, Answer = null, Message = "Deleted of user success" }); }
public TicketController(CommonContext commonContext, IServiceProvider serviceProvider, RedisCache redisCache, IOptions <AppSettings> appSettings, CommonAccountService commonAccountSvc, FileService fileService, IDataProtectionProvider dataProtector, StripeService stripeSvc, CitationService citationSvc) : base(commonContext, serviceProvider, redisCache, appSettings) { _commonAccountSvc = commonAccountSvc; _dataProtector = dataProtector.CreateProtector(GetType().FullName); _fileService = fileService; _stripeSvc = stripeSvc; _citationSvc = citationSvc; }
public DirectoryServiceAuthSteps( CommonContext commonContext, DirectoryClientContext directoryClientContext, DirectoryServiceClientContext directoryServiceClientContext) { _commonContext = commonContext; _directoryClientContext = directoryClientContext; _directoryServiceClientContext = directoryServiceClientContext; }
public UsersController(CommonContext commonContext, RedisCache cache, IOptions <AppSettings> appSettings, CommonAccountService commonAccountSvc, CommonUserService commonUserSvc, AccountContext accountCtx, PushNotification PushSvc) : base(commonContext, cache, appSettings) { _accountCtx = accountCtx; _commonAccountSvc = commonAccountSvc; _commonUserSvc = commonUserSvc; _PushSvc = PushSvc; }
public void Register(CommonContext commonContext, int logIndex) { logicContext = new LogicContext(); logicContext.Register(commonContext, logIndex); workerThread = new Thread(new ThreadStart(logicProcessorThread)); workerThread.Name = "StrategyLogicThread"; workerThread.Start(); }
public UnitofWork(ArchContext context, CommonContext cContext) { Database.SetInitializer <ArchContext>(null); if (context == null) { throw new ArgumentException("context is null"); } _context = context; _cContext = cContext; }
public void OnlySelect() { Logger.Log.Error("### OnlySelect #############################################"); using (var context = new CommonContext()) { var accounts = (from row in context.Account orderby row.Acctidx descending select row).Skip(0).ToList(); Logger.Log.Debug("accounts count = " + accounts.Count()); } }
public ShortTermLoanDefinition(BrowserContext browserContext, CommonContext commonContext) { _browserContext = browserContext; _commonContext = commonContext; _shortTermLoanAmountPage = new ShortTermLoanAmountPage(_browserContext); _assertShortTermLoan = new AssertShortTermLoan(_browserContext); _cookieBannerComponent = new CookieBannerComponent(_browserContext); _shortTermLoanActions = new ShortTermLoanActions(_browserContext); _commonActions = new CommonActions(_browserContext); }
public void Test3() { Logger.Log.Error("### Test3 #############################################"); using (var context = new CommonContext()) { var account1 = (from row in context.Account select row).Take(1).ToList().Single(); var account2 = (from row in context.Account where row.Acctidx != account1.Acctidx select row).Take(1).ToList().Single(); account1.Cash += 1; account1.Gold += 1; account2.Cash += 1; account2.Gold += 1; Logger.Log.Error("#####"); using (var scope = new TransactionScope(TransactionScopeOption.Required/*, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted }*/)) { context.SaveChanges(); scope.Complete(); } Logger.Log.Error("#####"); } }
public CommonStepDefinitions(ReviewInfo reviewInfo, CommonContext contextContext) : base(reviewInfo, contextContext) { }
public void Tes6() { Logger.Log.Error("### Test6 #############################################"); //// define our transaction scope //var scope = new TransactionScope( // // a new transaction will always be created // TransactionScopeOption.RequiresNew, // // we will allow volatile data to be read during transaction // new TransactionOptions() { // IsolationLevel = IsolationLevel.ReadUncommitted // } //); using (var scope = new TransactionScope(/*TransactionScopeOption.Suppress, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted }*/)) using (var context1 = new CommonContext()) using (var context2 = new CommonContext()) { var account1 = (from row in context1.Account select row).Take(1).ToList().Single(); var account2 = (from row in context2.Account where row.Acctidx != account1.Acctidx select row).Take(1).ToList().Single(); account1.Cash += 1; account1.Gold += 1; Logger.Log.Error("#####"); account2.Cash += 1; account2.Gold += 1; context1.SaveChanges(); context2.SaveChanges(); Logger.Log.Error("#####"); scope.Complete(); Logger.Log.Error("#####"); } }
public void UserProcedureMethod3() { Logger.Log.Error("### UserProcedureMethod3 #############################################"); //Started transaction using (var context = new CommonContext()) { var query = String.Format("call uspJoinAfter({0})", 0); var list = context.Database.SqlQuery<t_Account>(query); Logger.Log.Debug("ExecuteSqlCommand : result = " + "0"); } }
public void UserProcedureMethod2() { Logger.Log.Error("### UserProcedureMethod2 #############################################"); int accountId = 0; string accountName = ""; using (var context = new CommonContext()) { accountId = (from row in context.Account select row).Max(x => x.Acctidx) + 2; accountName = String.Format("test.{0}", accountId); Logger.Log.Debug("accountId = " + accountId + ", accountName = " + accountName); t_Account account = new t_Account() { Acctidx = accountId, Name = accountName, PlayerIdx = 1, DeviceIdx = 1, SuccessiveLoginCount = 1, Gold = 100, Cash = 100, FreeCash = 100, EnchantStone = 100, GoldenArrow = 100, Honor = 100, Level = 1, Exp = 0, Language = 0, Location = 0, UsePush = 0, UseProfile = 0, UsePushArrow = 0, InventorySlotSize = 0 }; context.Account.Add(account); context.SaveChanges(); } var parameters = new List<MySqlParameter> { new MySqlParameter("@account_id", (long)accountId), new MySqlParameter("@retval", MySqlDbType.Int32) { Direction = ParameterDirection.Output } }; int retval = 0; using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["_common_context"].ConnectionString)) { connection.Open(); using (var command = new MySqlCommand("t_uspJoinAfter", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddRange((Array)parameters.ToArray()); command.ExecuteNonQuery(); retval = (int)command.Parameters["@retval"].Value; } connection.Close(); Logger.Log.Debug(" : " + retval); } }
public void UserProcedureMethod1() { Logger.Log.Error("### UserProcedureMethod1 #############################################"); int accountId = 0; string accountName = ""; using (var context = new CommonContext()) { accountId = (from row in context.Account select row).Max(x => x.Acctidx) + 2; accountName = String.Format("test.{0}", accountId); Logger.Log.Debug("accountId = " + accountId + ", accountName = " + accountName); t_Account account = new t_Account() { Acctidx = accountId, Name = accountName, PlayerIdx = 1, DeviceIdx = 1, SuccessiveLoginCount = 1, Gold = 100, Cash = 100, FreeCash = 100, EnchantStone = 100, GoldenArrow = 100, Honor = 100, Level = 1, Exp = 0, Language = 0, Location = 0, UsePush = 0, UseProfile = 0, UsePushArrow = 0, InventorySlotSize = 0 }; context.Account.Add(account); context.SaveChanges(); } //Started transaction using (var context = new CommonContext()) { var query = String.Format("call uspJoinAfter({0})", accountId); var result = context.Database.ExecuteSqlCommand(query); Logger.Log.Debug("ExecuteSqlCommand : result = " + result); } }