public static void TriggerEvent(EventsName eventName) { UnityEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(); } }
public static void StopListening(EventsName eventName, UnityAction listener) { if (eventManager == null) { return; } UnityEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void StartListening(EventsName eventName, UnityAction listener) { UnityEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new UnityEvent(); thisEvent.AddListener(listener); instance.eventDictionary.Add(eventName, thisEvent); } }
public ActionResult Create(EventsName EventsName) { if (EventsName != null) { using (UOW uow = new UOW()) { EventsName eventsName = uow._iEventsRepository.Get().ToList().Where(x => x.EventName.ToLower() == EventsName.EventName.ToLower()).FirstOrDefault(); if (eventsName == null) { uow._iEventsRepository.Add(EventsName); uow.SaveChanges(); } } } return(RedirectToAction("Create", "Info")); }
/// <summary> /// The submit button click event handler. /// </summary> /// <param name="sender">Calling control.</param> /// <param name="e">Event arguments.</param> void submit_Click(object sender, EventArgs e) { if (LimitForEventReached && currentEvent != null) { Terminate = true; } if (currentEvent == null && !SingleWidgetPerEachEvent && IncludeCheckoutPage) { Terminate = true; } if (IncludeCheckoutPage && ProductId == Guid.Empty && !SingleWidgetPerEachEvent) { Terminate = true; } if (!Terminate) { if (currentEvent == null && SingleWidgetPerEachEvent) { //Check whether an Event with the given name already exists Event tempEvent = eventsManager.GetEvents().Where(ev => (ev.Title == EventsName && ev.Status == ContentLifecycleStatus.Live)).FirstOrDefault(); ProductId = ProductIdWidget; if (tempEvent != null) { currentEvent = tempEvent; //Check whether the max attendees number has been changed. If so, update it. if (int.Parse(currentEvent.GetValue(FieldMaxAttendees).ToString()) != MaxAttendeesWidget && int.Parse(currentEvent.GetValue(FieldMaxAttendees).ToString()) != 0) { Event master = eventsManager.Lifecycle.GetMaster(currentEvent) as Event; // We have to suppress security since the current request is not authenticated yet and won't be allowed to modify the event. using (new ElevatedModeRegion(eventsManager)) { // Check whether the item exists if (master != null) { // Use the singular facade to modify the master by the master ID App.WorkWith().Event(master.Id).CheckOut().Do(ev => { ev.SetValue(FieldMaxAttendees, MaxAttendeesWidget); }) .CheckIn().Publish().SaveChanges(); } } } } else { // We have to suppress security since the current request is not authenticated yet and won't be allowed to create an event. using (new ElevatedModeRegion(eventsManager)) { // Create the event currentEvent = eventsManager.CreateEvent(Guid.NewGuid()); // Set the event properties currentEvent.Title = EventsName; //If MaxAttendeesWidget == 0, there are no limitations for this event. if (MaxAttendeesWidget == 0) { MaxAttendeesWidget = 10000; } currentEvent.SetValue(FieldMaxAttendees, MaxAttendeesWidget); currentEvent.SetValue(FieldCurrAttendees, currentAttendees); currentEvent.UrlName = Regex.Replace(EventsName.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); currentEvent.PublicationDate = DateTime.Today; currentEvent.ExpirationDate = DateTime.Today.AddDays(365); currentEvent.ApprovalWorkflowState = "Draft"; currentEvent.Status = ContentLifecycleStatus.Master; // Save the changes eventsManager.SaveChanges(); } // Save as a Draft //var bag = new Dictionary<string, string>(); //bag.Add("ContentType", typeof(Event).FullName); //WorkflowManager.MessageWorkflow(currentEvent.Id, typeof(Event), null, "Draft", false, bag); } } //Holds the message content var msgContent = new StringBuilder(); if (IncludeNotification) { //Reads the fields controls on the form and stores the information in the msgContent StringBuilder foreach (var fieldControl in this.FieldControls) { if (fieldControl is FormTextBox) { msgContent.Append(String.Format("<p><strong>{0}:</strong> {1}</p>", ((FormTextBox)fieldControl).Title, ((FormTextBox)fieldControl).Value)); if (((FormTextBox)fieldControl).Title.ToLower().Contains("email") || ((FormTextBox)fieldControl).Title.ToLower().Contains("e-mail") || ((FormTextBox)fieldControl).Title.ToLower().Contains("e mail")) { _clientEmailField = ((FormTextBox)fieldControl).Value.ToString().Trim(); } } else if (fieldControl is FormParagraphTextBox) { msgContent.Append(String.Format("<p><strong>{0}:</strong> {1}</p>", ((FormParagraphTextBox)fieldControl).Title, ((FormParagraphTextBox)fieldControl).Value)); } else if (fieldControl is FormCheckboxes) { string choices = ((List <String>)((FormCheckboxes)fieldControl).Value).Aggregate(string.Empty, (current, item) => current + String.Format("{0},", item)); msgContent.Append(String.Format("<p><strong>{0}:</strong> {1}</p>", ((FormCheckboxes)fieldControl).Title, choices)); } else if (fieldControl is FormChoiceField) { msgContent.Append(String.Format("<p><strong>{0}:</strong> {1}</p>", ((FormChoiceField)fieldControl).Title, ((FormChoiceField)fieldControl).Value)); } else if (fieldControl is FieldControl) { var fldControl = fieldControl as FieldControl; msgContent.Append(String.Format("<p><strong>{0}:</strong> {1}</p>", fldControl.Title, fldControl.Value)); } } } if (!LimitForEventReached) { try { //Send the email(s) var isMsgSent = SendEmailMsg(FromAddress, ToAddresses, MailSubject, msgContent.ToString()); } catch (Exception ex) { } int currAttendees = int.Parse(currentEvent.GetValue(FieldCurrAttendees).ToString()); IncreaseAttendeesNumber(++currAttendees); //If the event is paid, add the event to the shopping cart if (IncludeCheckoutPage && ProductId != Guid.Empty) { AddEventToCart(currentEvent); } } } }