Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        protected void BeginConversation(SalesAgent agent, Contact contact)
        {
            // Conversation participant list.
            List <string> participantList = new List <string>();

            participantList.Add(agent.Uri);

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

            // initial IM message
            conversationContextData.Add(AutomationModalitySettings.FirstInstantMessage, "Apress Remodeling Application Context");

            // send initial IM immediately
            conversationContextData.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);

            // set application ID
            conversationContextData.Add(AutomationModalitySettings.ApplicationId, "{A07EE104-A0C2-4E84-ABB3-BBC370A37636}");

            string appData = "ContactID=" + contact.contactID + "|CustomerID=" + contact.customerID;

            // set application data
            conversationContextData.Add(AutomationModalitySettings.ApplicationData, appData);

            Automation auto = LyncClient.GetAutomation();

            // start the conversation.
            IAsyncResult beginconversation = auto.BeginStartConversation(
                AutomationModalities.InstantMessage
                , participantList
                , conversationContextData
                , null
                , null);
        }
Ejemplo n.º 3
0
        internal void SendMessage(string inviteeEmail, string imText)
        {
            try
            {
                // Create a generic List object to contain a contact URI.
                // Ensure that a valid URI is added.
                inviteeList = new List <string>();
                inviteeList.Add(inviteeEmail);

                if (_ModalitySettings.ContainsKey(AutomationModalitySettings.FirstInstantMessage))
                {
                    _ModalitySettings[AutomationModalitySettings.FirstInstantMessage] = subject + "! : " + imText;
                }
                else
                {
                    _ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, subject + "! : " + imText);
                }
                // Start the conversation.
                IAsyncResult ar = _Automation.BeginStartConversation(_ChosenMode,
                                                                     inviteeList,
                                                                     _ModalitySettings,
                                                                     null,
                                                                     null);


                //Block UI thread until conversation is started
                _Automation.EndStartConversation(ar);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 4
0
 public void Call(List <string> participants, bool fullscreen = true, int display = 0)
 {
     automation.BeginStartConversation(
         AutomationModalities.Video,
         participants,
         null,
         (ar) =>
     {
         ConversationWindow window = automation.EndStartConversation(ar);
         if (fullscreen)
         {
             CallWindow.ShowFullscreen(window, display);
         }
     },
         null);
 }
        internal void SendMessage(string imText)
        {
            try
            {
                if (_ModalitySettings.ContainsKey(AutomationModalitySettings.FirstInstantMessage))
                {
                    _ModalitySettings[AutomationModalitySettings.FirstInstantMessage] = "JIRA Tool Error! : " + imText;
                }
                else
                {
                    _ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, "JIRA Tool Error! : " + imText);
                }
                // Start the conversation.
                IAsyncResult ar = _Automation.BeginStartConversation(_ChosenMode,
                                                                     inviteeList,
                                                                     _ModalitySettings,
                                                                     null,
                                                                     null);


                //Block UI thread until conversation is started
                _Automation.EndStartConversation(ar);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 6
0
        public void SendIM()
        {
            Console.WriteLine("exiting");

            //Get a Lync client automation object.
            LyncClient client     = LyncClient.GetClient();
            Automation automation = LyncClient.GetAutomation();

            //Add two URIs to the list of IM addresses.
            System.Collections.Generic.List <string> inviteeList = new System.Collections.Generic.List <string>();
            inviteeList.Add(ConfigurationManager.AppSettings["UserURI"]);
            //inviteeList.Add(ConfigurationManager.AppSettings["CallingUserURI"]);
            inviteeList.Add(ConfigurationManager.AppSettings["UserURI2"]);

            //Specify IM settings.
            System.Collections.Generic.Dictionary <AutomationModalitySettings, object> mSettings = new System.Collections.Generic.Dictionary <AutomationModalitySettings, object>();
            string messageText = ImMessageText();

            mSettings.Add(AutomationModalitySettings.FirstInstantMessage, messageText);
            mSettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);

            //Broadcast the IM messages.
            IAsyncResult ar = automation.BeginStartConversation(AutomationModalities.InstantMessage, inviteeList, mSettings, null, null);

            cWindow = automation.EndStartConversation(ar);
            AutoResetEvent completedEvent = new AutoResetEvent(false);

            completedEvent.WaitOne();
        }
Ejemplo n.º 7
0
        //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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// If an instance of the Lync application exits this method will send the selected file to the predefined User Id.
        /// </summary>
        public override void Perform()
        {
            try
            {
                lyncClient = LyncClient.GetClient();
            }
            catch (Exception ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.Lync_ApplicationNotFound);
                Logger.Write(ex);

                return;
            }

            try
            {
                self = lyncClient.Self;

                if (self == null)
                {
                    ErrorLog.AddError(ErrorType.Failure, Strings.Lync_NotLoggedIn);
                    return;
                }

                try
                {
                    Contact contact = self.Contact.ContactManager.GetContactByUri(userId);
                }
                catch (Exception ex)
                {
                    ErrorLog.AddError(ErrorType.Failure, Strings.Lync_NoUserId);
                    Logger.Write(ex);
                    return;
                }

                Automation automation = LyncClient.GetAutomation();

                var participants = new List <string>();
                var contextData  = new Dictionary <AutomationModalitySettings, object>();

                contextData.Add(AutomationModalitySettings.FilePathToTransfer, fileName);
                contextData.Add(AutomationModalitySettings.FileIsShared, true);

                participants.Add(userId);

                automation.BeginStartConversation(AutomationModalities.FileTransfer, participants, contextData, null, automation);
            }
            catch (Exception ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.Lync_ReactionCouldntPerform);
                Logger.Write(ex);
            }
            finally
            {
                lyncClient = null;
            }
        }
        /// <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); }
        }
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string       conferenceUrl = MeetUrl.Text; // in the form of "conf:sip:[email protected];gruu;opaque=app:conf:focus:id:4FNRHN16";
         IAsyncResult ar            = Automation.BeginStartConversation(conferenceUrl, 0, StartConversation_Callback, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Join meeting failed", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// If an instance of the Lync application exits this method will make a video call to the predefined User Id.
        /// </summary>
        public override void Perform()
        {
            try
            {
                lyncClient = LyncClient.GetClient();
            }
            catch (Exception ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.Lync_ApplicationNotFound);
                Logger.Write(ex);

                return;
            }

            try
            {
                self = lyncClient.Self;

                if (self == null)
                {
                    ErrorLog.AddError(ErrorType.Failure, Strings.Lync_NotLoggedIn);
                    return;
                }

                try
                {
                    Contact contact = self.Contact.ContactManager.GetContactByUri(userId);
                }
                catch (Exception ex)
                {
                    ErrorLog.AddError(ErrorType.Failure, Strings.Lync_NoUserId);
                    Logger.Write(ex);
                    return;
                }

                Automation automation = LyncClient.GetAutomation();

                var participants = new List <string>();
                participants.Add(userId);

                automation.BeginStartConversation(AutomationModalities.Video, participants, null, null, automation);
            }
            catch (Exception ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.Lync_ReactionCouldntPerform);
                Logger.Write(ex);
            }
            finally
            {
                lyncClient = null;
            }
        }
        //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];
        }
Ejemplo n.º 13
0
        private void btnConversationStart_Click(object sender, RoutedEventArgs e)
        {
            // Create an Automation object.
            Automation automation = LyncClient.GetAutomation();

            List <string> participants = new List <string>();

            participants.Add(cboContacts.SelectedValue.ToString());

            // Declare instance of Dictionary to pass the conversation context data.
            Dictionary <AutomationModalitySettings, object> automationSettings = new Dictionary <AutomationModalitySettings, object>();

            // Provide Conversation context: First IM Message.
            automationSettings.Add(AutomationModalitySettings.FirstInstantMessage, "Hello!");

            // Provide Conversation context: Send first IM message immediately after the conversation starts.
            automationSettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);

            // Start the conversation.
            IAsyncResult beginconversation = automation.BeginStartConversation(AutomationModalities.InstantMessage, participants
                                                                               , automationSettings
                                                                               , onConversationStart
                                                                               , automation);
        }
Ejemplo n.º 14
0
        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();
            }
        }