private void GoToGist(EventModel.GistEvent gist) { var vm = this.CreateViewModel<GistViewModel>(); vm.Id = gist.Gist.Id; vm.Gist = gist.Gist; NavigateTo(vm); }
protected void Page_Load(object sender, EventArgs e) { var item = Sitecore.Context.Database.GetItem(Constants.Pages.MyAccountEvents); MyAccountItem context = (MyAccountItem)Sitecore.Context.Item; hypEventsTab.NavigateUrl = Sitecore.Context.Database.GetItem(Constants.Pages.WhatsHappening).GetUrl(); hypEventsTab.Text = context.UpcomingEventsLinkText; var events = SearchHelper.GetUpcomingEvents(2).ToList(); List<EventModel> eventsDataSource = new List<EventModel>(); foreach (BaseEventDetailPageItem eventItem in events.OrderByDescending(i => i.EventStartDate.DateTime.Date).ThenBy(i => i.EventStartDate.DateTime.TimeOfDay)) { EventModel stubEvent = new EventModel(); stubEvent.Title = eventItem.EventHeading.Rendered; stubEvent.TitleUrl = eventItem.InnerItem.GetUrl(); stubEvent.Type = eventItem.GetEventType(); stubEvent.TypeUrl = hypEventsTab.NavigateUrl; stubEvent.Date = eventItem.EventStartDate.DateTime.ToShortDateString(); stubEvent.Time = eventItem.EventStartDate.DateTime.ToShortTimeString(); eventsDataSource.Add(stubEvent); } rptEvents.DataSource = eventsDataSource; rptEvents.DataBind(); }
public ActionResult Create() { ViewBag.AllLanguages = _languageService.GetAllLanguages(true); var model = new EventModel(); AddLocales(_languageService, model.Locales); return View(model); }
private void GoToRepository(EventModel.RepoModel repo) { var repoId = new RepositoryIdentifier(repo.Name); var vm = this.CreateViewModel<RepositoryViewModel>(); vm.Init(repoId.Owner, repoId.Name); NavigateTo(vm); }
public ActionResult Add(EventModel model) { if (!string.IsNullOrWhiteSpace(model.Key) && BSPConfig.EventConfig.BSPEventList.Find(x => x.Key == model.Key.Trim().ToLower()) != null) ModelState.AddModelError("Key", "键已经存在"); if (!string.IsNullOrWhiteSpace(model.Title) && BSPConfig.EventConfig.BSPEventList.Find(x => x.Title == model.Title.Trim().ToLower()) != null) ModelState.AddModelError("Title", "名称已经存在"); if (ModelState.IsValid) { EventInfo eventInfo = new EventInfo() { Key = model.Key.Trim().ToLower(), Title = model.Title.Trim().ToLower(), TimeType = model.TimeType, TimeValue = model.TimeValue, ClassName = model.ClassName, Code = model.Code ?? "", Enabled = model.Enabled }; BSPConfig.EventConfig.BSPEventList.Add(eventInfo); BSPConfig.SaveEventConfig(BSPConfig.EventConfig); AddAdminOperateLog("添加事件", "添加事件,事件为:" + model.Title); return PromptView("事件添加成功"); } ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return View(model); }
private void GoToRepository(EventModel.RepoModel eventModel) { var repoId = new RepositoryIdentifier(eventModel.Name); ShowViewModel<RepositoryViewModel>(new RepositoryViewModel.NavObject { Username = repoId.Owner, Repository = repoId.Name }); }
private void GoToCommits(EventModel.RepoModel repoModel, string branch) { var repoId = new RepositoryIdentifier(repoModel.Name); var vm = CreateViewModel<ChangesetsViewModel>(); vm.RepositoryOwner = repoId.Owner; vm.RepositoryName = repoId.Name; vm.Branch = branch; ShowViewModel(vm); }
private void GoToCommits(EventModel.RepoModel repoModel, string branch) { var repoId = new RepositoryIdentifier(repoModel.Name); ShowViewModel<ChangesetsViewModel>(new ChangesetsViewModel.NavObject { Username = repoId.Owner, Repository = repoId.Name, Branch = branch }); }
public void CreateEvent(string method, List<string> arguments) { EventModel eventModel = new EventModel(); eventModel.method = method; eventModel.arguments = arguments; this.events.Add(eventModel); this.RaiseUpdateEvent(); }
public void subsriceEvent(EventModel model) { // link event handlers. List<eventCreator> ls; var x = eventDictionary [EventName.clickedKey]; // If event exists we subscribe to its event if (eventDictionary.TryGetValue (model.eventName, out ls)) { foreach (eventCreator creator in ls) { creator.setEventHandler(model.handler); } } }
internal EventItemViewModel( EventModel eventModel, IReadOnlyCollection<BaseEventsViewModel.TextBlock> headerBlocks, IReadOnlyCollection<BaseEventsViewModel.TextBlock> bodyBlocks) { Event = eventModel; HeaderBlocks = headerBlocks ?? new BaseEventsViewModel.TextBlock[0]; BodyBlocks = bodyBlocks ?? new BaseEventsViewModel.TextBlock[0]; GoToCommand = ReactiveCommand.Create(); Avatar = eventModel.Actor != null ? new GitHubAvatar(eventModel.Actor.AvatarUrl) : GitHubAvatar.Empty; Created = eventModel.CreatedAt; Type = ChooseImage(eventModel); }
private void GoToCommits(EventModel.RepoModel repoModel, string branch) { var repoId = RepositoryIdentifier.FromFullName(repoModel.Name); if (repoId == null) return; ShowViewModel<ChangesetsViewModel>(new ChangesetsViewModel.NavObject { Username = repoId?.Owner, Repository = repoId?.Name, Branch = branch }); }
public EventItemViewModel( EventModel eventModel, IReadOnlyCollection<BaseEventsViewModel.TextBlock> headerBlocks, IReadOnlyCollection<BaseEventsViewModel.TextBlock> bodyBlocks, Action gotoAction = null) { Event = eventModel; HeaderBlocks = headerBlocks ?? new BaseEventsViewModel.TextBlock[0]; BodyBlocks = bodyBlocks ?? new BaseEventsViewModel.TextBlock[0]; GoToCommand = ReactiveCommand.Create(); if (gotoAction != null) GoToCommand.Subscribe(x => gotoAction()); }
private static EventType ChooseImage(EventModel eventModel) { if (eventModel.PayloadObject is EventModel.CommitCommentEvent) return EventType.Comment; var createEvent = eventModel.PayloadObject as EventModel.CreateEvent; if (createEvent != null) { var createModel = createEvent; if (createModel.RefType.Equals("repository")) return EventType.Repository; if (createModel.RefType.Equals("branch")) return EventType.Branch; if (createModel.RefType.Equals("tag")) return EventType.Tag; } else if (eventModel.PayloadObject is EventModel.DeleteEvent) return EventType.Delete; else if (eventModel.PayloadObject is EventModel.FollowEvent) return EventType.Follow; else if (eventModel.PayloadObject is EventModel.ForkEvent) return EventType.Fork; else if (eventModel.PayloadObject is EventModel.ForkApplyEvent) return EventType.Fork; else if (eventModel.PayloadObject is EventModel.GistEvent) return EventType.Gist; else if (eventModel.PayloadObject is EventModel.GollumEvent) return EventType.Wiki; else if (eventModel.PayloadObject is EventModel.IssueCommentEvent) return EventType.Comment; else if (eventModel.PayloadObject is EventModel.IssuesEvent) return EventType.Issue; else if (eventModel.PayloadObject is EventModel.MemberEvent) return EventType.Organization; else if (eventModel.PayloadObject is EventModel.PublicEvent) return EventType.Public; else if (eventModel.PayloadObject is EventModel.PullRequestEvent) return EventType.PullRequest; else if (eventModel.PayloadObject is EventModel.PullRequestReviewCommentEvent) return EventType.Comment; else if (eventModel.PayloadObject is EventModel.PushEvent) return EventType.Commit; else if (eventModel.PayloadObject is EventModel.TeamAddEvent) return EventType.Organization; else if (eventModel.PayloadObject is EventModel.WatchEvent) return EventType.Star; else if (eventModel.PayloadObject is EventModel.ReleaseEvent) return EventType.Tag; return EventType.Unknown; }
private static UIImage ChooseImage(EventModel eventModel) { if (eventModel.PayloadObject is EventModel.CommitCommentEvent) return Images.Comments; var createEvent = eventModel.PayloadObject as EventModel.CreateEvent; if (createEvent != null) { var createModel = createEvent; if (createModel.RefType.Equals("repository")) return Images.Repo; if (createModel.RefType.Equals("branch")) return Images.Branch; if (createModel.RefType.Equals("tag")) return Images.Tag; } else if (eventModel.PayloadObject is EventModel.DeleteEvent) return Images.BinClosed; else if (eventModel.PayloadObject is EventModel.FollowEvent) return Images.Following; else if (eventModel.PayloadObject is EventModel.ForkEvent) return Images.Fork; else if (eventModel.PayloadObject is EventModel.ForkApplyEvent) return Images.Fork; else if (eventModel.PayloadObject is EventModel.GistEvent) return Images.Script; else if (eventModel.PayloadObject is EventModel.GollumEvent) return Images.Webpage; else if (eventModel.PayloadObject is EventModel.IssueCommentEvent) return Images.Comments; else if (eventModel.PayloadObject is EventModel.IssuesEvent) return Images.Flag; else if (eventModel.PayloadObject is EventModel.MemberEvent) return Images.Group; else if (eventModel.PayloadObject is EventModel.PublicEvent) return Images.Heart; else if (eventModel.PayloadObject is EventModel.PullRequestEvent) return Images.Hand; else if (eventModel.PayloadObject is EventModel.PullRequestReviewCommentEvent) return Images.Comments; else if (eventModel.PayloadObject is EventModel.PushEvent) return Images.Commit; else if (eventModel.PayloadObject is EventModel.TeamAddEvent) return Images.Team; else if (eventModel.PayloadObject is EventModel.WatchEvent) return Images.Eye; else if (eventModel.PayloadObject is EventModel.ReleaseEvent) return Images.Public; return Images.Priority; }
public void registerEvent(EventModel model) { List<eventCreator> ls; // If event exists we add it to the event list if (eventDictionary.TryGetValue (model.eventName, out ls)) { ls.Add (model.registerObject); } else { // We create the list and add the registered class. ls = new List<eventCreator>(); ls.Add (model.registerObject); eventDictionary.Add(model.eventName,ls); } }
public void AppendEvent(string @event, object value, object metadata) { if (currentSession == null) return; var currentEvent = new EventModel { sid = currentSession, @event = @event, timestamp = DateTime.UtcNow, value = value, metadata = metadata }; eventQueue.Enqueue(currentEvent); }
public bool InsertEvent(EventModel eventModel) { exc = new ExcData(); string strSQLInsert = EventSQL.InsertEvent; strSQLInsert = strSQLInsert.Replace("@Subject", "'" + eventModel.Subject + "'"); strSQLInsert = strSQLInsert.Replace("@Detail", "'" + eventModel.Detail + "'"); strSQLInsert = strSQLInsert.Replace("@PicThumbnail", "'" + eventModel.PicThumbnail + "'"); strSQLInsert = strSQLInsert.Replace("@PicFull", "'" + eventModel.PicFull + "'"); strSQLInsert = strSQLInsert.Replace("@DepartmentUID", "'" + eventModel.DepartmentUID + "'"); strSQLInsert = strSQLInsert.Replace("@ActiveDateFrom", "'" + eventModel.ActiveDateFrom + "'"); strSQLInsert = strSQLInsert.Replace("@ActiveDateTo", "'" + eventModel.ActiveDateTo + "'"); strSQLInsert = strSQLInsert.Replace("@Remark", "'" + eventModel.Remark + "'"); strSQLInsert = strSQLInsert.Replace("@CUser", "'" + eventModel.CUser + "'"); strSQLInsert = strSQLInsert.Replace("@MUser", "'" + eventModel.MUser + "'"); strSQLInsert = strSQLInsert.Replace("@StatusFlag", "'" + eventModel.StatusFlag + "'"); strSQLInsert = strSQLInsert.Replace("@LanguageUID", "'" + eventModel.LanguageUID + "'"); return exc.ExecData(strSQLInsert); }
public ActionResult Edit(string key = "") { EventInfo eventInfo = BSPConfig.EventConfig.BSPEventList.Find(x => x.Key == key); if (eventInfo == null) return PromptView("事件不存在"); EventModel model = new EventModel(); model.Key = eventInfo.Key; model.Title = eventInfo.Title; model.TimeType = eventInfo.TimeType; model.TimeValue = eventInfo.TimeValue; model.ClassName = eventInfo.ClassName; model.Code = eventInfo.Code; model.Enabled = eventInfo.Enabled; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return View(model); }
public ActionResult Create(EventModel model, bool continueEditing) { if (ModelState.IsValid) { var evt = model.ToEntity(); evt.CreatedOnUtc = DateTime.UtcNow; _eventService.InsertEvent(evt); //locales UpdateLocales(evt, model); _eventService.UpdateEvent(evt); SuccessNotification(_localizationService.GetResource("Toi.Plugin.Misc.Events.Event.Added")); return continueEditing ? RedirectToAction("Edit", new { id = evt.Id }) : RedirectToAction("List"); } return View(model); }
public void Add(ProjectItem item, EventModel model, IEnumerable<IEventScript> scripts, ResolveEventHandler resolver) { if (item == null) throw new ArgumentNullException("item"); var entry = new Entry(item, model, scripts, resolver); var project = item.ContainingProject; Dictionary<ProjectItem, Entry> items; if (!_entries.TryGetValue(project, out items)) { // Add project entry items = new Dictionary<ProjectItem, Entry>(); _entries.Add(project, items); } items.Add(item, entry); }
public Entry(ProjectItem item, EventModel model, IEnumerable<IEventScript> scripts, ResolveEventHandler resolver) { if (item == null) throw new ArgumentNullException("item"); if (model == null) throw new ArgumentNullException("model"); if (scripts == null) throw new ArgumentNullException("scripts"); if (resolver == null) throw new ArgumentNullException("resolver"); if (!scripts.Any()) throw new ArgumentException("Scripts should not be 0.", "scripts"); ProjectItem = item; EventModel = model; //Assembly = scripts.First().GetType().Assembly; // Dont require the Assembly to be passed ? _scripts.AddRange(scripts); Resolver = resolver; }
protected void Page_Load(object sender, EventArgs e) { var events = SearchHelper.GetUpcomingEvents(2).ToList(); List<EventModel> eventsDataSource = new List<EventModel>(); foreach (BaseEventDetailPageItem eventItem in events.OrderByDescending(i => i.EventStartDate.DateTime.Date).ThenBy(i => i.EventStartDate.DateTime.TimeOfDay)) { EventModel stubEvent = new EventModel(); stubEvent.Title = eventItem.EventHeading.Rendered; stubEvent.TitleUrl = eventItem.InnerItem.GetUrl(); stubEvent.Type = eventItem.GetEventType(); //stubEvent.TypeUrl = hypEventsTab.NavigateUrl; stubEvent.Date = eventItem.EventStartDate.DateTime.ToShortDateString(); stubEvent.Time = eventItem.EventStartDate.DateTime.ToShortTimeString(); stubEvent.Year = eventItem.EventStartDate.DateTime.Year.ToString(); stubEvent.ChildIssue = eventItem.ChildIssue.ListItems.Select(i => i.DisplayName).ToList(); stubEvent.ParentIssue = eventItem.ParentInterest.ListItems.Select(i => i.DisplayName).ToList(); eventsDataSource.Add(stubEvent); } rptUpcomingEvents.DataSource = eventsDataSource; rptUpcomingEvents.DataBind(); }
public void Load(ProjectItem item) { // Split the logic of this method into smaller pieces // Wrap with Try/Catch and print any exceptions (if debug build etc) // Handle missing references/includes better - print out what is being loaded and if some path is not found if (item == null) throw new ArgumentNullException("item"); // If this is public then check if it is a Jiss file here ... else make private ? // Right now every method that calls it checks it instead ? // Check if item is ProjectFile or IsJiss here ? //if (!item.IsProjectFile() or IsJiss()) // return; var filename = item.FileNames[0]; // create extension method GetFullName ? // Load the file and create a reader JissFile script; IJissReader reader; try { script = JissFile.Create(filename); reader = new JissReader(script); // Should reader take in filename and store a target property to get Language etc ? or just TargetLanguage property? } catch (Exception) { Report("Error occured when trying to load file: " + filename); // Could be one of the includes - better error handling return; } // Create Provider/Compiler CompilerResults result; using (var provider = CompilerHelper.CreateProvider(script.Language, CompilerVersion.v40)) { // Handle references var references = Helper.GetDefaultReferences().ToList(); references.AddRange(reader.GetGacs()); references.AddRange(reader.GetReferences()); // Create parameters var parameters = CompilerHelper.CreateParameters(references, true, false, false); parameters.SetGenerateInMemory(); // Compile result = provider.CompileAssemblyFromSource(parameters, reader.GetSources().ToArray()); } // What about warnings ? if (result.Errors.HasErrors) { string errors = ""; foreach (CompilerError error in result.Errors) { errors += error.ErrorText + Environment.NewLine; } Report(errors); // Show errors in the Error List instead !? return; } // Create the resolver for the referenced assemblies var assemblyReferences = result.CompiledAssembly.GetReferencedAssemblies(); var readerReferences = reader.GetReferences(); Dictionary<string, string> assemblyNames = new Dictionary<string, string>(); // Contains AssemblyName.FullName / Full reference foreach (var reference in readerReferences) { var assName = AssemblyName.GetAssemblyName(reference); foreach (var assReference in assemblyReferences) { if (assName.FullName == assReference.FullName) assemblyNames.Add(assName.FullName, reference); } } var jissAssName = typeof(IEventScript).Assembly.FullName; // add to assemblyNames + reference ? var resolver = new ResolveEventHandler((obj, args) => { if (args.RequestingAssembly == result.CompiledAssembly) { string fullReference; if (assemblyNames.TryGetValue(args.Name, out fullReference)) return Assembly.LoadFrom(fullReference); // Move this into seperate global resolver ? if (args.Name == jissAssName) return Assembly.Load(args.Name); // use AssemblyName instead ? } return null; }); // Only attach (and create) resolver if readerReferences.Any() ? requires seperate resolver for Dynamo.Jiss assembly then... AppDomain.CurrentDomain.AssemblyResolve += resolver; // Get all types/classes which implement the IEventScript interface var types = result.CompiledAssembly.GetTypesAssignableTo<IEventScript>(); // Create an instance for each type found and call setup var eventModel = new EventModel(); var instances = new List<IEventScript>(); foreach (var type in types) { IEventScript instance; try { instance = (IEventScript)Activator.CreateInstance(type); } catch (Exception) { Report("Error occured when trying to create an instance of type: " + type.Name + Environment.NewLine + "Please check that the type have an empty public constructor."); continue; } try { instance.Setup(item, eventModel); } catch (Exception) { Report("Error occured in the Setup() method for type: " + type.Name); continue; } instances.Add(instance); } // Add to index if any instances was created if (instances.Any()) { _index.Add(item, eventModel, instances, resolver); } else { AppDomain.CurrentDomain.AssemblyResolve -= resolver; } }
private void GoToTags(EventModel.RepoModel eventModel) { var repoId = RepositoryIdentifier.FromFullName(eventModel.Name); if (repoId == null) return; ShowViewModel<BranchesAndTagsViewModel>(new BranchesAndTagsViewModel.NavObject { Username = repoId?.Owner, Repository = repoId?.Name, IsShowingBranches = false }); }
/// <param name='id'> /// </param> /// <param name='eventParameter'> /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <HttpOperationResponse> PutEventWithHttpMessagesAsync(int id, EventModel eventParameter, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (eventParameter == null) { throw new ValidationException(ValidationRules.CannotBeNull, "eventParameter"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("id", id); tracingParameters.Add("eventParameter", eventParameter); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "PutEvent", tracingParameters); } // Construct URL var _baseUrl = this.Client.BaseUri.AbsoluteUri; var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/Events/{id}").ToString(); _url = _url.Replace("{id}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(id, this.Client.SerializationSettings).Trim('"'))); // Create HTTP transport objects HttpRequestMessage _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new Uri(_url); // Set Headers if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; if (eventParameter != null) { _requestContent = SafeJsonConvert.SerializeObject(eventParameter, this.Client.SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8); _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials if (this.Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 204) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new HttpOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
public HttpResponseMessage SendMessage(string id, string message) { try { var thing = ThingModel.FromRowKey(Lib.UserUtils.GetUser(this).RepoId, id); var eventModel = new EventModel(thing, EventType.Message); eventModel["EventMessage"] = message; foreach (var item in thing.Properties) { eventModel.EventProperties.Add(item.Key, item.Value); } eventModel.Send(); return new HttpResponseMessage(HttpStatusCode.Accepted); } catch { throw new HttpResponseException(HttpStatusCode.NotFound); } }
private async Task <DialogTurnResult> ShowEventInfoAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { // show event information before create var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken); var source = state.EventSource; var newEvent = new EventModel(source) { Title = state.MeetingInfo.Title, Content = state.MeetingInfo.Content, Attendees = state.MeetingInfo.ContactInfor.Contacts, StartTime = state.MeetingInfo.StartDateTime.Value, EndTime = state.MeetingInfo.EndDateTime.Value, TimeZone = TimeZoneInfo.Utc, Location = state.MeetingInfo.Location, ContentPreview = state.MeetingInfo.Content }; var attendeeConfirmTextString = string.Empty; if (state.MeetingInfo.ContactInfor.Contacts.Count > 0) { var attendeeConfirmResponse = TemplateManager.GenerateActivityForLocale(CreateEventResponses.ConfirmCreateAttendees, new { Attendees = DisplayHelper.ToDisplayParticipantsStringSummary(state.MeetingInfo.ContactInfor.Contacts, 5) }); attendeeConfirmTextString = attendeeConfirmResponse.Text; } var subjectConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.MeetingInfo.Title)) { var subjectConfirmResponse = TemplateManager.GenerateActivityForLocale(CreateEventResponses.ConfirmCreateSubject, new { Subject = string.IsNullOrEmpty(state.MeetingInfo.Title) ? CalendarCommonStrings.Empty : state.MeetingInfo.Title }); subjectConfirmString = subjectConfirmResponse.Text; } var locationConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.MeetingInfo.Location)) { var subjectConfirmResponse = TemplateManager.GenerateActivityForLocale(CreateEventResponses.ConfirmCreateLocation, new { Location = string.IsNullOrEmpty(state.MeetingInfo.Location) ? CalendarCommonStrings.Empty : state.MeetingInfo.Location }); locationConfirmString = subjectConfirmResponse.Text; } var contentConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.MeetingInfo.Content)) { var contentConfirmResponse = TemplateManager.GenerateActivityForLocale(CreateEventResponses.ConfirmCreateContent, new { Content = string.IsNullOrEmpty(state.MeetingInfo.Content) ? CalendarCommonStrings.Empty : state.MeetingInfo.Content }); contentConfirmString = contentConfirmResponse.Text; } var startDateTimeInUserTimeZone = TimeConverter.ConvertUtcToUserTime(state.MeetingInfo.StartDateTime.Value, state.GetUserTimeZone()); var endDateTimeInUserTimeZone = TimeConverter.ConvertUtcToUserTime(state.MeetingInfo.EndDateTime.Value, state.GetUserTimeZone()); var tokens = new { AttendeesConfirm = attendeeConfirmTextString, Date = startDateTimeInUserTimeZone.ToSpeechDateString(false), Time = startDateTimeInUserTimeZone.ToSpeechTimeString(false), EndTime = endDateTimeInUserTimeZone.ToSpeechTimeString(false), SubjectConfirm = subjectConfirmString, LocationConfirm = locationConfirmString, ContentConfirm = contentConfirmString }; var prompt = await GetDetailMeetingResponseAsync(sc, newEvent, CreateEventResponses.ConfirmCreate, tokens, cancellationToken); await sc.Context.SendActivityAsync(prompt, cancellationToken); // show at most 5 user names, ask user show rest users if (state.MeetingInfo.ContactInfor.Contacts.Count > 5) { return(await sc.BeginDialogAsync(Actions.ShowRestParticipants, cancellationToken : cancellationToken)); } else { return(await sc.NextAsync(cancellationToken : cancellationToken)); } } catch (Exception ex) { await HandleDialogExceptionsAsync(sc, ex, cancellationToken); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
/// <summary> /// Send messages for device /// </summary> /// <param name="service"></param> /// <param name="deviceId"></param> /// <param name="message"></param> /// <returns></returns> public static Task SendAsync(this IIoTHubTelemetryServices service, string deviceId, EventModel message) { return(service.SendAsync(deviceId, null, message)); }
public async Task <DialogTurnResult> ConfirmBeforeCreate(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken); if (state.Location == null && sc.Result != null && (!state.CreateHasDetail || state.RecreateState == RecreateEventState.Location)) { sc.Context.Activity.Properties.TryGetValue("OriginText", out var content); var luisResult = state.LuisResult; var userInput = content != null?content.ToString() : sc.Context.Activity.Text; var topIntent = luisResult?.TopIntent().intent.ToString(); var promptRecognizerResult = ConfirmRecognizerHelper.ConfirmYesOrNo(userInput, sc.Context.Activity.Locale); // Enable the user to skip providing the location if they say something matching the Cancel intent, say something matching the ConfirmNo recognizer or something matching the NoLocation intent if (CreateEventWhiteList.IsSkip(userInput)) { state.Location = string.Empty; } else { state.Location = userInput; } } var source = state.EventSource; var newEvent = new EventModel(source) { Title = state.Title, Content = state.Content, Attendees = state.Attendees, StartTime = state.StartDateTime.Value, EndTime = state.EndDateTime.Value, TimeZone = TimeZoneInfo.Utc, Location = state.Location, ContentPreview = state.Content }; var attendeeConfirmString = string.Empty; if (state.Attendees.Count > 0) { var attendeeConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateAttendees, new StringDictionary() { { "Attendees", state.Attendees.ToSpeechString(CommonStrings.And, li => li.DisplayName ?? li.Address) } }); attendeeConfirmString = attendeeConfirmResponse.Text; } var subjectConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.Title)) { var subjectConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateSubject, new StringDictionary() { { "Subject", string.IsNullOrEmpty(state.Title) ? CalendarCommonStrings.Empty : state.Title } }); subjectConfirmString = subjectConfirmResponse.Text; } var locationConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.Location)) { var subjectConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateLocation, new StringDictionary() { { "Location", string.IsNullOrEmpty(state.Location) ? CalendarCommonStrings.Empty : state.Location }, }); locationConfirmString = subjectConfirmResponse.Text; } var contentConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.Content)) { var contentConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateContent, new StringDictionary() { { "Content", string.IsNullOrEmpty(state.Content) ? CalendarCommonStrings.Empty : state.Content }, }); contentConfirmString = contentConfirmResponse.Text; } var startDateTimeInUserTimeZone = TimeConverter.ConvertUtcToUserTime(state.StartDateTime.Value, state.GetUserTimeZone()); var endDateTimeInUserTimeZone = TimeConverter.ConvertUtcToUserTime(state.EndDateTime.Value, state.GetUserTimeZone()); var tokens = new StringDictionary { { "AttendeesConfirm", attendeeConfirmString }, { "Date", startDateTimeInUserTimeZone.ToSpeechDateString(false) }, { "Time", startDateTimeInUserTimeZone.ToSpeechTimeString(false) }, { "EndTime", endDateTimeInUserTimeZone.ToSpeechTimeString(false) }, { "SubjectConfirm", subjectConfirmString }, { "LocationConfirm", locationConfirmString }, { "ContentConfirm", contentConfirmString }, }; var card = new Card() { Name = newEvent.OnlineMeetingUrl == null ? "CalendarCardNoJoinButton" : "CalendarCard", Data = newEvent.ToAdaptiveCardData(state.GetUserTimeZone(), showContent: true) }; var prompt = ResponseManager.GetCardResponse(CreateEventResponses.ConfirmCreate, card, tokens); var retryPrompt = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateFailed, tokens); return(await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions { Prompt = prompt, RetryPrompt = retryPrompt }, cancellationToken)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
public bool RemoveEvent(EventModel model) { _events.Remove(model); return(true); }
private async void ReserveEvent(object sender, RoutedEventArgs e) { if (control_calendar.Date != null) { var new_event = new EventModel() { EventStartTime = control_calendar.Date.Value.Date, EventDuration = control_time.Time, //EventName = control_name.Text, EventName = (_linedUpEvents.SelectedItem as ComboBoxItem).Content as string, EventAddress = "", EventInviteText = "", RSVPEmail = "", }; App.EventModel = new_event; if (new_event.EventName == "John's Band Night") { new_event.EventAddress = "Pike Place Market, Vancouver"; new_event.RSVPEmail = "*****@*****.**"; } if (new_event.EventName == "Hackathon") { new_event.EventAddress = "NewFoundland Place Market, Montreal"; new_event.RSVPEmail = "*****@*****.**"; } if (new_event.EventName == "Ariana Grande Musical") { new_event.EventAddress = "Playdium Centre, Toronto"; new_event.RSVPEmail = "*****@*****.**"; } if (new_event.EventName == "Microsoft Ignite") { new_event.EventAddress = "Celebration Centre, Ottawa"; new_event.RSVPEmail = "*****@*****.**"; } _events.Add(new_event); MessageDialog md = new MessageDialog($"{_events.Count} event reserved\n" + "You have your event booked on " + $"{new_event.EventStartTime.Month}/" + $"{new_event.EventStartTime.Day}/" + $"{new_event.EventStartTime.Year}" + $" at {new_event.EventDuration}" + $"for {new_event.EventName}"); await md.ShowAsync(); ev_address.Text = new_event.EventName + " @ " + new_event.EventAddress; var dateFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{month.full} {day.integer}"); var eventdate = dateFormatter.Format(new_event.EventStartTime); ev_time.Text = eventdate + " At " + new_event.EventDuration; control_calendar.Date = null; } else { MessageDialog md = new MessageDialog("Select a day first"); await md.ShowAsync(); } }
public void AddEvent(EventModel newEvent) { throw new NotImplementedException(); }
private bool SuitableOnceEvent(EventModel evnt, DateTime date) => evnt.Schedule.ScheduleType == ScheduleType.Once && evnt.DateFrom.Year == date.Year && evnt.DateFrom.Month == date.Month && evnt.DateFrom.Day == date.Day;
private bool SuitableWeeklyEvent(EventModel evnt, DateTime date) => evnt.Schedule.ScheduleType == ScheduleType.Weekly && evnt.Schedule.DaysOfWeek.Contains(date.DayOfWeek);
private bool SuitableMonthlyEvent(EventModel evnt, DateTime date, int lastDayOfMonth) => evnt.Schedule.ScheduleType == ScheduleType.Monthly && evnt.Schedule.Months.Contains((Month)date.Month) && (evnt.Schedule.DayOfMonth == date.Day || evnt.Schedule.DayOfMonth == -1 && date.Day == lastDayOfMonth);
private TextBlock CreateRepositoryTextBlock(EventModel.RepoModel repoModel) { //Most likely indicates a deleted repository if (repoModel == null) return new TextBlock("Unknown Repository"); if (repoModel.Name == null) return new TextBlock("<Deleted Repository>"); var repoSplit = repoModel.Name.Split('/'); if (repoSplit.Length < 2) return new TextBlock(repoModel.Name); // var repoOwner = repoSplit[0]; // var repoName = repoSplit[1]; return new AnchorBlock(repoModel.Name, () => GoToRepositoryCommand.Execute(repoModel)); }
/// <summary> /// Organises the person repository. /// </summary> private static async Task <bool> OrganisePersonRepository() { await DataStore.CN.MajorStatusAdd("Organising Person data").ConfigureAwait(false); foreach (PersonModel thePersonModel in DV.PersonDV.DataViewData) { HLinkPersonModel t = thePersonModel.HLink; // -- Organse Back Links --------------------- // Citation Collection foreach (HLinkCitationModel citationRef in thePersonModel.GCitationRefCollection) { DataStore.DS.CitationData[citationRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Event Collection foreach (HLinkEventModel eventRef in thePersonModel.GEventRefCollection) { DataStore.DS.EventData[eventRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } foreach (HLinkMediaModel mediaRef in thePersonModel.GMediaRefCollection) { DataStore.DS.MediaData[mediaRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Note Collection foreach (HLinkNoteModel noteRef in thePersonModel.GNoteRefCollection) { DataStore.DS.NoteData[noteRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Parent RelationShip foreach (HLinkFamilyModel familyRef in thePersonModel.GParentInRefCollection) { DataStore.DS.FamilyData[familyRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Sibling Collection foreach (HLinkPersonModel personRef in thePersonModel.SiblingRefCollection) { DataStore.DS.PersonData[personRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Back Reference Tag HLinks foreach (HLinkTagModel tagRef in thePersonModel.GTagRefCollection) { // Set the backlinks DataStore.DS.TagData[tagRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // -- Setup some extra values ------------------------------ // set Birthdate EventModel birthDate = DV.EventDV.GetEventType(thePersonModel.GEventRefCollection, CommonConstants.EventTypeBirth); if (birthDate.Valid) { thePersonModel.BirthDate = birthDate.GDate; } // set Is Living if (DV.EventDV.GetEventType(thePersonModel.GEventRefCollection, CommonConstants.EventTypeDeath).Valid) { thePersonModel.IsLiving = false; } else { thePersonModel.IsLiving = true; } // set Sibling Collection if (thePersonModel.GChildOf.Valid) { thePersonModel.SiblingRefCollection = DV.FamilyDV.FamilyData[thePersonModel.GChildOf.HLinkKey].GChildRefCollection; } DataStore.DS.PersonData[thePersonModel.HLinkKey] = thePersonModel; } return(true); }
public bool AddEvent(EventModel model) { model.id = Guid.NewGuid().ToString(); _events.Add(model); return(true); }
public EventModel AddEventReturnType(EventModel model) { model.id = Guid.NewGuid().ToString(); _events.Add(model); return(model); }
public async Task <DialogTurnResult> CreateEvent(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken); var confirmResult = (bool)sc.Result; if (confirmResult) { var source = state.EventSource; var newEvent = new EventModel(source) { Title = state.Title, Content = state.Content, Attendees = state.Attendees, StartTime = (DateTime)state.StartDateTime, EndTime = (DateTime)state.EndDateTime, TimeZone = TimeZoneInfo.Utc, Location = state.Location, }; var calendarService = ServiceManager.InitCalendarService(state.APIToken, state.EventSource); if (await calendarService.CreateEvent(newEvent) != null) { var tokens = new StringDictionary { { "Subject", state.Title }, }; newEvent.ContentPreview = state.Content; var replyMessage = ResponseManager.GetCardResponse( CreateEventResponses.EventCreated, new Card() { Name = newEvent.OnlineMeetingUrl == null ? "CalendarCardNoJoinButton" : "CalendarCard", Data = newEvent.ToAdaptiveCardData(state.GetUserTimeZone(), showContent: true) }, tokens); await sc.Context.SendActivityAsync(replyMessage, cancellationToken); } else { var prompt = ResponseManager.GetResponse(CreateEventResponses.EventCreationFailed); return(await sc.PromptAsync(Actions.Prompt, new PromptOptions { Prompt = prompt }, cancellationToken)); } state.Clear(); } else { return(await sc.ReplaceDialogAsync(Actions.GetRecreateInfo, options : sc.Options, cancellationToken : cancellationToken)); } return(await sc.EndDialogAsync(true, cancellationToken)); } catch (SkillException ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
public EventModel editCommentToEvent(EventModel e, CommentItem c) { throw new NotImplementedException(); }
public string Generate(object o) { EventModel em = o as EventModel; return(em.Pin); }
public abstract void EventPublish(EventModel anEvent);
private async Task <DialogTurnResult> CreateEventAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken); var source = state.EventSource; if (state.MeetingInfo.MeetingRoom != null) { state.MeetingInfo.ContactInfor.Contacts.Add(new EventModel.Attendee { DisplayName = state.MeetingInfo.MeetingRoom.DisplayName, Address = state.MeetingInfo.MeetingRoom.EmailAddress, AttendeeType = AttendeeType.Resource }); } var userTimezone = state.GetUserTimeZone(); var newEvent = new EventModel(source) { Title = state.MeetingInfo.Title, Content = state.MeetingInfo.Content, Attendees = state.MeetingInfo.ContactInfor.Contacts, StartTime = TimeConverter.ConvertUtcToUserTime((DateTime)state.MeetingInfo.StartDateTime, userTimezone), EndTime = TimeConverter.ConvertUtcToUserTime((DateTime)state.MeetingInfo.EndDateTime, userTimezone), TimeZone = userTimezone, Location = state.MeetingInfo.MeetingRoom == null ? state.MeetingInfo.Location : null, IsOnlineMeeting = true }; var status = false; sc.Context.TurnState.TryGetValue(StateProperties.APITokenKey, out var token); var calendarService = ServiceManager.InitCalendarService(token as string, state.EventSource); var createdEvent = await calendarService.CreateEventAsync(newEvent); if (createdEvent != null) { var activity = TemplateManager.GenerateActivityForLocale(CreateEventResponses.MeetingBooked); await sc.Context.SendActivityAsync(activity, cancellationToken); status = true; } else { var activity = TemplateManager.GenerateActivityForLocale(CreateEventResponses.EventCreationFailed); await sc.Context.SendActivityAsync(activity, cancellationToken); status = false; } if (state.IsAction) { return(await sc.EndDialogAsync(new ActionResult() { ActionSuccess = status }, cancellationToken)); } return(await sc.EndDialogAsync(true, cancellationToken)); } catch (SkillException ex) { await HandleDialogExceptionsAsync(sc, ex, cancellationToken); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptionsAsync(sc, ex, cancellationToken); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
private EventBlock CreateEventTextBlocks(EventModel eventModel) { var eventBlock = new EventBlock(); var repoId = eventModel.Repo != null?RepositoryIdentifier.FromFullName(eventModel.Repo.Name) : new RepositoryIdentifier(string.Empty, string.Empty); var username = eventModel.Actor != null ? eventModel.Actor.Login : null; // Insert the actor eventBlock.Header.Add(new AnchorBlock(username, () => GoToUser(username))); var commitCommentEvent = eventModel.PayloadObject as EventModel.CommitCommentEvent; if (commitCommentEvent != null) { var node = commitCommentEvent.Comment.CommitId.Substring(0, commitCommentEvent.Comment.CommitId.Length > 6 ? 6 : commitCommentEvent.Comment.CommitId.Length); eventBlock.Tapped = () => GoToChangeset(repoId, commitCommentEvent.Comment.CommitId); eventBlock.Header.Add(new TextBlock(" commented on commit ")); eventBlock.Header.Add(new AnchorBlock(node, eventBlock.Tapped)); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } eventBlock.Body.Add(new TextBlock(commitCommentEvent.Comment.Body)); return(eventBlock); } var createEvent = eventModel.PayloadObject as EventModel.CreateEvent; if (createEvent != null) { if (createEvent.RefType.Equals("repository")) { if (ReportRepository) { eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" created repository ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } else { eventBlock.Header.Add(new TextBlock(" created this repository")); } } else if (createEvent.RefType.Equals("branch")) { eventBlock.Tapped = () => GoToBranches(repoId); eventBlock.Header.Add(new TextBlock(" created branch ")); eventBlock.Header.Add(new AnchorBlock(createEvent.Ref, eventBlock.Tapped)); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } else if (createEvent.RefType.Equals("tag")) { eventBlock.Tapped = () => GoToTags(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" created tag ")); eventBlock.Header.Add(new AnchorBlock(createEvent.Ref, eventBlock.Tapped)); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } } var deleteEvent = eventModel.PayloadObject as EventModel.DeleteEvent; if (deleteEvent != null) { if (deleteEvent.RefType.Equals("branch")) { eventBlock.Tapped = () => GoToBranches(repoId); eventBlock.Header.Add(new TextBlock(" deleted branch ")); } else if (deleteEvent.RefType.Equals("tag")) { eventBlock.Tapped = () => GoToTags(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" deleted tag ")); } else { return(null); } eventBlock.Header.Add(new AnchorBlock(deleteEvent.Ref, eventBlock.Tapped)); if (!ReportRepository) { return(eventBlock); } eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); return(eventBlock); } if (eventModel.PayloadObject is EventModel.DownloadEvent) { // Don't show the download event for now... return(null); } var followEvent = eventModel.PayloadObject as EventModel.FollowEvent; if (followEvent != null) { eventBlock.Tapped = () => GoToUser(followEvent.Target.Login); eventBlock.Header.Add(new TextBlock(" started following ")); eventBlock.Header.Add(new AnchorBlock(followEvent.Target.Login, eventBlock.Tapped)); return(eventBlock); } /* * FORK EVENT */ else if (eventModel.PayloadObject is EventModel.ForkEvent) { var forkEvent = (EventModel.ForkEvent)eventModel.PayloadObject; var forkedRepo = new EventModel.RepoModel { Id = forkEvent.Forkee.Id, Name = forkEvent.Forkee.FullName, Url = forkEvent.Forkee.Url }; eventBlock.Tapped = () => GoToRepositoryCommand.Execute(forkedRepo); eventBlock.Header.Add(new TextBlock(" forked ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Header.Add(new TextBlock(" to ")); eventBlock.Header.Add(CreateRepositoryTextBlock(forkedRepo)); } /* * FORK APPLY EVENT */ else if (eventModel.PayloadObject is EventModel.ForkApplyEvent) { var forkEvent = (EventModel.ForkApplyEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" applied fork to ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Header.Add(new TextBlock(" on branch ")); eventBlock.Header.Add(new AnchorBlock(forkEvent.Head, () => GoToBranches(repoId))); } /* * GIST EVENT */ else if (eventModel.PayloadObject is EventModel.GistEvent) { var gistEvent = (EventModel.GistEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToGistCommand.Execute(gistEvent); if (string.Equals(gistEvent.Action, "create", StringComparison.OrdinalIgnoreCase)) { eventBlock.Header.Add(new TextBlock(" created Gist #")); } else if (string.Equals(gistEvent.Action, "update", StringComparison.OrdinalIgnoreCase)) { eventBlock.Header.Add(new TextBlock(" updated Gist #")); } else if (string.Equals(gistEvent.Action, "fork", StringComparison.OrdinalIgnoreCase)) { eventBlock.Header.Add(new TextBlock(" forked Gist #")); } eventBlock.Header.Add(new AnchorBlock(gistEvent.Gist.Id, eventBlock.Tapped)); eventBlock.Body.Add(new TextBlock(gistEvent.Gist.Description.Replace('\n', ' ').Replace("\r", "").Trim())); } /* * GOLLUM EVENT (WIKI) */ else if (eventModel.PayloadObject is EventModel.GollumEvent) { var gollumEvent = eventModel.PayloadObject as EventModel.GollumEvent; eventBlock.Header.Add(new TextBlock(" modified the wiki in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); if (gollumEvent != null && gollumEvent.Pages != null) { foreach (var page in gollumEvent.Pages) { var p = page; eventBlock.Body.Add(new AnchorBlock(page.PageName, () => GoToUrlCommand.Execute(p.HtmlUrl))); eventBlock.Body.Add(new TextBlock(" - " + page.Action + "\n")); } eventBlock.Multilined = true; } } /* * ISSUE COMMENT EVENT */ else if (eventModel.PayloadObject is EventModel.IssueCommentEvent) { var commentEvent = (EventModel.IssueCommentEvent)eventModel.PayloadObject; if (commentEvent.Issue.PullRequest != null && !string.IsNullOrEmpty(commentEvent.Issue.PullRequest.HtmlUrl)) { eventBlock.Tapped = () => GoToPullRequest(repoId, commentEvent.Issue.Number); eventBlock.Header.Add(new TextBlock(" commented on pull request ")); } else { eventBlock.Tapped = () => GoToIssue(repoId, commentEvent.Issue.Number); eventBlock.Header.Add(new TextBlock(" commented on issue ")); } eventBlock.Header.Add(new AnchorBlock("#" + commentEvent.Issue.Number, eventBlock.Tapped)); eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Body.Add(new TextBlock(commentEvent.Comment.Body.Replace('\n', ' ').Replace("\r", "").Trim())); } /* * ISSUES EVENT */ else if (eventModel.PayloadObject is EventModel.IssuesEvent) { var issueEvent = (EventModel.IssuesEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToIssue(repoId, issueEvent.Issue.Number); if (string.Equals(issueEvent.Action, "opened", StringComparison.OrdinalIgnoreCase)) { eventBlock.Header.Add(new TextBlock(" opened issue ")); } else if (string.Equals(issueEvent.Action, "closed", StringComparison.OrdinalIgnoreCase)) { eventBlock.Header.Add(new TextBlock(" closed issue ")); } else if (string.Equals(issueEvent.Action, "reopened", StringComparison.OrdinalIgnoreCase)) { eventBlock.Header.Add(new TextBlock(" reopened issue ")); } eventBlock.Header.Add(new AnchorBlock("#" + issueEvent.Issue.Number, eventBlock.Tapped)); eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Body.Add(new TextBlock(issueEvent.Issue.Title.Trim())); } /* * MEMBER EVENT */ else if (eventModel.PayloadObject is EventModel.MemberEvent) { var memberEvent = (EventModel.MemberEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); if (memberEvent.Action.Equals("added")) { eventBlock.Header.Add(new TextBlock(" added ")); } else if (memberEvent.Action.Equals("removed")) { eventBlock.Header.Add(new TextBlock(" removed ")); } var memberName = memberEvent.Member?.Login; if (memberName != null) { eventBlock.Header.Add(new AnchorBlock(memberName, () => GoToUser(memberName))); } else { eventBlock.Header.Add(new TextBlock("<deleted user>")); } eventBlock.Header.Add(new TextBlock(" as a collaborator")); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" to ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } /* * PUBLIC EVENT */ else if (eventModel.PayloadObject is EventModel.PublicEvent) { eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" has open sourced ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } else { eventBlock.Header.Add(new TextBlock(" has been open sourced this repository!")); } } /* * PULL REQUEST EVENT */ else if (eventModel.PayloadObject is EventModel.PullRequestEvent) { var pullEvent = (EventModel.PullRequestEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToPullRequest(repoId, pullEvent.Number); if (pullEvent.Action.Equals("closed")) { eventBlock.Header.Add(new TextBlock(" closed pull request ")); } else if (pullEvent.Action.Equals("opened")) { eventBlock.Header.Add(new TextBlock(" opened pull request ")); } else if (pullEvent.Action.Equals("synchronize")) { eventBlock.Header.Add(new TextBlock(" synchronized pull request ")); } else if (pullEvent.Action.Equals("reopened")) { eventBlock.Header.Add(new TextBlock(" reopened pull request ")); } eventBlock.Header.Add(new AnchorBlock("#" + pullEvent.PullRequest.Number, eventBlock.Tapped)); eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Body.Add(new TextBlock(pullEvent.PullRequest.Title)); } /* * PULL REQUEST REVIEW COMMENT EVENT */ else if (eventModel.PayloadObject is EventModel.PullRequestReviewCommentEvent) { var commentEvent = (EventModel.PullRequestReviewCommentEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToPullRequests(repoId); eventBlock.Header.Add(new TextBlock(" commented on pull request ")); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } eventBlock.Body.Add(new TextBlock(commentEvent.Comment.Body.Replace('\n', ' ').Replace("\r", "").Trim())); } /* * PUSH EVENT */ else if (eventModel.PayloadObject is EventModel.PushEvent) { var pushEvent = (EventModel.PushEvent)eventModel.PayloadObject; string branchRef = null; if (!string.IsNullOrEmpty(pushEvent.Ref)) { var lastSlash = pushEvent.Ref.LastIndexOf("/", StringComparison.Ordinal) + 1; branchRef = pushEvent.Ref.Substring(lastSlash); } if (eventModel.Repo != null) { eventBlock.Tapped = () => GoToCommits(eventModel.Repo, pushEvent.Ref); } eventBlock.Header.Add(new TextBlock(" pushed to ")); if (branchRef != null) { eventBlock.Header.Add(new AnchorBlock(branchRef, () => GoToBranches(repoId))); } if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" at ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } if (pushEvent.Commits != null) { foreach (var commit in pushEvent.Commits) { var desc = (commit.Message ?? ""); var sha = commit.Sha; var firstNewLine = desc.IndexOf("\n"); if (firstNewLine <= 0) { firstNewLine = desc.Length; } desc = desc.Substring(0, firstNewLine); var shortSha = commit.Sha; if (shortSha.Length > 6) { shortSha = shortSha.Substring(0, 6); } eventBlock.Body.Add(new AnchorBlock(shortSha, () => GoToChangeset(repoId, sha))); eventBlock.Body.Add(new TextBlock(" - " + desc + "\n")); eventBlock.Multilined = true; } } } var teamAddEvent = eventModel.PayloadObject as EventModel.TeamAddEvent; if (teamAddEvent != null) { eventBlock.Header.Add(new TextBlock(" added ")); if (teamAddEvent.User != null) { eventBlock.Header.Add(new AnchorBlock(teamAddEvent.User.Login, () => GoToUser(teamAddEvent.User.Login))); } else if (teamAddEvent.Repo != null) { eventBlock.Header.Add(CreateRepositoryTextBlock(new EventModel.RepoModel { Id = teamAddEvent.Repo.Id, Name = teamAddEvent.Repo.FullName, Url = teamAddEvent.Repo.Url })); } else { return(null); } if (teamAddEvent.Team == null) { return(eventBlock); } eventBlock.Header.Add(new TextBlock(" to team ")); eventBlock.Header.Add(new AnchorBlock(teamAddEvent.Team.Name, () => { })); return(eventBlock); } var watchEvent = eventModel.PayloadObject as EventModel.WatchEvent; if (watchEvent != null) { eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); eventBlock.Header.Add(watchEvent.Action.Equals("started") ? new TextBlock(" starred ") : new TextBlock(" unstarred ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); return(eventBlock); } var releaseEvent = eventModel.PayloadObject as EventModel.ReleaseEvent; if (releaseEvent != null) { eventBlock.Tapped = () => GoToUrlCommand.Execute(releaseEvent.Release.HtmlUrl); eventBlock.Header.Add(new TextBlock(" " + releaseEvent.Action + " release " + releaseEvent.Release.Name)); return(eventBlock); } return(eventBlock); }
/// <summary> /// Add Single API Event Call /// </summary> /// <param name="body">Required parameter: Example: </param> /// <return>Returns the void response from the API call</return> public void CreateEvent(EventModel body) { Task t = CreateEventAsync(body); Task.WaitAll(t); }
private EventItemViewModel CreateEventTextBlocks(EventModel eventModel) { Action eventAction = null; var headerBlocks = new List <TextBlock>(); var bodyBlocks = new List <TextBlock>(); var repoId = eventModel.Repo != null ? new RepositoryIdentifier(eventModel.Repo.Name) : new RepositoryIdentifier(); var username = eventModel.Actor != null ? eventModel.Actor.Login : null; // Insert the actor headerBlocks.Add(new AnchorBlock(username, () => GoToUser(username))); /* * COMMIT COMMENT EVENT */ if (eventModel.PayloadObject is EventModel.CommitCommentEvent) { var commitCommentEvent = (EventModel.CommitCommentEvent)eventModel.PayloadObject; var node = commitCommentEvent.Comment.CommitId.Substring(0, commitCommentEvent.Comment.CommitId.Length > 6 ? 6 : commitCommentEvent.Comment.CommitId.Length); eventAction = () => GoToChangeset(repoId, commitCommentEvent.Comment.CommitId); headerBlocks.Add(new TextBlock(" commented on commit ")); headerBlocks.Add(new AnchorBlock(node, eventAction)); if (ReportRepository) { headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } var desc = CreateShortMessage(commitCommentEvent.Comment.Body); if (desc != null) { bodyBlocks.Add(new TextBlock(desc)); } } /* * CREATE EVENT */ else if (eventModel.PayloadObject is EventModel.CreateEvent) { var createEvent = (EventModel.CreateEvent)eventModel.PayloadObject; if (createEvent.RefType.Equals("repository")) { if (ReportRepository) { eventAction = () => _gotoRepositoryCommand.Execute(eventModel.Repo); headerBlocks.Add(new TextBlock(" created repository ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } else { headerBlocks.Add(new TextBlock(" created this repository")); } } else if (createEvent.RefType.Equals("branch")) { eventAction = () => GoToBranches(repoId); headerBlocks.Add(new TextBlock(" created branch ")); headerBlocks.Add(new AnchorBlock(createEvent.Ref, eventAction)); if (ReportRepository) { headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } else if (createEvent.RefType.Equals("tag")) { eventAction = () => GoToTags(eventModel.Repo); headerBlocks.Add(new TextBlock(" created tag ")); headerBlocks.Add(new AnchorBlock(createEvent.Ref, eventAction)); if (ReportRepository) { headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } } /* * DELETE EVENT */ else if (eventModel.PayloadObject is EventModel.DeleteEvent) { var deleteEvent = (EventModel.DeleteEvent)eventModel.PayloadObject; if (deleteEvent.RefType.Equals("branch")) { eventAction = () => GoToBranches(repoId); headerBlocks.Add(new TextBlock(" deleted branch ")); } else if (deleteEvent.RefType.Equals("tag")) { eventAction = () => GoToTags(eventModel.Repo); headerBlocks.Add(new TextBlock(" deleted tag ")); } else { return(null); } headerBlocks.Add(new AnchorBlock(deleteEvent.Ref, eventAction)); if (ReportRepository) { headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } /* * FOLLOW EVENT */ else if (eventModel.PayloadObject is EventModel.DownloadEvent) { // Don't show the download event for now... return(null); } /* * FOLLOW EVENT */ else if (eventModel.PayloadObject is EventModel.FollowEvent) { var followEvent = (EventModel.FollowEvent)eventModel.PayloadObject; eventAction = () => GoToUser(followEvent.Target.Login); headerBlocks.Add(new TextBlock(" started following ")); headerBlocks.Add(new AnchorBlock(followEvent.Target.Login, eventAction)); } /* * FORK EVENT */ else if (eventModel.PayloadObject is EventModel.ForkEvent) { var forkEvent = (EventModel.ForkEvent)eventModel.PayloadObject; var forkedRepo = new EventModel.RepoModel { Id = forkEvent.Forkee.Id, Name = forkEvent.Forkee.FullName, Url = forkEvent.Forkee.Url }; eventAction = () => _gotoRepositoryCommand.Execute(forkedRepo); headerBlocks.Add(new TextBlock(" forked ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); headerBlocks.Add(new TextBlock(" to ")); headerBlocks.Add(CreateRepositoryTextBlock(forkedRepo)); } /* * FORK APPLY EVENT */ else if (eventModel.PayloadObject is EventModel.ForkApplyEvent) { var forkEvent = (EventModel.ForkApplyEvent)eventModel.PayloadObject; eventAction = () => _gotoRepositoryCommand.Execute(eventModel.Repo); headerBlocks.Add(new TextBlock(" applied fork to ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); headerBlocks.Add(new TextBlock(" on branch ")); headerBlocks.Add(new AnchorBlock(forkEvent.Head, () => GoToBranches(repoId))); } /* * GIST EVENT */ else if (eventModel.PayloadObject is EventModel.GistEvent) { var gistEvent = (EventModel.GistEvent)eventModel.PayloadObject; eventAction = () => _gotoGistCommand.ExecuteIfCan(gistEvent); if (string.Equals(gistEvent.Action, "create", StringComparison.OrdinalIgnoreCase)) { headerBlocks.Add(new TextBlock(" created Gist #")); } else if (string.Equals(gistEvent.Action, "update", StringComparison.OrdinalIgnoreCase)) { headerBlocks.Add(new TextBlock(" updated Gist #")); } else if (string.Equals(gistEvent.Action, "fork", StringComparison.OrdinalIgnoreCase)) { headerBlocks.Add(new TextBlock(" forked Gist #")); } headerBlocks.Add(new AnchorBlock(gistEvent.Gist.Id, eventAction)); var desc = CreateShortMessage(gistEvent.Gist.Description); if (desc != null) { bodyBlocks.Add(new TextBlock(desc)); } } /* * GOLLUM EVENT (WIKI) */ else if (eventModel.PayloadObject is EventModel.GollumEvent) { var gollumEvent = eventModel.PayloadObject as EventModel.GollumEvent; headerBlocks.Add(new TextBlock(" modified the wiki in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); if (gollumEvent != null && gollumEvent.Pages != null) { for (var i = 0; i < gollumEvent.Pages.Count; i++) { var p = gollumEvent.Pages[i]; bodyBlocks.Add(new AnchorBlock(p.PageName, () => _gotoUrlCommand(p.HtmlUrl))); var newLine = string.Empty; if (i != gollumEvent.Pages.Count - 1) { newLine = Environment.NewLine; } bodyBlocks.Add(new TextBlock(" - " + p.Action + newLine)); } } } /* * ISSUE COMMENT EVENT */ else if (eventModel.PayloadObject is EventModel.IssueCommentEvent) { var commentEvent = (EventModel.IssueCommentEvent)eventModel.PayloadObject; if (commentEvent.Issue.PullRequest != null && !string.IsNullOrEmpty(commentEvent.Issue.PullRequest.HtmlUrl)) { eventAction = () => GoToPullRequest(repoId, (int)commentEvent.Issue.Number); headerBlocks.Add(new TextBlock(" commented on pull request ")); } else { eventAction = () => GoToIssue(repoId, commentEvent.Issue.Number); headerBlocks.Add(new TextBlock(" commented on issue ")); } headerBlocks.Add(new AnchorBlock("#" + commentEvent.Issue.Number, eventAction)); headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); var desc = CreateShortMessage(commentEvent.Comment.Body); if (desc != null) { bodyBlocks.Add(new TextBlock(desc)); } } /* * ISSUES EVENT */ else if (eventModel.PayloadObject is EventModel.IssuesEvent) { var issueEvent = (EventModel.IssuesEvent)eventModel.PayloadObject; eventAction = () => GoToIssue(repoId, issueEvent.Issue.Number); if (string.Equals(issueEvent.Action, "opened", StringComparison.OrdinalIgnoreCase)) { headerBlocks.Add(new TextBlock(" opened issue ")); } else if (string.Equals(issueEvent.Action, "closed", StringComparison.OrdinalIgnoreCase)) { headerBlocks.Add(new TextBlock(" closed issue ")); } else if (string.Equals(issueEvent.Action, "reopened", StringComparison.OrdinalIgnoreCase)) { headerBlocks.Add(new TextBlock(" reopened issue ")); } headerBlocks.Add(new AnchorBlock("#" + issueEvent.Issue.Number, eventAction)); headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); bodyBlocks.Add(new TextBlock(issueEvent.Issue.Title)); } /* * MEMBER EVENT */ else if (eventModel.PayloadObject is EventModel.MemberEvent) { var memberEvent = (EventModel.MemberEvent)eventModel.PayloadObject; eventAction = () => _gotoRepositoryCommand.Execute(eventModel.Repo); if (memberEvent.Action.Equals("added")) { headerBlocks.Add(new TextBlock(" added as a collaborator")); } else if (memberEvent.Action.Equals("removed")) { headerBlocks.Add(new TextBlock(" removed as a collaborator")); } if (ReportRepository) { headerBlocks.Add(new TextBlock(" to ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } /* * PUBLIC EVENT */ else if (eventModel.PayloadObject is EventModel.PublicEvent) { eventAction = () => _gotoRepositoryCommand.Execute(eventModel.Repo); if (ReportRepository) { headerBlocks.Add(new TextBlock(" has open sourced ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } else { headerBlocks.Add(new TextBlock(" has been open sourced this repository!")); } } /* * PULL REQUEST EVENT */ else if (eventModel.PayloadObject is EventModel.PullRequestEvent) { var pullEvent = (EventModel.PullRequestEvent)eventModel.PayloadObject; eventAction = () => GoToPullRequest(repoId, (int)pullEvent.Number); if (pullEvent.Action.Equals("closed")) { headerBlocks.Add(new TextBlock(" closed pull request ")); } else if (pullEvent.Action.Equals("opened")) { headerBlocks.Add(new TextBlock(" opened pull request ")); } else if (pullEvent.Action.Equals("synchronize")) { headerBlocks.Add(new TextBlock(" synchronized pull request ")); } else if (pullEvent.Action.Equals("reopened")) { headerBlocks.Add(new TextBlock(" reopened pull request ")); } headerBlocks.Add(new AnchorBlock("#" + pullEvent.PullRequest.Number, eventAction)); headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); bodyBlocks.Add(new TextBlock(pullEvent.PullRequest.Title)); } /* * PULL REQUEST REVIEW COMMENT EVENT */ else if (eventModel.PayloadObject is EventModel.PullRequestReviewCommentEvent) { var commentEvent = (EventModel.PullRequestReviewCommentEvent)eventModel.PayloadObject; eventAction = () => GoToPullRequests(repoId); headerBlocks.Add(new TextBlock(" commented on pull request ")); if (ReportRepository) { headerBlocks.Add(new TextBlock(" in ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } var desc = CreateShortMessage(commentEvent.Comment.Body); if (desc != null) { bodyBlocks.Add(new TextBlock(desc)); } } /* * PUSH EVENT */ else if (eventModel.PayloadObject is EventModel.PushEvent) { var pushEvent = (EventModel.PushEvent)eventModel.PayloadObject; string branchRef = null; if (!string.IsNullOrEmpty(pushEvent.Ref)) { var lastSlash = pushEvent.Ref.LastIndexOf("/", StringComparison.Ordinal) + 1; branchRef = pushEvent.Ref.Substring(lastSlash); } if (eventModel.Repo != null) { eventAction = () => GoToCommits(eventModel.Repo, pushEvent.Ref); } headerBlocks.Add(new TextBlock(" pushed to ")); if (branchRef != null) { headerBlocks.Add(new AnchorBlock(branchRef, () => GoToBranches(repoId))); } if (ReportRepository) { headerBlocks.Add(new TextBlock(" at ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } if (pushEvent.Commits != null) { for (var i = 0; i < pushEvent.Commits.Count; i++) { var commit = pushEvent.Commits[i]; var sha = commit.Sha; var desc = CreateShortMessage(commit.Message ?? ""); var shortSha = commit.Sha; if (shortSha.Length > 6) { shortSha = shortSha.Substring(0, 6); } var newLine = string.Empty; if (i != pushEvent.Commits.Count - 1) { newLine = Environment.NewLine; } bodyBlocks.Add(new AnchorBlock(shortSha, () => GoToChangeset(repoId, sha))); if (desc != null) { bodyBlocks.Add(new TextBlock(" - " + desc + newLine)); } } } } else if (eventModel.PayloadObject is EventModel.TeamAddEvent) { var teamAddEvent = (EventModel.TeamAddEvent)eventModel.PayloadObject; headerBlocks.Add(new TextBlock(" added ")); if (teamAddEvent.User != null) { headerBlocks.Add(new AnchorBlock(teamAddEvent.User.Login, () => GoToUser(teamAddEvent.User.Login))); } else if (teamAddEvent.Repo != null) { headerBlocks.Add(CreateRepositoryTextBlock(new EventModel.RepoModel { Id = teamAddEvent.Repo.Id, Name = teamAddEvent.Repo.FullName, Url = teamAddEvent.Repo.Url })); } else { return(null); } if (teamAddEvent.Team != null) { headerBlocks.Add(new TextBlock(" to team ")); headerBlocks.Add(new AnchorBlock(teamAddEvent.Team.Name, () => { })); } } else if (eventModel.PayloadObject is EventModel.WatchEvent) { var watchEvent = (EventModel.WatchEvent)eventModel.PayloadObject; eventAction = () => _gotoRepositoryCommand.Execute(eventModel.Repo); headerBlocks.Add(watchEvent.Action.Equals("started") ? new TextBlock(" starred ") : new TextBlock(" unstarred ")); headerBlocks.Add(CreateRepositoryTextBlock(eventModel.Repo)); } else if (eventModel.PayloadObject is EventModel.ReleaseEvent) { var releaseEvent = (EventModel.ReleaseEvent)eventModel.PayloadObject; eventAction = () => _gotoUrlCommand(releaseEvent.Release.HtmlUrl); headerBlocks.Add(new TextBlock(" " + releaseEvent.Action + " release " + releaseEvent.Release.Name)); } return(new EventItemViewModel(eventModel, headerBlocks, bodyBlocks, eventAction)); }
public async Task CreateEventTest() { var newEvent = new EventModel(EventSource.Microsoft); await calendarService.CreateEventAsync(newEvent); }
public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, EventModel product) { if (product != null && ModelState.IsValid) { //productService.Update(product); } return(Json(new[] { product }.ToDataSourceResult(request, ModelState))); }
private void GoToRepository(EventModel.RepoModel eventModel) { var repoId = RepositoryIdentifier.FromFullName(eventModel.Name); if (repoId == null) return; ShowViewModel<RepositoryViewModel>(new RepositoryViewModel.NavObject { Username = repoId?.Owner, Repository = repoId?.Name }); }
public async Task <IActionResult> EditEventContent([FromForm] EventModel model) { await this._eventsManager.EditEvent(model); return(Ok()); }
public CtrlWindow() { BindingErrorTraceListener.SetTrace(); InitializeComponent(); // create a model object _event = new EventModel() { SelectedJack = new AudioLine { DeviceName = "-- Not Implemented -- ", LevelLeft = 0, LevelRight = 0, EmptyStr = "-", Fill = new SolidColorBrush() }, _AudioDeviceCollection = new ObservableCollection<AudioLine>(), AudioBitrate = 0, AudioChannel = 'U', IsNotAutoBitrate = true, IsNotAutoChannel = true, }; this.DataContext = _event; }
private async Task <DialogTurnResult> UpdateMeetingRoomAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken); var origin = state.ShowMeetingInfo.FocusedEvents[0]; var updateEvent = new EventModel(origin.Source); string meetingRoom = state.MeetingInfo.MeetingRoom?.DisplayName; var attendees = new List <EventModel.Attendee>(); attendees.AddRange(origin.Attendees); if (state.InitialIntent == CalendarLuis.Intent.ChangeCalendarEntry) { attendees.RemoveAll(x => x.AttendeeType == AttendeeType.Resource); } if (state.InitialIntent == CalendarLuis.Intent.DeleteCalendarEntry) { meetingRoom = attendees.Find(x => x.AttendeeType == AttendeeType.Resource)?.DisplayName; if (meetingRoom == null) { throw new Exception("No meeting room found."); } attendees.RemoveAll(x => x.AttendeeType == AttendeeType.Resource); } if (state.InitialIntent == CalendarLuis.Intent.ChangeCalendarEntry || state.InitialIntent == CalendarLuis.Intent.AddCalendarEntryAttribute) { if (state.MeetingInfo.MeetingRoom == null) { throw new NullReferenceException("UpdateMeetingRoom received a null MeetingRoom."); } attendees.Add(new EventModel.Attendee { DisplayName = state.MeetingInfo.MeetingRoom.DisplayName, Address = state.MeetingInfo.MeetingRoom.EmailAddress, AttendeeType = AttendeeType.Resource }); } updateEvent.Id = origin.Id; updateEvent.Attendees = attendees; updateEvent.Location = null; if (!string.IsNullOrEmpty(state.UpdateMeetingInfo.RecurrencePattern) && !string.IsNullOrEmpty(origin.RecurringId)) { updateEvent.Id = origin.RecurringId; } sc.Context.TurnState.TryGetValue(StateProperties.APITokenKey, out var token); var calendarService = ServiceManager.InitCalendarService(token as string, state.EventSource); var newEvent = await calendarService.UpdateEventByIdAsync(updateEvent); var data = new { MeetingRoom = meetingRoom, DateTime = SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime((DateTime)state.MeetingInfo.StartDateTime, state.GetUserTimeZone()), state.MeetingInfo.AllDay == true, DateTime.UtcNow > state.MeetingInfo.StartDateTime), Subject = newEvent.Title, }; if (state.InitialIntent == CalendarLuis.Intent.AddCalendarEntryAttribute) { var replyMessage = await GetDetailMeetingResponseAsync(sc, newEvent, FindMeetingRoomResponses.MeetingRoomAdded, data, cancellationToken); await sc.Context.SendActivityAsync(replyMessage, cancellationToken); } else if (state.InitialIntent == CalendarLuis.Intent.ChangeCalendarEntry) { var replyMessage = await GetDetailMeetingResponseAsync(sc, newEvent, FindMeetingRoomResponses.MeetingRoomChanged, data, cancellationToken); await sc.Context.SendActivityAsync(replyMessage, cancellationToken); } else { var activity = TemplateManager.GenerateActivityForLocale(FindMeetingRoomResponses.MeetingRoomCanceled, data); await sc.Context.SendActivityAsync(activity, cancellationToken); } state.Clear(); return(await sc.EndDialogAsync(true, cancellationToken)); } catch (Exception ex) { await HandleDialogExceptionsAsync(sc, ex, cancellationToken); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
private EventBlock CreateEventTextBlocks(EventModel eventModel) { var eventBlock = new EventBlock(); var repoId = eventModel.Repo != null ? RepositoryIdentifier.FromFullName(eventModel.Repo.Name) : new RepositoryIdentifier(string.Empty, string.Empty); var username = eventModel.Actor != null ? eventModel.Actor.Login : null; // Insert the actor eventBlock.Header.Add(new AnchorBlock(username, () => GoToUser(username))); var commitCommentEvent = eventModel.PayloadObject as EventModel.CommitCommentEvent; if (commitCommentEvent != null) { var node = commitCommentEvent.Comment.CommitId.Substring(0, commitCommentEvent.Comment.CommitId.Length > 6 ? 6 : commitCommentEvent.Comment.CommitId.Length); eventBlock.Tapped = () => GoToChangeset(repoId, commitCommentEvent.Comment.CommitId); eventBlock.Header.Add(new TextBlock(" commented on commit ")); eventBlock.Header.Add(new AnchorBlock(node, eventBlock.Tapped)); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } eventBlock.Body.Add(new TextBlock(commitCommentEvent.Comment.Body)); return eventBlock; } var createEvent = eventModel.PayloadObject as EventModel.CreateEvent; if (createEvent != null) { if (createEvent.RefType.Equals("repository")) { if (ReportRepository) { eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" created repository ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } else eventBlock.Header.Add(new TextBlock(" created this repository")); } else if (createEvent.RefType.Equals("branch")) { eventBlock.Tapped = () => GoToBranches(repoId); eventBlock.Header.Add(new TextBlock(" created branch ")); eventBlock.Header.Add(new AnchorBlock(createEvent.Ref, eventBlock.Tapped)); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } else if (createEvent.RefType.Equals("tag")) { eventBlock.Tapped = () => GoToTags(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" created tag ")); eventBlock.Header.Add(new AnchorBlock(createEvent.Ref, eventBlock.Tapped)); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } } var deleteEvent = eventModel.PayloadObject as EventModel.DeleteEvent; if (deleteEvent != null) { if (deleteEvent.RefType.Equals("branch")) { eventBlock.Tapped = () => GoToBranches(repoId); eventBlock.Header.Add(new TextBlock(" deleted branch ")); } else if (deleteEvent.RefType.Equals("tag")) { eventBlock.Tapped = () => GoToTags(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" deleted tag ")); } else return null; eventBlock.Header.Add(new AnchorBlock(deleteEvent.Ref, eventBlock.Tapped)); if (!ReportRepository) return eventBlock; eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); return eventBlock; } if (eventModel.PayloadObject is EventModel.DownloadEvent) { // Don't show the download event for now... return null; } var followEvent = eventModel.PayloadObject as EventModel.FollowEvent; if (followEvent != null) { eventBlock.Tapped = () => GoToUser(followEvent.Target.Login); eventBlock.Header.Add(new TextBlock(" started following ")); eventBlock.Header.Add(new AnchorBlock(followEvent.Target.Login, eventBlock.Tapped)); return eventBlock; } /* * FORK EVENT */ else if (eventModel.PayloadObject is EventModel.ForkEvent) { var forkEvent = (EventModel.ForkEvent)eventModel.PayloadObject; var forkedRepo = new EventModel.RepoModel {Id = forkEvent.Forkee.Id, Name = forkEvent.Forkee.FullName, Url = forkEvent.Forkee.Url}; eventBlock.Tapped = () => GoToRepositoryCommand.Execute(forkedRepo); eventBlock.Header.Add(new TextBlock(" forked ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Header.Add(new TextBlock(" to ")); eventBlock.Header.Add(CreateRepositoryTextBlock(forkedRepo)); } /* * FORK APPLY EVENT */ else if (eventModel.PayloadObject is EventModel.ForkApplyEvent) { var forkEvent = (EventModel.ForkApplyEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); eventBlock.Header.Add(new TextBlock(" applied fork to ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Header.Add(new TextBlock(" on branch ")); eventBlock.Header.Add(new AnchorBlock(forkEvent.Head, () => GoToBranches(repoId))); } /* * GIST EVENT */ else if (eventModel.PayloadObject is EventModel.GistEvent) { var gistEvent = (EventModel.GistEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToGistCommand.Execute(gistEvent); if (string.Equals(gistEvent.Action, "create", StringComparison.OrdinalIgnoreCase)) eventBlock.Header.Add(new TextBlock(" created Gist #")); else if (string.Equals(gistEvent.Action, "update", StringComparison.OrdinalIgnoreCase)) eventBlock.Header.Add(new TextBlock(" updated Gist #")); else if (string.Equals(gistEvent.Action, "fork", StringComparison.OrdinalIgnoreCase)) eventBlock.Header.Add(new TextBlock(" forked Gist #")); eventBlock.Header.Add(new AnchorBlock(gistEvent.Gist.Id, eventBlock.Tapped)); eventBlock.Body.Add(new TextBlock(gistEvent.Gist.Description.Replace('\n', ' ').Replace("\r", "").Trim())); } /* * GOLLUM EVENT (WIKI) */ else if (eventModel.PayloadObject is EventModel.GollumEvent) { var gollumEvent = eventModel.PayloadObject as EventModel.GollumEvent; eventBlock.Header.Add(new TextBlock(" modified the wiki in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); if (gollumEvent != null && gollumEvent.Pages != null) { foreach (var page in gollumEvent.Pages) { var p = page; eventBlock.Body.Add(new AnchorBlock(page.PageName, () => GoToUrlCommand.Execute(p.HtmlUrl))); eventBlock.Body.Add(new TextBlock(" - " + page.Action + "\n")); } eventBlock.Multilined = true; } } /* * ISSUE COMMENT EVENT */ else if (eventModel.PayloadObject is EventModel.IssueCommentEvent) { var commentEvent = (EventModel.IssueCommentEvent)eventModel.PayloadObject; if (commentEvent.Issue.PullRequest != null && !string.IsNullOrEmpty(commentEvent.Issue.PullRequest.HtmlUrl)) { eventBlock.Tapped = () => GoToPullRequest(repoId, commentEvent.Issue.Number); eventBlock.Header.Add(new TextBlock(" commented on pull request ")); } else { eventBlock.Tapped = () => GoToIssue(repoId, commentEvent.Issue.Number); eventBlock.Header.Add(new TextBlock(" commented on issue ")); } eventBlock.Header.Add(new AnchorBlock("#" + commentEvent.Issue.Number, eventBlock.Tapped)); eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Body.Add(new TextBlock(commentEvent.Comment.Body.Replace('\n', ' ').Replace("\r", "").Trim())); } /* * ISSUES EVENT */ else if (eventModel.PayloadObject is EventModel.IssuesEvent) { var issueEvent = (EventModel.IssuesEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToIssue(repoId, issueEvent.Issue.Number); if (string.Equals(issueEvent.Action, "opened", StringComparison.OrdinalIgnoreCase)) eventBlock.Header.Add(new TextBlock(" opened issue ")); else if (string.Equals(issueEvent.Action, "closed", StringComparison.OrdinalIgnoreCase)) eventBlock.Header.Add(new TextBlock(" closed issue ")); else if (string.Equals(issueEvent.Action, "reopened", StringComparison.OrdinalIgnoreCase)) eventBlock.Header.Add(new TextBlock(" reopened issue ")); eventBlock.Header.Add(new AnchorBlock("#" + issueEvent.Issue.Number, eventBlock.Tapped)); eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Body.Add(new TextBlock(issueEvent.Issue.Title.Trim())); } /* * MEMBER EVENT */ else if (eventModel.PayloadObject is EventModel.MemberEvent) { var memberEvent = (EventModel.MemberEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); if (memberEvent.Action.Equals("added")) eventBlock.Header.Add(new TextBlock(" added as a collaborator")); else if (memberEvent.Action.Equals("removed")) eventBlock.Header.Add(new TextBlock(" removed as a collaborator")); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" to ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } } /* * PUBLIC EVENT */ else if (eventModel.PayloadObject is EventModel.PublicEvent) { eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" has open sourced ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } else eventBlock.Header.Add(new TextBlock(" has been open sourced this repository!")); } /* * PULL REQUEST EVENT */ else if (eventModel.PayloadObject is EventModel.PullRequestEvent) { var pullEvent = (EventModel.PullRequestEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToPullRequest(repoId, pullEvent.Number); if (pullEvent.Action.Equals("closed")) eventBlock.Header.Add(new TextBlock(" closed pull request ")); else if (pullEvent.Action.Equals("opened")) eventBlock.Header.Add(new TextBlock(" opened pull request ")); else if (pullEvent.Action.Equals("synchronize")) eventBlock.Header.Add(new TextBlock(" synchronized pull request ")); else if (pullEvent.Action.Equals("reopened")) eventBlock.Header.Add(new TextBlock(" reopened pull request ")); eventBlock.Header.Add(new AnchorBlock("#" + pullEvent.PullRequest.Number, eventBlock.Tapped)); eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); eventBlock.Body.Add(new TextBlock(pullEvent.PullRequest.Title)); } /* * PULL REQUEST REVIEW COMMENT EVENT */ else if (eventModel.PayloadObject is EventModel.PullRequestReviewCommentEvent) { var commentEvent = (EventModel.PullRequestReviewCommentEvent)eventModel.PayloadObject; eventBlock.Tapped = () => GoToPullRequests(repoId); eventBlock.Header.Add(new TextBlock(" commented on pull request ")); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" in ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } eventBlock.Body.Add(new TextBlock(commentEvent.Comment.Body.Replace('\n', ' ').Replace("\r", "").Trim())); } /* * PUSH EVENT */ else if (eventModel.PayloadObject is EventModel.PushEvent) { var pushEvent = (EventModel.PushEvent)eventModel.PayloadObject; string branchRef = null; if (!string.IsNullOrEmpty(pushEvent.Ref)) { var lastSlash = pushEvent.Ref.LastIndexOf("/", StringComparison.Ordinal) + 1; branchRef = pushEvent.Ref.Substring(lastSlash); } if (eventModel.Repo != null) eventBlock.Tapped = () => GoToCommits(eventModel.Repo, pushEvent.Ref); eventBlock.Header.Add(new TextBlock(" pushed to ")); if (branchRef != null) eventBlock.Header.Add(new AnchorBlock(branchRef, () => GoToBranches(repoId))); if (ReportRepository) { eventBlock.Header.Add(new TextBlock(" at ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); } if (pushEvent.Commits != null) { foreach (var commit in pushEvent.Commits) { var desc = (commit.Message ?? ""); var sha = commit.Sha; var firstNewLine = desc.IndexOf("\n"); if (firstNewLine <= 0) firstNewLine = desc.Length; desc = desc.Substring(0, firstNewLine); var shortSha = commit.Sha; if (shortSha.Length > 6) shortSha = shortSha.Substring(0, 6); eventBlock.Body.Add(new AnchorBlock(shortSha, () => GoToChangeset(repoId, sha))); eventBlock.Body.Add(new TextBlock(" - " + desc + "\n")); eventBlock.Multilined = true; } } } var teamAddEvent = eventModel.PayloadObject as EventModel.TeamAddEvent; if (teamAddEvent != null) { eventBlock.Header.Add(new TextBlock(" added ")); if (teamAddEvent.User != null) eventBlock.Header.Add(new AnchorBlock(teamAddEvent.User.Login, () => GoToUser(teamAddEvent.User.Login))); else if (teamAddEvent.Repo != null) eventBlock.Header.Add(CreateRepositoryTextBlock(new EventModel.RepoModel { Id = teamAddEvent.Repo.Id, Name = teamAddEvent.Repo.FullName, Url = teamAddEvent.Repo.Url })); else return null; if (teamAddEvent.Team == null) return eventBlock; eventBlock.Header.Add(new TextBlock(" to team ")); eventBlock.Header.Add(new AnchorBlock(teamAddEvent.Team.Name, () => { })); return eventBlock; } var watchEvent = eventModel.PayloadObject as EventModel.WatchEvent; if (watchEvent != null) { eventBlock.Tapped = () => GoToRepositoryCommand.Execute(eventModel.Repo); eventBlock.Header.Add(watchEvent.Action.Equals("started") ? new TextBlock(" starred ") : new TextBlock(" unstarred ")); eventBlock.Header.Add(CreateRepositoryTextBlock(eventModel.Repo)); return eventBlock; } var releaseEvent = eventModel.PayloadObject as EventModel.ReleaseEvent; if (releaseEvent != null) { eventBlock.Tapped = () => GoToUrlCommand.Execute(releaseEvent.Release.HtmlUrl); eventBlock.Header.Add(new TextBlock(" " + releaseEvent.Action + " release " + releaseEvent.Release.Name)); return eventBlock; } return eventBlock; }
protected void rptUpcomingEvents_ItemDataBound(object sender, RepeaterItemEventArgs e) { EventModel eventItem = (EventModel)e.Item.DataItem as EventModel; HyperLink hypTitleLink = (HyperLink)e.Item.FindControl("hypTitleLink"); HyperLink hypEventDetails = (HyperLink)e.Item.FindControl("hypEventDetails"); Literal litDate = (Literal)e.Item.FindControl("litDate"); Literal litTime = (Literal)e.Item.FindControl("litTime"); Literal litYear = (Literal)e.Item.FindControl("litYear"); Literal litType = (Literal)e.Item.FindControl("litType"); Literal litType2 = (Literal)e.Item.FindControl("litType2"); Literal litDate2 = (Literal)e.Item.FindControl("litDate2"); Literal litTime2 = (Literal)e.Item.FindControl("litTime2"); Literal litYear2 = (Literal)e.Item.FindControl("litYear2"); Literal litIssuesCovered = (Literal)e.Item.FindControl("litIssuesCovered"); HtmlGenericControl tomorrowDiv = (HtmlGenericControl)e.Item.FindControl("tomorrowDiv"); hypTitleLink.NavigateUrl = eventItem.TitleUrl; hypTitleLink.Text = eventItem.Title; hypEventDetails.NavigateUrl = eventItem.TitleUrl; hypEventDetails.Text = "Event Details"; litDate.Text = litDate2.Text = eventItem.Date; litYear.Text = litYear2.Text = eventItem.Year; litTime.Text = litTime2.Text = eventItem.Time; litType.Text = litType2.Text = eventItem.Type; bool first = true; foreach (string s in eventItem.ChildIssue) { if (first) { litIssuesCovered.Text = s; first = false; } else { litIssuesCovered.Text += ", " + s; } } foreach (string s in eventItem.ParentIssue) { if (first) { litIssuesCovered.Text = s; first = false; } else { litIssuesCovered.Text += ", " + s; } } if (DateTime.Parse(eventItem.Date).Day.Equals(DateTime.Now.AddDays(1))) { tomorrowDiv.Visible = true; } else { tomorrowDiv.Visible = false; } }
/// <inheritdoc/> public async Task <EventModel> CreateEventAysnc(EventModel newEvent) { return(await calendarAPI.CreateEventAysnc(newEvent)); }
public ActionResult EditingPopup_Destroy([DataSourceRequest] DataSourceRequest request, EventModel product) { if (product != null) { //productService.Destroy(product); } return(Json(new[] { product }.ToDataSourceResult(request, ModelState))); }
public async Task <string> UpdateSpecific(int id, [FromBody] string value) { string UpdateResult = "Success"; try { PurchaseOrderDiscounts PurchaseOrdersToUpdate = JsonConvert.DeserializeObject <PurchaseOrderDiscounts>(value); PurchaseOrdersToUpdate.po_discount_id = id; Dictionary <String, String> ValuesToUpdate = new Dictionary <string, string>(); if (PurchaseOrdersToUpdate.po_id != 0) { ValuesToUpdate.Add("po_id", PurchaseOrdersToUpdate.po_id.ToString()); } if (PurchaseOrdersToUpdate.discount_percentage != 0) { ValuesToUpdate.Add("discount_percentage", PurchaseOrdersToUpdate.discount_percentage.ToString()); } if (PurchaseOrdersToUpdate.discount_note != null) { ValuesToUpdate.Add("discount_note", PurchaseOrdersToUpdate.discount_note.ToString()); } if (PurchaseOrdersToUpdate.completed_status != 0) { ValuesToUpdate.Add("completed_status", PurchaseOrdersToUpdate.completed_status.ToString()); } if (PurchaseOrdersToUpdate.created_by != 0) { ValuesToUpdate.Add("created_by", PurchaseOrdersToUpdate.created_by.ToString()); } if (PurchaseOrdersToUpdate.updated_by != 0) { ValuesToUpdate.Add("updated_by", PurchaseOrdersToUpdate.updated_by.ToString()); } if (PurchaseOrdersToUpdate.created_at != 0) { ValuesToUpdate.Add("created_at", PurchaseOrdersToUpdate.created_at.ToString()); } if (PurchaseOrdersToUpdate.updated_at != 0) { ValuesToUpdate.Add("updated_at", PurchaseOrdersToUpdate.updated_at.ToString()); } await _PurchaseOrdersDiscountsRepo.UpdateSpecific(ValuesToUpdate, "po_discount_id=" + id); var eventModel = new EventModel(tableName) { EntityId = PurchaseOrdersToUpdate.po_id, EventName = discount_specificupdate, RefrenceId = id, UserId = PurchaseOrdersToUpdate.updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(eventModel); var userEvent = new EventModel(userEventTableName) { EntityId = PurchaseOrdersToUpdate.updated_by, EventName = discount_specificupdate, RefrenceId = id, UserId = PurchaseOrdersToUpdate.updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(userEvent); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in updating updatespecific purchaseordersdiscounts with message" + ex.Message); UpdateResult = "Failed"; } return(UpdateResult); }
/// <inheritdoc/> public async Task <EventModel> UpdateEventByIdAsync(EventModel updateEvent) { return(await calendarAPI.UpdateEventByIdAsync(updateEvent)); }