public string NewTemplate(NSTemplateInfo nsTemplateInfo)
        {
            if (string.IsNullOrEmpty(nsTemplateInfo.TemplateName) ||
                string.IsNullOrWhiteSpace(nsTemplateInfo.TemplateText) ||
                string.IsNullOrWhiteSpace(nsTemplateInfo.TemplateType))
            {
                return("模板名称/模板内容/模板类型不能为空!");
            }


            TemplateRepository templateRespository = new TemplateRepository(Context);


            string version        = templateRespository.GetTemplateVersion(nsTemplateInfo.TemplateName, nsTemplateInfo.TemplateType);
            int    tempateVersion = -1;

            int.TryParse(version, out tempateVersion);
            nsTemplateInfo.Version = "1.0.0.1";//  (++tempateVersion).ToString();


            if (templateRespository != null)
            {
                templateRespository.Add(nsTemplateInfo);
                templateRespository.SaveChage();
            }

            return(string.Empty);
        }
Exemple #2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            TemplateModel template = new TemplateModel();

            template.Name      = txtName.Text;
            template.Positions = _lstPositionModel;
            _templateRepository.Add(template);
            this.Close();
        }
        private void DelAll()
        {
            if (DialogResult.Yes == MessageBox.Show("You want to delete all template?", "Messenge alert!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
            {
                try
                {
                    Utilities.ResetAll(_templateRepository._nameFile);

                    TemplateModel _TemplateModel = new TemplateModel();
                    _templateRepository.Add(_TemplateModel);
                    GetAll();
                    myFlagChange(true);
                    MessageBox.Show("Deleted all tempaltes!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error " + ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Canceled delete all templates!");
            }
        }