|
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using FogCreek.FogBugz;
using FogCreek.FogBugz.Plugins;
using FogCreek.FogBugz.Plugins.Api;
using FogCreek.FogBugz.Plugins.Entity;
using FogCreek.FogBugz.Plugins.Interfaces;
using FogCreek.FogBugz.UI.Dialog;
namespace TimeIntervalExample
{
public class TimeIntervalExample : Plugin, IPluginTimeIntervalCommit, IPluginTimeIntervalJoin,
IPluginJS, IPluginDatabase, IPluginRawPageDisplay
{
public TimeIntervalExample(CPluginApi api) : base(api) { }
protected const string SPluginId = "Adam+TimeIntervalExample@fogcreek.com";
string _preCommitComment = "";
private const string CommentsTable = "TimeIntervalComment";
private const string IntervalColumn = "ixInterval";
private const string CommentColumn = "sComment";
public const int CommentColumnMaxLength = 255;
private const int PluginSchemaVer = 1;
#region IPluginTimeIntervalCommit Members
public void TimeIntervalCommitAfter(CTimeInterval timeinterval)
{
throw new NotImplementedException();
}
public bool TimeIntervalCommitBefore(CTimeInterval timeinterval)
{
throw new NotImplementedException();
}
public void TimeIntervalCommitRollback(CTimeInterval timeinterval)
{
throw new NotImplementedException();
}
#endregion
#region IPluginTimeIntervalJoin Members
public string[] TimeIntervalJoinTables()
{
return new string[] { "TimeIntervalComment" };
}
#endregion
#region IPluginJS Members
public CJSInfo JSInfo()
{
throw new NotImplementedException();
}
#endregion
#region IPluginDatabase Members
public CTable[] DatabaseSchema()
{
var timeIntervalComments = api.Database.NewTable(api.Database.PluginTableName(CommentsTable));
timeIntervalComments.sDesc = "Assigns Comments to TimeIntervals";
timeIntervalComments.AddAutoIncrementPrimaryKey("ixTimeIntervalComment");
timeIntervalComments.AddIntColumn(IntervalColumn, true, 0);
timeIntervalComments.AddVarcharColumn(CommentColumn, CommentColumnMaxLength, false);
return new[] { timeIntervalComments };
}
public int DatabaseSchemaVersion()
{
return PluginSchemaVer;
}
public void DatabaseUpgradeAfter(int ixVersionFrom, int ixVersionTo, CDatabaseUpgradeApi apiUpgrade)
{
if (ixVersionTo == 1)
{
// No action required. Don't create any data in the tables
}
}
public void DatabaseUpgradeBefore(int ixVersionFrom, int ixVersionTo, CDatabaseUpgradeApi apiUpgrade)
{
if (ixVersionTo == 1)
{
// No action required. Don't create any data in the tables
}
}
#endregion
#region IPluginRawPageDisplay Members
public string RawPageDisplay()
{
if (api.Request[api.AddPluginPrefix("action")] != null &&
Convert.ToString(api.Request[api.AddPluginPrefix("action")]) == "postComment")
{
// make sure the request includes a valid action token
if ((api.Request[api.AddPluginPrefix("actionToken")] == null) ||
!api.Security.ValidateActionToken(api.Request[api.AddPluginPrefix("actionToken")],
"postComment"))
{
return "action token invalid";
}
else
{
PostComment();
}
}
if (api.Request[api.AddPluginPrefix("data")] == "getComment")
{
return GetComment();
}
else return "command not recognized";
}
public PermissionLevel RawPageVisibility()
{
return PermissionLevel.Normal;
}
#endregion
private void PostComment()
{
}
private void GetComment()
{
throw new NotImplementedException();
}
}
}
|
Loading...