//button 3 click event handler //sends IM to selected contacts private void button3_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Sending IM..."); Automation automation = LyncClient.GetAutomation(); //add contact URIs to a List object List <string> inviteeList = new List <string>(); for (int i = 0; i < listBox1.SelectedItems.Count; i++) { inviteeList.Add(listBox1.SelectedItems[i].ToString()); } //create settings object Dictionary <AutomationModalitySettings, object> settings = new Dictionary <AutomationModalitySettings, object>(); //specify message modality AutomationModalities mode = AutomationModalities.InstantMessage; //add settings to the settings object settings.Add(AutomationModalitySettings.FirstInstantMessage, "Weekly project status conference is starting..."); settings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); //launch the conference invite IAsyncResult ar = automation.BeginStartConversation( mode , inviteeList , settings , EndStartConversation , null); }
private void EnviarMensajeBienvenida() { List <string> inviteeList = new List <string>(); inviteeList.Add("sip:[email protected]"); // Create a generic Dictionary object to contain // conversation setting objects. Dictionary <AutomationModalitySettings, object> modalitySettings = new Dictionary <AutomationModalitySettings, object>(); AutomationModalities chosenMode = AutomationModalities.InstantMessage; string firstIMMessageText = textBox1.Text; IAsyncResult ar = automation.BeginStartConversation( chosenMode , inviteeList , modalitySettings , null , null); modalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, firstIMMessageText); modalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); IAsyncResult er = automation.BeginStartConversation( chosenMode , inviteeList , modalitySettings , null , null); }
/// <summary> /// 会话开启通用方法 /// </summary> /// <param name="participantList">参会人</param> /// <param name="automationModeality">会话类型</param> void StartConference_H(List <string> participantList, AutomationModalities automationModeality) { try { Dictionary <AutomationModalitySettings, object> dic = new Dictionary <AutomationModalitySettings, object>(); dic.Add(AutomationModalitySettings.FirstInstantMessage, Constant.ConferenceName + this.conversationImFirstInfo); dic.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); LyncClient.GetAutomation().BeginStartConversation( automationModeality, participantList, dic, (ar) => { try { ////获取主会话窗 //ConversationWindow window = LyncClient.GetAutomation().EndStartConversation(ar); /////注册会话更改事件 //window.StateChanged += window_StateChanged; } catch (OperationException oe) { System.Windows.MessageBox.Show("开启会话出现异常" + oe.Message); }; }, null); } catch (Exception ex) { LogManage.WriteLog(this.GetType(), ex); } }
/// <summary> /// Click event handler for StartIM button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StartIM_Click(object sender, EventArgs e) { try { // Check the entire row is selected or not in the grid view. if (SearchResults.SelectedRows.Count > 0) { // Check the selected contacts Uri is not null or empty. if (!string.IsNullOrEmpty(SearchResults.SelectedRows[0].Cells[0].Value.ToString())) { string selectedPerson = (string)SearchResults.SelectedRows[0].Cells[0].Value; // Get the selected contact by Uri. Contact selectedContact = contactMgr.GetContactByUri(selectedPerson); // Create a list of the contact to start conversation. List <string> lstInvitee = new List <string>(); lstInvitee.Add(selectedPerson); // Create text for the first IM message. string firstIMMessageText = Message.Text; // Create a generic Dictionary object to contain // conversation setting objects. Dictionary <AutomationModalitySettings, object> modalitySettings = new Dictionary <AutomationModalitySettings, object>(); AutomationModalities chosenMode = AutomationModalities.InstantMessage; modalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, firstIMMessageText); modalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); // Start the conversation. IAsyncResult arStartConversation = automation.BeginStartConversation( chosenMode , lstInvitee , modalitySettings , StartConversationCallback , null); } else { MessageBox.Show("Contact Uri is null or empty."); } } else { MessageBox.Show("Select the entire row to start conversation."); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
internal NotifierLync() { try { _Automation = LyncClient.GetAutomation(); // Create a generic Dictionary object to contain conversation setting objects. _ModalitySettings = new Dictionary <AutomationModalitySettings, object>(); _ModalitySettings.Add(AutomationModalitySettings.Subject, subject); _ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); _ChosenMode = AutomationModalities.InstantMessage; } catch (Exception) { throw; } }
//share browser private void button4_Click(object sender, RoutedEventArgs e) { string browser = GetDefaultBrowserPath(); Process process = new Process(); process.StartInfo.FileName = "iexplore.exe"; process.StartInfo.Arguments = "-nomerge http://www.google.com"; process.Start(); while (process.MainWindowHandle == IntPtr.Zero) { System.Threading.Thread.Sleep(100); } string contacts = Environment.GetCommandLineArgs()[2]; contacts = contacts.Substring(contacts.IndexOf("<") + 1).TrimEnd(new char[] { '>' }); _LyncClient = Microsoft.Lync.Model.LyncClient.GetClient(); List <string> c = new List <string>(); c.Add(contacts); Microsoft.Lync.Model.Extensibility.Automation automation = Microsoft.Lync.Model.LyncClient.GetAutomation(); AutomationModalities _ChosenMode = AutomationModalities.ApplicationSharing | AutomationModalities.InstantMessage; Dictionary <AutomationModalitySettings, object> _ModalitySettings = new Dictionary <AutomationModalitySettings, object>(); // Add the process Id to the modality settings for the conversation. _ModalitySettings.Add(AutomationModalitySettings.SharedProcess, process.Id); // Add the main window handle to the modality settings for the conversation. _ModalitySettings.Add(AutomationModalitySettings.SharedWindow, process.MainWindowHandle); // Adds text to toast and local user IMWindow text-entry control. _ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, "Hello Serkant. I would like to share my first running process with you."); _ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); IAsyncResult res = automation.BeginStartConversation(_ChosenMode, c, _ModalitySettings, StartConversationCallback2, null); //automation.EndStartConversation(res); }
internal JiraLync() { try { _Automation = LyncClient.GetAutomation(); // Create a generic List object to contain a contact URI. // Ensure that a valid URI is added. inviteeList = new List <string>(); inviteeList.Add(Properties.Settings.Default.SupportPerson); // Create a generic Dictionary object to contain conversation setting objects. _ModalitySettings = new Dictionary <AutomationModalitySettings, object>(); _ModalitySettings.Add(AutomationModalitySettings.Subject, "JIRA Tool Issues"); _ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); _ChosenMode = AutomationModalities.InstantMessage; } catch (Exception) { throw; } }
//event handler sends conference invitations private void button3_Click(object sender, RoutedEventArgs e) { Automation automation = LyncClient.GetAutomation(); //add contact URIs to a List object List <string> inviteeList = new List <string>(); for (int i = 0; i < listBox1.SelectedItems.Count; i++) { inviteeList.Add(listBox1.SelectedItems[i].ToString()); } //create settings object Dictionary <AutomationModalitySettings, object> settings = new Dictionary <AutomationModalitySettings, object>(); //specify message modality AutomationModalities mode = AutomationModalities.InstantMessage; //add settings to the settings object settings.Add(AutomationModalitySettings.FirstInstantMessage, "Weekly project status conference is starting..."); settings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); //launch the conference invite IAsyncResult ar = automation.BeginStartConversation( mode , inviteeList , settings , null , null); //get the conversation object ConversationWindow window = automation.EndStartConversation(ar); Conversation conference = window.Conversation; //display the conference URI textBox1.Text = "conference URI: " + conference.Properties[ConversationProperty.ConferencingUri] + "?" + conference.Properties[ConversationProperty.Id]; }
static void Main(string[] args) { //check if the log file 15 exist, meaning Lync log files if (Directory.Exists(_logLocation_15)) { //Array to hold the .uccapilog files string[] getLyncLogs = Directory.GetFiles(_logLocation_15, "*.uccapilog"); //check the temp folder exist and clean CreateAndClean(getLyncLogs); } //check if the log file 16 exist, meaning Skype for business log files else if (Directory.Exists(_logLocation_16)) { //Array to hold the .uccapilog files string[] getSkypelog = Directory.GetFiles(_logLocation_16, "*.uccapilog"); //check if the temp folder exist and clean CreateAndClean(getSkypelog); } /* * following part was written by Christoph Weste and all credit goes to him * twitter account @_cweste */ string s2 = null; if (args.Length > 0) { Console.WriteLine("User: {0}", args[0]); } if (args.Length > 1) { string s = args[1].ToString().Split(':')[1]; int i = s.Length; s2 = s.Substring(0, i - 1); Console.WriteLine("Contact: {0}", s2); Console.WriteLine("Contact: {0}", args[1]); } try { // Create the major UI Automation objects. Automation _Automation = LyncClient.GetAutomation(); // Create a dictionary object to contain AutomationModalitySettings data pairs. Dictionary <AutomationModalitySettings, object> _ModalitySettings = new Dictionary <AutomationModalitySettings, object>(); AutomationModalities _ChosenMode = AutomationModalities.FileTransfer | AutomationModalities.InstantMessage; //AutomationModalities _ChosenMode = AutomationModalities.InstantMessage| AutomationModalities.FileTransfer; // Store the file path as an object using the generic List class. string myFileTransferPath = string.Empty; // Edit this to provide a valid file path. myFileTransferPath = @"c:\\tempSkype4b\\Skype4b_logs.zip"; // Create a generic List object to contain a contact URI. String[] invitees = { s2 }; // Adds text to toast and local user IMWindow text entry control. _ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, "Hello attached you will get my Skype4B logfile"); //_ModalitySettings.Add(AutomationModalitySettings.); _ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); // Add file transfer conversation context type _ModalitySettings.Add(AutomationModalitySettings.FilePathToTransfer, myFileTransferPath); // Start the conversation. if (invitees != null) { IAsyncResult ar = _Automation.BeginStartConversation( _ChosenMode , invitees , _ModalitySettings , null , null); // Block UI thread until conversation is started. _Automation.EndStartConversation(ar); } //Console.ReadLine(); } catch { Console.WriteLine("Error"); Console.ReadLine(); } }
public void SendBreakBuildMessage() { do { FileInfo fi = new FileInfo(@"c:\builderror.txt"); //if (fi.Exists) { try { dynamic jobj = Utilities.GetDBBuildInfo(Utilities.UFT_BUILDINFO_CMD.lstfailure, Utilities.UFT_BUILDINFO_TYPE.CI); string failedJobUrl = ""; dynamic data = jobj.data; List <string> committers = new List <string>(); string buildVersion = ""; foreach (var obj in jobj.data) { bool notified = obj.notified; if (!notified) { failedJobUrl = obj.url.ToString(); buildVersion = obj.buildversion; if (obj.committers != null) { //Get the conversation modalities and settings AutomationModalities conversationModes = 0; Dictionary <AutomationModalitySettings, object> conversationSettings = new Dictionary <AutomationModalitySettings, object>(); conversationModes |= AutomationModalities.InstantMessage; conversationSettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); conversationSettings.Add(AutomationModalitySettings.FirstInstantMessage, "[(bandit)robot Message]Your commit may break the build, please check the failure. Check the link below for details\n" + failedJobUrl); string[] committersArray = obj.committers.ToString().Split(','); foreach (string committer in committersArray) { try { //committers.Add("sip:" + "*****@*****.**"); if (committer == "*****@*****.**") { committers.Add("sip:" + "*****@*****.**"); } else { committers.Add("sip:" + committer); } automation.BeginStartConversation(conversationModes, committers, conversationSettings, StartConversationCallback, null); committers.Clear(); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } } if (committersArray.Length > 0) { HttpContent content = new StringContent("{ \"notified\":\"true\" }", Encoding.UTF8, "application/json"); client.PatchAsync("your url" + buildVersion, content); } } } break; } } catch (Exception e) { Console.WriteLine(e); } //fi.Delete(); } Thread.Sleep(10000); } while (true); }
/// <summary> /// 会议开启通用方法 /// </summary> /// <param name="participantList">参会人</param> /// <param name="automationModeality">会话类型</param> protected static void StartConference_H(LyncClient lyncClient, string ConferenceName, string selfName, string mainConversationAccrodingStr, List <string> participantList, AutomationModalities automationModeality) { try { //在线联系人列表 List <string> OnlineParticpantList = new List <string>(); //遍历所有参会人并筛选在线参会人 foreach (var item in participantList) { //获取联系人 Contact contact = ConversationCodeEnterEntity.contactManager.GetContactByUri(item); //获取参会人状态 double s = Convert.ToDouble(contact.GetContactInformation(ContactInformationType.Availability)); //状态3500,对方不在线(s == 3500 && ) if (contact != lyncClient.Self.Contact) { OnlineParticpantList.Add(item); } } //Dictionary<AutomationModalitySettings, object> dic = new Dictionary<AutomationModalitySettings, object>(); //dic.Add(AutomationModalitySettings.FirstInstantMessage, ConferenceName + mainConversationAccrodingStr); //dic.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); ConversationCodeEnterEntity.lyncAutomation.BeginStartConversation( automationModeality, OnlineParticpantList, null, (ar) => { try { #region (会话窗体设置,参会人同步【呼叫】) //获取主会话窗 ConversationWindow conversationWindow = ConversationCodeEnterEntity.lyncAutomation.EndStartConversation(ar); //设置会话窗体的事件 SettingConversationWindowEvent(conversationWindow); ///注册会话更改事件 conversationWindow.StateChanged -= MainConversation_StateChanged; ///注册会话更改事件 conversationWindow.StateChanged += MainConversation_StateChanged; Application.Current.Dispatcher.BeginInvoke(new Action(() => { ShareWhiteboard(conversationWindow, selfName, new Action(() => { //LyncHelper.AvConnect(conversationWindow); //TimerJob.StartRun(new Action(() => // { // Close_AV(conversationWindow); // }), 800); })); })); #endregion } catch (OperationException ex) { LogManage.WriteLog(typeof(LyncHelper), ex); }; }, null); } catch (Exception ex) { LogManage.WriteLog(typeof(LyncHelper), ex); } }
void shareFileItem_Click(object sender, RoutedEventArgs e) { IItem item = ((MenuItem)e.Source).Tag as IItem; string extension = item.URL.Substring(item.URL.LastIndexOf('.') + 1); Process process = new Process(); switch (extension.ToLower()) { case "dotx": process.StartInfo.FileName = "winword.exe"; process.StartInfo.Arguments = "/t " + item.URL; break; case "doc": case "docx": process.StartInfo.FileName = "winword.exe"; process.StartInfo.Arguments = item.URL; break; case "xls": case "csv": process.StartInfo.FileName = "excel.exe"; process.StartInfo.Arguments = "/r" + item.URL; break; default: process.StartInfo.FileName = "iexplore.exe"; process.StartInfo.Arguments = "-nomerge " + item.URL; break; } process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; process.Start(); while (process.MainWindowHandle == IntPtr.Zero) { System.Threading.Thread.Sleep(100); } string contacts = Environment.GetCommandLineArgs()[2]; contacts = contacts.Substring(contacts.IndexOf("<") + 1).TrimEnd(new char[] { '>' }); _LyncClient = Microsoft.Lync.Model.LyncClient.GetClient(); List <string> c = new List <string>(); c.Add(contacts); Microsoft.Lync.Model.Extensibility.Automation automation = Microsoft.Lync.Model.LyncClient.GetAutomation(); AutomationModalities _ChosenMode = AutomationModalities.ApplicationSharing | AutomationModalities.InstantMessage; Dictionary <AutomationModalitySettings, object> _ModalitySettings = new Dictionary <AutomationModalitySettings, object>(); // Add the process Id to the modality settings for the conversation. _ModalitySettings.Add(AutomationModalitySettings.SharedProcess, process.Id); // Add the main window handle to the modality settings for the conversation. _ModalitySettings.Add(AutomationModalitySettings.SharedWindow, process.MainWindowHandle); // Adds text to toast and local user IMWindow text-entry control. _ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, "Hello Serkant. I would like to share my first running process with you."); _ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); IAsyncResult res = automation.BeginStartConversation(_ChosenMode, c, _ModalitySettings, null, null); automation.EndStartConversation(res); }
/// <summary> /// Handler of the Call button click event. We use this to set up and start the new conversation /// </summary> private void CallButton_Click(object sender, RoutedEventArgs e) { //Get the conversation modalities and settings AutomationModalities conversationModes = 0; Dictionary <AutomationModalitySettings, object> conversationSettings = new Dictionary <AutomationModalitySettings, object>(); //Instant Message modality if (instantMessageCheckBox.IsChecked.Value) { conversationModes |= AutomationModalities.InstantMessage; if (!String.IsNullOrEmpty(firstMessageTextBox.Text)) { conversationSettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true); conversationSettings.Add(AutomationModalitySettings.FirstInstantMessage, firstMessageTextBox.Text); } } //Audio modality if (audioCheckBox.IsChecked.Value) { conversationModes |= AutomationModalities.Audio; } //Video modality if (videoCheckBox.IsChecked.Value) { conversationModes |= AutomationModalities.Video; } //Application Sharing modality if (applicationSharingCheckBox.IsChecked.Value) { conversationModes |= AutomationModalities.ApplicationSharing; TextBlock resourceTextBlock = (TextBlock)resourceTypeComboBox.SelectedItem; AutomationModalitySettings resourceSetting = (AutomationModalitySettings)Enum.Parse(typeof(AutomationModalitySettings), "Shared" + resourceTextBlock.Text); object resourceValue = null; switch (resourceSetting) { case AutomationModalitySettings.SharedDesktop: break; case AutomationModalitySettings.SharedMonitor: if (monitorNumberComboBox.SelectedItem == null) { MessageBox.Show("Please select a monitor for sharing."); return; } resourceValue = (int)monitorNumberComboBox.SelectedItem; break; case AutomationModalitySettings.SharedProcess: Process selectedItem = processComboBox.SelectedItem as Process; if (selectedItem == null) { MessageBox.Show("Please select a process for sharing."); return; } resourceValue = selectedItem.Id; break; } conversationSettings.Add(resourceSetting, resourceValue); } //File Sharing modality if (fileTransferCheckBox.IsChecked.Value) { if (!String.IsNullOrEmpty(filePathTextBox.Text)) { conversationModes |= AutomationModalities.FileTransfer; conversationSettings.Add(AutomationModalitySettings.FilePathToTransfer, filePathTextBox.Text); } else { MessageBox.Show("Please select a file to transfer"); return; } } //Get the participants List <string> participants = new List <string>(participantsListBox.Items.Count); foreach (string participant in participantsListBox.Items) { participants.Add(participant); } if (conversationModes == 0) { MessageBox.Show("Please select a conversation mode."); return; } if (participants.Count == 0) { MessageBox.Show("Please add a participant."); return; } if (automation != null) { try { automation.BeginStartConversation(conversationModes, participants, conversationSettings, StartConversationCallback, null); } catch (LyncClientException lyncClientException) { MessageBox.Show("Call failed."); Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. MessageBox.Show("Call failed."); Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } } else { MessageBox.Show("Lync was not initialized property. Please restart this application."); } }