public static void OriginarLigacao(string quemLiga, string quemAtende) { try { _manager.Login(); var ramalOriginario = quemLiga; var canalParaLigacao = quemAtende; var actionLigacao = new OriginateAction { Context = "default", //"from-internal", Priority = "1", Channel = $"SIP/{canalParaLigacao}", //SIP/peer/9001 CallerId = "Chapeleta de Ouro", Exten = ramalOriginario, Timeout = 15000, Async = true }; var originateResponse = _manager.SendAction(actionLigacao, actionLigacao.Timeout); } catch (Exception e) { Console.WriteLine(e.Message); } }
private void button3_Click(object sender, EventArgs e) { //long initBNumber = 70019779805550000; long initBNumber = 80019779805550000; long initANumber = 97477009999; for (int i = 0; i < 100; i++) { OriginateAction oc = new OriginateAction(); oc.Async = true; oc.Context = @"autodialer"; oc.Priority = "1"; //oc.Channel = @"sip/ast2/70019779805550000"; oc.Channel = @"sip/ast2/" + (initBNumber + i).ToString(); //oc.CallerId = "97477009999"; oc.CallerId = (initANumber + i).ToString(); oc.Exten = "100"; oc.Timeout = ORIGINATE_TIMEOUT; manager.SendAction(oc, null); } }
public void CallStart(string originate_channel, string originate_callerid, string originate_exten) { if (!manager.IsConnected()) { throw new AsteriskNotConnectedException("Asterisk not connected. Contact with administrator"); } try { OriginateResponseEvent a = new OriginateResponseEvent(manager); Console.WriteLine(a.Exten); OriginateAction oc = new OriginateAction(); oc.Context = options.OriginateContext; oc.Priority = "1"; oc.Channel = originate_channel; oc.CallerId = originate_callerid; oc.Exten = originate_exten; oc.Timeout = options.OriginateTimeout; oc.Async = true; oc.ActionCompleteEventClass(); // oc.Variable = "VAR1=abc|VAR2=def"; //oc.SetVariable("VAR3", "ghi"); ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); Console.WriteLine(originateResponse); } catch (Exception e) { Console.WriteLine(e); } }
private void ButtonCall_Click(object sender, EventArgs e) { var from = TextBoxCallFrom.Text.Trim(); var to = TextBoxCallTo.Text.Trim(); var context = CheckBoxInternal.Checked ? "from-internal" : "from-trunk"; if (!string.IsNullOrEmpty(from) && !string.IsNullOrEmpty(to)) { var originateAction = new OriginateAction(); originateAction.Channel = "SIP/" + to; originateAction.CallerId = to; originateAction.Context = context; originateAction.Exten = from; originateAction.Priority = "1"; originateAction.Timeout = 30000; originateAction.Async = true; var originateResponse = manager.SendAction(originateAction); TextBoxOutput.Text += "-----Originating call-----" + Environment.NewLine + "from " + from + " to " + to + Environment.NewLine + Environment.NewLine; } else { TextBoxOutput.Text += "Fill 'call from' and 'call to' fields. " + Environment.NewLine; } }
public void Llamar(String Telefono, String Extension, Boolean Sincronico = false) { OriginateAction o = new OriginateAction(); o.Channel = "SIP/" + Extension; o.Context = "from-internal"; o.Exten = Prefijo + Limpiar(Telefono); o.CallerId = Limpiar(Telefono); o.Priority = "1"; o.Timeout = 15000; o.Async = true; o.Account = ""; Conn.Dial += new DialEventHandler(Conn_Dial); Conn.Status += new StatusEventHandler(Conn_Status); Conn.OriginateResponse += new OriginateResponseEventHandler(Conn_OriginateResponse); ResponseEvents response = Conn.SendEventGeneratingAction(o, 15000); Channel = response.Events[0].Channel; UniqueId = response.Events[0].UniqueId; Monitorear(Channel); DestChannel = ""; //ManagerResponse SD = Conn.SendAction(new AgiAction(Canal, "exec(\"SENDDTMF\",\"3\")")); //ManagerResponse SD2 = Conn.SendAction(new AgiAction(Canal, "exec(\"SENDDTMF\",\"4\")")); //ManagerResponse SD3 = Conn.SendAction(new AgiAction(Canal, "exec(\"SENDDTMF\",\"2\")")); //ManagerResponse SD4 = Conn.SendAction(new AgiAction(Canal, "exec(\"SENDDTMF\",\"7\")")); //ManagerResponse SD5 = Conn.SendAction(new AgiAction(Canal, "exec(\"SENDDTMF\",\"#\")")); //Conn.SendAction(new StatusAction()); //return new Result { Canal = Channel, UniqueId = UniqueId, Error = "", Status = "", DestChannel = DestChannel }; }
static void Main(string[] args) { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); manager.PingInterval = 0; // +++ try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } if (args.Count() == 4) { string originateChannel = args[0]; string originateCallerId = args[1]; string originateExten = args[2]; string originateContext = args[3]; //string originateChannel = "SIP/billy"; //string originateCallerId = "<1001>"; //string originateExten = "1002"; //string originateContext = "phones"; OriginateAction oc = new OriginateAction(); //oc.Channel = originateChannel; //oc.CallerId = originateCallerId; //oc.Context = originateContext; //oc.Exten = originateExten; //oc.Priority = 2; //oc.Timeout = 15000; oc.Channel = originateChannel; oc.CallerId = originateCallerId; oc.Application = "Dial"; oc.Data = "Local/" + originateExten + "@" + originateContext; oc.Timeout = 15000; try { ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); } catch (Exception e) { Console.WriteLine("error: {0}", e.Message); } } manager.Logoff(); }
/// <summary> /// Quay số gọi ra - tổng đài ip /// </summary> private bool QuaySoGoiDien() { bool bRet = false; const string ORIGINATE_CONTEXT = "from-internal"; try { string channel = string.Format("{0}/{1}", Config_Common.ChannelDial, G_lineIPPBX); AsteriskInfo.Manager.Login(); if (AsteriskInfo.Manager.IsConnected()) { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thành công - " + channel; })); } else { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thất bại !!! - " + channel; })); } var oc = new OriginateAction() { Context = ORIGINATE_CONTEXT, Priority = 1, Channel = channel,//"SIP/" + G_lineIPPBX, CallerId = G_lineIPPBX, Exten = G_PhoneNumber + Config_Common.Asterisk_SetNumberSign, Timeout = Config_Common.Asterisk_CallOut_TimeOut, //Async = true }; //oc.SetVariable("exten", G_PhoneNumber); if (AsteriskInfo.Manager.SendAction(oc, oc.Timeout).IsSuccess()) { bRet = true; } else { bRet = false; } AsteriskInfo.Manager.Logoff(); } catch (Exception ex) { bRet = false; AsteriskInfo.Manager.Logoff(); LogError.WriteLogError("QuaySoGoiDien2", ex); } return(bRet); }
private void ToolStripMenuItem_Click_Event(object sender, ToolStripItemClickedEventArgs e) { ToolStripItem item = e.ClickedItem; Log("History: ToolStripMenuItem_Click_Event"); AsteriskPhoneAgentForm asterfm; asterfm = this.Owner as AsteriskPhoneAgentForm; if (item.Text.Contains("Call")) { if (RINGENABLED != false) { CALLTO = item.Text.Replace("Call - ", string.Empty); OriginateAction oa = new OriginateAction(); // Context: Название контекста для совершения исходящего вызова (используется только совместно с параметрами Exten и Priority) oa.Context = ORIGINATE_CONTEXT; // from-internal // Priority: Priority to use on connect (используется только совместно с параметрами Context и Exten) oa.Priority = ORIGINATE_PRIORITY; // 1 // Exten: Extension to use on connect (используется только совместно с параметрами Context и Priority) oa.Exten = CALLTO; //CallerID: Значение CallerID, используемое для совершения исходящего вызова. oa.CallerId = USER_ID; // Channel: Название канала, с которого совершается исходящий вызов (В том же формате, как если бы Вы совершали вызов этому абоненту командой Dial.) oa.Channel = ASTERISK_PEER_NUMBER; // SIP/1001 // Timeout: Таймаут (в миллисекундах) для соединения с инициатором исходящего вызова (значение по умолчанию: 30000 миллисекунд). oa.Timeout = ORIGINATE_TIMEOUT; // Async: Если указано “true” исходящий вызов будет производиться асинхронно. // Результат ее выполнения будет возвращен позже, в пакете типа “Event” // (позволяет осуществлять несколько вызовов без ожидания результата предыдущей команды, совершающей исходящий вызов) oa.Async = true; ManagerResponse originateResponse = manager.SendAction(oa, oa.Timeout); if (originateResponse.Response.Contains("Success")) { Log("Call to " + CALLTO + " initialized"); //Tray.ShowBalloonTip(500, "Call", "Call to " + CALLTO + " initialized", ToolTipIcon.Info); } else { Log("Error: Call to " + CALLTO + " not success"); } } } }
public static OriginateAction GenerateOriginateAction(LoginCredentials creds, string outgoing) { OriginateAction temp = new OriginateAction() { Channel = $"SIP/{creds.login}", Context = "bbs-pabx", Exten = outgoing.Replace(" ", ""), CallerId = creds.login.ToString(), Priority = "1", Timeout = 100000, }; return(temp); }
private bool QuaySoGoiDien(Asterisk.NET.Manager.ManagerConnection manager, string line, string phoneNumber) { bool bRet = false; const string ORIGINATE_CONTEXT = "from-internal"; if (manager == null) { return(false); } try { if (!manager.IsConnected()) { manager = new ManagerConnection(AsteriskInfo.AST_HOSTNAME, AsteriskInfo.AST_PORT_NUMBER, AsteriskInfo.AST_USERNAME, AsteriskInfo.AST_PASSWORD); manager.Login(); } if (manager.IsConnected()) { Text = "Gọi đi : Kết nối tổng đài IP thành công"; } else { Text = "Gọi đi : Kết nối tổng đài IP thất bại !!!"; } OriginateAction oc = new OriginateAction(); oc.Context = ORIGINATE_CONTEXT; oc.Priority = 1; oc.Channel = "SIP/" + line; oc.CallerId = line; oc.Exten = phoneNumber; oc.Timeout = 30000; ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); if (originateResponse.IsSuccess()) { bRet = true; } else { bRet = false; } } catch (Exception ex) { LogError.WriteLogError("QuaySoGoiDien2", ex); } return(bRet); }
public async Task <bool> MakeCall(string phone, string voiceUrl, string voiceName, string baseVoiceName) { var action = new OriginateAction { Async = true, Channel = $"Dongle/dongle0/{phone}", Exten = "s", Context = "outgoing", Variable = $"SOUND_URL={voiceUrl},SOUND_NAME={voiceName},BASE_SOUND_NAME={baseVoiceName}" }; var response = _managerConnection.SendAction(action); return(response.IsSuccess()); }
private void button2_Click(object sender, EventArgs e) { OriginateAction oc = new OriginateAction(); oc.Context = @"from-internel"; oc.Priority = "1"; oc.Channel = @"Local/8001@from-internel"; oc.CallerId = "999111"; //oc. oc.Exten = "8001"; oc.Timeout = ORIGINATE_TIMEOUT; oc.Async = true; manager.SendAction(oc, null); //ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); //OriginateAction oc1 = new OriginateAction(); //oc1.Context = @"from-internel"; //oc1.Priority = "1"; //oc1.Channel = @"Local/8001@from-internel"; //oc1.CallerId = ORIGINATE_CALLERID; //oc1.Exten = "8001"; //oc1.Timeout = ORIGINATE_TIMEOUT; ////manager.SendAction(oc1, null); ////manager.ReconnectIntervalFast //if (manager.IsConnected()) //{ // ManagerResponse originateResponse1 = manager.SendAction(oc1, oc1.Timeout); //} //OriginateAction oc2 = new OriginateAction(); //oc2.Context = @"from-internel"; //oc2.Priority = "1"; //oc2.Channel = @"Local/8001@from-internel"; //oc2.CallerId = ORIGINATE_CALLERID; //oc2.Exten = "8001"; //oc2.Timeout = ORIGINATE_TIMEOUT; //manager.SendAction(oc2, null); return; }
public bool DoNotDisturb(string caller) { log.Debug("DND Toggle " + caller); OriginateAction newCall = new OriginateAction(); newCall.CallerId = caller; //newCall.Channel = "SIP/1000"; newCall.Channel = "SIP/" + caller; //newCall.Context = "app-dialvm"; newCall.Context = Properties.Settings.Default.DefaultContext; newCall.Priority = 1; //newCall.Exten = "*98"; newCall.Exten = Properties.Settings.Default.FeatureCodeDNDToggle; newCall.Timeout = 30000; newCall.Async = false; return(_manager.SendAction(newCall, 10000).IsSuccess()); }
public static void CallToPhone(string phone, string name) { try { OriginateAction action = new OriginateAction(); action.Channel = "SIP/" + Properties.Settings.Default.Phone; action.CallerId = "Набор номера: " + name; action.Exten = phone; action.Context = "call-out"; action.Priority = "0"; action.Async = true; manager.SendAction(action); } catch (Exception err) { LogWriter.Instance.WriteToLog("CallToPhone error " + err.Message); } }
public string Call(string caller, string callee) { //throw new NotImplementedException(); log.Debug("Make call from " + caller + " to " + callee); OriginateAction newCall = new OriginateAction(); newCall.CallerId = caller; //newCall.Channel = "SIP/1000"; newCall.Channel = "SIP/" + caller; //newCall.Context = "app-dialvm"; newCall.Context = Properties.Settings.Default.DefaultContext; newCall.Priority = 1; //newCall.Exten = "*98"; newCall.Exten = callee; newCall.Timeout = 30000; newCall.Async = false; string result = _manager.SendAction(newCall, 10000).ToString(); log.Debug("Result: " + result); return(result); }
private void llamar_Click(object sender, EventArgs e) { connectToAsterisk(); registros.Clear(); registros.Text = "--- Conexion Exitosa : ) --- " + Environment.NewLine;; registros.Text += "** Generando LLAMADA **" + Environment.NewLine; //registros.Text += "Al Numero: " + telefono.Text + " Desde la Extension: " + extension.Text + Environment.NewLine; var originateAction = new OriginateAction(); var originateResponse = new ManagerResponse(); //originateAction.Channel = "Local/201@from-internal"; //Local/210@from-internal originateAction.Channel = "local/" + telefono.Text + "@from-internal"; //SIP/actionvoip/0085261234567,Ttr originateAction.CallerId = telefono.Text; originateAction.Context = "from-internal"; //from-internal, originateAction.Exten = extension.Text; //originateAction.Application = "Dial"; //originateAction.Data = "SIP/210,201,Ttr"; //SIP/210,201,Ttr originateAction.Priority = 1; originateAction.Timeout = 30000; //originateAction.Async = true; // Realizando Login en el Servidor connectToAsterisk(); registros.Text += "Llamado a Telefono: " + telefono.Text + Environment.NewLine; registros.Text += "Esperando a que Contesten: "; // Enviando Parametros para generar llamada, timbrara por 30 sg en el cliente, cuando contesten envia al agente originateResponse = asteriskManager.SendAction(originateAction, originateAction.Timeout); registros.Text += originateResponse.Response + Environment.NewLine; Debug.WriteLine(originateResponse.Response); registros.Text += "Llamando al Agente : " + extension.Text + Environment.NewLine; // Desconectando del Servidor asteriskManager.Logoff(); }
public bool Forward(string caller, string destination) { log.Debug("Forward all from " + caller + " to " + destination); OriginateAction newCall = new OriginateAction(); newCall.CallerId = caller; //newCall.Channel = "SIP/1000"; newCall.Channel = "SIP/" + caller; //newCall.Context = "app-dialvm"; newCall.Context = Properties.Settings.Default.DefaultContext; newCall.Priority = 1; //newCall.Exten = "*98"; if (destination != "") { newCall.Exten = Properties.Settings.Default.FeatureCodeCallForwardAllActivate + destination; } else { newCall.Exten = Properties.Settings.Default.FeatureCodeCallForwardAllDeactivate; } newCall.Timeout = 30000; newCall.Async = false; return(_manager.SendAction(newCall, 10000).IsSuccess()); }
private static void checkManagerAPI() { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); // Register user event class manager.RegisterUserEventClass(typeof(UserAgentLoginEvent)); // Add or Remove events manager.UserEvents += new UserEventHandler(dam_UserEvents); // Dont't display this event manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent); // Display all other manager.UnhandledEvent += new ManagerEventHandler(dam_Events); // +++ Only to debug purpose manager.FireAllEvents = true; // manager.DefaultEventTimeout = 0; // manager.DefaultResponseTimeout = 0; manager.PingInterval = 0; // +++ try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } { Console.WriteLine("\nGetConfig action"); ManagerResponse response = manager.SendAction(new GetConfigAction("manager.conf")); if (response.IsSuccess()) { GetConfigResponse responseConfig = (GetConfigResponse)response; foreach (int key in responseConfig.Categories.Keys) { Console.WriteLine(string.Format("{0}:{1}", key, responseConfig.Categories[key])); foreach (int keyLine in responseConfig.Lines(key).Keys) { Console.WriteLine(string.Format("\t{0}:{1}", keyLine, responseConfig.Lines(key)[keyLine])); } } } else { Console.WriteLine(response); } } { Console.WriteLine("\nUpdateConfig action"); UpdateConfigAction config = new UpdateConfigAction("manager.conf", "manager.conf"); config.AddCommand(UpdateConfigAction.ACTION_NEWCAT, "testadmin"); config.AddCommand(UpdateConfigAction.ACTION_APPEND, "testadmin", "secret", "blabla"); ManagerResponse response = manager.SendAction(config); Console.WriteLine(response); } // Originate call example Console.WriteLine("\nPress ENTER key to originate call.\n" + "Start phone (or connect) or make a call to see events.\n" + "After all events press a key to originate call."); Console.ReadLine(); OriginateAction oc = new OriginateAction(); oc.Context = ORIGINATE_CONTEXT; oc.Priority = "1"; oc.Channel = ORIGINATE_CHANNEL; oc.CallerId = ORIGINATE_CALLERID; oc.Exten = ORIGINATE_EXTEN; oc.Timeout = ORIGINATE_TIMEOUT; // oc.Variable = "VAR1=abc|VAR2=def"; // oc.SetVariable("VAR3", "ghi"); ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); Console.WriteLine("Response:"); Console.WriteLine(originateResponse); Console.WriteLine("Press ENTER key to next test."); Console.ReadLine(); // // Display result of Show Queues command // { CommandAction command = new CommandAction(); CommandResponse response = new CommandResponse(); if (manager.AsteriskVersion == AsteriskVersion.ASTERISK_1_6) { command.Command = "queue show"; } else { command.Command = "show queues"; } try { response = (CommandResponse)manager.SendAction(command); Console.WriteLine("Result of " + command.Command); foreach (string str in response.Result) { Console.WriteLine("\t" + str); } } catch (Exception err) { Console.WriteLine("Response error: " + err); } Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); } // // Display Queues and Members // ResponseEvents re; try { re = manager.SendEventGeneratingAction(new QueueStatusAction()); } catch (EventTimeoutException e) { // this happens with Asterisk 1.0.x as it doesn't send a QueueStatusCompleteEvent re = e.PartialResult; } foreach (ManagerEvent e in re.Events) { if (e is QueueParamsEvent) { QueueParamsEvent qe = (QueueParamsEvent)e; Console.WriteLine("QueueParamsEvent" + "\n\tQueue:\t\t" + qe.Queue + "\n\tServiceLevel:\t" + qe.ServiceLevel); } else if (e is QueueMemberEvent) { QueueMemberEvent qme = (QueueMemberEvent)e; Console.WriteLine("QueueMemberEvent" + "\n\tQueue:\t\t" + qme.Queue + "\n\tLocation:\t" + qme.Location); } else if (e is QueueEntryEvent) { QueueEntryEvent qee = (QueueEntryEvent)e; Console.WriteLine("QueueEntryEvent" + "\n\tQueue:\t\t" + qee.Queue + "\n\tChannel:\t" + qee.Channel + "\n\tPosition:\t" + qee.Position); } } Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); // // To test create 3 extensions: // 1 - SIP/4012 w/o voicemail (with eyeBeam softphone) // 2 - IAX2/4008 w/o voicemail (with iaxComm softphone) // 3 - SIP/4010 w/ voicemal but no phone connect // RedirectCall: call from IAX2/4008 to SIP/4012 // Don't answer on SIP/4012 and call must redirect to SIP/4010 (to voicemail really) // Dial event used to define redirect channel Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC."); // Wait for Dial Event from ORIGINATE_CHANNEL DialEventHandler de = new DialEventHandler(dam_Dial); manager.Dial += de; while (transferChannel == null) { System.Threading.Thread.Sleep(100); if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) { break; } } manager.Dial -= de; // Now send Redirect action RedirectAction ra = new RedirectAction(); ra.Channel = transferChannel; ra.ExtraChannel = ORIGINATE_EXTRA_CHANNEL; ra.Context = ORIGINATE_CONTEXT; ra.Exten = ORIGINATE_EXTRA_EXTEN; ra.Priority = 1; try { ManagerResponse mr = manager.SendAction(ra, 10000); Console.WriteLine("Transfer Call" + "\n\tResponse:" + mr.Response + "\n\tMessage:" + mr.Message ); } catch (Exception ex) { Console.WriteLine(ex.Message); } // Monitor call. // Call from IA2/4008 to SIP/4012 // Link event used to define monitor channel Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC."); // Wait for Link event LinkEventHandler le = new LinkEventHandler(dam_Link); manager.Link += le; while (monitorChannel == null) { System.Threading.Thread.Sleep(100); if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) { break; } } manager.Link -= le; // Now send Monitor action MonitorAction ma = new MonitorAction(); ma.Channel = monitorChannel; ma.File = "voicefile"; ma.Format = "gsm"; ma.Mix = true; try { ManagerResponse mr = manager.SendAction(ma, 10000); Console.WriteLine("Monitor Call" + "\n\tResponse:" + mr.Response); } catch (Exception ex) { Console.WriteLine(ex.Message); } manager.Logoff(); }
private void button5_Click(object sender, EventArgs e) { // my bandwagon one call // channel originate pjsip/6001 extension 6001@from-internel //OriginateAction oc1 = new OriginateAction(); //oc1.Context = @"from-internel"; //oc1.Priority = "1"; //oc1.Channel = @"pjsip/6001"; //oc1.CallerId = "97477009999"; //oc1.Exten = "6001"; //oc1.Async = true; //oc1.Timeout = ORIGINATE_TIMEOUT; //CDR call = new CDR(); //call.Anumber = "97477009999"; //call.Bnumber = "7001"; //try //{ // dcdr.Add(call.Anumber, call); // manager.SendAction(oc1, null); //} //catch (Exception ep) //{ } dcdr.Clear(); // asterisk 190 N calls long initBNumber = 500036312340000; long initANumber = 85222930000; int j = int.Parse(textBox1.Text); for (int i = 0; i < j; i++) { OriginateAction oc = new OriginateAction(); oc.Async = true; oc.Context = @"autodialer"; oc.Priority = "1"; oc.Channel = @"sip/astToTB/" + (initBNumber + i).ToString(); oc.CallerId = (initANumber + i).ToString(); oc.Exten = "100"; oc.Timeout = ORIGINATE_TIMEOUT; //oc.Context = @"from-internel"; //oc.Priority = "1"; //oc.Channel = @"pjsip/6001"; //oc.CallerId = "97477009999"; //oc.Exten = "6001"; //oc.Async = true; //oc.Timeout = ORIGINATE_TIMEOUT; CDR call = new CDR(); call.Anumber = oc.CallerId; call.Bnumber = (initBNumber + i).ToString(); try { dcdr.Add(call.Anumber, call); manager.SendAction(oc, null); } catch (Exception ep) { } } //************************************* end of my bandwagon /******** asterisk 190 * * long initBNumber = 500036312340000; * * * long initANumber = 85222930000; * * * //int j = int.Parse(textBox1.Text); * * for (int i = 0; i < 50; i++) * { * * OriginateAction oc = new OriginateAction(); * oc.Async = true; * oc.Context = @"autodialer"; * oc.Priority = "1"; * //oc.Channel = @"sip/ast2/70019779805550000"; * * oc.Channel = @"sip/astToTB/" + (initBNumber + i).ToString(); * * * //oc.CallerId = "97477009999"; * * oc.CallerId = (initANumber + i).ToString(); * oc.Exten = "100"; * oc.Timeout = ORIGINATE_TIMEOUT; * manager.SendAction(oc, null); * * * } // for * * * * ******/// ebd of asterisk 190 //int i,k=0; //int j = int.Parse(textBox1.Text); //while(true) //{ // for ( i = k; i < j; i++) // { // OriginateAction oc = new OriginateAction(); // oc.Async = true; // oc.Context = @"autodialer"; // oc.Priority = "1"; // //oc.Channel = @"sip/ast2/70019779805550000"; // oc.Channel = @"sip/astToTB/" + (initBNumber + i).ToString(); // //oc.CallerId = "97477009999"; // oc.CallerId = (initANumber + i).ToString(); // oc.Exten = "100"; // oc.Timeout = ORIGINATE_TIMEOUT; // manager.SendAction(oc, null); // if (i >= k + 50) // { // k = k + 51; // System.Threading.Thread.Sleep(30000); // break; // } // } // for // } }
private bool QuaySoGoiDien(ManagerConnection manager, string line, string phoneNumber) { bool bRet = false; const string ORIGINATE_CONTEXT = "from-internal"; if (manager == null) { return(false); } try { G_manager = manager; string channel = string.Format("{0}/{1}", Config_Common.ChannelDial, line); if (!G_manager.IsConnected()) { G_manager = new ManagerConnection(AsteriskInfo.AST_HOSTNAME, AsteriskInfo.AST_PORT_NUMBER, AsteriskInfo.AST_USERNAME, AsteriskInfo.AST_PASSWORD); } G_manager.Login(); if (G_manager.IsConnected()) { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thành công - " + channel; })); } else { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thất bại !!! - " + channel; })); } OriginateAction oc = new OriginateAction() { Context = ORIGINATE_CONTEXT, Priority = 1, Channel = channel, CallerId = line, Exten = phoneNumber, Timeout = 15000 }; ManagerResponse originateResponse = G_manager.SendAction(oc, 30000); if (originateResponse.IsSuccess()) { bRet = true; } else { bRet = false; } G_manager.Logoff(); } catch (Exception ex) { bRet = false; G_manager.Logoff(); LogError.WriteLogError("QuaySoGoiDien2", ex); } return(bRet); }
private void button1_Click(object sender, EventArgs e) { ///**************** office asterisk // * //channel originate sip/ast2/70019779805550000 extension 100@autodialer long initBNumber = 70019779805550000; //long initBNumber = 80019779805550000; long initANumber = 97477009999; for (int i = 0; i < 100; i++) { OriginateAction oc = new OriginateAction(); oc.Async = true; oc.Context = @"autodialer"; oc.Priority = "1"; //oc.Channel = @"sip/ast2/70019779805550000"; oc.Channel = @"sip/ast2/" + (initBNumber + i).ToString(); //oc.CallerId = "97477009999"; oc.CallerId = (initANumber + i).ToString(); oc.Exten = "100"; oc.Timeout = ORIGINATE_TIMEOUT; manager.SendAction(oc, null); } //********/ // my banwagon //OriginateAction oc1 = new OriginateAction(); //oc1.Context = @"from-internel"; //oc1.Priority = "1"; //oc1.Channel = @"pjsip/7001"; //oc1.CallerId = "97477009999"; //oc1.Exten = "100"; //oc1.Async = true; //oc1.Timeout = ORIGINATE_TIMEOUT; //manager.SendAction(oc1, null); // //OriginateAction oc1 = new OriginateAction(); //oc1.Context = @"autodialer"; //oc1.Priority = "1"; //oc1.Channel = @"sip/ast2/70019779805550000"; //oc1.CallerId = "97477009999"; //oc1.Exten = "100"; //oc1.Timeout = ORIGINATE_TIMEOUT; //manager.SendAction(oc1, null); // //OriginateAction oc2 = new OriginateAction(); //oc2.Context = @"autodialer"; //oc2.Priority = "1"; //oc2.Channel = @"sip/ast2/70019779805550000"; //oc2.CallerId = "97477009999"; //oc2.Exten = "100"; //oc2.Timeout = ORIGINATE_TIMEOUT; //manager.SendAction(oc2, null); }
/// <summary> /// Quay số gọi ra - tổng đài ip /// </summary> private bool QuaySoGoiDien() { bool bRet = false; const string ORIGINATE_CONTEXT = "from-internal"; if (G_manager == null) { return(false); } try { if (!G_manager.IsConnected()) { G_manager = new ManagerConnection(AsteriskInfo.AST_HOSTNAME, AsteriskInfo.AST_PORT_NUMBER, AsteriskInfo.AST_USERNAME, AsteriskInfo.AST_PASSWORD); LogError.WriteLogInfo("ReConnected:" + G_PhoneNumber); } if (G_manager.IsConnected()) { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thành công"; })); } else { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thất bại !!!"; })); } G_manager.Login(); var oc = new OriginateAction() { Context = ORIGINATE_CONTEXT, Priority = 1, Channel = "SIP/" + G_lineIPPBX, CallerId = G_lineIPPBX, Exten = G_PhoneNumber, Timeout = 5000, //Async = true }; if (G_manager.SendAction(oc).IsSuccess()) { bRet = true; } else { bRet = false; } G_manager.Logoff(); } catch (Exception ex) { //bw_Call.CancelAsync(); bRet = false; G_manager.Logoff(); LogError.WriteLogError("QuaySoGoiDien2", ex); } return(bRet); }
/// <summary> /// Gọi ra bằng tổng đài IP /// </summary> /// <param name="manager"></param> /// <param name="lineIPPBX"></param> /// <param name="phoneNumber"></param> public void Call(ManagerConnection manager, string lineIPPBX, string phoneNumber) { if (Config_Common.Asterisk_QuickCall) { bool bRet = false; const string ORIGINATE_CONTEXT = "from-internal"; try { string channel = string.Format("{0}/{1}", Config_Common.ChannelDial, lineIPPBX); AsteriskInfo.Manager.Login(); if (AsteriskInfo.Manager.IsConnected()) { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thành công - " + channel; })); } else { this.Invoke(new MethodInvoker(delegate { Text = "Gọi đi : Kết nối tổng đài IP thất bại !!! - " + channel; })); } var oc = new OriginateAction() { Context = ORIGINATE_CONTEXT, Priority = 1, Channel = channel,//"SIP/" + G_lineIPPBX, CallerId = lineIPPBX, Exten = phoneNumber + Config_Common.Asterisk_SetNumberSign, Timeout = Config_Common.Asterisk_CallOut_TimeOut, //Async = true }; //oc.SetVariable("exten", G_PhoneNumber); if (AsteriskInfo.Manager.SendAction(oc, oc.Timeout).IsSuccess()) { bRet = true; } else { bRet = false; } AsteriskInfo.Manager.Logoff(); } catch (Exception ex) { bRet = false; AsteriskInfo.Manager.Logoff(); LogError.WriteLogError("QuaySoGoiDien2", ex); } //return bRet; ////System.Threading.Thread.Sleep(1000); //G_manager = manager; //G_lineIPPBX = lineIPPBX; //G_PhoneNumber = phoneNumber; ////if (!bw_Call.IsBusy) ////{ //// bw_Call.RunWorkerAsync(); ////} ////Task.Factory.StartNew(() => ////{ //// QuaySoGoiDien(); ////}); //if (Config_Common.MPCC_LinkDial != "" && // Config_Common.MPCC_Queue != "" && // Config_Common.MPCC_TrunkDial != "") //{ // QuaySoGoiDen_MPCC(lineIPPBX, phoneNumber); //} //else //{ // QuaySoGoiDien(); //} //System.Threading.Thread.Sleep(1000); //this.Hide(); } }