コード例 #1
0
        void EndOfCall(string ownerNumber, string caseId, string time)
        {
            try
            {
                Users usr = ModelContainerHolder.Model.Users.Where(a => a.PhoneNumber == ownerNumber).FirstOrDefault();
                if (usr == null)
                    throw new Exception("Couldnt match number with owner"); //Better exception

                AndroidPcPair ap = new AndroidPcPair();

                if (string.IsNullOrEmpty(caseId))//If the phone didnt pass the caseId, grab the latest recorded in the Pair.
                {
                    if (m_pairMap.TryGetValue(usr.Id,out ap))
                        caseId = ap.CurrentCaseId;
                }
                Cases Case = ModelContainerHolder.Model.Cases.Find(int.Parse(caseId));
                Case.EndTime = DateTime.Parse(time);
                //Case.TotalTime = ((TimeSpan?)(Case.EndTime - (DateTime?)Case.StartTime)).Value.Seconds; // Duration in seconds
                Case.TotalTime = (Nullable<int>)((DateTime)Case.EndTime).Subtract(Case.StartTime).TotalSeconds;
                ModelContainerHolder.Model.SaveChanges();

                //Notify PCClient
                if (m_pairMap.TryGetValue(usr.Id, out ap))
                    Send("02", ap.Pc);
            }
            catch (System.Exception ex)
            {
            	
            }
        }
コード例 #2
0
        void EndOfCall(string ownerNumber, string caseId, string time)
        {
            try
            {
                Users usr = ModelContainerHolder.Model.Users.Where(a => a.PhoneNumber == ownerNumber).FirstOrDefault();
                if (usr == null)
                {
                    throw new Exception("Couldnt match number with owner"); //Better exception
                }
                AndroidPcPair ap = new AndroidPcPair();

                if (string.IsNullOrEmpty(caseId))//If the phone didnt pass the caseId, grab the latest recorded in the Pair.
                {
                    if (m_pairMap.TryGetValue(usr.Id, out ap))
                    {
                        caseId = ap.CurrentCaseId;
                    }
                }
                Cases Case = ModelContainerHolder.Model.Cases.Find(int.Parse(caseId));
                Case.EndTime = DateTime.Parse(time);
                //Case.TotalTime = ((TimeSpan?)(Case.EndTime - (DateTime?)Case.StartTime)).Value.Seconds; // Duration in seconds
                Case.TotalTime = (Nullable <int>)((DateTime)Case.EndTime).Subtract(Case.StartTime).TotalSeconds;
                ModelContainerHolder.Model.SaveChanges();

                //Notify PCClient
                if (m_pairMap.TryGetValue(usr.Id, out ap))
                {
                    Send("02", ap.Pc);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
コード例 #3
0
 private void PhonePairRequest(string phoneNumber, string port, string ip)
 {
     try
     {
         Users usr = ModelContainerHolder.Model.Users.Where(a => a.PhoneNumber == phoneNumber).FirstOrDefault();
         if (usr == null)
         {
             throw new Exception("Couldnt match number with owner"); //Better exception
         }
         AndroidPcPair pair = new AndroidPcPair();
         if (m_pairMap.TryGetValue(usr.Id, out pair))
         {
             pair.Android = new Client(ip, port);
         }
         else
         {
             pair         = new AndroidPcPair();
             pair.Android = new Client(ip, port);
             m_pairMap.Add(usr.Id, pair);
         }
     }
     catch (Exception e)
     {
         //Handle Error.
     }
 }
コード例 #4
0
        protected override void IncomingCall(string ownerNumber, string callerNumber, string time)
        {
            try
            {
                Users usr = ModelContainerHolder.Model.Users.Where(a => a.PhoneNumber == ownerNumber).FirstOrDefault();
                if (usr == null)
                {
                    throw new Exception("Couldnt match number with owner"); //Better exception
                }
                //Create new case
                int newCaseID = ModelContainerHolder.NewCase(callerNumber, usr.Id, DateTime.Parse(time));
                if (newCaseID == -1)
                {
                    throw new Exception("Couldnt create new case.");
                }
                //Notify PC
                AndroidPcPair pair = new AndroidPcPair();
                if (m_pairMap.TryGetValue(usr.Id, out pair))
                {
                    pair.CurrentCaseId = newCaseID.ToString();
                    if (pair.Android != null)
                    {
                        m_transmitter.Send("00|" + newCaseID, pair.Android); //Send caseId to Phone.
                    }
                    else
                    {
                        throw new Exception("Not paired with phone");
                    }

                    if (pair.Pc != null)
                    {
                        m_transmitter.Send("00|" + newCaseID, pair.Pc); //Send caseId to PC.
                    }
                    else
                    {
                        throw new Exception("Not paired with PC.");
                    }
                }
                else
                {
                    throw new Exception("Not paired with phone");
                }
            }
            catch (Exception e)
            {
                //Error..
            }
        }
コード例 #5
0
        private void PcPairRequest(string userId, string ip, string port)
        {
            AndroidPcPair pair = new AndroidPcPair();

            //IF(Det finns redan en mappning mot detta userid)
            if (m_pairMap.TryGetValue(int.Parse(userId), out pair))
            {
                pair.Pc = new Client(ip, port);
            }
            else
            {
                pair    = new AndroidPcPair();
                pair.Pc = new Client(ip, port);
                m_pairMap.Add(int.Parse(userId), pair);
            }
        }
コード例 #6
0
        protected override void IncomingCall( string ownerNumber, string callerNumber, string time)
        {
            try
            {
                Users usr = ModelContainerHolder.Model.Users.Where(a => a.PhoneNumber == ownerNumber).FirstOrDefault();
                if (usr == null)
                    throw new Exception("Couldnt match number with owner"); //Better exception

                //Create new case
                int newCaseID = ModelContainerHolder.NewCase(callerNumber, usr.Id, DateTime.Parse(time));
                if (newCaseID == -1)
                    throw new Exception("Couldnt create new case.");
                //Notify PC
                AndroidPcPair pair = new AndroidPcPair();
                if (m_pairMap.TryGetValue(usr.Id, out pair))
                {
                    pair.CurrentCaseId = newCaseID.ToString();
                    if (pair.Android != null)
                    {
                        m_transmitter.Send("00|" + newCaseID, pair.Android); //Send caseId to Phone.
                    }
                    else
                        throw new Exception("Not paired with phone");

                    if (pair.Pc != null)
                    {
                        m_transmitter.Send("00|" + newCaseID, pair.Pc); //Send caseId to PC.
                    }
                    else
                        throw new Exception("Not paired with PC.");
                }
                else
                    throw new Exception("Not paired with phone");
            
            }
            catch (Exception e)
            {
                //Error..
            }
        }
コード例 #7
0
        private void PhonePairRequest(string phoneNumber, string port, string ip)
        {
            try
            {
                Users usr = ModelContainerHolder.Model.Users.Where(a => a.PhoneNumber == phoneNumber).FirstOrDefault();
                if (usr == null)
                    throw new Exception("Couldnt match number with owner"); //Better exception

                AndroidPcPair pair = new AndroidPcPair();
                if (m_pairMap.TryGetValue(usr.Id, out pair))
                    pair.Android = new Client(ip, port);
                else
                {
                    pair = new AndroidPcPair();
                    pair.Android = new Client(ip, port);
                    m_pairMap.Add(usr.Id, pair);
                }
            }
            catch (Exception e)
            {
                //Handle Error.
            }
            

            
     
        }
コード例 #8
0
        private void PcPairRequest(string userId, string ip, string port)
        {

            AndroidPcPair pair = new AndroidPcPair();
            //IF(Det finns redan en mappning mot detta userid)
            if (m_pairMap.TryGetValue(int.Parse(userId), out pair))
                pair.Pc = new Client(ip, port);
            else
            {
                pair = new AndroidPcPair();
                pair.Pc = new Client(ip, port);
                m_pairMap.Add(int.Parse(userId), pair);
            }

        }