当前位置: 首页>>代码示例>>C#>>正文


C# Template.Save方法代码示例

本文整理汇总了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>");
        }
    }
开发者ID:Didox,项目名称:MVC_e_Velocit_app,代码行数:24,代码来源:Template.aspx.cs

示例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);
        }
开发者ID:89sos98,项目名称:dashcommerce-3,代码行数:20,代码来源:TemplateController.cs

示例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;
        }
开发者ID:aisam97,项目名称:subtitleedit,代码行数:65,代码来源:Program.cs

示例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;
                }
            }
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:51,代码来源:SystemInfo.cs


注:本文中的Template.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。