Esempio n. 1
0
 public static void ToEntity(DT.StateLog source, StateLog target)
 {
     if ((source != null) && (target != null))
     {
         target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = source.State; target.UserId = source.UserId;
     }
 }
Esempio n. 2
0
        private void Notify(NotifyFlag notify, string title, string text, StateLog state, ToolTipIcon icon = ToolTipIcon.Info)
        {
            if (IsHandleCreated)
            {
                Invoke(new Action(() =>
                {
                    switch (state)
                    {
                    case StateLog.Normal:
                        _notify.Icon = Resources.state_normal;
                        break;

                    case StateLog.Busy:
                        _notify.Icon = Resources.state_busy;
                        break;

                    case StateLog.Listen:
                        _notify.Icon = Resources.state_listen;
                        break;
                    }
                }));
            }

            if (config.Notify >= notify)
            {
                _notify.ShowBalloonTip(1000, title, text, icon);
            }
        }
Esempio n. 3
0
        private FactTaskData CalculateFactTaskData(IEnumerable <StateLog> stateLogs)
        {
            var factTaskData = new FactTaskData();
            var enumerator   = stateLogs.GetEnumerator();

            if (enumerator.MoveNext())
            {
                StateLog current = enumerator.Current, first = current, prev = null;
                while (current != null)
                {
                    var next = enumerator.MoveNext() ? enumerator.Current : null;
                    int timeSpanInSeconds;
                    if (next != null)
                    {
                        timeSpanInSeconds = (int)(next.DateTime - current.DateTime).TotalSeconds;
                    }
                    else
                    {
                        timeSpanInSeconds      = (int)(DateTime.Now - current.DateTime).TotalSeconds;
                        factTaskData.Exception = current.Exception;
                    }
                    switch (current.State)
                    {
                    case TaskState.Calculating:
                        factTaskData.CalculatingTime += timeSpanInSeconds;
                        factTaskData.CalculationRuns++;
                        if (factTaskData.CalculationRuns == 1)
                        {
                            factTaskData.StartTime          = current.DateTime;
                            factTaskData.InitialWaitingTime = (int)(current.DateTime - first.DateTime).TotalSeconds;
                        }
                        if (prev != null && prev.State != TaskState.Transferring)
                        {
                            factTaskData.Retries++;
                        }
                        break;

                    case TaskState.Waiting:
                        factTaskData.WaitingTime += timeSpanInSeconds;
                        break;

                    case TaskState.Transferring:
                        factTaskData.TransferTime += timeSpanInSeconds;
                        break;

                    case TaskState.Finished:
                    case TaskState.Failed:
                    case TaskState.Aborted:
                        factTaskData.EndTime = current.DateTime;
                        break;
                    }
                    prev    = current;
                    current = next;
                }
            }
            return(factTaskData);
        }
Esempio n. 4
0
 /// <summary>
 /// 设置状态并备份
 /// 系统和用户操作一般用这个
 /// </summary>
 /// <param name="State"></param>
 public void SetStateType(StateType State)
 {
     lock (this)
     {
         this.State = State;
         DateTime dateTime = DateTime.Now;
         Thread.Sleep(1);
         StateLog.Add(dateTime, State);
     }
 }
Esempio n. 5
0
        public static StateLog ToEntity(DT.StateLog source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new StateLog(); ToEntity(source, entity);

            return(entity);
        }
Esempio n. 6
0
 public static DT.StateLog ToDto(StateLog source)
 {
     if (source == null)
     {
         return(null);
     }
     return(new DT.StateLog {
         Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, JobId = source.JobId, SlaveId = source.SlaveId, State = source.State, UserId = source.UserId
     });
 }
        public static void AddData(GanttChart ganttChart, string name, StateLog from, StateLog to, DateTime upperLimit)
        {
            DateTime until    = to != null ? to.DateTime : upperLimit;
            TimeSpan duration = until - from.DateTime;
            string   tooltip  = string.Format("Task: {0} " + Environment.NewLine + "Task Id: {1}" + Environment.NewLine + "State: {2} " + Environment.NewLine + "Duration: {3} " + Environment.NewLine + "{4} - {5}" + Environment.NewLine, from.TaskName, from.TaskId, from.State, duration, from.DateTime, until);

            if (to != null && to.SlaveId != null)
            {
                tooltip += "Slave: " + to.SlaveId;
            }

            if (!string.IsNullOrEmpty(from.Exception))
            {
                tooltip += Environment.NewLine + from.Exception;
            }
            ganttChart.AddData(name, from.State.ToString(), from.DateTime, until, tooltip, false);
        }
    public static void AddData(GanttChart ganttChart, string name, StateLog from, StateLog to, DateTime upperLimit) {
      DateTime until = to != null ? to.DateTime : upperLimit;
      TimeSpan duration = until - from.DateTime;
      string tooltip = string.Format("Task: {0} " + Environment.NewLine + "Task Id: {1}" + Environment.NewLine + "State: {2} " + Environment.NewLine + "Duration: {3} " + Environment.NewLine + "{4} - {5}" + Environment.NewLine, from.TaskName, from.TaskId, from.State, duration, from.DateTime, until);

      if (to != null && to.SlaveId != null)
        tooltip += "Slave: " + to.SlaveId;

      if (!string.IsNullOrEmpty(from.Exception))
        tooltip += Environment.NewLine + from.Exception;
      ganttChart.AddData(name, from.State.ToString(), from.DateTime, until, tooltip, false);
    }