本文整理汇总了C#中Castle.MonoRail.Framework.Controller.CancelView方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.CancelView方法的具体用法?C# Controller.CancelView怎么用?C# Controller.CancelView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.MonoRail.Framework.Controller
的用法示例。
在下文中一共展示了Controller.CancelView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmptyAction
/// <summary>
/// Represents an empty (no-op) action.
/// </summary>
/// <param name="controller">The controller.</param>
protected void EmptyAction(Controller controller)
{
controller.CancelView();
}
示例2: OnStepActionRequested
/// <summary>
/// Invoked when a step is accessed on the url,
/// i.e. http://host/mywizard/firststep.rails and
/// when an inner action is invoked like http://host/mywizard/firststep-save.rails
/// </summary>
/// <param name="controller"></param>
private void OnStepActionRequested(Controller controller)
{
if (currentStepInstance != null && !HasRequiredSessionData(controller))
{
StartWizard(controller, false);
}
controller.CancelView();
IRailsEngineContext context = controller.Context;
IWizardController wizController = (IWizardController) controller;
String wizardName = WizardUtils.ConstructWizardNamespace(controller);
String currentStep = (String) context.Session[wizardName + "currentstep"];
// The step will inherit the controller property bag,
// this way filters can pass values to the step property without having to know it
currentStepInstance.PropertyBag = controller.PropertyBag;
// If OnBeforeStep returns false we stop
if (!wizController.OnBeforeStep(wizardName, currentStep, currentStepInstance))
{
return;
}
// Initialize step data so instance members can be used
// executor.InitializeController(urlInfo.Area, urlInfo.Controller, innerAction);
// Record the step we're working with
WizardUtils.RegisterCurrentStepInfo(controller, currentStepInstance.ActionName);
// The step cannot be accessed in the current state of matters
if (!currentStepInstance.IsPreConditionSatisfied(controller.Context))
{
return;
}
// Dispatch process
try
{
// TODO: Invoke Whole step here
// currentStepInstance.Process(controller.Context,
// urlInfo.Area, urlInfo.Controller, innerAction);
currentStepExecutor.ProcessSelectedAction();
}
finally
{
wizController.OnAfterStep(wizardName, currentStep, currentStepInstance);
currentStepExecutor.Dispose();
}
}
示例3: Execute
public void Execute(Controller controller)
{
try
{
string filename = Path.GetTempFileName();
logger.Info("Saving tabular data into " + filename);
controller.PropertyBag["filename"] = filename;
TabularQuery query = TabularQuery.Find(int.Parse(controller.Params["table"]));
CustomQuery customQuery = new CustomQuery(query.SelectStatement);
customQuery.Logger = GlobalApplication.CreateLogger(typeof(CustomQuery));
QueryResults results = customQuery
.ConfigureFilters(controller.Params)
.Execute();
/*
* IMPORTANT: To make sure the Excel applicaton quits properly follow the below steps:
* SEE: http://support.microsoft.com/default.aspx?scid=kb;en-us;317109
*
* 1. each COM object should be a new variable
* 2. use System.Runtime.InteropServices.Marshal.ReleaseComObject when finished with an object
* 3. set variable to null
* 4. call the Quit method of the application
* 5. run garbage collection methods
*/
logger.Debug("initializing Excel application");
Application excel = new Application();
Workbooks books = excel.Workbooks;
Workbook book = books.Add(Missing.Value) as Workbook;
Sheets sheets = book.Worksheets as Sheets;
Worksheet sheet;
excel.Visible = true;
logger.Debug("removing unneeded sheets");
while (sheets.Count > 1)
{
sheet = book.ActiveSheet as Worksheet;
sheet.Delete();
}
sheet = book.ActiveSheet as Worksheet;
sheet.Name = query.Title;
// first row is column names
for (int i = 0; i < results.Columns.Length; i++)
{
((Range)sheet.Cells[1, i + 1]).Font.Bold = true;
sheet.Cells[1, i + 1] = results.Columns[i];
}
// subsequent rows are values
for (int i = 0; i < results.Rows.Count; i++)
{
object[] row = results.Rows[i];
for (int j = 0; j < row.Length; j++)
{
sheet.Cells[i + 2, j + 1] = row[j];
}
}
logger.Debug("saving excel workbook");
book.SaveCopyAs(filename);
book.Saved = true;
books.Close();
logger.Debug("cleaning up COM objects");
Marshal.ReleaseComObject(sheet);
Marshal.ReleaseComObject(sheets);
Marshal.ReleaseComObject(book);
Marshal.ReleaseComObject(books);
sheet = null;
sheets = null;
book = null;
books = null;
logger.Debug("closing excel application");
excel.Quit();
logger.Debug("final clean up and freeing of resources");
Marshal.ReleaseComObject(excel);
excel = null;
GC.GetTotalMemory(false);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.GetTotalMemory(true);
logger.Debug("sending content");
controller.CancelView();
controller.CancelLayout();
IResponse response = controller.Context.Response;
string attachment = String.Format("attachment; filename=\"{0}.xlsx\"", query.Title);
string contentLength = new FileInfo(filename).Length.ToString();
//.........这里部分代码省略.........
示例4: RenderFromTemplate
protected void RenderFromTemplate(String templateName, Controller controller)
{
StringWriter writer = new StringWriter();
IDictionary context = new Hashtable();
context.Add("flash", controller.Context.Flash);
foreach(DictionaryEntry entry in controller.PropertyBag)
{
context.Add(entry.Key, entry.Value);
}
#if USE_LOCAL_TEMPLATES
templateEngine.Process( context, templateName, writer );
#else
templateEngine.Process( context, "Castle.MonoRail.ActiveRecordScaffold/Templates/" + templateName, writer );
#endif
if (useDefaultLayout)
{
StringWriter layoutwriter = new StringWriter();
context.Add("childContent", writer.GetStringBuilder().ToString());
#if USE_LOCAL_TEMPLATES
templateEngine.Process(context, "layout.vm", layoutwriter);
#else
templateEngine.Process(context, "Castle.MonoRail.ActiveRecordScaffold/Templates/layout.vm", layoutwriter);
#endif
writer = layoutwriter;
controller.CancelView();
controller.Response.Write(writer.GetStringBuilder().ToString());
}
else
{
controller.DirectRender(writer.GetStringBuilder().ToString());
}
}