Code Cleanup: Assemblies
This commit is contained in:
@@ -5,16 +5,16 @@ using Swarmops.Interface.Objects;
|
||||
namespace Swarmops.Interface.DataObjects
|
||||
{
|
||||
#if !__MonoCS__
|
||||
[DataObject(true)]
|
||||
[DataObject(true)]
|
||||
#endif
|
||||
public class ExpensePayoutsDataObject
|
||||
{
|
||||
public class ExpensePayoutsDataObject
|
||||
{
|
||||
#if !__MonoCS__
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
#endif
|
||||
static public ExpensePayout[] SelectByOrganization(int organizationId)
|
||||
{
|
||||
return ExpensePayouts.FromOrganization(organizationId).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static ExpensePayout[] SelectByOrganization(int organizationId)
|
||||
{
|
||||
return ExpensePayouts.FromOrganization(organizationId).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,80 +6,68 @@ using Swarmops.Basic.Types;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ListPersonDataSource
|
||||
/// Summary description for ListPersonDataSource
|
||||
/// </summary>
|
||||
public class ListPerson : Person
|
||||
{
|
||||
//additional fields for the list
|
||||
private DateTime joinedDate;
|
||||
public DateTime JoinedDate
|
||||
{
|
||||
get { return joinedDate; }
|
||||
set { joinedDate = value; }
|
||||
}
|
||||
|
||||
private DateTime expiresDate;
|
||||
public DateTime ExpiresDate
|
||||
{
|
||||
get { return expiresDate; }
|
||||
set { expiresDate = value; }
|
||||
}
|
||||
private DateTime joinedDate;
|
||||
|
||||
private MembershipPaymentStatus paymentStatus;
|
||||
public MembershipPaymentStatus PaymentStatus
|
||||
{
|
||||
get { return paymentStatus; }
|
||||
set { paymentStatus = value; }
|
||||
}
|
||||
|
||||
int membershipId;
|
||||
|
||||
public int MembershipId
|
||||
{
|
||||
get { return membershipId; }
|
||||
set { membershipId = value; }
|
||||
}
|
||||
|
||||
public ListPerson (BasicPerson b)
|
||||
public ListPerson(BasicPerson b)
|
||||
: base(b)
|
||||
{
|
||||
}
|
||||
|
||||
public ListPerson (Person p)
|
||||
public ListPerson(Person p)
|
||||
: base(p)
|
||||
{
|
||||
}
|
||||
|
||||
public ListPerson ()
|
||||
public ListPerson()
|
||||
: base(null)
|
||||
{
|
||||
}
|
||||
|
||||
public DateTime JoinedDate
|
||||
{
|
||||
get { return this.joinedDate; }
|
||||
set { this.joinedDate = value; }
|
||||
}
|
||||
|
||||
public DateTime ExpiresDate
|
||||
{
|
||||
get { return this.expiresDate; }
|
||||
set { this.expiresDate = value; }
|
||||
}
|
||||
|
||||
public MembershipPaymentStatus PaymentStatus { get; set; }
|
||||
|
||||
public int MembershipId { get; set; }
|
||||
}
|
||||
|
||||
public class ListPersonDataSource
|
||||
{
|
||||
int[] listedPersons;
|
||||
private readonly int[] listedPersons;
|
||||
public int selectedOrgId = 1;
|
||||
|
||||
public ListPersonDataSource ()
|
||||
public ListPersonDataSource()
|
||||
{
|
||||
}
|
||||
|
||||
public ListPersonDataSource (int[] listedPersons)
|
||||
public ListPersonDataSource(int[] listedPersons)
|
||||
{
|
||||
this.listedPersons = listedPersons;
|
||||
}
|
||||
|
||||
public List<ListPerson> GetData (string sortBy)
|
||||
public List<ListPerson> GetData(string sortBy)
|
||||
{
|
||||
|
||||
List<ListPerson> retval = new List<ListPerson>();
|
||||
if (listedPersons != null)
|
||||
if (this.listedPersons != null)
|
||||
{
|
||||
People ppl = People.FromIdentities(listedPersons);
|
||||
Dictionary<int, List<BasicMembership>> membershipTable = Memberships.GetMembershipsForPeople(listedPersons, Membership.GracePeriod);
|
||||
People ppl = People.FromIdentities(this.listedPersons);
|
||||
Dictionary<int, List<BasicMembership>> membershipTable =
|
||||
Memberships.GetMembershipsForPeople(this.listedPersons, Membership.GracePeriod);
|
||||
Memberships membershipsToLoad = new Memberships();
|
||||
foreach (Person p in ppl)
|
||||
{
|
||||
@@ -87,7 +75,7 @@ public class ListPersonDataSource
|
||||
{
|
||||
foreach (BasicMembership bm in membershipTable[p.Identity])
|
||||
{
|
||||
if (bm.OrganizationId == selectedOrgId)
|
||||
if (bm.OrganizationId == this.selectedOrgId)
|
||||
{
|
||||
Membership ms = Membership.FromBasic(bm);
|
||||
membershipsToLoad.Add(ms);
|
||||
@@ -110,7 +98,7 @@ public class ListPersonDataSource
|
||||
{
|
||||
foreach (BasicMembership bm in membershipTable[p.Identity])
|
||||
{
|
||||
if (bm.OrganizationId == selectedOrgId)
|
||||
if (bm.OrganizationId == this.selectedOrgId)
|
||||
{
|
||||
Membership ms = memberships[bm.MembershipId];
|
||||
lp.JoinedDate = ms.MemberSince;
|
||||
@@ -123,19 +111,19 @@ public class ListPersonDataSource
|
||||
}
|
||||
}
|
||||
|
||||
PropertyInfo pi = typeof(ListPerson).GetProperty(sortBy);
|
||||
PropertyInfo pi = typeof (ListPerson).GetProperty(sortBy);
|
||||
if (pi != null)
|
||||
{
|
||||
|
||||
MemberInfo [] miA = pi.PropertyType.GetMember("CompareTo", MemberTypes.Method, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
|
||||
MemberInfo[] miA = pi.PropertyType.GetMember("CompareTo", MemberTypes.Method,
|
||||
BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
|
||||
if (miA.Length > 0)
|
||||
{
|
||||
|
||||
MethodInfo mi =(MethodInfo) miA[0];
|
||||
retval.Sort(delegate(ListPerson p1, ListPerson p2)
|
||||
{
|
||||
return Convert.ToInt32(mi.Invoke(pi.GetValue(p1, null), new object[] { pi.GetValue(p2, null) }));
|
||||
});
|
||||
MethodInfo mi = (MethodInfo) miA[0];
|
||||
retval.Sort(
|
||||
delegate(ListPerson p1, ListPerson p2)
|
||||
{
|
||||
return Convert.ToInt32(mi.Invoke(pi.GetValue(p1, null), new[] {pi.GetValue(p2, null)}));
|
||||
});
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
|
||||
@@ -11,117 +11,53 @@ namespace Swarmops.Interface.DataObjects
|
||||
#if !__MonoCS__
|
||||
[DataObject(true)]
|
||||
#endif
|
||||
|
||||
public class OrganizationRolesDataObject
|
||||
{
|
||||
public class Role : BasicPersonRole
|
||||
{
|
||||
private string organisationName;
|
||||
private string geographyName;
|
||||
private string personName;
|
||||
private string roleName;
|
||||
private int level;
|
||||
private int geoLevel;
|
||||
|
||||
public Role ()
|
||||
: base()
|
||||
public Role()
|
||||
{
|
||||
}
|
||||
|
||||
public Role (BasicPersonRole org)
|
||||
public Role(BasicPersonRole org)
|
||||
: base(org)
|
||||
{
|
||||
organisationName = Organization.FromIdentity(this.OrganizationId).Name;
|
||||
personName = Person.FromIdentity(this.PersonId).Name;
|
||||
roleName = Enum.GetName(this.Type.GetType(), this.Type);
|
||||
geographyName = "";
|
||||
if (RoleTypes.ClassOfRole(this.Type) == RoleClass.Local)
|
||||
this.OrganisationName = Organization.FromIdentity(OrganizationId).Name;
|
||||
this.PersonName = Person.FromIdentity(PersonId).Name;
|
||||
this.RoleName = Enum.GetName(Type.GetType(), Type);
|
||||
this.GeographyName = "";
|
||||
if (RoleTypes.ClassOfRole(Type) == RoleClass.Local)
|
||||
{
|
||||
if (GeographyId > 0)
|
||||
{
|
||||
geographyName = Geography.FromIdentity(GeographyId).Name;
|
||||
this.GeographyName = Geography.FromIdentity(GeographyId).Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GeographyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return geographyName;
|
||||
}
|
||||
set
|
||||
{
|
||||
geographyName = value;
|
||||
}
|
||||
}
|
||||
public int GeoLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return geoLevel;
|
||||
}
|
||||
set
|
||||
{
|
||||
geoLevel = value;
|
||||
}
|
||||
}
|
||||
public int Level
|
||||
{
|
||||
get
|
||||
{
|
||||
return level;
|
||||
}
|
||||
set
|
||||
{
|
||||
level = value;
|
||||
}
|
||||
}
|
||||
public string OrganisationName
|
||||
{
|
||||
get
|
||||
{
|
||||
return organisationName;
|
||||
}
|
||||
set
|
||||
{
|
||||
organisationName = value;
|
||||
}
|
||||
}
|
||||
public string PersonName
|
||||
{
|
||||
get
|
||||
{
|
||||
return personName;
|
||||
}
|
||||
set
|
||||
{
|
||||
personName = value;
|
||||
}
|
||||
}
|
||||
public string RoleName
|
||||
{
|
||||
get
|
||||
{
|
||||
return roleName;
|
||||
}
|
||||
set
|
||||
{
|
||||
roleName = value;
|
||||
}
|
||||
}
|
||||
public string GeographyName { get; set; }
|
||||
|
||||
public int GeoLevel { get; set; }
|
||||
|
||||
public int Level { get; set; }
|
||||
|
||||
public string OrganisationName { get; set; }
|
||||
|
||||
public string PersonName { get; set; }
|
||||
|
||||
public string RoleName { get; set; }
|
||||
}
|
||||
|
||||
static private object dataLock = new object();
|
||||
static private Dictionary<int, Geographies.HierSortOrder> hierarchicalSortOrder = new Dictionary<int, Geographies.HierSortOrder>();
|
||||
private static readonly object dataLock = new object();
|
||||
|
||||
private static Dictionary<int, Geographies.HierSortOrder> hierarchicalSortOrder =
|
||||
new Dictionary<int, Geographies.HierSortOrder>();
|
||||
|
||||
|
||||
#if !__MonoCS__
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
#endif
|
||||
static public OrganizationRolesDataObject.Role[] SelectAllByOrganization (int organizationId)
|
||||
public static Role[] SelectAllByOrganization(int organizationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -143,11 +79,12 @@ namespace Swarmops.Interface.DataObjects
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new OrganizationRolesDataObject.Role[0];
|
||||
return new Role[0];
|
||||
}
|
||||
}
|
||||
|
||||
static private void RecursiveAddInTreeOrder (List<Role> resultList, Dictionary<int, List<Role>> roleDictionary, int currentOrg, int level)
|
||||
private static void RecursiveAddInTreeOrder(List<Role> resultList, Dictionary<int, List<Role>> roleDictionary,
|
||||
int currentOrg, int level)
|
||||
{
|
||||
if (roleDictionary.ContainsKey(currentOrg))
|
||||
{
|
||||
@@ -157,19 +94,24 @@ namespace Swarmops.Interface.DataObjects
|
||||
int res = 0;
|
||||
try
|
||||
{
|
||||
res = ((int)RoleTypes.ClassOfRole(r1.Type)).CompareTo((int)RoleTypes.ClassOfRole(r2.Type));
|
||||
res = ((int) RoleTypes.ClassOfRole(r1.Type)).CompareTo((int) RoleTypes.ClassOfRole(r2.Type));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
if (res == 0)
|
||||
res = hierarchicalSortOrder[r1.GeographyId].Order.CompareTo(hierarchicalSortOrder[r2.GeographyId].Order);
|
||||
res =
|
||||
hierarchicalSortOrder[r1.GeographyId].Order.CompareTo(
|
||||
hierarchicalSortOrder[r2.GeographyId].Order);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
catch { }
|
||||
if (res == 0)
|
||||
res = r1.Type.CompareTo(r2.Type);
|
||||
return res;
|
||||
|
||||
});
|
||||
foreach (Role role in roleDictionary[currentOrg])
|
||||
{
|
||||
@@ -186,7 +128,7 @@ namespace Swarmops.Interface.DataObjects
|
||||
#if !__MonoCS__
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
#endif
|
||||
static public OrganizationRolesDataObject.Role[] SelectSubByOrganization (int organizationId)
|
||||
public static Role[] SelectSubByOrganization(int organizationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -211,14 +153,14 @@ namespace Swarmops.Interface.DataObjects
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new OrganizationRolesDataObject.Role[0];
|
||||
return new Role[0];
|
||||
}
|
||||
}
|
||||
|
||||
#if !__MonoCS__
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
#endif
|
||||
static public OrganizationRolesDataObject.Role[] SelectThisByOrganization (int organizationId)
|
||||
public static Role[] SelectThisByOrganization(int organizationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -243,8 +185,8 @@ namespace Swarmops.Interface.DataObjects
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new OrganizationRolesDataObject.Role[0];
|
||||
return new Role[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user