public static ServerPatch GetServerPatch() { ServerPatch sp = new ServerPatch(); //图片路径相关 XmlDocument xmlDoc = new XmlDocument(); //xmlDoc.Load(@"D:\Project\HCHE\ImagePatch.xml"); xmlDoc.Load(ConfigurationSettings.AppSettings["XMLURL"] + @"ServerPatch.xml"); XmlNode root = xmlDoc.SelectSingleNode("PublichPatch");//指向根节点 //浏览图片的相对地址 XmlNode xnImageURL = root.SelectSingleNode("ImageURL"); sp.imageURL = xnImageURL.InnerText;//读出里面的值 //上传时物理路径 XmlNode xnImageHomePath = root.SelectSingleNode("ImageHomePath"); sp.ImageHomePath = xnImageHomePath.InnerText;//读出里面的值 //SSO地址 XmlNode xnSsoAddress = root.SelectSingleNode("SsoAddress"); sp.SsoAddress = xnSsoAddress.InnerText;//读出里面的值 //帮我养车地址 XmlNode xnRunCarAdress = root.SelectSingleNode("RunCarAdress"); sp.RunCarAdress = xnRunCarAdress.InnerText;//读出里面的值 //主站地址 XmlNode xnMastSiteAddress = root.SelectSingleNode("MastSiteAddress"); sp.MastSiteAddress = xnMastSiteAddress.InnerText;//读出里面的值 return(sp); }
private void InitializeDownloadTasks() { for (int i = 0; i < _patches.Length; i++) { ServerPatch patch = _patches[i]; string url = patch.PatchUrl; int version = patch.Version; string filename = Path.GetFileName(url); string destination = Path.Combine(_serverDirectory, filename); DownloadTask task = new DownloadTask(_patches[i].PatchUrl, destination); ListViewItem item = new ListViewItem(new string[5]); task.ProgressUpdate += new EventHandler <ProgressUpdateEventArgs>(OnDownloadStateProgressUpdate); task.ProgressCompleted += new EventHandler <ProgressCompletedEventArgs>(OnDownloadStateProgressCompleted); _downloadManager.Queue(task); _downloadTable.Add(task, item); lvDownloads.Items.Add(item); UpdateDownloadStatus(task, item, 0, -1, 0, "Download Queued"); } }
public bool IsPatchApplied(ServerPatch patch) { return((from p in _context.ServerPatchContext where p.ShardId == patch.ShardId && p.PatchUrl == patch.PatchUrl && p.Version == patch.Version select p).Count() > 0); }
public ServerPatch[] GetPatches(int id) { DataSet data = _service.GetPatches(id); ServerPatch[] patches = null; if (data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0) { DataTable dt = data.Tables[0]; patches = new ServerPatch[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { patches[i] = new ServerPatch(); patches[i].ShardId = id; patches[i].PatchUrl = dt.Rows[i].Field <string>("PatchUrl"); patches[i].Version = dt.Rows[i].Field <int>("Version"); } } return(patches); }
public void Play() { try { Dictionary <string, string> table = new Dictionary <string, string>(); string dataString = string.Empty; string[] split = null; dataString = _url; dataString = Uri.UnescapeDataString(dataString); bool encoded = Regex.IsMatch(dataString, "^[A-Za-z0-9+/=]+$", RegexOptions.IgnoreCase); if (encoded) { dataString = Encoding.UTF8.GetString(Convert.FromBase64String(dataString)); } _log.Debug("dataString = {0}", dataString); split = dataString.Split('&'); for (int i = 0; i < split.Length; i++) { string[] keyValue = split[i].Split('='); if (keyValue.Length == 2) { string key = keyValue[0]; string value = keyValue[1]; table.Add(key, value); } } for (int i = 0; i < _requiredFields.Length; i++) { if (!table.ContainsKey(_requiredFields[i])) { MessageBoxEx.Show(Program.MainForm, string.Format("One or more of the following fields was missing from the ConnectUO Url Protocol string: {0}", string.Join(" ", _requiredFields))); return; } } string idString = table[Id]; string name = table[NameTolken]; string portString = table[PortTolken]; string hostAddress = table[HostTolken]; string allowRazor; string removeEnc; string patches; bool razor = Program.Database.LaunchRazor; bool enc; if (!table.TryGetValue(AllowRazorTolken, out allowRazor)) { allowRazor = "false"; } if (!table.TryGetValue(RemoveEncTolken, out removeEnc)) { removeEnc = "true"; } if (!table.TryGetValue(PatchesTolken, out patches)) { patches = ""; } int port; int id; if (!int.TryParse(idString, out id)) { MessageBoxEx.Show(Program.MainForm, "Invalid server id."); return; } if (!int.TryParse(portString, out port) || (port > 65536 || port < 0)) { MessageBoxEx.Show(Program.MainForm, "Invalid port number, please use a valid port number between 0 and 65535"); return; } bool shardAllowsRazor; bool.TryParse(allowRazor, out shardAllowsRazor); bool.TryParse(removeEnc, out enc); //Make sure the user wants razor, and that shard allows it. razor = razor && shardAllowsRazor; if (string.IsNullOrEmpty(Program.Database.UltimaOnlineDirectory)) { MessageBoxEx.Show(Program.MainForm, "ConnectUO was unable to find the directory that Ultima Online is installed to. This must be set in order to launch the client."); return; } if (string.IsNullOrEmpty(Program.Database.UltimaOnlineExe)) { MessageBoxEx.Show(Program.MainForm, "ConnectUO was unable to find the client executable. This must be set in order to launch the client."); return; } string folderName = name; Utility.EnsureValidFolderName(ref folderName); string serverDirectory = Path.Combine(Program.Database.PatchDirectory, folderName); string[] patchFiles = null; Utility.EnsureDirectory(serverDirectory); List <ServerPatch> patchList = new List <ServerPatch>(); split = patches.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < split.Length; i++) { string[] patchVersion = split[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (patchVersion.Length == 2) { string patchUri = patchVersion[0]; string versionString = patchVersion[1]; int version; int.TryParse(versionString, out version); ServerPatch patch = new ServerPatch(); patch.ShardId = id; patch.PatchUrl = patchUri; patch.Version = version; if (!Program.Database.IsPatchApplied(patch)) { patchList.Add(patch); } } } if (patchList.Count > 0) { if (Program.Database.IsServerBeingPatched(id)) { MessageBoxEx.Show(Program.MainForm, String.Format("{0} is already being patched, you cannot play until the patching process has been completed", name), "ConnectUO 2.0"); return; } else { frmTaskManager taskManager = new frmTaskManager(patchList, serverDirectory); if (taskManager.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } } } patchFiles = Directory.GetFiles(serverDirectory); ThreadPool.QueueUserWorkItem(delegate(object o) { new ConnectUOWebService().UpdatePlayStatistics(Program.Database.Guid, id); }); ClientLauncher.Launch(id, hostAddress, port, Path.Combine(Program.Database.UltimaOnlineDirectory, Program.Database.UltimaOnlineExe), Program.Database.RazorDirectory, razor, enc, Path.Combine(Program.Database.PatchDirectory, folderName), patchFiles); } catch (Exception e) { _log.Error(e); } }
public void Play(string url) { try { string[] split = null; if (url.Contains("//")) { split = url.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries); if (split.Length >= 2) { url = split[1]; } } url = url.Replace("/", ""); Dictionary <string, string> table = new Dictionary <string, string>(); string dataString = string.Empty; dataString = url; dataString = Uri.UnescapeDataString(dataString); bool encoded = Regex.IsMatch(dataString, "^[A-Za-z0-9+/=]+$", RegexOptions.IgnoreCase); if (encoded) { dataString = Encoding.UTF8.GetString(Convert.FromBase64String(dataString)); } Tracer.Verbose("dataString = {0}", dataString); split = dataString.Split('&'); for (int i = 0; i < split.Length; i++) { string[] keyValue = split[i].Split('='); if (keyValue.Length == 2) { string key = keyValue[0]; string value = keyValue[1]; table.Add(key, value); } } for (int i = 0; i < _requiredFields.Length; i++) { if (!table.ContainsKey(_requiredFields[i])) { MessageBoxEx.Show(_applicationService.MainForm, string.Format("One or more of the following fields was missing from the ConnectUO Url Protocol string: {0}", string.Join(" ", _requiredFields))); return; } } string idString = table[Id]; string name = table[NameTolken]; string portString = table[PortTolken]; string hostAddress = table[HostTolken]; string allowRazor; string removeEnc; string patches; bool razor = _settingsService.LaunchRazor; bool enc; if (!table.TryGetValue(AllowRazorTolken, out allowRazor)) { allowRazor = "false"; } if (!table.TryGetValue(RemoveEncTolken, out removeEnc)) { removeEnc = "true"; } if (!table.TryGetValue(PatchesTolken, out patches)) { patches = ""; } int port; int id; if (!int.TryParse(idString, out id)) { MessageBoxEx.Show(_applicationService.MainForm, "Invalid server id."); return; } if (!int.TryParse(portString, out port) || (port > 65536 || port < 0)) { MessageBoxEx.Show(_applicationService.MainForm, "Invalid port number, please use a valid port number between 0 and 65535"); return; } bool shardAllowsRazor; bool.TryParse(allowRazor, out shardAllowsRazor); bool.TryParse(removeEnc, out enc); //Make sure the user wants razor, and that shard allows it. razor = razor && shardAllowsRazor; if (string.IsNullOrEmpty(_settingsService.UltimaOnlineDirectory)) { MessageBoxEx.Show(_applicationService.MainForm, "ConnectUO was unable to find the directory that Ultima Online is installed to. This must be set in order to launch the client."); return; } if (string.IsNullOrEmpty(_settingsService.UltimaOnlineExe)) { MessageBoxEx.Show(_applicationService.MainForm, "ConnectUO was unable to find the client executable. This must be set in order to launch the client."); return; } string folderName = name; EnsureValidFolderName(ref folderName); string serverDirectory = Path.Combine(_settingsService.PatchDirectory, folderName); string[] patchFiles = null; FileSystemHelper.EnsureDirectoryExists(serverDirectory); List <ServerPatch> patchList = new List <ServerPatch>(); split = patches.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < split.Length; i++) { string[] patchVersion = split[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (patchVersion.Length == 2) { string patchUri = patchVersion[0]; string versionString = patchVersion[1]; int version; int.TryParse(versionString, out version); ServerPatch patch = new ServerPatch(); patch.ShardId = id; patch.PatchUrl = patchUri; patch.Version = version; patchList.Add(patch); //if (!_storageService.IsPatchApplied(patch)) //{ // //_storageService.ResetPatches(id); // patchList.Add(patch); // //i = 0; // //continue; //} } } ServerPatch[] notPatched = (from p in patchList where !_storageService.IsPatchApplied(p) select p).ToArray(); if (notPatched.Length > 0) { if (_storageService.IsServerBeingPatched(id)) { MessageBoxEx.Show(_applicationService.MainForm, String.Format("{0} is already being patched, you cannot play until the patching process has been completed", name), "ConnectUO 2.0"); return; } else { //_storageService.ResetPatches(id); PatcherForm taskManager = _kernel.Get <PatcherForm>(); taskManager.Patches = notPatched; taskManager.ServerDirectory = serverDirectory; if (taskManager.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } } } patchFiles = Directory.GetFiles(serverDirectory); _storageService.UpdatePlayStatistics(_settingsService.Guid, id); ClientLauncher.Launch( _kernel, id, hostAddress, port, Path.Combine(_settingsService.UltimaOnlineDirectory, _settingsService.UltimaOnlineExe), _settingsService.RazorDirectory, razor, enc, Path.Combine(_settingsService.PatchDirectory, folderName), patchFiles); } catch (Exception e) { Tracer.Error(e); } }
public void Play() { try { Dictionary<string, string> table = new Dictionary<string, string>(); string dataString = string.Empty; string[] split = null; dataString = _url; dataString = Uri.UnescapeDataString(dataString); bool encoded = Regex.IsMatch(dataString, "^[A-Za-z0-9+/=]+$", RegexOptions.IgnoreCase); if (encoded) { dataString = Encoding.UTF8.GetString(Convert.FromBase64String(dataString)); } _log.Debug("dataString = {0}", dataString); split = dataString.Split('&'); for (int i = 0; i < split.Length; i++) { string[] keyValue = split[i].Split('='); if (keyValue.Length == 2) { string key = keyValue[0]; string value = keyValue[1]; table.Add(key, value); } } for (int i = 0; i < _requiredFields.Length; i++) { if (!table.ContainsKey(_requiredFields[i])) { MessageBoxEx.Show(Program.MainForm, string.Format("One or more of the following fields was missing from the ConnectUO Url Protocol string: {0}", string.Join(" ", _requiredFields))); return; } } string idString = table[Id]; string name = table[NameTolken]; string portString = table[PortTolken]; string hostAddress = table[HostTolken]; string allowRazor; string removeEnc; string patches; bool razor = Program.Database.LaunchRazor; bool enc; if (!table.TryGetValue(AllowRazorTolken, out allowRazor)) { allowRazor = "false"; } if (!table.TryGetValue(RemoveEncTolken, out removeEnc)) { removeEnc = "true"; } if (!table.TryGetValue(PatchesTolken, out patches)) { patches = ""; } int port; int id; if (!int.TryParse(idString, out id)) { MessageBoxEx.Show(Program.MainForm, "Invalid server id."); return; } if (!int.TryParse(portString, out port) || (port > 65536 || port < 0)) { MessageBoxEx.Show(Program.MainForm, "Invalid port number, please use a valid port number between 0 and 65535"); return; } bool shardAllowsRazor; bool.TryParse(allowRazor, out shardAllowsRazor); bool.TryParse(removeEnc, out enc); //Make sure the user wants razor, and that shard allows it. razor = razor && shardAllowsRazor; if (string.IsNullOrEmpty(Program.Database.UltimaOnlineDirectory)) { MessageBoxEx.Show(Program.MainForm, "ConnectUO was unable to find the directory that Ultima Online is installed to. This must be set in order to launch the client."); return; } if (string.IsNullOrEmpty(Program.Database.UltimaOnlineExe)) { MessageBoxEx.Show(Program.MainForm, "ConnectUO was unable to find the client executable. This must be set in order to launch the client."); return; } string folderName = name; Utility.EnsureValidFolderName(ref folderName); string serverDirectory = Path.Combine(Program.Database.PatchDirectory, folderName); string[] patchFiles = null; Utility.EnsureDirectory(serverDirectory); List<ServerPatch> patchList = new List<ServerPatch>(); split = patches.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < split.Length; i++) { string[] patchVersion = split[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (patchVersion.Length == 2) { string patchUri = patchVersion[0]; string versionString = patchVersion[1]; int version; int.TryParse(versionString, out version); ServerPatch patch = new ServerPatch(); patch.ShardId = id; patch.PatchUrl = patchUri; patch.Version = version; if (!Program.Database.IsPatchApplied(patch)) { patchList.Add(patch); } } } if (patchList.Count > 0) { if (Program.Database.IsServerBeingPatched(id)) { MessageBoxEx.Show(Program.MainForm, String.Format("{0} is already being patched, you cannot play until the patching process has been completed", name), "ConnectUO 2.0"); return; } else { frmTaskManager taskManager = new frmTaskManager(patchList, serverDirectory); if (taskManager.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } } } patchFiles = Directory.GetFiles(serverDirectory); ThreadPool.QueueUserWorkItem(delegate(object o) { new ConnectUOWebService().UpdatePlayStatistics(Program.Database.Guid, id); }); ClientLauncher.Launch(id, hostAddress, port, Path.Combine(Program.Database.UltimaOnlineDirectory, Program.Database.UltimaOnlineExe), Program.Database.RazorDirectory, razor, enc, Path.Combine(Program.Database.PatchDirectory, folderName), patchFiles); } catch (Exception e) { _log.Error(e); } }
public void SetPatchApplied(ServerPatch patch) { _context.AddToServerPatchContext(patch); _context.SaveChanges(); }
public void AddToServerPatchContext(ServerPatch serverPatch) { base.AddObject("ServerPatchContext", serverPatch); }
public static ServerPatch CreateServerPatch(int shardId, string patchUrl, int version) { ServerPatch serverPatch = new ServerPatch(); serverPatch.ShardId = shardId; serverPatch.PatchUrl = patchUrl; serverPatch.Version = version; return serverPatch; }