public static void DoBuild(CallbackQuery query) { var msg = query.Message.Text + $"\n\nBeginning build...\n"; Bot.ReplyToCallback(query, msg); //determine what we are building var updateType = query.Data.Split('|')[1]; var beta = updateType.StartsWith("beta"); var control = !updateType.Contains("node"); var node = !updateType.Contains("control"); msg += "Build Definition(s) to Use:"; var definitions = new List <string>(); var env = beta ? "Beta" : "Release"; //var what = control ? node ? "Both" : "Control" : "Node"; if (control) { definitions.Add($"{env} Control"); } if (node) { definitions.Add($"{env} Node"); } msg = definitions.Aggregate(msg, (current, a) => current + "\n" + a); Thread.Sleep(500); Bot.Edit(query, msg); Thread.Sleep(500); //now let's actually kick off that build msg = definitions.Aggregate(msg, (current, def) => current + ("\n" + QueueBuild(def).Result)); Bot.Edit(query, msg); }
public static void DoUpdate(CallbackQuery query) { var msg = "Beginning file moving..."; try { Bot.ReplyToCallback(query, msg); //directories var uDir = "c:\\build\\"; var controlDir = uDir + "Werewolf Control\\bin\\"; var nodeDir = uDir + "Werewolf Node\\bin\\"; var botBaseDir = "c:\\BOT\\Werewolf 4.0 "; //files var baseFiles = new[] { "Database.dll", "Database.pdb", "TcpFramework.dll", "TcpFramework.pdb", "Telegram.Bot.dll", "Telegram.Bot.xml" }; //control has different names for each bot //node we will just copy the entire folder //stage the control files in the update folder foreach (var b in Builds) { foreach ( var file in Directory.GetFiles(controlDir + b.BuildName) .Where( x => baseFiles.Contains(Path.GetFileName(x)) || Path.GetFileName(x).Contains(b.ControlExeName)) ) { var fName = Path.GetFileName(file); System.IO.File.Copy(file, botBaseDir + b.BotDirSuffix + "\\Control\\Update\\" + fName, true); } msg += "\nCopied Control files for " + b.BotDirSuffix; Bot.ReplyToCallback(query, msg); //now find the oldest node folder Version oldVersion = new Version(99, 99); var oldest = ""; foreach ( var d in Directory.GetDirectories(botBaseDir + b.BotDirSuffix, "*Node*")) { //get the version of werewolf var file = Directory.GetFiles(d, "Werewolf Node.exe").First(); Version fvi = Version.Parse(FileVersionInfo.GetVersionInfo(file).FileVersion); if (fvi < oldVersion) { oldest = d; oldVersion = fvi; } } if (String.IsNullOrEmpty(oldest)) { throw new Exception("Could not determine oldest Node directory :("); } //copy the node files to it foreach (var file in Directory.GetFiles(nodeDir + b.BuildName)) { var fName = Path.GetFileName(file); System.IO.File.Copy(file, Path.Combine(oldest, fName), true); } msg += "\nCopied Node files to " + oldest.Substring(oldest.LastIndexOf("\\") + 1); Bot.ReplyToCallback(query, msg); } //tell each bot to replace nodes //tell each bot to update msg += "\n\nCompleted Call - until this is fully automated, please run /replacenodes and /update"; Bot.ReplyToCallback(query, msg); } catch (Exception e) { Bot.ReplyToCallback(query, msg + "\n" + e.Message); } }
public static void DoUpdate(CallbackQuery query) { var msg = query.Message.Text + "\n\nBeginning file moving..."; var updateType = query.Data.Split('|')[1]; try { Bot.ReplyToCallback(query, msg); //directories var uDir = "c:\\build\\"; var controlDir = uDir + "Werewolf Control\\bin\\"; var nodeDir = uDir + "Werewolf Node\\bin\\"; var botBaseDir = "c:\\BOT\\Werewolf 4.0 "; //files var baseFiles = new[] { "Database.dll", "Database.pdb", "TcpFramework.dll", "TcpFramework.pdb", "Telegram.Bot.dll", "Telegram.Bot.xml" }; //control has different names for each bot //node we will just copy the entire folder //stage the control files in the update folder foreach (var b in Builds) { if (!updateType.StartsWith(b.BuildName.ToLower())) { continue; } //update types can contain 'node', 'control', or 'both' if (!updateType.Contains("node")) //if nodes only, don't update control { foreach ( var file in Directory.GetFiles(controlDir + b.BuildName) .Where( x => baseFiles.Contains(Path.GetFileName(x)) || Path.GetFileName(x).Contains(b.ControlExeName)) ) { var fName = Path.GetFileName(file); File.Copy(file, botBaseDir + b.BotDirSuffix + "\\Control\\Update\\" + fName, true); } msg += $"\nCopied {b.BuildName} Control files"; Bot.ReplyToCallback(query, msg); } if (!updateType.Contains("control")) //if control only, don't update nodes { //now find the oldest node folder var copied = false; foreach ( var d in Directory.GetDirectories(botBaseDir + b.BotDirSuffix, "*Node*")) { //get the version of werewolf //copy the node files to it foreach (var file in Directory.GetFiles(nodeDir + b.BuildName)) { var fName = Path.GetFileName(file); copied = true; try { File.Copy(file, Path.Combine(d, fName), true); } catch (Exception e) { if (e.Message.Contains("because it is being used by another process")) //nodes in this folder are still active D: { copied = false; break; } else { throw; } } } if (copied) { msg += $"\nCopied {b.BuildName} Node files to " + d.Substring(d.LastIndexOf("\\") + 1); Bot.ReplyToCallback(query, msg); break; } } if (!copied) { throw new Exception("Unable to copy Node files to a directory."); } } } //tell each bot to replace nodes //tell each bot to update msg += "\n\nCompleted Call, bots should now auto load updated files"; Bot.ReplyToCallback(query, msg); } catch (Exception e) { Bot.ReplyToCallback(query, msg + "\n" + e.Message); } }
public static void DoUpdate(CallbackQuery query) { var msg = "Beginning file moving..."; try { Bot.ReplyToCallback(query, msg); //directories var uDir = "c:\\build\\"; var controlDir = uDir + "Werewolf Control\\bin\\"; var nodeDir = uDir + "Werewolf Node\\bin\\"; var botBaseDir = "c:\\BOT\\Werewolf 4.0 "; //files var baseFiles = new[] { "Database.dll", "Database.pdb", "TcpFramework.dll", "TcpFramework.pdb", "Telegram.Bot.dll", "Telegram.Bot.xml" }; //control has different names for each bot //node we will just copy the entire folder //stage the control files in the update folder foreach (var b in Builds) { foreach ( var file in Directory.GetFiles(controlDir + b.BuildName) .Where( x => baseFiles.Contains(Path.GetFileName(x)) || Path.GetFileName(x).Contains(b.ControlExeName)) ) { var fName = Path.GetFileName(file); System.IO.File.Copy(file, botBaseDir + b.BotDirSuffix + "\\Control\\Update\\" + fName, true); } msg += "\nCopied Control files for " + b.BotDirSuffix; Bot.ReplyToCallback(query, msg); //now find the oldest node folder var copied = false; foreach ( var d in Directory.GetDirectories(botBaseDir + b.BotDirSuffix, "*Node*")) { //get the version of werewolf //copy the node files to it foreach (var file in Directory.GetFiles(nodeDir + b.BuildName)) { var fName = Path.GetFileName(file); copied = true; try { System.IO.File.Copy(file, Path.Combine(d, fName), true); } catch (Exception e) { if (e.Message.Contains("because it is being used by another process")) //nodes in this folder are still active D: { copied = false; break; } else { throw; } } } if (copied) { msg += "\nCopied Node files to " + d.Substring(d.LastIndexOf("\\") + 1); Bot.ReplyToCallback(query, msg); break; } } if (!copied) { throw new Exception("Unable to copy Node files to a directory."); } } //tell each bot to replace nodes //tell each bot to update msg += "\n\nCompleted Call - until this is fully automated, please run /replacenodes and /update"; Bot.ReplyToCallback(query, msg); } catch (Exception e) { Bot.ReplyToCallback(query, msg + "\n" + e.Message); } }