ToString() public method

public ToString ( ) : string
return string
Example #1
0
        public HtCall(string rootpath, Call call)
        {
            RelativePath   = BackOne;
            Title          = call.ReadableName + " call";
            IncludeJQuery  = false;
            ActiveMenuItem = MenuItem.Calls;

            var potentialIconName = call.Name.ToLower();

            if (potentialIconName.Contains("-"))
            {
                potentialIconName = potentialIconName.Substring(0, potentialIconName.LastIndexOf('-'));
            }
            if (File.Exists(Path.Combine(rootpath, $"stuff\\{potentialIconName}.png")))
            {
                LeftTopIcon = potentialIconName;
            }
            else
            {
                Logger.Log($"Icon '{potentialIconName}' not found");
            }

            if (!TryIfLinkIsAlive(rootpath, call.Name + ".html"))
            {
                if (!TryIfLinkIsAlive(rootpath, call.Name.Split('-')[0] + ".html"))
                {
                    Logger.Log($"No good link found for '{call.Name}' from the call");
                }
            }

            EditPath = $"calls/{call.Name}.cfp";
            Content  = $"<h2><span class=\"ttl\">Call</span> of {call.ReadableName}</h2>"
                       + Environment.NewLine
                       + call.ToString();
        }
        public void RemoveLongestCall()
        {
            Call longestCall = this.callHistory.GetLongestCall();

            this.callHistory.Remove(longestCall);

            Print("Remove longest call", longestCall.ToString());
        }
Example #3
0
        public void CreateCallTest()
        {
            CallFactory target   = new CallFactory();
            Call        expected = new Call((uint)0);
            Call        actual;

            actual = target.CreateCall();
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Example #4
0
        public void ToStringTest()
        {
            uint   callId   = 0;
            Call   target   = new Call(callId);
            string expected = "Call ID: 0, StartTime: 00:00, BeginWaitTime: 00:00, FinishTime: 00:00, Product Type: Not Set";
            string actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }
Example #5
0
 public void VisitCall(Call call)
 {
     if (call.Target.ToString().Contains("System.Windows.Forms.MessageBox::Show"))
     {
         if (!call.ToString().Contains("System.Windows.Forms.MessageBoxOptions"))
         {
             Reporter.MethodFailed(m_method, CheckID, call.Untyped.Offset, string.Empty);
         }
     }
 }
        public void ToString_ShouldReturnCorrectString()
        {
            DateTime callDate = new DateTime(2010, 12, 31, 23, 59, 59);
            string   date     = callDate.ToShortDateString();
            Call     call     = new Call(callDate, "088888888", 120);
            string   expected = "Call " + date + " 23:59:59 to: 088888888 duration 2:00";
            string   result   = call.ToString();

            Assert.AreEqual(expected, result, "The output string should contain call date, time, number, duration");
        }
 static void Main()
 {
     string[] model = { "5S", "Galaxy", "Lumia 1080" };//necesery fields
     string[] manufactory = { "IPhone", "Samsung", "Nokia" };//necesery fields
     List<GSMCoreInfo> GSMs = new List<GSMCoreInfo>();
     //Loop for fill all fields
     for (int i = 0; i < model.Length; i++)
     {
         GSMCoreInfo GSM = new GSMCoreInfo(model[i], manufactory[i]);
         GSMs.Add(GSM);
         Console.WriteLine(GSM.ToString());
     }
     Console.WriteLine(GSMCoreInfo.IPhone);
     //Test the Call class
     List<Call> callPerPhone = new List<Call>();
     string[] callTime = { "2000.12.3;23:11", "2000.12.4;25:23", "2000.12.24;23:59", "2001.1.1;00:01" };
     string[] dialedNumber = { "0877123456", "0877123456", "0877123456", "0877123456" };
     ulong[] durationInSec = { 180, 240, 450, 360 };
     decimal sum = new decimal();
     for (int i = 0; i < 4; i++)
     {
         Call currentCall = new Call();
         currentCall.CallTime = callTime[i];
         currentCall.DialedNumber = dialedNumber[i];
         currentCall.DurationSec = durationInSec[i];
         Console.WriteLine(currentCall.ToString());
         callPerPhone.Add(currentCall);
     }
     //Idont have much time and i write it in Main to compile its prity good timing and fast rewriting
     TotalMoney total = new TotalMoney();
     Console.WriteLine("{0} \n Money spend: "+total.SumAllCalls(callPerPhone),GSMs[2]);
     ulong deffduration = callPerPhone[0].DurationSec;
     for (int i = 0; i <callPerPhone.Count; i++)
     {
         if (deffduration < callPerPhone[i].DurationSec)
         {
             deffduration = callPerPhone[i].DurationSec;
         }
     }
     for (int i = 0; i < callPerPhone.Count; i++)
     {
         if (deffduration == callPerPhone[i].DurationSec)
         {
             callPerPhone[i].DurationSec = 0;
         }
     }
     Console.WriteLine("{0} \n Money spend: " + total.SumAllCalls(callPerPhone), GSMs[2]);
     callPerPhone.Clear();
     Console.WriteLine("This Info is Cleared");
     Console.WriteLine("Have a nice Day");
 }
Example #8
0
        public void GameLoop()
        {
            Application.Run(callForm);
            call = (Call)bf.Deserialize(ns);
            string title = (string)bf.Deserialize(ns);

            if (!title.Equals("pass"))
            {
                callForm = new CallForm(ns, title);
                Application.Run(callForm);
            }
            this.Text = call.ToString();
            StartGame();
        }
Example #9
0
        private void button5_Click(object sender, EventArgs e)
        {
            lineIsBusy = true;

            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = true;
            button5.Enabled = false;

            currentCall = createOutgoingCall(comboBox1.Text, comboBox2.Text);
            label3.Text = "";
            label6.Text = currentCall.ToString();
        }
Example #10
0
        public void ToStringTest()
        {
            var call = new Call
            {
                CallDirection = Call.Direction.Outgoing,
                Caller        = new Contact("Serhii", "Litvinov", new List <string> {
                    "+38111"
                }),
                CallTime = DateTime.MaxValue
            };

            var expected = $"Serhii Litvinov Outgoing {DateTime.MaxValue} : ( 0 )";

            Assert.AreEqual(expected, call.ToString());
        }
Example #11
0
 private void AddCall(Call c, string address)
 {
     try
     {
         if (((Hashtable)Calls[address]).ContainsKey(c.callId))
         {
             log.Debug("Adding call for " + address + ": " + c.ToString());
             ss.AddCallLogs(address, c);
             shiftCall(c.callId, address);
         }
     }
     catch (Exception e)
     {
         log.Error("Unable to add call " + c.callId + " from " + address + ": " + e.Message);
     }
 }
Example #12
0
        public static void TestCallHistory()
        {
            StringBuilder sb    = new StringBuilder();
            Manufacturer  nokia = new Manufacturer("Nokia", "USA");
            GSM           lumia = new GSM("Lumia", nokia, 250, new Battery(), new Display());

            lumia.CallHistory.Add(new Call("12345", 230));
            lumia.CallHistory.Add(new Call("12345", 50));
            lumia.CallHistory.Add(new Call("12345", 180));

            sb.AppendLine("Call history: ");
            foreach (var call in lumia.CallHistory)
            {
                sb.AppendLine(call.ToString());
            }

            sb.AppendLine(Constants.Border);

            decimal totalPrice = lumia.CalculateTotalCallPrice(PricePerMinute);

            sb.AppendFormat("Total price all: {0}", totalPrice)
            .AppendLine()
            .AppendLine(Constants.Border);

            sb.AppendLine("To remove: ");
            Call longestCall = FindLongestCall(lumia);

            lumia.CallHistory.Remove(longestCall);

            sb.AppendLine(longestCall.ToString())
            .AppendLine(Constants.Border);

            totalPrice = lumia.CalculateTotalCallPrice(PricePerMinute);
            sb.AppendFormat("Total price after removal: {0}", totalPrice)
            .AppendLine()
            .AppendLine(Constants.Border);

            lumia.CallHistory.Clear();
            sb.AppendLine("Call history after clearing: ");
            foreach (var call in lumia.CallHistory)
            {
                sb.AppendLine(call.ToString());
            }

            Console.WriteLine(sb.ToString());
        }
Example #13
0
        private static void SendCallToPlayers()
        {
            for (int i = 0; i < players.Length; i++)
            {
                int clientIndex = players[i].ClientIndex;
                ns = clients[clientIndex].GetStream();
                bf.Serialize(ns, call);
                if (players[i].IsCall)
                {
                    bf.Serialize(ns, "pass");
                }
                else
                {
                    bf.Serialize(ns, call.ToString());
                }

                ns.Flush();
            }
        }
Example #14
0
 public override string ToString()
 {
     return(Call.ToString());
 }
        private void TopCallWorkersFrm_Load(object sender, EventArgs e)
        {
            if (Call == null)
            {
                return;
            }

            //show which call this is
            callLbl.Text = Call.ToString();

            //get the service user for this call
            ServiceUser serviceuser = Call.ServiceUser;

            ////this is the list of workers to add to the list
            List <TopWorkersViewModel> workersToAdd = new List <TopWorkersViewModel>();


            //Get infor for every active worker
            foreach (Worker worker in  WorkerManager.Instance.ActiveWorkers)
            {
                //first lets get distance
                double miles = -1;

                if (worker.LongLatCoords != null && worker.LongLatCoords.HasLongLat)
                {
                    try
                    {
                        miles = GoogleMaps.GetDistance(worker.LongLatCoords, serviceuser.LongLatCoords, "M");
                    }
                    catch (Exception ex) { }
                }

                //now whether they are a keyworker
                bool isKeyWorker = serviceuser.KeyWorkers.Contains(worker);

                //no
                Image img = null;

                if (isKeyWorker)
                {
                    img = Cura.Properties.Resources.key;
                }

                //now get the time unassigned
                int minutes_unassinged = worker.Unassigned_Mins_ForWeek(StartDate);

                //ignore people without any of this information!
                if (minutes_unassinged == 0 && !isKeyWorker && miles < 0)
                {
                    continue;
                }

                workersToAdd.Add(
                    new TopWorkersViewModel()
                {
                    worker         = worker,
                    distance_miles = miles,
                    isKeyWorker    = isKeyWorker,
                    image          = img,
                    mins_workingtime_unassigned = minutes_unassinged
                }
                    );
            }


            IEnumerable <TopWorkersViewModel> res = workersToAdd.OrderByDescending(w => w.isKeyWorker).ThenBy(w => w.distance_miles).ThenByDescending(w => w.mins_workingtime_unassigned).Take(10);

            int index = 1;

            foreach (TopWorkersViewModel model in res)
            {
                model.index = index++;
            }

            ////hours remaining
            listView1.SetObjects(res);



            ////distance
            ////get the closest remaining who aren't key workers

            //Dictionary<Worker, double> WorkerMiles = new Dictionary<Worker, double>();

            //if (serviceuser.LongLatCoords != null && serviceuser.LongLatCoords.HasLongLat)
            //{
            //    foreach (Worker worker in WorkerManager.Instance.Workers.Where(w => !serviceuser.KeyWorkers.Contains(w)))
            //    {
            //        if (worker.LongLatCoords == null || !worker.LongLatCoords.HasLongLat)
            //            continue ;

            //        double miles = GoogleMaps.GetDistance(worker.LongLatCoords, serviceuser.LongLatCoords, "M");

            //        WorkerMiles.Add(worker, miles);
            //    }
            //}



            ////FIRST DO THE KEYWORKERS
            //foreach (Worker worker in serviceuser.KeyWorkers)
            //{
            //    if (remaining == 0)
            //        break;

            //    double miles = -1;

            //    if (worker.LongLatCoords != null && worker.LongLatCoords.HasLongLat)
            //    {
            //        try
            //        {
            //            miles = GoogleMaps.GetDistance(worker.LongLatCoords, serviceuser.LongLatCoords, "M");
            //        }catch(Exception ex){}
            //    }

            //    workersToAdd.Add(new TopWorkersViewModel() { worker = worker, distance_miles = miles, isKeyWorker = true, image = ImageGenerator.Instance.GenerateWorkerImage(ImageGenerator.WorkerImageGen.Key), mins_workingtime_unassigned = worker.Unassigned_Mins_ForWeek(StartDate) });
            //    remaining -= 1;
            //}


            ////NOW DO THE PEOPLE THAT ARE CLOSEST BUT NOT KEY WORKERS
            // foreach(KeyValuePair<Worker, double> pair in WorkerMiles)
            //{
            //    if (remaining == 0)
            //        break;

            //    workersToAdd.Add(new TopWorkersViewModel() { worker = pair.Key, distance_miles = pair.Value, isKeyWorker = false, mins_workingtime_unassigned = pair.Key.Unassigned_Mins_ForWeek(StartDate) });

            //    remaining -= 1;
            //}


            //IEnumerable<Worker> list1 = WorkerManager.Instance.Workers;
            //list1.OrderByDescending(w => w.Unassigned_Mins_ForWeek(StartDate));

            // foreach (Worker worker in list1)
            // {
            //     if (remaining == 0)
            //         break;

            //     workersToAdd.Add(new TopWorkersViewModel() { worker = worker, isKeyWorker = false, mins_workingtime_unassigned = worker.Unassigned_Mins_ForWeek(StartDate) });

            //     remaining -= 1;
            // }


            //  workersToAdd.OrderBy(w => w.isKeyWorker).ThenBy(w => w.distance_miles).ThenBy(w => w.mins_workingtime_unassigned);

            ////hours remaining
            //listView1.SetObjects(workersToAdd);
        }
Example #16
0
 public override string ToString()
 {
     return("APPLY " + Call.ToString() + " ON " + ListExpression.ToString());
 }
Example #17
0
        private void UpdateCall(Call call)
        {
            // We can update this compoent only if we are in the from thread
            if (tbCall1Id.InvokeRequired)
            {
                CallArgReturningVoidDelegate d = new CallArgReturningVoidDelegate(UpdateCall);
                this.Invoke(d, new object[] { call });
            }
            else
            {
                Boolean VMAvailable = false;
                Boolean manageCall1 = false;


                log.LogDebug("UpdateCall: [{0}]", call.ToString());

                // Voice mail is available ?
                VMAvailable = rainbowTelephony.VoiceMailAvailable();

                // Do we need to update Call 1 or Call 2 ?
                if ((pbxCall2 != null) &&
                    (pbxCall2.Id == call.Id))
                {
                    manageCall1 = false;
                }
                else if (pbxCall1 == null)
                {
                    manageCall1 = true;
                }
                else if (pbxCall1.Id == call.Id)
                {
                    manageCall1 = true;
                }

                // Update form elements
                if (manageCall1)
                {
                    // Store call
                    pbxCall1 = call;

                    tbCall1Id.Text              = call.Id;
                    tbCall1Status.Text          = call.CallStatus.ToString();
                    tbCall1LocalMedia.Text      = call.LocalMedia.ToString();
                    tbCall1RemoteMedia.Text     = call.RemoteMedia.ToString();
                    tbCall1DeviceType.Text      = call.DeviceType;
                    cbCall1IsConference.Checked = call.IsConference;

                    // List participants
                    if ((pbxCall1.Participants != null) && (pbxCall1.Participants.Count > 0))
                    {
                        String output = "";
                        int    nb     = 1;
                        foreach (CallParticipant participant in pbxCall1.Participants)
                        {
                            if (nb > 1)
                            {
                                output += "\r\n";
                            }
                            output += nb + ") " + participant.DisplayName + " - " + participant.PhoneNumber;
                            nb++;
                        }
                        tbCall1Participants.Text = output;
                    }

                    // Manage buttons
                    cbCall1Dtmf.Visible = (call.CallStatus == Call.Status.ACTIVE);

                    switch (call.CallStatus)
                    {
                    case Call.Status.UNKNOWN:
                        // The call is finished
                        btn1Call1.Text    = "Answer";
                        btn1Call1.Enabled = false;

                        btn2Call1.Text    = "To VM";
                        btn2Call1.Enabled = false;

                        btn3Call1.Text    = "Release";
                        btn3Call1.Enabled = false;

                        // No more manage this call
                        pbxCall1 = null;
                        break;

                    case Call.Status.RINGING_INCOMING:
                        btn1Call1.Text    = "Answer";
                        btn1Call1.Enabled = true;

                        btn2Call1.Text    = "To VM";
                        btn2Call1.Enabled = VMAvailable;

                        btn3Call1.Text    = "Release";
                        btn3Call1.Enabled = true;

                        break;

                    case Call.Status.ANSWERING:
                    case Call.Status.CONNECTING:
                    case Call.Status.DIALING:
                    case Call.Status.RINGING_OUTGOING:
                        btn1Call1.Text    = "Answer";
                        btn1Call1.Enabled = false;

                        btn2Call1.Text    = "To VM";
                        btn2Call1.Enabled = false;

                        btn3Call1.Text    = "Release";
                        btn3Call1.Enabled = true;

                        break;

                    case Call.Status.ACTIVE:
                        btn1Call1.Text    = "Hold";
                        btn1Call1.Enabled = true;

                        btn2Call1.Text    = "DTMF";
                        btn2Call1.Enabled = true;

                        btn3Call1.Text    = "Release";
                        btn3Call1.Enabled = true;

                        break;

                    case Call.Status.RELEASING:
                        btn1Call1.Text    = "Hold";
                        btn1Call1.Enabled = false;

                        btn2Call1.Text    = "DTMF";
                        btn2Call1.Enabled = false;

                        btn3Call1.Text    = "Release";
                        btn3Call1.Enabled = false;
                        break;

                    case Call.Status.QUEUED_INCOMING:
                    case Call.Status.QUEUED_OUTGOING:
                    case Call.Status.HOLD:
                        btn1Call1.Text    = "Hold";
                        btn1Call1.Enabled = false;

                        btn2Call1.Text    = "DTMF";
                        btn2Call1.Enabled = false;

                        btn3Call1.Text    = "Release";
                        btn3Call1.Enabled = true;
                        break;

                    case Call.Status.PUT_ON_HOLD:
                        btn1Call1.Text    = "Unhold";
                        btn1Call1.Enabled = true;

                        btn2Call1.Text    = "DTMF";
                        btn2Call1.Enabled = false;

                        btn3Call1.Text    = "Release";
                        btn3Call1.Enabled = false;
                        break;

                    case Call.Status.ERROR:
                        break;
                    }
                }
                else // Manage Call 2
                {
                    // Store call
                    pbxCall2 = call;

                    tbCall2Id.Text              = call.Id;
                    tbCall2Status.Text          = call.CallStatus.ToString();
                    tbCall2LocalMedia.Text      = call.LocalMedia.ToString();
                    tbCall2RemoteMedia.Text     = call.RemoteMedia.ToString();
                    tbCall2DeviceType.Text      = call.DeviceType;
                    cbCall2IsConference.Checked = call.IsConference;

                    // List participants
                    if ((pbxCall2.Participants != null) && (pbxCall2.Participants.Count > 0))
                    {
                        String output = "";
                        int    nb     = 1;
                        foreach (CallParticipant participant in pbxCall2.Participants)
                        {
                            if (nb > 1)
                            {
                                output += "\r\n";
                            }
                            output += nb + ") " + participant.DisplayName + " - " + participant.PhoneNumber;
                            nb++;
                        }
                        tbCall2Participants.Text = output;
                    }

                    // Manage buttons
                    cbCall2Dtmf.Visible = (call.CallStatus == Call.Status.ACTIVE);

                    switch (call.CallStatus)
                    {
                    case Call.Status.UNKNOWN:
                        // The call is finished
                        btn1Call2.Text    = "Answer";
                        btn1Call2.Enabled = false;

                        btn2Call2.Text    = "To VM";
                        btn2Call2.Enabled = false;

                        btn3Call2.Text    = "Release";
                        btn3Call2.Enabled = false;

                        // No more manage this call
                        pbxCall2 = null;
                        break;

                    case Call.Status.RINGING_INCOMING:
                        btn1Call2.Text    = "Answer";
                        btn1Call2.Enabled = true;

                        btn2Call2.Text    = "To VM";
                        btn2Call2.Enabled = VMAvailable;

                        btn3Call2.Text    = "Release";
                        btn3Call2.Enabled = true;

                        break;

                    case Call.Status.ANSWERING:
                    case Call.Status.CONNECTING:
                    case Call.Status.DIALING:
                    case Call.Status.RINGING_OUTGOING:
                        btn1Call2.Text    = "Answer";
                        btn1Call2.Enabled = false;

                        btn2Call2.Text    = "To VM";
                        btn2Call2.Enabled = false;

                        btn3Call2.Text    = "Release";
                        btn3Call2.Enabled = true;

                        break;

                    case Call.Status.ACTIVE:
                        btn1Call2.Text    = "Hold";
                        btn1Call2.Enabled = true;

                        btn2Call2.Text    = "DTMF";
                        btn2Call2.Enabled = true;

                        btn3Call2.Text    = "Release";
                        btn3Call2.Enabled = true;

                        break;

                    case Call.Status.RELEASING:
                        btn1Call2.Text    = "Hold";
                        btn1Call2.Enabled = false;

                        btn2Call2.Text    = "DTMF";
                        btn2Call2.Enabled = false;

                        btn3Call2.Text    = "Release";
                        btn3Call2.Enabled = false;
                        break;

                    case Call.Status.QUEUED_INCOMING:
                    case Call.Status.QUEUED_OUTGOING:
                    case Call.Status.HOLD:
                        btn1Call2.Text    = "Hold";
                        btn1Call2.Enabled = false;

                        btn2Call2.Text    = "DTMF";
                        btn2Call2.Enabled = false;

                        btn3Call2.Text    = "Release";
                        btn3Call2.Enabled = true;
                        break;

                    case Call.Status.PUT_ON_HOLD:
                        btn1Call2.Text    = "Unhold";
                        btn1Call2.Enabled = true;

                        btn2Call2.Text    = "DTMF";
                        btn2Call2.Enabled = false;

                        btn3Call2.Text    = "Release";
                        btn3Call2.Enabled = false;
                        break;

                    case Call.Status.ERROR:
                        break;
                    }
                }

                // Can we perform another call ?
                //      - No call in progress
                //      - Only one call in progress and ACTIVE
                Boolean activeCall = false;
                int     nbCall     = 0;
                if (pbxCall1 != null)
                {
                    if (pbxCall1.CallStatus == Call.Status.ACTIVE)
                    {
                        activeCall = true;
                    }

                    if (pbxCall1.CallStatus != Call.Status.UNKNOWN)
                    {
                        nbCall++;
                    }
                }
                if (pbxCall2 != null)
                {
                    if (pbxCall2.CallStatus == Call.Status.ACTIVE)
                    {
                        activeCall = true;
                    }

                    if (pbxCall2.CallStatus != Call.Status.UNKNOWN)
                    {
                        nbCall++;
                    }
                }
                btMakeCall.Enabled = (activeCall && (nbCall == 1)) || (nbCall == 0);

                Boolean enableAdvanceAction = false;
                if ((pbxCall1 != null) &&
                    (pbxCall2 != null))
                {
                    enableAdvanceAction = ((pbxCall1.CallStatus == Call.Status.ACTIVE) && (pbxCall2.CallStatus == Call.Status.PUT_ON_HOLD)) ||
                                          ((pbxCall1.CallStatus == Call.Status.PUT_ON_HOLD) && (pbxCall2.CallStatus == Call.Status.ACTIVE));
                }
                btCallTransfer.Enabled = btCallConference.Enabled = enableAdvanceAction;

                // We cannot make another call if advanced actions are available
                if (enableAdvanceAction)
                {
                    btMakeCall.Enabled = false;
                }
            }
        }