private void SendMessageCallback(IAsyncResult ar) { try { InstantMessageModality imModality = (InstantMessageModality)ar.AsyncState; imModality.EndSendMessage(ar); } catch { } }
private static void ChatRecived(object sender, MessageSentEventArgs e) { InstantMessageModality nananana = (InstantMessageModality)sender; // el user ees elPibe string elPibe = nananana.Endpoint.DisplayName.Substring(0, nananana.Endpoint.DisplayName.LastIndexOf("@")); // por ahora, luego habrá que separar los argumentos, //no mejor habria que derivar del comando cuantos y que arg lleva y preguntarlos y esas cosas que le gustan al Colo string elComando = e.Text; //loguear Console.WriteLine(DateTime.Now + ". " + elPibe + " dice: " + elComando); nananana.BeginSendMessage("Llegó, gracias " + elPibe, (ar) => { nananana.EndSendMessage(ar); }, null); //Executar comando y contar como va yendo y esa onda var elResul = Ejecuta(elPibe, elComando); Console.WriteLine(elResul); nananana.BeginSendMessage(elResul, (ar) => { nananana.EndSendMessage(ar); }, null); }
/* * /// <summary> * /// Start the conversation with the specified participant using sip address * /// </summary> * /// <param name="sender"></param> * /// <param name="e"></param> * private void btnStartConv_Click(object sender, RoutedEventArgs e) * { * TextRange tr = new TextRange(rtbParticipants.Document.ContentStart, rtbParticipants.Document.ContentEnd); * if (String.IsNullOrEmpty(tr.Text.Trim())) * { * txtErrors.Text = "No participants specified!"; * return; * } * String[] participants = tr.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); * * KeyValuePair<AutomationModalitySettings, object>[] contextData = new KeyValuePair<AutomationModalitySettings, object>[] * { * new KeyValuePair<AutomationModalitySettings, object>(AutomationModalitySettings.SendFirstInstantMessageImmediately, true), * new KeyValuePair<AutomationModalitySettings, object>(AutomationModalitySettings.FirstInstantMessage, "Hello World"), * new KeyValuePair<AutomationModalitySettings, object>(AutomationModalitySettings.Subject, "Welcome To Lync Conversation Window"), * }; * * IAsyncResult ar = automation.BeginStartConversation(AutomationModalities.InstantMessage, participants, contextData, null, null); * automation.EndStartConversation(ar); * } */ /// <summary> /// Async callback method invoked by InstantMessageModality instance when SendMessage completes /// </summary> /// <param name="_asyncOperation">IAsyncResult The operation result</param> /// private void SendMessageCallback(IAsyncResult ar) { InstantMessageModality imModality = (InstantMessageModality)ar.AsyncState; try { imModality.EndSendMessage(ar); } catch (LyncClientException lce) { MessageBox.Show("Lync Client Exception on EndSendMessage " + lce.Message); } }
private void AfterMessageSent(IAsyncResult ar) { try { sender.EndSendMessage(ar); } catch (Exception) { // eat exception } finally { sender.BeginSetComposing(false, null, null); } }
private void SendMessageCallback(InstantMessageModality imModality, IAsyncResult asyncResult) { try { imModality.EndSendMessage(asyncResult); } catch (Exception ex) { Trace.WriteLine("Exception during SendMessageCallback"); Trace.WriteLine($"{ex.Message}"); Trace.WriteLine($"{ex.StackTrace}"); } finally { _sendIMEvent.Set(); } }
void ConversationTest_InstantMessageReceived(object sender, MessageSentEventArgs e) { ShowNewMessage(e); try { if (_ConversationImModality.CanInvoke(ModalityAction.SendInstantMessage)) { _ConversationImModality.BeginSendMessage( "Got your message", (ar) => { _ConversationImModality.EndSendMessage(ar); } , null); } } catch (LyncClientException ex) { txtErrors.Text = ex.Message; } }
public static void makeMessage(int flag, InstantMessageModality insM, string add) { Conversation conv = insM.Conversation; string Message = ""; Random r = new Random(); if (flag == 0) { string[] arr = add.Split(' '); try { conn.Open(); DataSet ds = new DataSet(); String sql; sql = "SELECT res FROM bot where req = '" + arr[0] + "'"; MySqlDataAdapter adpt = new MySqlDataAdapter(sql, conn); adpt.Fill(ds, "bot"); try { Message = ds.Tables[0].Rows[r.Next(ds.Tables[0].Rows.Count)].ItemArray[0].ToString(); // res 가 2개일때 처리 } catch { Message = "알 수 없는 명령어 입니다. \r\n\r\n EX) !추가 [가르칠 말] [반응할 말]"; } conn.Close(); } catch (Exception e) { Console.WriteLine(e.StackTrace); conn.Close(); } } if (flag == 1) { int a = 17 - Convert.ToInt32(DateTime.Now.ToString("HH")); int b = 59 - Convert.ToInt32(DateTime.Now.ToString("mm")); int c = 59 - Convert.ToInt32(DateTime.Now.ToString("ss")); Message = "퇴근시간까지 " + a.ToString() + "시간 " + b.ToString() + "분 " + c.ToString() + "초 남았습니다."; } if (flag == 2) { Message = "1~100 을 굴려 " + r.Next(1, 100) + "가 나왔습니다."; } if (flag == 3) { string[] arr = add.Split(' '); string Carr = ""; for (int i = 1; i < arr.Length; i++) { Carr += arr[i] + " "; } conn.Open(); String sql = "INSERT INTO bot (req, res) VALUES ('" + arr[0] + "', '" + Carr + "')"; MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); conn.Close(); Message = "알림 : !" + arr[0] + " 추가 되었습니다."; } if (flag == 4) { Meal SJ = new Meal(); string meal = SJ.parse(add); meal = meal.Replace("한식(쌀밥)", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 한식(쌀밥)</DIV>\r\n\r\n"); meal = meal.Replace("한식(잡곡밥)", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 한식(잡곡밥)</DIV>\r\n\r\n"); meal = meal.Replace("간편식", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 간편식</DIV>\r\n\r\n"); meal = meal.Replace("해장국", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 해장국</DIV>\r\n\r\n"); meal = meal.Replace("분식", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 분식</DIV>\r\n\r\n"); meal = meal.Replace("건강식", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 건강식</DIV>\r\n\r\n"); meal = meal.Replace("선택코너", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 선택코너</DIV>\r\n\r\n"); meal = meal.Replace("일품식", "\r\n\r\n<DIV style = 'color: green;font:bold; font-size:20p;'> 일품식</DIV>\r\n\r\n"); messageDictionary = new Dictionary <InstantMessageContentType, string>(); messageDictionary.Add(InstantMessageContentType.Html, meal); goto SENDSTART; } string FormattedMessage = "<DIV style='color: green;font:bold; font-size:20p;'>" + Message + "</DIV>"; messageDictionary = new Dictionary <InstantMessageContentType, string>(); messageDictionary.Add(InstantMessageContentType.Html, FormattedMessage); SENDSTART: insM.BeginSendMessage(messageDictionary, ar => { try { insM.EndSendMessage(ar); } catch (Exception ex) { } }, null); }