Beispiel #1
0
        public ConfigModel()
        {
            /// all the objects in the class have been initialized with an empty object to avoid
            /// throwing Object reference error even in all circumstances.
            /// these objects SHOULD be initialized with some default values - possibly from web.config for worst case scenarios.

            ConfigSettings         = new List <ConfigSettingModel>();
            BasketSettings         = new BasketSettings();
            B2BSettings            = new B2BSettings();
            CatalogSettings        = new CatalogSettings();
            DomainSettings         = new DomainSettings();
            OrderSettings          = new OrderSettings();
            SearchSettings         = new SearchSettings();
            SeoSettings            = new SeoSettings();
            ShippingSettings       = new ShippingSettings();
            SocialSettings         = new SocialSettings();
            RecommendationSettings = new RecommendationSettings();
            Currencies             = new List <CurrencyModel>();
            ShippingCountries      = new List <CountryModel>();
            BillingCountries       = new List <CountryModel>();
            Languages        = new List <LanguageModel>();
            RegionalSettings = new RegionalSettings();
            ReviewSettings   = new List <ProductReviewSection>();
            GeoLocators      = new List <GeoLocatorModel>();
            Snippets         = new List <SnippetModel>();
            FeatureToggles   = new FeatureToggleSettings();
        }
Beispiel #2
0
        protected virtual bool SupportSetters(RegionalSettings settings)
        {
            // should have at least one setter
            // Update() is there, but setters aren't

            var supportedRuntime = ReflectionUtils.HasMethod(settings, "Update") &&
                                   ReflectionUtils.HasPropertyPublicSetter(settings, "AdjustHijriDays");

            return(supportedRuntime);
        }
        protected virtual bool SupportSetters(RegionalSettings settings)
        {
            // should have at least one setter
            // Update() is there, but setters aren't

            var supportedRuntime = ReflectionUtils.HasMethod(settings, "Update")
                && ReflectionUtils.HasPropertyPublicSetter(settings, "AdjustHijriDays");

            return supportedRuntime;
        }
        protected virtual bool SupportSetters(RegionalSettings settings)
        {
            // should have at least one setter
            // Update() is there, but setters aren't

            var supportedRuntime = ReflectionUtils.HasMethod(settings, "Update") &&
                                   ReflectionUtils.HasPropertyPublicSetter(settings, "AdjustHijriDays");

            if (!supportedRuntime)
            {
                TraceService.Critical((int)LogEventId.ModelProvisionCoreCall,
                                      "CSOM runtime doesn't have RegionalSettings.Update() methods support. Update CSOM runtime to a new version. RegionalSettings provision is skipped");
            }

            return(supportedRuntime);
        }
        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(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;
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // define initial script, needed to render the chrome control
            string script = @"
            function chromeLoaded() {
                $('body').show();
            }

            //function callback to render chrome after SP.UI.Controls.js loads
            function renderSPChrome() {
                //Set the chrome options for launching Help, Account, and Contact pages
                var options = {
                    'appTitle': document.title,
                    'onCssLoaded': 'chromeLoaded()'
                };

                //Load the Chrome Control in the divSPChrome element of the page
                var chromeNavigation = new SP.UI.Controls.Navigation('divSPChrome', options);
                chromeNavigation.setVisible(true);
            }";

            //register script in page
            Page.ClientScript.RegisterClientScriptBlock(typeof(Default), "BasePageScript", script, true);

            // Set some default values
            //lblBasePath.Text = Request["SPHostUrl"].Substring(0, 8 + Request["SPHostUrl"].Substring(8).IndexOf("/")) + "/sites/";
            if (Request["RequestorSite"] != null)
            {
                lblBasePath.Text = Request["RequestorSite"] + "/";
            }
            else
            {
                lblBasePath.Text = Request["SPHostUrl"] + "/";
            }
            //templateSiteLink.Text = ConfigurationManager.AppSettings["TemplateSiteUrl"];
            //templateSiteLink.NavigateUrl = ConfigurationManager.AppSettings["TemplateSiteUrl"];

            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (ClientContext ctx = spContext.CreateUserClientContextForSPHost())
            {
                // Get time zones from server side
                RegionalSettings   reg   = ctx.Web.RegionalSettings;
                TimeZoneCollection zones = ctx.Web.RegionalSettings.TimeZones;
                ctx.Load(reg);
                ctx.Load(zones);
                ctx.ExecuteQuery();
            }

            // Set default values for the controls
            if (!Page.IsPostBack)
            {
                //RecordedPanel.Visible = false;
                //RequestPanel.Visible = true;
                processViews.ActiveViewIndex = 0;
                processViews.SetActiveView(RequestView);
                // Set template options - could also come from Azure or from some other solution, now hard coded.
                ddlTemplate.Items.Add(new System.Web.UI.WebControls.ListItem("Community", "CommunityTemplate.xml:COMMUNITY#0"));

                ddlTemplate.SelectedIndex = 0;
            }
        }
        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;
            }

            if (ReflectionUtils.HasPropertyPublicSetter(settings, "TimeZone") &&
                definition.TimeZoneId.HasValue)
            {
                var targetZone = settings.TimeZones
                                 .ToArray()
                                 .FirstOrDefault(z => z.Id == definition.TimeZoneId.Value);

                if (targetZone == null)
                {
                    throw new SPMeta2Exception(
                              string.Format("Cannot find TimeZone by ID:[{0}]", definition.TimeZoneId));
                }

                context.AddQuery(new ClientActionSetProperty(settings, "TimeZone", targetZone));
                shouldUpdate = true;
            }
        }
Beispiel #9
0
        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;
            }
        }
Beispiel #10
0
 internal SPRegionalInfo(RegionalSettings regionalSettings)
 {
     if (regionalSettings == null)
     {
         throw new ArgumentNullException(nameof(regionalSettings));
     }
     if (regionalSettings.IsPropertyAvailable("AM"))
     {
         this.AM = regionalSettings.AM;
     }
     if (regionalSettings.IsPropertyAvailable("AdjustHijriDays"))
     {
         this.AdjustHijriDays = regionalSettings.AdjustHijriDays;
     }
     if (regionalSettings.IsPropertyAvailable("AlternateCalendarType"))
     {
         this.AlternateCalendarType = regionalSettings.AlternateCalendarType;
     }
     if (regionalSettings.IsPropertyAvailable("CalendarType"))
     {
         this.CalendarType = regionalSettings.CalendarType;
     }
     if (regionalSettings.IsPropertyAvailable("Collation"))
     {
         this.Collation = regionalSettings.Collation;
     }
     if (regionalSettings.IsPropertyAvailable("CollationLCID"))
     {
         this.CollationLCID = regionalSettings.CollationLCID;
     }
     if (regionalSettings.IsPropertyAvailable("DateFormat"))
     {
         this.DateFormat = regionalSettings.DateFormat;
     }
     if (regionalSettings.IsPropertyAvailable("DateSeparator"))
     {
         this.DateSeparator = regionalSettings.DateSeparator;
     }
     if (regionalSettings.IsPropertyAvailable("DecimalSeparator"))
     {
         this.DecimalSeparator = regionalSettings.DecimalSeparator;
     }
     if (regionalSettings.IsPropertyAvailable("DigitGrouping"))
     {
         this.DigitGrouping = regionalSettings.DigitGrouping;
     }
     if (regionalSettings.IsPropertyAvailable("FirstDayOfWeek"))
     {
         this.FirstDayOfWeek = regionalSettings.FirstDayOfWeek;
     }
     if (regionalSettings.IsPropertyAvailable("FirstWeekOfYear"))
     {
         this.FirstWeekOfYear = regionalSettings.FirstWeekOfYear;
     }
     if (regionalSettings.IsPropertyAvailable("IsEastAsia"))
     {
         this.IsEastAsia = regionalSettings.IsEastAsia;
     }
     if (regionalSettings.IsPropertyAvailable("IsRightToLeft"))
     {
         this.IsRightToLeft = regionalSettings.IsRightToLeft;
     }
     if (regionalSettings.IsPropertyAvailable("IsUIRightToLeft"))
     {
         this.IsUIRightToLeft = regionalSettings.IsUIRightToLeft;
     }
     if (regionalSettings.IsPropertyAvailable("ListSeparator"))
     {
         this.ListSeparator = regionalSettings.ListSeparator;
     }
     if (regionalSettings.IsPropertyAvailable("LocaleId"))
     {
         this.LocaleId = regionalSettings.LocaleId;
     }
     if (regionalSettings.IsPropertyAvailable("NegNumberMode"))
     {
         this.NegNumberMode = regionalSettings.NegNumberMode;
     }
     if (regionalSettings.IsPropertyAvailable("NegativeSign"))
     {
         this.NegativeSign = regionalSettings.NegativeSign;
     }
     if (regionalSettings.IsPropertyAvailable("PM"))
     {
         this.PM = regionalSettings.PM;
     }
     if (regionalSettings.IsPropertyAvailable("PositiveSign"))
     {
         this.PositiveSign = regionalSettings.PositiveSign;
     }
     if (regionalSettings.IsPropertyAvailable("ShowWeeks"))
     {
         this.ShowWeeks = regionalSettings.ShowWeeks;
     }
     if (regionalSettings.IsPropertyAvailable("ThousandSeparator"))
     {
         this.ThousandSeparator = regionalSettings.ThousandSeparator;
     }
     if (regionalSettings.IsPropertyAvailable("Time24"))
     {
         this.Time24 = regionalSettings.Time24;
     }
     if (regionalSettings.IsPropertyAvailable("TimeMarkerPosition"))
     {
         this.TimeMarkerPosition = regionalSettings.TimeMarkerPosition;
     }
     if (regionalSettings.IsPropertyAvailable("TimeSeparator"))
     {
         this.TimeSeparator = regionalSettings.TimeSeparator;
     }
     if (regionalSettings.IsPropertyAvailable("WorkDayEndHour"))
     {
         this.WorkDayEndHour = regionalSettings.WorkDayEndHour;
     }
     if (regionalSettings.IsPropertyAvailable("WorkDayStartHour"))
     {
         this.WorkDayStartHour = regionalSettings.WorkDayStartHour;
     }
     if (regionalSettings.IsPropertyAvailable("WorkDays"))
     {
         this.WorkDays = regionalSettings.WorkDays;
     }
     if (regionalSettings.TimeZone.IsPropertyAvailable("Information"))
     {
         this.TimeZoneBias = regionalSettings.TimeZone.Information.Bias;
     }
 }
        public ProjectOnlineAccessService(string projectOnlineUrl, string projectOnlineUserName,
                                          string projectOnlinePassword, bool isOnline, Guid winServiceIterationUid)
        {
            logger.LogAndSendMessage(null, "ProjectOnlineAccessService START",
                                     null, winServiceIterationUid,
                                     $"ProjectOnlineAccessService START ProjectOnlineUrl: {ProjectOnlineUrl}; " +
                                     $"projectOnlineUserName: {projectOnlineUserName}; projectOnlinePassword: {projectOnlinePassword}; " +
                                     $"isOnline: {isOnline};",
                                     false, null);

            ProjectOnlineUrl            = projectOnlineUrl;
            this.isOnline               = isOnline;
            this.winServiceIterationUid = winServiceIterationUid;
            var securePassword = new SecureString();

            foreach (char c in projectOnlinePassword)
            {
                securePassword.AppendChar(c);
            }
            if (isOnline)
            {
                ProjectContext = new ProjectContext(ProjectOnlineUrl)
                {
                    Credentials = new SharePointOnlineCredentials(projectOnlineUserName, securePassword)
                };
            }
            else
            {
                ProjectContext = new ProjectContext(ProjectOnlineUrl)
                {
                    Credentials = new NetworkCredential(projectOnlineUserName, projectOnlinePassword)
                };
            }
            ProjectContext.RequestTimeout = RequestTimeout;
            ProjectContext.PendingRequest.RequestExecutor.WebRequest.Timeout          = RequestTimeout;
            ProjectContext.PendingRequest.RequestExecutor.WebRequest.ReadWriteTimeout = RequestTimeout;

            //SPClientCallableSettings

            //TODO:!!!!!!!!!!!!!
            //The underlying connection was closed: A connection that was expected to be kept alive was closed by the server." >>
            //"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
            //In my case, this solved the problem: **System.Net.ServicePointManager.Expect100Continue = false; **
            ServicePointManager.Expect100Continue = false;

            //One more solution. Add into Register
            //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ DWORD SynAttackProtect 00000000

            Web web = ProjectContext.Web;
            RegionalSettings regSettings = web.RegionalSettings;

            ProjectContext.Load(web);
            ProjectContext.Load(regSettings); //To get regional settings properties
            Microsoft.SharePoint.Client.TimeZone projectOnlineTimeZone = regSettings.TimeZone;
            ProjectContext.Load(projectOnlineTimeZone);
            //To get the TimeZone propeties for the current web region settings
            ExecuteQuery();
            TimeSpan projectOnlineUtcOffset =
                TimeSpan.Parse(projectOnlineTimeZone.Description.Substring(4,
                                                                           projectOnlineTimeZone.Description.IndexOf(")", StringComparison.Ordinal) - 4));
            ReadOnlyCollection <TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();

            ProjectOnlineTimeZoneInfo =
                timeZones.FirstOrDefault(x => x.BaseUtcOffset == projectOnlineUtcOffset);
            CurrentDateForCompare = ProjectOnlineTimeZoneInfo != null
                ? TimeZoneInfo.ConvertTime(DateTime.Now, ProjectOnlineTimeZoneInfo)
                : DateTime.Now;

            logger.LogAndSendMessage(null, "ProjectOnlineAccessService END",
                                     null, winServiceIterationUid, "ProjectOnlineAccessService END", false, null);
        }
        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;
            }
        }
Beispiel #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // define initial script, needed to render the chrome control
            string script = @"
            function chromeLoaded() {
                $('body').show();
            }

            //function callback to render chrome after SP.UI.Controls.js loads
            function renderSPChrome() {
                //Set the chrome options for launching Help, Account, and Contact pages
                var options = {
                    'appTitle': document.title,
                    'onCssLoaded': 'chromeLoaded()'
                };

                //Load the Chrome Control in the divSPChrome element of the page
                var chromeNavigation = new SP.UI.Controls.Navigation('divSPChrome', options);
                chromeNavigation.setVisible(true);
            }";

            //register script in page
            Page.ClientScript.RegisterClientScriptBlock(typeof(Default), "BasePageScript", script, true);

            // Set some default values
            lblBasePath.Text             = Request["SPHostUrl"].Substring(0, 8 + Request["SPHostUrl"].Substring(8).IndexOf("/")) + "/sites/";
            templateSiteLink.Text        = ConfigurationManager.AppSettings["TemplateSiteUrl"];
            templateSiteLink.NavigateUrl = ConfigurationManager.AppSettings["TemplateSiteUrl"];

            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (ClientContext ctx = spContext.CreateUserClientContextForSPHost())
            {
                // Get time zones from server side
                RegionalSettings   reg   = ctx.Web.RegionalSettings;
                TimeZoneCollection zones = ctx.Web.RegionalSettings.TimeZones;
                ctx.Load(reg);
                ctx.Load(zones);
                ctx.ExecuteQuery();

                foreach (var item in zones)
                {
                    timeZone.Items.Add(new System.Web.UI.WebControls.ListItem(item.Description, item.Id.ToString()));
                }

                // Add wanted languages for creation list
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1033).DisplayName, "1033"));
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1035).DisplayName, "1035"));
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1036).DisplayName, "1036"));
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1053).DisplayName, "1053"));
            }

            // Set default values for the controls
            if (!Page.IsPostBack)
            {
                // Set template options - could also come from Azure or from some other solution, now hard coded.
                listTemplates.Items.Add(new System.Web.UI.WebControls.ListItem("Team", "ContosoTemplate-01.xml"));
                listTemplates.Items.Add(new System.Web.UI.WebControls.ListItem("Simplistic", "ContosoTemplate-02.xml"));
                listTemplates.Items.Add(new System.Web.UI.WebControls.ListItem("Oslo Team", "ContosoTemplate-03.xml"));
                listTemplates.SelectedIndex = 0;

                txtUrl.Text              = DateTime.Now.Ticks.ToString();
                txtStorage.Text          = "100";
                timeZone.SelectedValue   = "10";
                listTemplates.Enabled    = false;
                templateSiteLink.Enabled = true;
            }
        }
 public void Init()
 {
     instance = new RegionalSettings();
 }
Beispiel #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // define initial script, needed to render the chrome control
            string script = @"
            function chromeLoaded() {
                $('body').show();
            }

            //function callback to render chrome after SP.UI.Controls.js loads
            function renderSPChrome() {
                //Set the chrome options for launching Help, Account, and Contact pages
                var options = {
                    'appTitle': document.title,
                    'onCssLoaded': 'chromeLoaded()'
                };

                //Load the Chrome Control in the divSPChrome element of the page
                var chromeNavigation = new SP.UI.Controls.Navigation('divSPChrome', options);
                chromeNavigation.setVisible(true);
            }";

            //register script in page
            Page.ClientScript.RegisterClientScriptBlock(typeof(Default), "BasePageScript", script, true);


            listTemplates.Items.Add(new System.Web.UI.WebControls.ListItem("Team", "STS#0"));
            listTemplates.Items.Add(new System.Web.UI.WebControls.ListItem("Organization", "STS#0"));
            listTemplates.Items.Add(new System.Web.UI.WebControls.ListItem("Group", "STS#0"));
            listTemplates.SelectedIndex = 0;

            lblBasePath.Text = Request["SPHostUrl"].Substring(0, 8 + Request["SPHostUrl"].Substring(8).IndexOf("/")) + "/sites/";

            txtStorage.Text = "100";

            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (ClientContext ctx = spContext.CreateUserClientContextForSPHost())
            {
                // Get time zones from server side
                RegionalSettings   reg   = ctx.Web.RegionalSettings;
                TimeZoneCollection zones = ctx.Web.RegionalSettings.TimeZones;
                ctx.Load(reg);
                ctx.Load(zones);
                ctx.ExecuteQuery();

                foreach (var item in zones)
                {
                    timeZone.Items.Add(new System.Web.UI.WebControls.ListItem(item.Description, item.Id.ToString()));
                }

                // Add wanted languages for creation list
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1033).DisplayName, "1033"));
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1035).DisplayName, "1035"));
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1036).DisplayName, "1036"));
                language.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(1053).DisplayName, "1053"));

                if (!Page.IsPostBack)
                {
                    txtUrl.Text            = Guid.NewGuid().ToString().Replace("-", "");
                    timeZone.SelectedValue = "10";
                }
            }
        }