Ejemplo n.º 1
0
        /// <summary>
        /// Filter routes by options, does not check "BlockEnabled" option.
        /// See FilterByBlockEnabled()
        /// </summary>
        /// <param name="routeList"></param>
        /// <param name="sideToLeave"></param>
        /// <param name="locData"></param>
        /// <returns></returns>
        public RouteList FilterByAllowedOptions(
            RouteList routeList,
            SideMarker sideToLeave,
            Locomotives.Data locData)
        {
            var res = new RouteList();

            foreach (var it in routeList)
            {
                var targetBlock           = it.Blocks[1];
                var targetBlockIdentifier = targetBlock.identifier;
                if (string.IsNullOrEmpty(targetBlockIdentifier))
                {
                    continue;
                }

                var targetFbData = GetFeedbackDataOf(targetBlockIdentifier, sideToLeave);
                if (targetFbData == null)
                {
                    continue;
                }

                //
                // the most interesting part of this method
                //
                if (IsLocAllowedForTargetBlock(locData, targetFbData))
                {
                    res.Add(it);
                }
            }
            return(res);
        }
Ejemplo n.º 2
0
 public void RegisterRoutes(RouteList routes)
 {
     routes.Add(
         "MarkAsSpam",
         "Admin/Plugins/SpamControl/MarkAsSpam",
         new { role = "Admin", validateAntiForgeryToken = true },
         new { httpMethod = new HttpMethodConstraint("POST") }
         );
 }
Ejemplo n.º 3
0
        private void AddNode(AbsNode newNode)
        {
            AbsNode lastCustomer    = RouteList.Count == 0 ? newNode : RouteList[RouteList.Count - 1];
            double  lastServiceTime = RouteList.Count == 0 ? 0 : ServiceBeginingTimes[ServiceBeginingTimes.Count - 1];
            double  serviceBegins   = NextServiceBeginTime(newNode, lastCustomer, lastServiceTime);

            RouteList.Add(newNode);
            ServiceBeginingTimes.Add(serviceBegins);
            UpdateId();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Filter all routes with blocks which are blocked by any other routes.
        /// https://github.com/cbries/railessentials/wiki/Lock-Additional-Blocks-during-Locomotive-Traveling
        /// </summary>
        /// <param name="routeList"></param>
        /// <param name="sideToLeave"></param>
        /// <returns></returns>
        public RouteList FilterByBlockedRoutes(
            RouteList routeList,
            SideMarker sideToLeave)
        {
            var res = new RouteList();

            foreach (var it in routeList)
            {
                var targetBlock           = it.Blocks[1];
                var targetBlockIdentifier = targetBlock.identifier;
                if (string.IsNullOrEmpty(targetBlockIdentifier))
                {
                    continue;
                }

                var targetFbData = GetFeedbackDataOf(targetBlockIdentifier, sideToLeave);
                if (targetFbData == null)
                {
                    continue;
                }

                var lockedBy = targetFbData.LockedByBlock;
                if (string.IsNullOrEmpty(lockedBy))
                {
                    res.Add(it);
                }
                else
                {
                    var fromBlock           = it.Blocks[0];
                    var fromBlockIdentifier = fromBlock.identifier;

                    if (lockedBy.StartsWith(fromBlockIdentifier, StringComparison.OrdinalIgnoreCase))
                    {
                        res.Add(it);
                    }
                }
            }
            return(res);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Filter routes by target block enabled stated,
        /// only use routes where target blocks are enabled.
        /// </summary>
        /// <param name="routeList"></param>
        /// <param name="sideToLeave"></param>
        /// <param name="locData"></param>
        /// <returns></returns>
        public RouteList FilterByBlockEnabled(
            RouteList routeList,
            SideMarker sideToLeave,
            Locomotives.Data locData)
        {
            var res = new RouteList();

            foreach (var it in routeList)
            {
                var targetBlock           = it.Blocks[1];
                var targetBlockIdentifier = targetBlock.identifier;
                if (string.IsNullOrEmpty(targetBlockIdentifier))
                {
                    continue;
                }

                var targetFbData = GetFeedbackDataOf(targetBlockIdentifier, sideToLeave);
                if (targetFbData == null)
                {
                    continue;
                }

                //
                // when the target block is disabled, do not use for routing
                //
                if (targetFbData.Settings != null && targetFbData.Settings.ContainsKey("BlockEnabled"))
                {
                    var blockEnabled = targetFbData.Settings["BlockEnabled"];
                    if (!blockEnabled)
                    {
                        continue;
                    }
                }

                res.Add(it);
            }
            return(res);
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Session[ByteCore.FerryBooking.Web.SessionVariable.Step1UserInput] is Step1UserInput))
            {
                Response.Redirect("Default.aspx");
            }
            Step1UserInput step1 = (Step1UserInput)Session[SessionVariable.Step1UserInput];
            if (!Page.IsPostBack)
            {
                RouteList routelist = new RouteList();
                Route r1 = new Route().GetById(step1.Route1Id,false);
                routelist.Add(r1);

                Hashtable htSchedulePreLoad = new Hashtable();
                htSchedulePreLoad.Add(r1.ID.ToString(),InitRouteSchedule(step1.Route1Id));

                if (step1.Route2Id>0)
                {
                    Route r2 = new Route().GetById(step1.Route2Id, false);
                    routelist.Add(r2);
                    htSchedulePreLoad.Add(r2.ID.ToString(), InitRouteSchedule(step1.Route2Id));
                }

                if (step1.Route3Id>0)
                {
                    Route r3 = new Route().GetById(step1.Route3Id, false);
                    routelist.Add(r3);
                    htSchedulePreLoad.Add(r3.ID.ToString(), InitRouteSchedule(step1.Route3Id));
                }

                if (step1.Route4Id > 0)
                {
                    Route r4 = new Route().GetById(step1.Route4Id, false);
                    routelist.Add(r4);
                    htSchedulePreLoad.Add(r4.ID.ToString(), InitRouteSchedule(step1.Route4Id));
                }

                Session[SessionVariable.RouteSchedules] = htSchedulePreLoad;

                this.lvSchedule.DataSource = routelist;
                lvSchedule.DataBind();
                RouteOrderPassengerDetailList passengerList = new RouteOrderPassengerDetailList();
                for (int i = 0; i < step1.PassengersCount; i++)
                {
                    passengerList.Add(new RouteOrderPassengerDetail());
                }

                lvPassenger.DataSource = passengerList;
                lvPassenger.DataBind();

                lvTravelMethod.DataSource = routelist;
                lvTravelMethod.DataBind();
            }
        }
Ejemplo n.º 7
0
 public void RegisterRoutes(RouteList routes)
 {
     routes.Add("MarkAsSpam", "Admin/Plugins/SpamControl/MarkAsSpam", new { role = "Admin" });
 }
Ejemplo n.º 8
0
 public void AddTravelRoute(TravelRoute travelRoute)
 {
     RouteList.Add(travelRoute);
 }
Ejemplo n.º 9
0
        private void ParseBaanBom()
        {
            //1/29/2019 - Casa 56 setup sheet shows ref des U163 with paste pn - real pn got skipped bcuz it was Manufactured instead of
            //purchased.  Commenting out the line below and changing 'Purchased' to .* in the regex
            //Tested this fix with a setup sheet from every customer done in LN so far.  Should be good to make permanent.

            //Regex reItemInfoRow= new Regex(@"1\s+\|\s*([0-9]{1,4})/\s+([0-9])\|(\S+)\s*\|(.*)\|Purchased\s+\|\s*([0-9]{1,4}).*\|.*\|.*\|.*\|.*\|.*\|.*\|\s*(\d+\.\d+)"); //Captures 1-FindNum, 2-Seq, 3-PN, 4-Operation, 5-BOMQty
            //Regex reItemInfoRow = new Regex(@"1\s+\|\s*([0-9]{1,4})/\s+([0-9])\|(\S+)\s*\|(.*)\|.*\|\s*([0-9]{1,4}).*\|.*\|.*\|.*\|.*\|.*\|.*\|\s*(\d+\.\d+)"); //Captures 1-FindNum, 2-Seq, 3-PN, 4-Operation, 5-BOMQty
            Regex reItemInfoRow = new Regex(@"1\s+\|\s*([0-9]{1,4})/\s+([0-9])\|(\S+.*)\|(.*)\|.*\|\s*([0-9]{1,4}).*\|.*\|.*\|.*\|.*\|.*\|.*\|\s*(\d+\.\d+)"); //Captures 1-FindNum, 2-Seq, 3-PN, 4-Operation, 5-BOMQty
            ///Line above is another fix for the reItemInfoRow regex.  Part numbers are now coming with spaces in them,
            ///so, I guess we have part phrases now, not part numbers, unbelievable.
            ///anyway the regex now has to capture the part number field and then trim it in case of leading or trailing space between separators |
            ///See other line below, trimming strPN variable
            ///5/2/2019
            ///
            Regex  reDate             = new Regex(@"Date\s+:\s(\d{2}-\d{2}-\d{2})");
            Regex  reRefDes           = new Regex(@"^\s+\|\s(\w+)\s+\|\s+\|\s+\d{1,4}\.\d{4}\s+\|\r?$");
            Regex  reAssemblyName     = new Regex(@"Manufactured Item\s+:\s+(\S+)");
            Regex  reRev              = new Regex(@"Revision\s*:\s+(\S+)");
            Regex  reRouteList        = new Regex(@"^\s+\|\s+(\d{1,4})/\s+\d\s+\|\s+([A-Z]?\d{1,4})\s+\|(.*)\|\d{2}-\d{2}-\d{2}\s+\|\s+\|\s+\w+\s+\|\s+\w*\s+\|\s+\d{1,3}\s+\|\s+\d+\.\d+\s+\|\s+\d+\.\d+\s*\|\s+\|\r?$");
            Regex  reDescription      = new Regex(@"^Description\s+:\s+(.*)");
            bool   bDateFound         = false;
            bool   bAssemblyNameFound = false;
            bool   bRevFound          = false;
            bool   bDescriptionFound  = false;
            string strCurrentFnSeq    = null;

            try
            {
                foreach (string line in BomLines)
                {
                    if (bDateFound == false)
                    {
                        Match m = reDate.Match(line);
                        if (m.Success)
                        {
                            DateOfListing = m.Groups[1].Value;
                            bDateFound    = true;
                            continue;
                        }
                    }
                    if (bAssemblyNameFound == false)
                    {
                        Match m = reAssemblyName.Match(line);
                        if (m.Success)
                        {
                            AssemblyName       = m.Groups[1].Value;
                            bAssemblyNameFound = true;
                            continue;
                        }
                    }
                    if (bDescriptionFound == false)
                    {
                        Match m = reDescription.Match(line);
                        if (m.Success)
                        {
                            AssyDescription   = m.Groups[1].Value.TrimEnd();
                            bDescriptionFound = true;
                            continue;
                        }
                    }
                    if (bRevFound == false)
                    {
                        Match m = reRev.Match(line);
                        if (m.Success)
                        {
                            Rev       = m.Groups[1].Value;
                            bRevFound = true;
                            continue;
                        }
                    }
                    Match match = reItemInfoRow.Match(line);
                    if (match.Success)
                    {
                        string strFnSeq = match.Groups[1].Value + ":" + match.Groups[2].Value;
                        //string strPN = match.Groups[3].Value;
                        //testing capturing part number row with wildcard, no restriction between pipes, so need to trim
                        //see next line
                        string strPN     = match.Groups[3].Value.Trim();
                        string strDesc   = match.Groups[4].Value;
                        string strOp     = match.Groups[5].Value;
                        string strBOMQty = match.Groups[6].Value.Trim();
                        strBOMQty = strBOMQty.Trim('0');
                        if (strBOMQty.EndsWith("."))
                        {
                            strBOMQty = strBOMQty.Trim('.');
                        }
                        if (strBOMQty.Equals(""))
                        {
                            strBOMQty = "0";
                        }
                        if (BomMap.ContainsKey(strFnSeq))
                        {
                            MessageBox.Show(string.Format("Duplicate Findnum/Sequence combination found!\nThis should not happen!  Check BOM:\n"
                                                          + "Key: = {0}, PN: = {4}\nExisting Values: {1}, {2}, {3}" + "\nNot adding new part to BOM",
                                                          strFnSeq, BomMap[strFnSeq][0], BomMap[strFnSeq][1], BomMap[strFnSeq][2], strPN), "BOM Error",
                                            MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            BomMap.Add(strFnSeq, new List <string> {
                                strPN, strOp, strDesc.Trim(), "", strBOMQty
                            });
                            if (!string.IsNullOrEmpty(strCurrentFnSeq) && BomMap[strCurrentFnSeq].Count > 2)
                            {
                                BomMap[strCurrentFnSeq][3] = BomMap[strCurrentFnSeq][3].TrimEnd(',');
                            }

                            strCurrentFnSeq = strFnSeq;
                        }
                        continue;
                    }
                    Match matchRds = reRefDes.Match(line);
                    if (matchRds.Success)
                    {
                        BomMap[strCurrentFnSeq][3] += matchRds.Groups[1].Value + ",";
                        continue;
                    }
                    Match matchRouteList = reRouteList.Match(line);
                    if (matchRouteList.Success)
                    {
                        string strRouteStep = matchRouteList.Groups[1].Value + ":" + matchRouteList.Groups[2].Value + ":" + matchRouteList.Groups[3].Value.Trim();
                        RouteList.Add(strRouteStep);
                    }
                }
                BomMap.ElementAt(BomMap.Count - 1).Value[3] = BomMap.ElementAt(BomMap.Count - 1).Value[3].TrimEnd(',');
                foreach (string key in BomMap.Keys)
                {
                    if (BomMap[key][3].Equals(""))
                    {
                        BomMap[key][3] = "No Ref Des";
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error parsing BAAN file.\nMake sure it's a valid BaaN BOM and try again.\nParseBaanBom()\n" + e.Message, strCurrentFnSeq, MessageBoxButton.OK, MessageBoxImage.Error);
                ClearData();
                IsValid = false;
                throw;
            }
        }