Esempio n. 1
0
 public RestartHubClient(MachineConfig machineConfig)
     : base(machineConfig)
 {
     this.restartHub        = this.HubConnection.CreateHubProxy("RestartHub");
     this.eventSubscription = this.restartHub.On("RestartIIS", RestartHubClient.RestartIIS);
     this.Connect();
 }
Esempio n. 2
0
        private void cmdNew_Click(object sender, EventArgs e)
        {
            // create a new profile, give it a name
            frmProfileName fpn = new frmProfileName();

            fpn.ShowDialog();
            String pf = fpn.ProfileName;

            if (pf.Length > 0)
            {
                //create a new profile with that name
                String fn = UVDLPApp.Instance().m_PathMachines;
                fn += UVDLPApp.m_pathsep;
                fn += pf;
                fn += ".machine";
                MachineConfig mc = new MachineConfig();
                mc.m_name = pf;
                if (!mc.Save(fn, txtIp.Text))
                {
                    DebugLogger.Instance().LogRecord("Error Saving new machine profile " + fn);
                    return;
                }
                UpdateProfiles();
            }
        }
        private void UpdateSwitchesBeforeSaved(MachineConfig mConfig)
        {
            //Save switches
            Log("Adding switches");
            foreach (var item in Switches)
            {
                var number = item.Number;

                //TODO: Keep or REMOVE for old column naming
                //if (MachineConfig.GetMachineType() == MachineType.PDB)
                //    number = item.Number.Split(':')[1];

                if (item.Name != "NOT USED")
                {
                    var sw = new PRSwitch()
                    {
                        Name         = item.Name,
                        Number       = number,
                        Tags         = item.Tags,
                        SwitchType   = item.Type,
                        Label        = item.Label,
                        VpSwitchType = item.VpSwitchType
                    };

                    if (item.BallSearch.Any(x => x != null))
                    {
                        sw.BallSearch = $"{item.BallSearch[0]}, {item.BallSearch[1]}";
                    }

                    mConfig.PRSwitches.Add(sw);
                }
            }
        }
Esempio n. 4
0
 public UserLogOnOff(MainForm mf, string user, MachineConfig mc)
 {
     InitializeComponent();
     currentUser       = user;
     mainForm          = mf;
     machineParameters = mc;
 }
Esempio n. 5
0
        public static async Task <Either <PowershellFailure, TypedPsObject <VirtualMachineInfo> > > Disk(
            VirtualMachineDiskConfig diskConfig,
            IPowershellEngine engine,
            TypedPsObject <VirtualMachineInfo> vmInfo,
            MachineConfig vmConfig,
            Func <string, Task> reportProgress)
        {
            if (!File.Exists(diskConfig.Path))
            {
                await reportProgress($"Create VHD: {diskConfig.Name}").ConfigureAwait(false);

                await engine.RunAsync(PsCommandBuilder.Create().Script(
                                          $"New-VHD -Path \"{diskConfig.Path}\" -ParentPath \"{diskConfig.Template}\" -Differencing"),
                                      reportProgress : p => ReportPowershellProgress($"Create VHD {diskConfig.Name}", p, reportProgress)).ConfigureAwait(false);
            }

            await GetOrCreateInfoAsync(vmInfo,
                                       i => i.HardDrives,
                                       disk => diskConfig.Path.Equals(disk.Path, StringComparison.OrdinalIgnoreCase),
                                       async() =>
            {
                await reportProgress($"Add VHD: {diskConfig.Name}").ConfigureAwait(false);
                return(await engine.GetObjectsAsync <HardDiskDriveInfo>(PsCommandBuilder.Create()
                                                                        .AddCommand("Add-VMHardDiskDrive")
                                                                        .AddParameter("VM", vmInfo.PsObject)
                                                                        .AddParameter("Path", diskConfig.Path)).ConfigureAwait(false));
            }).ConfigureAwait(false);

            return(vmInfo.Recreate());
        }
Esempio n. 6
0
 public static Task <Either <PowershellFailure, Seq <VMDriveStorageSettings> > > PlanDriveStorageSettings(
     MachineConfig config, VMStorageSettings storageSettings, HostSettings hostSettings, IPowershellEngine engine)
 {
     return(config.VM.Drives
            .ToSeq().MapToEitherAsync((index, c) =>
                                      DriveConfigToDriveStorageSettings(index, c, storageSettings, hostSettings)));
 }
        public static IMachineBuilder AddMachine(this IServiceCollection services,
                                                 Action <MachineConfig> setupAction)
        {
            var config = new MachineConfig();

            setupAction(config);
            services.AddSingleton <IEngineServiceInternal, EngineService>();
            services.AddSingleton <IEngineService>(sp => sp.GetService <IEngineServiceInternal>());
            services.AddTransient <EngineRuntime>();
            services.AddSingleton <IBuildHandler, BuildHandler>();

            services.Configure <MvcOptions>(o =>
            {
                o.Filters.Add <OperationCancelledExceptionFilter>();
                o.Conventions.Add(new MachineApplicationModelConvention(config.Namespace,
                                                                        config.AuthenticationSchemes));
            });
            services.Configure <MvcNewtonsoftJsonOptions>(o =>
            {
                o.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            });
            services.Configure <RouteOptions>(o => o.LowercaseUrls = true);

            var builder = new MachineBuilder(services);

            builder.AddThotSmtModel();
            builder.AddTransferEngine();
            builder.AddMemoryDataAccess();
            builder.AddTextFileTextCorpus();
            return(builder);
        }
        public async Task <long> Handle(CreateOrUpdateInstanceSettingsTemplateCommand request, CancellationToken cancellationToken)
        {
            MachineConfig instanceSettingsTemplate;

            if (request.Id > 0)
            {
                instanceSettingsTemplate = await _context.Set <MachineConfig>()
                                           .FirstOrDefaultAsync(x => x.IsTemplate && x.Id == request.Id, cancellationToken);

                if (instanceSettingsTemplate == null)
                {
                    throw new EntityNotFoundException(nameof(MachineConfig), request.Id);
                }
            }
            else
            {
                instanceSettingsTemplate = new MachineConfig()
                {
                    IsTemplate = true
                };
                _context.Set <MachineConfig>().Add(instanceSettingsTemplate);
            }

            Mapper.Map(request, instanceSettingsTemplate);

            await _context.SaveChangesAsync(cancellationToken);

            return(instanceSettingsTemplate.Id);
        }
Esempio n. 9
0
        public SelectRecipe(MainForm mf, MachineConfig mc)
        {
            InitializeComponent();

            mainForm         = mf;
            machineParamters = mc;
        }
Esempio n. 10
0
        private void cmdShutterOpen(object sender, object e)
        {
            try
            {
                //get the right parameter from the machine configuration
                string        openshutter = "cmdOpenShutter";
                MachineConfig cfg         = UVDLPApp.Instance().m_printerinfo;

                CWParameter parm = cfg.userParams.paramDict[openshutter];
                if (parm != null)
                {
                    //get the value
                    GuiParam <string> dat  = (GuiParam <string>)parm;
                    string            cmds = dat.GetVal();
                    foreach (string gcode in cmds.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        string tmp = gcode.Trim();
                        UVDLPApp.Instance().m_deviceinterface.SendCommandToDevice(tmp + "\r\n");
                    }
                }
            }catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
Esempio n. 11
0
        public UserAccessSettings(MainForm mf, MachineConfig mc)
        {
            InitializeComponent();

            mainForm          = mf;
            machineParameters = mc;
        }
Esempio n. 12
0
 private void lstMachineProfiles_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstMachineProfiles.SelectedIndex != -1)
     {
         UpdateButtons();
         // the profile may have changed,
         if (cmbMachineProfiles.SelectedItem.ToString().Equals(lstMachineProfiles.SelectedItem.ToString()))
         {
             //we clicked on the current profile
             m_config = null;
             m_config = UVDLPApp.Instance().m_printerinfo;
             SetData(); // show the data
             UpdateMainConnection();
             UpdateDisplayConnection();
         }
         else
         {
             //load this profile
             string filename = UVDLPApp.Instance().m_PathMachines + UVDLPApp.m_pathsep + lstMachineProfiles.SelectedItem.ToString() + ".machine";
             m_config = new MachineConfig();
             m_config.Load(filename);
             SetData(); // show the data
             UpdateMainConnection();
             UpdateDisplayConnection();
         }
     }
 }
Esempio n. 13
0
        override public void Initialize(string symbolName, MachineConfig machineConfig)
        {
            var areaSize    = machineConfig.blankSymbolSize;
            var displayArea = SlotModel.Instance.SlotConfig.DebugSymbolArea;

            Initialize(symbolName, areaSize, displayArea);
        }
        /// <summary>
        /// Parses the machine configuration to MachineConfigDict then to a listed MachineConfig
        /// </summary>
        /// <param name="ex">The ex.</param>
        private void ParseMachineConfigWithKeyValues(System.Exception ex)
        {
            var result = System.Windows.MessageBox.Show
                             ($"Error parsing machine.yaml \n\r Yaml entries must be converted to list before use here\n\r See EmptyGames machine.yaml\n\r {ex.Message}", "Couldn't parse machine, Convert and backup?", System.Windows.MessageBoxButton.YesNo);

            //Parse with different object
            if (result == System.Windows.MessageBoxResult.Yes)
            {
                try
                {
                    var machineConfigFile = Path.Combine(GameFolder, YamlFiles[5]);
                    MachineConfigDict = _skeletonGameSerializer.DeserializeSkeletonYaml <MachineConfigDict>(machineConfigFile);

                    Log($"Saving machine.yaml to {machineConfigFile}.bak");
                    File.Delete(machineConfigFile + ".bak");
                    File.Copy(machineConfigFile, machineConfigFile + ".bak");

                    if (MachineConfigDict != null)
                    {
                        Log("Converting machine.yaml dictionary to list");

                        foreach (var coil in MachineConfigDict.PRCoils.Select(x => x))
                        {
                            coil.Value.Name = coil.Key;
                        }
                        Log($"Coils converted = {string.Join(", ", MachineConfigDict.PRCoils.Select(x => x.Value.Name))}");

                        foreach (var lamp in MachineConfigDict.PRLamps.Select(x => x))
                        {
                            lamp.Value.Name = lamp.Key;
                        }
                        Log($"Lamps converted = {string.Join(", ", MachineConfigDict.PRLamps.Select(x => x.Value.Name))}");

                        foreach (var sw in MachineConfigDict.PRSwitches.Select(x => x))
                        {
                            sw.Value.Name = sw.Key;
                        }
                        Log($"Lamps converted = {string.Join(", ", MachineConfigDict.PRSwitches.Select(x => x.Value.Name))}");

                        MachineConfig = new MachineConfig()
                        {
                            PRGame     = MachineConfigDict.PRGame,
                            PRBumpers  = MachineConfigDict.PRBumpers,
                            PRFlippers = MachineConfigDict.PRFlippers,
                            PRCoils    = MachineConfigDict.PRCoils.Select(x => x.Value).ToList(),
                            PRLamps    = MachineConfigDict.PRLamps.Select(x => x.Value).ToList(),
                            PRSwitches = MachineConfigDict.PRSwitches.Select(x => x.Value).ToList()
                        };

                        this.SaveMachineConfig(MachineConfig);
                        MachineConfigDict = null;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Esempio n. 15
0
 public Engineering(AbbCom.Client lc, MachineConfig mc, RuntimeParameters rp, MainForm mf)
 {
     logClient         = lc;
     machineParameters = mc;
     runtimeParameters = rp;
     mainForm          = mf;
     InitializeComponent();
 }
Esempio n. 16
0
 public BMapPainter(Texture2D tex, Box2 viewBox)
 {
     map                = new SCBitmap(tex);
     this.viewBox       = viewBox;
     BitMapToPaperScale = viewBox.getFitScale(map.size);
     dbugSettings       = UnityEngine.Object.FindObjectOfType <DbugSettings>();
     machineConfig      = UnityEngine.Object.FindObjectOfType <MachineConfig>();
 }
Esempio n. 17
0
        public FormUserSetPassword(MainForm mf, MachineConfig mc, string u)
        {
            InitializeComponent();

            mainForm          = mf;
            machineParameters = mc;
            user = u;
        }
Esempio n. 18
0
        public SystemOptions(MainForm mf, MachineConfig mc)
        {
            InitializeComponent();

            mainForm          = mf;
            machineParameters = mc;
            restoreParameters = mc.ShallowCopy();
        }
Esempio n. 19
0
 public async Task <IActionResult> Post([FromBody] MachineConfig config)
 {
     return(Ok(await _operationManager.StartNew(
                   new ConvergeVirtualMachineCommand
     {
         Config = config,
     }
                   ).ConfigureAwait(false)));
 }
Esempio n. 20
0
 public SCBitmap(Texture2D tex)
 {
     this.tex          = tex;
     dbugSettings      = UnityEngine.Object.FindObjectOfType <DbugSettings>();
     machineConfig     = UnityEngine.Object.FindObjectOfType <MachineConfig>();
     stripeFieldConfig = UnityEngine.Object.FindObjectOfType <StripeFieldConfig>();
     lineWidth         = stripeFieldConfig.lineWidth;
     size = new Vector2(tex.width, tex.height);
 }
 public List <Object> FindMaterialForMachine(Chest chest, MachineConfig machineConfig)
 {
     return(chest?.items
            .OfType <Object>()
            .Where(i =>
                   i.quality <= machineConfig.MaxQuality &&
                   (machineConfig.IsAcceptableObject(i) || machineConfig.IsAcceptableCategory(i))
                   )
            .ToList());
 }
Esempio n. 22
0
 void Setup()
 {
     finished        = false;
     canvasClone     = Instantiate(canvas);
     mat.mainTexture = canvasClone;
     machineConfig   = FindObjectOfType <MachineConfig>();
     gCodeWriter     = FindObjectOfType <GCodeWriter>();
     dbugSettings    = FindObjectOfType <DbugSettings>();
     painter         = new BMapPainter(canvasClone, machineConfig.paper);
 }
Esempio n. 23
0
        public Vision(MainForm mf, RuntimeParameters rp, CogJobManager cjm, MachineConfig mc)
        {
            InitializeComponent();

            mainForm          = mf;
            runtimeParameters = rp;
            machineParameters = mc;
            restoreParameters = rp.ShallowCopy();
            mcjmAcq           = cjm;
        }
 private static bool MatchTemplate(MachineConfig templateConfig, MachineConfig machineConfig)
 {
     return(new VersionInfo(machineConfig.LauncherHash).Hash == new VersionInfo(templateConfig.LauncherHash).Hash&&
            new VersionInfo(machineConfig.ReportingHash).Hash == new VersionInfo(templateConfig.ReportingHash).Hash&&
            new VersionInfo(machineConfig.PdfExportHash).Hash == new VersionInfo(templateConfig.PdfExportHash).Hash&&
            new VersionInfo(machineConfig.SiteMasterHash).Hash == new VersionInfo(templateConfig.SiteMasterHash).Hash&&
            new VersionInfo(machineConfig.ClientHash).Hash == new VersionInfo(templateConfig.ClientHash).Hash&&
            new VersionInfo(machineConfig.RelExportHash).Hash == new VersionInfo(templateConfig.RelExportHash).Hash&&
            new VersionInfo(machineConfig.DeployerHash).Hash == new VersionInfo(templateConfig.DeployerHash).Hash&&
            new VersionInfo(machineConfig.PopulateHash).Hash == new VersionInfo(templateConfig.PopulateHash).Hash);
 }
Esempio n. 25
0
 void Start()
 {
     startFileLines = new List <string>();
     lines          = new List <string>(1000);
     machineConfig  = FindObjectOfType <MachineConfig>();
     Reset();
     floatFormatter = "0.";
     for (int i = 0; i < machineConfig.moveCoordFloatPrecision; ++i)
     {
         floatFormatter = string.Format("{0}0", floatFormatter);
     }
 }
 public void SaveMachineConfig(MachineConfig mConfig)
 {
     try
     {
         Log($"Saving {GameFolder + "\\" + YamlFiles[5]}");
         _skeletonGameSerializer.SerializeYaml(GameFolder + "\\" + YamlFiles[5], mConfig);
     }
     catch (Exception ex)
     {
         Log(ex.Message, Category.Exception);
     }
 }
Esempio n. 27
0
        public HubClient(MachineConfig machineConfig)
        {
            this.machineConfig = machineConfig;

            // recomended by MS
            ServicePointManager.DefaultConnectionLimit = 10;

            string webAddress = ConfigurationManager.AppSettings["WebAddress"];

            this.hubConnection = new HubConnection(webAddress);
            this.hubConnection.StateChanged += HubClient.LogStateChanges;
            this.hubConnection.Closed       += this.Reconnect;
        }
 private Task <Either <PowershellFailure, TypedPsObject <VirtualMachineInfo> > > ConvergeVm(
     TypedPsObject <VirtualMachineInfo> vmInfo,
     MachineConfig machineConfig,
     VMStorageSettings storageSettings,
     HostSettings hostSettings,
     IPowershellEngine engine)
 {
     return
         (from infoFirmware in Converge.Firmware(vmInfo, machineConfig, engine, ProgressMessage)
          from infoCpu in Converge.Cpu(infoFirmware, machineConfig.VM.Cpu, engine, ProgressMessage)
          from infoDrives in Converge.Drives(infoCpu, machineConfig, storageSettings, hostSettings, engine, ProgressMessage)
          from infoNetworks in Converge.NetworkAdapters(infoDrives, machineConfig.VM.NetworkAdapters.ToSeq(), machineConfig, engine, ProgressMessage)
          from infoCloudInit in Converge.CloudInit(infoNetworks, storageSettings.VMPath, machineConfig.Provisioning, engine, ProgressMessage)
          select infoCloudInit);
 }
Esempio n. 29
0
        public static void Main()
        {
            var resetEvent = new AutoResetEvent(initialState: false);

            Console.CancelKeyPress += (s, e) => { e.Cancel = true; resetEvent.Set(); };
            STOPWATCH = new Stopwatch();
            STOPWATCH.Start();
            ConsoleLogger.Log($"[{KeyName}] start");
            Scheduler = new JobManager();
            var urlFile = $"{Parameter.AntdCfg}/host_reference";

            while (!File.Exists(urlFile))
            {
                Thread.Sleep(500);
                ConsoleLogger.Warn($"[{KeyName}] waiting for server");
            }
            while (string.IsNullOrEmpty(File.ReadAllText(urlFile)))
            {
                Thread.Sleep(500);
                ConsoleLogger.Warn($"[{KeyName}] waiting for server");
            }
            ServerUrl            = File.ReadAllText(urlFile);
            CurrentConfiguration = Help.GetCurrentConfiguration();
            while (CurrentConfiguration == null)
            {
                ConsoleLogger.Warn($"[{KeyName}] waiting for server");
                Thread.Sleep(500);
                CurrentConfiguration = Help.GetCurrentConfiguration();
            }
            var port       = CurrentConfiguration.WebService.GuiWebServicePort;
            var uri        = $"http://localhost:{port}/";
            var webService = new NancyHost(new Uri(uri));

            webService.Start();
            StaticConfiguration.DisableErrorTraces = false;
            ConsoleLogger.Log($"[{KeyName}] web service is listening on port {port}");
            ConsoleLogger.Log($"[{KeyName}] loaded in: {STOPWATCH.ElapsedMilliseconds} ms");

            #region [    Set Parameters    ]
            ServerUrl = CommonString.Append(CurrentConfiguration.WebService.Protocol, "://", CurrentConfiguration.WebService.Host, ":", CurrentConfiguration.WebService.Port.ToString());
            #endregion

            resetEvent.WaitOne();
            webService.Stop();
            STOPWATCH.Stop();
            ConsoleLogger.Log($"[{KeyName}] stop");
            Environment.Exit(0);
        }
Esempio n. 30
0
        public static async Task Definition(
            IPowershellEngine engine,
            TypedPsObject <VirtualMachineInfo> vmInfo,
            MachineConfig vmConfig,
            Func <string, Task> reportProgress)
        {
            if (vmInfo.Value.Generation >= 2)
            {
                await engine.GetObjectsAsync <VMFirmwareInfo>(PsCommandBuilder.Create()
                                                              .AddCommand("Get-VMFirmware")
                                                              .AddParameter("VM", vmInfo.PsObject)).MapAsync(async(firmwareInfo) =>
                {
                    if (firmwareInfo.Head.Value.SecureBoot != OnOffState.Off)
                    {
                        await reportProgress($"Configure VM Firmware - Secure Boot: {OnOffState.Off}")
                        .ConfigureAwait(false);

                        await engine.RunAsync(PsCommandBuilder.Create()
                                              .AddCommand("Set-VMFirmware")
                                              .AddParameter("VM", vmInfo.PsObject)
                                              .AddParameter("EnableSecureBoot", OnOffState.Off)).ConfigureAwait(false);
                    }
                }).ConfigureAwait(false);
            }


            if (vmInfo.Value.ProcessorCount != vmConfig.VM.Cpu.Count)
            {
                await reportProgress($"Configure VM Processor: Count: {vmConfig.VM.Cpu.Count}").ConfigureAwait(false);

                await engine.RunAsync(PsCommandBuilder.Create()
                                      .AddCommand("Set-VMProcessor")
                                      .AddParameter("VM", vmInfo.PsObject)
                                      .AddParameter("Count", vmConfig.VM.Cpu.Count)).ConfigureAwait(false);
            }

            var memoryStartupBytes = vmConfig.VM.Memory.Startup * 1024L * 1024;

            if (vmInfo.Value.MemoryStartup != memoryStartupBytes)
            {
                await reportProgress($"Configure VM Memory: Startup: {vmConfig.VM.Memory.Startup} MB").ConfigureAwait(false);

                await engine.RunAsync(PsCommandBuilder.Create()
                                      .AddCommand("Set-VMMemory")
                                      .AddParameter("VM", vmInfo.PsObject)
                                      .AddParameter("StartupBytes", memoryStartupBytes)).ConfigureAwait(false);
            }
        }
 private void cmdEdit_Click(object sender, EventArgs e)
 {
     if (lstMachineProfiles.SelectedIndex != -1)
     {
         string fn = FNFromIndex(lstMachineProfiles.SelectedIndex);
         if (fn != null)
         {
             MachineConfig mc = null;
             if (UVDLPApp.Instance().m_printerinfo.m_filename.Equals(fn))
             {
                 mc = UVDLPApp.Instance().m_printerinfo; // current machine profile
             }
             else
             {
                 mc = new MachineConfig(); // existing but not current
                 mc.Load(fn);
             }
             frmMachineConfig maccfg = new frmMachineConfig(ref mc);
             maccfg.Show();
         }
     }
 }
 private void ConfigUpdated(String filename)
 {
     //load and make active
     if (UVDLPApp.Instance().LoadMachineConfig(filename) != true)
     {
         MessageBox.Show("Error loading machine configuration");
         //should try to load/create a valid one
         return;
     }
     UVDLPApp.Instance().SetupDriver();
     //load this profile
     //string filename = UVDLPApp.Instance().m_PathMachines + UVDLPApp.m_pathsep + lstMachineProfiles.SelectedItem.ToString() + ".machine";
     m_config = new MachineConfig();
     m_config.Load(filename);
     SetData(); // show the data
     UpdateMainConnection();
     UpdateDisplayConnection();
     //show the info on the GUI
 }
Esempio n. 33
0
 /// <summary>
 /// Create a new MachineConfig object.
 /// </summary>
 /// <param name="ID">Initial value of Id.</param>
 public static MachineConfig CreateMachineConfig(int ID)
 {
     MachineConfig machineConfig = new MachineConfig();
     machineConfig.Id = ID;
     return machineConfig;
 }
 private void cmdNew_Click(object sender, EventArgs e)
 {
     // create a new profile, give it a name
     frmProfileName fpn = new frmProfileName();
     fpn.ShowDialog();
     String pf = fpn.ProfileName;
     if (pf.Length > 0)
     {
         //create a new profile with that name
         String fn = UVDLPApp.Instance().m_PathMachines;
         fn += UVDLPApp.m_pathsep;
         fn += pf;
         fn += ".machine";
         MachineConfig mc = new MachineConfig();
         mc.m_name = pf;
         if (!mc.Save(fn))
         {
             DebugLogger.Instance().LogRecord("Error Saving new machine profile " + fn);
             return;
         }
         UpdateProfiles();
     }
 }
 private void lstMachineProfiles_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstMachineProfiles.SelectedIndex != -1)
     {
         UpdateButtons();
         // the profile may have changed,
         if (cmbMachineProfiles.SelectedItem.ToString().Equals(lstMachineProfiles.SelectedItem.ToString()))
         {
             //we clicked on the current profile
             m_config = null;
             m_config = UVDLPApp.Instance().m_printerinfo;
             SetData(); // show the data
         }
         else
         {
             //load this profile
             string filename = UVDLPApp.Instance().m_PathMachines + UVDLPApp.m_pathsep + lstMachineProfiles.SelectedItem.ToString() + ".machine";
             m_config = new MachineConfig();
             m_config.Load(filename);
             SetData(); // show the data
         }
     }
 }
Esempio n. 36
0
        internal static void AssignReleaseMachine(MachineConfig freeMachine, bool IsAssign)
        {
            if (freeMachine == null)
                return;

            string spName = IsAssign ? "AssignMachine" : "ReleaseMachine";
            SqlClient.SqlConnection sqlCon = new System.Data.SqlClient.SqlConnection(remoteClientConfigDb);
            sqlCon.Open();
            SqlClient.SqlCommand sqlCommand = new System.Data.SqlClient.SqlCommand(spName, sqlCon);
            sqlCommand.CommandType = CommandType.StoredProcedure;
            SqlClient.SqlParameter machineIDParam = new System.Data.SqlClient.SqlParameter("@MachineID", freeMachine.MachineID);
            sqlCommand.Parameters.Add(machineIDParam);
            sqlCommand.ExecuteNonQuery();

        }
Esempio n. 37
0
        /// <summary>
        /// Writes the test configuration to an xml file which can be read by remote clients
        /// </summary>
        /// <param name="uris"></param>
        /// <example>
        /// <root>
        ///     <browser></browser>
        ///     <browseraction>start/stop</browseraction>
        ///     <services>
        ///         <service>"Uri Goes Here"</service>
        ///         <service>"Uri Goes Here"</service>
        ///     </services>
        /// </root>
        /// </example> 
        internal static void WriteConfigFile(string[] uris, string browserAction)
        {
            string browserExecutable = GetBrowserExe(AstoriaTestProperties.AstoriaClientBrowser);

            XDocument xDoc = new XDocument();
            XName xnRoot = XName.Get("root");
            XName xnBrowser = XName.Get("browser");
            XName xnBrowserAction = XName.Get("browseraction");
            XName xnServiceS = XName.Get("services");
            XName xnService = XName.Get("service");


            XElement xeRoot = new XElement(xnRoot);

            #region  add <browser> node
            XElement xeBrowser = new XElement(xnBrowser);
            xeBrowser.Value = browserExecutable;
            XElement xeBrowserAction = new XElement(xnBrowserAction);
            xeBrowserAction.Value = browserAction;
            #endregion add <browser> node
            #region  add <services> node
            XElement xeServiceS = new XElement(xnServiceS);
            foreach (string serviceURI in uris)
            {
                XElement xeService = new XElement(xnService);
                xeService.Value = serviceURI;
                xeServiceS.Add(xeService);
            }
            #endregion  add <services> node

            xeRoot.Add(xeBrowser);
            xeRoot.Add(xeBrowserAction);
            xeRoot.Add(xeServiceS);
            xDoc.Add(xeRoot);


            AstoriaTestLog.WriteLine("Waiting for machine {0} , {1}", AstoriaTestProperties.AstoriaClientOS.ToString(), AstoriaTestProperties.AstoriaClientBrowser.ToString());
            while (_currentTestMachine == null || String.IsNullOrEmpty(_currentTestMachine.MachineName))
            {
                _currentTestMachine = GetAvailableMachine();
                if (_currentTestMachine.MachineName == null)
                {
                    AstoriaTestLog.Write(".");
                }
                System.Threading.Thread.Sleep(10000);
            }
            if (!String.IsNullOrEmpty(_currentTestMachine.MachineName))
            {
                AstoriaTestLog.WriteLine("Remote Client Machine is : {0}", _currentTestMachine.MachineName);
                AssignMachine();
                xDoc.Save(Path.Combine(remoteClientConfigDropShare, _currentTestMachine.MachineName.Trim(' ') + ".xml"), System.Xml.Linq.SaveOptions.None);
            }
            else
            {
                throw (new TestFailedException(String.Format("Failed to find Machines for the config : {0} , {1}", AstoriaTestProperties.AstoriaClientOS.ToString(), AstoriaTestProperties.AstoriaClientBrowser.ToString())));
            }
        }
Esempio n. 38
0
        internal static MachineConfig GetAvailableMachine()
        {
            MachineConfig freeMachine = new MachineConfig();

            #region Get Available Machine
            SqlClient.SqlConnection sqlCon = new System.Data.SqlClient.SqlConnection(remoteClientConfigDb);
            sqlCon.Open();

            SqlClient.SqlCommand sqlCommand = new System.Data.SqlClient.SqlCommand("GetAvailableMachines", sqlCon);

            #region staging
            SqlClient.SqlParameter osNameParam = new System.Data.SqlClient.SqlParameter("@OsName", AstoriaTestProperties.AstoriaClientOS.ToString());

            SqlClient.SqlParameter browserNameParam = new System.Data.SqlClient.SqlParameter("@BrowserName", AstoriaTestProperties.AstoriaClientBrowser.ToString());
            SqlClient.SqlParameter silverlightVersionParam = new System.Data.SqlClient.SqlParameter("@SilverlightVersion", "3.0.2.1");
            sqlCommand.Parameters.Add(osNameParam);
            sqlCommand.Parameters.Add(browserNameParam);
            sqlCommand.Parameters.Add(silverlightVersionParam);
            sqlCommand.CommandType = CommandType.StoredProcedure;
            #endregion

            SqlClient.SqlDataReader machines = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
            while (machines.Read())
            {

                freeMachine.MachineID = Int32.Parse(machines["MachineID"].ToString());
                freeMachine.MachineName = machines["MachineName"].ToString();
                freeMachine.IPAddress = machines["IPAddress"].ToString();
                break;
            }
            #endregion Get Available Machine


            if (sqlCon.State == ConnectionState.Open)
            {
                sqlCon.Close();
            }


            return freeMachine;
        }