public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { if (databaseContext == null) { throw new ArgumentNullException(nameof(databaseContext)); } if (StringContext == null) { throw new Exception($"The provided {nameof(StringContext)} is null"); } ITableModel table = databaseContext.Table; if (table == null) { throw new Exception($"The {nameof(TableModel)} is not set"); } string TrimedStringContext = TrimContextFromContextWrapper(StringContext); if (!(table?.Columns ?? new List <IColumnModel>()).Any(m => m.IsIndexed)) { return(String.Empty); } var result = TemplateHandler. HandleFunctionTemplate (TrimedStringContext, DatabaseContextCopier.CopyWithOverride(databaseContext, table)); return(result); }
private void LoadSelectedTemplate() { string description = (string)templateListBox.SelectedValue; TemplateHandler.LoadTemplateByDescription(description); Close(); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { ControlContext(StringContext, databaseContext); ITableModel table = databaseContext.Table; if (table == null) { throw new Exception($"The {nameof(table)} is not set"); } if (table.Columns == null) { throw new Exception($"The {nameof(table.Columns)} are not set in {nameof(table)}"); } if (table.Columns.Any(m => m == null)) { throw new Exception($"There is a null reference in the {nameof(table.Columns)} from {nameof(table)}"); } string TrimedStringContext = TrimContextFromContextWrapper(StringContext); var indexedColumns = table.Columns.Where(m => m.IsIndexed); var eachIndexedcolumnResult = indexedColumns .Select(currentColumn => TemplateHandler.HandleTemplate(TrimedStringContext, DatabaseContextCopier.CopyWithOverride(databaseContext, currentColumn))); var result = string.Join(string.Empty, eachIndexedcolumnResult); return(result); }
private void SaveToolStripMenuItem_Click(object sender, EventArgs e) { if (this.currentFile != null) { if (this.currentFile.treeHandler.Tree.IsTemplate == false) { this.saveFileDialog1.FileName = this.currentFile.tabPage.Name + ".tree"; this.saveFileDialog1.Filter = "Tree File|*.tree"; if (this.currentFile.savePath != null) { this.saveFileDialog1.InitialDirectory = this.currentFile.savePath; } if (this.saveFileDialog1.ShowDialog() == DialogResult.OK) { if (this.saveFileDialog1.FileName.Trim().Length > 0) { this.currentFile.SaveTree(this.saveFileDialog1.FileName); this.currentFile.state = PageState.Save; } } } else { TemplateHandler.getInstance().setBaseTrees(this.baseTrees); this.currentFile.state = PageState.Save; } } }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { if (databaseContext == null) { throw new ArgumentNullException(nameof(databaseContext)); } if (StringContext == null) { throw new Exception($"The provided {nameof(StringContext)} is null"); } ITableModel table = databaseContext.Table; if (table == null) { throw new Exception($"The {nameof(TableModel)} is not set"); } string TrimedStringContext = TrimContextFromContextWrapper(StringContext); var autoGeneratedValueColumns = table.Columns.Where(m => m.IsAutoGeneratedValue).ToList(); var result = string.Join(string.Empty, autoGeneratedValueColumns.Select(currentColumn => TemplateHandler.HandleTemplate(TrimedStringContext, DatabaseContextCopier.CopyWithOverride(databaseContext, currentColumn)))); return(result); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { ControlContext(StringContext, databaseContext); var visitedTablesStack = new List <List <ITableModel> >(); var currentVisitedTables = new List <ITableModel>() { databaseContext.Table }; while (currentVisitedTables.Any()) { visitedTablesStack = visitedTablesStack.Append(currentVisitedTables).ToList(); var extractionResults = ExtractForeignTables(databaseContext.Database, currentVisitedTables); currentVisitedTables = extractionResults.SelectMany(m => m.Item2).Reverse().ToList(); } var tableAndDepth = visitedTablesStack.SelectMany( (currentList, depth) => currentList.Select(current => Tuple.Create(current, depth))).Skip(1).Reverse().ToList(); string trimedStringContext = TrimContextFromContextWrapper(StringContext); var result = string.Join(string.Empty, tableAndDepth.Select(tableAndDepth => TemplateHandler.HandleTemplate(trimedStringContext, DatabaseContextCopier.CopyWithOverride(databaseContext, tableAndDepth.Item1)))); return(result); }
/// <summary> /// when the selected template to edit changes /// </summary> protected void OnEditChanged() { if (SelectedAddOrEdit()) { // selected new = clear inputs txtEditName.Text = txtEditPathsExclude.Text = txtEditPaths.Text = txtTypeFilter.Text = lblLastUsed.Text = ""; chbInvertType.Checked = false; } else { // selected existing = show values of this template BackupTemplate template = TemplateHandler.GetTemplateByName(cmbTemplatesEdit.Text); if (template == null) { SendOutput("[Templates] Selected template doesn't exist", true); return; } txtEditName.Text = template.BackupName; // append "," for adding new values txtEditPaths.Text = template.GetBackupPathsString() + ","; txtEditPathsExclude.Text = template.GetExcludePathsString() + ","; txtTypeFilter.Text = template.GetTypeFilterString() + ","; chbInvertType.Checked = template.TypeInverted; lblLastUsed.Text = template.LastUsed.ToString(); } // show buttons DisplayDeleteButton(); }
public override string PrepareProcessor(string TrimmedStringContext) { if (!regex.IsMatch(TrimmedStringContext)) { return($"{{:TDB:PREPROCESSOR:MAPPING:WARNING:NOT:HANDLED({TrimmedStringContext}):PREPROCESSOR:WARNING:NOT:HANDLED:}}"); } var headerMatches = mappingHeaderRegex.Matches(TrimmedStringContext); var headerMatch = headerMatches.FirstOrDefault(); var headerAsString = ExtractMatch(headerMatch, TrimmedStringContext); string destinationTypeSetName = ToDestinationTypeSetName(headerAsString); var trimmedContextWithoutHeader = TrimmedStringContext.Substring(headerMatch.Index + headerMatch.Length); trimmedContextWithoutHeader = trimmedContextWithoutHeader.Substring(0, trimmedContextWithoutHeader.Length - 1); var items = ToTypeMappingItems(trimmedContextWithoutHeader).ToList(); TemplateHandler.OverwriteTypeMapping(new[] { new TypeMapping() { SourceTypeSetName = DatabaseModel?.TypeSetName ?? "UnknownTypeSet", DestinationTypeSetName = destinationTypeSetName, TypeMappingItems = items } }); return(string.Empty); }
static void Main(string[] args) { TemplateHandler templatetest = new TemplateHandler(); templatetest.RegisterHooks("templatetest"); templatetest.ResponseMime = "text/plain"; templatetest.TemplateText = "Template test. Query parameters: {{query}}"; templatetest.GetHandler += templatetest_GetHandler; EmbeddedHttpServer server = new EmbeddedHttpServer(8080); server.Path = Environment.CurrentDirectory; server.Handlers.Add(templatetest); server.LogDir = Path.Combine(Environment.CurrentDirectory, "Log"); server.AppPackages.Add(Path.Combine(Environment.CurrentDirectory, "webdev.zip")); server.Start(); Console.WriteLine("Server running. Press ESC to quit"); ConsoleKeyInfo key; do { key = Console.ReadKey(); }while (key.Key != ConsoleKey.Escape); server.Stop(); }
public override string HandleTrimedContext(string StringTrimedContext, IDatabaseContext databaseContext) { if (StringTrimedContext == null) { return(null); } return(TemplateHandler.HandleTemplate(StringTrimedContext, databaseContext)); }
private void PrintSelectedBtn_Click(object sender, EventArgs e) { TemplateHandler CertificateTemplate = new TemplateHandler(); string CertificatesTable = CertificateTemplate.FillTemplate(this.SelectedCertificatesList); RegistryPrintForm PrintRegistry = new RegistryPrintForm(CertificatesTable); PrintRegistry.ShowDialog(); this.ClearHideSelectedList(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = Convert.ToInt32(Request.QueryString["id"]); TemplateHandler handler = new TemplateHandler(); SmsTemplateInfo info = handler.GetTemplateInfo(id); template = info.SmsContent; tid = info.ID.ToString(); Page.DataBind(); } }
private void PrintAllBtn_Click(object sender, EventArgs e) { Certificate GetCertificates = new Certificate(); IList <CertificatesListItem> Certificates = GetCertificates.GetCertificatesRegistry(); TemplateHandler CertificateTemplate = new TemplateHandler(); string CertificatesTable = CertificateTemplate.FillTemplate(Certificates); RegistryPrintForm PrintRegistry = new RegistryPrintForm(CertificatesTable); PrintRegistry.ShowDialog(); }
static void templatetest_GetHandler(object sender, HTTPEventArgs e) { TemplateHandler template = (TemplateHandler)sender; if (e.Parameters != null) { template.TemplateTags.Add("query", e.Parameters.ToString()); } else { template.TemplateTags.Add("query", "No query parameters specified"); } }
public void Initialize() { _person = new Person { Id = Guid.Parse("7AEC12CD-FD43-49DD-A2AB-3CDD19A3A5F4"), Birthday = new DateTimeOffset(new DateTime(1980, 1, 1)), Firstname = "John", Lastname = "Doe" }; _linkBuilderMock = new Mock <ILinkBuilder>(MockBehavior.Strict); _handler = new TemplateHandler(); }
public CreatureTemplateWindow() { InitializeComponent(); if (openWindow != null) { openWindow.Close(); } openWindow = this; Closing += CreatureTemplateWindow_Closing; templateListBox.ItemsSource = TemplateHandler.ListTemplateDescriptions(); templateListBox.MouseDoubleClick += TemplateListBox_MouseDoubleClick; templateListBox.SelectedIndex = 0; }
public static void AddTownProperties(MapObject mpobjTown, TemplateHandler thTemplate, int iTownNumber, int iZoneIndex) { string[] strPropertiesNames = Enum.GetNames(typeof(eTown)); foreach (string strProperty in strPropertiesNames) { //add property mpobjTown.ObjectSpacificProperties.Add(strProperty, thTemplate.GetTownsAttributes(iZoneIndex, iTownNumber, strProperty)); } //todo: Add Player Assaign string strPlayerID = thTemplate.getPlayerIdPerZone(iZoneIndex); mpobjTown.ObjectSpacificProperties.Add("PlayerId", strPlayerID); }
public override string HandleTrimedContext(string StringTrimedContext, IDatabaseContext databaseContext) { if (StringTrimedContext == null) { return(null); } IForeignKeyConstraintModel constraint = databaseContext.ForeignKeyConstraint; if (constraint == null) { return(StringTrimedContext); //TODO Strange } return(TemplateHandler.HandleTemplate(StringTrimedContext, databaseContext)); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { try { var user = await UserManager.FindByNameAsync(model.Email); if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id))) { // Don't reveal that the user does not exist or is not confirmed return(View("ForgotPasswordConfirmation")); } var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { UserId = user.Id, code = code }, protocol: Request.Url.Scheme); TemplateCreateOptions templateCreateOptions = new TemplateCreateOptions() { TemplateModel = new ForgotPasswordEmailModel() { FirstName = user.FirstName, LastName = user.LastName, CallBackURL = callbackUrl }, TemplateName = ForgotPasswordEmailModel.ForgotPasswordEmailName }; string[] recipents = { user.Email }; string body = TemplateHandler.Create(templateCreateOptions); _mailClient.SendMail("Forgot Password", recipents, body, null); return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } catch (Exception Ex) { throw Ex; } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); //return RedirectToAction("ForgotPasswordConfirmation", "Account"); } // If we got this far, something failed, redisplay form return(View(model)); }
public override string HandleTrimedContext(string StringTrimedContext, IDatabaseContext databaseContext) { if (StringTrimedContext == null) { return(null); } IColumnModel columnModel = databaseContext.Column; if (columnModel == null) { return(StringTrimedContext); } return(TemplateHandler. HandleTemplate(StringTrimedContext, databaseContext)); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { ControlContext(StringContext, databaseContext); ITableModel table = databaseContext.Table; string TrimedStringContext = TrimContextFromContextWrapper(StringContext); var columns = table.Columns; if (columns == null) { throw new ArgumentException($"{table.Columns} are not set for {nameof(table)}"); } var notAutoGeneratedColumn = columns.Where(currentColumn => currentColumn.IsNotNull).ToList(); var result = string.Join(string.Empty, notAutoGeneratedColumn.Select(currentColumn => TemplateHandler.HandleTemplate(TrimedStringContext, DatabaseContextCopier.CopyWithOverride(databaseContext, currentColumn)))); return(result); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { ControlContext(StringContext, databaseContext); ITableModel table = databaseContext.Table; string trimedStringContext = TrimContextFromContextWrapper(StringContext); var constraints = table.ForeignKeyConstraints; if (constraints == null) { throw new ArgumentNullException(nameof(table.ForeignKeyConstraints)); } var result = string.Join(string.Empty, constraints.Select(constraint => TemplateHandler.HandleTemplate(trimedStringContext, DatabaseContextCopier.CopyWithOverride(databaseContext, constraint)))); return(result); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { ControlContext(StringContext, databaseContext); ITableModel table = databaseContext.Table; string TrimedStringContext = TrimContextFromContextWrapper(StringContext); if (!(table?.Columns ?? new List <IColumnModel>()).Any(m => m.IsAutoGeneratedValue)) { return(String.Empty); } var result = TemplateHandler. HandleFunctionTemplate (TrimedStringContext, DatabaseContextCopier.CopyWithOverride(databaseContext, table)); return(result); }
private bool MakeBackup(string targetPath, string backupname, bool onlyChanged) { BackupTemplate template = TemplateHandler.GetTemplateByName(backupname); if (template == null) { communication.SendOutput("[Backup] " + (backupname ?? "NULL") + " template does not exist", true); return(false); } if (string.IsNullOrEmpty(targetPath)) { communication.SendOutput("[Backup] Destination folder does not exist: ", true); return(false); } try { // create destination, for sorting in explorer format year, month, day targetPath += "\\" + template.BackupName + "_" + DateTime.Now.ToString("yyyy_MM_dd"); if (onlyChanged) { targetPath += "_INC"; } // if backup does already exist add hour + minute if (Directory.Exists(targetPath)) { targetPath += "_" + DateTime.Now.ToString("HH_mm"); } Directory.CreateDirectory(targetPath); } catch { communication.SendOutput("[Backup] Could not create destination folder at " + targetPath, true); return(false); } communication.OnBackupProgressChanged("Started " + backupname); // copy files and folders CopyDirectories(template, targetPath, onlyChanged); AddUsedTemplate(targetPath, template); communication.SendOutput("[Backup] Saved at: " + targetPath); return(true); }
public override string HandleTrimedContext(string StringTrimedContext, IDatabaseContext databaseContext) { if (StringTrimedContext == null) { return(null); } if (databaseContext == null) { throw new ArgumentNullException(nameof(databaseContext)); } ITableModel table = databaseContext.Table; if (table == null) { return(StringTrimedContext); } return(TemplateHandler. HandleTemplate(StringTrimedContext, databaseContext)); }
public async Task <ActionResult> ConfirmEmailSendLink(ForgotPasswordViewModel model) { if (ModelState.IsValid) { try { var user = await UserManager.FindByNameAsync(model.Email); //if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id))) if (user == null) { // Don't reveal that the user does not exist return(View("ConfirmEmailSendLinkConfirmation")); } var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); TemplateCreateOptions templateCreateOptions = new TemplateCreateOptions() { TemplateModel = new ConfirmEmailModel() { FirstName = user.FirstName, LastName = user.LastName, CallBackURL = callbackUrl }, TemplateName = ConfirmEmailModel.ConfirmEmailName }; string[] recipents = { user.Email }; string body = TemplateHandler.Create(templateCreateOptions); _mailClient.SendMail("Email Confirmation", recipents, body, null); return(RedirectToAction("ConfirmEmailSendLinkConfirmation", "Account")); } catch (Exception Ex) { throw Ex; } } // If we got this far, something failed, redisplay form return(View(model)); }
public override string ProcessContext(string StringContext, IDatabaseContext databaseContext) { if (databaseContext == null) { throw new ArgumentNullException(nameof(databaseContext)); } if (StringContext == null) { throw new Exception($"The provided {nameof(StringContext)} is null"); } IColumnModel column = databaseContext.Column; if (column == null) { throw new Exception($"The {nameof(ColumnModel)} is not set"); } string TrimedStringContext = TrimContextFromContextWrapper(StringContext); if (TrimedStringContext == "") { throw new Exception("There is a problem with the function provided in template '" + (StartContext + TrimedStringContext + EndContext) + "' -> The value parameter cannot be empty"); } InitConversionHandlerMap(); if (!DestinationTypeSets.Contains(TrimedStringContext.ToLowerInvariant())) { return($"CONVERT:UNKNOWN({TrimedStringContext})"); } if (conversionMap.TryGetValue(new MappingKey() { DestinationTypeSet = TrimedStringContext.ToLowerInvariant(), SourceType = column.Type }, out var result)) { var processedResult = TemplateHandler.HandleTableColumnTemplate(result, DatabaseContextCopier.CopyWithOverride(databaseContext, column)); return(processedResult); } return(column.Type); }
public Attachment CreateAdaptiveCardAttachment(string filePath, object data = null) { var adaptiveCardJson = string.Empty; if (data != null) { adaptiveCardJson = TemplateHandler.RenderFile(filePath, data); } else { adaptiveCardJson = File.ReadAllText(filePath); } var adaptiveCardAttachment = new Attachment() { ContentType = "application/vnd.microsoft.card.adaptive", Content = JsonConvert.DeserializeObject(adaptiveCardJson), }; return(adaptiveCardAttachment); }
/// <summary> /// 退出 /// </summary> private void quit() { NodeHandler.getInstance().setBaseNodes(this.baseNodes); PreconditionHandler.getInstance().setBasePreconditions(this.basePreconditions); TemplateHandler.getInstance().setBaseTrees(this.baseTrees); if (this.currentFile != null && this.currentFile.savePath != null && this.currentFile.isTemplate == false) { PageHandler.getInstance().setLastPage(this.currentFile.savePath); } if (this.openFiles != null && this.openFiles.Count > 0) { foreach (var item in this.openFiles) { if (item.savePath != null && item.savePath.Length > 0) { item.SaveTree(item.savePath); } } } }
private void MainForm_Load(object sender, EventArgs e) { //初始化数据 this.openFiles = new List <Page>(); this.basePreconditions = PreconditionHandler.getInstance().getBasePreconditions(); if (this.basePreconditions == null) { this.basePreconditions = new List <Precondition>(); } this.baseNodes = NodeHandler.getInstance().getBaseNodes(); if (this.baseNodes == null) { this.baseNodes = new List <Node>(); } this.baseTrees = TemplateHandler.getInstance().getBaseTrees(); if (this.baseTrees == null) { this.baseTrees = new List <Tree>(); } //数据源绑定 this.NodeListBoxDataBinding(); this.PreconditionListBoxDataBinding(); this.TemplateListBoxDataBinding(); //显示 this.toolStripStatusLabel1.Text = "版本: 1.0.1.0"; //加载最后修改文件 string path = PageHandler.getInstance().getLastPage(); if (path != null && path.Length > 0 && File.FileIsExist(path)) { Page page = new Page(path); this.tabControl2.TabPages.Add(page.tabPage); this.tabControl2.SelectedTab = page.tabPage; this.openFiles.Add(page); this.currentFile = page; } }
public CriteriaTemplate AddTemplate(string key, TemplateHandler value) { m_Template.Add(key, value); return this; }
public static CriteriaTemplate Create(string key, TemplateHandler value) { return new CriteriaTemplate().AddTemplate(key, value); }