Beispiel #1
0
        internal ActivityEvent(XmlNode eventNode)
        {
            XmlNode node;

            node = eventNode.Attributes.GetNamedItem("type");
            if( node == null )
                _type = ActivityEventType.Unknown;
            else if( node.Value == "comment" )
                _type = ActivityEventType.Comment;
            else if( node.Value == "note" )
                _type = ActivityEventType.Note;
            else if( node.Value == "fave" )
                _type = ActivityEventType.Favourite;
            else
                _type = ActivityEventType.Unknown;

            node = eventNode.Attributes.GetNamedItem("user");
            if( node != null ) _userId = node.Value;

            node = eventNode.Attributes.GetNamedItem("username");
            if( node != null ) _userName = node.Value;

            node = eventNode.Attributes.GetNamedItem("dateadded");
            if( node != null ) _dateAdded = Utils.UnixTimestampToDate(node.Value);

            node = eventNode.FirstChild;
            if( node != null && node.NodeType == XmlNodeType.Text ) _content = node.Value;
        }
 // Token: 0x060001AA RID: 426 RVA: 0x00007051 File Offset: 0x00005251
 public void LogActivityEvent(IActivityScope activityScope, ActivityEventType eventType)
 {
     if (activityScope == null)
     {
         throw new ArgumentNullException("activityScope");
     }
     this.InternalLogActivityEvent(activityScope, eventType);
 }
Beispiel #3
0
 public ActivityEventBase(object trigger, string displayName, string activityId, ActivityEventType type,
                          int templateId = 0, ActivityStatus status = ActivityStatus.Unspecified)
     : base(trigger, displayName, templateId)
 {
     this.ActivityId = activityId;
     this.Type       = type;
     this.Status     = status;
 }
        // Token: 0x060001A7 RID: 423 RVA: 0x00006E34 File Offset: 0x00005034
        private static Dictionary <ActivityEventType, string> CreateActivityEventTypeDictionary()
        {
            Dictionary <ActivityEventType, string> dictionary = new Dictionary <ActivityEventType, string>();

            foreach (object obj in Enum.GetValues(typeof(ActivityEventType)))
            {
                ActivityEventType activityEventType = (ActivityEventType)obj;
                dictionary.Add(activityEventType, activityEventType.ToString());
            }
            return(dictionary);
        }
Beispiel #5
0
 protected ActivityEvent(
     Guid activityId,
     ActivityEventType eventType,
     DateTimeOffset timestamp,
     string extraData,
     string name)
 {
     this.ActivityId = activityId;
     this.EventType  = eventType;
     this.Timestamp  = timestamp;
     this.ExtraData  = extraData;
     this.Name       = name; // no null check since the default constructor (used by json library) doesn't construct a correct object in this case.
 }
        internal ActivityEvent(XmlNode eventNode)
        {
            XmlNode node;

            node = eventNode.Attributes.GetNamedItem("type");
            if (node == null)
            {
                _type = ActivityEventType.Unknown;
            }
            else if (node.Value == "comment")
            {
                _type = ActivityEventType.Comment;
            }
            else if (node.Value == "note")
            {
                _type = ActivityEventType.Note;
            }
            else if (node.Value == "fave")
            {
                _type = ActivityEventType.Favourite;
            }
            else
            {
                _type = ActivityEventType.Unknown;
            }

            node = eventNode.Attributes.GetNamedItem("user");
            if (node != null)
            {
                _userId = node.Value;
            }

            node = eventNode.Attributes.GetNamedItem("username");
            if (node != null)
            {
                _userName = node.Value;
            }

            node = eventNode.Attributes.GetNamedItem("dateadded");
            if (node != null)
            {
                _dateAdded = Utils.UnixTimestampToDate(node.Value);
            }

            node = eventNode.FirstChild;
            if (node != null && node.NodeType == XmlNodeType.Text)
            {
                _content = node.Value;
            }
        }
Beispiel #7
0
        public void LogActivityEvent(IActivityScope activityScope, ActivityEventType eventType)
        {
            if (activityScope == null)
            {
                throw new ArgumentNullException("activityScope");
            }
            if (!this.configuration.IsLoggingEnabled || !this.IsInterestingEvent(activityScope, eventType))
            {
                return;
            }
            ILogEvent logEvent = activityScope.UserState as ILogEvent;
            ICollection <KeyValuePair <string, object> > collection;
            string text;

            if (logEvent != null)
            {
                collection = this.GetEventData(logEvent);
                text       = logEvent.EventId;
            }
            else
            {
                collection = new List <KeyValuePair <string, object> >(0);
                if (activityScope.ActivityType == ActivityType.Global)
                {
                    text = "GlobalActivity";
                }
                else
                {
                    text = activityScope.GetProperty(ExtensibleLoggerMetadata.EventId);
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                text = "<null>";
            }
            ICollection <KeyValuePair <string, object> > componentSpecificData = this.GetComponentSpecificData(activityScope, text);
            List <KeyValuePair <string, object> >        list = this.FormatWlmActivity(activityScope);
            int capacity = collection.Count + componentSpecificData.Count + list.Count + 2;
            List <KeyValuePair <string, object> > list2 = new List <KeyValuePair <string, object> >(capacity);

            list2.AddRange(collection);
            list2.AddRange(componentSpecificData);
            list2.Add(new KeyValuePair <string, object>("Bld", this.buildNumber));
            list2.Add(new KeyValuePair <string, object>("ActID", activityScope.ActivityId));
            list2.AddRange(list);
            this.LogRow(text, list2);
        }
        protected override void InternalLogActivityEvent(IActivityScope scope, ActivityEventType eventType)
        {
            List <KeyValuePair <string, object> > customData = null;

            switch (eventType)
            {
            case ActivityEventType.StartActivity:
            case ActivityEventType.ResumeActivity:
                break;

            case ActivityEventType.SuspendActivity:
            case ActivityEventType.EndActivity:
                customData = WorkloadManagementLogger.FormatWlmActivity(scope, true);
                break;

            default:
                MrsAndProxyActivityLogger.instance.SafeTraceDebug(0L, "Skip logging ActivityEvent '{0}'.", new object[]
                {
                    eventType
                });
                return;
            }
            MrsAndProxyActivityLogger.InternalLogRow(scope.ActivityId, ActivityContextLogger.ActivityEventTypeDictionary[eventType], scope.Action, scope.UserId, scope.ClientInfo, customData);
        }
 public ActivityEventArgs(ActivityEventType activityEventType, string message = null)
 {
     this.activityEventType = activityEventType;
     this.Message           = message;
 }
Beispiel #10
0
 public NetworkMessageEvent(object trigger, string displayName, string messageId, ActivityEventType type, NetworkMessageDirection direction,
                            int templateId = 0, ActivityStatus status = ActivityStatus.Unspecified) :
     base(trigger, displayName, messageId, type, templateId, status)
 {
     Direction = direction;
 }
Beispiel #11
0
 protected virtual bool IsInterestingEvent(IActivityScope activityScope, ActivityEventType eventType)
 {
     return(eventType == ActivityEventType.EndActivity);
 }
 // Token: 0x060001B0 RID: 432
 protected abstract void InternalLogActivityEvent(IActivityScope activityScope, ActivityEventType eventType);
Beispiel #13
0
        protected override void InternalLogActivityEvent(IActivityScope activityScope, ActivityEventType eventType)
        {
            object        userState     = activityScope.UserState;
            AssistantBase assistantBase = null;
            string        assistantShortName;

            if (activityScope.ActivityType == ActivityType.Global)
            {
                assistantShortName = "GlobalActivity";
            }
            else
            {
                SystemTaskBase systemTaskBase = userState as SystemTaskBase;
                if (systemTaskBase != null)
                {
                    assistantShortName = systemTaskBase.Workload.Id;
                }
                else
                {
                    AssistantBase assistantBase2 = userState as AssistantBase;
                    if (assistantBase2 == null)
                    {
                        return;
                    }
                    assistantBase      = assistantBase2;
                    assistantShortName = assistantBase.NonLocalizedName;
                }
            }
            AssistantsEventType eventType2;

            switch (eventType)
            {
            case ActivityEventType.SuspendActivity:
                eventType2 = AssistantsEventType.SuspendActivity;
                goto IL_92;

            case ActivityEventType.EndActivity:
                eventType2 = AssistantsEventType.EndActivity;
                goto IL_92;
            }
            base.SafeTraceDebug(0L, "Skip logging ActivityEvent '{0}'.", new object[]
            {
                eventType
            });
            return;

IL_92:
            List <KeyValuePair <string, object> > customData = WorkloadManagementLogger.FormatWlmActivity(activityScope, true);

            AssistantsLog.InternalLogRow(activityScope.ActivityId, assistantShortName, assistantBase, eventType2, customData, Guid.Empty);
        }
Beispiel #14
0
 // Token: 0x060005B0 RID: 1456 RVA: 0x0001BD1D File Offset: 0x00019F1D
 protected override void InternalLogActivityEvent(IActivityScope activityScope, ActivityEventType eventType)
 {
 }
Beispiel #15
0
 public ActivityEventBase(object trigger, string displayName, string activityId, ActivityEventType type, int templateId = 0)
     : base(trigger, displayName, templateId)
 {
     this.ActivityId = activityId;
     this.Type       = type;
 }
Beispiel #16
0
        public override void NotifyEvent(ActivityEventType EventType)
        {
            playerTrain = simulator.OriginalPlayerTrain;
            switch (EventType)
            {
            // The train is stopped.
            case ActivityEventType.TrainStop:
                if (playerTrain.TrainType != TrainType.AiPlayerHosting && playerTrain.TrainAtStation() ||
                    playerTrain.TrainType == TrainType.AiPlayerHosting && (playerTrain as AITrain).MovementState == AiMovementState.StationStop)
                {
                    if (simulator.TimetableMode || playerTrain.StationStops.Count == 0)
                    {
                        // If yes, we arrived
                        if (ActualArrival == null)
                        {
                            ActualArrival = TimeSpan.FromSeconds((int)simulator.ClockTime);
                        }

                        arrived = true;

                        // Figure out the boarding time
                        // <CSComment> No midnight checks here? There are some in Train.CalculateDepartTime
                        double plannedBoardingS  = (ScheduledDeparture - ScheduledArrival).TotalSeconds;
                        double punctualBoardingS = (ScheduledDeparture - ActualArrival.GetValueOrDefault(ScheduledArrival)).TotalSeconds;
                        double expectedBoardingS = plannedBoardingS > 0 ? plannedBoardingS : PlatformEnd1.PlatformMinWaitingTime;
                        BoardingS = punctualBoardingS;                                         // default is leave on time
                        if (punctualBoardingS < expectedBoardingS)                             // if not enough time for boarding
                        {
                            if (plannedBoardingS > 0 && plannedBoardingS < PlatformEnd1.PlatformMinWaitingTime)
                            {                                 // and tight schedule
                                BoardingS = plannedBoardingS; // leave late with no recovery of time
                            }
                            else
                            {                                                           // generous schedule
                                BoardingS = Math.Max(
                                    punctualBoardingS,                                  // leave on time
                                    PlatformEnd1.PlatformMinWaitingTime);               // leave late with some recovery
                            }
                        }
                        // ActArrive is usually same as ClockTime
                        BoardingEndS = simulator.ClockTime + BoardingS;
                        // But not if game starts after scheduled arrival. In which case actual arrival is assumed to be same as schedule arrival.
                        double sinceActArriveS = (TimeSpan.FromSeconds((int)simulator.ClockTime) - ActualArrival.GetValueOrDefault(ScheduledArrival)).TotalSeconds;
                        BoardingEndS -= sinceActArriveS;
                    }
                    else
                    {
                        // <CSComment> MSTS mode - player
                        if (simulator.GameTime < 2)
                        {
                            // If the simulation starts with a scheduled arrive in the past, assume the train arrived on time.
                            if (ScheduledArrival.TotalSeconds < simulator.ClockTime)
                            {
                                ActualArrival = ScheduledArrival;
                            }
                        }
                        BoardingS = playerTrain.StationStops[0].ComputeStationBoardingTime(simulator.PlayerLocomotive.Train);
                        if (BoardingS > 0 || ((double)(ScheduledDeparture - ScheduledArrival).TotalSeconds > 0 &&
                                              playerTrain.PassengerCarsNumber == 1 && playerTrain.Cars.Count > 10))
                        {
                            // accepted station stop because either freight train or passenger train or fake passenger train with passenger car on platform or fake passenger train
                            // with Scheduled Depart > Scheduled Arrive
                            // ActArrive is usually same as ClockTime
                            BoardingEndS = simulator.ClockTime + BoardingS;

                            if (!ActualArrival.HasValue)
                            {
                                ActualArrival = TimeSpan.FromSeconds((int)simulator.ClockTime);
                            }

                            arrived = true;
                            // But not if game starts after scheduled arrival. In which case actual arrival is assumed to be same as schedule arrival.
                            double sinceActArriveS = (TimeSpan.FromSeconds((int)simulator.ClockTime) - ActualArrival.GetValueOrDefault(ScheduledArrival)).TotalSeconds;
                            BoardingEndS -= sinceActArriveS;
                            double SchDepartS = ScheduledDeparture.TotalSeconds;
                            BoardingEndS = Time.Compare.Latest((int)SchDepartS, (int)BoardingEndS);
                        }
                    }
                    if (playerTrain.NextSignalObject[0] != null)
                    {
                        distanceToNextSignal = playerTrain.NextSignalObject[0].DistanceTo(playerTrain.FrontTDBTraveller);
                    }
                }
                break;

            case ActivityEventType.TrainStart:
                // Train has started, we have things to do if we arrived before
                if (arrived)
                {
                    ActualDeparture = TimeSpan.FromSeconds((int)simulator.ClockTime);
                    CompletedAt     = ActualDeparture.Value;
                    // Completeness depends on the elapsed waiting time
                    IsCompleted = maydepart;
                    if (playerTrain.TrainType != TrainType.AiPlayerHosting)
                    {
                        playerTrain.ClearStation(PlatformEnd1.LinkedPlatformItemId, PlatformEnd2.LinkedPlatformItemId, true);
                    }

                    if (logStationStops)
                    {
                        StringBuilder stringBuild = new StringBuilder();
                        char          separator   = (char)simulator.Settings.DataLoggerSeparator;
                        stringBuild.Append(PlatformEnd1.Station);
                        stringBuild.Append(separator);
                        stringBuild.Append(ScheduledArrival.ToString("c"));
                        stringBuild.Append(separator);
                        stringBuild.Append(ScheduledDeparture.ToString("c"));
                        stringBuild.Append(separator);
                        stringBuild.Append(ActualArrival.HasValue ? ActualArrival.Value.ToString("c") : "-");
                        stringBuild.Append(separator);
                        stringBuild.Append(ActualDeparture.HasValue ? ActualDeparture.Value.ToString("c") : "-");

                        TimeSpan delay = ActualDeparture.HasValue ? (ActualDeparture - ScheduledDeparture).Value : TimeSpan.Zero;
                        stringBuild.Append(separator);
                        stringBuild.Append(delay.ToString("c"));
                        stringBuild.Append(separator);
                        stringBuild.Append(maydepart ? "Completed" : "NotCompleted");
                        stringBuild.Append('\n');
                        File.AppendAllText(logStationLogFile, stringBuild.ToString());
                    }
                }
                break;

            case ActivityEventType.Timer:
                // Waiting at a station
                if (arrived)
                {
                    int remaining = (int)Math.Ceiling(BoardingEndS - simulator.ClockTime);

                    if (remaining < 1)
                    {
                        DisplayColor = Color.LightGreen;
                    }
                    else if (remaining < 11)
                    {
                        DisplayColor = new Color(255, 255, 128);
                    }
                    else
                    {
                        DisplayColor = Color.White;
                    }

                    if (remaining < 120 && (playerTrain.TrainType != TrainType.AiPlayerHosting))
                    {
                        playerTrain.ClearStation(PlatformEnd1.LinkedPlatformItemId, PlatformEnd2.LinkedPlatformItemId, false);
                    }

                    // Still have to wait
                    if (remaining > 0)
                    {
                        DisplayMessage = Simulator.Catalog.GetString("Passenger boarding completes in {0:D2}:{1:D2}",
                                                                     remaining / 60, remaining % 60);

                        //Debrief Eval
                        if (simulator.PlayerLocomotive.SpeedMpS > 0 && !debriefEvalDepartBeforeBoarding)
                        {
                            Train train = simulator.PlayerLocomotive.Train;
                            debriefEvalDepartBeforeBoarding = true;
                            DebriefEvalDepartBeforeBoarding.Add(PlatformEnd1.Station);
                            train.DbfEvalValueChanged = true;
                        }
                    }
                    // May depart
                    else if (!maydepart)
                    {
                        // check if signal ahead is cleared - if not, do not allow depart
                        if (distanceToNextSignal >= 0 && distanceToNextSignal < 300 && playerTrain.NextSignalObject[0] != null &&
                            playerTrain.NextSignalObject[0].SignalLR(SignalFunction.Normal) == SignalAspectState.Stop &&
                            playerTrain.NextSignalObject[0].OverridePermission != SignalPermission.Granted)
                        {
                            DisplayMessage = Simulator.Catalog.GetString("Passenger boarding completed. Waiting for signal ahead to clear.");
                        }
                        else
                        {
                            maydepart             = true;
                            DisplayMessage        = Simulator.Catalog.GetString("Passenger boarding completed. You may depart now.");
                            simulator.SoundNotify = TrainEvent.PermissionToDepart;
                        }

                        debriefEvalDepartBeforeBoarding = false;    //reset flag. Debrief Eval

                        // if last task, show closure window
                        // also set times in logfile

                        if (NextTask == null)
                        {
                            if (logStationStops)
                            {
                                StringBuilder stringBuild = new StringBuilder();
                                char          separator   = (char)simulator.Settings.DataLoggerSeparator;
                                stringBuild.Append(PlatformEnd1.Station);
                                stringBuild.Append(separator);
                                stringBuild.Append(ScheduledArrival.ToString("hh\\:mm\\:ss", CultureInfo.InvariantCulture));
                                stringBuild.Append(separator);
                                stringBuild.Append('-');
                                stringBuild.Append(separator);
                                stringBuild.Append(ActualArrival.HasValue ? ActualArrival.Value.ToString("c") : "-");
                                stringBuild.Append(separator);
                                stringBuild.Append('-');
                                stringBuild.Append(separator);

                                TimeSpan delay = ActualArrival.HasValue ? (ActualArrival - ScheduledArrival).Value : TimeSpan.Zero;
                                stringBuild.Append(delay.ToString("c"));
                                stringBuild.Append(separator);
                                stringBuild.Append("Final stop");
                                stringBuild.Append('\n');
                                File.AppendAllText(logStationLogFile, stringBuild.ToString());
                            }

                            IsCompleted = true;
                        }
                    }
                }
                else
                {
                    // Checking missed station
                    int tmp = (int)(simulator.ClockTime % 10);
                    if (tmp != timerChk)
                    {
                        if (TrainMissedStation() && (playerTrain.TrainType != TrainType.AiPlayerHosting))
                        {
                            playerTrain.ClearStation(PlatformEnd1.LinkedPlatformItemId, PlatformEnd2.LinkedPlatformItemId, true);
                            IsCompleted = false;

                            if (logStationStops)
                            {
                                StringBuilder stringBuild = new StringBuilder();
                                char          separator   = (char)simulator.Settings.DataLoggerSeparator;
                                stringBuild.Append(PlatformEnd1.Station);
                                stringBuild.Append(separator);
                                stringBuild.Append(ScheduledArrival.ToString("c"));
                                stringBuild.Append(separator);
                                stringBuild.Append(ScheduledDeparture.ToString("c"));
                                stringBuild.Append(separator);
                                stringBuild.Append('-');
                                stringBuild.Append(separator);
                                stringBuild.Append('-');
                                stringBuild.Append(separator);
                                stringBuild.Append('-');
                                stringBuild.Append(separator);
                                stringBuild.Append("Missed");
                                stringBuild.Append('\n');
                                File.AppendAllText(logStationLogFile, stringBuild.ToString());
                            }
                        }
                    }
                }
                break;
            }
        }
Beispiel #17
0
 // Token: 0x06002546 RID: 9542 RVA: 0x00086EAB File Offset: 0x000850AB
 protected override bool IsInterestingEvent(IActivityScope activityScope, ActivityEventType eventType)
 {
     return(base.IsInterestingEvent(activityScope, eventType) && (activityScope.GetProperty(ExtensibleLoggerMetadata.EventId) != null || activityScope.Statistics.Any <KeyValuePair <OperationKey, OperationStatistics> >()));
 }
Beispiel #18
0
 public ProcedureEvent(object trigger, string displayName, string procedureId, ActivityEventType type, int templateId = 0) :
     base(trigger, displayName, procedureId, type, templateId)
 {
 }
Beispiel #19
0
 public ObjectLifetimeEvent(object trigger, string displayName, string objectId, ActivityEventType type, int templateId = 0) :
     base(trigger, displayName, objectId, type, templateId)
 {
 }
 public void LogActivityEvent(IActivityScope activityScope, ActivityEventType eventType)
 {
     this.logger.LogActivityEvent(activityScope, eventType);
 }
Beispiel #21
0
 public virtual void NotifyEvent(ActivityEventType EventType)
 {
 }
Beispiel #22
0
 public ProcedureEvent(object trigger, string displayName, string procedureId, ActivityEventType type, int templateId = 0, ActivityStatus status = ActivityStatus.Unspecified) :
     base(trigger, displayName, procedureId, type, templateId, status)
 {
 }
Beispiel #23
0
 public NetworkMessageEvent(object trigger, string displayName, string messageId, ActivityEventType type, NetworkMessageDirection direction, int templateId = 0) :
     base(trigger, displayName, messageId, type, templateId)
 {
     Direction = direction;
 }
Beispiel #24
0
        protected override void InternalLogActivityEvent(IActivityScope activityScope, ActivityEventType eventType)
        {
            LogRowFormatter logRowFormatter = new LogRowFormatter(base.LogSchema);

            logRowFormatter[1] = activityScope.ActivityType;
            logRowFormatter[2] = ActivityContextLogger.ActivityEventTypeDictionary[eventType];
            logRowFormatter[3] = activityScope.Status;
            logRowFormatter[4] = activityScope.StartTime;
            logRowFormatter[5] = activityScope.EndTime;
            logRowFormatter[6] = WorkloadManagementLogger.FormatWlmActivity(activityScope, true);
            base.AppendLog(logRowFormatter);
        }
Beispiel #25
0
 // Token: 0x06001315 RID: 4885 RVA: 0x0006E5F7 File Offset: 0x0006C7F7
 protected override void InternalLogActivityEvent(IActivityScope activityScope, ActivityEventType eventType)
 {
     throw new NotImplementedException();
 }