private string GetAssociatedNumberDescription(IConversation conversation) { if (!IsSinglePartnerConversation(conversation)) { throw new ArgumentException("Single partner conversation expected."); } IContact associatedContact = conversation.AssociatedContacts[0]; string phoneNumberDescription; if (associatedContact.PhoneNumbers.Count == 1) { // // Add LTR markers because phone numbers should never be displayed RTL. // phoneNumberDescription = string.Format("{0}{1}{2}", '\u200E', PhoneNumberFormatter.FormatNumberWithDashes(associatedContact.PhoneNumbers[0]), '\u202C'); } else { phoneNumberDescription = string.Format("{0} numbers", associatedContact.PhoneNumbers.Count); } return phoneNumberDescription; }
private static ITextGraphDataCollection GetPerMonthDataCollection(IConversation conversation) { TextGraphDataCollection dataCollection = new TextGraphDataCollection(); if (conversation.MessageCount == 0) { return(dataCollection); } Dictionary <DateTime, int> monthCounts = new Dictionary <DateTime, int>(); foreach (IConversationMessage message in conversation) { DateTime messageTimestamp = message.Timestamp; DateTime firstDayOfMonth = new DateTime(messageTimestamp.Year, messageTimestamp.Month, 1); if (monthCounts.ContainsKey(firstDayOfMonth)) { monthCounts[firstDayOfMonth]++; } else { monthCounts[firstDayOfMonth] = 1; } } foreach (DateTime date in monthCounts.Keys) { dataCollection.Add(new TextGraphData(date, monthCounts[date])); } return(AdjustGraphDataCollectionForWorkaround(dataCollection)); }
public static IConversationStatistics CalculateStatistics(IConversation conversation) { ConversationStatistics stats = new ConversationStatistics(); if (conversation == null) { return(stats); } Dictionary <DateTime, bool> datesSeen = new Dictionary <DateTime, bool>(); foreach (IConversationMessage message in conversation) { if (!datesSeen.ContainsKey(message.Timestamp.Date)) { datesSeen[message.Timestamp.Date] = true; stats.AddDay(); } if (message.IsOutgoing) { stats.AddSentMessage(); } else { stats.AddReceivedMessage(); } } return(stats); }
public void InvalidArgPerUnitTimeTest() { IConversation conversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.TonyWolfCell); GraphDataGenerator generator = new GraphDataGenerator(); generator.MessageCountPerUnitTime(conversation, GraphTimeUnit.Unknown); }
public MessagesController(MainOperation <Message> messagesRepo, JobTaskDbContext ctx, IConversation conv, IMessages messages) { this.messagesRepo = messagesRepo; this.ctx = ctx; this.conv = conv; this.messages = messages; }
public static void ConversationRunner(IConversation conversation) { IEnumerable<IDialog> currentDialogs = conversation.CurrentDialogs().ToList(); Console.WriteLine(conversation.GetDescription()); Console.WriteLine(""); Console.WriteLine("----------------------------"); while (currentDialogs.Any()) { if (currentDialogs.Count() == 1) { Console.WriteLine("-" + currentDialogs.First().GetText()); Console.ReadKey(); conversation.Next(); } else if (currentDialogs.Count() > 1) { Console.WriteLine("(Select an answer) 1-"+currentDialogs.Count()+")"); int i = 1; foreach (var dialog in currentDialogs) { Console.WriteLine(" "+i+")"+dialog.GetText()); i++; } int answer = ReadAnswerNumber(1, currentDialogs.Count()); conversation.Answer(currentDialogs.ToList()[answer-1]); } currentDialogs = conversation.CurrentDialogs(); } }
private static ITextGraphDataCollection GetAggregateHourOfDayDataCollection(IConversation conversation) { const int hoursPerDay = 24; int[] messagesExchangedPerHour = new int[hoursPerDay]; for (int i = 0; i < hoursPerDay; i++) { messagesExchangedPerHour[i] = 0; } foreach (IConversationMessage message in conversation) { messagesExchangedPerHour[message.Timestamp.Hour]++; } TextGraphDataCollection dataCollection = new TextGraphDataCollection(); for (int i = 0; i < hoursPerDay; i++) { TextGraphData graphData = new TextGraphData(NormalizedSunday.AddHours(i)); graphData.MessagesTotal = messagesExchangedPerHour[i]; dataCollection.Add(graphData); } return(dataCollection); }
public List <ITextGraphData> GetAggregateConversationGraphData(DummyPhoneNumberId DummyPhoneNumberId, GraphAggregateType aggregateType) { IConversation conversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId); GraphDataGenerator generator = new GraphDataGenerator(); return(new List <ITextGraphData>(generator.MessageCountAggregate(conversation, aggregateType))); }
private static ITextGraphDataCollection GetAggregateDayOfWeekDataCollection(IConversation conversation) { const int daysPerWeek = 7; int[] messagesExchangedPerDayOfWeek = new int[daysPerWeek]; for (int i = 0; i < daysPerWeek; i++) { messagesExchangedPerDayOfWeek[i] = 0; } foreach (IConversationMessage message in conversation) { messagesExchangedPerDayOfWeek[(int)message.Timestamp.DayOfWeek]++; } TextGraphDataCollection dataCollection = new TextGraphDataCollection(); for (int i = 0; i < daysPerWeek; i++) { TextGraphData graphData = new TextGraphData(NormalizedSunday.AddDays(i)); graphData.MessagesTotal = messagesExchangedPerDayOfWeek[i]; dataCollection.Add(graphData); } return(dataCollection); }
public Task Converse(IConversation conversation) { if (ConversationContext != null) { throw new InvalidOperationException("Already having a conversation"); } ConversationContext = conversation.Context; return(Task .Run(conversation.Start, ConversationContext.TokenSource.Token) .ContinueWith(async t => { if (t.IsFaulted) { var exception = t.Exception?.Flatten().InnerException; if (!(exception is TaskCanceledException)) { Logger.Error(exception, "Caught exception when executing conversation"); } } ConversationContext?.Dispose(); ConversationContext = null; await ModifyStats(exclRequest: true); })); }
public void InvalidArgAggregateTest() { IConversation conversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.TonyWolfCell); GraphDataGenerator generator = new GraphDataGenerator(); generator.MessageCountAggregate(conversation, GraphAggregateType.Unknown); }
public ConversationRendererBase(IDisplayOptionsReadOnly displayOptions, IConversation conversation) { _displayOptions = displayOptions; _conversation = conversation; _lastMessageDate = DateTime.MinValue; _lastMessageReadIndex = -1; _renderedEmptyMessage = false; _remoteContacts = new List<IContact>(); _localSenderColor = Color.FromRgb(210, 0, 0); _remoteSenderColors = new Color[6]; _remoteSenderColors[0] = Color.FromRgb(0, 0, 210); _remoteSenderColors[1] = Color.FromRgb(114, 159, 0); _remoteSenderColors[2] = Color.FromRgb(186, 124, 30); _remoteSenderColors[3] = Color.FromRgb(0, 210, 210); _remoteSenderColors[4] = Color.FromRgb(143, 2, 128); _remoteSenderColors[5] = Color.FromRgb(52, 143, 156); ClearRenderingBuffer(); }
protected override List <ExportError> ExportConversationAttachments(IConversation conversation, string exportFilename, out IAttachmentExportLocator exportLocator) { List <ExportError> exportErrors = new List <ExportError>(); string exportBasePath = Path.GetDirectoryName(exportFilename); AttachmentExportLocator attachmentExportLocator = new AttachmentExportLocator(exportBasePath); string attachmentDirectoryPath = null; bool exportedVideoAttachment = false; bool exportedAudioAttachment = false; foreach (IConversationMessage message in conversation) { if (!message.HasAttachments()) { continue; } if (attachmentDirectoryPath == null) { string attachmentDirectoryName = GenerateAttachmentExportDirectoryName(exportFilename); attachmentDirectoryPath = Path.Combine(exportBasePath, attachmentDirectoryName); attachmentDirectoryPath = FileCreator.CreateNewDirectoryWithRenameAttempts(attachmentDirectoryPath, _exportFileSystem, MaxRenameAttempts); } foreach (IMessageAttachment attachment in message.Attachments) { try { string exportedPath = ExportMessageAttachment(attachment, attachmentDirectoryPath); attachmentExportLocator.AddAttachmentExportLocation(attachment, exportedPath); if (attachment.Type == AttachmentType.Video) { exportedVideoAttachment = true; } else if (attachment.Type == AttachmentType.Audio) { exportedAudioAttachment = true; } } catch (Exception ex) { exportErrors.Add(new ExportError(conversation, ex)); } } } if (exportedVideoAttachment) { string videoIconPath = PlaceVideoIconFile(attachmentDirectoryPath); attachmentExportLocator.AddFileExportLocation(VideoIconOutputFilename, videoIconPath); } if (exportedAudioAttachment) { string audioIconPath = PlaceAudioIconFile(attachmentDirectoryPath); attachmentExportLocator.AddFileExportLocation(AudioIconOutputFilename, audioIconPath); } exportLocator = attachmentExportLocator; return(exportErrors); }
private void VerifyTitleMatchesExpected(IConversation conversation, string titleExpected) { ConversationExporterHtml_Accessor target = new ConversationExporterHtml_Accessor(new MockFileSystem()); string titleActual = target.CreateTitle(conversation); Assert.AreEqual(titleExpected, titleActual); }
private void VerifyHeaderContentTitleLineMatchesByConversation(IConversation conversation, string titleLineExpected) { ConversationExporterHtml_Accessor exporter = new ConversationExporterHtml_Accessor(new MockFileSystem()); string titleLineActual = exporter.CreateContentHeaderTitleLine(conversation); Assert.AreEqual(titleLineExpected, titleLineActual); }
public static int AlphabeticalByContact(IConversation conversationA, IConversation conversationB) { if ((conversationA == null) && (conversationB == null)) { return(0); } else if (conversationA == null) { return(-1); } else if (conversationB == null) { return(1); } int sizeCompare = CompareBasedOnContactListSize(conversationA.AssociatedContacts, conversationB.AssociatedContacts); if (sizeCompare != 0) { return(sizeCompare); } int contactCompare = CompareContactListsAlphabetically(conversationA.AssociatedContacts, conversationB.AssociatedContacts); if (contactCompare != 0) { return(contactCompare); } return(0); }
public void SetDefaultConversation(IConversation conversation) { if (conversation == null) throw new ArgumentNullException("conversation"); if (theDefaultConversation != null) throw new InvalidOperationException("Another default conversation is already set."); theDefaultConversation = conversation; }
public static int AlphabeticalByContact(IConversation conversationA, IConversation conversationB) { if ((conversationA == null) && (conversationB == null)) { return 0; } else if (conversationA == null) { return -1; } else if (conversationB == null) { return 1; } int sizeCompare = CompareBasedOnContactListSize(conversationA.AssociatedContacts, conversationB.AssociatedContacts); if (sizeCompare != 0) { return sizeCompare; } int contactCompare = CompareContactListsAlphabetically(conversationA.AssociatedContacts, conversationB.AssociatedContacts); if (contactCompare != 0) { return contactCompare; } return 0; }
/// <summary> /// tries to determine a value for the requested parameter from a number of possible locations; current response entities, current response, previously provided information (context), or previously provided entities /// </summary> /// <param name="paramName">the parameter to be searching for</param> /// <param name="result">the luis query result that identities the intent and entities</param> /// <param name="c">the current conversation</param> /// <returns></returns> public virtual string GetValue(string paramName, LuisResult result, IConversation c) { var currentEntity = result?.Entities?.FirstOrDefault(x => x.Type.Equals(paramName))?.Entity; if (currentEntity != null) // check the current request entities { return(currentEntity); } if (IsParamRequest(paramName, c)) // was the user responding to a specific request { return(result.Query); } if (c.Context.ContainsKey(paramName)) // check the context data { return(c.Context[paramName]); } var initialEntity = c.Result?.Entities?.FirstOrDefault(x => x.Type.Equals(paramName))?.Entity; if (initialEntity != null) // check the initial request entities { return(initialEntity); } return(string.Empty); }
private async Task StartAudioVideoIVRFlowAsync(IncomingInviteEventArgs <IAudioVideoInvitation> e) { Logger.Instance.Information(string.Format("[StartAudioVideoIVRFlowAsync]: LoggingContext: {0}", m_loggingContext)); m_pstnCallConversation = null; // Step1: accept incoming call Logger.Instance.Information(string.Format("[StartAudioVideoIVRFlowAsync] Step 1: Accept incoming av call: LoggingContext: {0}", m_loggingContext)); await e.NewInvite.AcceptAsync(m_loggingContext).ConfigureAwait(false); await e.NewInvite.WaitForInviteCompleteAsync().ConfigureAwait(false); // if everything is fine, you will be able to get the related conversation m_pstnCallConversation = e.NewInvite.RelatedConversation; m_pstnCallConversation.HandleResourceRemoved += HandlePSTNCallConversationRemoved; // Step 2 : wait AV flow connected and play Promt IAudioVideoCall pstnAv = m_pstnCallConversation.AudioVideoCall; IAudioVideoFlow pstnFlow = await pstnAv.WaitForAVFlowConnected().ConfigureAwait(false); pstnFlow.ToneReceivedEvent += ToneReceivedEvent; // Step 3 : play prompt await PlayPromptAsync(pstnFlow, AudioVideoIVRAction.PlayMainPrompt).ConfigureAwait(false); }
public IntentInput GetInput(ItemContextParameters parameters, IConversation conversation) { var dbName = (!string.IsNullOrEmpty(parameters.Database)) ? parameters.Database : Settings.MasterDatabase; var publishingTargets = PublishWrapper.GetPublishingTargets(dbName); return(IntentInputFactory.Create(IntentInputType.LinkList, publishingTargets)); }
private List <Paragraph> GetMultiDayConversationRenderingExpected(IConversation conversation, ConversationRendererRichText_Accessor renderer) { List <IConversationMessage> messages = new List <IConversationMessage>(conversation); List <Paragraph> paragraphsExpected = new List <Paragraph>(); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(ConversationRendererRichText_Accessor.DateAsInline(messages[0].Timestamp)); paragraph.Inlines.Add(new LineBreak()); paragraph.Inlines.AddRange(renderer.ConversationMessageToInlines(messages[0])); paragraph.Inlines.Add(new LineBreak()); paragraph.Inlines.AddRange(renderer.ConversationMessageToInlines(messages[1])); paragraphsExpected.Add(paragraph); paragraph = new Paragraph(); paragraph.Inlines.Add(new LineBreak()); paragraph.Inlines.Add(ConversationRendererRichText_Accessor.DateAsInline(messages[2].Timestamp)); paragraph.Inlines.Add(new LineBreak()); paragraph.Inlines.AddRange(renderer.ConversationMessageToInlines(messages[2])); paragraph.Inlines.Add(new LineBreak()); paragraph.Inlines.AddRange(renderer.ConversationMessageToInlines(messages[3])); paragraphsExpected.Add(paragraph); return(paragraphsExpected); }
public void RenderSingleMessage24HourTimeTest() { IConversation conversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.UnknownEagle); IConversationMessage message = conversation.GetMessage(0); MockDisplayOptions displayOptions = new MockDisplayOptions(); displayOptions.TimeDisplayFormat = TimeDisplayFormat.HourMinSec24h; ConversationRendererRichText_Accessor renderer = new ConversationRendererRichText_Accessor(displayOptions, conversation); List <Inline> inlineListExpected = new List <Inline>(); Span messagePrefix = new Span(); messagePrefix.Inlines.Add(new Bold(new Run("Unknown Sender"))); messagePrefix.Inlines.Add(new Run(" (\u200E20:38:17\u202C)")); messagePrefix.Inlines.Add(new Run(": ")); inlineListExpected.Add(messagePrefix); inlineListExpected.Add(new ConversationContentRun(message.MessageContents)); List <Inline> inlineListActual = new List <Inline>(); inlineListActual.AddRange(renderer.ConversationMessageToInlines(message)); VerifyInlineListsMatch(inlineListExpected, inlineListActual); }
protected override List<ExportError> ExportConversationAttachments(IConversation conversation, string exportFilename, out IAttachmentExportLocator exportLocator) { List<ExportError> exportErrors = new List<ExportError>(); string exportBasePath = Path.GetDirectoryName(exportFilename); AttachmentExportLocator attachmentExportLocator = new AttachmentExportLocator(exportBasePath); string attachmentDirectoryPath = null; bool exportedVideoAttachment = false; bool exportedAudioAttachment = false; foreach (IConversationMessage message in conversation) { if (!message.HasAttachments()) { continue; } if (attachmentDirectoryPath == null) { string attachmentDirectoryName = GenerateAttachmentExportDirectoryName(exportFilename); attachmentDirectoryPath = Path.Combine(exportBasePath, attachmentDirectoryName); attachmentDirectoryPath = FileCreator.CreateNewDirectoryWithRenameAttempts(attachmentDirectoryPath, _exportFileSystem, MaxRenameAttempts); } foreach (IMessageAttachment attachment in message.Attachments) { try { string exportedPath = ExportMessageAttachment(attachment, attachmentDirectoryPath); attachmentExportLocator.AddAttachmentExportLocation(attachment, exportedPath); if (attachment.Type == AttachmentType.Video) { exportedVideoAttachment = true; } else if (attachment.Type == AttachmentType.Audio) { exportedAudioAttachment = true; } } catch (Exception ex) { exportErrors.Add(new ExportError(conversation, ex)); } } } if (exportedVideoAttachment) { string videoIconPath = PlaceVideoIconFile(attachmentDirectoryPath); attachmentExportLocator.AddFileExportLocation(VideoIconOutputFilename, videoIconPath); } if (exportedAudioAttachment) { string audioIconPath = PlaceAudioIconFile(attachmentDirectoryPath); attachmentExportLocator.AddFileExportLocation(AudioIconOutputFilename, audioIconPath); } exportLocator = attachmentExportLocator; return exportErrors; }
public List <ITextGraphData> GetConversationGraphData(DummyPhoneNumberId DummyPhoneNumberId, GraphTimeUnit timeUnit) { IConversation conversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId); GraphDataGenerator generator = new GraphDataGenerator(); return(new List <ITextGraphData>(generator.MessageCountPerUnitTime(conversation, timeUnit))); }
public static IConversationStatistics CalculateStatistics(IConversation conversation) { ConversationStatistics stats = new ConversationStatistics(); if (conversation == null) { return stats; } Dictionary<DateTime, bool> datesSeen = new Dictionary<DateTime, bool>(); foreach (IConversationMessage message in conversation) { if (!datesSeen.ContainsKey(message.Timestamp.Date)) { datesSeen[message.Timestamp.Date] = true; stats.AddDay(); } if (message.IsOutgoing) { stats.AddSentMessage(); } else { stats.AddReceivedMessage(); } } return stats; }
protected void Page_Load(object sender, EventArgs e) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; if (conversation == null) { throw new Exception("The page doesn't have conversation"); } if (Session["conversationId"] == null) { throw new Exception("We haven't found the Id's conversation in the ASP.NET session"); } object id = Session["conversationId"]; if (!conversation.Id.Equals(id)) { throw new Exception("The conversation in iframe isn't same that conversation in container page. Current.Id " + conversation.Id); } Checker.CheckSpanningConversations(1); lblConversationId.Text = conversation.Id.ToString(); }
public ConversationRendererRichText(IDisplayOptionsReadOnly displayOptions, IConversation conversation) : base(displayOptions, conversation) { _currentParagraph = null; _fileSystem = new OsFileSystem(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BurrowFramework bf = new BurrowFramework(); IConversation conversation = bf.CurrentConversation; Checker.CheckSpanningConversations(0); if (conversation == null) { throw new Exception("The page doesn't have conversation"); } //if (BurrowFramework.ActiveConversations.Count != 1) // throw new Exception("There are more conversations that the expected"); object lastConversationId = Session["conversationId"]; if (lastConversationId == null) { throw new Exception("We haven't found the Id of previous conversation"); } if (conversation.Id.Equals(lastConversationId)) { throw new Exception("The conversation is same that previous, the new conversation was not created"); } } }
public void WriteConversationContentsTest() { IConversation conversation = DummyConversationDataGenerator.GetSingleConversation(DummyPhoneNumberId.ObamaCell); string exportedConversationExpected = "Tuesday, Nov 4, 2008\r\n" + "Me (\u200E10:18:05 PM\u202C): Congrats, buddy!\r\n" + "Barack Obama (\u200E10:18:40 PM\u202C): Thanks. Couldn't have done it without you!\r\n" + "Me (\u200E10:25:58 PM\u202C): np\r\n" + "\r\n" + "Sunday, May 1, 2011\r\n" + "Me (\u200E8:47:27 AM\u202C): Yo, I think I know where Osama Bin Laden is hiding?\r\n" + "Barack Obama (\u200E8:50:52 AM\u202C): o rly?\r\n" + "Me (\u200E8:51:21 AM\u202C): Yeah, dude. Abottabad, Pakistan. Huge compound. Can't miss it.\r\n" + "Barack Obama (\u200E8:51:46 AM\u202C): Sweet. I'll send some navy seals."; ConversationExporterPlaintext_Accessor conversationExporter = new ConversationExporterPlaintext_Accessor(new MockFileSystem()); MemoryStream outputStream = new MemoryStream(); StreamWriter sw = new StreamWriter(outputStream); conversationExporter.WriteConversationContents(sw, conversation, new MockDisplayOptions(), new AttachmentExportLocator(null)); sw.Flush(); outputStream.Seek(0, SeekOrigin.Begin); StreamReader sr = new StreamReader(outputStream); string exportedConversationActual = sr.ReadToEnd(); Assert.AreEqual(exportedConversationExpected, exportedConversationActual); }
public async void TestSetup() { m_loggingContext = new LoggingContext(Guid.NewGuid()); var data = TestHelper.CreateApplicationEndpoint(); m_mockEventChannel = data.EventChannel; m_restfulClient = data.RestfulClient; ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint; await applicationEndpoint.InitializeAsync(m_loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(m_loggingContext).ConfigureAwait(false); m_restfulClient.HandleRequestProcessed += (sender, args) => { TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_MessagingInvitationStarted.json", m_mockEventChannel); TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_ConversationConnected.json", m_mockEventChannel); TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_ParticipantAdded.json", m_mockEventChannel); }; IMessagingInvitation invitation = await applicationEndpoint.Application.Communication .StartMessagingAsync("Test subject", new SipUri("sip:[email protected]"), "https://example.com/callback", m_loggingContext) .ConfigureAwait(false); m_conversation = invitation.RelatedConversation; }
private void VerifyConversationHeaderMatches(IConversation conversation, string headerExpected) { ConversationExporterPlaintext_Accessor exporter = new ConversationExporterPlaintext_Accessor(new MockFileSystem()); string headerActual = exporter.CreateHeaderConversationLine(conversation); Assert.AreEqual(headerExpected, headerActual); }
/// <summary> /// Отправляет Push-уведомление внутри приложения. /// </summary> /// <param name="conversation">Беседа, уведомление для которой нужно отправить.</param> /// <param name="message">Сообщение для отправки.</param> private void SendPush(IConversation conversation, VKMessage message) { if ((message.Type & VKMessageType.Sent) == VKMessageType.Sent) { return; } var navParameter = new NavigateToPageMessage { Page = AppViews.ConversationView, Parameter = conversation.ID }; string title = null; if (message.IsChatMessage) { title = String.Format("{0}\n{1}", message.Sender.FullName, conversation.Title); } else { title = message.Sender.FullName; } CoreHelper.SendInAppPush(message.Body, title, PopupMessageType.Default, message.Sender.Photo50, parameter: navParameter); }
public async void TestSetup() { m_loggingContext = new LoggingContext(Guid.NewGuid()); var data = TestHelper.CreateApplicationEndpoint(); m_restfulClient = data.RestfulClient; m_eventChannel = data.EventChannel; await data.ApplicationEndpoint.InitializeAsync(m_loggingContext).ConfigureAwait(false); await data.ApplicationEndpoint.InitializeApplicationAsync(m_loggingContext).ConfigureAwait(false); var communication = data.ApplicationEndpoint.Application.Communication; m_restfulClient.HandleRequestProcessed += (sender, args) => { // Deliver invitation started events TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_MessagingInvitationStarted.json", m_eventChannel); TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.AudioInvitations, HttpMethod.Post, "Event_AudioInvitationStarted.json", m_eventChannel); TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.AudioVideoInvitations, HttpMethod.Post, "Event_AudioVideoInvitationStarted.json", m_eventChannel); // Deliver conversation deleted event TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.Conversation, HttpMethod.Delete, "Event_ConversationDeleted.json", m_eventChannel); }; // Start a conversation with messaging modality IMessagingInvitation invitation = await communication .StartMessagingWithIdentityAsync("Test message", "sip:[email protected]", "https://example.com/callback", "Test user 1", "sip:[email protected]") .ConfigureAwait(false); m_conversation = invitation.RelatedConversation; }
protected virtual void AfterMethodExecution(MethodInfo methodInfo) { IPersistenceConversationInfo att = Metadata.GetConversationInfoFor(methodInfo); var cca = ConversationsContainerAccessor; if (att == null || cca == null) { return; } IConversation c = cca.Container.Get(conversationId); switch (att.ConversationEndMode) { case EndMode.End: c.End(); c.Dispose(); break; case EndMode.Abort: c.Abort(); c.Dispose(); break; case EndMode.CommitAndContinue: c.FlushAndPause(); break; case EndMode.DoNothing: break; default: c.Pause(); break; } }
protected virtual void BeforeMethodExecution(MethodInfo methodInfo) { IPersistenceConversationInfo att = Metadata.GetConversationInfoFor(methodInfo); var cca = ConversationsContainerAccessor; if (att == null || cca == null) { return; } string convId = GetConvesationId(Metadata.Setting); IConversation c = cca.Container.Get(convId); if (c == null) { var cf = ConversationFactory; if (cf == null) { return; } c = cf.CreateConversation(convId); // we are using the event because a custom eventHandler can prevent the rethrow // but we must Unbind the conversation from the container // and we must dispose the conversation itself (high probability UoW inconsistence). c.OnException += ((conversation, args) => cca.Container.Unbind(c.Id).Dispose()); ConfigureConversation(c); cca.Container.SetAsCurrent(c); c.Start(); } else { cca.Container.SetAsCurrent(c); c.Resume(); } }
protected virtual void ConfigureConversation(IConversation conversation) { IConversationCreationInterceptor cci = null; Type creationInterceptorType = Metadata.Setting.ConversationCreationInterceptor; if (creationInterceptorType != null) { cci = creationInterceptorType.IsInterface ? GetConversationCreationInterceptor(creationInterceptorType) : creationInterceptorType.Instantiate <IConversationCreationInterceptor>(); } else { if (Metadata.Setting.UseConversationCreationInterceptorConvention) { Type concreteImplementationType = BaseConventionType.MakeGenericType(Metadata.ConversationalClass); cci = GetConversationCreationInterceptor(concreteImplementationType); } } if (cci != null) { cci.Configure(conversation); } if (Metadata.Setting.AllowOutsidePersistentCall) { var conversationWithOpc = conversation as ISupportOutsidePersistentCall; if (conversationWithOpc == null) { throw new InvalidOperationException("The conversation doesn't support outside persistent call"); } conversationWithOpc.UseSupportForOutsidePersistentCall = true; } }
protected override void OnLeave(IConversation conversation) { base.OnLeave(conversation); var c = ConversationStatistics.Get(conversation); c.LastLeaveTime = DateTime.Now; c.WorkTime += c.LastLeaveTime - c.LastEnterTime; }
/// <summary> /// get a valid parameter object by checking for it in the previously retrieved data store or by finding it based on the information provided by the user /// </summary> /// <param name="paramName">the parameter to retrieve</param> /// <param name="result">the luis response that provides intent and entity information provided by the user</param> /// <param name="c">the current conversation</param> /// <param name="parameters">the context paramters</param> /// <param name="GetValidParameter">the method that can retrieve the valid parameters for a valid user input</param> /// <returns></returns> public virtual bool TryGetParam(string paramName, LuisResult result, IConversation c, ItemContextParameters parameters, Func <string, ItemContextParameters, IConversation, object> GetValidParameter) { var storedValue = c.Data.ContainsKey(paramName) ? c.Data[paramName] : null; if (storedValue != null) { return(true); } string value = GetValue(paramName, result, c); if (string.IsNullOrEmpty(value)) { return(false); } var validParam = GetValidParameter(value, parameters, c); if (validParam == null) { return(false); } if (IsParamRequest(paramName, c)) // clear any request for this property { c.Context.Remove(ReqParam); } c.Context[paramName] = value; c.Data[paramName] = validParam; return(true); }
public EmployeeController(IConversation conversation, IMappingEngine mapper, EmployeeRepository repository, IValidator validator, IStringConverter<Employee> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
public CustomerController(IConversation conversation, IMappingEngine mapper, CustomerRepository repository, IValidator validator, IStringConverter<Customer> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
public ConversationDouble(bool useStrictMocking, IConversationContext context, IConversation userSpecifiedDouble) { if (context == null) throw new ArgumentNullException("context"); this.context = context; strict = useStrictMocking; userDouble = userSpecifiedDouble; }
public OrderDetailController(IConversation conversation, IMappingEngine mapper, OrderDetailRepository repository, IValidator validator, IStringConverter<OrderDetail> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
/// <summary> /// Deactivates the conversation. /// </summary> /// <param name="conversation">The conversation.</param> public void DeactivateConversation(IConversation conversation) { if (conversation == null) throw new ArgumentNullException("conversation"); if (conversation.IsActive) { ConversationSessionContext.CurrentConversation = null; } }
public RegionController(IConversation conversation, IMappingEngine mapper, RegionRepository repository, IValidator validator, IStringConverter<Region> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
public void Start(IConversation conversation) { foreach (var transactor in GetTransactors()){ transactor.Start(conversation); } }
public ProductController(IConversation conversation, IMappingEngine mapper, ProductRepository repository, IValidator validator, IStringConverter<Product> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
public ConversationListItem(IConversation conversation) { _descriptionHelper = new ConversationDescriptionHelper(); this.Description = GetDescription(conversation); this.Conversation = conversation; }
public TerritoryController(IConversation conversation, IMappingEngine mapper, TerritoryRepository repository, IValidator validator, IStringConverter<Territory> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
public void Setup() { scene = new Scene(); conversation1 = Substitute.For<IConversation>(); conversation2 = Substitute.For<IConversation>(); conversation3 = Substitute.For<IConversation>(); conversation4 = Substitute.For<IConversation>(); }
protected override void OnEnter(IConversation conversation) { base.OnEnter(conversation); var c = ConversationStatistics.Get(conversation); c.Enters++; c.LastEnterTime = DateTime.Now; if(c.LastLeaveTime.Year>1900){ c.StayTime += (c.LastEnterTime - c.LastLeaveTime); } }
public ITextGraphDataCollection MessageCountPerUnitTime(IConversation conversation, GraphTimeUnit timeUnit) { switch (timeUnit) { case GraphTimeUnit.Month: return GetPerMonthDataCollection(conversation); default: throw new ArgumentException("Invalid graph type", "timeUnit"); } }
public void AddConversation(IConversation conversation) { if (conversation == null) throw new ArgumentException("Can't add Null Conversation!"); if (conversationList.Contains(conversation)) return; conversationList.Add(conversation); }
public List<ExportError> Export(IConversation conversation, IDisplayOptionsReadOnly displayOptions, string exportFilename) { IAttachmentExportLocator exportLocator; List<ExportError> attachmentExportErrors = DoAttachmentExport(conversation, displayOptions, exportFilename, out exportLocator); List<ExportError> conversationTextExportErrors = DoConversationTextExport(conversation, displayOptions, exportFilename, exportLocator); List<ExportError> exportErrors = new List<ExportError>(); exportErrors.AddRange(attachmentExportErrors); exportErrors.AddRange(conversationTextExportErrors); return exportErrors; }
private void VerifyExportErrorString(IConversation conversation, Exception ex, string descriptionExpected) { ExportError exportError = new ExportError(conversation, ex); var mockDescriptionHelper = new Mock<IConversationDescriptionHelper>(); mockDescriptionHelper.Setup(x => x.GetDescription(It.IsAny<IConversation>())) .Returns("<some conversation>"); ExportErrorFormatter errorFormatter = new ExportErrorFormatter(mockDescriptionHelper.Object); string descriptionActual = errorFormatter.Format(exportError); Assert.AreEqual(descriptionExpected, descriptionActual); }
protected override void OnLeave(IConversation conversation) { if (conversation.ActualEnters == 1){ if (conversation.iscanbecommited()){ conversation.cancelcanbecommited(); Commit(conversation); } if (conversation.isneedcleanonleave()){ Rollback(conversation); } } }
public int FindConversationIndex(IConversation conversation) { for (int conversationIndex = 0; conversationIndex < ConversationCount; conversationIndex++) { if (GetConversation(conversationIndex) == conversation) { return conversationIndex; } } return -1; }
public ITextGraphDataCollection MessageCountAggregate(IConversation conversation, GraphAggregateType aggregateType) { switch (aggregateType) { case GraphAggregateType.DayOfWeek: return GetAggregateDayOfWeekDataCollection(conversation); case GraphAggregateType.HourOfDay: return GetAggregateHourOfDayDataCollection(conversation); default: throw new ArgumentException("Invalid graph type", "aggregateType"); } }
public string CreateExportFilenameSuggestion(IConversation conversation) { string filenameFormat = "{0} - {1} - {2}"; IContact contact = conversation.AssociatedContacts[0]; string description = _descriptionHelper.GetDescription(conversation); string suggestedFilename = string.Format(filenameFormat, FilenamePrefix, description, GetCurrentDatestamp()); return ReplaceIllegalFilenameCharacters(suggestedFilename); }
public void Bind(IConversation conversation) { if (conversation == null) { throw new ArgumentNullException("conversation"); } if(AutoUnbindAfterEndConversation) { conversation.Ended += ((x, y) => Unbind(conversation.Id)); } Store[conversation.Id] = conversation; SetCurrentIfNecessary(); }