public SaveOutput Action(SaveInput input) { var normalizedResult = BusinessRules.InsertValidation.Action(new ValidationInput(input.Amount, input.Iteratins, input.RunTime, input.PaperFormat, input.Speed)); if (normalizedResult.NormalizedTime == null) { return(new SaveOutput(false, normalizedResult.FormatedResult)); } using (var database = DataBaseFactory.CreateDatabase()) { database.JobEntities.Add(new JobEntity { // ReSharper disable PossibleInvalidOperationException Amount = input.Amount.Value, BigProblem = input.BigProblem, Problem = input.Problem, EffectiveTime = input.RunTime, Iterations = input.Iteratins.Value, Length = input.PaperFormat.Lenght.Value, NormaizedTime = normalizedResult.NormalizedTime.Value, Speed = input.Speed.Value, StartTime = input.StartTime, Width = input.PaperFormat.Width.Value, // ReSharper restore PossibleInvalidOperationException IterationTime = input.IterationTime, SetupTime = input.SetupTime }); database.SaveChanges(); } return(new SaveOutput(true, string.Empty)); }
public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); if (CurrentEnvironment.IsDevelopment()) { services.AddCors(); } services.AddOptions(Configuration); DataBaseFactory dataBaseFactory = services.AddDatabase(Configuration); // TODO make internal def services.AddDbOptions(dataBaseFactory); services.AddCaches(dataBaseFactory); services.AddCachePolicy(); services.AddIdentity(dataBaseFactory); AddAuthenticationExtensions.AddAuthentication(services); AddAuthorizationExtensions.AddAuthorization(services); services.AddManagers(); services.AddPresenters(); services.AddAdmin(); services.AddMemoryCache(); services.AddImagesServices(); services.AddCiphers(dataBaseFactory); services.AddJobs(); services.AddSingleton <CaptchaService>(); services.AddSanitizer(); services.AddTransient <IEmailSenderService, EmailSenderService>(); services.AddMvcCore(options => { // Add filters here }) .AddApiExplorer() .AddAuthorization() .AddJsonFormatters(options => { options.ContractResolver = SunJsonContractResolver.Instance; options.DateTimeZoneHandling = DateTimeZoneHandling.Utc; }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
private ComponentDao() { if (db == null) { db = DataBaseFactory.Create(EquipmentConst.DataBaseName); } }
public static OperationResult <User> LogInUser(string userName, string password) { User user = null; try { if (!FormatChecker.CheckUserNameFormat(userName)) { return(new OperationResult <User>("用户名格式错误,创建失败!", false, null)); } if (!FormatChecker.CheckPasswordFormat(password)) { return(new OperationResult <User>("密码格式错误,创建失败!", false, null)); } if (!DataBaseFactory.DriveDataBase().LogInUser(userName, password)) { return(new OperationResult <User>("用户不存在或密码错误,登录失败!", false, null)); } user = DataBaseFactory.DriveDataBase().GetUser(userName); } catch (Exception e) { return(new OperationResult <User>("创建失败!" + e.Message, false, null)); } return(new OperationResult <User>("用户登录成功!", true, user)); }
private RoleDao() { if (db == null) { db = DataBaseFactory.Create("Equipment"); } }
public object Action(object input) { using (var database = DataBaseFactory.CreateDatabase()) { foreach (var group in database.SetupEntities.AsNoTracking().GroupBy(e => e.SetupType)) { var time = group.Average(e => e.Value); switch (group.Key) { case SetupType.Setup: Properties.Settings.Default.SetupTime = (int)time; break; case SetupType.Iteration: Properties.Settings.Default.IterationTime = (int)time; break; } } } Properties.Settings.Default.Save(); return(null); }
private GuaranteeDao() { if (db == null) { db = DataBaseFactory.Create(EquipmentConst.DataBaseName); } }
public static void AddIdentity(this IServiceCollection services, DataBaseFactory dataBaseFactory) { services.AddIdentity <User, Role>( options => { options.Password.RequireDigit = false; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; options.Password.RequiredUniqueChars = 2; options.Password.RequiredLength = 6; options.User.RequireUniqueEmail = true; const string engChars = "abcdefghijklmnopqrstuvwxyz"; const string rusChars = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"; const string numbers = "0123456789"; const string other = " -"; options.User.AllowedUserNameCharacters = engChars + engChars.ToUpper() + rusChars + rusChars.ToUpper() + numbers + other; }) .AddLinqToDBStores <int>(dataBaseFactory) .AddUserManager <SunUserManager>() .AddRoleManager <SunRoleManager>() .AddDefaultTokenProviders(); }
public GameDataBase() { #if DataReset DataRemove(); #endif binform = new BinaryFormatter(); DataBaseFactory factory = new DataBaseFactory(); if (!LoadFile()) { dataCls = new DataContainerClass(); userDB.Initialize(); levelDB.Initialize(); tropyDB.Initialize(); //stageDB.Initialize(); //achivDB.Initialize(); } for (ObjectClassEnumType type = ObjectClassEnumType.None + 1; type < ObjectClassEnumType.End; type++) { ObjectDatas[(int)type] = factory.CreateDB(type); ObjectDatas[(int)type].Initialize(dataCls.GetInstallBinData(type)); } factory = null; }
private OrganizationDao() { if (db == null) { db = DataBaseFactory.Create("Equipment"); } }
public static OperationResult <JudgeResult> JudgeExercise(Exercise exercise, ExerciseResult exerciseResult, User user) { JudgeResult judgeResult = null; try { judgeResult = ExerciseGeneratorFactory.DriveGenerator().JudgeExercise(exercise, exerciseResult); JudgeInfo judgeInfo = DataBaseFactory.DriveDataBase().GetJudgeInfo(user.UserID); if (judgeInfo == null) { return(new OperationResult <JudgeResult>("批改失败!", true, null)); } judgeInfo.QuestionNum += judgeResult.TotalNum; judgeInfo.QuestionErrorNum += judgeResult.ErrorNum; judgeInfo.LastestCompleteTime = DateTime.Now; if (!JudgeInfoLogic.UpdateJudgeInfo(judgeInfo, user)) { return(new OperationResult <JudgeResult>("更改批改信息失败!", true, null)); } } catch (Exception e) { return(new OperationResult <JudgeResult>("批改失败!" + e.Message, true, null)); } return(new OperationResult <JudgeResult>("批改成功!", true, judgeResult)); }
/// <summary> /// 添加用户 /// </summary> /// <param name="model"></param> /// <returns></returns> public AjaxMsgResult Add(string userId) { result.Success = false; try { Dictionary <string, object> dic = new Dictionary <string, object>(); StringBuilder sql = new StringBuilder(); sql.Append(@" INSERT INTO UC_UserExtend(Id,QQ,OpenId,RealName,AddRess,UpdateTime) VALUES (?Id,?QQ,?OpenId,?RealName,?AddRess,?UpdateTime)"); dic.Add("Id", userId); dic.Add("QQ", null); dic.Add("OpenId", null); dic.Add("RealName", null); dic.Add("AddRess", null); dic.Add("UpdateTime", DateTime.Now); int count = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteNonQuery(sql.ToString(), dic); if (count == 1) { result.Success = true; } else { result.Msg = "添加失败,请检查数据合法性!"; } } catch (Exception e) { result.Msg = e.ToString(); } return(result); }
public static OperationResult CreateUser(string userName, string password) { try { if (!FormatChecker.CheckUserNameFormat(userName)) { return(new OperationResult("用户名格式错误,创建失败!", false)); } if (!FormatChecker.CheckPasswordFormat(password)) { return(new OperationResult("密码格式错误,创建失败!", false)); } if (!DataBaseFactory.DriveDataBase().CheckUserName(userName)) { return(new OperationResult("用户名不唯一,创建失败!", false)); } if (!DataBaseFactory.DriveDataBase().CreateUser(userName, password)) { return(new OperationResult("创建失败!", false)); } } catch (Exception e) { return(new OperationResult("创建失败! " + e.Message, false)); } return(new OperationResult("用户创建成功!", true)); }
/// <summary> /// 用户个数 /// </summary> /// <returns></returns> public string UserCount() { result.Success = false; string sql = " SELECT COUNT(*) FROM UC_User "; return(DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteSingle(sql)); }
public DbCommand GetDbCommand() { DbCommand command; command = DataBaseFactory.DbCommandFactory(this.connectInfo); return(command); }
protected override async void OnInitialized() { InitializeComponent(); PathDataBase = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ProcessoSeletivo.db3"); DataBaseFactory.CreateDataBase(PathDataBase); RegisterDependency(); await NavigationService.NavigateAsync("NavigationPage/HomeView"); }
protected void Application_Start() { BaseDao.db = DataBaseFactory.Create("Equipment"); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
protected void Application_Start() { DataBaseFactory.Initialize(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public AjaxMsgResult Query(List <string> id) { var dic = new Dictionary <String, Object>() { { "Id", string.Join(",", id.ToArray()) } }; result.Source = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteReader <UC_TeamApp>("select * from UC_TeamApp where id in(?Id)", dic); return(result); }
public AjaxMsgResult Query(UC_Team tm, int count) { var dic = new Dictionary <String, Object>() { { "count", count } }; result.Source = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteReader <UC_Team>("select * from UC_Team order by createtime limit ?count", dic); return(result); }
public void AddTeacher(string connStr) { var DB = new DataBaseFactory().GetDB(connStr); Teacher teacher = new Teacher() { tname = "TEST" + new Random().Next(100, 999).ToString() }; DB.Insertable(teacher).ExecuteCommand(); }
/// <summary> /// 获取该应用的信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public AjaxMsgResult Get(String id) { var dic = new Dictionary <String, Object>() { { "id", id } }; result.Source = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteReader <UC_AppInfo>("select * from UC_AppInfo where id=?id", dic)[0]; return(result); }
/// <summary> /// 查询应用 /// </summary> /// <param name="model"></param> /// <param name="orderType"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="recordCount"></param> /// <returns></returns> public AjaxMsgResult Query(UC_AppInfo model, int count) { Dictionary <string, object> dic = new Dictionary <string, object>() { { "count", count } }; List <string> fileds = new List <string>(); result.Source = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteReader <UC_AppInfo>("select * from UC_AppInfo order by createtime limit ?count", dic); return(result); }
public void sqlServerDataBase_ConnectWithFactoryMethod_ReturnQueryResult(string ip, string port, string nameDataBase, string serverInstance, string username, string password, string engine, string query) { DataBaseFactory factory = new DataBaseFactory(); InterfaceDatabase dataBase = factory.createInstanceDataBase(ip, port, nameDataBase, serverInstance, username, password, engine); dataBase.openConnection(); string result = dataBase.executeQuery(query); dataBase.closeConnection(); Console.Write(result); }
public static OperationResult DeleteUser(User user) { try { DataBaseFactory.DriveDataBase().DeleteUser(user.UserID); } catch (Exception e) { return(new OperationResult("删除失败!" + e.Message, false)); } return(new OperationResult("用户删除成功!", true)); }
/// <summary> /// 删除用户 /// </summary> /// <param name="model"></param> /// <param name="operationUser"></param> /// <returns></returns> public AjaxMsgResult Del(List <string> ids, UC_User operationUser) { result.Success = false; try { if (ids.Count == 0) { result.State = AjaxMsgResult.StateEnum.VerifyFailed; result.Msg = "未检测到要修改的id!"; return(result); } Dictionary <string, object> dic = new Dictionary <string, object>(); StringBuilder sql = new StringBuilder(); sql.Append(@"UPDATE UC_User SET IsValid=1 WHERE 1=1 "); for (int i = 0; i < ids.Count; i++) { if (ids.Count > 0) { if (i > 0) { sql.AppendFormat(@" OR Id=?Id{0} ", i); if (i == ids.Count - 1) { sql.Append(@" ) "); } } else { sql.AppendFormat(@" AND ( Id=?Id{0} ", i); } } else { sql.AppendFormat(@" AND Id=?Id{0} ", i); } dic.Add("Id" + i, ids[i]); } int count = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteNonQuery(sql.ToString(), dic); if (count == ids.Count) { result.Success = true; } else { result.Msg = "删除失败,请检查数据合法性!"; } } catch (Exception e) { result.Msg = e.ToString(); } return(result); }
public static OperationResult UpdateJudgeInfo(JudgeInfo judgeInfo, User user) { try { DataBaseFactory.DriveDataBase().UpdateJudgeInfo(judgeInfo, user.UserID); } catch (Exception e) { return(new OperationResult("修改失败!" + e.Message, false)); } return(new OperationResult("修改成功!", true)); }
public object Action(AddSetupInput input) { using (var database = DataBaseFactory.CreateDatabase()) { foreach (var item in input.Items.Where(i => i != null)) { AddSetupEntity(database, item); } database.SaveChanges(); } return(null); }
/// <summary> /// 判断是否重复 /// </summary> /// <param name="loginName">登录名</param> /// <param name="mobile">手机号码</param> /// <returns></returns> public bool IsRepeat(string loginName = null, string mobile = null, string email = null) { bool isRepeat = true; try { if (loginName == null && mobile == null && email == null) { result.State = AjaxMsgResult.StateEnum.VerifyFailed; return(isRepeat); } Dictionary <string, object> dic = new Dictionary <string, object>(); StringBuilder sql = new StringBuilder(); sql.Append(@" select * from UC_User WHERE 1=1 "); if (loginName != null) { sql.Append(@" AND LoginName=?LoginName "); dic.Add("LoginName", loginName); } if (mobile != null) { sql.Append(@" AND Mobile=?Mobile "); dic.Add("Mobile", mobile); } if (email != null) { sql.Append(@" AND Email=?Email "); dic.Add("Email", email); } // List<UC_User> data = null; IList <UC_User> data = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteReader <UC_User>(sql.ToString(), true, dic); if (data != null) { if (data.Count > 0) { isRepeat = true; } } else { isRepeat = false; } } catch (Exception e) { result.Msg = e.ToString(); } return(isRepeat); }
//IDataBase con = new PostgreSQL(); #region 添加用户 /// <summary> /// 添加用户 /// </summary> /// <param name="model"></param> /// <returns></returns> public AjaxMsgResult Add(UC_User model, string CreateUser = null) { result.Success = false; try { if (IsRepeat(model.LoginName, model.Mobile, model.Email) == true) { result.State = AjaxMsgResult.StateEnum.IsExist; result.Msg = "添加失败,存在相同的数据!"; return(result); } if (string.IsNullOrWhiteSpace(model.LoginName) && string.IsNullOrWhiteSpace(model.Mobile) && string.IsNullOrWhiteSpace(model.Email)) { result.State = AjaxMsgResult.StateEnum.VerifyFailed; result.Msg = "添加失败,注册用户名为空!"; return(result); } Dictionary <string, object> dic = new Dictionary <string, object>(); StringBuilder sql = new StringBuilder(); sql.Append(@" INSERT INTO UC_User(Id,UserName,LoginName,PassWord,IsValid,Status,Mobile,CreateUser,CreateTime) VALUES (?Id,?UserName,?LoginName,?PassWord,?IsValid,?Status,?Mobile,?CreateUser,?CreateTime)"); string id = NewData.NewId("YH"); dic.Add("Id", id); dic.Add("UserName", model.UserName); dic.Add("LoginName", model.LoginName); dic.Add("PassWord", Com.SHA512Encrypt(model.PassWord)); dic.Add("IsValid", model.IsValid); dic.Add("Status", model.Status); dic.Add("Mobile", model.Mobile); dic.Add("CreateUser", CreateUser == null? id:model.CreateUser); dic.Add("CreateTime", DateTime.Now); int count = DataBaseFactory.GetDataBase(DataBaseType.main).ExecuteNonQuery(sql.ToString(), dic); if (count == 1) { if (userExtendService.Add(id).Success == true) { result = Verify(model); } } else { result.Msg = "添加失败,请检查数据合法性!"; } } catch (Exception e) { result.Msg = e.ToString(); } return(result); }