Пример #1
0
        public static DataTable GetTimesOfDay(TimeType type)
        {
            DataTable timeTable = new DataTable("TimeOfDay");

            timeTable.Columns.Add(new DataColumn("TimeType"));
            timeTable.Columns.Add(new DataColumn("Time"));

            if (type == TimeType.Hour)
            {
                for (int i = 0; i < 24; i++)
                {
                    DataRow row = timeTable.NewRow();
                    row["TimeType"] = type.ToString();
                    row["Time"]     = i.ToString("d2");
                    timeTable.Rows.Add(row);
                }
            }

            if (type == TimeType.Minute)
            {
                for (int i = 0; i < 60; i += 15)
                {
                    DataRow row = timeTable.NewRow();
                    row["TimeType"] = type.ToString();
                    row["Time"]     = i.ToString("d2");
                    timeTable.Rows.Add(row);
                }
            }

            if (type == TimeType.Second)
            {
                for (int i = 0; i < 60; i += 15)
                {
                    DataRow row = timeTable.NewRow();
                    row["TimeType"] = type.ToString();
                    row["Time"]     = i.ToString("d2");
                    timeTable.Rows.Add(row);
                }
            }

            if (type == TimeType.All)
            {
                for (int i = 0; i < 24; i++)
                {
                    for (int j = 0; j < 60; j += 15)
                    {
                        DataRow row = timeTable.NewRow();
                        row["TimeType"] = type.ToString();
                        row["Time"]     = i.ToString("d2") + ":" + j.ToString("d2") + ":00";
                        timeTable.Rows.Add(row);
                    }
                }
            }

            return(timeTable);
        }
    // returns the time localization key for Medium format time
    private string GetLocalizationMediumKey(TimeType timeType, bool plural, bool useAbbreviated = true)
    {
        if (plural)
        {
            switch (timeType)
            {
            case TimeType.Moment:
                return("MOMENTS_AGO");

            case TimeType.Minute:
                return(useAbbreviated ? "MINUTES_AGO_ABBREVIATED" : "MINUTES_AGO");

            case TimeType.Hour:
                return(useAbbreviated ? "HOURS_AGO_ABBREVIATED" : "HOURS_AGO");

            case TimeType.Day:
                return("DAYS_AGO");

            case TimeType.Second:
                return(useAbbreviated ? "SECONDS_AGO_ABBREVIATED" : "SECONDS_AGO");

            default:
                UnityEngine.Debug.LogWarning("Unknown TimeType: " + timeType.ToString());
                return("");
            }
        }
        else
        {
            switch (timeType)
            {
            case TimeType.Moment:
                return("MOMENTS_AGO");

            case TimeType.Minute:
                return(useAbbreviated ? "MINUTE_AGO_ABBREVIATED" : "MINUTE_AGO");

            case TimeType.Hour:
                return(useAbbreviated ? "HOUR_AGO_ABBREVIATED" : "HOUR_AGO");

            case TimeType.Day:
                return("DAY_AGO");

            case TimeType.Second:
                return(useAbbreviated ? "SECOND_AGO_ABBREVIATED" : "SECOND_AGO");

            default:
                UnityEngine.Debug.LogWarning("Unknown TimeType: " + timeType.ToString());
                return("");
            }
        }
    }
Пример #3
0
        public ConverterPage(TimeType from, TimeType to)
            : this()
        {
            this.from = from;
            this.to   = to;

            FromType.Text = from.ToString();
        }
Пример #4
0
        public void Alter(Content content, DateTime dateTime, TimeType timeType)
        {
            //在Content之外封装一个方法,可以修改Content的CreateTime和PublishTime
            Type      type = typeof(Content);
            FieldInfo fieldInfo;

            fieldInfo = type.GetField(timeType.ToString(), BindingFlags.NonPublic | BindingFlags.Instance);
            fieldInfo.SetValue(timeType, dateTime);
        }
        private void WriteLogs(string callerAcctNum, LogType logType, ServiceLogLevel logLevel, string connectorName,
                               string connectorVersion, string docCode,
                               string operation, string serviceUrl, string source, int lineCount, EventBlock eventBlock,
                               string functionName, TimeType timeType, string licenseKey, string message, Boolean writeToLocalFile, Boolean writeToLogEntries, string folderPath)
        {
            try
            {
                string msg = string.Empty;
                if (message == string.Empty)
                {
                    msg = string.Format("LINECOUNT - {0} :: {1} : {2} - {3}",
                                        lineCount,
                                        (eventBlock == EventBlock.InternalFunction) ? functionName : eventBlock.ToString(),
                                        timeType.ToString(),
                                        DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz")
                                        );
                }
                else
                {
                    msg = message;
                }

                string logMessage = string.Empty;
                logMessage = "[";
                logMessage = logMessage + "{\"" + "CallerAcctNum" + "\"" + ":" + "\"" + callerAcctNum + "\"}";
                logMessage = logMessage + "{\"" + "LogType" + "\"" + ":" + "\"" + GetLogTypeAsString(logType) + "\"}";
                logMessage = logMessage + "{\"" + "LogLevel" + "\"" + ":" + "\"" + GetLogLevelAsString(logLevel) + "\"}";
                logMessage = logMessage + "{\"" + "ConnectorName" + "\"" + ":" + "\"" + connectorName + "\"}";
                logMessage = logMessage + "{\"" + "ConnectorVersion" + "\"" + ":" + "\"" + connectorVersion + "\"}";
                logMessage = logMessage + "{\"" + "Operation" + "\"" + ":" + "\"" + operation + "\"}";
                logMessage = logMessage + "{\"" + "ServiceURL" + "\"" + ":" + "\"" + serviceUrl + "\"}";
                logMessage = logMessage + "{\"" + "Source" + "\"" + ":" + "\"" + source + "\"}";
                logMessage = logMessage + "{\"" + "DocCode" + "\"" + ":" + "\"" + docCode + "\"}";
                logMessage = logMessage + "{\"" + "Message" + "\"" + ":" + "\"" + msg + "\"}";
                logMessage = logMessage + "]";

                LogToLogEntries(logMessage);
            }
            catch (Exception ex)
            {
                LogMessages("-----------------------------------------");
                LogMessages("Error while writing logs ");
                LogMessages(ex.Message);
                LogMessages(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    LogMessages(ex.InnerException.ToString());
                }
            }
        }
Пример #6
0
        public static string GetTimeTypeText(TimeType tt)
        {
            switch (tt)
            {
            case TimeType.RealSunTime:
                return(localize.TimeType_RealSunTime);

            case TimeType.MiddleSunTime:
                return(localize.TimeType_MiddleSunTime);

            case TimeType.TimeZoneTime:
                return(localize.TimeType_TimeZoneTime);
            }
            return(tt.ToString());
        }
Пример #7
0
        public String GetTimeFieldAndOption(String fieldName, TimeType type = TimeType.DATETIME, Boolean isNotNull = false, String Default = "")
        {
            String field = fieldName;

            field += " " + type.ToString();
            if (isNotNull)
            {
                field += " NOT NULL";          //숫자형은 무조건 not null이다.
            }
            if (isNotNull && Default != null && Default.Length > 0)
            {
                field += " DEFAULT '" + Default + "'";
            }


            return(field);
        }
Пример #8
0
        public JobBase()
        {
            bool hasError = false;

            switch (TimeType)
            {
            case TimeType.Interval:
                hasError = HasError <long?>(ref m_IntervalSeconds);
                break;

            case TimeType.Hour:
            case TimeType.Day:
                hasError = HasError <TimeSpan?>(ref m_ExecuteTime);
                break;

            case TimeType.Week:
                hasError = HasError <DayOfWeek?>(ref m_DayOfWeek);
                if (hasError == false)
                {
                    hasError = HasError <TimeSpan?>(ref m_ExecuteTime);
                }
                break;

            case TimeType.Month:
                hasError = HasError <TimeSpan?>(ref m_ExecuteTime);
                break;

            case TimeType.Year:
                hasError = HasError <int?>(ref m_Month);
                if (hasError == false)
                {
                    hasError = HasError <TimeSpan?>(ref m_ExecuteTime);
                }
                break;

            default: break;
            }

            if (hasError)
            {
                throw new Exception(@"任务“" + Type + @"”还未设置执行时间或者执行时间不合法;
该任务执行时间类型是:" + TimeType.ToString() + ",请检查SetTime()方法。");
            }
        }
    /// **** Time methods moved below, because their reliance upon LocalizationManager creates
    /// **** dependency loops requiring much framework code to be located in the main assembly instead of
    /// **** the Plugins assembly. We may wish to move this to another class at some point.


    /// <summary>
    /// Converts a time in seconds to a relative time string, describing how long ago something occurred in human-readable terms
    /// </summary>
    /// <param name="seconds">The length of time to describe in seconds</param>
    /// <param name="localizationKeySuffix">The suffix for the localization key used as a template for the construted string</param>
    /// <param name="substituteMomentsAgo">Flag indicating that small times should be replaced by "moments ago"</param>
    /// <returns>Human-readable string describing how long ago something occurred (assuming seconds ended now)</returns>
    public string RelativeTimeString(long seconds, string localizationKeySuffix = "", bool substituteMomentsAgo = true)
    {
        long     timeValue = TimeUtil.RelativeTimeFloorValue(seconds);
        TimeType timeType  = TimeUtil.RelativeTimeType(seconds, substituteMomentsAgo);

        // Moment type times do not have a value and are always plural
        if (timeType == TimeType.Moment && substituteMomentsAgo)
        {
            return(Localize("MOMENTS_AGO"));
        }

        // Singular form
        string timeTypeLocalizationString = timeType.ToString().ToUpper();

        // Use plural form
        if (timeValue != 1)
        {
            timeTypeLocalizationString += "S";
        }

        // Gets the appropriate singular or plural form (example: SECONDS_AGO) and replaces the number string with the actual value
        return(Localize(timeTypeLocalizationString + localizationKeySuffix).Replace("[number]", timeValue.ToString(CultureInfo.InvariantCulture)));
    }
Пример #10
0
 /// <summary>
 /// Initialises a new instance of the <see cref="PointsTableRowViewModel"/> class.
 /// </summary>
 /// <param name="key">entry key</param>
 /// <param name="name">name of the athlete</param>
 /// <param name="pb">athlete's personal best</param>
 /// <param name="points">total number of points scored</param>
 /// <param name="finishingPoints">number of points scored by finishing an event</param>
 /// <param name="positionPoints">number of points scored through event position</param>
 /// <param name="bestPoints">number of points scored by improving on the season best time</param>
 /// <param name="raceNumber">athlete's number</param>
 /// <param name="numberOfRuns">number of runs started</param>
 /// <param name="averagePoints">average number of points scored per event</param>
 /// <param name="sb">athlete's season best</param>
 public PointsTableRowViewModel(
     int key,
     string name,
     TimeType pb,
     int points,
     int finishingPoints,
     int positionPoints,
     int bestPoints,
     string raceNumber,
     int numberOfRuns,
     string averagePoints,
     TimeType sb)
     : base(key, name)
 {
     this.personalBest    = pb.ToString();
     this.points          = points;
     this.finishingPoints = finishingPoints;
     this.positionPoints  = positionPoints;
     this.bestPoints      = bestPoints;
     this.RaceNumber      = raceNumber;
     this.numberOfRuns    = numberOfRuns;
     this.averagePoints   = averagePoints;
     this.seasonBest      = sb.ToString();
 }
Пример #11
0
        private void Load()
        {
            TaskControl_Head = Db.TaskControl_Heads
                               .SingleOrDefault(x => x.Domain == TaskControlDomain);
            if (TaskControl_Head == default(TaskControl_Head))
            {            //Ha még nem volt ilyen, akkor létrehozom
                TaskControl_Head = new TaskControl_Head()
                {
                    Domain   = TaskControlDomain,
                    TimeUnit = TimeUnit,
                    TimeType = TimeType,
                };
                Db.TaskControl_Heads.Add(TaskControl_Head);

                TaskControl_Item = new TaskControl_Item()
                {
                    Code          = ItemCode,
                    Head          = TaskControl_Head,
                    DateTimeStart = ItemDateTimeStart ?? DateTime.Now,
                };
                TaskControl_Head.TaskControl_Items.Add(TaskControl_Item);
            }
            else
            {            //Ha megtaláltam, ellenőrzöm a beállításait, megkeresem tci-t
                if (TaskControl_Head.TimeUnit != TimeUnit)
                {
                    throw new Exception($"TaskControl.Load hiba {TaskControl_Head.TimeUnit.ToString()} != {TimeUnit.ToString()}.");
                }
                if (TaskControl_Head.TimeType != TimeType)
                {
                    throw new Exception($"TaskControl.Load hiba {TaskControl_Head.TimeType.ToString()} != {TimeType.ToString()}.");
                }

                //TaskControl_Head.TaskControl_Items.Load();
                TaskControl_Item = Db.TaskControl_Items.GetData(x => { x.Code = ItemCode; x.HeadId = TaskControl_Head.Id; });

                if (ItemDateTimeStart != null)
                {
                    TaskControl_Item.DateTimeStart = ItemDateTimeStart ?? DateTime.Now;
                }
            }
        }
 private void AssertTimeType(TimeType time, string expectedValue, string message)
 {
     Assert.IsNotNull(time, message);
     Assert.AreEqual(expectedValue, time.ToString(), message);
 }
        public async Task <TransportApiResult <Journey> > PostJourney(ITokenComponent tokenComponent, TransportApiClientSettings settings, CancellationToken ct, IEnumerable <string> fareProducts, IEnumerable <string> onlyAgencies, IEnumerable <string> omitAgencies, IEnumerable <TransportMode> onlyModes, IEnumerable <TransportMode> omitModes, double startLatitude, double startLongitude, double endLatitude, double endLongitude, DateTime?time, TimeType timeType = TimeType.DepartAfter, Profile profile = Profile.ClosestToTime, int maxItineraries = 3, string exclude = null)
        {
            var result = new TransportApiResult <Journey>();

            if (maxItineraries < 1 || maxItineraries > 5)
            {
                result.Error = "Invalid value for maxItineraries. Expected a value between or including 1 and 5.";

                return(result);
            }

            var accessToken = await tokenComponent.GetAccessToken();

            if (accessToken == null)
            {
                result.Error = tokenComponent.DefaultErrorMessage;

                return(result);
            }

            string timeIso8601 = null;

            if (time != null)
            {
                timeIso8601 = time.Value.ToString("o");
            }

            JourneyInputModel jsonBody = new JourneyInputModel()
            {
                Time           = timeIso8601,
                TimeType       = timeType.ToString(),
                FareProducts   = fareProducts,
                MaxItineraries = maxItineraries,
                Profile        = profile.ToString(),
                Omit           = new JourneyOmitInputModel()
                {
                    Agencies = omitAgencies,
                    Modes    = omitModes
                },
                Only = new JourneyOnlyInputModel()
                {
                    Agencies = onlyAgencies,
                    Modes    = onlyModes
                },
                Geometry = new GeoJsonLineString()
                {
                    Type        = GeoJsonType.MultiPoint,
                    Coordinates = new List <List <string> >()
                    {
                        new List <string>()
                        {
                            startLongitude.ToString(CultureInfo.InvariantCulture), startLatitude.ToString(CultureInfo.InvariantCulture)
                        },
                        new List <string>()
                        {
                            endLongitude.ToString(CultureInfo.InvariantCulture), endLatitude.ToString(CultureInfo.InvariantCulture)
                        }
                    }
                }
            };

            using (var client = Client(settings.Timeout))
            {
                string path = "journeys";

                if (!string.IsNullOrWhiteSpace(exclude))
                {
                    path += "?exclude=" + exclude;
                }

                var request = PostRequest(path, accessToken);

                request.AddJsonBody(jsonBody);

                try
                {
                    IRestResponse <Journey> restResponse = await client.Execute <Journey>(request, ct);

                    result.StatusCode = restResponse.StatusCode;

                    if (restResponse.IsSuccess)
                    {
                        result.IsSuccess = true;
                        result.Data      = restResponse.Data;
                    }
                    else
                    {
                        result.Error = ((RestResponse)restResponse).Content;
                    }
                }
                catch (Exception e)
                {
                    result.Error = e.Message;
                }
            }

            return(result);
        }
Пример #14
0
        private void Window_Closed(object sender, EventArgs e)
        {
            Properties.Settings.Default.LastType = TimeType.ToString() ?? "Pomodoro";

            Properties.Settings.Default.Save();
        }
 public static XElement Serialize(this TimeType value, string name)
 {
     return(value != null ? new XElement(UblNames.Cbc + name, value.ToString()) : null);
 }
Пример #16
0
        private void NumberOfTimesEntry_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                decimal input  = decimal.Parse(e.NewTextValue);
                decimal result = 0;

                // convert any unit to seconds
                switch (from)
                {
                case TimeType.Nanosecond:
                    input *= 0.000000001M;
                    break;

                case TimeType.Microsecond:
                    input *= 0.000001M;
                    break;

                case TimeType.Second:
                    input *= 1M;
                    break;

                case TimeType.Minute:
                    input *= 60.0M;
                    break;

                case TimeType.Hour:
                    input *= 60.0M * 60.0M;
                    break;

                case TimeType.Day:
                    input *= 60.0M * 60.0M * 24.0M;
                    break;

                case TimeType.Week:
                    input *= 60.0M * 60.0M * 24.0M * 7.0M;
                    break;

                case TimeType.Year:
                    input *= 60.0M * 60.0M * 24.0M * 365.2425M;
                    break;

                default:
                    break;
                }

                switch (to)
                {
                case TimeType.Nanosecond:
                    result = input * 1000000000.0M;
                    break;

                case TimeType.Microsecond:
                    result = input * 1000000.0M;
                    break;

                case TimeType.Second:
                    result = input;
                    break;

                case TimeType.Minute:
                    result = input / 60.0M;
                    break;

                case TimeType.Hour:
                    result = input / 60.0M / 60.0M;
                    break;

                case TimeType.Day:
                    result = input / 60.0M / 60.0M / 24.0M;
                    break;

                case TimeType.Week:
                    result = input / 60.0M / 60.0M / 24.0M / 7.0M;
                    break;

                case TimeType.Year:
                    result = input / 60.0M / 60.0M / 24.0M / 365.2425M;
                    break;
                }

                Result.Text = ValueFormat(result) + " " + to.ToString() + "(s)";
            }
            catch (Exception ex)
            {
                Result.Text = ex.Message;
                return;
            }
        }
Пример #17
0
 protected string PrintTimeValue(double v, TimeType t)
 {
     return(t == TimeType.Time ? v.ToString() : (t == TimeType.NLaps) ? v + " Laps" : t.ToString());
 }