Пример #1
0
        private void MouseLeftDownHandler(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                if (GetExtension().Length == 0)
                {
                    return;
                }
                if (GetStatus() != PhoneStatusCodes.Idle)
                {
                    return;
                }
                //send call to ACWin
                if (Globals.AcWinManager != null)
                {
                    Globals.AcWinManager.MakeCall(GetPrefix(), GetExtension());
//                    if (Globals.AcWinManager.MakeCall(GetPrefix(), GetExtension()) == false)
//                        Globals.Logger.LogString(LogManager.LogLevels.LogFlagError, "Could not create call through ACWin");
                }
                else if (Globals.Config.GetConfig("Options", "Optiset", "NO") == "YES")
                {
                    //get the extension only from a full phone number
                    string OptisetExtenstion = PhoneNumber.GetExtensionFromFullNumberStr(Globals.Config.GetConfig("Options", "OptisetExtension", ""));
                    if (OptisetExtenstion == null || OptisetExtenstion.Length == 0)
                    {
                        return;
                    }

                    //optiset can't call itself
                    string Extensionstr = GetExtension().ToString();
                    if (OptisetExtenstion == Extensionstr)
                    {
                        return;
                    }

                    long CurrentCallId = Globals.ExtensionManager.GetCallId(GetServerIPAndPort(), GetPrefix(), GetExtension());
                    if (CurrentCallId != 0)
                    {
                        Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "Extension " + GetExtension().ToString() + " is already in a call. Can't call him");
                        return;
                    }

                    // if this extension is not in a call, than make a direct call
                    long OptisetCallId = Globals.ExtensionManager.GetOptisetCallId();
                    if (OptisetCallId == 0) // if this target extension does not have an ongoing call yet
                    {
                        Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "CallingDevice=" + OptisetExtenstion + ", CalledDirectoryNumber=" + Extensionstr);
                        //MakeCall(m_strOptisetExtension, m_strSelectedExtension, make_call_doNotPrompt);

                        if (Globals.ConnectionManager != null)
                        {
                            NetworkClient nc = Globals.ConnectionManager.GetCLient(ServerIPAndPort);
                            if (nc != null)
                            {
                                nc.PacketBuilder.MakeCall(OptisetExtenstion, Extensionstr, MakeCallPrompTypes.make_call_doNotPrompt);
                            }
                        }
                        return;
                    }
                    if (OptisetCallId != 0)
                    {
                        //Client.ConsultationCall(sDevice.GetBuffer(sDevice.GetLength()), strConsultedDevice.GetBuffer(strConsultedDevice.GetLength()), strExistingCallID.GetBuffer(strExistingCallID.GetLength()), "", 0);
                        if (Globals.ConnectionManager != null)
                        {
                            NetworkClient nc = Globals.ConnectionManager.GetCLient(ServerIPAndPort);
                            if (nc != null)
                            {
                                nc.PacketBuilder.ConsultationCall(OptisetExtenstion, Extensionstr, OptisetCallId.ToString(), "", 0);
                            }
                        }
                    }
                }
            }
        }