public void RunInAppStartInitTest() { ConfigServiceClient ci = new ConfigServiceClient(); var r = ci.RunInAppStartInit(); Assert.IsTrue(r != null); Assert.IsTrue(r.Result); }
public void GetComponentConfigTest() { ConfigServiceClient ci = new ConfigServiceClient(); ci.RunInAppStartInit(); var r = ci.GetComponentConfig(1001); Assert.IsTrue(r != null); Assert.IsTrue(r.ComponentId == 1001); }
public ClientIntegrationTests(ClientIntegrationTestsFixture fixture) { this._fixture = fixture; this.Client = ConfigServiceClientFactory.GetDefaultServiceClient(new List <string>() { "Test" }); //extra safety! if (!_fixture.RunTheseTests) { Client = null; } }
public object LoadContents(ConfigServiceClient cfg, RepoServiceClient repo) { if (cfg == null) throw new ArgumentNullException(); StringBuilder ribbonResult = new StringBuilder(); ribbonResult.Append("<script type='text/javascript'>").AppendLine(); //ribbonResult.Append("make sure createButtons function is loaded") ribbonResult.Append("var controlProperties = [];").AppendLine(); var cfgRibbons = GetConfigGuidList(cfg); string hideElements = ""; foreach (Guid cfgId in cfgRibbons) { string c = cfg.GetBranchJson(cfgId, this.Category()); if (c != null) { JObject jc = JObject.Parse(c); if (jc["error"] != null) { ribbonResult.Append("console.error('problem loading ribbon config: " + jc["error"] + "');"); continue; } //List<string> jControlProperties = jc["controlProperties"].ToObject<List<string>>(); JToken jControlProperties = jc["controlProperties"]; hideElements = (jc["hideSelector"] ?? "").ToString(); foreach (JObject controlProperty in jControlProperties) { string json = controlProperty.ToString(); ribbonResult.Append("controlProperties.push("); ribbonResult.Append(json); ribbonResult.Append(");").AppendLine(); } } } ribbonResult.Append("EnsureScriptFunc('createButtons.js', 'createButtons', function() {" + "EnsureScriptFunc('ribbon', 'SP.Ribbon.PageManager', function() {" + "if(controlProperties.length!=0)" + "createButtons(controlProperties);" + (!string.IsNullOrEmpty(hideElements) ? ("$('" + hideElements.Replace("'", "\\'") + "').hide();") : "") + "});" + "});").AppendLine(); ribbonResult.Append("</script>"); return ribbonResult.ToString(); }
public void GetConfigList() { var request = new GetAppConfigRequest(); request.AppId = 100002003; request.FileName = "app.properties"; var client = new ConfigServiceClient(); var actual = client.GetAppConfig(request); Assert.IsNotNull(actual); Assert.IsNotNull(actual.SavoryConfig); Assert.IsNotNull(actual.SavoryConfig.Properties); Assert.AreNotEqual(0, actual.SavoryConfig.Properties.Count); }
public ConfigGuidList GetConfigGuidList(ConfigServiceClient cfg) { var filters = new Dictionary<ConfigFilterType, string> { { ConfigFilterType.App, this.Category() }, { ConfigFilterType.Url, this.Context.Request.RawUrl } }; if (SPContext.Current.List != null) { filters.Add(ConfigFilterType.ListType, SPContext.Current.List.BaseType.ToString()); } if (SPContext.Current.ListItem != null) { filters.Add(ConfigFilterType.ContentType, SPContext.Current.ListItem.ContentTypeId.ToString()); } return cfg.Filter(SPContext.Current.Web, filters); }
protected void Page_Load(object sender, EventArgs e) { if (SPContext.Current == null) return; var log = NaverticaLog.GetInstance(); using (new SPMonitoredScope("PageHead")) { try { SPSite site = SPContext.Current.Site; ConfigServiceClient cfg = new ConfigServiceClient(site); RepoServiceClient repo = new RepoServiceClient(site); if (this.Request.QueryString["Reset"].ToBool()) { cfg.Reset(site.Url); repo.Reset(); PluginHost.Reset(); } IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent(site); IEnumerable<IPageHead> executeInterfaces = serviceLocator.GetAllInstances<IPageHead>(); foreach (IPageHead pageInterface in executeInterfaces) { ModulesLiteral.Text += "<!-- NVR PageHead " + pageInterface.Category() + " start -->\n"; using (new SPMonitoredScope(pageInterface.Category())) { ModulesLiteral.Text += (string)pageInterface.LoadContents(cfg, repo); } ModulesLiteral.Text += "<!-- NVR PageHead " + pageInterface.Category() + " END -->\n"; } } catch (Exception ex) { log.LogException(ex); } } }
public object LoadContents(ConfigServiceClient cfg, RepoServiceClient repo) { if (cfg == null || repo == null) throw new ArgumentNullException(); StringBuilder scriptsResult = new StringBuilder(); var cfgScripts = GetConfigGuidList(cfg); foreach (Guid cfgId in cfgScripts) { PageHeadConfig c = (PageHeadConfig)cfg.GetBranch<PageHeadConfig>(cfgId, this.Category()); if (c != null) { string libFilePaths = ""; foreach (string scriptFileName in c.LibLinks) { if (string.IsNullOrWhiteSpace(scriptFileName)) continue; string scriptName = scriptFileName.ToLowerInvariant().EndsWith(".js") ? scriptFileName : scriptFileName + ".js"; libFilePaths += scriptName + ";"; } if (!string.IsNullOrWhiteSpace(libFilePaths)) scriptsResult.Append("<script type='text/javascript' src='/_layouts/Navertica.SPTools/GetScript.aspx?FilePaths=").Append(libFilePaths).Append("'></script>").AppendLine(); // v SiteConfigu mohou byt jen jmena souboru z adresare dane aplikace v SiteScripts, // nikdy primo kod, ktery by se vkladal do stranky (mozna u javascriptu by to tak byt nemuselo) foreach (string scriptFileName in c.ScriptLinks) { if (string.IsNullOrWhiteSpace(scriptFileName)) continue; /*string scriptName = scriptFileName.ToLowerInvariant().EndsWith(".js") ? scriptFileName : scriptFileName + ".js";*/ string scriptBody = repo.GetJavaScript(scriptFileName); scriptsResult.Append(scriptBody); } } } return scriptsResult.ToString(); }
private static decimal GetConfigData(string languageCode, string countryCode, string customerSet, string orderCode, int quantity) { try { var service = new ConfigServiceClient("ConfigService.V3.BasicHttpService"); ProcessRequestRequest input = new ProcessRequestRequest { request = new ConfigRequest { LanguageId = languageCode, CountryId = countryCode, CustomerSetId = customerSet, PostType = PostType.NoPost, ConfigRequestFlag = // IncludeItem - return ConfigItem ConfigRequestFlag._262144 // SkipLeadTime - GCM will recalculate for us | ConfigRequestFlag._8192 // SelectedOptionsOnly - Tells Config to skip extra processing (they always return only selected items) | ConfigRequestFlag._4, OrderCode = "CAI135NW10PH5008", //mocking ItemQuantity = quantity } }; var response = service.ProcessRequest(input); decimal price = response.ProcessRequestResult.ConfigItem.OriginalPrice; string str = string.Empty; return(price); } catch (Exception ex) { string str = string.Empty; } return(0); }
public object LoadContents(ConfigServiceClient cfg, RepoServiceClient repo) { if (cfg == null || repo == null) throw new ArgumentNullException(); StringBuilder stylesResult = new StringBuilder(); stylesResult.Append("<style>").AppendLine(); var cfgStyles = GetConfigGuidList(cfg); foreach (Guid cfgId in cfgStyles) { PageHeadConfig c = (PageHeadConfig) cfg.GetBranch<PageHeadConfig>(cfgId, this.Category()); if (c != null) { // v SiteConfigu mohou byt jen jmena souboru z adresare dane aplikace v SiteScripts, // nikdy primo kod, ktery by se vkladal do stranky (mozna u css by to tak byt nemuselo) foreach (string scriptFileName in c.StyleLinks) { if (string.IsNullOrWhiteSpace(scriptFileName)) continue; string scriptName = scriptFileName.ToLowerInvariant().EndsWith(".css") ? scriptFileName : scriptFileName + ".css"; var scriptKvp = repo.Get(scriptName); if (scriptKvp != null) { stylesResult.Append("/* " + scriptName + " start */\n"); stylesResult.Append(scriptKvp.StringUnicode); stylesResult.Append("/* " + scriptName + " end */\n"); } } } } stylesResult.Append("</style>"); return stylesResult.ToString(); }
public object LoadContents(ConfigServiceClient cfg, RepoServiceClient repo) { if (cfg == null) throw new ArgumentNullException(); StringBuilder translationsResult = new StringBuilder(); translationsResult.Append("<script type='text/javascript'>").AppendLine(); //ribbonResult.Append("make sure createButtons function is loaded") translationsResult.Append("if(!typeof(NVRHlasky)=='object' && $.isEmptyObject(NVRHlasky)){var NVRHlasky = {};}").AppendLine();//if Hlasky != emptyObject => Expand object instead var cfgTranslations = GetConfigGuidList(cfg); foreach (Guid cfgId in cfgTranslations) { string c = cfg.GetBranchJson(cfgId, this.Category()); if (c != null) { JObject jc = JObject.Parse(c); if (jc["error"] != null) { translationsResult.Append("console.error('problem loading translations config: " + jc["error"] + "');"); continue; } JToken jTranslations = jc["Hlasky"]; //translations = (jc["Hlasky"] ?? "").ToString(); foreach (JProperty translation in jTranslations) { var key = translation.Name; var value = translation.Value; translationsResult.Append("NVRHlasky = $.extend({}, NVRHlasky, {\"" + key + "\": " + value + "});").AppendLine(); } } } translationsResult.Append("</script>"); return translationsResult.ToString(); }
/// <summary> /// Executes the specified content db id. /// </summary> /// <param name="contentDbId">The content db id.</param> public override void Execute(Guid contentDbId) { ILogging log = NaverticaLog.GetInstance(); List<KeyValuePair<string, object>> executionResults = new List<KeyValuePair<string, object>>(); SPWebApplication webApplication = this.Parent as SPWebApplication; if (webApplication == null) { log.LogError(this.Name + ": cannot get SPWebApplication!!!"); return; } //Vetsinou je jen jedna ale muze jich byt vice //SPContentDatabase contentDb = webApplication.ContentDatabases[0]; foreach (SPContentDatabase contentDb in webApplication.ContentDatabases) { for (int i = 0; i < contentDb.Sites.Count; i++) { using (SPSite site = contentDb.Sites[i]) { try { ConfigServiceClient configurations = new ConfigServiceClient(site); log.LogInfo("JOB " + this.Name + " RAN at site: " + site.Url); ConfigGuidList cfgs = configurations.Filter(site.RootWeb, new Dictionary<ConfigFilterType, string> { { ConfigFilterType.App, this.Name } }); if (cfgs.Count == 0) continue; PluginHost.Init(site); foreach (var cfgguid in cfgs) { PluginConfig cfg = (PluginConfig) configurations.GetBranch<PluginConfig>(cfgguid, "TimerJob"); if (cfg == null) continue; foreach (KeyValuePair<string, KeyValuePair<string, JObject>> kvp in cfg.PluginConfigs) { string pluginName = kvp.Key; IPlugin plugin = TimerJobPluginHost.Get(site, pluginName); if (plugin == null) { log.LogError(string.Format( "TimerJobPlugin named {0} was not found in loaded plugins, skipping execution", pluginName)); continue; } TimerJobPluginConfig timerPluginConfig = ConfigBranch.GetInstance<TimerJobPluginConfig>(kvp.Value.Value.ToString()); if (!timerPluginConfig.EnabledToRun) continue; try { using (new SPMonitoredScope("Executing TimerJobPlugin " + pluginName)) { object result = plugin.Execute(timerPluginConfig, site); executionResults.Add(new KeyValuePair<string, object>(pluginName + "|" + kvp.Value.Key, result)); } } catch (Exception e) { log.LogError(string.Format("TimerJobPlugin named {0} has thrown {1}", pluginName, e, e.InnerException, e.StackTrace, e.Source)); } } } string logstr = log.LogInfo("TimerJobPlugins ran:\n" + executionResults.Select( kvp => string.Format("Ran TimerJobPlugin|config name {0} with result:{1}\n\n", kvp.Key, ( kvp.Value ?? "null" ).ToString())).JoinStrings("\n")); } catch (Exception e) { log.LogException(e); } } } } }
public async Task <string> GetOrderCodeDetails(string orderCode, string customerSet, string country, string language) { //_logger.LogInformation("Call to 'GetOrderCodeDetails'"); ConfigServiceClient sc = new ConfigServiceClient(ConfigServiceClient.EndpointConfiguration.BasicHttpService, _IConfigurationSection.GetSection("ServiceURL").Value); ProcessRequestRequest request = new ProcessRequestRequest { request = new ConfigRequest() }; request.request.OrderCode = orderCode; request.request.CustomerSetId = customerSet; request.request.LanguageId = language; request.request.CountryId = country; request.request.Version = 7.1; request.request.AllowChanges = false; //request.request.CartId = System.Guid.NewGuid(); request.request.CatalogId = 0; request.request.PostType = PostType.PartialPost; request.request.ResponseType = ResponseType.Default; request.request.RetrieveCorrectionMode = false; request.request.TrackSelectionUpdates = true; request.request.CfiOptionalModuleId = -2147483648; request.request.CfiRequiredModuleId = -2147483648; //TODO : generate KEY var jsonRequest = JsonConvert.SerializeObject(request); string hashKeyForRequest = HashGenerator.GenerateHashKey(jsonRequest.ToLower()); request.request.CartId = Guid.NewGuid(); //TODO : Write to CallLog // 1. check if already exists or in progress also check for ExpiryDate // 2. Decide if you need to call service or wait (sleep) var callLogRow = _context.CallLog .Where(b => b.Key == hashKeyForRequest) .FirstOrDefault(); if (callLogRow != null) { ProcessRequestResponse processRequestResponse = null; int responseSnapshoptDurationInMinutes = (DateTime.UtcNow - callLogRow.FinishTime).Minutes; int serviceRequestThresholdInSeconds = (DateTime.UtcNow - callLogRow.RequestStartTime).Seconds; if (responseSnapshoptDurationInMinutes >= Convert.ToInt16(_IConfigurationSection.GetSection("ResponseSnapshoptDurationInMinutes").Value)) { if (callLogRow.Status == CallLogStatus.InProgress.ToString() && serviceRequestThresholdInSeconds < Convert.ToInt16(_IConfigurationSection.GetSection("serviceRequestThresholdInSeconds").Value)) { //Open questions are there.. Thread.Sleep(5001); callLogRow = _context.CallLog .Where(b => b.Key == hashKeyForRequest) .FirstOrDefault(); if (callLogRow.Status == CallLogStatus.InProgress.ToString() && serviceRequestThresholdInSeconds < Convert.ToInt16(_IConfigurationSection.GetSection("serviceRequestThresholdInSeconds").Value)) { Thread.Sleep(5001); } } //var task = new[] //{ // Task.Factory.StartNew(() => { }), // Task.Factory.StartNew(() => { }) //}; //Task.WaitAll(task); //new Thread(delegate () //{ // _ICallLogRepository.UpdateCallLog(callLogRow, hashKeyForRequest, // CallLogStatus.InProgress); //}).Start(); _ICallLogRepository.UpdateCallLog(callLogRow, hashKeyForRequest, CallLogStatus.InProgress); try { processRequestResponse = await sc.ProcessRequestAsync(request); } catch (Exception ex) { _ICallLogRepository.DeleteCallLog(callLogRow, hashKeyForRequest); _IOrderCodeRepository.DeleteOrderCode(hashKeyForRequest); _logger.LogError(ex.StackTrace); return(Error.FromConfigService.ToString() + " | " + hashKeyForRequest + "_" + DateTime.UtcNow); } string jsonResponse = JsonConvert.SerializeObject(processRequestResponse); string compressedJsonResponse = Utility.CompressString(jsonResponse); //new Thread(delegate () //{ // _IOrderCodeRepository.UpdateOrderCode(compressedJsonResponse, hashKeyForRequest, // jsonRequest); //}).Start(); _IOrderCodeRepository.UpdateOrderCode(compressedJsonResponse, hashKeyForRequest, jsonRequest); _ICallLogRepository.UpdateCallLog(callLogRow, hashKeyForRequest, CallLogStatus.Completed); return(jsonResponse); } else { var orderCodeRow = _context.OrderCode .Where(b => b.Key == hashKeyForRequest) .FirstOrDefault(); string deCompressedJsonResponse = Utility.DecompressString(orderCodeRow.Response); return(deCompressedJsonResponse); } } else { ProcessRequestResponse processRequestResponse = null; _ICallLogRepository.CreateCallLog(hashKeyForRequest, CallLogStatus.InProgress); //TODO : if first call, make async call to Config Service try { processRequestResponse = await sc.ProcessRequestAsync(request); } catch (Exception ex) { // TODO: update call log _ICallLogRepository.DeleteCallLog(null, hashKeyForRequest); _logger.LogError(ex.StackTrace); return(Error.FromConfigService.ToString() + " | " + hashKeyForRequest + "_" + DateTime.UtcNow); } string jsonResponse = JsonConvert.SerializeObject(processRequestResponse); string compressedJsonResponse = Utility.CompressString(jsonResponse); // 1. Exception Handling (do not store in case of failure) // 2. Zip the output . // 3. Store output in DB (order code model repository) _IOrderCodeRepository.CreateOrderCode(compressedJsonResponse, hashKeyForRequest, jsonRequest); //TODO : UPdate call log with finish time and status. _ICallLogRepository.UpdateCallLog(null, hashKeyForRequest, CallLogStatus.Completed); //TODO : convert the output to required format and return return(jsonResponse); } }
static ConfigHelper() { _configService = ConfigClientFactory.Instance.GetConfigClient(); _compoentConfig = _configService.GetComponentConfig(DefineTable.ComponentID); //不进行null检查保证配置初始化出现问题时爆出异常 _config = XmlConfigSerializer.Instance.FromXml <ConfigServerConfig>(_compoentConfig.Content); //不进行null检查保证配置初始化出现问题时爆出异常 }
protected void Page_Load(object sender, EventArgs e) { //using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { SPSite site = SPContext.Current.Site; StringBuilder result = new StringBuilder(); ConfigServiceClient configurations = null; RepoServiceClient scripts; SPList siteConfig = null; SPList siteScripts = null; IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent(site); IServiceLocatorConfig typeMappings = serviceLocator.GetInstance<IServiceLocatorConfig>(); typeMappings.Site = site; #region Services PrintHeader("NVRServices"); #region NVRConfigService string cfgSvcValue; try { configurations = new ConfigServiceClient(site); cfgSvcValue = configurations.ServiceApplicationIisGuid().ToString(); } catch (Exception exc) { cfgSvcValue = exc.Message; return; } PrintRow("NVRConfigService", cfgSvcValue); #endregion #region NVRRepoService string scriptsSvcValue; try { scripts = new RepoServiceClient(site); scriptsSvcValue = scripts.ServiceApplicationIisGuid().ToString(); } catch (Exception exc) { scriptsSvcValue = exc.Message; } PrintRow("NVRRepoService", scriptsSvcValue); Separator(); #endregion #endregion #region PageHeads PrintHeader("IPageHead"); IEnumerable<IPageHead> pageHeadInstances = serviceLocator.GetAllInstances<IPageHead>(); foreach (IPageHead pageInterface in pageHeadInstances) { PrintRow(pageInterface.GetType().Name, ""); } Separator(); #endregion #region ILOGGING PrintHeader("ILogging"); IEnumerable<ILogging> logInstances = serviceLocator.GetAllInstances<ILogging>(); if (logInstances.Count() == 0) { PrintRow("NO LOGGING INTERFACE FOUND!!!", ""); } foreach (ILogging logInterface in logInstances) { PrintRow(logInterface.GetType().Name, ""); } Separator(); #endregion #region IExecute PrintHeader("IExecute"); IEnumerable<IExecuteScript> executeInterfaces = serviceLocator.GetAllInstances<IExecuteScript>(); if (executeInterfaces.Count() == 0) { PrintRow("NO EXECUTE INTERFACE FOUND!!!", ""); } foreach (IExecuteScript execInterface in executeInterfaces) { PrintRow(execInterface.GetType().Name, ""); } Separator(); #endregion #region NVR LISTS PrintHeader("SiteConfig"); #region SiteConfig try { siteConfig = site.RootWeb.OpenList("SiteConfig", true); PrintRow("SPList " + siteConfig.InternalName(), "OK"); } catch (Exception exc) { PrintRow(siteConfig.InternalName(), exc.Message); return; } var siteConfigCt = siteConfig.ContentTypes.GetContentType("NVR_SiteConfigJSON"); if (siteConfigCt == null) { PrintRow("SPContentType NVR_SiteConfigJSON", "NOT FOUND"); return; } PrintRow("SPContentType NVR_SiteConfigJSON", "OK"); try { if (!siteConfig.ContainsFieldIntName(SiteStructuresDefinitions.SiteConfigFields)) throw new SPFieldNotFoundException(siteConfig, SiteStructuresDefinitions.SiteConfigFields); PrintRow("Required Fields", "OK"); } catch (Exception exc) { PrintRow("Required Fields", exc.Message); } try { SPListItem reloadItem = siteConfig.Items.Cast<SPListItem>().Where(i => i.ContentTypeId == siteConfigCt.Id).FirstOrDefault(); configurations.Reload(reloadItem); PrintRow("SiteConfig Reload CFG", "OK"); } catch (Exception exc) { PrintRow("SiteConfig Reload CFG", exc.Message); } try { var filters = new Dictionary<ConfigFilterType, string> { { ConfigFilterType.App, "JavaScripts" }, { ConfigFilterType.Url, this.Context.Request.RawUrl } }; if (SPContext.Current.List != null) { filters.Add(ConfigFilterType.ListType, SPContext.Current.List.BaseType.ToString()); } if (SPContext.Current.ListItem != null) { filters.Add(ConfigFilterType.ContentType, SPContext.Current.ListItem.ContentTypeId.ToString()); } configurations.Filter(SPContext.Current.Web, filters); PrintRow("SiteConfig Filter CFG", "OK"); } catch (Exception exc) { PrintRow("SiteConfig Filter CFG", exc.Message); } Separator(); #endregion #region SiteScripts PrintHeader("SiteScripts"); try { siteScripts = site.RootWeb.OpenList("SiteScripts", true); PrintRow("SPList " + siteScripts.InternalName(), "OK"); } catch (Exception exc) { PrintRow(siteScripts.InternalName(), exc.Message); return; } var siteScriptsCt = siteScripts.ContentTypes.GetContentType("NVR_SiteScripts"); if (siteScriptsCt == null) { PrintRow("SPContentType NVR_SiteScripts", "NOT FOUND"); } else { PrintRow("SPContentType NVR_SiteScripts", "OK"); } Separator(); #endregion #endregion #region Plugins PrintHeader("Plugins"); PluginHost.Reset(); PluginHost.Init(site); List<string> plugins = PluginHost.List(site); foreach (var pluginName in plugins) { IPlugin plugin = PluginHost.Get(site, pluginName); PrintRow(plugin.Name(), plugin.Description()); } #endregion /* longOperation.LeadingHTML = "Updating. . ."; longOperation.TrailingHTML = "Totok se nezobrazilo"; longOperation.Begin(); * */ //EndOperation(longOperation, System.Web.HttpUtility.JavaScriptStringEncode(result.ToString())); Content.Text = result.ToString(); } }
public object LoadContents(ConfigServiceClient cfg, RepoServiceClient repo) { StringBuilder sb = new StringBuilder(); var cfgScripts = GetConfigGuidList(cfg); if (cfgScripts.Count == 0) return null; sb.AppendLine("<script type='text/javascript' src='/_layouts/15/NVR.SPTools/libs/Intro/intro.js'></script>").AppendLine(); sb.AppendLine("<link type=\"text/css\" rel=\"stylesheet\" href=\"/_layouts/15/NVR.SPTools/libs/Intro/introjs.css\" />"); sb.AppendLine("<script type='text/javascript'>"); sb.AppendLine(@" function ReplaceHelp(){ window.helpDiv = document.createElement('div'); helpDiv.className = 'ms-core-menu-box ms-core-defaultFont'; window.helpUl = document.createElement('ul'); helpUl.className = 'ms-core-menu-list'; helpDiv.appendChild(helpUl); window.createHelpLi= function(fn, title){ var li = document.createElement('li'); li.className='ms-core-menu-item'; var a = document.createElement('a'); a.className = 'ms-core-menu-link'; a.href = 'javascript:;'; a.title = title; a.innerText = title; a.onclick = function(){window.helpDialog.close(); fn(); return false;} li.appendChild(a); window.helpUl.appendChild(li); } var help = $('span#ms-help a'); createHelpLi(function(){TopHelpButtonClick('HelpHome','');return false;}, 'Default Help'); help[0].onclick = function(){ window.helpDialog = SP.UI.ModalDialog.showModalDialog({ title:'Help Menu', x:window.innerWidth-350, y:0, html: helpDiv, autoSize: true, showClose: true, }); return false; }; SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs('helpReplace'); } SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog', function(){_spBodyOnLoadFunctionNames.push('ReplaceHelp');}); "); sb.AppendLine("</script>"); foreach (Guid cfgId in cfgScripts) { ConfigBranch c = cfg.GetBranch<ConfigBranch>(cfgId, this.Category()); IntroConfig introConfig = ConfigBranch.GetInstance<IntroConfig>(c); string theme = !string.IsNullOrEmpty(introConfig.Theme) ? introConfig.Theme : "introjs-nassim"; sb.AppendLine("<link type=\"text/css\" rel=\"stylesheet\" href=\"/_layouts/15/NVR.SPTools/libs/Intro/themes/" + theme + ".css\" />"); string functionName = "startIntro" + cfgId.ToString("N"); sb.AppendLine("<script type='text/javascript'>"); sb.AppendLine("function " + functionName + "(){"); sb.AppendLine("var intro = introJs();"); sb.AppendLine("intro.setOptions({ steps: ["); string cultureName = CultureInfo.CurrentUICulture.Name; for (int i = 0; i < introConfig.Steps.Count; i++) { IntroConfig.IntroStep introStep = introConfig.Steps[i]; string intro = "Intro " + cultureName; sb.AppendLine("{"); if (introStep.Intro != null) { var introTitle = introStep.Intro.SingleOrDefault(l => l.Language == cultureName); if (introTitle != null) { intro = introTitle.Title; } } if (!string.IsNullOrEmpty(introStep.Element)) { sb.AppendLine("element: " + introStep.Element + ","); } if (!string.IsNullOrEmpty(introStep.Position)) { sb.AppendLine("position: \"" + introStep.Position + "\","); } sb.AppendLine("intro: \"" + intro + "\""); sb.AppendLine("}"); if (i < introConfig.Steps.Count - 1) { sb.AppendLine(","); } } sb.AppendLine("]});"); sb.AppendLine("intro.start();"); sb.AppendLine("}"); string title = "help"; if (introConfig.Title != null) { var helpTitle = introConfig.Title.SingleOrDefault(l => l.Language == cultureName); if (helpTitle != null) { title = helpTitle.Title; } } //function(){} sb.AppendLine("SP.SOD.executeOrDelayUntilScriptLoaded( function(){createHelpLi(" + functionName + ",'" + title + "')},'helpReplace');"); //sb.AppendLine("SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog', function(){_spBodyOnLoadFunctionNames.push(\"createHelpLi(" + functionName + ",'" + title + "')\");});"); sb.AppendLine("</script>"); } return sb.ToString(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { // copy files and items via NVRFeatureReceiver base.FeatureActivated(properties); SPSite site = properties.Feature.Parent as SPSite; if (site == null) throw new NullReferenceException("Couldn't load parent site"); // reset our internal list name cache - will be done by SPListEventReceivers in the future HttpRuntime.Cache.Remove("OpenlistDict_" + site.ID + site.RootWeb.ID); bool firstTimeInstallSiteConfig = false; bool firstTimeInstallSiteScripts = false; if (site.RootWeb.OpenList(Const.SITECONFIG_LIST_TITLE, false) == null) firstTimeInstallSiteConfig = true; if (site.RootWeb.OpenList(Const.SITESCRIPTS_LIST_TITLE, false) == null) firstTimeInstallSiteScripts = true; log.LogInfo(properties.Feature.Definition.DisplayName + " feature receiver starting"); try { // Deploy SiteScripts library and SiteConfig list properties.Definition.Farm.Properties["NVR_ScriptsServiceBaseUrl"] = site.Url; SiteStructuresDefinitions.DeploySiteModel(site); SiteStructuresDefinitions.DeployRootWebStructures(site); } catch (Exception exc) { log.LogException(exc, "SPMeta2 deploying models"); } try { site.RootWeb.EventReceivers.Add(SPEventReceiverType.ListAdded, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.ListAdding, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.ListDeleted, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.ListDeleting, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.FieldAdded, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.FieldAdding, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.FieldDeleted, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.FieldDeleting, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.FieldUpdated, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); site.RootWeb.EventReceivers.Add(SPEventReceiverType.FieldUpdating, Const.NVR_DLL, Const.NVR_LIST_RECEIVER); } catch (Exception exc) { log.LogException(exc, "adding SPListEventReceivers to root web"); throw; } // reset our internal list name cache - will be done by SPListEventReceivers in the future HttpRuntime.Cache.Remove("OpenlistDict_" + site.ID + site.RootWeb.ID); // REMOVE ACCESS if (firstTimeInstallSiteConfig) { try { SPList SiteConfig = site.RootWeb.OpenList(Const.SITECONFIG_LIST_TITLE, false); if (SiteConfig != null) { SiteConfig.RemoveRights(); } } catch (Exception exc) { log.LogException(exc, "removing rights from SiteConfig"); throw; } } if (firstTimeInstallSiteScripts) { try { SPList SiteScripts = site.RootWeb.OpenList(Const.SITESCRIPTS_LIST_TITLE, false); if (SiteScripts != null) { SiteScripts.RemoveRights(); } } catch (Exception exc) { log.LogException(exc, "removing rights from SiteScripts"); throw; } } try { ConfigServiceClient cfg = new ConfigServiceClient(site); RepoServiceClient repo = new RepoServiceClient(site); cfg.Reset(site.Url); repo.Reset(); PluginHost.Reset(); } catch (Exception e) { log.LogException(e); throw; } log.LogInfo(properties.Feature.Definition.DisplayName + " feature receiver finished"); }
public void Dispose() { this.Client = null; }
private void RunAllValid(SPItemEventProperties props) { ILogging log = NaverticaLog.GetInstance(); string eventName = Global + props.EventType.ToString(); if (props.ListItem == null) // ItemAdding { log.LogInfo("props.ListItem == null in list ", props.List.DefaultViewUrl, eventName); return; } ConfigServiceClient configurations = new ConfigServiceClient(props.Site); List<KeyValuePair<string, object>> executionResults = new List<KeyValuePair<string, object>>(); try { ConfigGuidList cfgs = configurations.Filter(props.ListItem, eventName); if (cfgs.Count == 0) return; log.LogInfo(eventName, "item url", props.ListItem.FormUrlDisplay(true)); PluginHost.Init(props.Site); foreach (var cfgguid in cfgs) { var c = configurations.GetBranchJson(cfgguid, ""); //get completeBranch//configurations.GetBranchJson(cfgguid, eventName); if (c != null) { JObject jc = JObject.Parse(c); JObject eventBranch = (JObject) jc[eventName]; if (eventBranch == null) { log.LogError("Missing event branch in config: " + eventName); return; } foreach (KeyValuePair<string, JToken /* really string */> kvp in eventBranch) { string pluginName = kvp.Value.ToString(); IPlugin plugin = ItemReceiverPluginHost.Get(props.Site, pluginName); if (plugin == null) { log.LogError(string.Format("ItemReceiverScriptPlugin named {0} was not found in loaded plugins, skipping execution", pluginName)); continue; } try { // plugin config itself should be in another root branch ItemReceiverPluginConfig pluginConfig = ConfigBranch.GetInstance<ItemReceiverPluginConfig>(jc[kvp.Key].ToString()); // on by default, as is ShP standard if (!( pluginConfig.EventFiringEnabled ?? true )) { this.EventFiringEnabled = false; } object result = plugin.Execute(pluginConfig, props); executionResults.Add(new KeyValuePair<string, object>(kvp.Value.ToString(), result)); } catch (Exception e) { log.LogError(string.Format("ItemReceiverScriptPlugin named {0} has thrown {1}", pluginName, e, e.InnerException, e.StackTrace, e.Source)); } } } } string logstr = log.LogInfo("ItemReceiverScriptPlugins ran:\n" + executionResults.Select( kvp => string.Format("Ran ItemReceiverScriptPlugin|config name {0} with result:{1}\n\n", kvp.Key, ( kvp.Value ?? "null" ).ToString())).JoinStrings("\n")); } catch (Exception e) { log.LogException(e); } }