private void DeployRegionalSettings(object modelHost, Web web, RegionalSettingsDefinition definition)
        {
            var settings = GetCurrentRegionalSettings(web);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = settings,
                ObjectType = typeof(RegionalSettings),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            MapRegionalSettings(settings, definition);

            //web.RegionalSettings = settings;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = settings,
                ObjectType = typeof(RegionalSettings),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });
        }
 private void MapRegionalSettings(SPRegionalSettings settings, RegionalSettingsDefinition definition)
 {
     settings.AdjustHijriDays = definition.AdjustHijriDays;
     settings.AlternateCalendarType = definition.AlternateCalendarType;
     settings.CalendarType = definition.CalendarType;
     settings.Collation = definition.Collation;
     settings.FirstDayOfWeek = definition.FirstDayOfWeek;
     settings.FirstWeekOfYear = definition.FirstWeekOfYear;
     settings.LocaleId = definition.LocaleId;
     settings.WorkDayStartHour = definition.WorkDayStartHour;
     settings.WorkDayEndHour = definition.WorkDayEndHour;
     settings.WorkDays = definition.WorkDays;
     settings.ShowWeeks = definition.ShowWeeks;
     settings.Time24 = definition.Time24;
     settings.LocaleId = definition.LocaleId;
 }
        private void MapRegionalSettings(RegionalSettings settings, RegionalSettingsDefinition definition)
        {
            // TODO, CSOM does not support any operation for RegionalSetting yet

            //settings.AdjustHijriDays = definition.AdjustHijriDays;
            //settings.AlternateCalendarType = definition.AlternateCalendarType;
            //settings.CalendarType = definition.CalendarType;
            //settings.Collation = definition.Collation;
            //settings.FirstDayOfWeek = definition.FirstDayOfWeek;
            //settings.FirstWeekOfYear = definition.FirstWeekOfYear;
            //settings.LocaleId = definition.LocaleId;
            //settings.WorkDayStartHour = definition.WorkDayStartHour;
            //settings.WorkDayEndHour = definition.WorkDayEndHour;
            //settings.WorkDays = definition.WorkDays;
            //settings.ShowWeeks = definition.ShowWeeks;
            //settings.Time24 = definition.Time24;
            //settings.LocaleId = definition.LocaleId;
        }
        private void MapRegionalSettings(SPRegionalSettings settings, RegionalSettingsDefinition definition)
        {
            if (definition.AdjustHijriDays.HasValue)
                settings.AdjustHijriDays = definition.AdjustHijriDays.Value;

            if (definition.AlternateCalendarType.HasValue)
                settings.AlternateCalendarType = definition.AlternateCalendarType.Value;

            if (definition.CalendarType.HasValue)
                settings.CalendarType = definition.CalendarType.Value;

            if (definition.Collation.HasValue)
                settings.Collation = definition.Collation.Value;

            if (definition.FirstDayOfWeek.HasValue)
                settings.FirstDayOfWeek = definition.FirstDayOfWeek.Value;

            if (definition.FirstWeekOfYear.HasValue)
                settings.FirstWeekOfYear = definition.FirstWeekOfYear.Value;

            if (definition.LocaleId.HasValue)
                settings.LocaleId = definition.LocaleId.Value;

            if (definition.WorkDayStartHour.HasValue)
                settings.WorkDayStartHour = definition.WorkDayStartHour.Value;

            if (definition.WorkDayEndHour.HasValue)
                settings.WorkDayEndHour = definition.WorkDayEndHour.Value;

            if (definition.WorkDays.HasValue)
                settings.WorkDays = definition.WorkDays.Value;

            if (definition.ShowWeeks.HasValue)
                settings.ShowWeeks = definition.ShowWeeks.Value;

            if (definition.Time24.HasValue)
                settings.Time24 = definition.Time24.Value;

            if (definition.LocaleId.HasValue)
                settings.LocaleId = definition.LocaleId.Value;
        }
        private void DeployRegionalSettings(object modelHost, Web web, RegionalSettingsDefinition definition)
        {
            var context = web.Context;

            var settings = GetCurrentRegionalSettings(web);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = settings,
                ObjectType = typeof(RegionalSettings),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            bool shouldUpdate;
            MapRegionalSettings(context, settings, definition, out shouldUpdate);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = settings,
                ObjectType = typeof(RegionalSettings),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            if (shouldUpdate)
            {
                context.AddQuery(new ClientActionInvokeMethod(settings, "Update", null));
                context.ExecuteQueryWithTrace();
            }
        }
        protected virtual void MapRegionalSettings(ClientRuntimeContext context, RegionalSettings settings, RegionalSettingsDefinition definition,
            out bool shouldUpdate)
        {
            shouldUpdate = false;

            if (!SupportSetters(settings))
                return;

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "AdjustHijriDays")
                && definition.AdjustHijriDays.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "AdjustHijriDays", definition.AdjustHijriDays.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "AlternateCalendarType")
                && definition.AlternateCalendarType.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "AlternateCalendarType", definition.AlternateCalendarType.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "CalendarType")
                && definition.CalendarType.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "CalendarType", definition.CalendarType.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "Collation")
                && definition.Collation.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "Collation", definition.Collation.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "FirstDayOfWeek")
                && definition.FirstDayOfWeek.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "FirstDayOfWeek", definition.FirstDayOfWeek.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "FirstWeekOfYear")
                && definition.FirstWeekOfYear.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "FirstWeekOfYear", definition.FirstWeekOfYear.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "LocaleId")
                && definition.LocaleId.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "LocaleId", definition.LocaleId.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "WorkDayStartHour")
                && definition.WorkDayStartHour.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "WorkDayStartHour", definition.WorkDayStartHour.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "WorkDayEndHour")
                && definition.WorkDayEndHour.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "WorkDayEndHour", definition.WorkDayEndHour.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "WorkDays")
                && definition.WorkDays.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "WorkDays", definition.WorkDays.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "ShowWeeks")
                && definition.ShowWeeks.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "ShowWeeks", definition.ShowWeeks.Value));
                shouldUpdate = true;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "Time24")
                && definition.Time24.HasValue)
            {
                context.AddQuery(new ClientActionSetProperty(settings, "Time24", definition.Time24.Value));
                shouldUpdate = true;
            }
        }
 public static ModelNode AddRegionalSettings(this ModelNode model, RegionalSettingsDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }
 public static ModelNode AddRegionalSettings(this ModelNode model, RegionalSettingsDefinition definition)
 {
     return AddRegionalSettings(model, definition, null);
 }