public static void Load() { var result = new AppsResult(); try { HubConnection connection = new HubConnectionBuilder() .WithUrl(AppsClientConfig.AppsURL + "/appsHub") .Build(); //connection.On<string, string>("SendAppsClientConfig", (user, message) => //{ //}); connection.StartAsync().Wait(); connection.Closed += async(error) => { await Task.Delay(new Random().Next(0, 5) * 1000); connection.StartAsync().Wait(); }; //connection.InvokeAsync("SendMessage", this.MachineName, "AppsHub started."); AppsClientHub.AppsHubConnection = connection; } catch (Exception ex) { new AppFlows.ClientSystem.Exception(ex, ref result); } }
public virtual string[] Load(string configFileName, ref AppsResult result) { string[] lines = null; string machineName = Environment.MachineName; string configPath = @"\MyConfig\" + configFileName; string configDefaultDrivePath = "D:"; string configAlternateDrivePath = "C:"; string configAlternateDrivePathG = "G:"; string defaultPath = configDefaultDrivePath + configPath; string alternatConfigPath = configAlternateDrivePath + configPath; string altG = configAlternateDrivePathG + configPath; string usingConfigPath = ""; if (File.Exists(defaultPath)) { usingConfigPath = defaultPath; } else if (File.Exists(alternatConfigPath)) { usingConfigPath = alternatConfigPath; } else if (File.Exists(altG)) { usingConfigPath = altG; } if (File.Exists(usingConfigPath)) { lines = File.ReadAllLines(usingConfigPath); // create config here: } else { //AppsLog.LogError( AppsLog.Flow.Config, "Missing default and alternate configuration file paths."); } return(lines); }