public void SetUser(string login,
			string password,
			string firstName,
			string lastName,
			string email,
			string phone,
			int role,
			GroupModel[] groups,
			SoapLibraryPage[] pages,
			out string message)
		{
			message = string.Empty;
			var client = GetAdminClient();
			if (client != null)
			{
				try
				{
					var sessionKey = client.getSessionKey(Login, Password);
					if (!string.IsNullOrEmpty(sessionKey))
						client.setUser(sessionKey, login, password, firstName, lastName, email, phone, groups, pages, role);
					else
						message = "Couldn't complete operation.\nLogin or password are not correct.";
				}
				catch (Exception ex)
				{
					message = string.Format("Couldn't complete operation.\n{0}.", ex.Message);
				}
			}
			else
				message = "Couldn't complete operation.\nServer is unavailable.";
		}
Exemplo n.º 2
0
		public FormEditPage(UserModel[] users, GroupModel[] groups)
		{
			InitializeComponent();
			_users.AddRange(users);
			gridControlUsers.DataSource = _users;

			_groups.AddRange(groups);
			gridControlGroups.DataSource = _groups;

			Text = "Edit Page";
		}
		public void SetPage(string id, UserModel[] users, GroupModel[] groups, out string message)
		{
			message = string.Empty;
			var client = GetAdminClient();
			if (client != null)
			{
				try
				{
					var sessionKey = client.getSessionKey(Login, Password);
					if (!string.IsNullOrEmpty(sessionKey))
						client.setPage(sessionKey, id, users, groups);
					else
						message = "Couldn't complete operation.\nLogin or password are not correct.";
				}
				catch (Exception ex)
				{
					message = string.Format("Couldn't complete operation.\n{0}.", ex.Message);
				}
			}
			else
				message = "Couldn't complete operation.\nServer is unavailable.";
		}
Exemplo n.º 4
0
 /// <remarks/>
 public void setPageAsync(string sessionKey, string id, UserModel[] assignedUsers, GroupModel[] assignedGroups, object userState) {
     if ((this.setPageOperationCompleted == null)) {
         this.setPageOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsetPageOperationCompleted);
     }
     this.InvokeAsync("setPage", new object[] {
                 sessionKey,
                 id,
                 assignedUsers,
                 assignedGroups}, this.setPageOperationCompleted, userState);
 }
Exemplo n.º 5
0
 /// <remarks/>
 public void setPageAsync(string sessionKey, string id, UserModel[] assignedUsers, GroupModel[] assignedGroups) {
     this.setPageAsync(sessionKey, id, assignedUsers, assignedGroups, null);
 }
Exemplo n.º 6
0
 public void setPage(string sessionKey, string id, UserModel[] assignedUsers, GroupModel[] assignedGroups) {
     this.Invoke("setPage", new object[] {
                 sessionKey,
                 id,
                 assignedUsers,
                 assignedGroups});
 }
Exemplo n.º 7
0
 /// <remarks/>
 public void setUserAsync(string sessionKey, string login, string password, string firstName, string lastName, string email, string phone, GroupModel[] assignedGroups, SoapLibraryPage[] assignedPages, int role, object userState) {
     if ((this.setUserOperationCompleted == null)) {
         this.setUserOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsetUserOperationCompleted);
     }
     this.InvokeAsync("setUser", new object[] {
                 sessionKey,
                 login,
                 password,
                 firstName,
                 lastName,
                 email,
                 phone,
                 assignedGroups,
                 assignedPages,
                 role}, this.setUserOperationCompleted, userState);
 }
Exemplo n.º 8
0
 /// <remarks/>
 public void setUserAsync(string sessionKey, string login, string password, string firstName, string lastName, string email, string phone, GroupModel[] assignedGroups, SoapLibraryPage[] assignedPages, int role) {
     this.setUserAsync(sessionKey, login, password, firstName, lastName, email, phone, assignedGroups, assignedPages, role, null);
 }
Exemplo n.º 9
0
 public void setUser(string sessionKey, string login, string password, string firstName, string lastName, string email, string phone, GroupModel[] assignedGroups, SoapLibraryPage[] assignedPages, int role) {
     this.Invoke("setUser", new object[] {
                 sessionKey,
                 login,
                 password,
                 firstName,
                 lastName,
                 email,
                 phone,
                 assignedGroups,
                 assignedPages,
                 role});
 }
Exemplo n.º 10
0
		public FormEditUser(bool newUser, bool complexPassword, string[] existedUsers, GroupModel[] groups, SoapLibrary[] libraries)
		{
			InitializeComponent();

			_newUser = newUser;
			_complexPassword = complexPassword;
			_existedUsers.AddRange(existedUsers);

			_groups.AddRange(groups);
			gridControlGroups.DataSource = _groups;

			_libraries.Clear();
			_libraries.AddRange(libraries);
			_pages.Clear();
			_pages.AddRange(libraries.SelectMany(x => x.pages));

			gridViewLibraries.MasterRowEmpty += OnLibraryChildListIsEmpty;
			gridViewLibraries.MasterRowGetRelationCount += OnGetLibraryRelationCount;
			gridViewLibraries.MasterRowGetRelationName += OnGetLibrariesRelationName;
			gridViewLibraries.MasterRowGetChildList += OnGetLibraryChildList;
			gridControlLibraries.DataSource = _libraries;

			textEditLogin.Enter += FormMain.Instance.Editor_Enter;
			textEditLogin.MouseUp += FormMain.Instance.Editor_MouseUp;
			textEditLogin.MouseDown += FormMain.Instance.Editor_MouseDown;
			textEditFirstName.Enter += FormMain.Instance.Editor_Enter;
			textEditFirstName.MouseUp += FormMain.Instance.Editor_MouseUp;
			textEditFirstName.MouseDown += FormMain.Instance.Editor_MouseDown;
			textEditLastName.Enter += FormMain.Instance.Editor_Enter;
			textEditLastName.MouseUp += FormMain.Instance.Editor_MouseUp;
			textEditLastName.MouseDown += FormMain.Instance.Editor_MouseDown;
			textEditPhone.Enter += FormMain.Instance.Editor_Enter;
			textEditPhone.MouseUp += FormMain.Instance.Editor_MouseUp;
			textEditPhone.MouseDown += FormMain.Instance.Editor_MouseDown;
			textEditEmail.Enter += FormMain.Instance.Editor_Enter;
			textEditEmail.MouseUp += FormMain.Instance.Editor_MouseUp;
			textEditEmail.MouseDown += FormMain.Instance.Editor_MouseDown;
			textEditEmailConfirm.Enter += FormMain.Instance.Editor_Enter;
			textEditEmailConfirm.MouseUp += FormMain.Instance.Editor_MouseUp;
			textEditEmailConfirm.MouseDown += FormMain.Instance.Editor_MouseDown;
			buttonEditPassword.Enter += FormMain.Instance.Editor_Enter;
			buttonEditPassword.MouseUp += FormMain.Instance.Editor_MouseUp;
			buttonEditPassword.MouseDown += FormMain.Instance.Editor_MouseDown;

			if (_newUser)
			{
				Text = "Add User";
				checkEditPassword.Visible = false;
				laPassword.Visible = true;
				textEditLogin.Enabled = true;
				buttonEditPassword_ButtonClick(null, null);
			}
			else
			{
				Text = "Edit User";
				checkEditPassword.Visible = true;
				checkEditPassword.Checked = false;
				laPassword.Visible = false;
				textEditLogin.Enabled = false;
			}
		}
Exemplo n.º 11
0
		public static IEnumerable<UserInfo> ImportUsers(string filePath, UserModel[] existedUsers, GroupModel[] existedGroups, bool complexPassword, out string message)
		{
			message = string.Empty;
			var userInfo = new List<UserInfo>();
			var existedGroupList = new List<GroupModel>(existedGroups);
			var existedUserLogins = new List<string>(existedUsers.Select(x => x.login));

			var connnectionString = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR=Yes;IMEX=1"";", filePath);
			var connection = new OleDbConnection(connnectionString);
			try
			{
				connection.Open();
				var groupName = string.Empty;
				var dataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
				foreach (DataRow row in dataTable.Rows)
				{
					groupName = row["TABLE_NAME"].ToString().Replace("$", "").Replace('"'.ToString(), "'").Replace("'", "");
					break;
				}
				var dataAdapter = new OleDbDataAdapter(string.Format("SELECT * FROM [{0}$]", groupName), connection);
				dataTable = new DataTable();
				try
				{
					dataAdapter.Fill(dataTable);
					foreach (DataRow row in dataTable.Rows)
					{
						var firtsName = dataTable.Columns.Count > 0 && row[0] != null ? row[0].ToString() : String.Empty;
						var lastName = dataTable.Columns.Count > 1 && row[1] != null ? row[1].ToString() : String.Empty;
						var email = dataTable.Columns.Count > 2 && row[2] != null ? row[2].ToString() : String.Empty;
						var phone = dataTable.Columns.Count > 3 && row[3] != null ? row[3].ToString() : String.Empty;
						var login = dataTable.Columns.Count > 4 && row[4] != null ? row[4].ToString() : String.Empty;

						if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email)) continue;

						var group = existedGroupList.FirstOrDefault(x => x.name.ToLower().Equals(groupName.Trim().ToLower()));

						var notChangedUser = group != null && existedUsers.Any(u =>
								 login.Equals(u.login, StringComparison.OrdinalIgnoreCase) &&
								 firtsName.Equals(u.firstName, StringComparison.OrdinalIgnoreCase) &&
								 lastName.Equals(u.lastName, StringComparison.OrdinalIgnoreCase) &&
								 email.Equals(u.email, StringComparison.OrdinalIgnoreCase) &&
								 phone.Equals(u.phone, StringComparison.OrdinalIgnoreCase) &&
								 u.groups.Any(existedGroup => group.name == existedGroup.name));
						if (notChangedUser) continue;

						var newUser = !existedUserLogins.Any(existedLogin => login.Equals(existedLogin, StringComparison.OrdinalIgnoreCase));
						var user = new UserInfo();
						user.Login = login.ToLower().Trim();
						user.Password = newUser ? (complexPassword ? Membership.GeneratePassword(10, 3) : (new PasswordGenerator()).Generate()) : String.Empty;
						user.FirstName = firtsName.Trim();
						user.LastName = lastName.Trim();
						user.Email = email.ToLower().Trim();
						user.Phone = phone.ToLower().Trim();

						if (group == null)
						{
							group = new GroupModel();
							group.IsNew = true;
							group.id = Guid.NewGuid().ToString();
							group.name = groupName.Trim();
							existedGroupList.Add(group);
						}
						user.Groups.Add(group);

						existedUserLogins.Add(user.Login);
						userInfo.Add(user);
					}
				}
				catch
				{
					message = "Couldn't read file";
				}
				finally
				{
					dataAdapter.Dispose();
					dataTable.Dispose();
				}
				connection.Close();
			}
			catch
			{
				message = "Couldn't connect to file";
			}
			return userInfo;
		}