public async static Task Initialization(string storageConnectionString, string scenarioTableName, string scenarioName, string conversationLogTableName) { try { Global.DebugServicesURL = CloudConfigurationManager.GetSetting("LAMBF.DebugServicesURL"); ScenarioName = scenarioName; CloudTableClient tableClient = CloudStorage.GetTableClient(storageConnectionString); // Run these initlializations in parallel await ConversationLog.GetTableReference(tableClient, conversationLogTableName).CreateIfNotExistsAsync(); await Scenario.GetTableReference(tableClient, scenarioTableName).CreateIfNotExistsAsync(); tableLog = ConversationLog.GetTableReference(tableClient, conversationLogTableName); tableScenario = Scenario.GetTableReference(tableClient, scenarioTableName); //INIT TRANSLATOR string TranslateKey = CloudConfigurationManager.GetSetting("LAMBF.TranslatorKey"); if (!string.IsNullOrEmpty(TranslateKey)) { Global.admAuth = new ADMAuthentication(TranslateKey); Global.TranslationEnabled = true; } } catch (Exception e) { } }
public void SendPrivateMessage(String msgFrom, String msg, String msgTo) { List <Connection> connList = new List <Connection>(); using (IdentityFrameworkUtils utils = new IdentityFrameworkUtils()) connList = utils.GetUserConnectionInfo(msgTo); if (connList.Count > 0) { Clients.Caller.receiveMessage(msgFrom, msg, msgTo, true); Clients.Client(connList.FirstOrDefault().ConnectionID).receiveMessage(msgFrom, msg, msgTo, false); using (IdentityFrameworkUtils utils = new IdentityFrameworkUtils()) { ConversationLog log = new ConversationLog { ClientIp = HttpContext.Current != null ? HttpContext.Current.Request.UserHostAddress : null, CreatedOn = DateTime.Now, FromUser = msgFrom, ToUser = msgTo, Message = msg }; utils.SaveConversation(log, msgFrom); } } else { //ERROR } }
protected override void OnDrawItem(DrawItemEventArgs e) { if (-1 != e.Index) { if (null == SelectedTestLog) { return; } e.DrawBackground(); String text = Items[e.Index].ToString(); ConversationLog logForConversation = mSelectedTestLog.ConversationLogs.ToList()[e.Index]; if (null == logForConversation) { return; } e.Graphics.DrawString(text, Font, new SolidBrush(logForConversation.TestStatus.GetColor()), e.Bounds); } base.OnDrawItem(e); }
/// <inheritdoc /> public async Task CreateConversationLog(ITurnContext context, string botReply) { // Build a log object to write to the database. ConversationLog logData = new ConversationLog { From = context.Activity.From, Recipient = context.Activity.Recipient, Conversation = context.Activity.Conversation, ChannelData = context.Activity.ChannelData, ChannelId = context.Activity.ChannelId, Time = DateTime.Now.ToString(CultureInfo.InvariantCulture), Message = context.Activity.Text, Reply = botReply }; // Write our log to the database. try { await this.docClient.CreateDocumentAsync( UriFactory.CreateDocumentCollectionUri( this.dataConfig.DatabaseName, this.dataConfig.ConversationLogTable), logData); } catch (Exception ex) { // More logic for what to do on a failed write can be added here throw ex; } }
public void SaveConversation(ConversationLog log, String msgFrom) { var from = context.Users .Include(u => u.ConversationLogs) .SingleOrDefault(u => u.UserName == msgFrom); from.ConversationLogs.Add(log); context.SaveChanges(); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } instance = this; }
/// <inheritdoc /> public async Task OnTurnAsync( ITurnContext context, NextDelegate next, CancellationToken cancellationToken = new CancellationToken()) { string botReply = string.Empty; if (context.Activity.Type == ActivityTypes.Message) { // Create a send activity handler to grab all response activities // from the activity list. context.OnSendActivities( async(activityContext, activityList, activityNext) => { if (activityList.Any()) { botReply = string.Join("\n\n", activityList.Select(a => a.Text)); } return(await activityNext()); }); } // Pass execution on to the next layer in the pipeline. await next(cancellationToken); // Save logs for each conversational exchange only. if (context.Activity.Type == ActivityTypes.Message) { // Build a log object to write to the database. var logData = new ConversationLog { From = context.Activity.From, Recipient = context.Activity.Recipient, Conversation = context.Activity.Conversation, ChannelData = context.Activity.ChannelData, ChannelId = context.Activity.ChannelId, Time = DateTime.Now.ToString( CultureInfo.InvariantCulture), Message = context.Activity.Text, Reply = botReply }; // Write our log to the database. try { await this.conversationRepository.Save(logData); } catch (Exception ex) { // More logic for what to do on a failed write can be added here throw ex; } } }
private void ShowLog(ConversationLog currentLog) { lVSteps.BeginUpdate(); lVSteps.Items.Clear(); currentLog.Steps.ForEach(step => { var item = new ListViewItem(step.Number.ToString(CultureInfo.InvariantCulture)); item.SubItems.Add(step.Message); item.SubItems.Add(step.Status.GetDescription().ToUpper()); item.SubItems.Add(step.ErrorMessage); lVSteps.Items.Add(item); }); lVSteps.EndUpdate(); ShowPairs(currentLog.Conversation, null); }
public void LoadDetails() { int selectedIndex = cBConversations.SelectedIndex; if (-1 == selectedIndex) { return; } if (null == SelectedTest) { return; } ConversationLog currentLog = SelectedTest.Log.ConversationLogs[selectedIndex]; ShowLog(currentLog); }
public List <KeyValuePair <int, int> > LoadScenario(string Scenario, string DateStart, string DateFinish) { IEnumerable <ConversationLog> CL = ConversationLog.LoadScenario(Global.tableLog, Scenario); int[] A = new int[500]; foreach (ConversationLog item in CL) { if ((item.Origin == "USER") && (item.CurrentQuestion > -1)) { A[item.CurrentQuestion]++; } } List <KeyValuePair <int, int> > LII = new List <KeyValuePair <int, int> >(); for (int i = 0; i < A.Length; i++) { if (A[i] != 0) { LII.Add(new KeyValuePair <int, int>(i, A[i])); } } return(LII); }
private void StartTest(IEnumerable <Conversation> conversations) { foreach (Conversation conversation in conversations) { mCurrentLog = new ConversationLog(this, conversation); try { ProcessConversation(conversation); } catch (TestNotSupportedException e) { mCurrentLog.ErrorMessage = e.Message; StepNotDetected(e.Message); //if (null != OnTestNotSupported) // OnTestNotSupported(this, new TestNotSupportedEventArgs(e.Message)); } catch (Exception e) { StepFailed(e); } finally { if (null != OnConversationTested) { OnConversationTested(this, new ConversationLogEventArgs(mCurrentLog)); } Log.Add(mCurrentLog); mCurrentLog = null; mCurrentStepNum = 0; } } }
private void lVSteps_SelectedIndexChanged(object sender, EventArgs e) { var lVSender = sender as ListView; if (null == lVSender) { throw new ArgumentException("", "sender"); } if (null == SelectedTest) { return; } if (0 == lVSender.SelectedIndices.Count) { mSelectedStep = null; return; } ConversationLog currentLog = SelectedTest.Log.ConversationLogs.FirstOrDefault( item => item.Conversation == cBConversations.SelectedConversation); int selectedIndex = lVSender.SelectedIndices[0]; if (selectedIndex > currentLog.Steps.Count) { throw new IndexOutOfRangeException(); } mSelectedStep = currentLog.Steps[selectedIndex]; ClearRequestResponse(); ShowPairs(currentLog.Conversation, mSelectedStep); }
public ConversationLogEventArgs(ConversationLog log) { Log = log; }
override public void BuildModel() { try { ConversationLog = ConversationLog.OrderBy(c => c.ResponseTimestamp).ToList(); if (ConversationLog.Count > 2) { Name = ConversationLog[3].Request.Input.Text; } else { return; } for (int i = 0; i < ConversationLog.Count; i++) { var input = ""; if (ConversationLog.Count > i) { input = ConversationLog[i + 1].Request.Input.Text; } var outputs = ConversationLog[i].Response.Output.Text; switch (i) { case 0: Interested = input; break; case 1: Roles = input; break; case 3: Phone = input; break; case 4: Email = input; break; case 5: FutureMeetTime = input; break; case 6: PreferredContactMethod = input; break; } string botSays = ""; foreach (var output in outputs) { botSays += String.Format(@"<p>Bot says:</p><p>{0}<p>", output); } ConversationLogString += String.Format("{0}<p>{1} says:</p><p>{2}</p>", botSays, Name, input); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public Task Save(ConversationLog conversationLog) { return(this.UpsertItemAsync(conversationLog)); }