protected void bAddNewMessage_Click(object sender, ImageClickEventArgs e)
    {
        if (tbNewMessage.Text.Trim().Length > 0 && FeedbackID > 0)
        {
            string l_strMessage = tbNewMessage.Text.Trim();

            FeedbacksData dalc = new FeedbacksData();
            try
            {
                dalc.StartTransaction();
                dalc.AddUpdateFeedbackMessage(null, FeedbackID, l_strMessage, true, DateTime.Now);
                dalc.Commit();
            }
            catch
            {
                dalc.Rollback();
                throw;
            }
            finally
            {
                dalc.Dispose();
            }
            tbNewMessage.Text = "";
            LoadFeedbackMessages();
        }
    }
Exemple #2
0
 public Metadata()
 {
     Occ                     = new OccData(this);
     LocomotivesData         = new LocomotivesData(this);
     LocomotivesDurationData = new DurationsData(this);
     FeedbacksData           = new FeedbacksData(this);
 }
Exemple #3
0
 public bool LoadFeedbacks(string pathToFeedbacksmodel)
 {
     if (string.IsNullOrEmpty(pathToFeedbacksmodel))
     {
         return(false);
     }
     if (!File.Exists(pathToFeedbacksmodel))
     {
         File.WriteAllText(pathToFeedbacksmodel, "[]", Encoding.UTF8);
     }
     FeedbacksData = new FeedbacksData(this);
     return(FeedbacksData.Load(pathToFeedbacksmodel));
 }
        /// <summary>
        /// Filters the routes where the current locomotive
        /// is not allowed to enter the block.
        /// </summary>
        /// <param name="routeList"></param>
        /// <param name="locDataEcos"></param>
        /// <param name="locData"></param>
        /// <param name="feedbacks"></param>
        /// <returns></returns>
        public static RouteList FilterBy(
            this RouteList routeList,
            Locomotive locDataEcos,
            Locomotives.Data locData,
            FeedbacksData feedbacks
            )
        {
            var res = new RouteList();

            foreach (var it in routeList)
            {
                var targetBlock           = it.Blocks[1];
                var targetBlockIdentifier = targetBlock.identifier;
                var targetEnterSide       = targetBlock.side;

                var targetBlockData = feedbacks.GetByBlockId(targetBlockIdentifier, targetEnterSide);
                if (targetBlockData == null)
                {
                    continue;
                }

                //
                // check if the target block denies entering by the current locomotive
                //
                var useIsDenied = false;
                foreach (var itLoc in targetBlockData.DeniedLocomotives)
                {
                    useIsDenied = itLoc.Id.Equals(locDataEcos.Name, StringComparison.Ordinal);
                    if (useIsDenied)
                    {
                        break;
                    }
                }
                if (useIsDenied)
                {
                    continue;
                }

                //
                // check if the locomotive type is not allowed to enter the target block
                //
                targetBlockData.Settings ??= GetDefaultSettings();
                if (targetBlockData.Settings.Count == 0)
                {
                    continue;
                }
                var enterIsAllowed = false;
                foreach (var itLocSetting in locData.Settings)
                {
                    var name  = itLocSetting.Key;
                    var state = itLocSetting.Value;

                    if (targetBlockData.Settings.ContainsKey(name))
                    {
                        enterIsAllowed = state == targetBlockData.Settings[name];
                        if (enterIsAllowed)
                        {
                            break;
                        }
                    }
                }
                if (!enterIsAllowed)
                {
                    continue;
                }

                res.Add(it);
            }

            return(res);
        }