本文整理汇总了C#中Template.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Template.Save方法的具体用法?C# Template.Save怎么用?C# Template.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSalvar_Click
protected void btnSalvar_Click(object sender, EventArgs e)
{
var template = new Template();
try
{
if (txtId.Text != "")
{
template.IDTemplate = int.Parse(txtId.Text);
template.Get();
}
template.Descricao = txtNome.Text;
template.Chave = txtChave.Text;
template.Conteudo = txtConteudo.Text;
template.Save();
GetTemplate((int)template.IDTemplate);
Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>");
}
catch (Exception err)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>");
}
}
示例2: Insert
public void Insert(string Name,string Description,string StyleSheet,string CreatedBy,DateTime CreatedOn,string ModifiedBy,DateTime ModifiedOn)
{
Template item = new Template();
item.Name = Name;
item.Description = Description;
item.StyleSheet = StyleSheet;
item.CreatedBy = CreatedBy;
item.CreatedOn = CreatedOn;
item.ModifiedBy = ModifiedBy;
item.ModifiedOn = ModifiedOn;
item.Save(UserName);
}
示例3: Main
private static int Main(string[] args)
{
var myName = Environment.GetCommandLineArgs()[0];
myName = Path.GetFileNameWithoutExtension(string.IsNullOrWhiteSpace(myName)
? System.Reflection.Assembly.GetEntryAssembly().Location
: myName);
if (args.Length != 2)
{
Console.Write("Usage: " + myName + @" <template> <target>
<template> Path to the template file with [GITHASH] and [REVNO]
<target> Path to the target file (AssemblyInfo.cs)
");
return 1;
}
Console.WriteLine("Updating assembly info...");
var workingFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
var templateFile = args[0];
var targetFile = args[1];
var template = new Template(templateFile);
var clrHash = new CommandLineRunner();
var clrTags = new CommandLineRunner();
var gitPath = GetGitPath();
string exceptionMessage;
if (clrHash.RunCommandAndGetOutput(gitPath, "rev-parse --verify HEAD", workingFolder) &&
clrTags.RunCommandAndGetOutput(gitPath, "describe --tags", workingFolder))
{
try
{
template.Replace("[GITHASH]", clrHash.Result);
if (clrTags.Result.IndexOf('-') < 0)
clrTags.Result += "-0";
template.Replace("[REVNO]", clrTags.Result.Split('-')[1]);
template.Save(targetFile);
return 0;
}
catch (Exception ex)
{
exceptionMessage = ex.Message;
}
}
else
{
try
{
// allow to compile without git
Console.WriteLine("WARNING: Could not run Git - build number will be 9999!");
template.Replace("[GITHASH]", string.Empty);
template.Replace("[REVNO]", "9999");
template.Save(targetFile);
return 0;
}
catch (Exception ex)
{
exceptionMessage = ex.Message;
}
}
Console.WriteLine(myName + ": Could not update AssemblyInfo: " + exceptionMessage);
Console.WriteLine(" - Git folder: " + workingFolder);
Console.WriteLine(" - Template: " + templateFile);
Console.WriteLine(" - Target: " + targetFile);
return 1;
}
示例4: importTemplate
private void importTemplate(string templateData)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(templateData);
foreach (XmlNode templateNode in doc.SelectNodes("/export/template"))
{
string templateName = "";
if (templateNode != null && templateNode.Attributes["name"] != null && !String.IsNullOrEmpty(templateNode.Attributes["name"].Value))
templateName = templateNode.Attributes["name"].Value;
else
throw new Exception(Provider.GetResource("The attribute /template[@name] not found or not valid"));
string templatePath = Provider.MapPath("/" + templateName);
XmlNode codeNode = templateNode.SelectSingleNode("code");
string code = "";
if (codeNode != null && !String.IsNullOrEmpty(codeNode.InnerText))
code = CMSUtility.HtmlDecode(codeNode.InnerText.Trim());
else
throw new Exception(Provider.GetResource("The node /template/code not found or not valid"));
Provider.Database.Begin();
try
{
// sonra bu template'i ve içindeki modülleri silelim
Provider.DeleteTemplate(templateName, false);
// yeni template'i oluşturalım
Template t = new Template();
t.FileName = templateName;
t.HTMLCode = code;
t.Save();
// import edilen modülleri okuyalım
List<Module> modules = getModulesFromXML(templateNode.SelectSingleNode("modules"), null);
// bu modülleri kaydedelim
foreach (Module mdl in modules)
mdl.SaveACopyFor(templateName);
Provider.Database.Commit();
}
catch (Exception ex)
{
Provider.Database.Rollback();
throw ex;
}
}
}