示例#1
0
 private void simulate(object obj)
 {
     if (ValidateFields())
     {
         SimulatorAction simulatorAction            = new SimulatorAction(ClientId, selectedLine, SelectedType, destCall, numOfCalls, minDuration, maxDuration);
         Tuple <object, HttpStatusCode> returnTuple = httpClient.PostRequest(ApiConfigs.SimulateRoute, simulatorAction);
         logger.Print(returnTuple.Item1.ToString());
         lockIdBox = true;
     }
 }
示例#2
0
        public IHttpActionResult Simulate([FromBody] SimulatorAction simulatorAction)
        {
            bool b = simulatorManager.Simulate(simulatorAction);

            if (b)
            {
                if (simulatorAction.Type.Equals("Call"))
                {
                    return(Ok("Calls added succesfully"));
                }
                else
                {
                    return(Ok("SMS added succesfully."));
                }
            }
            return(Ok("failed to add calls"));
        }
示例#3
0
        public bool Simulate(SimulatorAction simulatorAction)
        {
            if (simulatorAction.Type.Equals("Call"))
            {
                for (int i = 0; i < simulatorAction.numOfCalls; i++)
                {
                    if (i % 5 == 0)
                    {
                        networkRepository.AddCallsToCenter(simulatorAction.ClientId);
                    }
                    double Duration = GetRandomNumber(simulatorAction.minDuration, simulatorAction.maxDuration);
                    Call   call     = new Call(simulatorAction.Line, Duration, 20.0, simulatorAction.destCall);
                    bool   success  = networkRepository.AddCall(call).Result;

                    if (!success)
                    {
                        return(success);
                    }
                }
            }
            else
            {
                for (int i = 0; i < simulatorAction.numOfCalls; i++)
                {
                    if (i % 5 == 0)
                    {
                        networkRepository.AddCallsToCenter(simulatorAction.ClientId);
                    }
                    double Duration = GetRandomNumber(simulatorAction.minDuration, simulatorAction.maxDuration);
                    SMS    Sms      = new SMS(simulatorAction.Line, 20.0, simulatorAction.destCall);
                    bool   success  = networkRepository.AddSms(Sms).Result;

                    if (!success)
                    {
                        return(success);
                    }
                }
            }
            return(true);
        }