public static string Reload(string fileNamePath, SPSite site) { RepoServiceClient repo = new RepoServiceClient(site); fileNamePath = RepoServiceClient.NormalizedFilePath(fileNamePath); var log = NaverticaLog.GetInstance(); using (new SPMonitoredScope("ReloadPlugin")) { if (repo.FullPathsToAllFilesAndFolders.Contains(fileNamePath) && fileNamePath.ToLowerInvariant().Contains("plugin")) { try { var result = repo.Execute(fileNamePath, new ScriptContext()); if (result != null) { List<string> errors = new List<string>(); foreach(string s1 in result.Keys) { if (s1.StartsWith("_ERROR ")) { errors.Add(log.LogError("Error loading plugin ", s1, result[s1])); } } if (errors.Count > 0) return "Errors:\n" + string.Join("\n", errors); return "Success " + fileNamePath; } } catch (Exception ee) { return log.LogError("Exception loading plugin ", fileNamePath, ee); } return "Failed " + fileNamePath; } return "Not a file/plugin, skipped " + fileNamePath; } }
public static void LoadPlugins(SPSite site) { RepoServiceClient repo = new RepoServiceClient(site); var log = NaverticaLog.GetInstance(); using (new SPMonitoredScope("LoadPlugins")) { foreach (string s in repo.FullPathsToAllFilesAndFolders) { if (s.ToLowerInvariant().Contains("plugin")) { try { ScriptContext result = repo.Execute(s, new ScriptContext()); if (result != null) { foreach(string s1 in result.Keys) { if (s1.StartsWith("_ERROR ")) { log.LogError("Error loading plugin ", s, result[s1]); } } } } catch (Exception e) { log.LogError("Error loading plugin ", s, e); } } } } }