Timespans processing implemented; PunishmentType.timeSpan implemented; Punishment.Expires implemented

main
Inga 🏳‍🌈 14 years ago
parent 2e2334a38d
commit 050be28f6b
  1. 2
      Builder/IISMainHandler/build.txt
  2. 10
      Common/UserContext.cs
  3. 1
      Common/dataobjects/Post.cs
  4. 13
      Common/dataobjects/Punishment.cs
  5. 13
      Common/dataobjects/PunishmentType.cs
  6. 13
      Core/Util.cs
  7. 2
      MySQLConnector/Connection.cs
  8. 3
      templates/Full/PostPunish.xslt
  9. 21
      templates/Full/elems/Main.xslt
  10. 3
      templates/Lite/PostPunish.xslt
  11. 21
      templates/Lite/elems/Main.xslt

@ -50,6 +50,16 @@ namespace FLocal.Common {
);
}
public static XElement ToXml(this TimeSpan timeSpan) {
return new XElement("timeSpan",
new XElement("days", (long)timeSpan.TotalDays),
new XElement("hours", timeSpan.Hours),
new XElement("minutes", timeSpan.Minutes),
new XElement("seconds", timeSpan.Seconds),
new XElement("ticks", timeSpan.Ticks)
);
}
}
}

@ -377,6 +377,7 @@ namespace FLocal.Common.dataobjects {
{ Punishment.TableSpec.FIELD_PUNISHMENTTYPE, new ScalarFieldValue(type.id.ToString()) },
{ Punishment.TableSpec.FIELD_ISWITHDRAWED, new ScalarFieldValue("0") },
{ Punishment.TableSpec.FIELD_COMMENT, new ScalarFieldValue(comment) },
{ Punishment.TableSpec.FIELD_EXPIRES, new ScalarFieldValue(DateTime.Now.Add(type.timeSpan).ToUTCString()) },
}
)
);

@ -21,6 +21,7 @@ namespace FLocal.Common.dataobjects {
public const string FIELD_PUNISHMENTTYPE = "PunishmentType";
public const string FIELD_ISWITHDRAWED = "IsWithdrawed";
public const string FIELD_COMMENT = "Comment";
public const string FIELD_EXPIRES = "Expires";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
@ -118,6 +119,14 @@ namespace FLocal.Common.dataobjects {
}
}
private DateTime _expires;
public DateTime expires {
get {
this.LoadIfNotLoaded();
return this._expires;
}
}
protected override void doFromHash(Dictionary<string, string> data) {
this._postId = int.Parse(data[TableSpec.FIELD_POSTID]);
this._ownerId = int.Parse(data[TableSpec.FIELD_OWNERID]);
@ -127,6 +136,7 @@ namespace FLocal.Common.dataobjects {
this._punishmentTypeId = int.Parse(data[TableSpec.FIELD_PUNISHMENTTYPE]);
this._isWithdrawed = Util.string2bool(data[TableSpec.FIELD_ISWITHDRAWED]);
this._comment = data[TableSpec.FIELD_COMMENT];
this._expires = Util.ParseDateTimeFromTimestamp(data[TableSpec.FIELD_EXPIRES]).Value;
}
public XElement exportToXml(UserContext context) {
@ -138,7 +148,8 @@ namespace FLocal.Common.dataobjects {
new XElement("punishmentDate", this.punishmentDate.ToXml()),
this.punishmentType.exportToXml(context),
new XElement("isWithdrawed", this.isWithdrawed.ToPlainString()),
new XElement("comment", this.comment)
new XElement("comment", this.comment),
new XElement("expires", this.expires)
);
}

@ -16,6 +16,7 @@ namespace FLocal.Common.dataobjects {
public const string FIELD_DESCRIPTION = "Description";
public const string FIELD_WEIGHT = "Weight";
public const string FIELD_WEIGHTDESCRIPTION = "WeightDescription";
public const string FIELD_TIMESPAN = "TimeSpan";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
@ -48,10 +49,19 @@ namespace FLocal.Common.dataobjects {
}
}
private TimeSpan _timeSpan;
public TimeSpan timeSpan {
get {
this.LoadIfNotLoaded();
return this._timeSpan;
}
}
protected override void doFromHash(Dictionary<string, string> data) {
this._description = data[TableSpec.FIELD_DESCRIPTION];
this._weight = int.Parse(data[TableSpec.FIELD_WEIGHT]);
this._weightDescription = data[TableSpec.FIELD_WEIGHTDESCRIPTION];
this._timeSpan = Util.ParseTimeSpanFromTimestamp(data[TableSpec.FIELD_TIMESPAN]).Value;
}
public XElement exportToXml(UserContext context) {
@ -59,7 +69,8 @@ namespace FLocal.Common.dataobjects {
new XElement("id", this.id),
new XElement("description", this.description),
new XElement("weight", this.weight),
new XElement("weightDescription", this.weightDescription)
new XElement("weightDescription", this.weightDescription),
this.timeSpan.ToXml()
);
}

@ -134,6 +134,19 @@ namespace FLocal.Core {
}
}
public static TimeSpan? ParseTimeSpanFromTimestamp(string raw) {
if(raw == "") {
return null;
} else {
long ticks = long.Parse(raw);
if(ticks < 1) {
return null;
} else {
return new TimeSpan(ticks);
}
}
}
public static string EOL {
get {
return new string(new char[] { (char)0x0d, (char)0x0a });

@ -57,6 +57,8 @@ namespace FLocal.MySQLConnector {
string sValue;
if(value is DateTime) {
sValue = ((DateTime)value).Ticks.ToString();
} else if(value is TimeSpan) {
sValue = ((TimeSpan)value).Ticks.ToString();
} else {
sValue = value.ToString();
}

@ -90,7 +90,8 @@
<xsl:value-of select="weight"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="weightDescription"/>
<xsl:text>)</xsl:text>
<xsl:text>), ńđîę äĺéńňâč˙ </xsl:text>
<xsl:apply-templates select="timeSpan"/>
</label>
<br/>
</xsl:template>

@ -104,6 +104,27 @@
</span>
</xsl:template>
<xsl:template match="timeSpan">
<span nowrap="nowrap">
<xsl:if test="days &gt; 0">
<xsl:value-of select="days"/>
<xsl:text> äíåé </xsl:text>
</xsl:if>
<xsl:if test="hours &gt; 0">
<xsl:value-of select="hours"/>
<xsl:text> ÷àñîâ </xsl:text>
</xsl:if>
<xsl:if test="minutes &gt; 0">
<xsl:value-of select="minutes"/>
<xsl:text> ìèíóò </xsl:text>
</xsl:if>
<xsl:if test="seconds &gt; 0">
<xsl:value-of select="seconds"/>
<xsl:text> ñåêóíä </xsl:text>
</xsl:if>
</span>
</xsl:template>
<xsl:template match="pageOuter/pages/page" mode="withoutCurrent">
<xsl:param name="baseLink"/>
<xsl:param name="selected">-1</xsl:param>

@ -86,7 +86,8 @@
<xsl:value-of select="weight"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="weightDescription"/>
<xsl:text>)</xsl:text>
<xsl:text>), ńđîę äĺéńňâč˙ </xsl:text>
<xsl:apply-templates select="timeSpan"/>
</label>
<br/>
</xsl:template>

@ -98,6 +98,27 @@
</span>
</xsl:template>
<xsl:template match="timeSpan">
<span nowrap="nowrap">
<xsl:if test="days &gt; 0">
<xsl:value-of select="days"/>
<xsl:text> äíåé </xsl:text>
</xsl:if>
<xsl:if test="hours &gt; 0">
<xsl:value-of select="hours"/>
<xsl:text> ÷àñîâ </xsl:text>
</xsl:if>
<xsl:if test="minutes &gt; 0">
<xsl:value-of select="minutes"/>
<xsl:text> ìèíóò </xsl:text>
</xsl:if>
<xsl:if test="seconds &gt; 0">
<xsl:value-of select="seconds"/>
<xsl:text> ñåêóíä </xsl:text>
</xsl:if>
</span>
</xsl:template>
<xsl:template match="pageOuter/pages/page" mode="withoutCurrent">
<xsl:param name="baseLink"/>
<xsl:param name="selected">-1</xsl:param>

Loading…
Cancel
Save