Code Cleanup: Assemblies
This commit is contained in:
@@ -6,55 +6,54 @@ using Swarmops.Logic.Swarm;
|
||||
|
||||
namespace Swarmops.Interface.Collections
|
||||
{
|
||||
class ExpensePayouts: List<ExpensePayout>
|
||||
{
|
||||
private ExpensePayouts() // prevent public construction
|
||||
{
|
||||
}
|
||||
internal class ExpensePayouts : List<ExpensePayout>
|
||||
{
|
||||
private ExpensePayouts() // prevent public construction
|
||||
{
|
||||
}
|
||||
|
||||
public static ExpensePayouts FromOrganization(Organization org)
|
||||
{
|
||||
return FromOrganization(org.Identity);
|
||||
}
|
||||
public static ExpensePayouts FromOrganization(Organization org)
|
||||
{
|
||||
return FromOrganization(org.Identity);
|
||||
}
|
||||
|
||||
public static ExpensePayouts FromOrganization(int organizationId)
|
||||
{
|
||||
// This aggregates a list of all pending expense payouts per person,
|
||||
// and returns an ExpensePayouts object.
|
||||
public static ExpensePayouts FromOrganization(int organizationId)
|
||||
{
|
||||
// This aggregates a list of all pending expense payouts per person,
|
||||
// and returns an ExpensePayouts object.
|
||||
|
||||
// It uses a Dictionary<int, List<ExpenseClaim>> to build the data, iterating over
|
||||
// all expenses, where the int key is the person identity.
|
||||
// It uses a Dictionary<int, List<ExpenseClaim>> to build the data, iterating over
|
||||
// all expenses, where the int key is the person identity.
|
||||
|
||||
ExpenseClaims allExpenseClaims = ExpenseClaims.FromOrganization(Organization.FromIdentity(organizationId));
|
||||
Dictionary<int, ExpenseClaims> aggregation = new Dictionary<int, ExpenseClaims>();
|
||||
ExpensePayouts result = new ExpensePayouts();
|
||||
ExpenseClaims allExpenseClaims = ExpenseClaims.FromOrganization(Organization.FromIdentity(organizationId));
|
||||
Dictionary<int, ExpenseClaims> aggregation = new Dictionary<int, ExpenseClaims>();
|
||||
ExpensePayouts result = new ExpensePayouts();
|
||||
|
||||
// Aggregate per person
|
||||
// Aggregate per person
|
||||
|
||||
foreach (ExpenseClaim expense in allExpenseClaims)
|
||||
{
|
||||
if (expense.Approved && expense.Open)
|
||||
{
|
||||
// Ready for payout
|
||||
foreach (ExpenseClaim expense in allExpenseClaims)
|
||||
{
|
||||
if (expense.Approved && expense.Open)
|
||||
{
|
||||
// Ready for payout
|
||||
|
||||
if (!aggregation.ContainsKey(expense.ClaimingPersonId))
|
||||
{
|
||||
aggregation[expense.ClaimingPersonId] = new ExpenseClaims();
|
||||
}
|
||||
if (!aggregation.ContainsKey(expense.ClaimingPersonId))
|
||||
{
|
||||
aggregation[expense.ClaimingPersonId] = new ExpenseClaims();
|
||||
}
|
||||
|
||||
aggregation[expense.ClaimingPersonId].Add(expense);
|
||||
}
|
||||
}
|
||||
aggregation[expense.ClaimingPersonId].Add(expense);
|
||||
}
|
||||
}
|
||||
|
||||
// Create ExpensePayout objects
|
||||
// Create ExpensePayout objects
|
||||
|
||||
foreach (int personId in aggregation.Keys)
|
||||
{
|
||||
result.Add(new ExpensePayout(Person.FromIdentity(personId), aggregation[personId]));
|
||||
}
|
||||
foreach (int personId in aggregation.Keys)
|
||||
{
|
||||
result.Add(new ExpensePayout(Person.FromIdentity(personId), aggregation[personId]));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,74 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace Swarmops.Interface.Localization
|
||||
{
|
||||
public class LocalizationManager
|
||||
{
|
||||
public LocalizationManager()
|
||||
public static string GetLocalString(string stringName, string defaultValue)
|
||||
{
|
||||
// Determine current culture
|
||||
|
||||
return GetLocalString(Thread.CurrentThread.CurrentCulture.Name, stringName, defaultValue);
|
||||
}
|
||||
|
||||
static public string GetLocalString (string stringName, string defaultValue)
|
||||
{
|
||||
// Determine current culture
|
||||
|
||||
return GetLocalString(System.Threading.Thread.CurrentThread.CurrentCulture.Name, stringName, defaultValue);
|
||||
}
|
||||
|
||||
static public string GetLocalString (string locale, string stringName, string defaultValue)
|
||||
public static string GetLocalString(string locale, string stringName, string defaultValue)
|
||||
{
|
||||
locale = locale.Substring (0, 2).ToLower();
|
||||
locale = locale.Substring(0, 2).ToLower();
|
||||
|
||||
switch (stringName)
|
||||
{
|
||||
case "Interface.Security.Login.WelcomeHeader":
|
||||
switch (locale)
|
||||
{
|
||||
case "sv":
|
||||
return "Välkommen till PirateWeb!";
|
||||
case "es":
|
||||
return "Bienvenido en PirateWeb!";
|
||||
case "fr":
|
||||
return "Bienvenue à PirateWeb!";
|
||||
case "de":
|
||||
return "Willkommen zu PirateWeb!";
|
||||
case "ru":
|
||||
return "????? ?????????? ?? PirateWeb!";
|
||||
case "ja":
|
||||
return "PirateWeb????!";
|
||||
}
|
||||
break;
|
||||
switch (stringName)
|
||||
{
|
||||
case "Interface.Security.Login.WelcomeHeader":
|
||||
switch (locale)
|
||||
{
|
||||
case "sv":
|
||||
return "Välkommen till PirateWeb!";
|
||||
case "es":
|
||||
return "Bienvenido en PirateWeb!";
|
||||
case "fr":
|
||||
return "Bienvenue à PirateWeb!";
|
||||
case "de":
|
||||
return "Willkommen zu PirateWeb!";
|
||||
case "ru":
|
||||
return "????? ?????????? ?? PirateWeb!";
|
||||
case "ja":
|
||||
return "PirateWeb????!";
|
||||
}
|
||||
break;
|
||||
|
||||
case "Interface.Security.Login.WelcomeParagraph":
|
||||
switch (locale)
|
||||
{
|
||||
case "sv":
|
||||
return "PirateWeb är ett system för att hantera medlemmar för piratpartierna runt om i världen. För att logga in, så skriv ditt namn, medlemsnummer eller e-mail, tillsammans med ditt lösenord.";
|
||||
case "es":
|
||||
return "PirateWeb es un sistema de gerencia del miembro para los Partidos Piratos alrededor del mundo. A la conexión, escribir por favor su nombre, número del miembro, o dirección d'email, junto con su contraseña.";
|
||||
case "fr":
|
||||
return "PirateWeb est un système de gestion de membre pour les Partis Pirates autour du monde. À l'ouverture, écrire svp votre nom, nombre de membre, ou adresse d'email, avec votre mot de passe.";
|
||||
case "de":
|
||||
return "PirateWeb ist ein internationales Mitgliedermanagementsystem für Piraten. Zum Login geben Sie bitte ihren Namen, Mitgliedsnummer oder e-mail Adresse, zusammen mit ihrem Kennwort ein.";
|
||||
case "ru":
|
||||
return "PirateWeb ???????? ?????? ??????? ??????????? ????????? ?????? ?? ???? ????. ????? ??????????, ??????????, ??????? ???? ???, ?????????? ??????, ??? ????? ??????????? ?????, ? ????? ??????.";
|
||||
case "ja":
|
||||
return "PirateWeb??????????????????????????? ????????????????????????????????????????E???????????????";
|
||||
}
|
||||
break;
|
||||
case "Interface.Security.Login.WelcomeParagraph":
|
||||
switch (locale)
|
||||
{
|
||||
case "sv":
|
||||
return
|
||||
"PirateWeb är ett system för att hantera medlemmar för piratpartierna runt om i världen. För att logga in, så skriv ditt namn, medlemsnummer eller e-mail, tillsammans med ditt lösenord.";
|
||||
case "es":
|
||||
return
|
||||
"PirateWeb es un sistema de gerencia del miembro para los Partidos Piratos alrededor del mundo. A la conexión, escribir por favor su nombre, número del miembro, o dirección d'email, junto con su contraseña.";
|
||||
case "fr":
|
||||
return
|
||||
"PirateWeb est un système de gestion de membre pour les Partis Pirates autour du monde. À l'ouverture, écrire svp votre nom, nombre de membre, ou adresse d'email, avec votre mot de passe.";
|
||||
case "de":
|
||||
return
|
||||
"PirateWeb ist ein internationales Mitgliedermanagementsystem für Piraten. Zum Login geben Sie bitte ihren Namen, Mitgliedsnummer oder e-mail Adresse, zusammen mit ihrem Kennwort ein.";
|
||||
case "ru":
|
||||
return
|
||||
"PirateWeb ???????? ?????? ??????? ??????????? ????????? ?????? ?? ???? ????. ????? ??????????, ??????????, ??????? ???? ???, ?????????? ??????, ??? ????? ??????????? ?????, ? ????? ??????.";
|
||||
case "ja":
|
||||
return
|
||||
"PirateWeb??????????????????????????? ????????????????????????????????????????E???????????????";
|
||||
}
|
||||
break;
|
||||
|
||||
case "Interface.Security.Login.NewPasswordLink":
|
||||
switch (locale)
|
||||
{
|
||||
case "sv":
|
||||
return "Jag har glömt mitt lösenord...";
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (locale)
|
||||
{
|
||||
case "sv":
|
||||
return "Jag har glömt mitt lösenord...";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+133
-139
@@ -7,174 +7,168 @@ using Swarmops.Logic.Swarm;
|
||||
|
||||
namespace Swarmops.Interface.Objects
|
||||
{
|
||||
public class ExpensePayout: IHasIdentity
|
||||
{
|
||||
internal ExpensePayout(Person person, ExpenseClaims expenseClaims)
|
||||
{
|
||||
this.person = person;
|
||||
this.expenseClaims = expenseClaims;
|
||||
public class ExpensePayout : IHasIdentity
|
||||
{
|
||||
private readonly decimal amount;
|
||||
private readonly ExpenseClaims expenseClaims;
|
||||
private readonly Person person;
|
||||
|
||||
decimal total = 0.0m;
|
||||
internal ExpensePayout(Person person, ExpenseClaims expenseClaims)
|
||||
{
|
||||
this.person = person;
|
||||
this.expenseClaims = expenseClaims;
|
||||
|
||||
foreach (ExpenseClaim expense in expenseClaims)
|
||||
{
|
||||
total += expense.Amount;
|
||||
}
|
||||
decimal total = 0.0m;
|
||||
|
||||
this.amount = total;
|
||||
}
|
||||
foreach (ExpenseClaim expense in expenseClaims)
|
||||
{
|
||||
total += expense.Amount;
|
||||
}
|
||||
|
||||
private readonly Person person;
|
||||
this.amount = total;
|
||||
}
|
||||
|
||||
public Person Person
|
||||
{
|
||||
get { return person; }
|
||||
}
|
||||
public Person Person
|
||||
{
|
||||
get { return this.person; }
|
||||
}
|
||||
|
||||
private readonly decimal amount;
|
||||
public decimal Amount
|
||||
{
|
||||
get { return this.amount; }
|
||||
}
|
||||
|
||||
public decimal Amount
|
||||
{
|
||||
get { return amount; }
|
||||
}
|
||||
|
||||
private readonly ExpenseClaims expenseClaims;
|
||||
|
||||
public ExpenseClaims ExpenseClaims
|
||||
{
|
||||
get { return expenseClaims; }
|
||||
}
|
||||
|
||||
public static ExpensePayout FromOrganizationAndPerson (int organizationId, int personId)
|
||||
{
|
||||
ExpenseClaims allExpenseClaims = ExpenseClaims.FromOrganization(Organization.FromIdentity(organizationId));
|
||||
ExpenseClaims expenseClaims = new ExpenseClaims();
|
||||
|
||||
// Aggregate per person
|
||||
|
||||
foreach (ExpenseClaim expense in allExpenseClaims)
|
||||
{
|
||||
if (expense.ClaimingPersonId == personId)
|
||||
{
|
||||
if (expense.Approved && expense.Open)
|
||||
{
|
||||
// Ready for payout
|
||||
|
||||
expenseClaims.Add(expense);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create ExpensePayout object
|
||||
|
||||
return new ExpensePayout(Person.FromIdentity(personId), expenseClaims);
|
||||
}
|
||||
public ExpenseClaims ExpenseClaims
|
||||
{
|
||||
get { return this.expenseClaims; }
|
||||
}
|
||||
|
||||
|
||||
public string ReceiptIdentitiesString // this could be calculated on construction
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> identities = new List<string>();
|
||||
public string ReceiptIdentitiesString // this could be calculated on construction
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> identities = new List<string>();
|
||||
|
||||
foreach (ExpenseClaim expense in expenseClaims)
|
||||
{
|
||||
identities.Add(expense.Identity.ToString());
|
||||
}
|
||||
foreach (ExpenseClaim expense in this.expenseClaims)
|
||||
{
|
||||
identities.Add(expense.Identity.ToString());
|
||||
}
|
||||
|
||||
return String.Join(",", identities.ToArray());
|
||||
}
|
||||
}
|
||||
return String.Join(",", identities.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public string ReceiptList // this could be calculated on construction
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> spans = new List<string>();
|
||||
List<int> expenseIdList = new List<int>();
|
||||
public string ReceiptList // this could be calculated on construction
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> spans = new List<string>();
|
||||
List<int> expenseIdList = new List<int>();
|
||||
|
||||
foreach (ExpenseClaim expense in expenseClaims)
|
||||
{
|
||||
expenseIdList.Add(expense.Identity);
|
||||
}
|
||||
foreach (ExpenseClaim expense in this.expenseClaims)
|
||||
{
|
||||
expenseIdList.Add(expense.Identity);
|
||||
}
|
||||
|
||||
int[] expenseIds = expenseIdList.ToArray();
|
||||
Array.Sort(expenseIds);
|
||||
int[] expenseIds = expenseIdList.ToArray();
|
||||
Array.Sort(expenseIds);
|
||||
|
||||
// iterate over the sorted array: group spans of ids together
|
||||
// iterate over the sorted array: group spans of ids together
|
||||
|
||||
int spanStart = expenseIds[0];
|
||||
int spanLength = 0;
|
||||
int currentIndex = 1;
|
||||
int spanStart = expenseIds[0];
|
||||
int spanLength = 0;
|
||||
int currentIndex = 1;
|
||||
|
||||
while (currentIndex < expenseIds.Length)
|
||||
{
|
||||
if (spanStart + spanLength + 1 == expenseIds[currentIndex])
|
||||
{
|
||||
// the span continues
|
||||
while (currentIndex < expenseIds.Length)
|
||||
{
|
||||
if (spanStart + spanLength + 1 == expenseIds[currentIndex])
|
||||
{
|
||||
// the span continues
|
||||
|
||||
spanLength++;
|
||||
currentIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the span does NOT continue: add
|
||||
spanLength++;
|
||||
currentIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the span does NOT continue: add
|
||||
|
||||
if (spanLength == 0)
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
}
|
||||
else if (spanLength == 1) // really means 2, is zero based
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
spans.Add((spanStart + 1).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
spans.Add (String.Format ("{0}-{1}", spanStart, spanStart + spanLength));
|
||||
}
|
||||
if (spanLength == 0)
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
}
|
||||
else if (spanLength == 1) // really means 2, is zero based
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
spans.Add((spanStart + 1).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
spans.Add(String.Format("{0}-{1}", spanStart, spanStart + spanLength));
|
||||
}
|
||||
|
||||
spanStart = expenseIds[currentIndex];
|
||||
spanLength = 0;
|
||||
spanStart = expenseIds[currentIndex];
|
||||
spanLength = 0;
|
||||
|
||||
currentIndex++;
|
||||
currentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// Add the last span
|
||||
|
||||
// Add the last span
|
||||
if (spanLength == 0)
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
}
|
||||
else if (spanLength == 1) // really means 2, is zero based
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
spans.Add((spanStart + 1).ToString());
|
||||
}
|
||||
else if (spanLength > 1)
|
||||
{
|
||||
spans.Add(String.Format("{0}-{1}", spanStart, spanStart + spanLength));
|
||||
}
|
||||
|
||||
if (spanLength == 0)
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
}
|
||||
else if (spanLength == 1) // really means 2, is zero based
|
||||
{
|
||||
spans.Add(spanStart.ToString());
|
||||
spans.Add((spanStart + 1).ToString());
|
||||
}
|
||||
else if (spanLength > 1)
|
||||
{
|
||||
spans.Add (String.Format ("{0}-{1}", spanStart, spanStart + spanLength));
|
||||
}
|
||||
// Join spans together with ", " between them
|
||||
|
||||
// Join spans together with ", " between them
|
||||
return String.Join(", ", spans.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
return String.Join (", ", spans.ToArray());
|
||||
#region IHasIdentity Members
|
||||
|
||||
}
|
||||
}
|
||||
public int Identity
|
||||
{
|
||||
// We're borrowing the person's identity, as that is what we iterate across.
|
||||
get { return this.person.Identity; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IHasIdentity Members
|
||||
public static ExpensePayout FromOrganizationAndPerson(int organizationId, int personId)
|
||||
{
|
||||
ExpenseClaims allExpenseClaims = ExpenseClaims.FromOrganization(Organization.FromIdentity(organizationId));
|
||||
ExpenseClaims expenseClaims = new ExpenseClaims();
|
||||
|
||||
public int Identity
|
||||
{
|
||||
// We're borrowing the person's identity, as that is what we iterate across.
|
||||
// Aggregate per person
|
||||
|
||||
get { return person.Identity; }
|
||||
}
|
||||
foreach (ExpenseClaim expense in allExpenseClaims)
|
||||
{
|
||||
if (expense.ClaimingPersonId == personId)
|
||||
{
|
||||
if (expense.Approved && expense.Open)
|
||||
{
|
||||
// Ready for payout
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
expenseClaims.Add(expense);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create ExpensePayout object
|
||||
|
||||
return new ExpensePayout(Person.FromIdentity(personId), expenseClaims);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Xml.Serialization;
|
||||
namespace Swarmops.Interface.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MainMenuItem
|
||||
/// Summary description for MainMenuItem
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class MainMenuItem
|
||||
@@ -26,10 +26,21 @@ namespace Swarmops.Interface.Objects
|
||||
}
|
||||
}
|
||||
|
||||
public string ResourceKey { get; set; }
|
||||
public int UserLevel { get; set; }
|
||||
public string Permissions { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
public string NavigateUrl { get; set; }
|
||||
public MenuItemType Type { get; set; }
|
||||
|
||||
// TODO: INSERTION POINT (for plugins)
|
||||
|
||||
public MainMenuItem[] Children { get; set; }
|
||||
|
||||
public static MainMenuItem Link(string image, string navUrl, string resourceKey, int userLevel,
|
||||
string permissions)
|
||||
{
|
||||
MainMenuItem result = new MainMenuItem()
|
||||
MainMenuItem result = new MainMenuItem
|
||||
{
|
||||
ImageUrl = image,
|
||||
NavigateUrl = navUrl,
|
||||
@@ -44,7 +55,7 @@ namespace Swarmops.Interface.Objects
|
||||
|
||||
public static MainMenuItem Submenu(string resourceKey, int userLevel, string permissions)
|
||||
{
|
||||
MainMenuItem result = new MainMenuItem()
|
||||
MainMenuItem result = new MainMenuItem
|
||||
{
|
||||
Permissions = permissions,
|
||||
ResourceKey = resourceKey,
|
||||
@@ -57,7 +68,7 @@ namespace Swarmops.Interface.Objects
|
||||
|
||||
public static MainMenuItem Disabled(string image, string resourceKey, int userLevel, string permissions)
|
||||
{
|
||||
MainMenuItem result = new MainMenuItem()
|
||||
MainMenuItem result = new MainMenuItem
|
||||
{
|
||||
ImageUrl = image,
|
||||
Permissions = permissions,
|
||||
@@ -82,40 +93,26 @@ namespace Swarmops.Interface.Objects
|
||||
|
||||
public static void PrimeNewMenuFile()
|
||||
{
|
||||
MainMenuItem todoItem = MainMenuItem.Disabled(string.Empty, "Placeholder_Todo", 1, string.Empty);
|
||||
MainMenuItem[] todoItemArray = new MainMenuItem[] {todoItem};
|
||||
MainMenuItem todoItem = Disabled(string.Empty, "Placeholder_Todo", 1, string.Empty);
|
||||
MainMenuItem[] todoItemArray = {todoItem};
|
||||
|
||||
MainMenuItem peopleItem = MainMenuItem.Submenu("People", 1, string.Empty);
|
||||
MainMenuItem peopleItem = Submenu("People", 1, string.Empty);
|
||||
peopleItem.Children = todoItemArray;
|
||||
|
||||
MainMenuItem commsItem = MainMenuItem.Submenu("Communications", 1, string.Empty);
|
||||
MainMenuItem commsItem = Submenu("Communications", 1, string.Empty);
|
||||
peopleItem.Children = todoItemArray;
|
||||
|
||||
MainMenuItem claimRefundItem = MainMenuItem.Link("iconshock-moneyback",
|
||||
MainMenuItem claimRefundItem = Link("iconshock-moneyback",
|
||||
"/Pages/v5/Financial/FileExpenseClaim.aspx", "Financial_ClaimExpense", 2, String.Empty);
|
||||
MainMenuItem separatorItem = MainMenuItem.Separator;
|
||||
MainMenuItem separatorItem = Separator;
|
||||
|
||||
MainMenuItem[] financialChildren = new[] {claimRefundItem, separatorItem};
|
||||
MainMenuItem financialItem = MainMenuItem.Submenu("Financial", 2, string.Empty);
|
||||
MainMenuItem[] financialChildren = {claimRefundItem, separatorItem};
|
||||
MainMenuItem financialItem = Submenu("Financial", 2, string.Empty);
|
||||
financialItem.Children = financialChildren;
|
||||
|
||||
MainMenuItem[] protoMenu = new[] {peopleItem, commsItem, financialItem};
|
||||
MainMenuItem[] protoMenu = {peopleItem, commsItem, financialItem};
|
||||
PrimeXml(protoMenu);
|
||||
|
||||
}
|
||||
|
||||
public string ResourceKey { get; set; }
|
||||
public int UserLevel { get; set; }
|
||||
public string Permissions { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
public string NavigateUrl { get; set; }
|
||||
public MenuItemType Type { get; set; }
|
||||
|
||||
// TODO: INSERTION POINT (for plugins)
|
||||
|
||||
public MainMenuItem[] Children { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public enum MenuItemType
|
||||
@@ -123,37 +120,37 @@ namespace Swarmops.Interface.Objects
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary>
|
||||
/// A normal link
|
||||
/// A normal link
|
||||
/// </summary>
|
||||
Link,
|
||||
|
||||
/// <summary>
|
||||
/// Something that looks like a menu item but is disabled
|
||||
/// Something that looks like a menu item but is disabled
|
||||
/// </summary>
|
||||
Disabled,
|
||||
|
||||
/// <summary>
|
||||
/// A header (with or without image) that leads to more options as sub
|
||||
/// A header (with or without image) that leads to more options as sub
|
||||
/// </summary>
|
||||
Submenu,
|
||||
|
||||
/// <summary>
|
||||
/// A thin line separating menu items
|
||||
/// A thin line separating menu items
|
||||
/// </summary>
|
||||
Separator,
|
||||
|
||||
/// <summary>
|
||||
/// A major header (non-link) introducing new menu section
|
||||
/// A major header (non-link) introducing new menu section
|
||||
/// </summary>
|
||||
Header,
|
||||
|
||||
/// <summary>
|
||||
/// Build number indicator
|
||||
/// Build number indicator
|
||||
/// </summary>
|
||||
BuildNumber,
|
||||
|
||||
/// <summary>
|
||||
/// SPECIAL CASE: Close Books menu item
|
||||
/// SPECIAL CASE: Close Books menu item
|
||||
/// </summary>
|
||||
SpecialCloseBooks
|
||||
}
|
||||
|
||||
@@ -6,19 +6,39 @@ namespace Swarmops.Interface.Objects
|
||||
{
|
||||
public class OrganizationMetadata
|
||||
{
|
||||
public OrganizationMetadata (int organizationId, bool recursive, Color color)
|
||||
private readonly Color color;
|
||||
private readonly int organizationId;
|
||||
private readonly bool recursive;
|
||||
|
||||
public OrganizationMetadata(int organizationId, bool recursive, Color color)
|
||||
{
|
||||
this.organizationId = organizationId;
|
||||
this.recursive = recursive;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
public int OrganizationId
|
||||
{
|
||||
get { return this.organizationId; }
|
||||
}
|
||||
|
||||
public bool Recursive
|
||||
{
|
||||
get { return this.recursive; }
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return this.color; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the organization accessed from the URL, like *.piratpartiet.se => orgid 1.
|
||||
/// Determines the organization accessed from the URL, like *.piratpartiet.se => orgid 1.
|
||||
/// </summary>
|
||||
/// <param name="url">The url of the webpage in question, like data.piratpartiet.se/something.</param>
|
||||
/// <returns>A new OrganizationMetadata instance.</returns>
|
||||
static public OrganizationMetadata FromUrl (string url)
|
||||
public static OrganizationMetadata FromUrl(string url)
|
||||
{
|
||||
// We could do this using regexps, but it would be messy and error-prone. So instead, I'm going to do it
|
||||
// the old fashioned readable way.
|
||||
@@ -63,7 +83,7 @@ namespace Swarmops.Interface.Objects
|
||||
|
||||
if (url.EndsWith("localhost"))
|
||||
{
|
||||
return new OrganizationMetadata(1, false, Color.FromArgb(0x66, 0, 0x87)); // debug purposes
|
||||
return new OrganizationMetadata(1, false, Color.FromArgb(0x66, 0, 0x87)); // debug purposes
|
||||
}
|
||||
|
||||
//HACK:
|
||||
@@ -79,29 +99,7 @@ namespace Swarmops.Interface.Objects
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ArgumentException("Unsupported organization" );
|
||||
throw new ArgumentException("Unsupported organization");
|
||||
}
|
||||
|
||||
|
||||
public int OrganizationId
|
||||
{
|
||||
get { return this.organizationId; }
|
||||
}
|
||||
|
||||
public bool Recursive
|
||||
{
|
||||
get { return this.recursive; }
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return this.color; }
|
||||
}
|
||||
|
||||
private int organizationId;
|
||||
private bool recursive;
|
||||
private Color color;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-19
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using Swarmops.Basic.Enums;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
@@ -8,21 +6,8 @@ namespace Swarmops.Interface
|
||||
{
|
||||
public class PersonIcon
|
||||
{
|
||||
public class PersonIconSpec
|
||||
{
|
||||
public PersonIconSpec (string image, string altText)
|
||||
{
|
||||
this.Image = image;
|
||||
this.AltText = altText;
|
||||
|
||||
}
|
||||
|
||||
public string Image = "";
|
||||
public string AltText = "";
|
||||
}
|
||||
|
||||
[Obsolete ("Person icons are deprecated in Swarmops in favor of individual avatars", true)]
|
||||
public static PersonIconSpec ForPerson (Person person, Organizations organizations)
|
||||
[Obsolete("Person icons are deprecated in Swarmops in favor of individual avatars", true)]
|
||||
public static PersonIconSpec ForPerson(Person person, Organizations organizations)
|
||||
{
|
||||
throw new NotImplementedException("Person icons are deprecated in Swarmops v5 in favor of gravatars/avatars");
|
||||
|
||||
@@ -212,6 +197,18 @@ namespace Swarmops.Interface
|
||||
// unhandled role type
|
||||
return new PersonIconSpec("user-silhouette-question.png", "unknown role, " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
public class PersonIconSpec
|
||||
{
|
||||
public string AltText = "";
|
||||
public string Image = "";
|
||||
|
||||
public PersonIconSpec(string image, string altText)
|
||||
{
|
||||
this.Image = image;
|
||||
this.AltText = altText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,70 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Web;
|
||||
using Swarmops.Interface.Localization;
|
||||
|
||||
namespace Swarmops.Interface
|
||||
{
|
||||
public class PirateWebMapProvider: XmlSiteMapProvider
|
||||
{
|
||||
public PirateWebMapProvider()
|
||||
{
|
||||
NameValueCollection parameters = new NameValueCollection();
|
||||
public class PirateWebMapProvider : XmlSiteMapProvider
|
||||
{
|
||||
public PirateWebMapProvider()
|
||||
{
|
||||
NameValueCollection parameters = new NameValueCollection();
|
||||
#if __MonoCS__
|
||||
parameters.Add("siteMapFile", HttpContext.Current.Server.MapPath("~/PirateWeb.sitemap"));
|
||||
#else
|
||||
parameters.Add("siteMapFile", "~/PirateWeb.sitemap");
|
||||
parameters.Add("siteMapFile", "~/PirateWeb.sitemap");
|
||||
#endif
|
||||
base.Initialize("PirateWebMapProvider", parameters);
|
||||
}
|
||||
base.Initialize("PirateWebMapProvider", parameters);
|
||||
}
|
||||
|
||||
public override SiteMapNode FindSiteMapNode(string rawUrl)
|
||||
{
|
||||
return base.FindSiteMapNode(rawUrl);
|
||||
}
|
||||
public override SiteMapNode FindSiteMapNode(string rawUrl)
|
||||
{
|
||||
return base.FindSiteMapNode(rawUrl);
|
||||
}
|
||||
|
||||
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
|
||||
{
|
||||
SiteMapNodeCollection baseCollection = base.GetChildNodes(node);
|
||||
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
|
||||
{
|
||||
SiteMapNodeCollection baseCollection = base.GetChildNodes(node);
|
||||
|
||||
SiteMapNodeCollection newCollection = new SiteMapNodeCollection();
|
||||
SiteMapNodeCollection newCollection = new SiteMapNodeCollection();
|
||||
|
||||
int count = baseCollection.Count;
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
SiteMapNode oldNode = baseCollection[index];
|
||||
int count = baseCollection.Count;
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
SiteMapNode oldNode = baseCollection[index];
|
||||
|
||||
// TODO: Filter on oldNode.Roles here
|
||||
// TODO: Filter on oldNode.Roles here
|
||||
|
||||
SiteMapNode newNode = new SiteMapNode(oldNode.Provider, oldNode.Key, oldNode.Url, Localization.LocalizationManager.GetLocalString (oldNode.Description, oldNode.Title), oldNode.Description);
|
||||
newCollection.Add(newNode);
|
||||
}
|
||||
SiteMapNode newNode = new SiteMapNode(oldNode.Provider, oldNode.Key, oldNode.Url,
|
||||
LocalizationManager.GetLocalString(oldNode.Description, oldNode.Title), oldNode.Description);
|
||||
newCollection.Add(newNode);
|
||||
}
|
||||
|
||||
return baseCollection ;
|
||||
return baseCollection;
|
||||
//return newCollection;
|
||||
}
|
||||
|
||||
public override SiteMapNode GetParentNode(SiteMapNode node)
|
||||
{
|
||||
return base.GetParentNode(node);
|
||||
}
|
||||
public override SiteMapNode GetParentNode(SiteMapNode node)
|
||||
{
|
||||
return base.GetParentNode(node);
|
||||
}
|
||||
|
||||
protected override SiteMapNode GetRootNodeCore()
|
||||
{
|
||||
protected override SiteMapNode GetRootNodeCore()
|
||||
{
|
||||
//return LocalizeNode (base.GetRootNodeCore());
|
||||
return base.GetRootNodeCore();
|
||||
}
|
||||
|
||||
private SiteMapNode LocalizeNode(SiteMapNode node)
|
||||
{
|
||||
if (node == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private SiteMapNode LocalizeNode(SiteMapNode node)
|
||||
{
|
||||
if (node == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new SiteMapNode(node.Provider, node.Key, node.Url, Localization.LocalizationManager.GetLocalString(node.Description, node.Title), node.Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new SiteMapNode(node.Provider, node.Key, node.Url,
|
||||
LocalizationManager.GetLocalString(node.Description, node.Title), node.Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly: AssemblyTitle("Interface")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
@@ -16,9 +17,11 @@ using System.Runtime.InteropServices;
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
||||
[assembly: Guid("5519b139-b70a-47dc-917f-7312449507c7")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
@@ -30,5 +33,6 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
+23
-23
@@ -15,13 +15,13 @@ using System.Xml;
|
||||
|
||||
namespace Swarmops.Interface
|
||||
{
|
||||
|
||||
public class RssWriter
|
||||
{
|
||||
XmlWriter m_writer;
|
||||
private readonly XmlWriter m_writer;
|
||||
|
||||
public RssWriter(XmlWriter tw)
|
||||
{
|
||||
m_writer = tw;
|
||||
this.m_writer = tw;
|
||||
}
|
||||
|
||||
// Write header for RSS Feed
|
||||
@@ -32,24 +32,23 @@ namespace Swarmops.Interface
|
||||
// generator - optional string for 'generator' tag.
|
||||
public void WriteHeader(string title, string link, string description, string generator)
|
||||
{
|
||||
m_writer.WriteStartElement("rss");
|
||||
m_writer.WriteAttributeString("version", "2.0");
|
||||
m_writer.WriteStartElement("channel");
|
||||
m_writer.WriteElementString("title", title);
|
||||
this.m_writer.WriteStartElement("rss");
|
||||
this.m_writer.WriteAttributeString("version", "2.0");
|
||||
this.m_writer.WriteStartElement("channel");
|
||||
this.m_writer.WriteElementString("title", title);
|
||||
|
||||
if (link != null)
|
||||
{
|
||||
m_writer.WriteElementString("link", link); // link to generated report.
|
||||
this.m_writer.WriteElementString("link", link); // link to generated report.
|
||||
}
|
||||
m_writer.WriteElementString("description", description);
|
||||
this.m_writer.WriteElementString("description", description);
|
||||
|
||||
if (generator != null)
|
||||
{
|
||||
m_writer.WriteElementString("generator", generator);
|
||||
this.m_writer.WriteElementString("generator", generator);
|
||||
}
|
||||
|
||||
m_writer.WriteElementString("lastBuildDate", ConvertDate(new DateTime()));
|
||||
|
||||
this.m_writer.WriteElementString("lastBuildDate", ConvertDate(new DateTime()));
|
||||
}
|
||||
|
||||
// Write out an item.
|
||||
@@ -57,18 +56,21 @@ namespace Swarmops.Interface
|
||||
// content - main body of the blog entry
|
||||
// link - link the blog entry back to a webpage.
|
||||
// time - date for the blog entry.
|
||||
public void WriteItem(string title, string content, System.Uri link, DateTime time)
|
||||
public void WriteItem(string title, string content, Uri link, DateTime time)
|
||||
{
|
||||
m_writer.WriteStartElement("item");
|
||||
WriteItemBody(m_writer, title, content, link, time);
|
||||
m_writer.WriteEndElement(); // item
|
||||
this.m_writer.WriteStartElement("item");
|
||||
WriteItemBody(this.m_writer, title, content, link, time);
|
||||
this.m_writer.WriteEndElement(); // item
|
||||
}
|
||||
|
||||
// Write just the body (InnerXml) of a new item
|
||||
public static void WriteItemBody(XmlWriter w, string title, string content, System.Uri link, DateTime time)
|
||||
public static void WriteItemBody(XmlWriter w, string title, string content, Uri link, DateTime time)
|
||||
{
|
||||
w.WriteElementString("title", title);
|
||||
if (link != null) { w.WriteElementString("link", link.ToString()); }
|
||||
if (link != null)
|
||||
{
|
||||
w.WriteElementString("link", link.ToString());
|
||||
}
|
||||
w.WriteElementString("description", content); // this will escape
|
||||
w.WriteElementString("pubDate", ConvertDate(time));
|
||||
}
|
||||
@@ -77,15 +79,14 @@ namespace Swarmops.Interface
|
||||
// this does not close the underlying XML writer.
|
||||
public void Close()
|
||||
{
|
||||
m_writer.WriteEndElement(); // channel
|
||||
m_writer.WriteEndElement(); // rss
|
||||
this.m_writer.WriteEndElement(); // channel
|
||||
this.m_writer.WriteEndElement(); // rss
|
||||
}
|
||||
|
||||
// Convert a DateTime into the format needed for RSS (from RFC 822).
|
||||
// This looks like: "Wed, 04 Jan 2006 16:03:00 GMT"
|
||||
static string ConvertDate(DateTime t)
|
||||
private static string ConvertDate(DateTime t)
|
||||
{
|
||||
|
||||
// See this for help on format string
|
||||
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomdatetimeformatstrings.asp
|
||||
DateTime t2 = t.ToUniversalTime();
|
||||
@@ -93,6 +94,5 @@ namespace Swarmops.Interface
|
||||
|
||||
// unnecessary - t.ToUniversalTime().ToString ("r") would have done it /RF
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user