public EventChain Create(string name) { if (Directory.Exists(GetEventPath() + name)) { Directory.Delete(GetEventPath() + name, true); } Directory.CreateDirectory(GetEventPath() + name); var eventChain = new EventChain(name); _EventChains.Add(eventChain); EventAdd?.Invoke(eventChain); return(eventChain); }
public virtual Task <HttpStatusCode> SendEmailAddNew(EventSubmission eventSubmission) { var messageSubject = $"[Event date] - {eventSubmission.EventDate.Value.ToString("d MMMM yyyy")}, [Event] - {eventSubmission.Title}"; _logger.LogInformation("Sending event submission form email"); var attachments = new List <IFormFile>(); if (eventSubmission.Image != null) { attachments.Add(eventSubmission.Image); } if (eventSubmission.Attachment != null) { attachments.Add(eventSubmission.Attachment); } var imagePath = FileHelper.GetFileNameFromPath(eventSubmission.Image); var attachmentPath = FileHelper.GetFileNameFromPath(eventSubmission.Attachment); var emailBody = new EventAdd { Title = eventSubmission.Title, EventDate = eventSubmission.EventDate.HasValue ? ((DateTime)eventSubmission.EventDate).ToString("dddd dd MMMM yyyy") : "-", EndDate = eventSubmission.EndDate.HasValue ? ((DateTime)eventSubmission.EndDate).ToString("dddd dd MMMM yyyy") : "-", StartTime = eventSubmission.StartTime.HasValue ? ((DateTime)eventSubmission.StartTime).ToString("HH:mm") : "-", EndTime = eventSubmission.EndTime.HasValue ? ((DateTime)eventSubmission.EndTime).ToString("HH:mm") : "-", Frequency = !string.IsNullOrEmpty(eventSubmission.Frequency) ? eventSubmission.Frequency : "-", Fee = !string.IsNullOrEmpty(eventSubmission.Fee) ? eventSubmission.Fee : "-", Location = !string.IsNullOrEmpty(eventSubmission.Location) ? eventSubmission.Location : "-", SubmittedBy = !string.IsNullOrEmpty(eventSubmission.SubmittedBy) ? eventSubmission.SubmittedBy : "-", Description = !string.IsNullOrEmpty(eventSubmission.Description) ? eventSubmission.Description : "-", ImagePath = !string.IsNullOrEmpty(imagePath) ? imagePath : "-", AttachmentPath = !string.IsNullOrEmpty(attachmentPath) ? attachmentPath : "-", SubmitterEmail = !string.IsNullOrEmpty(eventSubmission.SubmitterEmail) ? eventSubmission.SubmitterEmail : "-", Categories = eventSubmission.CategoriesList, GroupName = string.IsNullOrEmpty(eventSubmission.GroupName) ? string.Empty : $"Group name: {eventSubmission.GroupName}", Occurrences = eventSubmission.Occurrences == 0 ? string.Empty : $"(occurs {eventSubmission.Occurrences} times)", }; return(_emailClient.SendEmailToService(new EmailMessage(messageSubject, _emailClient.GenerateEmailBodyFromHtml(emailBody), _fromEmail, _configuration.GetEventSubmissionEmail(_businessId.ToString()).ToString(), eventSubmission.SubmitterEmail, attachments))); }
private Delegate CreateDelegate(Type delegateType) { Type[] methodArgs = { typeof(EventAdd <T>), typeof(object), typeof(T) }; DynamicMethod handleEvent = new DynamicMethod( "HandleEventMethode", null, methodArgs, typeof(FromEventSubject <T>).Module); MethodInfo addValueInfo = typeof(EventAdd <T>).GetMethod("AddValue", BindingFlags.Public | BindingFlags.Instance); ILGenerator ilGenerator = handleEvent.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldarg_0); ilGenerator.Emit(OpCodes.Ldarg_1); ilGenerator.Emit(OpCodes.Ldarg_2); ilGenerator.EmitCall(OpCodes.Call, addValueInfo, null); ilGenerator.Emit(OpCodes.Ret); EventAdd <T> eventadd = new EventAdd <T>(); eventadd.subject = this; //handleEvent.Invoke(eventadd, new object[] { eventadd, new object(), new EventArgs() }); return(handleEvent.CreateDelegate(delegateType, eventadd)); }
public IActionResult Add([FromBody] EventAdd model) { Event temp = new Event(); temp.Title = model.Title; temp.TitleURL = model.TitleURL; temp.ShortDescription = model.ShortDescription; temp.Description = model.FullDescription; temp.CountryId = (int)model.Country.Id; temp.Location = model.Location; temp.EventCategoryId = (int)model.Category.Id; temp.EventTypeId = (int)model.EventType.Id; temp.From = model.FromDate; temp.To = model.ToDate; temp.DatePublished = model.DatePublished; temp.SourceUrl = model.Url; bool status = eventService.Create(temp); if (model.NewTags != null) { if (model.NewTags.Count() > 0) { foreach (SimpleItem item in model.NewTags) { if (item.Id == null) { Tag tempTag = tagService.Read(item.Name, (int)TagGroupType.Event_Search); if (tempTag == null) { Tag tag = new Tag(); tag.Name = item.Name; tag.TagGroupId = (int)TagGroupType.Event_Search; tagService.Create(tag); item.Id = tag.TagId; } else { item.Id = tempTag.TagId; } } EventTag eventTag = new EventTag(); eventTag.EventId = temp.EventId; eventTag.TagId = (int)item.Id; eventTagService.Create(eventTag); } } if (model.DeletedTags.Count() > 0) { foreach (SimpleItem item in model.DeletedTags) { EventTag eventTag = new EventTag(); eventTag.EventId = temp.EventId; eventTag.TagId = (int)item.Id; eventTagService.Delete(eventTag); } } } return(new StatusCodeResult(status ? 200 : 409)); }
/// <summary> /// 发送选中学生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Add_Click(object sender, RoutedEventArgs e) { EventAdd?.Invoke(StudentList[0] as DataSystem.DB.Student); Combobox_StudentList.Text = ""; }