public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { obj = value; DateFormatString dateFormat = (DateFormatString)Enum.Parse(typeof(DateFormatString), (string)parameter); if (dateFormat == DateFormatString.MonthAndDay) { DateTime date = (DateTime)value; return($"{CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month)} {date.Day}"); } return(value); }
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); }