Example #1
0
        protected void Wizard1_PreviousButtonClick(object sender, WizardNavigationEventArgs e)
        {
            if (e.CurrentStepIndex == (int)StepsEnum.Refine_Shipments &&
                e.NextStepIndex == (int)StepsEnum.Define_Criteria)
            {
                ////get all shipments that have been lock for routing  during this wizard and change their status back to Mapped
                ////therefore unlocking them
                //List<TDCShipment> shipmentsToRemove = null;
                //try
                //{
                //   shipmentsToRemove = RoutingController.GetShipmentsByRoutingHistoryId(RoutingHistoryId.Value, false);
                //}
                //catch (Exception ex)
                //{
                //    Console.WriteLine(ex);
                //}

                if (!RoutingController.RemoveItemsFromRouting(null, User.Identity.Name,
                                                              RoutingHistoryId.Value))
                {
                    DisplayMessage("There was a problem un-locking the Shipments.");
                    e.Cancel = true;
                }
            }
            else if (e.CurrentStepIndex == (int)StepsEnum.Merge_Delivery_Points &&
                     e.NextStepIndex == (int)StepsEnum.Refine_Shipments)
            {
                siteCodesToMerge.Clear();
                GridViewShipmentsToRefine.DataBind();
            }
        }
        /// <summary>
        /// Saves the drops.
        /// </summary>
        /// <returns></returns>
        private SubscriberStatusEnum SaveDrops()
        {
            ShipmentDrop firstDropInTrip = null;

            foreach (ShipmentDrop drop in drops)
            {
                if ((firstDropInTrip == null || firstDropInTrip.TripNumber != drop.TripNumber) && drop.CallType == ShipmentDrop.CallTypeEnum.Depot)
                {
                    //we need to retain the first drop in the trip because we can then use the original
                    //deport data when relating the drops to a trip.
                    //the original deport data can change about after the first drop!
                    firstDropInTrip = drop;
                }


                if (firstDropInTrip != null)
                {
                    DropController.SaveDrop(drop, firstDropInTrip.OriginalDepot);

                    if (RequestProcessor != null && !RequestProcessor.RequestDictionary.ContainsKey("RoutingHistory"))
                    {
                        RoutingHistory routingHistory = RoutingController.GetRoutingHistoryByShipmentId(drop.ShipmentId);
                        if (routingHistory != null)
                        {
                            RequestProcessor.RequestDictionary.Add("RoutingHistory", routingHistory);
                        }
                    }
                    drop.TripId = Null.NullInteger;
                    drop.Id     = Null.NullInteger;
                }
            }

            return(SubscriberStatusEnum.Processed);
        }
        protected void GridViewHistory_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Reset")
            {
                try
                {
                    if (RoutingController.ResetLock(Convert.ToInt32(e.CommandArgument), User.Identity.Name))
                    {
                        GridViewHistory.DataBind();
                    }
                    else
                    {
                        DisplayMessage("Failed to Reset Locks.", DiscoveryMessageType.Error);
                    }
                }
                catch (Exception e1)
                {
                    if (ExceptionPolicy.HandleException(e1, "User Interface"))
                    {
                        DisplayMessage("Failed to Reset Locks.");
                    }
                }
            }
            else if (e.CommandName == "Details")
            {
                RoutingHistoryId = Convert.ToInt32(e.CommandArgument);
                MultiViewHistory.ActiveViewIndex = 1;

                // Reset the page number
                TDCShipmentsUserControl.PageIndex = 0;

                // Search was clicked, refresh shipments
                TDCShipmentsUserControl.DataBind();
            }
        }
        /// <summary>
        /// Processes the request.
        /// </summary>
        /// <param name="requestMessage">The request message.</param>
        public override void ProcessRequest(RequestMessage requestMessage)
        {
            if (RequestProcessor.RequestDictionary.ContainsKey("RoutingHistory"))
            {
                RoutingHistory routingHistory;
                routingHistory = RequestProcessor.RequestDictionary["RoutingHistory"] as RoutingHistory;

                if (routingHistory != null)
                {
                    //get the routing history record
                    if (RequestProcessor.RequestMessage.Name.Equals(ConfigurationManager.AppSettings["OptrakDropsFileName"].ToString(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        routingHistory.DropFileReceivedDate = DateTime.Now;
                    }
                    else if (RequestProcessor.RequestMessage.Name.Equals(ConfigurationManager.AppSettings["OptrakTripPartFileName"].ToString(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        routingHistory.TripPartFileReceivedDate = DateTime.Now;
                    }


                    //save the time we recieved the current file we're processing
                    int routingHistoryId = RoutingController.SaveRoutingHistory(routingHistory);
                    if (routingHistoryId != -1)
                    {
                        //if we saved sucessfully then see if we have all three files
                        if (routingHistory.Status == RoutingHistory.StatusEnum.Recieved)
                        {
                            // if we have all three files then update the status of shipments related to the routing history id

                            if (!RoutingController.SetShipmentsToRouted(routingHistoryId, GetType().FullName))
                            {
                                throw new Exception(
                                          string.Format(
                                              "Failed to update the status of all shipments related to the routing history id '{0}'",
                                              routingHistoryId));
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(
                                  string.Format(
                                      "Failed to update the file recieved time of routing history  record with the id of '{0}'",
                                      routingHistoryId));
                    }
                }

                Status = SubscriberStatusEnum.Processed;
            }
            else if (RequestProcessor.RequestMessage.Name ==
                     ConfigurationManager.AppSettings["OptrakDropsFileName"].ToString() || RequestProcessor.RequestMessage.Name ==
                     ConfigurationManager.AppSettings["OptrakTripPartFileName"].ToString())
            {
                LastError =
                    new Exception(
                        "The Optrak file subscriber tried to set the shipment statuses to Routed but failed as it was unable to find a related Routing History record.");
                //we should have a RoutingHistory object in the cache so fail
                Status = SubscriberStatusEnum.Failed;
            }
        }
        public void GenerateUsefulRouteResponse_MultipleRoutes_AllRoutesConvertedCorrectly()
        {
            // Arrange
            RouteResponse OldRouteFormat = new RouteResponse {
                Routes = new List <Route> {
                    GetRoute1(), GetRoute2()
                }
            };

            // Act
            List <UsefulRouteResponse> actualResult = RoutingController.GenerateUsefulRouteResponse(OldRouteFormat);

            // Assert
            Assert.Equal(2, actualResult.Count);

            for (int focusedResponseIndex = 0; focusedResponseIndex < Route1And2ExpectedOutcome.Count; focusedResponseIndex++)
            {
                Assert.Equal(Route1And2ExpectedOutcome[focusedResponseIndex].TravelTimeInSeconds, actualResult[focusedResponseIndex].TravelTimeInSeconds);
                Assert.Equal(Route1And2ExpectedOutcome[focusedResponseIndex].Distance, actualResult[focusedResponseIndex].Distance);

                for (int focusedPointIndex = 0; focusedPointIndex < actualResult[0].Points.Count; focusedPointIndex++)
                {
                    Assert.Equal(Route1And2ExpectedOutcome[focusedResponseIndex].Points[focusedPointIndex].Latitude, actualResult[focusedResponseIndex].Points[focusedPointIndex].Latitude);
                    Assert.Equal(Route1And2ExpectedOutcome[focusedResponseIndex].Points[focusedPointIndex].Longitude, actualResult[focusedResponseIndex].Points[focusedPointIndex].Longitude);
                }
            }
        }
Example #6
0
        private bool RemoveItemsFromRouting(List <TDCShipment> shipmentsToRemoveFromRouting)
        {
            bool success = false;

            try
            {
                success = RoutingController.RemoveItemsFromRouting(shipmentsToRemoveFromRouting, User.Identity.Name,
                                                                   RoutingHistoryId.Value);
            }
            catch (Exception e)
            {
                if (ExceptionPolicy.HandleException(e, "User Interface"))
                {
                    DisplayMessage("There was a problem removing the selected Shipments.");
                }
            }
            if (!success)
            {
                DisplayMessage("There was a problem removing the selected Shipments.");
            }
            else
            {
                ShipmentIdsToRemoveFromRouting.Clear();
            }
            return(success);
        }
Example #7
0
 // Use this for initialization
 void Start()
 {
     oldTravelers      = new Queue <GameObject>();
     routingController = GetComponentInParent <RoutingController>();
     spawners          = GameObject.Find("Spawners");
     travelers         = GameObject.Find("Travelers");
     InitTravelerSpawn();
     startTime = Time.time;
 }
        public void ShouldNotParseIfNothingAvailable()
        {
            var moqYamlSourceController = new Mock <IYamlSourceController>();

            moqYamlSourceController.Setup(m => m.GetYaml(YamlType.Routing, null)).Returns(null as string);
            var sut = new RoutingController(moqYamlSourceController.Object);

            Assert.Null(sut.RoutingConfiguration);
        }
Example #9
0
 // Use this for initialization
 public virtual void Start()
 {
     mainRouter = GameObject.FindObjectOfType <RoutingController>();
     if (mainRouter == null)
     {
         Debug.LogError("No routingController found!");
     }
     vehicles = new HashSet <GameObject>();
     lineMesh = GetComponent <LineRenderer>();
 }
        public void Process()
        {
            Request           request           = new Request();
            RequestDTO        requestDto        = request.Parse(request.ReadRequest(_clientStream));
            RoutingController routingController = new RoutingController(
                new ResponseSender(_clientStream, kernel.Get <IResponseBuilder>()),
                new ResponseHandler(kernel.Get <IStatusCodeResponse>(), kernel.Get <IFileResponseBuilder>(), kernel.Get <IUserController>()));

            routingController.TransferResponse(requestDto);
        }
Example #11
0
        public ListenerHandler(TcpClient client, RoutingController rc, ConnectionController cc, ref Dictionary <String, BinaryWriter> socketHandler)
        {
            this.client        = client;
            this.rc            = rc;
            this.cc            = cc;
            this.socketHandler = socketHandler;

            thread = new Thread(new ParameterizedThreadStart(handleThread));
            thread.Start(client);
        }
    /// <summary>
    /// Awake method.
    /// </summary>
    void Awake()
    {
        globalParam       = FindObjectOfType <FlashPedestriansGlobalParameters>();
        routingController = FindObjectOfType <RoutingController>();
        activePedestrians = new Dictionary <int, FlashPedestriansController>();
        secondsPerMeter   = 1 / globalParam.averageSpeed;

        logSeriesId = LoggerAssembly.GetLogSeriesId();

        bikeStations = new Dictionary <int, BikeStationScript>();
    }
Example #13
0
 /// <summary>
 /// Initializes the fields when the script starts.
 /// </summary>
 void Start()
 {
     if (simulationIntegrated)
     {
         trafficData          = (TrafficIntegrationData)this.GetComponent("TrafficIntegrationData");
         vehControllers       = new Dictionary <string, TrafficIntegrationVehicle>();
         timeStepIndex        = 0;
         lastTimeStepExecuted = -1;
         cameraFrustum        = Camera.main.GetComponent <CameraFrustumScript>();
         routingContr         = FindObjectOfType <RoutingController>();
     }
 }
Example #14
0
 /// <summary>
 /// Initializes the fields when the script starts.
 /// </summary>
 void Start()
 {
     if (conf.integrateSumo)
     {
         mc                = FindObjectOfType <SumoMainController>();
         tdb               = (SumoTrafficDB)this.GetComponent("SumoTrafficDB");
         vehControllers    = new Dictionary <string, SumoVehicleController>();
         timeStepIndex     = 0;
         cameraFrustum     = Camera.main.GetComponent <CameraFrustumScript>();
         routingController = FindObjectOfType <RoutingController>();
     }
 }
Example #15
0
        public Domain()
        {
            RC  = new RoutingController();
            CC  = new ConnectionController();
            NCC = new NetworkCallController("directory1.txt", "policy.txt");
            IPAddress myhost = IPAddress.Parse("127.0.0.1");

            domainServer = new Socket(myhost.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            domainClient = new Socket(myhost.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            socketToSub  = new Socket(myhost.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
        }
Example #16
0
 protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
 {
     try
     {
         RoutingController.GenerateOptrakFiles(RoutingHistoryId.Value, ListBoxRegions.SelectedValue);
     }
     catch (Exception ex)
     {
         if (ExceptionPolicy.HandleException(ex, "User Interface"))
         {
             DisplayMessage("Could not generate Optrak files.", DiscoveryMessageType.Error);
         }
     }
 }
Example #17
0
 protected void GridViewDeliveryPointDetail_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "UnMerge")
     {
         RoutingController.UnMerge(Convert.ToInt32(e.CommandArgument), RoutingHistoryId.Value);
         //rebind the grid if there's more than 1 in the group before unmerging.
         //If there was only 1 the reshuffeling that occurs in the Unmerge method will mean we will see the new and wrong group of data in the grid
         if (GridViewDeliveryPointDetail.Rows.Count > 1)
         {
             GridViewDeliveryPointDetail_Bind(ViewState["CurrentSiteCode"] as string);
         }
         else
         {
             ReturnToSummaryView();
         }
     }
 }
Example #18
0
 /// <summary>
 /// Calling base start to make sure that the vehicles-list is initiated.
 /// Initiate vehiclesOut
 /// </summary>
 public void Start()
 {
     timeController = GameObject.FindObjectOfType <TimeController>();
     mainRouter     = GameObject.FindObjectOfType <RoutingController>();
     if (mainRouter == null)
     {
         Debug.LogError("No routingController found!");
     }
     transline = GetComponent <LineController>();
     if (transline == null)
     {
         Debug.LogError("No lineController attached to this gameobject: " + gameObject.name);
     }
     vehiclesOutOfService = new HashSet <GameObject>();
     if (spawnFromStart)
     {
         startTime = (useGlobalSpawnRate) ? -globalSpawnRate + spawnFromStartDelay : -localSpawnRate + spawnFromStartDelay;
     }
     //SpawnAndResetTimer();
 }
Example #19
0
        protected void ButtonMerge_Click(object sender, EventArgs e)
        {
            if (MultiView1.ActiveViewIndex == 0) //summary view
            {
                if (siteCodesToMerge.Count > 1)
                {
                    //merge the selected delivery points
                    int mainSiteCode = siteCodesToMerge[0];
                    siteCodesToMerge.RemoveAt(0);

                    int returnValue = RoutingController.MergeDeliveryPointsManually(RoutingHistoryId.Value, mainSiteCode, siteCodesToMerge);

                    switch (returnValue)
                    {
                    case 0:
                        siteCodesToMerge.Clear();
                        GridViewMergedPoints.DataBind();
                        break;

                    case -1:
                        DisplayMessage("Items from different delivery warehouse cannot be selected from merging.");
                        break;

                    case -2:
                    case -3:
                        DisplayMessage("Failed to Merge Items.");
                        break;
                    }
                }
                else
                {
                    DisplayMessage("You must select 2 or more items to merge.");
                }
            }
            else //detail view
            {
                ReturnToSummaryView();
            }
        }
        public void ShouldParse()
        {
            var moqYamlSourceController = new Mock <IYamlSourceController>();

            moqYamlSourceController.Setup(m => m.GetYaml(YamlType.Routing, null)).Returns(@"# Zorgtoeslag routing for burger site demo
stuurinformatie:
  onderwerp: zorgtoeslag
  organisatie: belastingdienst
  type: toeslagen
  domein: zorg
  versie: 5.0
  status: ontwikkel
  jaar: 2019
parameters:
 - waarde: woonland
   locatie: woonlandfactorUrl");
            var sut = new RoutingController(moqYamlSourceController.Object);

            Assert.Single(sut.RoutingConfiguration.Parameters);
            Assert.Equal("woonland", sut.RoutingConfiguration.Parameters.ElementAt(0).Name);
            Assert.Equal("woonlandfactorUrl", sut.RoutingConfiguration.Parameters.ElementAt(0).Location);
        }
        /// <summary>
        /// Saves the dropLines.
        /// </summary>
        /// <returns></returns>
        private SubscriberStatusEnum SaveDropLines()
        {
            foreach (ShipmentDropLine dropLine in dropLines)
            {
                if (DropController.SaveDropLine(dropLine) == -1)
                {
                    throw new Exception("A Drop line did not save successfully.");
                }

                if (RequestProcessor != null && !RequestProcessor.RequestDictionary.ContainsKey("RoutingHistory"))
                {
                    RoutingHistory routingHistory = RoutingController.GetRoutingHistoryByShipmentLineId(dropLine.ShipmentLineId);
                    if (routingHistory != null)
                    {
                        RequestProcessor.RequestDictionary.Add("RoutingHistory", routingHistory);
                    }
                }

                dropLine.ShipmentLineId = -1;
                dropLine.DropId         = -1;
            }

            return(SubscriberStatusEnum.Processed);
        }
        protected void dataSourceShipments_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            // Assign our shipment criteria, query has not ran yet
            e.InputParameters["routingHistoryId"] = RoutingHistoryId.Value;

            // Page number and max rows
            e.Arguments.MaximumRows   = TDCShipmentsUserControl.PageSize;
            e.Arguments.StartRowIndex = TDCShipmentsUserControl.PageIndex;

            // Get the total number of rows
            try
            {
                TDCShipmentsUserControl.TotalRows = RoutingController.GetShipmentsByRoutingHistoryIdCount(RoutingHistoryId.Value, false);
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "User Interface"))
                {
                    DisplayMessage(ex);
                }
            }
            // Sorting
            e.Arguments.SortExpression = string.Concat(TDCShipmentsUserControl.SortExpression, " ", TDCShipmentsUserControl.SortDirection.ToString());
        }
Example #23
0
 public static Area Create(OspfModule module, RoutingController controller, uint number)
 {
     return new Area
            {
                Module = module,
                _controller = controller,
                Number = number
            };
 }
Example #24
0
 public static Neighbor Create(OspfModule module, RoutingController controller, Interface ospfInterface, IPAddress source, IPAddress rid, OspfOptions options, byte priority, IPAddress dr, IPAddress bdr)
 {
     var n = new Neighbor
            {
                _controller = controller,
                Module = module,
                Interface = ospfInterface,
                RouterID = rid,
                DiscoveredOptions = options,
                //TODO: is THIS the source??
                Address = source,
                Priority = priority,
                OspfNeighborState = OspfNeighborState.Down,
                DR = dr,
                BDR = bdr,
                LastSeen = DateTime.Now
            };
     n.Init();
     return n;
 }
 public void setRCHandler(RoutingController rc)
 {
     this.rcHandler = rc;
 }
        public void TestLRM()
        {
            var subnetwork1Address = new NetworkAddress("1");

            var client1Address = new NetworkAddress("1.1.1");
            var client2Address = new NetworkAddress("1.2.1");

            var node1Address = new NetworkAddress("1.1");
            var node2Address = new NetworkAddress("1.2");

            var node1Client1SnppOut = new SubnetworkPointPool(client1Address.Append(1));
            var node1Client1SnppIn  = new SubnetworkPointPool(node1Address.Append(1));
            var node1Node2SnppOut   = new SubnetworkPointPool(node2Address.Append(2));
            var node1Node2SnppIn    = new SubnetworkPointPool(node1Address.Append(2));
            var node2Client2SnppOut = new SubnetworkPointPool(client2Address.Append(1));
            var node2Client2SnppIn  = new SubnetworkPointPool(node2Address.Append(1));

            var client1Node1Link = new Link(node1Client1SnppIn, node1Client1SnppOut, 10, true);
            var node1Node2Link   = new Link(node1Node2SnppIn, node1Node2SnppOut, 10, false);
            var client2Node2Link = new Link(node2Client2SnppIn, node2Client2SnppOut, 10, true);

            var rcAddress = subnetwork1Address;
            var rc        = new RoutingController(rcAddress);

            _controlPlaneElements.Add(new Row(rcAddress, ControlPlaneElementType.RC), rc);

            var ccAddress = subnetwork1Address;
            var cc        = new ConnectionController(ccAddress);

            _controlPlaneElements.Add(new Row(ccAddress, ControlPlaneElementType.CC), cc);

            var cc1Address = node1Address;
            var cc1        = new ConnectionController(cc1Address);

            _controlPlaneElements.Add(new Row(cc1Address, ControlPlaneElementType.CC), cc1);

            var cc2Address = node2Address;
            var cc2        = new ConnectionController(cc2Address);

            _controlPlaneElements.Add(new Row(cc2Address, ControlPlaneElementType.CC), cc2);

            var lrm1Address = node1Address;
            var lrm1        = new LinkResourceManager(lrm1Address);

            _controlPlaneElements.Add(new Row(lrm1Address, ControlPlaneElementType.LRM), lrm1);

            var lrm2Address = node2Address;
            var lrm2        = new LinkResourceManager(lrm2Address);

            _controlPlaneElements.Add(new Row(lrm2Address, ControlPlaneElementType.LRM), lrm2);


            rc.MessageToSend   += PassMessage;
            cc.MessageToSend   += PassMessage;
            cc1.MessageToSend  += PassMessage;
            cc2.MessageToSend  += PassMessage;
            lrm1.MessageToSend += PassMessage;
            lrm2.MessageToSend += PassMessage;

            rc.UpdateState   += UpdateState;
            cc.UpdateState   += UpdateState;
            cc1.UpdateState  += UpdateState;
            cc2.UpdateState  += UpdateState;
            lrm1.UpdateState += UpdateState;
            lrm2.UpdateState += UpdateState;

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client1Node1Link,
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client1Node1Link.Reverse(),
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link,
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link.Reverse(),
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link,
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link.Reverse(),
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client2Node2Link,
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client2Node2Link.Reverse(),
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            cc.ReceiveMessage(new SignallingMessage {
                DemandedCapacity               = 5,
                DestinationAddress             = ccAddress,
                DestinationControlPlaneElement = ControlPlaneElementType.CC,
                DestinationClientAddress       = client2Address,
                Operation = OperationType.ConnectionRequest,
                Payload   = new[] {
                    node1Client1SnppIn,
                    node1Node2SnppOut
                },
                SourceAddress             = subnetwork1Address,
                SourceClientAddress       = client1Address,
                SourceControlPlaneElement = ControlPlaneElementType.CC
            });
        }
Example #27
0
 /// <summary>
 /// Binds the GridViewDeliveryPointDetail grid with data for the chosen site code, it shows a break down
 /// </summary>
 /// <param name="locationCode">The location code.</param>
 private void GridViewDeliveryPointDetail_Bind(string locationCode)
 {
     GridViewDeliveryPointDetail.DataSource =
         RoutingController.GetShipmentsForDeliveryPoint(locationCode, RoutingHistoryId.Value, false);
     GridViewDeliveryPointDetail.DataBind();
 }
Example #28
0
        /**
         * DOMAIN:
         *      LISTENER_RCandCC_for_LRM_AND_RC_AND_CC[0],
         *      DOMAIN_ID[1],
         *          NCC_PORT[2],
         *      DOMAIN_FLAG[3]
         * SUBNETWORK:
         *      LISTENER_RCandCC_for_LRM_AND_RC_AND_CC[0],
         *      SUBNETWORK_ID[1],
         *      UPPER_RCandCC_PORT[2],
         */
        static void Main(string[] args)
        {
            Dictionary <String, BinaryWriter> socketHandler = new Dictionary <string, BinaryWriter>();

            string rcId = "RC_" + args[1];
            string ccId = "CC_" + args[1];

            string[] rcArgs = new string[] { };
            if (args.Length == 4)
            {
                rcArgs        = new string[] { rcId }; // DOMAIN [RC_ID]
                Console.Title = "DN" + args[1] + " Control RC_CC";
            }
            else if (args.Length == 3)
            {
                rcArgs        = new string[] { rcId, args[2] }; // SUBNETWORK [RC_ID, connect up RC]
                Console.Title = "SN" + args[1] + " Control RC_CC";
            }
            else
            {
                errorWriter("[ERROR] Wrong aguments.");
            }

            string[] ccArgs = new string[] { };
            if (args.Length == 4)
            {
                ccArgs = new string[] { ccId, args[2] }
            }
            ;                                           // DOMAIN [CC_ID, connect NCC]
            else if (args.Length == 3)
            {
                ccArgs = new string[] { ccId, args[2], args[2] }
            }
            ;                                                    // SUBNETWORK [CC_ID, connect up CC, flag]
            else
            {
                errorWriter("[ERROR] Wrong aguments.");
            }

            RoutingController    rc = new RoutingController(rcArgs);
            ConnectionController cc = new ConnectionController(ccArgs);

            rc.setCCHandler(cc);
            cc.setRCHandler(rc);
            rc.setSocketHandler(socketHandler);
            cc.setSocketHandler(socketHandler);

            // LISTENER[0]
            int listenerPort;

            int.TryParse(args[0], out listenerPort);
            TcpListener listener = new TcpListener(IPAddress.Parse("127.0.0.1"), listenerPort);

            listener.Start();

            Boolean noError = true;

            while (noError)
            {
                try
                {
                    TcpClient       client = listener.AcceptTcpClient();
                    ListenerHandler thread = new ListenerHandler(client, rc, cc, ref socketHandler);
                }
                catch (SocketException ex)
                {
                    Program.errorWriter("[ERROR] Socket failed. Listener.");
                    noError = false;
                }
            }
        }
Example #29
0
 public void TestInitialize()
 {
     _graphHopperGateway   = Substitute.For <IGraphHopperGateway>();
     _elevationDataStorage = Substitute.For <IElevationDataStorage>();
     _controller           = new RoutingController(_graphHopperGateway, _elevationDataStorage, new ItmWgs84MathTransfromFactory(), new GeometryFactory());
 }
Example #30
0
#pragma warning disable IDE1006 // Naming Styles
        static async Task Main(string[] args)
#pragma warning restore IDE1006 // Naming Styles
        {
            #region Delegates.GetDirectory

            var getEmptyDirectoryDelegate = new GetRelativeDirectoryDelegate(string.Empty);

            var getTemplatesDirectoryDelegate = new GetRelativeDirectoryDelegate(Directories.Base[Entity.Templates]);

            var getDataDirectoryDelegate = new GetRelativeDirectoryDelegate(Directories.Base[Entity.Data], getEmptyDirectoryDelegate);

            var getRecycleBinDirectoryDelegate           = new GetRelativeDirectoryDelegate(Directories.Base[Entity.RecycleBin], getDataDirectoryDelegate);
            var getProductImagesDirectoryDelegate        = new GetRelativeDirectoryDelegate(Directories.Base[Entity.ProductImages], getDataDirectoryDelegate);
            var getAccountProductImagesDirectoryDelegate = new GetRelativeDirectoryDelegate(Directories.Base[Entity.AccountProductImages], getDataDirectoryDelegate);
            var getReportDirectoryDelegate           = new GetRelativeDirectoryDelegate(Directories.Base[Entity.Reports], getDataDirectoryDelegate);
            var getValidationDirectoryDelegate       = new GetRelativeDirectoryDelegate(Directories.Base[Entity.Md5], getDataDirectoryDelegate);
            var getProductFilesBaseDirectoryDelegate = new GetRelativeDirectoryDelegate(Directories.Base[Entity.ProductFiles], getDataDirectoryDelegate);
            var getScreenshotsDirectoryDelegate      = new GetRelativeDirectoryDelegate(Directories.Base[Entity.Screenshots], getDataDirectoryDelegate);

            var getProductFilesDirectoryDelegate = new GetUriDirectoryDelegate(getProductFilesBaseDirectoryDelegate);

            #endregion

            #region Delegates.GetFilename

            var getJsonFilenameDelegate = new GetJsonFilenameDelegate();
            var getBinFilenameDelegate  = new GetBinFilenameDelegate();

            var getStoredHashesFilenameDelegate = new GetFixedFilenameDelegate("hashes", getBinFilenameDelegate);

            var getAppTemplateFilenameDelegate    = new GetFixedFilenameDelegate("app", getJsonFilenameDelegate);
            var gerReportTemplateFilenameDelegate = new GetFixedFilenameDelegate("report", getJsonFilenameDelegate);
            var getCookiesFilenameDelegate        = new GetFixedFilenameDelegate("cookies", getJsonFilenameDelegate);
            var getSettingsFilenameDelegate       = new GetFixedFilenameDelegate("settings", getJsonFilenameDelegate);

            var getIndexFilenameDelegate = new GetFixedFilenameDelegate(Filenames.Base[Entity.Index], getJsonFilenameDelegate);

            var getWishlistedFilenameDelegate = new GetFixedFilenameDelegate("wishlisted", getJsonFilenameDelegate);
            var getUpdatedFilenameDelegate    = new GetFixedFilenameDelegate("updated", getJsonFilenameDelegate);

            var getUriFilenameDelegate        = new GetUriFilenameDelegate();
            var getReportFilenameDelegate     = new GetReportFilenameDelegate();
            var getValidationFilenameDelegate = new GetValidationFilenameDelegate();

            #endregion

            #region Delegates.GetPath

            var getStoredHashesPathDelegate = new GetPathDelegate(
                getEmptyDirectoryDelegate,
                getStoredHashesFilenameDelegate);

            var getAppTemplatePathDelegate = new GetPathDelegate(
                getTemplatesDirectoryDelegate,
                getAppTemplateFilenameDelegate);

            var getReportTemplatePathDelegate = new GetPathDelegate(
                getTemplatesDirectoryDelegate,
                gerReportTemplateFilenameDelegate);

            var getCookiePathDelegate = new GetPathDelegate(
                getEmptyDirectoryDelegate,
                getCookiesFilenameDelegate);

            var getSettingsPathDelegate = new GetPathDelegate(
                getEmptyDirectoryDelegate,
                getSettingsFilenameDelegate);

            var getGameDetailsFilesPathDelegate = new GetPathDelegate(
                getProductFilesDirectoryDelegate,
                getUriFilenameDelegate);

            var getValidationPathDelegate = new GetPathDelegate(
                getValidationDirectoryDelegate,
                getValidationFilenameDelegate);

            #endregion

            var statusController = new StatusController();

            var ioOperations    = new List <string>();
            var ioTraceDelegate = new IOTraceDelegate(ioOperations);

            var streamController    = new StreamController();
            var fileController      = new FileController();
            var directoryController = new DirectoryController();

            var storageController = new StorageController(
                streamController,
                fileController,
                ioTraceDelegate);

            var serializationController = new JSONStringController();

            var convertBytesToStringDelegate  = new ConvertBytesToStringDelegate();
            var getBytesMd5HashAsyncDelegate  = new GetBytesMd5HashAsyncDelegate(convertBytesToStringDelegate);
            var convertStringToBytesDelegate  = new ConvertStringToBytesDelegate();
            var getStringMd5HashAsyncDelegate = new GetStringMd5HashAsyncDelegate(
                convertStringToBytesDelegate,
                getBytesMd5HashAsyncDelegate);

            var protoBufSerializedStorageController = new ProtoBufSerializedStorageController(
                fileController,
                streamController,
                statusController,
                ioTraceDelegate);

            #region Controllers.Stash

            var storedHashesStashController = new StashController <Dictionary <string, string> >(
                getStoredHashesPathDelegate,
                protoBufSerializedStorageController,
                statusController);

            #endregion

            var precomputedHashController = new StoredHashController(storedHashesStashController);

            var serializedStorageController = new SerializedStorageController(
                precomputedHashController,
                storageController,
                getStringMd5HashAsyncDelegate,
                serializationController,
                statusController);

            #region User editable files stashControllers

            // Settings.json

            var settingsStashController = new StashController <Settings>(
                getSettingsPathDelegate,
                serializedStorageController,
                statusController);

            // templates/app.json

            var appTemplateStashController = new StashController <List <Template> >(
                getAppTemplatePathDelegate,
                serializedStorageController,
                statusController);

            // templates/report.json

            var reportTemplateStashController = new StashController <List <Template> >(
                getReportTemplatePathDelegate,
                serializedStorageController,
                statusController);

            // cookies.json - this is required to be editable to allow user paste browser cookies

            var cookieStashController = new StashController <Dictionary <string, string> >(
                getCookiePathDelegate,
                serializedStorageController,
                statusController);

            #endregion

            var consoleController = new ConsoleController();
            var formatTextToFitConsoleWindowDelegate = new FormatTextToFitConsoleWindowDelegate(consoleController);

            var consoleInputOutputController = new ConsoleInputOutputController(
                formatTextToFitConsoleWindowDelegate,
                consoleController);

            var formatBytesDelegate   = new FormatBytesDelegate();
            var formatSecondsDelegate = new FormatSecondsDelegate();

            var collectionController = new CollectionController();

            var itemizeStatusChildrenDelegate = new ItemizeStatusChildrenDelegate();

            var statusTreeToEnumerableController = new ConvertTreeToEnumerableDelegate <IStatus>(itemizeStatusChildrenDelegate);

            var applicationStatus = new Status {
                Title = "This ghost is a kind one."
            };

            var appTemplateController = new TemplateController(
                "status",
                appTemplateStashController,
                collectionController);


            var reportTemplateController = new TemplateController(
                "status",
                reportTemplateStashController,
                collectionController);

            var formatRemainingTimeAtSpeedDelegate = new FormatRemainingTimeAtSpeedDelegate();

            var statusAppViewModelDelegate = new StatusAppViewModelDelegate(
                formatRemainingTimeAtSpeedDelegate,
                formatBytesDelegate,
                formatSecondsDelegate);

            var statusReportViewModelDelegate = new StatusReportViewModelDelegate(
                formatBytesDelegate,
                formatSecondsDelegate);

            var getStatusViewUpdateDelegate = new GetStatusViewUpdateDelegate(
                applicationStatus,
                appTemplateController,
                statusAppViewModelDelegate,
                statusTreeToEnumerableController);

            var consoleNotifyStatusViewUpdateController = new NotifyStatusViewUpdateController(
                getStatusViewUpdateDelegate,
                consoleInputOutputController);

            // TODO: Implement a better way
            // add notification handler to drive console view updates
            statusController.NotifyStatusChangedAsync += consoleNotifyStatusViewUpdateController.NotifyViewUpdateOutputOnRefreshAsync;

            var constrainExecutionAsyncDelegate = new ConstrainExecutionAsyncDelegate(
                statusController,
                formatSecondsDelegate);

            var constrainRequestRateAsyncDelegate = new ConstrainRequestRateAsyncDelegate(
                constrainExecutionAsyncDelegate,
                collectionController,
                statusController,
                new string[] {
                Models.Uris.Uris.Paths.Account.GameDetails,             // gameDetails requests
                Models.Uris.Uris.Paths.ProductFiles.ManualUrlDownlink,  // manualUrls from gameDetails requests
                Models.Uris.Uris.Paths.ProductFiles.ManualUrlCDNSecure, // resolved manualUrls and validation files requests
                Models.Uris.Uris.Roots.Api                              // API entries
            });

            var uriController = new UriController();

            var cookieSerializationController = new CookieSerializationController();

            var cookiesController = new CookiesController(
                cookieStashController,
                cookieSerializationController,
                statusController);

            var networkController = new NetworkController(
                cookiesController,
                uriController,
                constrainRequestRateAsyncDelegate);

            var downloadFromResponseAsyncDelegate = new DownloadFromResponseAsyncDelegate(
                networkController,
                streamController,
                fileController,
                statusController);

            var downloadFromUriAsyncDelegate = new DownloadFromUriAsyncDelegate(
                networkController,
                downloadFromResponseAsyncDelegate,
                statusController);

            var requestPageAsyncDelegate = new RequestPageAsyncDelegate(
                networkController);

            var languageController = new LanguageController();

            var itemizeLoginIdDelegate = new ItemizeAttributeValuesDelegate(
                AttributeValuesPatterns.LoginId);
            var itemizeLoginUsernameDelegate = new ItemizeAttributeValuesDelegate(
                AttributeValuesPatterns.LoginUsername);
            var itemizeLoginTokenDelegate = new ItemizeAttributeValuesDelegate(
                AttributeValuesPatterns.LoginToken);
            var itemizeSecondStepAuthenticationTokenDelegate = new ItemizeAttributeValuesDelegate(
                AttributeValuesPatterns.SecondStepAuthenticationToken);

            var itemizeGOGDataDelegate     = new ItemizeGOGDataDelegate();
            var itemizeScreenshotsDelegate = new ItemizeScreenshotsDelegate();

            var formatImagesUriDelegate      = new FormatImagesUriDelegate();
            var formatScreenshotsUriDelegate = new FormatScreenshotsUriDelegate();

            var recycleDelegate = new RecycleDelegate(
                getRecycleBinDirectoryDelegate,
                fileController,
                directoryController);

            #region Correct settings

            var correctSettingsCollectionsAsyncDelegate               = new CorrectSettingsCollectionsAsyncDelegate(statusController);
            var correctSettingsDownloadsLanguagesAsyncDelegate        = new CorrectSettingsDownloadsLanguagesAsyncDelegate(languageController);
            var correctSettingsDownloadsOperatingSystemsAsyncDelegate = new CorrectSettingsDownloadsOperatingSystemsAsyncDelegate();
            var correctSettingsDirectoriesAsyncDelegate               = new CorrectSettingsDirectoriesAsyncDelegate();

            var correctSettingsActivity = new CorrectSettingsActivity(
                settingsStashController,
                statusController,
                correctSettingsCollectionsAsyncDelegate,
                correctSettingsDownloadsLanguagesAsyncDelegate,
                correctSettingsDownloadsOperatingSystemsAsyncDelegate,
                correctSettingsDirectoriesAsyncDelegate);

            #endregion

            #region Data Controllers

            var dataControllerFactory = new DataControllerFactory(
                protoBufSerializedStorageController,
                precomputedHashController,
                getDataDirectoryDelegate,
                getBinFilenameDelegate,
                statusController);

            // TODO: Remove the stub
            Interfaces.Controllers.Index.IIndexController <long> wishlistedIndexController = null;
            //  dataControllerFactory.CreateIndexController(
            //     Entity.Wishlist,
            //     getWishlistedFilenameDelegate);

            // TODO: Remove the stub
            Interfaces.Controllers.Index.IIndexController <long> updatedIndexController = null;
            // dataControllerFactory.CreateIndexController(
            //     Entity.Updated,
            //     getUpdatedFilenameDelegate);

            var activityRecordsController = dataControllerFactory.CreateStringRecordsController(Entity.Activity);

            var productsDataController           = dataControllerFactory.CreateDataControllerEx <Product>(Entity.Products);
            var accountProductsDataController    = dataControllerFactory.CreateDataControllerEx <AccountProduct>(Entity.AccountProducts);
            var gameDetailsDataController        = dataControllerFactory.CreateDataControllerEx <GameDetails>(Entity.GameDetails);
            var gameProductDataDataController    = dataControllerFactory.CreateDataControllerEx <GameProductData>(Entity.GameProductData);
            var apiProductsDataController        = dataControllerFactory.CreateDataControllerEx <ApiProduct>(Entity.ApiProducts);
            var productScreenshotsDataController = dataControllerFactory.CreateDataControllerEx <ProductScreenshots>(Entity.ProductScreenshots);
            var productDownloadsDataController   = dataControllerFactory.CreateDataControllerEx <ProductDownloads>(Entity.ProductDownloads);
            var productRoutesDataController      = dataControllerFactory.CreateDataControllerEx <ProductRoutes>(Entity.ProductRoutes);
            var validationResultsDataController  = dataControllerFactory.CreateDataControllerEx <ValidationResult>(Entity.ValidationResults);

            #endregion

            var aliasController         = new AliasController(ActivityContext.Aliases);
            var whitelistController     = new WhitelistController(ActivityContext.Whitelist);
            var prerequisitesController = new PrerequisiteController(ActivityContext.Prerequisites);
            var supplementaryController = new SupplementaryController(ActivityContext.Supplementary);

            var activityContextController = new ActivityContextController(
                aliasController,
                whitelistController,
                prerequisitesController,
                supplementaryController);

            #region Activity Controllers

            #region Authorize

            var correctUsernamePasswordAsyncDelegate = new CorrectUsernamePasswordAsyncDelegate(
                consoleInputOutputController);
            var correctSecurityCodeAsyncDelegate = new CorrectSecurityCodeAsyncDelegate(
                consoleInputOutputController);

            var attributeValuesItemizeDelegates = new Dictionary <string, IItemizeDelegate <string, string> >
            {
                { QueryParameters.LoginId,
                  itemizeLoginIdDelegate },
                { QueryParameters.LoginUsername,
                  itemizeLoginUsernameDelegate },
                { QueryParameters.LoginToken,
                  itemizeLoginTokenDelegate },
                { QueryParameters.SecondStepAuthenticationToken,
                  itemizeSecondStepAuthenticationTokenDelegate }
            };

            var authorizationController = new AuthorizationController(
                correctUsernamePasswordAsyncDelegate,
                correctSecurityCodeAsyncDelegate,
                uriController,
                networkController,
                serializationController,
                attributeValuesItemizeDelegates,
                statusController);

            var authorizeActivity = new AuthorizeActivity(
                settingsStashController,
                authorizationController,
                statusController);

            #endregion

            #region Update.PageResults

            var getProductUpdateUriByContextDelegate        = new GetProductUpdateUriByContextDelegate();
            var getQueryParametersForProductContextDelegate = new GetQueryParametersForProductContextDelegate();

            var getProductsPageResultsAsyncDelegate = new GetPageResultsAsyncDelegate <ProductsPageResult>(
                Entity.Products,
                getProductUpdateUriByContextDelegate,
                getQueryParametersForProductContextDelegate,
                requestPageAsyncDelegate,
                getStringMd5HashAsyncDelegate,
                precomputedHashController,
                serializationController,
                statusController);

            var itemizeProductsPageResultProductsDelegate = new ItemizeProductsPageResultProductsDelegate();

            var productsUpdateActivity = new PageResultUpdateActivity <ProductsPageResult, Product>(
                (Activity.UpdateData, Entity.Products),
                activityContextController,
                getProductsPageResultsAsyncDelegate,
                itemizeProductsPageResultProductsDelegate,
                productsDataController,
                activityRecordsController,
                statusController);

            var getAccountProductsPageResultsAsyncDelegate = new GetPageResultsAsyncDelegate <AccountProductsPageResult>(
                Entity.AccountProducts,
                getProductUpdateUriByContextDelegate,
                getQueryParametersForProductContextDelegate,
                requestPageAsyncDelegate,
                getStringMd5HashAsyncDelegate,
                precomputedHashController,
                serializationController,
                statusController);

            var itemizeAccountProductsPageResultProductsDelegate = new ItemizeAccountProductsPageResultProductsDelegate();

            var accountProductsUpdateActivity = new PageResultUpdateActivity <AccountProductsPageResult, AccountProduct>(
                (Activity.UpdateData, Entity.AccountProducts),
                activityContextController,
                getAccountProductsPageResultsAsyncDelegate,
                itemizeAccountProductsPageResultProductsDelegate,
                accountProductsDataController,
                activityRecordsController,
                statusController);

            var confirmAccountProductUpdatedDelegate = new ConfirmAccountProductUpdatedDelegate();

            var updatedUpdateActivity = new UpdatedUpdateActivity(
                activityContextController,
                accountProductsDataController,
                confirmAccountProductUpdatedDelegate,
                updatedIndexController,
                statusController);

            #endregion

            #region Update.Wishlisted

            var getDeserializedPageResultAsyncDelegate = new GetDeserializedGOGDataAsyncDelegate <ProductsPageResult>(networkController,
                                                                                                                      itemizeGOGDataDelegate,
                                                                                                                      serializationController);

            var wishlistedUpdateActivity = new WishlistedUpdateActivity(
                getDeserializedPageResultAsyncDelegate,
                wishlistedIndexController,
                statusController);

            #endregion

            #region Update.Products

            // dependencies for update controllers

            var getDeserializedGOGDataAsyncDelegate = new GetDeserializedGOGDataAsyncDelegate <GOGData>(networkController,
                                                                                                        itemizeGOGDataDelegate,
                                                                                                        serializationController);

            var getDeserializedGameProductDataAsyncDelegate = new GetDeserializedGameProductDataAsyncDelegate(
                getDeserializedGOGDataAsyncDelegate);

            var getProductUpdateIdentityDelegate         = new GetProductUpdateIdentityDelegate();
            var getGameProductDataUpdateIdentityDelegate = new GetGameProductDataUpdateIdentityDelegate();
            var getAccountProductUpdateIdentityDelegate  = new GetAccountProductUpdateIdentityDelegate();

            var fillGameDetailsGapsDelegate = new FillGameDetailsGapsDelegate();

            var itemizeAllUserRequestedIdsAsyncDelegate = new ItemizeAllUserRequestedIdsAsyncDelegate(args);

            // product update controllers

            var itemizeAllGameProductDataGapsAsyncDelegatepsDelegate = new ItemizeAllMasterDetailsGapsAsyncDelegate <Product, GameProductData>(
                productsDataController,
                gameProductDataDataController);

            var itemizeAllUserRequestedIdsOrDefaultAsyncDelegate = new ItemizeAllUserRequestedIdsOrDefaultAsyncDelegate(
                itemizeAllUserRequestedIdsAsyncDelegate,
                itemizeAllGameProductDataGapsAsyncDelegatepsDelegate,
                updatedIndexController);

            var gameProductDataUpdateActivity = new MasterDetailProductUpdateActivity <Product, GameProductData>(
                Entity.GameProductData,
                getProductUpdateUriByContextDelegate,
                itemizeAllUserRequestedIdsOrDefaultAsyncDelegate,
                productsDataController,
                gameProductDataDataController,
                updatedIndexController,
                getDeserializedGameProductDataAsyncDelegate,
                getGameProductDataUpdateIdentityDelegate,
                statusController);

            var getApiProductDelegate = new GetDeserializedGOGModelAsyncDelegate <ApiProduct>(
                networkController,
                serializationController);

            var itemizeAllApiProductsGapsAsyncDelegate = new ItemizeAllMasterDetailsGapsAsyncDelegate <Product, ApiProduct>(
                productsDataController,
                apiProductsDataController);

            var itemizeAllUserRequestedOrApiProductGapsAndUpdatedDelegate = new ItemizeAllUserRequestedIdsOrDefaultAsyncDelegate(
                itemizeAllUserRequestedIdsAsyncDelegate,
                itemizeAllApiProductsGapsAsyncDelegate,
                updatedIndexController);

            var apiProductUpdateActivity = new MasterDetailProductUpdateActivity <Product, ApiProduct>(
                Entity.ApiProducts,
                getProductUpdateUriByContextDelegate,
                itemizeAllUserRequestedOrApiProductGapsAndUpdatedDelegate,
                productsDataController,
                apiProductsDataController,
                updatedIndexController,
                getApiProductDelegate,
                getProductUpdateIdentityDelegate,
                statusController);

            var getDeserializedGameDetailsDelegate = new GetDeserializedGOGModelAsyncDelegate <GameDetails>(
                networkController,
                serializationController);

            var confirmStringContainsLanguageDownloadsDelegate = new ConfirmStringMatchesAllDelegate(
                collectionController,
                Models.Separators.Separators.GameDetailsDownloadsStart,
                Models.Separators.Separators.GameDetailsDownloadsEnd);

            var replaceMultipleStringsDelegate = new ReplaceMultipleStringsDelegate();

            var itemizeDownloadLanguagesDelegate = new ItemizeDownloadLanguagesDelegate(
                languageController,
                replaceMultipleStringsDelegate);

            var itemizeGameDetailsDownloadsDelegate = new ItemizeGameDetailsDownloadsDelegate();

            var formatDownloadLanguagesDelegate = new FormatDownloadLanguageDelegate(
                replaceMultipleStringsDelegate);

            var convertOperatingSystemsDownloads2DArrayToArrayDelegate = new Convert2DArrayToArrayDelegate <OperatingSystemsDownloads>();

            var getDeserializedGameDetailsAsyncDelegate = new GetDeserializedGameDetailsAsyncDelegate(
                networkController,
                serializationController,
                languageController,
                formatDownloadLanguagesDelegate,
                confirmStringContainsLanguageDownloadsDelegate,
                itemizeDownloadLanguagesDelegate,
                itemizeGameDetailsDownloadsDelegate,
                replaceMultipleStringsDelegate,
                convertOperatingSystemsDownloads2DArrayToArrayDelegate,
                collectionController);

            var itemizeAllGameDetailsGapsAsyncDelegate = new ItemizeAllMasterDetailsGapsAsyncDelegate <AccountProduct, GameDetails>(
                accountProductsDataController,
                gameDetailsDataController);

            var itemizeAllUserRequestedOrDefaultAsyncDelegate = new ItemizeAllUserRequestedIdsOrDefaultAsyncDelegate(
                itemizeAllUserRequestedIdsAsyncDelegate,
                itemizeAllGameDetailsGapsAsyncDelegate,
                updatedIndexController);

            var gameDetailsUpdateActivity = new MasterDetailProductUpdateActivity <AccountProduct, GameDetails>(
                Entity.GameDetails,
                getProductUpdateUriByContextDelegate,
                itemizeAllUserRequestedOrDefaultAsyncDelegate,
                accountProductsDataController,
                gameDetailsDataController,
                updatedIndexController,
                getDeserializedGameDetailsAsyncDelegate,
                getAccountProductUpdateIdentityDelegate,
                statusController,
                fillGameDetailsGapsDelegate);

            #endregion

            #region Update.Screenshots

            var updateScreenshotsAsyncDelegate = new UpdateScreenshotsAsyncDelegate(
                getProductUpdateUriByContextDelegate,
                productScreenshotsDataController,
                networkController,
                itemizeScreenshotsDelegate,
                statusController);

            var updateScreenshotsActivity = new UpdateScreenshotsActivity(
                productsDataController,
                productScreenshotsDataController,
                updateScreenshotsAsyncDelegate,
                statusController);

            #endregion

            // dependencies for download controllers

            var getProductImageUriDelegate        = new GetProductImageUriDelegate();
            var getAccountProductImageUriDelegate = new GetAccountProductImageUriDelegate();

            var itemizeAllUserRequestedIdsOrUpdatedAsyncDelegate = new ItemizeAllUserRequestedIdsOrDefaultAsyncDelegate(
                itemizeAllUserRequestedIdsAsyncDelegate,
                updatedIndexController);

            var getProductsImagesDownloadSourcesAsyncDelegate = new GetProductCoreImagesDownloadSourcesAsyncDelegate <Product>(
                itemizeAllUserRequestedIdsOrUpdatedAsyncDelegate,
                productsDataController,
                formatImagesUriDelegate,
                getProductImageUriDelegate,
                statusController);

            var getAccountProductsImagesDownloadSourcesAsyncDelegate = new GetProductCoreImagesDownloadSourcesAsyncDelegate <AccountProduct>(
                itemizeAllUserRequestedIdsOrUpdatedAsyncDelegate,
                accountProductsDataController,
                formatImagesUriDelegate,
                getAccountProductImageUriDelegate,
                statusController);

            var getScreenshotsDownloadSourcesAsyncDelegate = new GetScreenshotsDownloadSourcesAsyncDelegate(
                productScreenshotsDataController,
                formatScreenshotsUriDelegate,
                getScreenshotsDirectoryDelegate,
                fileController,
                statusController);

            var routingController = new RoutingController(
                productRoutesDataController,
                statusController);

            var itemizeGameDetailsManualUrlsAsyncDelegate = new ItemizeGameDetailsManualUrlsAsyncDelegate(
                settingsStashController,
                gameDetailsDataController);

            var itemizeGameDetailsDirectoriesAsyncDelegate = new ItemizeGameDetailsDirectoriesAsyncDelegate(
                itemizeGameDetailsManualUrlsAsyncDelegate,
                getProductFilesDirectoryDelegate);

            var itemizeGameDetailsFilesAsyncDelegate = new ItemizeGameDetailsFilesAsyncDelegate(
                itemizeGameDetailsManualUrlsAsyncDelegate,
                routingController,
                getGameDetailsFilesPathDelegate,
                statusController);

            // product files are driven through gameDetails manual urls
            // so this sources enumerates all manual urls for all updated game details
            var getManualUrlDownloadSourcesAsyncDelegate = new GetManualUrlDownloadSourcesAsyncDelegate(
                updatedIndexController,
                gameDetailsDataController,
                itemizeGameDetailsManualUrlsAsyncDelegate,
                statusController);

            // schedule download controllers

            var updateProductsImagesDownloadsActivity = new UpdateDownloadsActivity(
                Entity.ProductImages,
                getProductsImagesDownloadSourcesAsyncDelegate,
                getProductImagesDirectoryDelegate,
                fileController,
                productDownloadsDataController,
                accountProductsDataController,
                productsDataController,
                statusController);

            var updateAccountProductsImagesDownloadsActivity = new UpdateDownloadsActivity(
                Entity.AccountProductImages,
                getAccountProductsImagesDownloadSourcesAsyncDelegate,
                getAccountProductImagesDirectoryDelegate,
                fileController,
                productDownloadsDataController,
                accountProductsDataController,
                productsDataController,
                statusController);

            var updateScreenshotsDownloadsActivity = new UpdateDownloadsActivity(
                Entity.Screenshots,
                getScreenshotsDownloadSourcesAsyncDelegate,
                getScreenshotsDirectoryDelegate,
                fileController,
                productDownloadsDataController,
                accountProductsDataController,
                productsDataController,
                statusController);

            var updateProductFilesDownloadsActivity = new UpdateDownloadsActivity(
                Entity.ProductFiles,
                getManualUrlDownloadSourcesAsyncDelegate,
                getProductFilesDirectoryDelegate,
                fileController,
                productDownloadsDataController,
                accountProductsDataController,
                productsDataController,
                statusController);

            // downloads processing

            var formatUriRemoveSessionDelegate = new FormatUriRemoveSessionDelegate();

            var confirmValidationExpectedDelegate = new ConfirmValidationExpectedDelegate();

            var formatValidationUriDelegate = new FormatValidationUriDelegate(
                getValidationFilenameDelegate,
                formatUriRemoveSessionDelegate);

            var formatValidationFileDelegate = new FormatValidationFileDelegate(
                getValidationPathDelegate);

            var downloadValidationFileAsyncDelegate = new DownloadValidationFileAsyncDelegate(
                formatUriRemoveSessionDelegate,
                confirmValidationExpectedDelegate,
                formatValidationFileDelegate,
                getValidationDirectoryDelegate,
                formatValidationUriDelegate,
                fileController,
                downloadFromUriAsyncDelegate,
                statusController);

            var downloadManualUrlFileAsyncDelegate = new DownloadManualUrlFileAsyncDelegate(
                networkController,
                formatUriRemoveSessionDelegate,
                routingController,
                downloadFromResponseAsyncDelegate,
                downloadValidationFileAsyncDelegate,
                statusController);

            var downloadProductImageAsyncDelegate = new DownloadProductImageAsyncDelegate(downloadFromUriAsyncDelegate);

            var productsImagesDownloadActivity = new DownloadFilesActivity(
                Entity.ProductImages,
                productDownloadsDataController,
                downloadProductImageAsyncDelegate,
                statusController);

            var accountProductsImagesDownloadActivity = new DownloadFilesActivity(
                Entity.AccountProductImages,
                productDownloadsDataController,
                downloadProductImageAsyncDelegate,
                statusController);

            var screenshotsDownloadActivity = new DownloadFilesActivity(
                Entity.Screenshots,
                productDownloadsDataController,
                downloadProductImageAsyncDelegate,
                statusController);

            var productFilesDownloadActivity = new DownloadFilesActivity(
                Entity.ProductFiles,
                productDownloadsDataController,
                downloadManualUrlFileAsyncDelegate,
                statusController);

            // validation controllers

            var validationResultController = new ValidationResultController();

            var fileMd5Controller = new GetFileMd5HashAsyncDelegate(
                storageController,
                getStringMd5HashAsyncDelegate);

            var dataFileValidateDelegate = new DataFileValidateDelegate(
                fileMd5Controller,
                statusController);

            var productFileValidationController = new FileValidationController(
                confirmValidationExpectedDelegate,
                fileController,
                streamController,
                getBytesMd5HashAsyncDelegate,
                validationResultController,
                statusController);

            var validateProductFilesActivity = new ValidateProductFilesActivity(
                getProductFilesDirectoryDelegate,
                getUriFilenameDelegate,
                formatValidationFileDelegate,
                productFileValidationController,
                validationResultsDataController,
                gameDetailsDataController,
                itemizeGameDetailsManualUrlsAsyncDelegate,
                itemizeAllUserRequestedIdsOrUpdatedAsyncDelegate,
                routingController,
                statusController);

            var validateDataActivity = new ValidateDataActivity(
                precomputedHashController,
                fileController,
                dataFileValidateDelegate,
                statusController);

            #region Repair

            var repairActivity = new RepairActivity(
                validationResultsDataController,
                validationResultController,
                statusController);

            #endregion

            #region Cleanup

            var itemizeAllGameDetailsDirectoriesAsyncDelegate = new ItemizeAllGameDetailsDirectoriesAsyncDelegate(
                gameDetailsDataController,
                itemizeGameDetailsDirectoriesAsyncDelegate,
                statusController);

            var itemizeAllProductFilesDirectoriesAsyncDelegate = new ItemizeAllProductFilesDirectoriesAsyncDelegate(
                getProductFilesBaseDirectoryDelegate,
                directoryController,
                statusController);

            var itemizeDirectoryFilesDelegate = new ItemizeDirectoryFilesDelegate(directoryController);

            var directoryCleanupActivity = new CleanupActivity(
                Entity.Directories,
                itemizeAllGameDetailsDirectoriesAsyncDelegate,  // expected items (directories for gameDetails)
                itemizeAllProductFilesDirectoriesAsyncDelegate, // actual items (directories in productFiles)
                itemizeDirectoryFilesDelegate,                  // detailed items (files in directory)
                formatValidationFileDelegate,                   // supplementary items (validation files)
                recycleDelegate,
                directoryController,
                statusController);

            var itemizeAllUpdatedGameDetailsManualUrlFilesAsyncDelegate =
                new ItemizeAllUpdatedGameDetailsManualUrlFilesAsyncDelegate(
                    updatedIndexController,
                    gameDetailsDataController,
                    itemizeGameDetailsFilesAsyncDelegate,
                    statusController);

            var itemizeAllUpdatedProductFilesAsyncDelegate =
                new ItemizeAllUpdatedProductFilesAsyncDelegate(
                    updatedIndexController,
                    gameDetailsDataController,
                    itemizeGameDetailsDirectoriesAsyncDelegate,
                    directoryController,
                    statusController);

            var itemizePassthroughDelegate = new ItemizePassthroughDelegate();

            var fileCleanupActivity = new CleanupActivity(
                Entity.Files,
                itemizeAllUpdatedGameDetailsManualUrlFilesAsyncDelegate, // expected items (files for updated gameDetails)
                itemizeAllUpdatedProductFilesAsyncDelegate,              // actual items (updated product files)
                itemizePassthroughDelegate,                              // detailed items (passthrough)
                formatValidationFileDelegate,                            // supplementary items (validation files)
                recycleDelegate,
                directoryController,
                statusController);

            var cleanupUpdatedActivity = new CleanupUpdatedActivity(
                updatedIndexController,
                statusController);

            #endregion

            #region Help

            var helpActivity = new HelpActivity(
                activityContextController,
                statusController);

            #endregion

            #region Report Task Status

            var reportFilePresentationController = new FilePresentationController(
                getReportDirectoryDelegate,
                getReportFilenameDelegate,
                streamController);

            var fileNotifyStatusViewUpdateController = new NotifyStatusViewUpdateController(
                getStatusViewUpdateDelegate,
                reportFilePresentationController);

            var reportActivity = new ReportActivity(
                fileNotifyStatusViewUpdateController,
                statusController);

            #endregion

            #region List

            var listUpdatedActivity = new ListUpdatedActivity(
                updatedIndexController,
                accountProductsDataController,
                statusController);

            #endregion

            #endregion

            #region Activity Context To Activity Controllers Mapping

            var activityContextToActivityControllerMap = new Dictionary <(Activity, Entity), IActivity>
            {
                { (Activity.Correct, Entity.Settings), correctSettingsActivity },
Example #31
0
        protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            try
            {
                if (e.CurrentStepIndex == (int)StepsEnum.Define_Criteria &&
                    e.NextStepIndex == (int)StepsEnum.Refine_Shipments)
                {
                    if (ListBoxRegions.SelectedValue == "")
                    {
                        DisplayMessage("Please Select a Region.");
                        RoutingHistoryId = null;
                        e.Cancel         = true;
                        return;
                    }
                    else
                    {
                        try
                        {
                            RoutingHistoryId = RoutingController.SetOptrakLocks(User.Identity.Name, ListBoxRegions.SelectedValue, (RoutingController.PeriodEnum)RadioButtonListPeriod.SelectedIndex);

                            if (RoutingHistoryId == -2)
                            {
                                //there are no shipments matching the criteria to lock so display message to user
                                DisplayMessage("No shipments were found to Route.");
                                RoutingHistoryId = null;
                                e.Cancel         = true;
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            ExceptionPolicy.HandleException(ex, "User Interface");
                        }


                        if (RoutingHistoryId == null)
                        {
                            DisplayMessage(
                                "There was a problem locking the Shipments which match the specified criteria for Routing.",
                                DiscoveryMessageType.Error);
                            e.Cancel = true;
                        }
                        else
                        {
                            GridViewShipmentsToRefine.Sort("ShipmentName,pafpostcode,estimateddeliverydate",
                                                           SortDirection.Ascending);
                        }
                    }
                }

                else if (e.CurrentStepIndex == (int)StepsEnum.Refine_Shipments &&
                         e.NextStepIndex == (int)StepsEnum.Merge_Delivery_Points)
                {
                    List <TDCShipment> shipmentsToRemoveFromRouting = new List <TDCShipment>();

                    foreach (int shipmentId in ShipmentIdsToRemoveFromRouting)
                    {
                        TDCShipment tdcShipment = new TDCShipment();
                        tdcShipment.Id     = shipmentId;
                        tdcShipment.Status = Shipment.StatusEnum.Routing;
                        shipmentsToRemoveFromRouting.Add(tdcShipment);
                    }
                    e.Cancel = !RemoveItemsFromRouting(shipmentsToRemoveFromRouting);
                    if (!e.Cancel)
                    {
                        //merge their delivery points using Customer Name and PAF postcode
                        bool mergeWorked = false;
                        try
                        {
                            mergeWorked = RoutingController.MergeDeliveryPointsAutomatically(RoutingHistoryId.Value);
                        }
                        catch (Exception ex)
                        {
                            ExceptionPolicy.HandleException(ex, "User Interface");
                        }
                        if (!mergeWorked)
                        {
                            DisplayMessage("Merging of Delivery points failed.");
                            e.Cancel = true;
                        }

                        MultiView1.ActiveViewIndex = 0;
                        GridViewMergedPoints.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "User Interface"))
                {
                    DisplayMessage(ex);
                }
            }
        }
Example #32
0
 public static Interface Create(OspfModule module, RoutingController controller, string deviceID, Area area, InterfaceElement config)
 {
     var interfc = new Interface
                   {
                       Module = module,
                       _controller = controller,
                       DeviceID = deviceID,
                       Area = area,
                       _config = config,
                       InterfaceState = InterfaceState.Down
                   };
     interfc.Priority = config.Priority;
     interfc.OspfNetworkType = config.Type;
     interfc.HelloInterval = config.HelloInterval;
     interfc.RouterDeadInterval = config.RouterDeadInterval;
     interfc.RxmtInterval = config.RxmtInterval;
     //interfc.NeighborSelf = Neighbor.Create(module, controller, interfc, controller.DeviceConfigurationMap[deviceID].PrimaryIPConfiguration.Address, module.RouterID,
     //                                       new OspfOptions(), config.Priority);
     return interfc;
 }
Example #33
0
 public void TestInitialize()
 {
     _graphHopperGateway   = Substitute.For <IGraphHopperGateway>();
     _elevationDataStorage = Substitute.For <IElevationDataStorage>();
     _controller           = new RoutingController(_graphHopperGateway, _elevationDataStorage);
 }