コード例 #1
0
        void sendFileItem_Click(object sender, RoutedEventArgs e)
        {
            IItem  item     = ((MenuItem)e.Source).Tag as IItem;
            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();

            Dictionary <AutomationModalitySettings, object> _ModalitySettings = new Dictionary <AutomationModalitySettings, object>();

            _ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, "Hi Serkant, please have a look at this:");
            _ModalitySettings.Add(AutomationModalitySettings.Subject, "Sharing File");
            _ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);
            //_ModalitySettings.Add(AutomationModalitySettings.FilePathToTransfer, @"c:\temp\test.txt");
            _ModalitySettings.Add(AutomationModalitySettings.FilePathToTransfer, item.URL);


            IAsyncResult res = automation.BeginStartConversation(AutomationModalities.InstantMessage | AutomationModalities.FileTransfer, c, _ModalitySettings, null, null);

            automation.EndStartConversation(res);
        }
コード例 #2
0
        //send message
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                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();

                IAsyncResult res = automation.BeginStartConversation(Microsoft.Lync.Model.Extensibility.AutomationModalities.InstantMessage, c, null, SendContextDataCallback, automation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Err:" + ex.Message);
            }
        }
コード例 #3
0
        //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);
        }
コード例 #4
0
ファイル: MessageSender.cs プロジェクト: yinpengji/cibot
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <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.");
            }
        }