Esempio n. 1
0
        static void Main(string[] args)
        {
            string[] phoneNumbers = Console.ReadLine().Split();
            string[] urls         = Console.ReadLine().Split();

            Telephony telephony = new Telephony();

            foreach (string number in phoneNumbers)
            {
                try
                {
                    telephony.Call(number);
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
            foreach (string url in urls)
            {
                try
                {
                    telephony.Browser(url);
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
        }
Esempio n. 2
0
        private void InitializeRainbowSDK()
        {
            rainbowApplication = new Rainbow.Application();;

            // Set Application Id, Secret Key and Host Name
            rainbowApplication.SetApplicationInfo(APP_ID, APP_SECRET_KEY);
            rainbowApplication.SetHostInfo(HOST_NAME);

            // Get Rainbow main objects
            rainbowTelephony = rainbowApplication.GetTelephony();
            rainbowContacts  = rainbowApplication.GetContacts();

            // EVENTS WE WANT TO MANAGE SOME EVENTS
            rainbowApplication.ConnectionStateChanged += RainbowApplication_ConnectionStateChanged;

            rainbowTelephony.TelephonyStatusUpdated     += RainbowTelephony_TelephonyStatusUpdated;
            rainbowTelephony.CallForwardStatusUpdated   += RainbowTelephony_CallForwardStatusUpdated;
            rainbowTelephony.NomadicStatusUpdated       += RainbowTelephony_NomadicStatusUpdated;
            rainbowTelephony.VoiceMessagesNumberUpdated += RainbowTelephony_VoiceMessagesNumberUpdated;

            rainbowTelephony.CallUpdated += RainbowTelephony_CallUpdated;
            rainbowTelephony.CallFailed  += RainbowTelephony_CallFailed;

            // Init other objects
            voiceMessagesList = null;

            pbxCall1 = null;
            pbxCall2 = null;
        }
 public CallingForm(Telephony _pjsipTelephony, string PhoneNumber)
 {
     InitializeComponent();
     pjsipTelephony = _pjsipTelephony;
     pjsipTelephony.IncomingCallEnded += PjsipTelephony_IncomingCallEnded;
     phoneNumber = PhoneNumber;
     label1.Text = PhoneNumber;
 }
Esempio n. 4
0
        public HttpResponse checkagentlogoncode(string location, string agent, string code)
        {
            try
            {
                Response.ContentType = "application/json";

                if (location == null || location == "")
                {
                    throw new Exception("Invalid location");
                }

                AgentClient ac = new AgentClient();
                Agent       a  = ac.GetAll().Execute().Where(x => x.LoginName == agent).SingleOrDefault();

                if (a == null)
                {
                    throw new Exception("Invalid agent ID or code");
                }

                if (a.LoginCode == code)
                {
                    a.CurrentLocation = location;
                    a.CurrentStatus   = "loggedon";
                    ac.Update(a);

                    AgentEventClient aec = new AgentEventClient();
                    aec.AddNewItem(new AgentEvent(agent, "logon", location));

#if DEBUG
#else
                    Telephony t = new Telephony();
                    //Send to Rick
                    //t.SendSMS("+19174340659", agent + " logged on at " + location);

                    //Send to Mike
                    t.SendSMS("+19179578770", agent + " logged on at " + location);
#endif

                    Response.Write("{\"result\": \"ok\", \"logonname\": \"" + a.LoginName + "\", \"logoncolor\": \"" + a.LoginColor + "\"}");
                    Response.End();
                }
                else
                {
                    throw new Exception("Invalid agent ID or code");
                }
            }
            catch (Exception ex)
            {
                Response.ContentType = "application/json";
                Response.Write(DefaultErrorResponse(ex.Message));
                Response.End();
            }

            return(null);
        }
Esempio n. 5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     pjsipTelephony = TelephonyList.Create("PJSIP");
     label4.Text    = pjsipTelephony.State.ToString();
 }
Esempio n. 6
0
// code to get IMEI
        public static string GetTerminalImeiAddress()
        {
            Telephony t = null;
            Line line = null;
            try
            {
                t = new Telephony();
                t.Initialize();
                line = t.CreateLine(0,MediaMode.AutomatedVoice, CallPrivilege.Monitor);

                byte[] buffer = new byte[512];
                //write size
                BitConverter.GetBytes(512).CopyTo(buffer, 0);

                if (lineGetGeneralInfo(line.hLine, buffer) != 0)
                {
                    throw new System.ComponentModel.Win32Exception(
                        System.Runtime.InteropServices.Marshal.GetLastWin32Error(),
                        "TAPI Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X"));
                }

                int serialsize = BitConverter.ToInt32(buffer, 36);
                int serialoffset = BitConverter.ToInt32(buffer, 40);
                string imei = System.Text.Encoding.Unicode.GetString(buffer, serialoffset, serialsize);
                imei = imei.Substring(0, imei.IndexOf(Convert.ToChar(0)));

                return imei;

            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            finally
            {
                try
                {
                    if (line != null)
                        line.Dispose();
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }

                try
                {
                    if (t != null)
                        t.Shutdown();
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }

            }

            return string.Empty;
        }
Esempio n. 7
0
 public AccountForm(Telephony _pjsipTelephony)
 {
     InitializeComponent();
     pjsipTelephony = _pjsipTelephony;
 }
Esempio n. 8
0
        public HttpResponse logoff(string location, string agent, string code)
        {
            try
            {
                Response.ContentType = "application/json";

                AgentClient ac = new AgentClient();
                Agent       a  = ac.GetAll().Execute().Where(x => x.LoginName == agent).SingleOrDefault();

                if (a == null)
                {
                    throw new Exception("Invalid agent ID or code");
                }

                if (a.LoginCode == code)
                {
                    DateTime nowTime = EasternTimeConverter.Convert(DateTime.UtcNow);


                    AgentEventClient aec       = new AgentEventClient();
                    AgentEvent       lastEvent = aec.GetAll().Execute().Where(x => x.Agent == agent).OrderByDescending(x => x.EventTime).FirstOrDefault();

                    string hoursworked = "No prior logon.";
                    string production  = "No results.";
                    if (lastEvent.EventType == "logon")
                    {
                        long     elapsedTicks = nowTime.Ticks - lastEvent.EventTime.Ticks;
                        TimeSpan ts           = new TimeSpan(elapsedTicks);
                        hoursworked = ts.Hours.ToString() + "h : " + ts.Minutes + "m logged.";

                        //Count how many leads
                        List <SkillCowRequestSubmission> allrecords = new List <SkillCowRequestSubmission>();

                        DateTime cursordate = lastEvent.EventTime;

                        SkillCowRequestSubmissionClient rsc = new SkillCowRequestSubmissionClient();
                        while (cursordate <= nowTime)
                        {
                            CloudTableQuery <SkillCowRequestSubmission> query = rsc.GetAll(cursordate.ToString("yyyyMMdd"));
                            allrecords.AddRange(query.Execute().Where(x => x.UtmCampaign == location && x.UtmContent == agent).OrderBy(x => x.Timestamp));
                            cursordate = cursordate.AddDays(1);
                        }

                        //tally up
                        int totalschoolleads = 0;
                        int totalindeedjobs  = 0;
                        int totalcourses     = 0;
                        foreach (SkillCowRequestSubmission x in allrecords)
                        {
                            switch (x.SourceForm)
                            {
                            case "schoolform":
                                totalschoolleads++;
                                break;

                            case "indeedjob":
                                totalindeedjobs++;
                                break;

                            case "udemycourse":
                                totalcourses++;
                                break;
                            }
                        }
                        if (totalschoolleads + totalindeedjobs + totalcourses > 0)
                        {
                            production  = "\n";
                            production += totalschoolleads + " school leads\n";
                            production += totalindeedjobs + " indeed jobs\n";
                            production += totalcourses + " udemy courses";
                        }
                    }

                    //Log event
                    aec.AddNewItem(new AgentEvent(agent, "logoff", location));

                    a.CurrentLocation = "";
                    a.CurrentStatus   = "loggedoff";
                    ac.Update(a);

#if DEBUG
#else
                    Telephony t = new Telephony();

                    string message = agent + " logged OFF at " + location + "\n" + hoursworked + "\n" + production;
                    //Send to Rick
                    //t.SendSMS("+19174340659", message);

                    t.SendSMS("+19179578770", message);
#endif

                    Response.Write("{\"result\": \"ok\", \"logonname\": \"" + a.LoginName + "\"}");
                    Response.End();
                }
                else
                {
                    throw new Exception("Invalid agent ID or code");
                }
            }
            catch (Exception ex)
            {
                Response.ContentType = "application/json";
                Response.Write(DefaultErrorResponse(ex.Message));
                Response.End();
            }

            return(null);
        }