Esempio n. 1
0
        public string ToString(TimeFormatString format)
        {
            switch (format)
            {
            case TimeFormatString.DHMS:
                return(string.Format("{0:00} day(s) {1:00}:{2:00}:{3:00}", Remainder(TimePart.Day), Remainder(TimePart.Hour), Remainder(TimePart.Minute), Remainder(TimePart.Second)));

            case TimeFormatString.HMS:
                return(string.Format("{0:00}:{1:00}:{2:00}", Remainder(TimePart.Hour), Remainder(TimePart.Minute), Remainder(TimePart.Second)));

            case TimeFormatString.MST:
                return(string.Format("{1:00}:{2:00}.{3:000}", null, Dividend(TimePart.Minute), Remainder(TimePart.Second), Remainder(TimePart.Thousanth)));

            case TimeFormatString.HMS3:
                return(string.Format("{0:00}:{1:00}:{2:00}.{3:000}", Remainder(TimePart.Hour), Remainder(TimePart.Minute), Remainder(TimePart.Second), Remainder(TimePart.Thousanth)));

            case TimeFormatString.HMS5:
                return(string.Format("{0:00}:{1:00}:{2:00}:{3:00000}", Remainder(TimePart.Hour), Remainder(TimePart.Minute), Remainder(TimePart.Second), Remainder(TimePart.Millionth)));

            case TimeFormatString.MS:
                return(string.Format("{0:##,###,000}:{1:00}", Dividend(TimePart.Minute), Remainder(TimePart.Second)));

            case TimeFormatString.MILLISECONDS:
                return(string.Format("{0}", Milliseconds));

            case TimeFormatString.SECONDS:
            default:
                return(string.Format("{0}", Dividend(TimePart.Second)));
            }
        }
Esempio n. 2
0
        public string GetString(TimeFormatString type)
        {
            switch (type)
            {
            case TimeFormatString.DHMS:
                return(string.Format(Strings.TimeOutputFormat_01_DHMS, Day, Hour ?? Z, Minute ?? Z, Second ?? Z));

            case TimeFormatString.HMS:
                return(string.Format(Strings.TimeOutputFormat_02_HMS, Hour ?? Z, Minute ?? Z, Second ?? Z));

            case TimeFormatString.HMSF:
                return(string.Format(Strings.TimeOutputFormat_02_HMS, Hour ?? Z, Minute ?? Z, Second ?? Z, Frame ?? Z));
            }
            return("00:00");
        }
Esempio n. 3
0
        public string Calculate(TimeFormatString format)
        {
            TimeSpan tbegin = TimeBegin;
            TimeSpan tend   = TimeEnd;
            TimeSpan tlen   = TimeEnd - TimeBegin;

            string sbegin = sempty;
            string send   = sempty;
            string slen   = sempty;

            TimeEx temp = 0;

            switch (format)
            {
            case TimeFormatString.SECONDS:
                //
                temp   = TimeEx.ToMS(tbegin);
                sbegin = string.Format("{0:00}:{1:00}", temp.Minutes, temp.Seconds);
                //
                temp = TimeEx.ToMS(tend);
                send = string.Format("{0:00}:{1:00}", temp.Minutes, temp.Seconds);
                //
                temp = TimeEx.ToMS(tlen);
                slen = string.Format("{0:00}:{1:00}", temp.Minutes, temp.Seconds);
                //
                break;

            case TimeFormatString.MS:
                //
                temp   = TimeEx.ToMS(tbegin);
                sbegin = string.Format("{0:00}:{1:00}", temp.Minutes, temp.Seconds);
                temp   = TimeEx.ToMS(tend);
                send   = string.Format("{0:00}:{1:00}", temp.Minutes, temp.Seconds);
                temp   = TimeEx.ToMS(tlen);
                slen   = string.Format("{0:00}:{1:00}", temp.Minutes, temp.Seconds);
                //
                break;

            case TimeFormatString.DHMS:
                sbegin = string.Format(Strings.TimeOutputFormat_01_DHMS, tbegin);
                send   = string.Format(Strings.TimeOutputFormat_01_DHMS, tend);
                slen   = string.Format(Strings.TimeOutputFormat_01_DHMS, tlen);
                //
                break;

            case TimeFormatString.HMS:
                temp   = TimeEx.ToHMS(tbegin);
                sbegin = string.Format("{0:00}:{1:00}:{2:00}", temp.Hours, temp.Minutes, temp.Seconds);
                temp   = TimeEx.ToHMS(tend);
                send   = string.Format("{0:00}:{1:00}:{2:00}", temp.Hours, temp.Minutes, temp.Seconds);
                temp   = TimeEx.ToHMS(tlen);
                slen   = string.Format("{0:00}:{1:00}:{2:00}", temp.Hours, temp.Minutes, temp.Seconds);
                break;

            case TimeFormatString.HMSF:
                sbegin = string.Format(Strings.TimeOutputFormat_03_HMSF, tbegin);
                send   = string.Format(Strings.TimeOutputFormat_03_HMSF, tend);
                slen   = string.Format(Strings.TimeOutputFormat_03_HMSF, tlen);
                break;
            }

            //1227:42

            return(Strings.Time_Calculation_String
                   .Replace("{time1}", sbegin)
                   .Replace("{time2}", send)
                   .Replace("{difference}", slen)
                   );
        }
        protected override void Execute(CodeActivityContext eContext)
        {
            // Read Variables
            int precision = DecimalPrecision.Get(eContext);

            // Setup
            var             context        = eContext.GetExtension <IWorkflowContext>();
            var             serviceFactory = eContext.GetExtension <IOrganizationServiceFactory>();
            var             service        = serviceFactory.CreateOrganizationService(null);
            ITracingService tracer         = eContext.GetExtension <ITracingService>();


            tracer.Trace("Retrieving User Settings");
            // Read Settings
            var settings = UserSettings.GetUserSettings(service, context.UserId);

            tracer.Trace("User Settings Retrieved");


            tracer.Trace("Retrieving User Setting Attributes");
            var uilang                     = GetEntityValue <int>(tracer, settings, "uilanguageid");
            var currencyPrecision          = GetEntityValue <int>(tracer, settings, "currencydecimalprecision");
            var currencyFormatCode         = GetEntityValue <int>(tracer, settings, "currencyformatcode");
            var currencySymbol             = GetEntityValue <string>(tracer, settings, "currencysymbol");
            var numberGroupFormat          = GetEntityValue <string>(tracer, settings, "numbergroupformat");
            var negativeCurrencyFormatCode = GetEntityValue <int>(tracer, settings, "negativecurrencyformatcode");
            var negativeFormatCode         = GetEntityValue <int>(tracer, settings, "negativeformatcode");
            var decimalSymbol              = GetEntityValue <string>(tracer, settings, "decimalsymbol");
            var numberSeparator            = GetEntityValue <string>(tracer, settings, "numberseparator");
            var businessUnitId             = GetEntityValue <Guid>(tracer, settings, "businessunitid");
            var timeFormatString           = GetEntityValue <string>(tracer, settings, "timeformatstring");
            var dateFormatString           = GetEntityValue <string>(tracer, settings, "dateformatstring");
            var timeZoneCode               = GetEntityValue <int>(tracer, settings, "timezonecode");
            var localeid                   = GetEntityValue <int>(tracer, settings, "localeid");

            // Calculate Fields
            tracer.Trace("Calculating Fields");
            var uiCulture = new CultureInfo(uilang);

            var currencyFormat = NumberFormat.GetFormatString(decimalSymbol, numberSeparator,
                                                              currencyPrecision, numberGroupFormat,
                                                              negativeCurrencyFormatCode, true,
                                                              currencySymbol,
                                                              currencyFormatCode);

            var numberFormat = NumberFormat.GetFormatString(decimalSymbol, numberSeparator,
                                                            precision, numberGroupFormat,
                                                            negativeFormatCode);

            var businessUnit = new EntityReference("businessunit", businessUnitId);

            // Store Results
            tracer.Trace("Storing Results");
            Locale.Set(eContext, localeid);
            BusinessUnit.Set(eContext, businessUnit);
            CurrencySymbol.Set(eContext, currencySymbol);
            CurrencyFormatString.Set(eContext, currencyFormat);
            NumberFormatString.Set(eContext, numberFormat);
            DateFormatString.Set(eContext, dateFormatString);
            TimeFormatString.Set(eContext, timeFormatString);
            TimeZoneCode.Set(eContext, timeZoneCode);
            UILanguageCode.Set(eContext, uilang);
            UILanguageName.Set(eContext, uiCulture.DisplayName);
            UILanguageEnglishName.Set(eContext, uiCulture.EnglishName);
        }
Esempio n. 5
0
 public TimeCalc(TimeEx t1, TimeEx t2, TimeFormatString sf = TimeFormatString.HMS)
 {
     SelectedFormat = sf;
     Reset(t1, t2);
 }