/// <summary> /// Sendet eine Notification an alle Schuldner einer Rechnung mit dem Link zur Bestätigung /// </summary> /// <param name="bill"></param> /// <param name="billUrl"></param> public void SendBillReceivedNotification(Bill bill, string billUrl) { Require.NotNull(bill, "bill"); foreach (BillUserGroupDebitor billUserGroupDebitor in FindDebitorsToNotifyOnBillCreated(bill)) { string userEmail = billUserGroupDebitor.UserGroupMembership.User.Email; ModelMap modelMap = new ModelMap(); modelMap.Add("debitor", billUserGroupDebitor.UserGroupMembership.User); modelMap.Add("creditor", bill.Creditor.User); modelMap.Add("billUrl", billUrl); modelMap.Add("bill", bill); modelMap.Add("amount", bill.GetPartialAmountByPortion(billUserGroupDebitor.Portion)); MailMessage mailMessage = EmailService.CreateMailMessage(userEmail, modelMap, "BillReceived"); EmailService.SendMessage(mailMessage); } foreach (var billGuestDebitor in bill.GuestDebitors) { string userEmail = billGuestDebitor.Email; ModelMap modelMap = new ModelMap(); modelMap.Add("debitor", billGuestDebitor); modelMap.Add("creditor", bill.Creditor.User); modelMap.Add("billUrl", billUrl); modelMap.Add("bill", bill); modelMap.Add("amount", bill.GetPartialAmountByPortion(billGuestDebitor.Portion)); MailMessage mailMessage = EmailService.CreateMailMessage(userEmail, modelMap, "BillReceivedGuest"); EmailService.SendMessage(mailMessage); } }
public void SendPeanutUpdateRequirementsNotification(Peanut peanut, string updateComment, PeanutUpdateRequirementsNotificationOptions notificationOptions, User user) { Require.NotNull(peanut, "peanut"); Require.NotNull(notificationOptions, "notificationOptions"); Require.NotNull(user, "user"); if (string.IsNullOrWhiteSpace(updateComment)) { updateComment = "-"; } foreach (PeanutParticipation creditors in FindCreditorsToNotifyOnRequirementsChange(peanut, user)) { ModelMap modelMap = new ModelMap(); modelMap.Add("peanut", peanut); modelMap.Add("editor", user); modelMap.Add("recipient", creditors.UserGroupMembership.User); modelMap.Add("peanutUrl", notificationOptions.PeanutUrl); modelMap.Add("requirements", string.Join(Environment.NewLine, peanut.Requirements.Select(r => string.Format("<li>{0} {1}</li>", r.QuantityAndUnit, r.Name)))); modelMap.Add("updateComment", updateComment); MailMessage mailMessage = EmailService.CreateMailMessage(creditors.UserGroupMembership.User.Email, modelMap, "PeanutRequirementsUpdated"); EmailService.SendMessage(mailMessage); } }
public void Parse(ModelMap map, string filePath) { var replacement = new ModelMap(map.Name, map.Entity); _inner.Parse(replacement, filePath); map.ReplaceWith(replacement); }
private void removeProperties(ModelMap map, ModelMap overrides, ModelMapDiffOptions options) { options.Removals.Each(_ => executeRemoveInstruction(map, overrides, options, _)); var prunedInstructions = new List <IModelMapInstruction>(); var contexts = new Stack <IModelMapInstruction>(); foreach (var instruction in map.Instructions) { if (contexts.Count != 0) { var previous = contexts.Peek(); var previousType = previous.GetType(); if ((previousType == typeof(BeginRelation) && instruction.GetType() == typeof(EndRelation)) || (previousType == typeof(BeginAdHocRelation) && instruction.GetType() == typeof(EndRelation))) { prunedInstructions.Add(previous); prunedInstructions.Add(instruction); contexts.Pop(); continue; } } contexts.Push(instruction); } prunedInstructions.Each(map.RemoveInstruction); }
public void Visit(XElement element, ModelMap map, ParsingContext context) { var instruction = context.Serializer.Deserialize <BeginTransform>(element); map.AddInstruction(instruction); context.PushObject(instruction); }
public void Match_many_default() { var map = new ModelMap <TestEntity, TestItem>("items", (x, y) => x.Items = y); var entity = new TestEntity(); var guid1 = Guid.NewGuid(); var guid2 = Guid.NewGuid(); var guid3 = Guid.NewGuid(); var items = new[] { new TestItem { Key = guid1 }, new TestItem { Key = guid2 }, new TestItem { Key = guid3 } }; map.Match(entity, new [] { guid1.ToString("N"), guid2.ToString("N") }, items); Assert.That(entity.Items.Count(), Is.EqualTo(2)); Assert.That(entity.Items.First().Key, Is.EqualTo(guid1)); Assert.That(entity.Items.Skip(1).Take(1).First().Key, Is.EqualTo(guid2)); }
/// <summary> /// 创建地图 /// </summary> /// <param name="rowCount"></param> /// <param name="colCount"></param> /// <param name="boxWidth"></param> /// <param name="boxHeight"></param> /// <param name="line"></param> /// <param name="box"></param> /// <returns></returns> public static ModelMap GenMap(int rowCount, int colCount, int boxWidth, int boxHeight, Color line, Color box) { var map = new ModelMap { Row = rowCount, Column = colCount, Box = new ModelBox { Width = boxWidth, Height = boxHeight }, Line = line, Color = box, Body = new List <ModelElement>() }; #region 初始化地图实体 for (int ri = 0; ri < rowCount; ri++) { for (int ci = 0; ci < colCount; ci++) { map.Body.Add(new ModelElement { Abscissa = ri, Ordinate = ci }); } } #endregion return(map); }
public void Parse(ModelMap map, string filePath) { var overrides = new ModelMap(map.Name, map.Entity); _inner.Parse(overrides, filePath); _diff.Diff(map, overrides, _options); }
private static void PrintBase(Base baseToPrint, bool draft) { _log.Info("Print Controller printing Base: " + baseToPrint.Artifact.Name); var trimName = ModelMap.GetBaseFolderName(baseToPrint.TokenType, baseToPrint.TokenUnit, baseToPrint.RepresentationType); _outputFolder = ModelMap.FilePath + ModelMap.BaseFolder + ModelMap.FolderSeparator + trimName + ModelMap.FolderSeparator + ModelMap.Latest; _filePath = _outputFolder + ModelMap.FolderSeparator + trimName + ".docx"; try { Directory.CreateDirectory(_outputFolder); InitWorkingDocument(ModelMap.StyleSource); } catch (Exception ex) { _log.Error("Artifact Output Folder: " + _outputFolder + " cannot be created."); _log.Error(ex); return; } BasePrinter.PrintTokenBase(_document, baseToPrint, false); Utils.InsertCustomWatermark(_document, draft ? ModelMap.DraftWaterMark : ModelMap.WaterMark); Utils.AddFooter(_document, baseToPrint.Artifact.Name); Save(); }
private void TmControl_Tick(object sender, EventArgs e) { tmControl.Stop(); tmControl.Interval = _snake.Speed; _snake = MapHelper.MoveSnakeOnMap(palMap, _map, _snake, _direction); if (ConfigHelper.SnakeClimbNum == 0) { _map = MapHelper.ShowBonus(palMap, _map, _snake, ConfigHelper.BeanColor); } else if (ConfigHelper.SnakeClimbNum == ConfigHelper.BeanShowTime) { _map = MapHelper.HideBonus(palMap, _map); ConfigHelper.SnakeClimbNum = -1; } ConfigHelper.SnakeClimbNum++; ConfigHelper.i_playtime++; if (ConfigHelper.i_playtime == 500) { MessageBox.Show("Hi,young man, too long you have played !"); ConfigHelper.i_playtime = 0; } tmControl.Start(); }
/// <summary> /// 地图描边 /// </summary> /// <param name="panel"></param> /// <param name="map"></param> public static void DrawMap(Panel panel, ModelMap map) { #region 勾画地图 var g = panel.CreateGraphics(); #region 画横线 for (int ri = 0; ri <= map.Row; ri++) { g.DrawLine(new Pen(Color.Black), 0, ri * map.Box.Height, map.Column * map.Box.Width, ri * map.Box.Height); } #endregion #region 画竖线 for (int ci = 0; ci <= map.Column; ci++) { g.DrawLine(new Pen(Color.Black), ci * map.Box.Width, 0, ci * map.Box.Height, map.Row * map.Box.Width); } #endregion #region 勾画方块 foreach (var b in map.Body) { DrawMapBox(panel, map.Color, b.Abscissa, b.Ordinate, map.Box.Width, map.Box.Height); } #endregion #endregion }
public void SendPeanutUpdateStateNotification(Peanut peanut, PeanutUpdateNotificationOptions notificationOptions, User user) { Require.NotNull(peanut, "peanut"); Require.NotNull(notificationOptions, "notificationOptions"); if (peanut.PeanutState == PeanutState.Started) { /*Der Peanut wurde gestartet => alle Teilnehmer, außer den ändernden Nutzer benachrichtigen*/ foreach (PeanutParticipation peanutParticipation in FindParticipatorsToNotifyOnUpdate(peanut, user)) { ModelMap modelMap = new ModelMap(); modelMap.Add("peanut", peanut); modelMap.Add("editor", user); modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User); modelMap.Add("participation", peanutParticipation); modelMap.Add("peanutUrl", notificationOptions.PeanutUrl); MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email, modelMap, "PeanutStart"); EmailService.SendMessage(mailMessage); } } if (peanut.PeanutState == PeanutState.PurchasingDone) { /*Der Beschaffung der Voraussetzungen für den Peanut ist abgeschlossen => alle Produzenten, außer den ändernden Nutzer, benachrichtigen*/ foreach (PeanutParticipation peanutParticipation in FindProducersToNotifyOnPurchasingDone(peanut, user)) { ModelMap modelMap = new ModelMap(); modelMap.Add("peanut", peanut); modelMap.Add("editor", user); modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User); modelMap.Add("participation", peanutParticipation); modelMap.Add("peanutUrl", notificationOptions.PeanutUrl); MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email, modelMap, "PeanutPurchasingDone"); EmailService.SendMessage(mailMessage); } } if (peanut.PeanutState == PeanutState.Canceled) { /*Der Peanut wurde abgesagt => alle Teilnehmer, außer den ändernden Nutzer benachrichtigen*/ foreach (PeanutParticipation peanutParticipation in FindParticipatorsToNotifyOnUpdate(peanut, user)) { ModelMap modelMap = new ModelMap(); modelMap.Add("peanut", peanut); modelMap.Add("editor", user); modelMap.Add("recipient", peanutParticipation.UserGroupMembership.User); modelMap.Add("participation", peanutParticipation); modelMap.Add("peanutUrl", notificationOptions.PeanutUrl); MailMessage mailMessage = EmailService.CreateMailMessage(peanutParticipation.UserGroupMembership.User.Email, modelMap, "PeanutCanceled"); EmailService.SendMessage(mailMessage); } } }
public ModelFactory() { _assemblyMap = new ModelMap <string, NetAssembly>(); _typeMap = new ModelMap <string, NetType>(); _methodMap = new ModelMap <MethodKey, NetMethod>(); _methodParameterMap = new ModelMap <MethodParameterKey, NetMethodParameter>(); _propertyMap = new ModelMap <PropertyKey, NetProperty>(); }
/// <summary> /// Rendert eine MailMessage aus dem angegebenen Template und verwendet dabei die Daten aus dem Model. /// </summary> /// <param name="templateName">Name des Templates</param> /// <param name="model">Daten für das Template</param> /// <returns></returns> public string RenderMessage(string templateName, ModelMap model) { if (_mailMessages.ContainsKey(templateName)) { return(_mailMessages[templateName]); } return(_mailMessages["default"]); }
/// <summary> /// Erstellt ein EmailModel für das PasswordReset und gibt dieses zurück /// </summary> /// <param name="user"></param> /// <param name="baseLink"></param> /// <returns></returns> private ModelMap GetEmailModelForPasswordReset(User user, string baseLink) { ModelMap emailModel = new ModelMap(); emailModel.Add("user", user); emailModel.Add("baseLink", baseLink); return(emailModel); }
private ModelMap GetEmailModelForEmailConfirmation(string name, string confirmationLink) { ModelMap emailModel = new ModelMap(); emailModel.Add("name", name); emailModel.Add("confirmationLink", confirmationLink); return(emailModel); }
/// <summary> /// Initialisiert eine neue Instanz der <see cref="T:System.Object" />-Klasse. /// </summary> public PlaceholderModel(string placeholder, ModelMap modelMap) { _placeholderName = GetPlaceholderName(placeholder); _placeholderPath = GetPlaceholderPath(placeholder); object placeholderObject = GetPlaceholderValue(modelMap, PlaceholderName); _value = GetValueFromModelByPath(PlaceholderPath, placeholderObject); }
private object GetPlaceholderValue(ModelMap modelMap, string placeholderName) { if (modelMap.ContainsKey(placeholderName)) { return(modelMap[PlaceholderName]); } return(null); }
/// <summary> /// 蛇身描绘至地图 /// </summary> /// <param name="panel"></param> /// <param name="map"></param> /// <param name="snake"></param> /// <returns></returns> public static ModelSnake DrawSnakeOnMap(Panel panel, ModelMap map, ModelSnake snake) { snake = GenSnakeOnMap(map, snake); foreach (var b in snake.Body) { DrawMapBox(panel, snake.Color, b.Abscissa, b.Ordinate, map.Box.Width, map.Box.Height); } return(snake); }
/// <summary> /// Rendert eine Mailmessage aus dem angegebenen Template und verwendet dabei die Daten aus dem Model. /// </summary> /// <param name="templateName">Name des Templates</param> /// <param name="model">Daten für das Template</param> /// <returns></returns> /// <exception cref="FileNotFoundException">Falls das Template nicht gefunden wird.</exception> public string RenderMessage(string templateName, ModelMap model) { _log.DebugFormat("Render message für das Template {0}.", templateName); CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; string template = LoadMailMessageTemplate(templateName, cultureInfo); Templater templater = new Templater(cultureInfo); string evaluatedTemplate = templater.FormatTemplate(template, model); return(evaluatedTemplate); }
public ModelBuilder(ModelMap <MODEL> modelMap, IClarifyListCache listCache, ISchemaCache schemaCache, IOutputEncoder outputEncoder, IMapEntryBuilder mapEntryBuilder) { _modelMap = modelMap; _mapEntryBuilder = mapEntryBuilder; _outputEncoder = outputEncoder; _schemaCache = schemaCache; _listCache = listCache; FieldSortMapOverrides = new FieldSortMap[0]; }
public void Constructor_single() { var map = new ModelMap <TestEntity, TestItem>("Id", (x, y) => x.Item = y); Assert.That(map.SetModel, Is.Not.Null); Assert.That(map.Alias, Is.EqualTo("id")); Assert.That(map.ModelType, Is.EqualTo(typeof(TestItem))); Assert.That(!map.IsMany); Assert.That(map.IsMatch, Is.EqualTo(ModelMap.DefaultMatchKey)); }
public void ChildrenBound(ModelMap map, ParsingContext context) { var query = context.CurrentObject <IQueryContext>(); var instruction = query is BeginView ? (IModelMapInstruction) new EndView() : new EndTable(); map.AddInstruction(instruction); context.PopObject(); }
public HttpResponseMessage GetLessonsByAudithory(double audithory) { if (audithory > 2.0 || audithory < 0.0009) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Pelease insert only double; example 6.200")); } var list = ModelMap.LessonDomainToView(manager.getLessonsByAuditory(audithory)); var response = Request.CreateResponse <IEnumerable <LessonViewModel> >(HttpStatusCode.OK, list); return(response); }
public void Visit(XElement element, ModelMap map, ParsingContext context) { var instruction = context.Serializer.Deserialize <IncludePartial>(element); foreach (var attribute in element.Attributes().Where(_ => !_.Name.ToString().EqualsIgnoreCase("name"))) { instruction.Attributes.Add(attribute.Name.ToString(), new DynamicValue(attribute.Value)); } map.AddInstruction(instruction); }
/// <summary> /// Sendet eine Notification an den Nutzer mit der Information das sich ein Nutzer um eine Mitgliedschaft in einer /// Gruppe beworben hat. /// </summary> /// <param name="user"></param> /// <param name="urlToUserGroup"></param> public void SendRequestMembershipNotification(User user, string urlToUserGroup) { Require.NotNull(user, "user"); ModelMap modelMap = new ModelMap(); modelMap.Add("user", user); modelMap.Add("groupLink", urlToUserGroup); MailMessage mailMessage = EmailService.CreateMailMessage(user.Email, modelMap, "RequestMembership"); EmailService.SendMessage(mailMessage); }
public static ModelMap HideBonus(Panel panel, ModelMap map) { var ms = map.Body.Where(t => t.Bonus); foreach (var m in ms) { DrawMapBox(panel, map.Color, m.Abscissa, m.Ordinate, map.Box.Width, map.Box.Height); m.Bonus = false; } return(map); }
/// <summary> /// Sendet eine Notification an den Nutzer das er zu einer Mitgliedschaft in einer Gruppe eingeladen wurde /// </summary> /// <param name="user"></param> /// <param name="allMembershipsUrl"></param> public void SendUserGroupInvitationNotification(User user, string allMembershipsUrl) { Require.NotNull(user, "user"); ModelMap modelMap = new ModelMap(); modelMap.Add("user", user); modelMap.Add("groupLink", allMembershipsUrl); MailMessage mailMessage = EmailService.CreateMailMessage(user.Email, modelMap, "InviteMembership"); EmailService.SendMessage(mailMessage); }
public void Visit(XElement element, ModelMap map, ParsingContext context) { var query = context.Serializer.Deserialize <QueryElement>(element); var queryContext = query.Type == "view" ? (IModelMapInstruction) new BeginView(query.From) : new BeginTable(query.From); map.AddInstruction(queryContext); context.PushObject(queryContext); }
public bool Matches(ModelMap map, string filePath) { var doc = openFile(filePath); var overrides = doc.Root.Attribute("overrides"); if (overrides == null) { return(false); } return(map.Name.EqualsIgnoreCase(overrides.Value)); }