Exemplo n.º 1
0
        public static TimeZoneInfo ToTimeZoneInfo(this TimeZoneCode zone)
        {
            switch (zone)
            {
            case TimeZoneCode.Utc:
                return(TimeZoneInfo.Utc);

            case TimeZoneCode.Central:
                return(TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));

            case TimeZoneCode.Mountain:
                return(TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time"));

            case TimeZoneCode.Pacific:
                return(TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"));

            case TimeZoneCode.Arizona:
                return(TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time"));

            case TimeZoneCode.Alaska:
                return(TimeZoneInfo.FindSystemTimeZoneById("Alaskan Standard Time"));

            case TimeZoneCode.Hawaii:
                return(TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time"));

            case TimeZoneCode.Indiana:
                return(TimeZoneInfo.FindSystemTimeZoneById("US Eastern Standard Time"));

            case TimeZoneCode.Eastern:
            default:
                return(TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
            }
        }
Exemplo n.º 2
0
        public virtual byte[] Serialize()
        {
            if ((TimeZoneCode ?? "").Trim().ToUpper() == "TEST")
            {
                return(Encoding.ASCII.GetBytes("tEsT"));
            }
            var rv = new List <byte>();

            rv.Add(Version);
            rv.Add(0);
            var payload = Encoding.ASCII.GetBytes(TimeZoneCode.ToString());

            rv.AddRange(payload);;
            rv[1] = Convert.ToByte(payload.Length); // Total length of payload only
            byte cs = ChecksumSeed;

            foreach (byte b in rv)
            {
                cs ^= b;
            }
            rv.Add(cs);
            return(rv.ToArray());
        }
        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);
        }
Exemplo n.º 4
0
 public override int GetHashCode()
 {
     return(Code.GetHashCode() ^ TimeZoneCode.GetHashCode() ^ TerritoryCode.GetHashCode());
 }