public override bool CanMoveNext(int index) { if (index == PAGE_FILE) { if ((string.IsNullOrEmpty(FileText.Text)) || !File.Exists(FileText.Text)) { SquadronContext.Errr("Please enter a valid file!"); return(false); } } else if (index == PAGE_FILECONTENT) { if (!_isFileContentValid) { SquadronContext.Errr("Due to error(s) cannot continue further!"); return(false); } } else if (index == PAGE_MATCHES) { return(CanApplyPermissions()); } return(true); }
private void ExecuteButton_Click(object sender, EventArgs e) { _hasErrors = false; SquadronContext.WriteMessage("Started.."); SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite site = new SPSite(SquadronContext.Url); DataTable table = RefreshUserProfiles(site); RefreshMySiteInfo(); if (table != null) { SquadronContext.WriteMessage(table.Rows.Count.ToString() + " rows found"); } SquadronContext.WriteMessage("Completed."); }); if (_hasErrors) { SquadronContext.Errr("Errors occurred!"); } }
private void ShowResultToGrid() { grid.DataSource = null; grid.DataSource = Result; grid.Columns["UsersInGroup"].Visible = ShowUsersInGroup.Checked; grid.Columns["InheritUrl"].Visible = IncludeInheritUrlChecked.Checked; if (grid.Columns.Contains("InternalObject")) { grid.Columns["InternalObject"].Visible = false; } if (_discardedCount > 0) { SquadronContext.WriteMessage("Discarded " + _discardedCount.ToString() + " result(s) based on condition specified!"); } if (_errorsOccurred) { SquadronContext.Errr("Some of the permission items thrown exeptions. Please check the log for details!"); } Helper.Instance.DisableSort(grid); }
public void SafePerform(object o, IExplorer explorer) { try { Perform(o, explorer); SquadronContext.WriteMessage(this.Text + " operation completed!"); } catch (Exception ex) { SquadronContext.Errr(ex.ToString()); } }
private bool AreInputsValid() { DataTable table = (grid.DataSource as DataTable); if ((table == null) || (!table.Columns.Contains("PersonalSpace"))) { SquadronContext.Errr("'PersonalSpace' column not in input table!"); return(false); } return(true); }
private void SaveToFile() { try { DataTable table = _permissionsControl.GetDataTable(true); ConvertBlanksToDots(table); FileLink.Text = new ExcelExport().ExportToExcel(table, FileText.Text); ShowSummary(); } catch (Exception ex) { SquadronContext.Errr(ex.ToString()); } }
private void ConnectToDestServer() { _connectedToDest = false; SPSecurity.RunWithElevatedPrivileges(delegate() { try { _destinationSite = new SPSite(Url2.Text); _destinationWeb = _destinationSite.OpenWeb(); _connectedToDest = true; } catch (Exception ex) { SquadronContext.Errr("Unable to connect to Destination Server!" + Environment.NewLine + ex.ToString()); } }); }
public void DeleteSolution(SolutionEntity solution) { try { if (solution.Type == "Sandbox Solution") { solution.SPSite.Solutions.Remove(solution.InternalObject as SPUserSolution); } else if (solution.Type == "Farm Solution") { SPFarm.Local.Solutions.Remove(solution.SolutionGuid); } } catch (Exception ex) { SquadronContext.Errr(ex.ToString()); } }
private void PerformButton_Click(object sender, EventArgs e) { SquadronContext.WriteMessage("Started.."); SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite site = new SPSite(SquadronContext.Url); UserProfileManager manager = null; try { manager = new UserProfileManager(SPServiceContext.GetContext(site)); } catch (Exception ex) { SquadronContext.Errr("Unable to create UserProfileManager object!" + Environment.NewLine + "Please ensure Central Administration > User Profile Service Application > Permissions are set!"); SquadronContext.HandleException(ex); return; } DataTable table = new DataTable(); foreach (Property p in manager.Properties) { table.Columns.Add(p.Name, typeof(string)); } foreach (UserProfile profile in manager) { DataRow row = table.NewRow(); foreach (Property property in manager.Properties) { row[property.Name] = profile[property.Name].Value; } table.Rows.Add(row); } grid.DataSource = table; SquadronContext.WriteMessage(table.Rows.Count.ToString() + " rows found"); SquadronContext.WriteMessage("Completed."); }); }
public void RefreshData() { SquadronHelper.Instance.StartAnimation(); try { explorer.Url = SquadronContext.Url; } catch (InvalidURLException iex) { SquadronContext.Errr(iex.Message.ToString(), "http://jeanpaulva.com/2013/04/01/squadron-invalid-url-exception-solutions/"); } catch (Exception ex) { SquadronContext.HandleException(ex); } finally { SquadronHelper.Instance.StopAnimation(); } }
public override bool CanMoveNext(int index) { if (index == PAGE_TREE) { if (browser.SelectedObjects.Count == 0) { SquadronContext.Errr("Please select atleast one item!"); return(false); } } else if (index == PAGE_FILE) { if (string.IsNullOrEmpty(FileText.Text)) { SquadronContext.Errr("Please select a valid file!"); return(false); } } return(true); }
private void CopyButton_Click(object sender, EventArgs e) { try { if (Valid()) { if (Confirm()) { SquadronHelper.Instance.StartAnimation(); Copy(); } } } catch (Exception ex) { SquadronContext.Errr(ex.ToString()); } finally { SquadronHelper.Instance.StopAnimation(); } }
private bool InputsValid() { if (List1.CheckedItems.Count == 0) { SquadronContext.Errr("Please select atleast one Source List!"); return(false); } if (!_connectedToDest) { SquadronContext.Errr("Unable to connect to Destination Server!" + Environment.NewLine + "Please retry changing url / user."); return(false); } if (copyControl1.GetCopyControls().Count() == 0) { SquadronContext.Errr("No valid Destination Lists!"); return(false); } return(true); }
private DataTable RefreshUserProfiles(SPSite site) { UserProfileManager manager = null; try { manager = new UserProfileManager(SPServiceContext.GetContext(site)); } catch (NullReferenceException nex) { SquadronContext.Errr("User Profile Error!" + Environment.NewLine + "Please ensure User Profile Service application is Provisioned & Permissions are set correctly."); return(null); } catch (UserProfileApplicationNotAvailableException uex) { SquadronContext.Errr("User Profile Error!" + Environment.NewLine + "Please configure User Profile Service Application & Ensure Permissions are set correctly."); return(null); } catch { throw; } DataTable table = new DataTable(); foreach (Property p in manager.Properties) { table.Columns.Add(p.Name, typeof(string)); } foreach (UserProfile profile in manager) { DataRow row = table.NewRow(); foreach (Property property in manager.Properties) { row[property.Name] = profile[property.Name].Value; } bool canAdd = true; if (!FilterColumn.Text.Contains("(")) { try { canAdd = (profile[FilterColumn.Text].Value != null) && profile[FilterColumn.Text].Value.ToString().Contains(FilterValue.Text); } catch (Exception ex) { _hasErrors = true; SquadronContext.WriteMessage("Error: " + ex.ToString()); canAdd = false; } } if (canAdd) { table.Rows.Add(row); } } grid.DataSource = table; return(table); }