public static void fillSkills(string answerSkills) { // buraya Mola|1;Yemek|2; şeklinde data geliyor answer.skills içerisinde. Split edip kullanıyoruz. main.logAdd("", 1, "Downloading Skills..."); string[] skills = answerSkills.Split(';'); foreach (string skill in skills) { try { string[] skillInfo = skill.Split('|'); sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (sipClient != null) { sipClient.ComboboxItem item = new sipClient.ComboboxItem(); item.Text = skillInfo[0]; item.Value = skillInfo[1]; sipClient.agentSkill.Items.Add(item); main.logAdd("", 2, "New Skill: " + skillInfo[0]); } else { main.errorModal("Form'a erişilemedi. Kaynak: fillSkills"); } } catch (Exception e) { main.logAdd("error", 1, e.Message.ToString()); } } main.logAdd("", 1, "Downloaded Skills."); }
public static void regStateChanged(RegistrationStateChangedArgs e) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (e.State == RegState.Error) { sipClient.statusScreen.Text = "Registration failed: " + e.ReasonPhrase.ToString(); logAdd("error", 1, "Registration Failed."); sipClient.Hide(); errorModal("Registration failed: " + e.ReasonPhrase.ToString()); Application.Exit(); } else if (e.State == RegState.RegistrationRequested) { sipClient.statusScreen.Text = "Registering..."; logAdd("", 1, "Registering..."); } else if (e.State == RegState.RegistrationSucceeded) { sipClient.statusScreen.Text = "Registration success."; sipClient.phoneLine1.DoNotDisturb = true; //agentState.SelectedItem = "Logged In"; sipClient.timer1.Enabled = true; sipClient.timer1.Start(); logAdd("", 1, "Registration succesfully."); } else if (e.State == RegState.NotRegistered) { MessageBox.Show("Sunucu ile bağlantı koptu."); } }
public static void fillStates(string answerStates) { // buraya Mola|1;Yemek|2; şeklinde data geliyor answer.states içerisinde. Split edip kullanıyoruz. string[] states = answerStates.Split(';'); int i = 0; main.logAdd("", 1, "Downloading States..."); foreach (string state in states) { try { string[] stateInfo = state.Split('|'); sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (sipClient != null && stateInfo[0].Length > 0) { ToolStripItem subItem = new ToolStripMenuItem(stateInfo[0]); subItem.Click += new EventHandler(changeAgentState); sipClient.states.DropDownItems.Add(subItem); //sipClient.states.DropDownItems[Convert.ToInt16(stateInfo[1])].Click += new EventHandler(changeAgentState); main.logAdd("", 2, "New State: " + stateInfo[0]); i++; } else if (sipClient == null) { main.errorModal("Form'a erişilemedi. Kaynak: fillStates"); } } catch (Exception e) { main.logAdd("error", 1, e.Message.ToString()); } } main.logAdd("", 1, "Downloaded States."); }
public static void disableAllVideoCodecs() { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.MPEG4); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.H264); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.H263_plus); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.H263); }
public static void infoAdd(string field, string value) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (field == "skillName") { main.agentCurrentSkillName = value.ToString(); sipClient.infoTable.Rows.Add(null, value); } }
internal static void getAgentAnnounceFiles() { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); string[] package = { sipClient.jwsSessionId }; try { var answer = jws.jAgentGetAnnounceFiles(main.packUp(package)); if (answer.result == "OK" && answer.recordFile1 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile1, answer.recordContent1); } if (answer.result == "OK" && answer.recordFile2 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile2, answer.recordContent2); } if (answer.result == "OK" && answer.recordFile3 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile3, answer.recordContent3); } if (answer.result == "OK" && answer.recordFile4 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile4, answer.recordContent4); } if (answer.result == "OK" && answer.recordFile5 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile5, answer.recordContent5); } if (answer.result == "OK" && answer.recordFile6 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile6, answer.recordContent6); } if (answer.result == "OK" && answer.recordFile7 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile7, answer.recordContent7); } if (answer.result == "OK" && answer.recordFile8 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile8, answer.recordContent8); } if (answer.result == "OK" && answer.recordFile9 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile9, answer.recordContent9); } if (answer.result == "OK" && answer.recordFile10 != null) { System.IO.File.WriteAllBytes(main.announcePath + answer.recordFile10, answer.recordContent10); } } catch (Exception e) { main.errorModal("Announce: " + e.Message.ToString()); } }
public static void changeAgentState(object sender, EventArgs e) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); string newStateName = sender.ToString(); if (newStateName == sipClient.agentCurrentState.Text) { return; } if (sipClient != null) { string[] package = { sipClient.jwsSessionId, main.currentAgentState.ToString(), newStateName }; try { var answer = sipClient.jws.jAgentChangeState(main.packUp(package)); if (answer.result == "OK") { sipClient.agentCurrentState.Text = newStateName; main.logAdd("", 1, "Agent State Changed to " + newStateName); main.resetTimer(); sipClient.enterToLinePanel.Hide(); if (sipClient.agentCurrentState.Text == "Logged In" && newStateName != "Available") // logged in -> otherBreak başka bir molaya falan geçiyor. avail olmayacak dnd den çıkmasın { sipClient.phoneLine1.DoNotDisturb = true; } if (newStateName == "Available") // -> available { sipClient.phoneLine1.DoNotDisturb = false; } } else { main.errorModal(answer.reason); return; } } catch (Exception err) { main.errorModal("Statü değiştirilemedi: " + err.Message.ToString()); return; } } else { main.errorModal("Form bulunamadi"); } }
public static void enableAudioCodec(string codecName) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (codecName == "G729") { sipClient.softphone.EnableCodec(Ozeki.Media.Codec.CodecPayloadType.G729); } else if (codecName == "G722") { sipClient.softphone.EnableCodec(Ozeki.Media.Codec.CodecPayloadType.G722); } }
private void callWelcome_Load(object sender, EventArgs e) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); wsc.getAgentAnnounces(); ComboBox skills = sipClient.agentSkill; foreach (sipClient.ComboboxItem skill in skills.Items) { recordSkills.Items.Add(skill.Text); } Microphone.GetDevices().ForEach(delegate(Ozeki.Media.Audio.DeviceInfo mic) { mics.Items.Add(mic.ProductName); if (mic.ProductName == main.defMicrophone) { mics.SelectedItem = main.defMicrophone; } }); Speaker.GetDevices().ForEach(delegate(Ozeki.Media.Audio.DeviceInfo speaker) { speakers.Items.Add(speaker.ProductName); if (speaker.ProductName == main.defSpeaker) { speakers.SelectedItem = main.defSpeaker; } }); foreach (Ozeki.Media.Codec.CodecInfo codec in sipClient.softphone.Codecs) { audioCodecs.Items.Add(codec.CodecName); if (codec.CodecName == main.defAudioCodec) { audioCodecs.SelectedItem = main.defAudioCodec; } videoCodecs.Items.Add(codec.CodecName); if (codec.CodecName == main.defVideoCodec) { videoCodecs.SelectedItem = main.defVideoCodec; } } //sipClient.audioProcessor.AutoGainControl = true; //sipClient.audioProcessor.GainSpeed = ; }
internal static void getAgentAnnounces() { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); setSounds setSounds = (from p in Application.OpenForms.OfType <setSounds>() select p).FirstOrDefault(); if (setSounds != null) { setSounds.announces.Rows.Clear(); } sipClient.announces.Rows.Clear(); int i = 0; string[] package = { sipClient.jwsSessionId }; try { var answer = jws.jAgentGetAnnounce(main.packUp(package)); if (answer.result == "OK" && answer.records.ToString().Length > 0) { string[] fields = answer.records.ToString().Split(';'); foreach (string field in fields) { try { string[] datas = field.Split('|'); if (setSounds != null) { setSounds.announces.Rows.Insert(i, datas[0], datas[1], datas[2], datas[3], datas[4], datas[5], "Oynat"); } sipClient.announces.Rows.Insert(i, datas[0], datas[1], datas[2], datas[3], "Oynat"); i++; } catch { } } } else { main.errorModal("Records Error: " + answer.result); } } catch { } }
internal static void onMinimize() { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (sipClient.WindowState == FormWindowState.Minimized) { //sipClientMin sipClientMin = new sipClientMin(); //sipClientMin.Show(); sipClient.Height = 180; Screen myScreen = Screen.PrimaryScreen; sipClient.Location = new Point(main.getStartPosition(sipClient.Width), myScreen.WorkingArea.Height - 500); sipClient.WindowState = FormWindowState.Normal; } if (sipClient.WindowState == FormWindowState.Maximized) { sipClientMin sipClientMin = new sipClientMin(); sipClientMin.Hide(); } }
private void button3_Click(object sender, EventArgs e) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (mics.SelectedItem == null || speakers.SelectedItem == null || audioCodecs.SelectedItem == null || videoCodecs.SelectedItem == null) { main.errorModal("Tüm alanları (Mikrofon, Kulaklık, Ses ve Video codecleri dahil) eksiksiz doldurmalısınız."); return; } string[] package = { sipClient.jwsSessionId, mics.SelectedItem.ToString(), speakers.SelectedItem.ToString(), audioCodecs.SelectedItem.ToString(), videoCodecs.SelectedItem.ToString(), }; var answer = jws.jAgentSetSoundOption(main.packUp(package)); if (answer.result == "OK") { main.defMicrophone = mics.SelectedItem.ToString(); main.defSpeaker = speakers.SelectedItem.ToString(); main.defAudioCodec = audioCodecs.SelectedItem.ToString(); main.defVideoCodec = videoCodecs.SelectedItem.ToString(); main.disableAllAudioCodecs(); main.disableAllVideoCodecs(); main.enableAudioCodec(audioCodecs.SelectedItem.ToString()); main.enableVideoCodec(videoCodecs.SelectedItem.ToString()); main.infoModal("Ses ayarlarınız başarıyla kaydedildi."); } else { main.errorModal("Error: " + answer.result); } }
private void aktifEtToolStripMenuItem_Click(object sender, EventArgs e) { try { if (announces.SelectedRows.Count >= 0) { if (MessageBox.Show("Seçili olan " + announces.SelectedRows.Count.ToString() + " karşılama anonsunu aktif etmek istediğinize emin misiniz ?", "Emin misiniz ?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); string allId = null; foreach (DataGridViewRow row in announces.SelectedRows) { allId += row.Cells[0].Value.ToString() + ","; } string[] package = { sipClient.jwsSessionId, allId, "A" }; var answer = jws.jAgentSetAnnounceState(main.packUp(package)); if (answer.result == "OK") { wsc.getAgentAnnounces(); } else { main.errorModal("Error: " + answer.result); } } } } catch (Exception err) { main.errorModal(err.Message.ToString()); } }
/*public static void getForm(string formName) * { * sipClient sipClient = (from p in Application.OpenForms.OfType<sipClient>() select p).FirstOrDefault(); * if (sipClient != null) * sipClient.Text = "Text Değişti"; * }*/ public static void logAdd(string logType, int logLevel, string text) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (sipClient != null) { if (logType == "error") { text = text.ToUpper(); } if (logLevel == 2) { text = "--" + text; } if (logLevel == 3) { text = "---" + text; } sipClient.logs.Text += "[" + DateTime.Now.ToLongTimeString().ToString() + "] " + text + System.Environment.NewLine; } }
private void kaydıSilToolStripMenuItem_Click(object sender, EventArgs e) { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); if (announces.SelectedRows.Count >= 0) { if (MessageBox.Show("Seçili olan " + announces.SelectedRows.Count.ToString() + " karşılama anonsunu silmek istediğinize emin misiniz ?", "Emin misiniz ?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { string allId = null; foreach (DataGridViewRow row in announces.SelectedRows) { allId += row.Cells[0].Value.ToString() + ","; } string[] package = { sipClient.jwsSessionId, allId }; var answer = jws.jAgentRemoveAnnounce(main.packUp(package)); if (answer.result == "OK") { foreach (DataGridViewRow row in announces.SelectedRows) { if (File.Exists(main.announcePath + row.Cells[1].Value)) { File.Delete(main.announcePath + row.Cells[1].Value); } announces.Rows.RemoveAt(row.Index); } } else { main.errorModal(answer.reason); } } } }
private void button1_Click_1(object sender, EventArgs e) { try { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); sipClient.mp3Recorder.Stop(); sipClient.mp3Recorder.Dispose(); timer1.Stop(); if (File.Exists(main.announcePath + fileName.Text)) { Byte[] bytes = File.ReadAllBytes(main.announcePath + fileName.Text); String file = Convert.ToBase64String(bytes); string[] package = { sipClient.jwsSessionId, fileName.Text, newAnnounceName.Text, recordSkills.SelectedItem.ToString(), second.ToString(), main.agentId.ToString() }; var answer = jws.jAgentAddAnnounce(main.packUp(package), bytes); if (answer.result == "OK") { second = 0; wsc.getAgentAnnounces(); } else { main.errorModal("Error: " + answer.result); } } } catch (Exception err) { main.errorModal("Error: " + err.Message.ToString()); } }
public static void disableAllAudioCodecs() { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G722); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G723); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G726_16); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G726_24); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G726_32); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G726_40); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G728); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.G729); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.GSM); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.iLBC); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.L16); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.L16_44_1); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.L16_44_2); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.PCMA); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.PCMU); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.Speex_Narrowband); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.Speex_Ultrawideband); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.Speex_Wideband); sipClient.softphone.DisableCodec(Ozeki.Media.Codec.CodecPayloadType.telephone_event); }
private void button1_Click(object sender, EventArgs e) { if (validate.isEmail(username.Text) != true) { main.errorModal("Kullanıcı adı hatalı. Kullanıcı adı şu formatta olmalı: [email protected] veya isim@alanadi gibi."); return; } if (validate.notNull(password.Text) != true) { main.errorModal("Bir şifre yazmalısınız."); return; } string publicIp = wsc.getPublicIp(); if (publicIp == "0") { main.errorModal("Public IP algılanamadı. Lütfen bir yetkiliyle ile görüşün."); return; } publicIpShow.Text = publicIp; try { string[] package = { username.Text, password.Text, main.getMACAddress().ToString(), main.getLocalIP().ToString(), publicIp }; var answer = jws.jAgentLogin(main.packUp(package)); if (answer.result == "OK" && answer.sessionId.ToString().Length > 0) { this.Hide(); var sipClient = new sipClient(); sipClient.jwsSessionId = answer.sessionId.ToString(); main.sipUserName = answer.sipUserName.ToString(); main.sipAuth = answer.sipAuth.ToString(); main.sipPassword = answer.sipPassword.ToString(); main.sipServerIp = answer.sipServerIp.ToString(); main.sipServerHostname = answer.sipServerHostname.ToString(); main.sipServerPort = answer.sipServerPort.ToString(); main.agentId = answer.agentId.ToString(); main.domainName = answer.domainName.ToString(); main.defMicrophone = answer.defMicrophone.ToString(); main.defSpeaker = answer.defSpeaker.ToString(); main.defAudioCodec = answer.defAudioCodec.ToString(); main.defVideoCodec = answer.defVideoCodec.ToString(); sipClient.Show(); sipClient.stationExt.Text = answer.sipUserName.ToString(); sipClient.domainName.Text = answer.domainName.ToString(); wsc.fillStates(answer.states); wsc.fillSkills(answer.skills); } else { main.errorModal("Login Error: " + answer.result); } } catch (Exception err) { main.errorModal("Login: " + err.Message.ToString()); } }
internal static void addCallToGrid() { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); }
public static void loadActions() { try { sipClient sipClient = (from p in Application.OpenForms.OfType <sipClient>() select p).FirstOrDefault(); sipClient.answerPanel.Visible = false; sipClient.downloadBar.Visible = false; Screen myScreen = Screen.PrimaryScreen; Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.SetLicense("OZSDK-DNA2CALL-151119-282F5AEA", "TUNDOjIsTVBMOjIsRzcyOTp0cnVlLE1TTEM6MixNRkM6MixVUDoyMDE2LjExLjE5LFA6MjE5OS4wMS4wMXxGdnd4ZEt6SnFRbzI1eXdvMmpVaVkrdVVscUpoRXg0OGNta2w4WDYzMGFJMENOWkx4dmtobXgrWURXMERaQjAwNHcvbE4xL25FYnpORGh2Qm5WUWdXZz09"); sipClient.softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000); sipClient.statusScreen.Text = "Started"; sipClient.Height = myScreen.WorkingArea.Height; sipClient.Location = new Point(getStartPosition(sipClient.Width), 0); logAdd("", 1, "Application Started"); bool result = registerToSIP(); if (result == true) { sipClient.phoneLine1.RegistrationStateChanged += sipClient.sipAccount_RegStateChanged; sipClient.softphone.IncomingCall += sipClient.softphone_IncomingCall; sipClient.sipMessageLogger = new SIPMessageLogger(); sipClient.sipMessageLogger.SIPMessageReceived += (sipClient.sipMessageLogger_SIPMessageReceived); bool microphoneSuccess = false; Microphone.GetDevices().ForEach(delegate(Ozeki.Media.Audio.DeviceInfo mic) { if (mic.ProductName.Contains(defMicrophone)) { sipClient.microphone = Microphone.GetDevice(mic); MessageBox.Show("Mikrofon seçildi = " + mic.ProductName.ToString()); microphoneSuccess = true; } }); bool speakerSuccess = false; Speaker.GetDevices().ForEach(delegate(Ozeki.Media.Audio.DeviceInfo speaker) { if (speaker.ProductName.Contains(defSpeaker)) { sipClient.speaker = Speaker.GetDevice(speaker); MessageBox.Show("Kulaklık seçildi = " + speaker.ProductName.ToString()); speakerSuccess = true; } }); if (microphoneSuccess == false) { sipClient.microphone = Microphone.GetDefaultDevice(); main.errorModal("Daha önce seçtğiniz " + defMicrophone + " adlı cihaz şuan bu PC'ye bağlı değil. Bu sebeple varsayılan mikrofon seçildi."); } if (speakerSuccess == false) { sipClient.speaker = Speaker.GetDefaultDevice(); main.errorModal("Daha önce seçtğiniz " + defSpeaker + " adlı cihaz şuan bu PC'ye bağlı değil. Bu sebeple varsayılan kulaklık/hoparlör seçildi."); } sipClient.mediaReceiver = new PhoneCallAudioReceiver(); sipClient.mediaSender = new PhoneCallAudioSender(); sipClient.connector = new MediaConnector(); disableAllAudioCodecs(); disableAllVideoCodecs(); enableAudioCodec(defAudioCodec); enableVideoCodec(defVideoCodec); wsc.getAgentAnnounces(); } } catch (Exception err) { errorModal("LoadActions: " + err.Message.ToString()); } }