Пример #1
0
        protected void AllGroupsStore_ReadData(object sender, StoreReadDataEventArgs e)
        {
            ListRequest groupsReq = new ListRequest();

            groupsReq.Size    = "100";
            groupsReq.StartAt = "0";
            groupsReq.Filter  = "";

            //Fetching the corresponding list

            //in this test will take a list of News


            ListResponse <SecurityGroup> groups = _accessControlService.ChildGetAll <SecurityGroup>(groupsReq);

            if (!groups.Success)
            {
                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", groups.ErrorCode) != null ? GetGlobalResourceObject("Errors", groups.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + groups.LogId : groups.Summary).Show();
                return;
            }

            GroupUsersListRequest request = new GroupUsersListRequest();

            request.UserId = CurrentUser.Text;
            ListResponse <SecurityGroupUser> userGroups = _accessControlService.ChildGetAll <SecurityGroupUser>(request);

            if (!groups.Success)
            {
                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", groups.ErrorCode) != null ? GetGlobalResourceObject("Errors", groups.ErrorCode).ToString() : groups.Summary).Show();
                return;
            }
            UserGroupsStore.DataSource = userGroups.Items;
            UserGroupsStore.DataBind();

            List <SecurityGroup> availableGroups = new List <SecurityGroup>();

            groups.Items.ForEach(x => { if (userGroups.Items.Where(y => y.sgId == x.recordId).Count() == 0)
                                        {
                                            availableGroups.Add(x);
                                        }
                                 });

            AllGroupsStore.DataSource = availableGroups;
            AllGroupsStore.DataBind();
            GroupsCombo.Select(0);
        }
Пример #2
0
        public void LeaveGroup(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                SecurityGroupUser user = new SecurityGroupUser();
                user.userId = CurrentUser.Text;
                user.sgId   = index;
                PostRequest <SecurityGroupUser> req = new PostRequest <SecurityGroupUser>();
                req.entity = user;
                PostResponse <SecurityGroupUser> r = _accessControlService.ChildDelete <SecurityGroupUser>(req);
                if (!r.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(r);
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    UserGroupsStore.Reload();
                    AllGroupsStore.Reload();

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
Пример #3
0
        protected void addUserToGroup(object sender, DirectEventArgs e)
        {
            PostRequest <SecurityGroupUser> user = new PostRequest <SecurityGroupUser>();
            SecurityGroupUser en = new SecurityGroupUser();

            en.userId = CurrentUser.Text;
            if (GroupsCombo.SelectedItem == null)
            {
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                return;
            }
            en.sgId     = GroupsCombo.SelectedItem.Value;
            user.entity = en;
            PostResponse <SecurityGroupUser> resp = _accessControlService.ChildAddOrUpdate <SecurityGroupUser>(user);

            if (!resp.Success)
            {
                Common.errorMessage(resp);
                return;
            }

            AllGroupsStore.Reload();
        }
Пример #4
0
        protected void PoPuP(object sender, DirectEventArgs e)
        {
            panelRecordDetails.ActiveIndex = 0;
            DeactivatePassword(true);
            userGroups.Disabled = false;
            int    id   = Convert.ToInt32(e.ExtraParams["id"]);
            string type = e.ExtraParams["type"];

            CurrentUser.Text = id.ToString();
            switch (type)
            {
            case "imgEdit":
                //Step 1 : get the object from the Web Service
                RecordRequest r = new RecordRequest();
                r.RecordID = id.ToString();

                RecordResponse <UserInfo> response = _systemService.ChildGetRecord <UserInfo>(r);
                if (!response.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(response);
                    return;
                }
                //Step 2 : call setvalues with the retrieved object

                PasswordConfirmation.Text = response.result.password;
                this.BasicInfoTab.SetValues(response.result);
                if (response.result.activeStatus == Convert.ToInt16(ActiveStatus.INACTIVE))
                {
                    isInactiveCheck.Checked = true;
                }
                else
                {
                    isInactiveCheck.Checked = false;
                }


                if (!String.IsNullOrEmpty(response.result.employeeId))
                {
                    RecordRequest empRecord = new RecordRequest();
                    empRecord.RecordID = response.result.employeeId;
                    RecordResponse <Employee> empResponse = _employeeService.Get <Employee>(empRecord);

                    RecordRequest req = new RecordRequest();

                    employeeId.GetStore().Add(new object[]
                    {
                        new
                        {
                            recordId = response.result.employeeId,
                            fullName = empResponse.result.name.fullName
                        }
                    });
                    employeeId.SetValue(response.result.employeeId);

                    X.Call("SetNameEnabled", false, empResponse.result.name.fullName);
                }
                pro.Hidden = true;

                // InitCombos(response.result);
                this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle;
                this.EditRecordWindow.Show();


                AllGroupsStore.Reload();
                break;

            case "imgDelete":
                X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig
                {
                    Yes = new MessageBoxButtonConfig
                    {
                        //We are call a direct request metho for deleting a record
                        Handler = String.Format("App.direct.DeleteRecord({0})", id),
                        Text    = Resources.Common.Yes
                    },
                    No = new MessageBoxButtonConfig
                    {
                        Text = Resources.Common.No
                    }
                }).Show();
                break;

            case "imgAttach":

                //Here will show up a winow relatice to attachement depending on the case we are working on
                break;

            default:
                break;
            }
        }