Example #1
0
        private void AddClick(object sender, RoutedEventArgs e)
        {
            UsersDataGrid.UnselectAll();

            string resultPath = string.Empty;

            using (var dialog = new FolderBrowserDialog())
            {
                DialogResult result = dialog.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    resultPath = dialog.SelectedPath;
                }
                else
                {
                    return;
                }
            }

            if (ListOfDirectories.FirstOrDefault(dir => dir.Path == resultPath) != null)
            {
                return;
            }

            int count = Directory.CreateDirectory(resultPath).GetFiles().Length;

            DirectoryObject directoryObject = new DirectoryObject(Rules.FirstOrDefault(rule => rule.AccessID == 0), resultPath, count);

            _allDirectories.Add(directoryObject);
            ListOfDirectories.Add(directoryObject);
        }
Example #2
0
        private void AddRoleClick(object sender, RoutedEventArgs e)
        {
            UsersDataGrid.UnselectAll();

            int id = Roles.Select(rule => rule.RoleID).Max() + 1;

            Roles.Add(new AccessRole(id, $"Новая роль {id}", "0,1", Rules));
        }
Example #3
0
        private void AddRuleClick(object sender, RoutedEventArgs e)
        {
            UsersDataGrid.UnselectAll();

            int id = Rules.Select(rule => rule.AccessID).Max() + 1;

            Rules.Add(new AccessRule(id, $"Новый уровень доступа {id}"));
        }
Example #4
0
        private void Initialize()
        {
            AdminJournalDetail = new AdminJournalDetail(ref UsersDataGrid, ref LoginJournalDataGrid, ref ComputerParamsDataGrid,
                                                        ref ModulesJornalDataGrid, ref RichTextBox, ref MessagesDataGrid);

            DateFromPicker.Value = DateTime.Now;
            DateToPicker.Value   = DateTime.Now;

            Filter();
            AdminJournalDetail.FillMessages(MessagesFromDateTimePicker.Value, MessagesToDateTimePicker.Value);
            UsersDataGrid.AddColumns();
            AdminJournalDetail.SetGrid();
        }
Example #5
0
        private void AddUserClick(object sender, RoutedEventArgs e)
        {
            UsersDataGrid.UnselectAll();

            int id = 0;

            if (Users.Any())
            {
                id = Users.Select(rule => rule.UserId).Max() + 1;
            }

            Users.Add(new MyUser(id, $"Новый пользователь {id}", "0", Roles));
        }
Example #6
0
        private void OnlinerTimer_Tick(object sender, EventArgs e)
        {
            AdminJournalDetail.FillUsers(DateFromPicker.Value, DateToPicker.Value);
            AdminJournalDetail.CheckOnline();
            AdminJournalDetail.ClearTopMostAndTopModuleAndIdle();
            UsersDataGrid.SuspendLayout();
            UsersDataGrid.Refresh();
            UsersDataGrid.ResumeLayout();

            TotalUsersLabel.Text = "Всего: " + AdminJournalDetail.UsersBindingSource.Count;
            OnlineLabel.Text     = "Онлайн: " + AdminJournalDetail.GetOnlineUsersCount();

            AdminJournalDetail.FillRichTextBox();
        }
Example #7
0
        void InitializeDataSources()
        {
            projectId = (long)HttpContext.Current.Items["ProjectId"];
            project   = Project.Find(projectId);

            //Note - Since we are not using weak references yet, records are cached in memory.
            //a call to refresh ensures we are getting the latest from the DB.
            project.Refresh();

            UsersDataGrid.DataSource = project.Users;
            UsersDataGrid.DataBind();

            ProjectName.Text = project.Title;
        }
    protected void ApplyUsersFilter_Click(object sender, EventArgs e)
    {
        try
        {
            int userTypeId       = Convert.ToInt32(UsersFilterTable_TypeDropDownList.SelectedValue);
            int userRoleId       = Convert.ToInt32(UsersFilterTable_RoleDropDownList.SelectedValue);
            int selectedDealerId = Convert.ToInt32(UsersFilterTable_DealerDropDownList.SelectedValue);


            string     connectionString = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
            DataBlock  dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int        orgId            = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
            List <int> usersIds         = new List <int>();

            dataBlock.OpenConnection();
            if (userTypeId != -1)
            {
                usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, userTypeId));
            }
            else
            {
                usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.DriverUserTypeId));
                usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.AdministratorUserTypeId));
                usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.ManagerUserTypeId));
            }
            Session["UsersTab_UserControl_UsersIds"] = usersIds;

            DataTable dt = new DataTable();
            DataRow   dr;
            dt.Columns.Add(new DataColumn("DEALER", typeof(string)));
            dt.Columns.Add(new DataColumn("SURNAME", typeof(string)));
            dt.Columns.Add(new DataColumn("NAME", typeof(string)));
            dt.Columns.Add(new DataColumn("PAtronimic", typeof(string)));
            dt.Columns.Add(new DataColumn("LOGIN", typeof(string)));
            dt.Columns.Add(new DataColumn("REG_DATE", typeof(string)));
            dt.Columns.Add(new DataColumn("ROLE", typeof(string)));
            dt.Columns.Add(new DataColumn("USER_TYPE", typeof(string)));
            dt.Columns.Add(new DataColumn("STATE", typeof(string)));

            int userInfoId = 0;
            //int dealerId;
            string   dealerName = "";
            DateTime date       = new DateTime();
            int      dealerId;
            foreach (int userId in usersIds)
            {
                if (userRoleId != -1)
                {
                    if (dataBlock.usersTable.GetUserRoleId(userId) != userRoleId)
                    {
                        continue;
                    }
                }

                /*if (userTypeId != -1)
                 *  if (dataBlock.usersTable.Get_UserTypeId(userId) != userTypeId)
                 *      continue;*/
                if (selectedDealerId != -1)
                {
                    userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_DealerId);
                    if (int.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, userInfoId), out dealerId))
                    {
                        if (selectedDealerId != dealerId)
                        {
                            continue;
                        }
                        else
                        {
                            dealerName = dataBlock.organizationTable.GetOrganizationName(dealerId);
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_DealerId);
                    if (int.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, userInfoId), out dealerId))
                    {
                        dealerName = dataBlock.organizationTable.GetOrganizationName(dealerId);
                    }
                    else
                    {
                        dealerName = "???";
                    }
                    if (dealerName.Trim() == "")
                    {
                        dealerName = "???";
                    }
                }
                dr = dt.NewRow();
                //DEALER
                dr["DEALER"] = dealerName;
                //SURNAME
                userInfoId    = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Surname);
                dr["SURNAME"] = dataBlock.usersTable.GetUserInfoValue(userId, userInfoId);
                //NAME
                userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Name);
                dr["NAME"] = dataBlock.usersTable.GetUserInfoValue(userId, userInfoId);
                //Patronimic
                userInfoId       = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Patronimic);
                dr["PAtronimic"] = dataBlock.usersTable.GetUserInfoValue(userId, userInfoId);
                //LOGIN
                dr["LOGIN"] = dataBlock.usersTable.Get_UserName(userId);
                //REG_DATE
                if (DateTime.TryParse(dataBlock.usersTable.GetUserInfoValue(userId, DataBaseReference.UserInfo_RegDate), out date))
                {
                    dr["REG_DATE"] = date.ToLongDateString() + " " + date.ToShortTimeString();
                }
                //ROLE
                dr["ROLE"] = dataBlock.usersTable.Get_UserRoleName(userId);
                //USER_TYPE
                dr["USER_TYPE"] = dataBlock.usersTable.Get_UserTypeStr(userId);
                //STATE
                date = dataBlock.usersTable.Get_TimeConnect(userId);
                if (date == (new DateTime()))
                {
                    dr["STATE"] = "Вход не производился";
                }
                else
                {
                    dr["STATE"] = "Последний вход " + date.ToLongDateString() + " " + date.ToShortTimeString();
                }
                //
                dt.Rows.Add(dr);
            }
            dataBlock.CloseConnection();
            UsersDataGrid.DataSource = dt;
            UsersDataGrid.DataBind();
            UsersDataGridUpdatePanel.Update();
        }
        catch (Exception ex)
        {
            RaiseException(ex);
        }
    }
    public void LoadUsersTable()
    {
        string               connectionString  = ConfigurationSettings.AppSettings["fleetnetbaseConnectionString"];
        DataBlock            dataBlock         = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
        int                  orgId             = Convert.ToInt32(Session["CURRENT_ORG_ID"]);
        List <int>           usersIds          = new List <int>();
        List <UserFromTable> userFromTableList = new List <UserFromTable>();

        dataBlock.OpenConnection();
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.DriverUserTypeId));
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.AdministratorUserTypeId));
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.ManagerUserTypeId));
        usersIds.AddRange(dataBlock.usersTable.Get_AllUsersId(orgId, dataBlock.usersTable.DealerUserTypeId));
        foreach (int id in usersIds)
        {
            userFromTableList.Add(new UserFromTable().FillWithInfo(id, dataBlock.usersTable));
        }
        Session["UsersTab_UserControl_UsersIds"] = usersIds;

        DataTable dt = new DataTable();
        DataRow   dr;

        dt.Columns.Add(new DataColumn("DEALER", typeof(string)));
        dt.Columns.Add(new DataColumn("SURNAME", typeof(string)));
        dt.Columns.Add(new DataColumn("NAME", typeof(string)));
        dt.Columns.Add(new DataColumn("PAtronimic", typeof(string)));
        dt.Columns.Add(new DataColumn("LOGIN", typeof(string)));
        dt.Columns.Add(new DataColumn("REG_DATE", typeof(string)));
        dt.Columns.Add(new DataColumn("ROLE", typeof(string)));
        dt.Columns.Add(new DataColumn("USER_TYPE", typeof(string)));
        dt.Columns.Add(new DataColumn("STATE", typeof(string)));

        int      userInfoId = 0;
        int      dealerId;
        string   dealerName = "";
        DateTime date       = new DateTime();

        foreach (UserFromTable users in userFromTableList)
        {
            dr = dt.NewRow();
            //DEALER
            userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_DealerId);
            if (int.TryParse(dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId), out dealerId))
            {
                dealerName = dataBlock.organizationTable.GetOrganizationName(dealerId);
            }
            else
            {
                dealerName = "???";
            }
            if (dealerName.Trim() == "")
            {
                dealerName = "???";
            }
            dr["DEALER"] = dealerName;
            //SURNAME
            userInfoId    = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Surname);
            dr["SURNAME"] = dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId);
            //NAME
            userInfoId = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Name);
            dr["NAME"] = dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId);
            //Patronimic
            userInfoId       = dataBlock.usersTable.GetUserInfoNameId(DataBaseReference.UserInfo_Patronimic);
            dr["PAtronimic"] = dataBlock.usersTable.GetUserInfoValue(users.id, userInfoId);
            //LOGIN
            dr["LOGIN"] = users.name;
            //REG_DATE
            if (DateTime.TryParse(dataBlock.usersTable.GetUserInfoValue(users.id, DataBaseReference.UserInfo_RegDate), out date))
            {
                dr["REG_DATE"] = date.ToLongDateString() + " " + date.ToShortTimeString();
            }
            //ROLE
            dr["ROLE"] = users.userRole;
            //USER_TYPE
            dr["USER_TYPE"] = users.userType;
            //STATE
            if (users.timeConnection == (new DateTime()))
            {
                dr["STATE"] = "Вход не производился";
            }
            else
            {
                dr["STATE"] = "Последний вход " + users.timeConnection.ToLongDateString() + " " + users.timeConnection.ToShortTimeString();
            }
            //
            dt.Rows.Add(dr);
        }
        dataBlock.CloseConnection();
        UsersDataGrid.DataSource = dt;
        UsersDataGrid.DataBind();
    }
Example #10
0
 private void ClearFocusClick(object sender, RoutedEventArgs e)
 {
     UsersDataGrid.UnselectAll();
 }
Example #11
0
 private void RulesDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     UsersDataGrid.UnselectAll();
 }