private void button1_Click(object sender, EventArgs e) { MachineData mdata = new MachineData(); Name = tvstools.GetMachineName(); mdata.disks = tvstools.ReadSmart(); mdata.ethernets = tvstools.GetNetworkDevices(); mdata.mounts = tvstools.GetMountPoints(); mdata.UpTime = tvstools.GetUpTime(); mdata.Processor = tvstools.GetProcessorName(); mdata.OS = tvstools.GetOSName(); mdata.FreeMemory = tvstools.GetFreeMemory(); mdata.FreeSwap = tvstools.GetFreeSwapMemory(); mdata.TotalMemory = tvstools.GetTotalMemory(); mdata.TotalSwap = tvstools.GetTotalSwapMemory(); mdata.Name = Name; //API.SessionKey = "f42a8580-24b7-11e4-b30f-3b79ab91660d"; //textBox1.Text += "\r\n" + API._CallAPI("loadmachines", null); textBox1.Text += "\r\n" + mdata.ToJSON(); //Smart[] smarts = tvstools.ReadSmart(); //foreach (Smart smart in smarts) //{ // textBox1.Text += smart.ToString(); //} }
public void CopyAndOverrideFile(MachineData machineData) { if (machineData.AlreadyBackup == false) { MessageBox.Show("Backup data first"); return; } if (machineData.FileDirectors == null) { return; } if (machineData.FileDirectors.Count == 0) { return; } foreach (var fileDirector in machineData.FileDirectors) { string fileName = Path.GetFileName(fileDirector.Source_FilePath); string sourceFile = Path.Combine(machineData.RootPath, fileDirector.Source_FilePath); string destFile = Path.Combine(fileDirector.Destination_FolderPath, fileName); File.Copy(sourceFile, destFile, true); Define.Logger.AddLog("DATA", $"Copy \'{sourceFile}\' to \'{destFile}\' Success"); } }
public async Task <ActionResult <MachineData> > PostData(MachineData data) { _context.MachineDatas.Add(data); await _context.SaveChangesAsync(); return(CreatedAtAction("GetData", new { id = data.Id }, data)); }
public WorkPackage FetchWork(MachineData pMachineData) { //debug test NewLogMessageEvent?.Invoke($"New Work Request received from {this.Context?.ConnectionId}"); var work = WorkRequestedEvent?.Invoke(pMachineData.OperatingSystem, this.Context?.ConnectionId); return(work); }
public string Index() { string licence = DataCipher.RSAEncrypt(MachineData.MachineCode() + "|" + DateTime.Now.AddDays(20).ToString("yyyy-MM-dd"), "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmlx+ouP4MJehomQOn+8YqjBUnX3oUVXDR2R3I4HdC0QUG9Qq0565n1fPl3TZLdS3njamNtUMu9Ovjl2bI0/oRyv536J4px4QDKGrB78PRbLC/jIq+Nuk2V3ObEPXJA8EAnSrdGGqn3rb4fejZgCAKashTp96VD+SKbhaCk3kTbVL9TMIyCDTv9/QjK3xKSFxlq2x3bnt/hqTUMHveTcE93qFDpEV2jtNbUz1oT43//J/wvIFIHFU+Xd5CjEYqeo0gaX0uzt2oAODljHP7ce1R+d1Gt6ab2kYfKE2t5beXQhEETsWcAm3U1nmq4d/YNXoE2RwXNfQzFr01LsFmFks4QIDAQAB"); var a = MachineData.AppPeriod(licence); return(a.ValidityDate.ToString()); }
public void Add(MachineData data) { data.Queued = true; data.Status = DemonStatus.None; lock (Queue) Queue.Enqueue(data); }
public void MachineFolderBackup(MachineData machineData) { if (machineData.BackupPaths == null) { return; } if (machineData.BackupPaths.Count == 0) { return; } foreach (string folder in machineData.BackupPaths) { if (!Directory.Exists(folder)) { continue; } string backupFolderName = $"{folder} - NO MES"; if (Directory.Exists(backupFolderName)) { MessageBoxResult result = MessageBox.Show( $"{backupFolderName} folder already exist.\nDo you want to create new backup folder?", "Attention", MessageBoxButton.YesNo); if (result != MessageBoxResult.Yes) { machineData.AlreadyBackup = true; return; } else { backupFolderName = $"{folder} - NO MES_{DateTime.Now.ToString("yyMMddHHmmss")}"; } } Directory.CreateDirectory(backupFolderName); //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(folder, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(folder, backupFolderName)); } //Copy all the files & Replaces any files with the same name foreach (string newPath in Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(folder, backupFolderName), true); } Define.Logger.AddLog("DATA", $"Backup \'{folder}\' to \'{backupFolderName}\' Success!"); } machineData.AlreadyBackup = true; }
/// <summary> /// Set MyData into actor's private state store /// </summary> /// <param name="data">the user-defined MyData which will be stored into state store as "my_data" state</param> public async Task <string> SetDataAsync(MachineData data) { // Data is saved to configured state store implicitly after each method execution by Actor's runtime. // Data can also be saved explicitly by calling this.StateManager.SaveStateAsync(); // State to be saved must be DataContract serializable. await this.StateManager.SetStateAsync <MachineData>( "my_data", // state name data); // data saved for the named state "my_data" return("Success"); }
public static MachineData GetMachineData() { MachineData mdata = new MachineData(); mdata.ContainerVersion = GetContainerVersion(); mdata.OperatingSystem = GetOperatingSystem(); mdata.ProcessingUnit = GetProcessingUnitType(); mdata.Name = GetContainerName(); return(mdata); }
public void SpecificContentExecute() { MachineData machineData = new MachineData(); if (HelperStatus.DataBuildMode) { machineData.BackupPaths = new List <string> { @"D:\TOP\UI", @"D:\TOP\TASK", @"D:\TOP\VCM_BONDING", @"C:\Program Files\VCM_TEST" }; foreach (string file in Directory.GetFiles(machineDataPath)) { if (file.EndsWith("MachineData.json")) { continue; } machineData.FileDirectors.Add(new FileDirector { Source_FilePath = file.Replace(machineDataPath, "").Replace(@"\", ""), Destination_FolderPath = null }); } System.IO.File.WriteAllText(Path.Combine(machineDataPath, "MachineData.json"), JsonConvert.SerializeObject(machineData, Formatting.Indented)); } else { machineData = JsonConvert.DeserializeObject <MachineData>(File.ReadAllText(Path.Combine(machineDataPath, "MachineData.json"))); machineData.RootPath = machineDataPath; CompletedPercentage = 10; MachineFolderCreate(machineData); CompletedPercentage = 20; MachineFileCreate(machineData); CompletedPercentage = 30; MachineFolderBackup(machineData); CompletedPercentage = 60; CopyAndOverrideFile(machineData); CompletedPercentage = 90; CreateProfileString(machineData); } CompletedPercentage = 100; }
void OnCollisionExit(Collision collisionInfo) { Debug.Log("OnCollisionExit"); MachineData md = collisionInfo.gameObject.GetComponent <MachineData> (); if (md != null) { //Detiene rutina de conexion md.cleanData(); target.SetActive(false); } }
public void Constructor_CreateMachine_CheckFields() { int capacity = 2; double length = 2.0; double width = 1.0; var machine = new MachineData(length, width, capacity); Assert.AreEqual(machine.Length, length, 1e-5); Assert.AreEqual(machine.Width, width, 1e-5); Assert.IsFalse(machine.Products.Any()); Assert.IsFalse(machine.IsFull); }
public override void OnSave(BlockXDataHolder stream) { if (toRemove) { return; } if (AddPiece.isSimulating) { return; } stream.Write("modLoader-machineData", MachineData.GetSaveData()); }
public void PerformProcessAndResultDataGenerate(DataTable excelDatatable) { DataTable resultDataTable = new DataTable(); int machineCounter = 0; MachineServicesList = new List <MachineData>(); // Iterate Webservers for (int rowCount = 2; rowCount < excelDatatable.Rows.Count; rowCount++) { ManagementScope scope = null; DataRow row = excelDatatable.Rows[rowCount]; MachineData md = new MachineData(); List <ServicesData> servicesFromExcel = null; bool isLoginSuccess = false; // Login to Webserver bool processMachine = Convert.ToBoolean(Enum.Parse(typeof(YesNo), row[1].ToString())); md.MachineName = row[0].ToString(); if (processMachine) { scope = LoginToMachine(md.MachineName, out isLoginSuccess); md.isSuccess = isLoginSuccess; } else { md.IsMachineSkipped = true; MachineServicesList.Add(md); //MachineServicesList[machineCounter].IsMachineSkipped = md.IsMachineSkipped; continue; } //if (isLoginSuccess) //{ // Iterate Services servicesFromExcel = GetServiceData(excelDatatable, md.MachineName); // Get Current Service Status GetCurrentServiceStatus(servicesFromExcel, scope); // Service ON/Off StartStopServices(servicesFromExcel, scope); //} // Add Service Data To Machine data md.services = servicesFromExcel; MachineServicesList[machineCounter++].services = md.services; scope = null; } }
void OnCollisionEnter(Collision collisionInfo) { Debug.Log("OnCollisionEnter"); MachineData md = collisionInfo.gameObject.GetComponent <MachineData> (); if (md != null) { //Inicia rutina de conexion Debug.Log(collisionInfo.gameObject.name); collidedObject = collisionInfo.gameObject.name; md.setUpData(collidedObject); target.SetActive(true); } }
public override bool Equals(object obj) { MachineData data = obj as MachineData; return((Children == null || data.Children == Children) && (Cats == null || data.Cats == Cats) && (Samoyeds == null || data.Samoyeds == Samoyeds) && (Pomeranians == null || data.Pomeranians == Pomeranians) && (Akitas == null || data.Akitas == Akitas) && (Vizslas == null || data.Vizslas == Vizslas) && (Goldfish == null || data.Goldfish == Goldfish) && (Trees == null || data.Trees == Trees) && (Cars == null || data.Cars == Cars) && (Perfumes == null || data.Perfumes == Perfumes)); }
public override float GetAutomationValue(string item) { if (!item.Equals(product) && !item.Equals(byproduct)) { Debug.LogError(item + " is not produced by " + this); } if (MachineData == null) { return(0); } return(MachineData.ValueAddedToProduction(stockpile)); //return baseProductivity; }
private void Start() { DontDestroyOnLoad(this); loadedMods = new List <InternalMod>(); loadedMods.Add(new InternalMod(new LoaderMod(), Assembly.GetExecutingAssembly())); Commands.Initialize(); // Create the console before loading the config so it can display // possible errors. var console = Tools.Console.Instance; Configuration.Load(); Keybindings.LoadFromConfig(); Game.Initialize(); SettingsMenu.Initialize(); OptionsMenu.Initialize(); MachineData.Initialize(); Tools.ModToggle.Initialize(); Tools.Keymapper.Initialize(); #if DEV_BUILD Tools.ObjectExplorer.Initialize(); if (Environment.CommandLine.Contains("-enable-debug-server")) { Tools.DebugServer.Initialize(); Tools.DebugServer.Instance.StartDebugServer(5000); } #endif // Enable the console interface since it can now ask the configuration // for the correct keys to use. console.EnableInterface(); var blockLoaderInfo = new TheGuysYouDespise.BlockLoaderInfo(); blockLoaderInfo.LoadBlockLoader(); LoadMods(); RegisterModManagementCommands(); InitializeMods(); UpdateChecker.Initialize(); }
public override object GetSecondAnwer(string input) { MachineData target = new MachineData() { Children = 3, Cats = 7, Samoyeds = 2, Pomeranians = 3, Akitas = 0, Vizslas = 0, Goldfish = 5, Trees = 3, Cars = 2, Perfumes = 1 }; foreach (var item in input.SplitLines()) { var newAunt = new MachineData(item); if (newAunt.EqualByRetroencabulator(target)) { return(newAunt.AuntNumber); } } return("nothing"); }
public void CreateProfileString(MachineData machineData) { if (machineData.ProfileStrings == null) { return; } if (machineData.ProfileStrings.Count == 0) { return; } foreach (var profile in machineData.ProfileStrings) { WritePrivateProfileString(profile.Section, profile.Key, profile.Value, profile.FilePath); Define.Logger.AddLog("DATA", $"Write \"{profile.Section}\"{profile.Key}={profile.Value} to file {profile.FilePath} Success!"); } }
private MachineData GetMachineData(RegisterIssueRequest request, ISession session) { MachineData md; if (request.Session.Machine == null) { var machine = _machineBusiness.GetMachine(session.MachineFingerprint); md = new MachineData { Fingerprint = machine.Id, Name = machine.Name, Data = machine.Data, }; } else { md = request.Session.Machine; } return(md); }
public void MachineFolderCreate(MachineData machineData) { if (machineData.ToCreatePaths == null) { return; } if (machineData.ToCreatePaths.Count == 0) { return; } foreach (string folder in machineData.ToCreatePaths) { Directory.CreateDirectory(folder); Define.Logger.AddLog("DATA", $"Create \'{folder}\' Success!"); } }
public void AddProduct_CreateMachine_ValidateProducts() { int capacity = 2; double length = 2.0; double width = 1.0; var machine = new MachineData(length, width, capacity); var prod1 = new ProductMock(); var prod2 = new ProductMock(); machine .AddProduct(prod1) .AddProduct(prod2); Assert.AreEqual(machine.Products.Count(), 2); Assert.AreSame(machine.Products.ElementAt(0), prod1); Assert.AreSame(machine.Products.ElementAt(1), prod2); Assert.IsTrue(machine.IsFull); }
public bool EqualByRetroencabulator(MachineData data) { return((Children == null || data.Children == Children) && (Samoyeds == null || data.Samoyeds == Samoyeds) && (Akitas == null || data.Akitas == Akitas) && (Vizslas == null || data.Vizslas == Vizslas) && (Goldfish == null || data.Goldfish > Goldfish) && (Pomeranians == null || data.Pomeranians > Pomeranians) && (Trees == null || data.Trees < Trees) && (Cats == null || data.Cats < Cats) && (Cars == null || data.Cars == Cars) && (Perfumes == null || data.Perfumes == Perfumes)); }
public async Task <IActionResult> Create([Bind("Id,Name,MachineDataId,TaskId")] Machine machine) { if (ModelState.IsValid) { var data = new MachineData(); _context.Add(data); machine.MachineData = data; _context.Add(machine); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MachineDataId"] = new SelectList(_context.MachineDatas, "Id", "Id", machine.MachineDataId); ViewData["TaskId"] = new SelectList(_context.Tasks, "TaskId", "TaskId", machine.TaskId); return(View(machine)); }
public IActionResult CreateMachine([FromBody] List <string> code) { var compilado = Compilador.Compilar(code); if (compilado.Erros.Count > 0) { return(BadRequest(compilado.Erros)); } var newUc = CriaUC(code, compilado); var virtualUc = new MachineData(); virtualUc.codigo = code; virtualUc.Key = Guid.NewGuid(); virtualUc.uc = newUc; _data.Add(virtualUc); return(Ok(PcToResult(virtualUc))); }
private void OnTimedEvent(object source, ElapsedEventArgs e) { mTimer.Stop(); MachineData mdata = new MachineData(); LogMan.AddLog("Fetching Smart"); mdata.disks = tvstools.ReadSmart(); GC.KeepAlive(mTimer); LogMan.AddLog("Fetching Network Devices"); mdata.ethernets = tvstools.GetNetworkDevices(); GC.KeepAlive(mTimer); LogMan.AddLog("Fetching Mount Points"); mdata.mounts = tvstools.GetMountPoints(); GC.KeepAlive(mTimer); mdata.UUID = MachineUUID; mdata.UpTime = tvstools.GetUpTime(); mdata.Processor = tvstools.GetProcessorName(); mdata.OS = tvstools.GetOSName(); mdata.FreeMemory = tvstools.GetFreeMemory(); mdata.FreeSwap = tvstools.GetFreeSwapMemory(); mdata.TotalMemory = tvstools.GetTotalMemory(); mdata.TotalSwap = tvstools.GetTotalSwapMemory(); mdata.Name = Name; LogMan.AddDebug(mdata.ToJSON()); GC.KeepAlive(mTimer); LogMan.AddLog("Sending data"); if (API.SendMachine(mdata)) { if (MachineUUID == null) { MachineUUID = API.MachineUUID; LogMan.AddLog("First time of this machine! Now the UUID is: " + MachineUUID); RegMan.Write("MachineUUID", MachineUUID); } LogMan.AddLog("Data sent successfully!"); } else { LogMan.AddLog("Fail sending machine data!"); } mTimer.Start(); }
public override void OnLoad(BlockXDataHolder stream) { if (toRemove) { return; } if (AddPiece.isSimulating) { return; } if (stream.HasKey("modLoader-machineData")) { MachineData.LoadData(stream.ReadString("modLoader-machineData")); } else { MachineData.LoadData("NOTFOUND"); } }
public ManagementScope LoginToMachine(string machineAddress, out bool isLoginSuccess) { MachineData machineData = new MachineData(); ManagementScope scope = null; try { string machineIp = GetIpAddressFromMachineAddress(machineAddress); string IP = $@"\\{machineIp}\root\cimv2"; // remote IP string username = AppSettings["userName"]; // remote username string password = AppSettings["password"]; // remote password ConnectionOptions connectoptions = new ConnectionOptions(); connectoptions.Username = username; connectoptions.Password = password; machineData.MachineName = machineAddress; machineData.MachineIp = machineIp; scope = new ManagementScope(IP, connectoptions); scope.Connect(); LoginSuccess = true; try { // Check if Services are accessible ServiceController[] services = ServiceController.GetServices(scope.Path.Server); } catch (Exception ex) { machineData.ErrorMessage = ex.Message; LoginSuccess = false; } } catch (Exception e) { LoginSuccess = false; machineData.ErrorMessage = e.Message; } machineData.isSuccess = LoginSuccess; MachineServicesList.Add(machineData); isLoginSuccess = LoginSuccess; return(scope); }
public void MachineFileCreate(MachineData machineData) { if (machineData.ToCreateFiles == null) { return; } if (machineData.ToCreateFiles.Count == 0) { return; } foreach (string file in machineData.ToCreateFiles) { // Create file if file not created if (File.Exists(file) == false) { Directory.CreateDirectory(Path.GetDirectoryName(file)); File.Create(file).Dispose(); Define.Logger.AddLog("DATA", $"Create \'{file}\' Success!"); } } }