Exemplo n.º 1
0
        /// <summary>
        /// Makes a call to the number in the parameter
        /// </summary>
        /// <param name="number">number to call</param>
        public void makeCall(String phoneNumber)
        {
            // Create a generic List object to contain the URI to call.
            // Edit this to provide a valid URI.
            List <string> participantUri = new List <string>();

            //participantUri.Add("506 72944567");
            //participantUri.Add("+972 3 5396852");
            participantUri.Add(phoneNumber);

            // Start the conversation.
            LyncClient.GetAutomation().BeginStartConversation(
                AutomationModalities.Audio,
                participantUri,
                null,
                (ar) =>
            {
                try
                {
                    ConversationWindow newWindow = LyncClient.GetAutomation().EndStartConversation(ar);
                }
                catch (OperationException oe) { MessageBox.Show("Operation exception on start conversation " + oe.Message); };
            },
                null);
        }
Exemplo n.º 2
0
        public Configuracion()
        {
            InitializeComponent();

            try
            {
                //Obtener instancias de Lync Client y Contact Manager.
                lyncClient = LyncClient.GetClient();
                automation = LyncClient.GetAutomation();
                contactMgr = lyncClient.ContactManager;

                activeSearchProviders    = new List <SearchProviders>();
                searchResultSubscription = contactMgr.CreateSubscription();

                // Carga Proveedor de búsqueda experto si está configurado y habilita la casilla de verificación.
                if (contactMgr.GetSearchProviderStatus(SearchProviders.Expert)
                    == SearchProviderStatusType.SyncSucceeded || contactMgr.GetSearchProviderStatus(SearchProviders.Expert)
                    == SearchProviderStatusType.SyncSucceededForExternalOnly || contactMgr.GetSearchProviderStatus(SearchProviders.Expert)
                    == SearchProviderStatusType.SyncSucceededForInternalOnly)
                {
                    activeSearchProviders.Add(SearchProviders.Expert);
                }

                // Registrarse para el evento SearchProviderStatusChanged
                // by ContactManager.
                //contactMgr.SearchProviderStateChanged += contactMgr_SearchProviderStateChanged;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:    " + ex.Message);
            }
        }
 public MainWindow()
 {
     InitializeComponent();
     try
     {
         //Start the conversation
         automation = LyncClient.GetAutomation();
         client     = LyncClient.GetClient();
     }
     catch (LyncClientException lyncClientException)
     {
         MessageBox.Show("Failed to connect to Lync.");
         Console.Out.WriteLine(lyncClientException);
     }
     catch (SystemException systemException)
     {
         if (IsLyncException(systemException))
         {
             // Log the exception thrown by the Lync Model API.
             MessageBox.Show("Failed to connect to Lync.");
             Console.WriteLine("Error: " + systemException);
         }
         else
         {
             // Rethrow the SystemException which did not come from the Lync Model API.
             throw;
         }
     }
 }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
        /// <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);
            }
        }
Exemplo n.º 8
0
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += MainWindow_Loaded;

            _client     = LyncClient.GetClient();
            _automation = LyncClient.GetAutomation();
        }
Exemplo n.º 9
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public MainWindow()
        {
            try
            {
                //加载UI
                InitializeComponent();

                //绑定当前上下文
                this.DataContext = this;

                #region 控件绑定

                //自我绑定
                MainWindow.mainWindow = this;
                //主页绑定
                MainWindow.MainPageInstance = this.mainPage;
                //首页绑定
                MainWindow.IndexInstance = this.index;

                #endregion

                #region 事件注册

                //退出
                this.btnExit.Click += btnExit_Click;
                //首页子项选择事件
                this.index.IndexItemSelected += index_IndexItemSelected;
                //主窗体关闭事件
                this.Closed += MainWindow_Closed;
                //弹出软键盘
                this.btnkeyBoard.Click += btnkeyBoard_Click;
                //刷新
                this.btnReflesh.Click += btnReflesh_Click;
                //通讯修复
                //this.btnCommunicationRepair.Click += btnCommunicationRepair_Click;
                //返回高级菜单
                this.btnBack.Click += btnBack_Click;
                //状态更改
                this.StateChanged += MainWindow_StateChanged;

                this.ChangedToDesk.Click += ChangedToDesk_Click;

                #endregion

                //获取automation
                Constant.lyncAutomation = LyncClient.GetAutomation();
                //时间显示
                TimerDisplayManage.TimerDisplay(this.txtNowTime);
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(this.GetType(), ex);
            }
            finally
            {
            }
        }
Exemplo n.º 10
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;
            }
        }
Exemplo n.º 11
0
        //callback method for the Automation.BeginStartConversation
        public void EndStartConversation(IAsyncResult res)
        {
            Automation automation = LyncClient.GetAutomation();

            //get the conversation object
            ConversationWindow window     = automation.EndStartConversation(res);
            Conversation       conference = window.Conversation;

            //display the conference URI
            textBox1.Text = "conference URI: " + conference.Properties[ConversationProperty.ConferencingUri] + "?" + conference.Properties[ConversationProperty.Id];
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         LyncClient       = LyncClient.GetClient();
         Automation       = LyncClient.GetAutomation();
         this.DataContext = this;
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 13
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;
            }
        }
Exemplo n.º 14
0
 private static void BindNewInstance()
 {
     try
     {
         var client     = LyncClient.GetClient();
         var automation = LyncClient.GetAutomation();
         instance = new AppController(client, automation);
     }
     catch (ClientNotFoundException)
     {
         throw new InvalidStateException("No Skype / Lync app running");
     }
 }
Exemplo n.º 15
0
        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;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Handles the window loaded event and gets the Lync client
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            try
            {
                _Automation = LyncClient.GetAutomation();

                //Load a list of the user's followed chat rooms
                LoadRoomList();
            }
            catch (ClientNotFoundException)
            {
                System.Diagnostics.Debug.WriteLine("Client is not running");
            }
            catch (LyncClientException lce)
            {
                System.Diagnostics.Debug.WriteLine("LyncClientException on getClient(): " + lce.Message);
            }
        }
Exemplo n.º 17
0
        void Callback(IAsyncResult ar)
        {
            int x = 1;

            try
            {
                Automation _Automation = LyncClient.GetAutomation();


                SearchResults sr = _lc.ContactManager.EndSearch(ar);
                Contact       c  = sr.Contacts.First();
                _cList.Add(c);
                c.ContactInformationChanged += c_ContactInformationChanged;
                ContactAvailability availEnum = (ContactAvailability)c.GetContactInformation(ContactInformationType.Availability);
                _cn.SendStatusChange((string)((List <object>)c.GetContactInformation(ContactInformationType.EmailAddresses)).First(), availEnum);
            }
            catch
            {
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void Parameter_Init()
        {
            try
            {
                Constant.lyncClient = LyncClient.GetClient();

                //获取automation
                Constant.lyncAutomation = LyncClient.GetAutomation();

                //时间显示
                TimerDisplayManage.TimerDisplay(this.txtNowTime);
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(this.GetType(), ex);
            }
            finally
            {
            }
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            //Init
            LyncClient client = null;

            Microsoft.Lync.Model.Extensibility.Automation automation = null;
            //InstantMessageModality _ConversationImModality;

            try
            {
                //Start the conversation
                automation = LyncClient.GetAutomation();
                client     = LyncClient.GetClient();
            }
            catch (LyncClientException lyncClientException)
            {
                Console.WriteLine("Failed to connect to Lync." + lyncClientException.Message);
                Console.Out.WriteLine(lyncClientException);
            }
            catch (SystemException systemException)
            {
                if (IsLyncException(systemException))
                {
                    // Log the exception thrown by the Lync Model API.
                    Console.Write("Failed to connect to Lync." + systemException.Message);
                    Console.WriteLine("Error: " + systemException);
                }
                else
                {
                    // Rethrow the SystemException which did not come from the Lync Model API.
                    throw;
                }
            }

            //los eventos
            client.ConversationManager.ConversationAdded += ConeversAded;

            Console.ReadKey();
        }
        public Search()
        {
            InitializeComponent();
            try
            {
                // Get instances of Lync Client and Contact Manager.
                lyncClient = LyncClient.GetClient();
                automation = LyncClient.GetAutomation();
                contactMgr = lyncClient.ContactManager;

                // Create a DataTable for search results.
                dt = new DataTable();
                dt.Columns.Add("Contact Uri");
                dt.Columns.Add("Contact Details");

                // Create list to cache a list of SearchProviders instances
                // that are synchronized and can accept user search requests.
                activeSearchProviders    = new List <SearchProviders>();
                searchResultSubscription = contactMgr.CreateSubscription();

                // Loads Expert search provider if it is configured and enables the checkbox.
                if (contactMgr.GetSearchProviderStatus(SearchProviders.Expert)
                    == SearchProviderStatusType.SyncSucceeded || contactMgr.GetSearchProviderStatus(SearchProviders.Expert)
                    == SearchProviderStatusType.SyncSucceededForExternalOnly || contactMgr.GetSearchProviderStatus(SearchProviders.Expert)
                    == SearchProviderStatusType.SyncSucceededForInternalOnly)
                {
                    activeSearchProviders.Add(SearchProviders.Expert);
                    ExpertSearch.Enabled = true;
                }

                // Register for the SearchProviderStatusChanged event raised
                // by ContactManager.
                contactMgr.SearchProviderStateChanged += contactMgr_SearchProviderStateChanged;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:    " + ex.Message);
            }
        }
        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];
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
 public MessageSender()
 {
     try
     {
         automation = LyncClient.GetAutomation();
     }
     catch (LyncClientException lyncClientException)
     {
         Console.Out.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;
         }
     }
 }
Exemplo n.º 25
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();
            }
        }
Exemplo n.º 26
0
        public SeriousBusinessCat(MainWindow main)
        {
            this._main = main;

            this.whisperCat = new WhisperCat(this);

            try
            {
#if DEBUG
                debug = new DebugWindow();
                debug.info("Test");
                debug.Show();

                /*
                 * var _testWhisper = new WhisperWindow(null, null, null, "Your key: 12345\r\nTheir key: 6789A");
                 *
                 * _testWhisper.AddWhisper(new Whisper(true, "testing a really really long message, at least it seems pretty long, but i guess it is really not that long to begin with", "cipher1"));
                 * _testWhisper.AddWhisper(new Whisper(false, "okay, looks good", "cipher2"));
                 * _testWhisper.AddWhisper(new Whisper(true, "glad you think so, you jerk", "cipher3"));
                 * _testWhisper.Show();
                 */
#endif


                //Start the conversation
                automation = LyncClient.GetAutomation();
                client     = LyncClient.GetClient();

                ConversationManager conversationManager = client.ConversationManager;
                conversationManager.ConversationAdded   += ConversationManager_ConversationAdded;
                conversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;
                //conversationManager.ConversationAdded += new EventHandler<ConversationManagerEventArgs>(conversationManager_ConversationAdded);

                _main.lbConversations.ItemsSource = _conversations;

                RefreshConversations(true);

                try
                {
                    _selfUserName = client.Self.Contact.GetContactInformation(ContactInformationType.PrimaryEmailAddress).ToString();
                    if (_selfUserName.Contains("@"))
                    {
                        _selfUserName = _selfUserName.Split('@')[0];
                    }
                    _selfUserNameLast = _selfUserName;
                    if (_selfUserNameLast.Contains('.'))
                    {
                        _selfUserNameLast = _selfUserNameLast.Split('.')[1];
                    }
                }
                catch (Exception)
                {
                    // ignore
                }
            }
            catch (LyncClientException lyncClientException)
            {
                MessageBox.Show("Failed to connect to Lync: " + lyncClientException.ToString());
                Console.Out.WriteLine(lyncClientException);
            }
            catch (SystemException systemException)
            {
                if (Util.IsLyncException(systemException))
                {
                    // Log the exception thrown by the Lync Model API.
                    MessageBox.Show("Failed to connect to Lync with system error: " + systemException.ToString());
                    Console.WriteLine("Error: " + systemException);
                }
                else
                {
                    // Rethrow the SystemException which did not come from the Lync Model API.
                    throw;
                }
            }

            CreateFileWatcher();
        }
Exemplo n.º 27
0
        private async void pollingLoop()
        {
            System.Net.Sockets.NetworkStream Stream = null;
            int byteCount = 0;

            byte[] buffer = new byte[4096];

            while (btClient.Connected)
            {
                if (Stream == null)
                {
                    Stream = btClient.GetStream();
                }

                byteCount = await Stream.ReadAsync(buffer, 0, buffer.Length);

                String response = Encoding.UTF8.GetString(buffer, 0, byteCount);

                if (txtBTMsg.InvokeRequired == true)
                {
                    Invoke(new MethodInvoker(delegate()
                    {
                        txtBTMsg.AppendText(response);
                    }));
                }
                else
                {
                    txtBTMsg.AppendText(response);
                }

                if (response.Contains(txtTrigCode.Text)) //"VideoCall\r\n"))
                {
                    List <string> participantUri = new List <string>();
                    if (txtUserAlias.Text.Trim() != "")
                    {
                        participantUri.Add("sip:" + txtUserAlias.Text);
                        LyncClient.GetAutomation().BeginStartConversation(
                            AutomationModalities.Video,
                            //AutomationModalities.Audio,
                            participantUri,
                            null,
                            (ar) =>
                        {
                            try
                            {
                                ConversationWindow newWindow = LyncClient.GetAutomation().EndStartConversation(ar);
                                newWindow.ShowFullScreen(0);
                            }
                            catch (OperationException oe) { MessageBox.Show("Operation exception on start conversation " + oe.Message); };
                        },
                            null);
                    }
                }
                else if (response.Contains(txtCapCode.Text))
                {
                    if (webcam1.InvokeRequired == true)
                    {
                        Invoke(new MethodInvoker(delegate()
                        {
                            webcam1.TimeToCapture_milliseconds = FrameNumber;
                            webcam1.Start(0);
                            bCapture = true;
                        }));
                    }

                    //imgCapture.Image = imgVideo.Image;
                }
            }
        }