private void SetModuleTree(Tree tree, Module module, UserSystem userSystems) { HashSet <Tree> childTreeSet = new HashSet <Tree>(); var modules = from m in module.Modules orderby m.ShowOrder select m; foreach (var item in modules) { if (item != module) { Tree childTree = new Tree(); string moduleID = item.ModuleID.ToString(); var userModules = UserModuleRepository.GetQueryable().FirstOrDefault(i => i.Module.ModuleID == new Guid(moduleID) && i.UserSystem.UserSystemID == userSystems.UserSystemID); childTree.id = userModules.UserModuleID.ToString(); childTree.text = "模块:" + item.ModuleName; childTree.@checked = userModules == null ? false : userModules.IsActive; childTree.attributes = "module"; childTreeSet.Add(childTree); if (item.Modules.Count > 0) { SetModuleTree(childTree, item, userSystems); } if (item.Functions.Count > 0) { SetModuleFunTree(childTree, item, userModules); } } } tree.children = childTreeSet.ToArray(); }
private void InitUserModule(UserSystem userSystem) { foreach (var module in userSystem.System.Modules) { var userModules = userSystem.UserModules.Where(um => um.Module.ModuleID == module.ModuleID && um.UserSystem.UserSystemID == userSystem.UserSystemID); if (userModules.Count() == 0) { UserModule um = new UserModule() { UserModuleID = Guid.NewGuid(), UserSystem = userSystem, Module = module, IsActive = userSystem.User.UserName == "Admin" }; userSystem.IsActive = userSystem.User.UserName == "Admin"; SetParentUserModuleIsActiveFalse(um); UserModuleRepository.Add(um); UserModuleRepository.SaveChanges(); } var userModule = userSystem.UserModules.Single(um => um.Module.ModuleID == module.ModuleID && um.UserSystem.UserSystemID == userSystem.UserSystemID); InitUserFunctions(userModule); } }
protected void btnChangePassword_Click(object sender, EventArgs e) { try { UserSystem usrsys = new UserSystem(); User usr = (User)Session["CurrentUser"]; usrsys.ChangePassword(usr.UserName, txtOldPassword.Text, txtNewPassword.Text); lblError.Visible = false; lblSuccess.Visible = true; lblSuccess.Text = "Zapisano."; } catch (System.Data.SqlClient.SqlException) { lblError.Text = "Wystąpił nieoczekiwany błąd. (SQL)"; lblError.Visible = true; } catch (UserException ue) { string ErrorMssg = ""; switch (ue.Type) { case UserException.UserExceptionType.Unknown: ErrorMssg = "Wystąpił nieoczekiwany błąd."; break; case UserException.UserExceptionType.IncorrectPassword: ErrorMssg = "Niepoprawne hasło."; break; } lblError.Text = ErrorMssg; lblError.Visible = true; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(UserSystem.Model.User model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into User("); strSql.Append("Name,Password,AddTime)"); strSql.Append(" values ("); strSql.Append("@Name,@Password,@AddTime)"); strSql.Append(";select LAST_INSERT_ROWID()"); SQLiteParameter[] parameters = { new SQLiteParameter("@Name", DbType.String,70), new SQLiteParameter("@Password", DbType.String,70), new SQLiteParameter("@AddTime", DbType.String,70)}; parameters[0].Value = model.Name; parameters[1].Value = model.Password; parameters[2].Value = model.AddTime; object obj = DbHelperSQLite.GetSingle(strSql.ToString(),parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } }
public void NewOrder(int userId, int productId, int cityId) { IUserSystem iUserSystem = new UserSystem("为什么"); IStorageSystem iStorageSystem = new StorageSystem(); ILogisticsSystem iLogisticsSystem = new LogisticsSystem(); IOrderSystem iOrderSystem = new OrderSystem(); if (!iUserSystem.CheckUser(userId)) { Console.WriteLine("用户检测失败"); } else if (!iStorageSystem.CheckStorage(productId)) { Console.WriteLine("仓储检测失败"); } else if (!iLogisticsSystem.CheckLogistics(productId, cityId)) { Console.WriteLine("物流检测失败"); //不能直接去物流增加一个检测失败的数据记录 //而是通过物流系统的方法去做 } else if (!iOrderSystem.CheckOrder(userId, productId)) { Console.WriteLine("订单检测失败"); } else { iOrderSystem.NewOrder(userId, productId); iLogisticsSystem.NewLogistics(productId, cityId); } }
public void TestInsertOperationWithAttributeTableHana() { var hanaConnection = System.Data.Common.DbProviderFactories.GetFactory("Sap.Data.Hana").CreateConnection(); hanaConnection.ConnectionString = ConfigurationManager.ConnectionStrings["hana"].ConnectionString; hanaConnection.Open(); var trans = hanaConnection.BeginTransaction(); using (var conn = hanaConnection) { IScriptBuilder builder = new ScriptHanaBuilder(); var user = new UserSystem() { Name = "Moisés", Email = "*****@*****.**", LoginName = "mosheh" }; var createTableScript = builder.GetCreateTableCommand <UserSystem>(); builder.Execute(createTableScript, conn); var lastId = conn.InsertReturningId <UserSystem>(user); Assert.AreEqual(1, lastId); trans.Rollback(); builder.Execute("drop table \"IV_MD_SystemUser\"", hanaConnection); } }
}// End of getAll function /// <summary> /// Get all event types /// </summary> /// <param name="event_o"></param> /// <param name="user_log"></param> /// <returns></returns> public IList <EventType> getAllEventTypes(Event event_o, UserSystem user_log) { return(http_service.JSONHttpPettitionList <EventType>( HttpMethod.GET, "eventtype", null)); }// End of getAllEventTypes function
/// <summary> /// 生成查询sql语句 /// </summary> private string GetSelectSql() { int i = 0; StringBuilder sb = new StringBuilder(); sb.Append(UserSystem.BinUserSelectSql("UserName", TB_UserName.Text.Trim(), ref i)); sb.Append(UserSystem.BinUserSelectSql("UserID", this.TB_LoginName.Text.Trim(), ref i)); sb.Append(UserSystem.BinUserSelectSql("stationNameHtml", this.txtUnitName.Value.Trim(), ref i)); sb.Append(UserSystem.BinUserSelectSql("Phone", this.TB_Tel.Text.Trim(), ref i)); sb.Append(UserSystem.BinUserSelectSql("Mobile", this.TB_Mtel.Text.Trim(), ref i)); sb.Append(UserSystem.BinUserSelectSql("MailBox", this.TB_Email.Text.Trim(), ref i)); sb.Append(UserSystem.BinUserSelectSql("SortID", this.TB_WorkCode.Text.Trim(), ref i)); if (sltIsAllow.SelectedValue == "2") { } else { if (i > 0) { sb.Append(" and "); } sb.Append("status = " + sltIsAllow.SelectedValue); } //Response.Write(sb.ToString()); return(sb.ToString()); }
/// <summary> /// Initialize application global variables /// </summary> public static void Init(ISettingRepository setttingRepository) { CurrentFolders folder = new CurrentFolders(setttingRepository); Folders = folder; Folders.Init(); CurrentDevice device = new CurrentDevice(setttingRepository, Folders.DevicesGuid); Device = device; Device.Init(); CurrentUser userSystem = new CurrentUser(setttingRepository, Folders.UsersGuid); UserSystem = userSystem; UserSystem.Init(); CurrentUser user = new CurrentUser(setttingRepository, Folders.UsersGuid); User = user; User.Init(); SettingLog log = new SettingLog(setttingRepository); Log = log; Log.Init(); }
public bool CancelSessionKeys(UserSystem userSystem, AuthorizationStatus oldStatus, DateTime dateBlock, AuthorizationStatus newStatus) { if (!userSystem.IdEntity.HasValue) { throw new ArgumentException($"Parameter {nameof(userSystem.IdEntity)} must be not empty", nameof(userSystem.IdEntity)); } var idParam = new SqlParameter { ParameterName = "@IdEntity", Value = userSystem.IdEntity.Value }; var oldStatusParam = new SqlParameter { ParameterName = "@OldStatus", Value = oldStatus.GetStatusName() }; var finishKeyParam = new SqlParameter { ParameterName = "@FinishSession", Value = dateBlock }; var newStatusParam = new SqlParameter { ParameterName = "@NewStatus", Value = newStatus.GetStatusName() }; ExecuteCommand(SpCancelSessionKey, idParam, oldStatusParam, finishKeyParam, newStatusParam); return(true); }
/// <summary> /// 门面模式通过是单例的 /// 门面模式不能直接新增一个物流或者仓储检测方法,只能通过调用物流系统或者仓储系统的检测方法,这是门面模式的严格界定 /// 用于分层 /// 门面模式就是为了屏蔽上端知道太多细节 /// </summary> /// <param name="userId"></param> /// <param name="productId"></param> public void NewOrder(int userId, int productId) { IUserSystem iUser = new UserSystem(); ILogisticsSystem iLogistics = new LogisticsSystem(); IStorageSystem iStorage = new StorageSystem(); IOrderSystem iOrder = new OrderSystem(); if (!iUser.CheckUser(userId)) { Console.WriteLine("用户检测失败"); } else if (!iStorage.CheckStorage(productId)) { Console.WriteLine("仓储检测失败"); } else if (!iLogistics.CheckLogistics(userId, productId)) { Console.WriteLine("物流检测失败"); } else if (!iOrder.CheckOrder(userId, productId)) { Console.WriteLine("订单检测失败"); } else { iOrder.NewOrder(userId, productId); iLogistics.NewLogistics(userId, productId); } }
public static List <UserSystem> DocFileUser() { List <UserSystem> lus = new List <UserSystem>(); try { StreamReader sr = new StreamReader("Data\\UserFile.txt", Encoding.UTF8); string line = sr.ReadLine(); while (line != null) { string[] arr = line.Split(';'); if (arr.Length == 2) { UserSystem us = new UserSystem(); us.username = arr[0]; us.password = arr[1]; lus.Add(us); } line = sr.ReadLine();// doc dong tiep theo } sr.Close(); } catch (Exception ex) { throw ex; } return(lus); }
public static Customer HaveYouBeenHereBefore() { var currentCustomer = new UserSystem(); Console.Write("Welcome! Have you been here before? (y/n):"); string mainUserInput = Console.ReadLine(); try { switch (mainUserInput) { case "y": return(currentCustomer.OldCustomer()); case "n": return(currentCustomer.AddCustomer()); default: Console.WriteLine("Not a valid option. Try again"); return(HaveYouBeenHereBefore()); } } catch (FormatException) { Console.WriteLine("You have to enter (y/n) Try again"); return(HaveYouBeenHereBefore()); } }
public void GetUserById_Test() { var userId = 1; var expected = "AAA"; var user = new User { UserName = expected, Id = userId }; var userRepositoryMock = new Mock <IRepository <User> >(); userRepositoryMock.Setup(m => m.GetById(userId)).Returns(user).Verifiable(); var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(m => m.UserRepository).Returns(userRepositoryMock.Object); IUserSystem sut = new UserSystem(unitOfWorkMock.Object); //Act var actual = sut.GetUser(userId); //Assert userRepositoryMock.Verify(); Assert.IsNotNull(actual); Assert.AreEqual(expected, actual.UserName); }
}// End of getCompetitorsById function /// <summary> /// Upload the image of the route to the db /// </summary> /// <param name="competition"></param> /// <param name="img"></param> /// <param name="user_log"></param> /// <returns></returns> public Competition ImageToCompetition(Competition competition, Image img, UserSystem user_log) { return(http_service.JSONHttpPettitionObject <Competition>( HttpMethod.PUT, string.Format( "competition/image/{0}", competition.id), JsonConvert.SerializeObject(DataConvert.ImageToByte(img)))); }// End of ImageToCompetition function
}// End of getCategoriesById function /// <summary> /// Get competitions by event /// </summary> /// <param name="event_o"></param> /// <param name="user_log"></param> /// <returns></returns> public IList <Competition> getCompetitionsByEvent(Event event_o, UserSystem user_log) { return(http_service.JSONHttpPettitionList <Competition>( HttpMethod.GET, string.Format( "competition/byevent/?event_id={0}", event_o.id), null)); }// End of getCompetitionsByEvent function
}// End of getByName function /// <summary> /// Get categories by id /// </summary> /// <param name="competition_id"></param> /// <param name="user_log"></param> /// <returns></returns> public IList <Category> getCategoriesById(int competition_id, UserSystem user_log) { return(http_service.JSONHttpPettitionList <Category>( HttpMethod.GET, string.Format( "competition/categories/?competition_id={0}", competition_id), null)); }// End of getCategoriesById function
public IActionResult DeleteCommentByUseridMidex([FromBody] Comment comment) { if (UserSystem.DeleteOneComment(comment)) { return(Json(new { code = 0, msg = "删除成功" })); } return(Json(new { code = -1, msg = "删除失败" })); }
/// <summary> /// 加载所有的User信息 /// </summary> private void LoadAllUserData() { if (Session["UserMessageCache"] == null) { Session["UserMessageCache"] = UserSystem.GetUserMessage(ProjectCode); //ataGrid1.DataBind(); } }
private void loadUser() { oUser = (UserSystem)Session["User"]; if (oUser == null) { Response.Redirect("../../index.aspx"); } }
public FormLogView() { InitializeComponent(); Icon = UserSystem.GetFormWindowIcon(); net_simplify_client = UserClient.Net_simplify_client; }
}// End of getCompetitionsById function /// <summary> /// Image to event /// Sends the image to the server and shit /// </summary> /// <param name="event_o"></param> /// <param name="img"></param> /// <param name="user_log"></param> /// <returns></returns> public Event ImageToEvent(Event event_o, Image img, UserSystem user_log) { return(http_service.JSONHttpPettitionObject <Event>( HttpMethod.PUT, string.Format( "event/image/{0}", event_o.id), JsonConvert.SerializeObject(DataConvert.ImageToByte(img)))); }// End of ImageToEvent function
/// <summary> /// 对用户进行排序 /// </summary> private void SortUserData() { LoadAllUserData(); string sortsql = BLL.GridSort.GetSortSQL(ViewState); Session["UserMessageCache"] = UserSystem.SortUserMessage((DataView)Session["UserMessageCache"], sortsql); BindDataGrid(); }
}// End of deleteAuthentication function /// <summary> /// Get all /// </summary> /// <param name="user_log"></param> /// <returns></returns> public IList <Authentication> getAll(UserSystem user_log) { return(http_service.JSONHttpPettitionList <Authentication>( HttpMethod.GET, GetType().Name.ToLower().Replace( TWords.SERVICE, TWords.EMPTY), null)); }// End of getAll function
/// <summary> /// 初始化 /// </summary> private void FormInitialization(IntegrationFileClient IntegratedFile, string[] files, string factory, string group, string id) { Icon = UserSystem.GetFormWindowIcon(); // 设置窗口ICON Files = files; // 设置文件名队列 Factory = factory; // 第一大类 Group = group; // 第二大类 Id = id; // 第三大类 IntegrationFile = IntegratedFile; }
}// End of getByRol function /// <summary> /// Get by user name /// </summary> /// <param name="user_name"></param> /// <param name="user_log"></param> /// <returns></returns> public UserSystem getByUserId(int user_id, UserSystem user_log) { return(http_service.JSONHttpPettitionObject <UserSystem>( HttpMethod.GET, string.Format( "usersystem/getbyuser/?user_id={0}", user_id), null)); }// End of getByUserName function
}// End of getCompetitionNum function /// <summary> /// Get registers by competition /// </summary> /// <param name="competition"></param> /// <param name="user_log"></param> /// <returns></returns> public IList <Register> getRegistersByCompetition(Competition competition, UserSystem user_log) { return(http_service.JSONHttpPettitionList <Register>( HttpMethod.GET, string.Format( "register/bycompetition/?competition_id={0}", competition.id), null)); }// End of getRegistersByCompetition function
public FormMainWindow() { InitializeComponent(); Icon = UserSystem.GetFormWindowIcon(); // 初始化头像管理器 UserClient.PortraitManager = new UserPortrait(Application.StartupPath + @"\Portrait\" + UserClient.UserAccount.UserName); }
}// End of getByUser function /// <summary> /// Get competition number /// </summary> /// <param name="competition"></param> /// <param name="user_log"></param> /// <returns></returns> public int getCompetitorNum(int competition_id, UserSystem user_log) { return(http_service.JSONHttpPettitionObject <int>( HttpMethod.GET, string.Format( "register/competitornum/{0}", competition_id), null)); }// End of getCompetitionNum function
public FormDownloading(int customer, Action <OperateResult <string> > action) { InitializeComponent(); Icon = UserSystem.GetFormWindowIcon(); net_cmd = customer; DealWithResult = action; DoubleBuffered = true; }
/// <summary> /// 实例化一个选择服务器账户的窗口,该窗口可以根据工厂属性或是角色属性来筛选 /// </summary> /// <param name="condition">筛选条件</param> /// <param name="minSelected">选择账户数量的下限</param> /// <param name="multiSelected">选择账户数量的上限</param> /// <param name="selected">已选择的账户名</param> public FormAccountSelect(string condition = null, int minSelected = 0, int maxSelected = int.MaxValue, List <string> selected = null) { InitializeComponent(); Icon = UserSystem.GetFormWindowIcon(); m_selected = selected; m_condition = condition; m_MaxSelected = maxSelected; m_MinSelected = minSelected; }
/// <summary> /// Provides an interface to call functions in other modules. /// </summary> /// <param name="Modulename">The module name according to the bot.</param> /// <param name="serverid">The server id of a server the module is active on.</param> /// <param name="FullFunctionname">The full function name.</param> /// <param name="preserveUserPriveleges">The User object to compare priveleges to.</param> /// <param name="parameters">The parameters.</param> /// <returns>The return object or null.</returns> public object CrossModuleCall(string Modulename, int serverid, string FullFunctionname, UserSystem.User preserveUserPriveleges, params object[] parameters) { IModule[] imods = (IModule[])RequestVariable( Request.ModuleList, serverid); MethodInfo mi = null; object o = null; for ( int i = 0; i < imods.Length; i++ ) if ( imods[i].IsLoaded ) if ( imods[i].ModuleConfig.FullName.Equals( Modulename ) ) { mi = imods[i].ModuleProxy.ModuleInstance.GetType().GetMethod( FullFunctionname, BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Instance ); if ( mi != null ) { o = imods[i].ModuleProxy.ModuleInstance; break; } } if ( mi == null ) return null; PrivelegeContainer p = preserveUserPriveleges.UserAttributes != null ? preserveUserPriveleges.UserAttributes.Privegeles : null; bool continueWithCall = true; if ( p == null || !p.HasPrivelege( Priveleges.SuperUser ) ) { //Check method permissions, can we call it? object[] privreq = mi.GetCustomAttributes( false ); for ( int j = 0; j < privreq.Length; j++ ) { if ( continueWithCall && privreq[j].GetType().Equals( typeof( PrivelegeRequiredAttribute ) ) ) { PrivelegeRequiredAttribute pra = (PrivelegeRequiredAttribute)privreq[j]; continueWithCall = p != null ? p.HasPrivelege( pra.Required ) : ( (ulong)pra.Required == 0 ); } if ( continueWithCall && privreq[j].GetType().Equals( typeof( UserLevelRequiredAttribute ) ) ) { UserLevelRequiredAttribute ura = (UserLevelRequiredAttribute)privreq[j]; continueWithCall = p != null ? p.NumericalLevel >= ura.Required : ( ura.Required == 0 ); } if ( !continueWithCall ) break; } } if ( !continueWithCall ) return null; o = mi.Invoke( o, parameters ); return o; }
public IronPython([Import("Commands")] Dictionary<string, ICommand> commands, [Import("UserSystem")] UserSystem userSystem) { this.commands = commands; this.userSystem = userSystem; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(UserSystem.Model.User model) { return dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(UserSystem.Model.User model) { return dal.Add(model); }
public AuthenticateUser([Import("UserSystem")] UserSystem userSystem) { this.userSystem = userSystem; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(UserSystem.Model.User model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update User set "); strSql.Append("Name=@Name,"); strSql.Append("Password=@Password "); strSql.Append(" where ID=@ID"); SQLiteParameter[] parameters = { new SQLiteParameter("@Name", DbType.String,70), new SQLiteParameter("@Password", DbType.String,70), new SQLiteParameter("@ID", DbType.Int32,8)}; parameters[0].Value = model.Name; parameters[1].Value = model.Password; parameters[2].Value = model.ID; int rows=DbHelperSQLite.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } }
public UserComponent(TinyMessenger.ITinyMessengerHub hub, UserSystem userSystem) : base(hub) { this.userSystem = userSystem; }
public Set([Import("UserSystem")] UserSystem userSystem) { this.userSystem = userSystem; }
public ListAuthenticatedUsers([Import("UserSystem")] UserSystem userSystem) { this.userSystem = userSystem; }
public AddUser([Import("UserSystem")] UserSystem userSystem) { this.userSystem = userSystem; }