Ejemplo n.º 1
0
        public static UserSettings GetUserSettings()
        {

            if (OrganizationServiceProxy.UserSettings == null)
            {
                OrganizationServiceProxy.UserSettings = (UserSettings)OrganizationServiceProxy.Retrieve(UserSettings.EntityLogicalName, Page.Context.GetUserId(), new string[] { "AllColumns" });
                // Add the separator values
                UserSettings.TimeFormatString = UserSettings.TimeFormatString.Replace(":", OrganizationServiceProxy.UserSettings.TimeSeparator);
                UserSettings.DateFormatString = UserSettings.DateFormatString.Replace(@"/", OrganizationServiceProxy.UserSettings.DateSeparator);

                // We need to change the format string from CRM into the datepicker format which is:
                // mm/dd/yy   Default - mm/dd/yy
                // yy-mm-dd   ISO 8601 - yy-mm-dd
                // d M, y   Short - d M, y
                // d MM, y   Medium - d MM, y
                // DD, d MM, yy   Full - DD, d MM, yy
                // 'day' d 'of' MM 'in the year' yy   With text - 'day' d 'of' MM 'in the year' yy
                UserSettings.DateFormatString = UserSettings.DateFormatString.Replace("MM", "mm").Replace("yyyy", "UU").Replace("yy", "y").Replace("UU", "yy").Replace("M", "m");
            }

            if (OrganizationServiceProxy.OrganizationSettings == null)
            {
                string fetchXml = @"<fetch>
                                    <entity name='organization' >
                                        <attribute name='weekstartdaycode' />
                                    </entity>
                                </fetch>";

                OrganizationServiceProxy.OrganizationSettings = (OrganizationSettings)OrganizationServiceProxy.RetrieveMultiple(fetchXml).Entities[0];
            }
            return UserSettings;

        }
Ejemplo n.º 2
0
 public static DateTime UTCToLocalTimeFromSettings(DateTime UTCTime, UserSettings settings)
 {
     return UTCToLocalTime(UTCTime,
         settings.TimeZoneBias,
         settings.TimeZoneDaylightBias,
         settings.TimeZoneDaylightYear,
         settings.TimeZoneDaylightMonth,
         settings.TimeZoneDaylightDay,
         settings.TimeZoneDaylightHour,
         settings.TimeZoneDaylightMinute,
         settings.TimeZoneDaylightSecond,
         0,
         settings.TimeZoneDaylightDayOfWeek,
         settings.TimeZoneStandardBias,
         settings.TimeZoneStandardYear,
         settings.TimeZoneStandardMonth,
         settings.TimeZoneStandardDay,
         settings.TimeZoneStandardHour,
         settings.TimeZoneStandardMinute,
         settings.TimeZoneStandardSecond,
         0,
         settings.TimeZoneStandardDayOfWeek);
     
 }