fixed bugs

This commit is contained in:
vfedosevich 2013-08-28 20:18:56 +03:00
parent 3fc3a425e0
commit 80d4843693
24 changed files with 2453 additions and 2295 deletions

View file

@ -39,7 +39,8 @@
MailboxesEnabled="false"
EnableMailboxOnly="true"
ContactsEnabled="false"
DistributionListsEnabled="true" />
DistributionListsEnabled="true"
SecurityGroupsEnabled="true" />
</ContentTemplate>
</asp:UpdatePanel>

View file

@ -41,7 +41,8 @@
MailboxesEnabled="false"
EnableMailboxOnly="true"
ContactsEnabled="false"
DistributionListsEnabled="true" />
DistributionListsEnabled="true"
SecurityGroupsEnabled="true" />
</ContentTemplate>
</asp:UpdatePanel>

View file

@ -69,6 +69,8 @@
meta:resourcekey="chkIncludeContacts" AutoPostBack="true" CssClass="Normal" OnCheckedChanged="chkIncludeMailboxes_CheckedChanged" />
<asp:CheckBox ID="chkIncludeLists" runat="server" Text="Distribution Lists" Checked="true"
meta:resourcekey="chkIncludeLists" AutoPostBack="true" CssClass="Normal" OnCheckedChanged="chkIncludeMailboxes_CheckedChanged" />
<asp:CheckBox ID="chkIncludeGroups" runat="server" Text="Groups" Checked="true"
meta:resourcekey="chkIncludeGroups" AutoPostBack="true" CssClass="Normal" OnCheckedChanged="chkIncludeMailboxes_CheckedChanged" />
</div>
<div class="FormButtonsBarClean">
<div class="FormButtonsBarCleanRight">

View file

@ -67,6 +67,12 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
set { ViewState["DistributionListsEnabled"] = value; }
}
public bool SecurityGroupsEnabled
{
get { return ViewState["SecurityGroupsEnabled"] != null ? (bool)ViewState["SecurityGroupsEnabled"] : false; }
set { ViewState["SecurityGroupsEnabled"] = value; }
}
public int ExcludeAccountId
{
get { return PanelRequest.AccountID; }
@ -109,6 +115,9 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
chkIncludeContacts.Checked = ContactsEnabled;
chkIncludeLists.Visible = DistributionListsEnabled;
chkIncludeLists.Checked = DistributionListsEnabled;
chkIncludeGroups.Visible = SecurityGroupsEnabled;
chkIncludeGroups.Checked = SecurityGroupsEnabled;
}
// register javascript
@ -131,14 +140,16 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccountType accountType = (ExchangeAccountType)accountTypeId;
string imgName = "mailbox_16.gif";
if (accountType == ExchangeAccountType.Contact)
imgName = "contact_16.gif";
else if (accountType == ExchangeAccountType.DistributionList)
imgName = "dlist_16.gif";
if (accountType == ExchangeAccountType.Contact)
imgName = "contact_16.gif";
else if (accountType == ExchangeAccountType.DistributionList)
imgName = "dlist_16.gif";
else if (accountType == ExchangeAccountType.Room)
imgName = "room_16.gif";
else if (accountType == ExchangeAccountType.Equipment)
imgName = "equipment_16.gif";
else if (accountType == ExchangeAccountType.Equipment)
imgName = "dlist_16.gif";
return GetThemedImage("Exchange/" + imgName);
}
@ -174,7 +185,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccount[] accounts = ES.Services.ExchangeServer.SearchAccounts(PanelRequest.ItemID,
chkIncludeMailboxes.Checked, chkIncludeContacts.Checked, chkIncludeLists.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked, chkIncludeGroups.Checked,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
if (ExcludeAccountId > 0)

View file

@ -1,22 +1,15 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.832
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WebsitePanel.Portal.ExchangeServer.UserControls {
/// <summary>
/// AccountsList class.
/// </summary>
/// <remarks>
/// Auto-generated class.
/// </remarks>
public partial class AccountsList {
/// <summary>
@ -136,6 +129,15 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls {
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkIncludeLists;
/// <summary>
/// chkIncludeGroups control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkIncludeGroups;
/// <summary>
/// SearchPanel control.
/// </summary>

View file

@ -184,7 +184,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccount[] accounts = ES.Services.ExchangeServer.SearchAccounts(PanelRequest.ItemID,
chkIncludeMailboxes.Checked, chkIncludeContacts.Checked, chkIncludeLists.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked, false,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
if (ExcludeAccountId > 0)

View file

@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="btnAdd.Text" xml:space="preserve">
<value>Add...</value>
@ -135,6 +135,9 @@
<data name="chkIncludeEquipment.Text" xml:space="preserve">
<value>Equipment</value>
</data>
<data name="chkIncludeGroups" xml:space="preserve">
<value>Groups</value>
</data>
<data name="chkIncludeLists.Text" xml:space="preserve">
<value>Distribution Lists</value>
</data>

View file

@ -116,8 +116,8 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
private void BindPopupAccounts()
{
ExchangeAccount[] accounts = ES.Services.Organizations.SearchSecurityGroups(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
ExchangeAccount[] accounts = ES.Services.Organizations.SearchOrganizationAccounts(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", true);
accounts = accounts.Where(x => !GetAccounts().Contains(x.AccountName)).ToArray();
@ -158,6 +158,8 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
gvGroups.DataSource = accounts;
gvGroups.DataBind();
UpdateGridViewAccounts(gvGroups);
btnDelete.Visible = gvGroups.Rows.Count > 0;
}
@ -184,6 +186,39 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
return accounts;
}
private void UpdateGridViewAccounts(GridView gv)
{
CheckBox chkSelectAll = (CheckBox)gv.HeaderRow.FindControl("chkSelectAll");
for (int i = 0; i < gv.Rows.Count; i++)
{
GridViewRow row = gv.Rows[i];
CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
if (chkSelect == null)
{
continue;
}
ExchangeAccountType exAccountType = (ExchangeAccountType)Enum.Parse(typeof(ExchangeAccountType), ((Literal)row.FindControl("litAccountType")).Text);
if (exAccountType != ExchangeAccountType.DefaultSecurityGroup)
{
chkSelectAll = null;
chkSelect.Enabled = true;
}
else
{
chkSelect.Enabled = false;
}
}
if (chkSelectAll != null)
{
chkSelectAll.Enabled = false;
}
}
protected void chkIncludeMailboxes_CheckedChanged(object sender, EventArgs e)
{
BindPopupAccounts();

View file

@ -157,7 +157,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
ExchangeAccount[] accounts = ES.Services.ExchangeServer.SearchAccounts(PanelRequest.ItemID,
chkIncludeMailboxes.Checked, chkIncludeContacts.Checked, chkIncludeLists.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked,
chkIncludeRooms.Checked, chkIncludeEquipment.Checked, false,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
if (ExcludeAccountId > 0)

View file

@ -54,79 +54,12 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
Unselected
}
public bool IncludeMailboxes
{
get
{
object ret = ViewState["IncludeMailboxes"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["IncludeMailboxes"] = value;
}
}
public bool IncludeMailboxesOnly
{
get
{
object ret = ViewState["IncludeMailboxesOnly"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["IncludeMailboxesOnly"] = value;
}
}
public bool ExcludeOCSUsers
{
get
{
object ret = ViewState["ExcludeOCSUsers"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["ExcludeOCSUsers"] = value;
}
}
public bool ExcludeLyncUsers
{
get
{
object ret = ViewState["ExcludeLyncUsers"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["ExcludeLyncUsers"] = value;
}
}
public bool ExcludeBESUsers
{
get
{
object ret = ViewState["ExcludeBESUsers"];
return (ret != null) ? (bool)ret : false;
}
set
{
ViewState["ExcludeBESUsers"] = value;
}
}
public int ExcludeAccountId
{
get { return PanelRequest.AccountID; }
}
public void SetAccounts(OrganizationUser[] accounts)
public void SetAccounts(ExchangeAccount[] accounts)
{
BindAccounts(accounts, false);
}
@ -134,10 +67,10 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
public string[] GetAccounts()
{
// get selected accounts
List<OrganizationUser> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.All);
List<ExchangeAccount> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.All);
List<string> accountNames = new List<string>();
foreach (OrganizationUser account in selectedAccounts)
foreach (ExchangeAccount account in selectedAccounts)
accountNames.Add(account.AccountName);
return accountNames.ToArray();
@ -178,7 +111,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
protected void btnDelete_Click(object sender, EventArgs e)
{
// get selected accounts
List<OrganizationUser> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.Unselected);
List<ExchangeAccount> selectedAccounts = GetGridViewAccounts(gvAccounts, SelectedState.Unselected);
// add to the main list
BindAccounts(selectedAccounts.ToArray(), false);
@ -187,7 +120,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
protected void btnAddSelected_Click(object sender, EventArgs e)
{
// get selected accounts
List<OrganizationUser> selectedAccounts = GetGridViewAccounts(gvPopupAccounts, SelectedState.Selected);
List<ExchangeAccount> selectedAccounts = GetGridViewAccounts(gvPopupAccounts, SelectedState.Selected);
// add to the main list
BindAccounts(selectedAccounts.ToArray(), true);
@ -206,6 +139,9 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
case ExchangeAccountType.Equipment:
imgName = "equipment_16.gif";
break;
case ExchangeAccountType.SecurityGroup:
imgName = "dlist_16.gif";
break;
default:
imgName = "admin_16.png";
break;
@ -216,58 +152,23 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
private void BindPopupAccounts()
{
OrganizationUser[] accounts = ES.Services.Organizations.SearchAccounts(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", IncludeMailboxes);
ExchangeAccount[] accounts = ES.Services.Organizations.SearchOrganizationAccounts(PanelRequest.ItemID,
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "", false);
List<OrganizationUser> newAccounts = new List<OrganizationUser>();
List<ExchangeAccount> newAccounts = new List<ExchangeAccount>();
accounts = accounts.Where(x => !GetAccounts().Contains(x.AccountName)).ToArray();
if (ExcludeAccountId > 0)
{
List<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
foreach (OrganizationUser account in accounts)
List<ExchangeAccount> updatedAccounts = new List<ExchangeAccount>();
foreach (ExchangeAccount account in accounts)
if (account.AccountId != ExcludeAccountId)
updatedAccounts.Add(account);
accounts = updatedAccounts.ToArray();
}
if (IncludeMailboxesOnly)
{
List<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
foreach (OrganizationUser account in accounts)
{
bool addUser = false;
if (account.ExternalEmail != string.Empty) addUser = true;
if ((account.IsBlackBerryUser) & (ExcludeBESUsers)) addUser = false;
if ((account.IsLyncUser) & (ExcludeLyncUsers)) addUser = false;
if (addUser) updatedAccounts.Add(account);
}
accounts = updatedAccounts.ToArray();
}
else
if ((ExcludeOCSUsers) | (ExcludeBESUsers) | (ExcludeLyncUsers))
{
List<OrganizationUser> updatedAccounts = new List<OrganizationUser>();
foreach (OrganizationUser account in accounts)
{
bool addUser = true;
if ((account.IsOCSUser) & (ExcludeOCSUsers)) addUser = false;
if ((account.IsLyncUser) & (ExcludeLyncUsers)) addUser = false;
if ((account.IsBlackBerryUser) & (ExcludeBESUsers)) addUser = false;
if (addUser) updatedAccounts.Add(account);
}
accounts = updatedAccounts.ToArray();
}
Array.Sort(accounts, CompareAccount);
if (Direction == SortDirection.Ascending)
{
@ -281,21 +182,21 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
gvPopupAccounts.DataBind();
}
private void BindAccounts(OrganizationUser[] newAccounts, bool preserveExisting)
private void BindAccounts(ExchangeAccount[] newAccounts, bool preserveExisting)
{
// get binded addresses
List<OrganizationUser> accounts = new List<OrganizationUser>();
List<ExchangeAccount> accounts = new List<ExchangeAccount>();
if(preserveExisting)
accounts.AddRange(GetGridViewAccounts(gvAccounts, SelectedState.All));
// add new accounts
if (newAccounts != null)
{
foreach (OrganizationUser newAccount in newAccounts)
foreach (ExchangeAccount newAccount in newAccounts)
{
// check if exists
bool exists = false;
foreach (OrganizationUser account in accounts)
foreach (ExchangeAccount account in accounts)
{
if (String.Compare(newAccount.AccountName, account.AccountName, true) == 0)
{
@ -317,9 +218,9 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
btnDelete.Visible = gvAccounts.Rows.Count > 0;
}
private List<OrganizationUser> GetGridViewAccounts(GridView gv, SelectedState state)
private List<ExchangeAccount> GetGridViewAccounts(GridView gv, SelectedState state)
{
List<OrganizationUser> accounts = new List<OrganizationUser>();
List<ExchangeAccount> accounts = new List<ExchangeAccount>();
for (int i = 0; i < gv.Rows.Count; i++)
{
GridViewRow row = gv.Rows[i];
@ -327,7 +228,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
if (chkSelect == null)
continue;
OrganizationUser account = new OrganizationUser();
ExchangeAccount account = new ExchangeAccount();
account.AccountType = (ExchangeAccountType)Enum.Parse(typeof(ExchangeAccountType), ((Literal)row.FindControl("litAccountType")).Text);
account.AccountName = (string)gv.DataKeys[i][0];
account.DisplayName = ((Literal)row.FindControl("litDisplayName")).Text;
@ -352,7 +253,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
set { ViewState[DirectionString] = value; }
}
private static int CompareAccount(OrganizationUser user1, OrganizationUser user2)
private static int CompareAccount(ExchangeAccount user1, ExchangeAccount user2)
{
return string.Compare(user1.DisplayName, user2.DisplayName);
}