Opened 10 years ago
Last modified 6 years ago
#11340 closed enhancement
Confusion with timestamp - lack of documentation — at Initial Version
Reported by: | Owned by: | osimons | |
---|---|---|---|
Priority: | normal | Component: | XmlRpcPlugin |
Severity: | normal | Keywords: | documentation |
Cc: | Trac Release: | 1.0 |
Description
I would like to start using Trac tickets, but first I need to synchronize thousands of ticket with trac via XmlRpcPlugin.
I cannot find any documentation with properties and their types to provide to ticket_create and ticket_update. Documentation http://www.jspwiki.org/Wiki.jsp?page=WikiRPCInterface2 linked from http://trac-hacks.org/wiki/XmlRpcPlugin doesn't work.
Can you please provide more complex example how to use timestamps when calling ticket_update? I cannot get it work. I would expect that I should provide timestamp of type int32 in _ts field? But when I call _trac.ticket_get(id) I obtain very long number _ts? = "1380897120346000" which seem not be be int32 unix timestamp.
I probably use wrong type beause of "Server returned a fault exception: [1] 'unsupported type for timedelta microseconds component: unicode' while executing 'ticket.update()'". My code C# code is:
public XmlRpcStruct GetProperties()
{
XmlRpcStruct dict = new XmlRpcStruct(); dict.Add("type", Type.ToString()); dict.Add("time", Time.ToString("yyyyMMddTHHmmsszzz")); dict.Add("changetime", Changetime.ToString("yyyyMMddTHHmmsszzz")); dict.Add("_ts", DateTimeToUnixTimeStamp(DateTime.Now)); dict.Add("component", Component ?? string.Empty); dict.Add("severity", Severity.ToString()); dict.Add("priority", Priority.ToString()); dict.Add("owner", Owner ?? string.Empty); dict.Add("reporter", Reporter ?? string.Empty); dict.Add("cc", Cc ?? string.Empty); dict.Add("version", Version ?? string.Empty); dict.Add("milestone", Milestone ?? string.Empty); dict.Add("status", Status.ToString()); dict.Add("resolution", Resolution.ToString()); dict.Add("summary", Summary ?? string.Empty); dict.Add("description", Description?? string.Empty); dict.Add("keywords", Keywords ?? string.Empty); return dict;
}
public static int DateTimeToUnixTimeStamp(DateTime dateTime) {
System.DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0); return (int)((dateTime - epoch.ToLocalTime()).TotalSeconds);
}