private void OnCommandDeleteMemberGroup(object sender, System.EventArgs e)
        {
            IGroupsView    view      = base._view as IGroupsView;
            IGroupsModel   model     = base._model as IGroupsModel;
            IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>();
            string         email     = view.UserEmail;

            if (SyncContext != null)
            {
                SyncContext.Post(delegate {
                    presenter.EnableControl(false);
                    presenter.ActivateSpinner(true);
                    presenter.UpdateProgressInfo("Processing...");
                }, null);
            }
            Thread deletemembergroup = new Thread(() => {
                if (string.IsNullOrEmpty(model.AccessToken))
                {
                    SyncContext.Post(delegate {
                        presenter.EnableControl(true);
                        presenter.ActivateSpinner(false);
                        presenter.UpdateProgressInfo("");
                    }, null);
                }
                else
                {
                    if (email.Contains(","))
                    {
                        char delimiter  = ',';
                        string[] emails = email.Split(delimiter);
                        foreach (string newEmail in emails)
                        {
                            this.DeleteMemberGroup(model, newEmail, presenter);
                        }
                    }
                    if (!email.Contains(","))
                    {
                        this.DeleteMemberGroup(model, email, presenter);
                    }

                    if (SyncContext != null)
                    {
                        SyncContext.Post(delegate
                        {
                            // update result and update view.
                            PresenterBase.SetViewPropertiesFromModel <IGroupsView, IGroupsModel>(
                                ref view, model
                                );
                            // update result and update view.
                            view.RenderGroupList();
                            presenter.ActivateSpinner(false);
                            presenter.EnableControl(true);
                            presenter.UpdateProgressInfo("Completed.");
                        }, null);
                    }
                }
            });

            deletemembergroup.Start();
        }
        private void OnDataChanged(object sender, System.EventArgs e)
        {
            IGroupsView  view  = base._view as IGroupsView;
            IGroupsModel model = base._model as IGroupsModel;

            PresenterBase.SetModelPropertiesFromView <IGroupsModel, IGroupsView>(
                ref model, view
                );
        }
Example #3
0
 public MainView(IGroupsView groupsView, IProductsView productsView, Control receiptView) : this()
 {
     this.groupsView   = groupsView;
     this.productsView = productsView;
     this.receiptView  = receiptView;
     (this.groupsView as Control).Dock   = DockStyle.Fill;
     (this.productsView as Control).Dock = DockStyle.Fill;
     this.receiptView.Dock = DockStyle.Fill;
     splitContainer.Panel1.Controls.Add(this.receiptView);
     ShowGroupsView();
 }
        protected override void Initialize()
        {
            IGroupsView  view  = base._view as IGroupsView;
            IGroupsModel model = base._model as IGroupsModel;

            PresenterBase.SetViewPropertiesFromModel <IGroupsView, IGroupsModel>(
                ref view, model
                );

            SyncContext.Post(delegate {
                view.RefreshAccessToken();
            }, null);
        }
        public GroupsPresenter(IGroupsView GroupsWindow, int userId)
        {
            this.userId = userId;
            model       = new GroupsModel();
            win         = GroupsWindow;
            border      = new BorderPresenter(win);
            win.Border_MouseLeftButtonDown += new EventHandler(BorderMouseLeftClick);
            win.Grid_MouseRightButtonDown  += new EventHandler(GridMouseRightClick);
            //GenerateContent();
            List <GroupModel> constGroups = model.Groups;

            win.GenerateContent(constGroups);
        }
 protected override void UnWireViewEvents()
 {
     if (IsViewEventsWired)
     {
         IGroupsView view = base._view as IGroupsView;
         view.DataChanged             -= OnDataChanged;
         view.CommandGetGroups        -= OnCommandGetGroups;
         view.CommandCreateGroup      -= OnCommandCreateGroup;
         view.CommandExportGroups     -= OnCommandExportGroups;
         view.CommandExportGroupPerms -= OnCommandExportGroupPerms;
         view.CommandAddMember        -= OnCommandAddMemberGroup;
         view.CommandDeleteMember     -= OnCommandDeleteMemberGroup;
         IsViewEventsWired             = false;
     }
 }
 protected override void WireViewEvents()
 {
     if (!IsViewEventsWired)
     {
         IGroupsView view = base._view as IGroupsView;
         view.DataChanged             += OnDataChanged;
         view.CommandGetGroups        += OnCommandGetGroups;
         view.CommandCreateGroup      += OnCommandCreateGroup;
         view.CommandExportGroups     += OnCommandExportGroups;
         view.CommandExportGroupPerms += OnCommandExportGroupPerms;
         view.CommandAddMember        += OnCommandAddMemberGroup;
         view.CommandDeleteMember     += OnCommandDeleteMemberGroup;
         IsViewEventsWired             = true;
     }
 }
        private void OnCommandCreateGroup(object sender, System.EventArgs e)
        {
            IGroupsView    view      = base._view as IGroupsView;
            IGroupsModel   model     = base._model as IGroupsModel;
            IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>();
            string         groupName = view.GroupName;
            string         groupType = view.GroupType;

            if (SyncContext != null)
            {
                SyncContext.Post(delegate {
                    presenter.EnableControl(false);
                    presenter.ActivateSpinner(true);
                    presenter.UpdateProgressInfo("Processing...");
                }, null);
            }
            Thread creategroup = new Thread(() => {
                if (string.IsNullOrEmpty(model.AccessToken))
                {
                    SyncContext.Post(delegate {
                        presenter.EnableControl(true);
                        presenter.ActivateSpinner(false);
                        presenter.UpdateProgressInfo("");
                    }, null);
                }
                else
                {
                    this.CreateGroup(model, groupName, groupType, presenter);
                    if (SyncContext != null)
                    {
                        SyncContext.Post(delegate
                        {
                            // update result and update view.
                            PresenterBase.SetViewPropertiesFromModel <IGroupsView, IGroupsModel>(
                                ref view, model
                                );
                            // update result and update view.
                            view.RenderGroupList();
                            presenter.ActivateSpinner(false);
                            presenter.EnableControl(true);
                        }, null);
                    }
                }
            });

            creategroup.Start();
        }
Example #9
0
 public GroupsPresenter(IGroupsView view)
 {
     this.view = view;
     SubsribeToEvents();
 }
        //need work
        private void OnCommandExportGroupPerms(object sender, System.EventArgs e)
        {
            IGroupsView    view      = base._view as IGroupsView;
            IGroupsModel   model     = base._model as IGroupsModel;
            IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>();

            if (SyncContext != null)
            {
                SyncContext.Post(delegate {
                    presenter.EnableControl(false);
                    presenter.ActivateSpinner(true);
                    presenter.UpdateProgressInfo("Processing...");
                }, null);
            }
            Thread exportgroupperms = new Thread(() => {
                if (string.IsNullOrEmpty(model.AccessToken))
                {
                    SyncContext.Post(delegate {
                        presenter.EnableControl(true);
                        presenter.ActivateSpinner(false);
                        presenter.UpdateProgressInfo("");
                    }, null);
                }
                else
                {
                    //need to get groups checked then get shared folders for each
                    this.ExportGroups(model, presenter);
                    this.ExportGroupPerms(model, presenter);

                    if (SyncContext != null)
                    {
                        SyncContext.Post(delegate
                        {
                            // update result and update view.
                            PresenterBase.SetViewPropertiesFromModel <IGroupsView, IGroupsModel>(
                                ref view, model
                                );
                            string sPath = string.Empty;
                            if (model.GroupPerms.Count > 0)
                            {
                                //create CSV file in My Documents folder
                                sPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\GroupPermsExport.csv";
                                CsvConfiguration config = new CsvConfiguration()
                                {
                                    HasHeaderRecord = true,
                                    Delimiter       = ",",
                                    Encoding        = System.Text.Encoding.UTF8
                                };
                                config.RegisterClassMap(new GroupPermsHeaderMap());
                                int total = model.GroupPerms.Count;
                                using (CsvWriter writer = new CsvWriter(new StreamWriter(sPath), config))
                                {
                                    writer.WriteHeader <GroupPermsHeaderRecord>();
                                    int count = 0;
                                    foreach (var item in model.GroupPerms)
                                    {
                                        writer.WriteField <string>(item.GroupName);
                                        writer.WriteField <string>(item.GroupId);
                                        writer.WriteField <string>(item.GroupManagementType);
                                        writer.WriteField <string>(item.GroupType);
                                        writer.WriteField <string>(item.SharedFolderName);
                                        writer.WriteField <string>(item.SharedFolderId);
                                        writer.WriteField <string>(item.IsMember);
                                        writer.WriteField <string>(item.IsOwner);
                                        writer.WriteField <string>(item.AccessType);
                                        writer.WriteField <string>(item.IsInherited);
                                        writer.WriteField <string>(item.IsTeamFolder);
                                        writer.WriteField <string>(item.IsInsideTeamFolder);
                                        count++;
                                        if (SyncContext != null)
                                        {
                                            SyncContext.Post(delegate
                                            {
                                                presenter.UpdateProgressInfo(string.Format("Writing Record: {0}/{1}", (count), total));
                                            }, null);
                                        }
                                        writer.NextRecord();
                                    }
                                }
                                if (SyncContext != null)
                                {
                                    SyncContext.Post(delegate
                                    {
                                        presenter.UpdateProgressInfo("Completed. Exported file located at " + sPath);
                                    }, null);
                                }
                            }
                            if (model.GroupPerms.Count == 0)
                            {
                                presenter.UpdateProgressInfo("No groups were selected to export.");
                            }
                            presenter.ActivateSpinner(false);
                            presenter.EnableControl(true);
                        }, null);
                    }
                }
            });

            exportgroupperms.Start();
        }
 public GroupsPresenter(IGroupsModel model, IGroupsView view)
     : base(model, view)
 {
 }
 public GroupsPresenter(IGroupsModel model, IGroupsView view)
     : base(model, view) {
 }