コード例 #1
0
        protected void cbStart_Click(object sender, EventArgs e)
        {
            // create/confirm client table exists
            CloudStorageAccount cloudStorageAccount =
                CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
            CloudTableClient cloudClient = cloudStorageAccount.CreateCloudTableClient();
            cloudClient.CreateTableIfNotExist("client");

            // if table exists
            if (cloudClient.DoesTableExist("client"))
            {
                // create a new client info record to persist to table storage
                ClientInformation clientInfo = new ClientInformation(
                            txtName.Text,
                            PASSKEY,
                            TEAM_NUMBER,
                            Double.Parse(txtLatitudeValue.Value),
                            Double.Parse(txtLongitudeValue.Value),
                            Request.ServerVariables["SERVER_NAME"]);

                // add client info record
                var ctx = new ClientDataContext(
                   cloudStorageAccount.TableEndpoint.ToString(),
                   cloudStorageAccount.Credentials);
                ctx.AddObject("client", clientInfo);
                ctx.SaveChanges();

                // redirect to the status page
                Response.Redirect("/Status.aspx");
            }
        }
コード例 #2
0
        protected void cbStart_Click(object sender, EventArgs e)
        {
            // create/confirm client table exists
            ClientInformation clientInfo = new ClientInformation(
                            txtName.Text,
                            PASSKEY,
                            TEAM_NUMBER,
                            Double.Parse(txtLatitudeValue.Value),
                            Double.Parse(txtLongitudeValue.Value),
                            Request.ServerVariables["SERVER_NAME"]);
            _clientDataRepo.Save(clientInfo);
            // redirect to the status page
            if (!ApplicationSettings.RunningOnAzure)
            {
                Task task = Task.Factory.StartNew(() =>
                     {

                             FoldingClient client = FoldingClientFactory.CreateFoldingClient();
                             client.Launch();

                     });
            }
            Response.Redirect("/Status.aspx");
        }
コード例 #3
0
 public void Save(ClientInformation clientInfo)
 {
     MongoCollection<ClientInformation> coll = _mongoDatabase.GetCollection<ClientInformation>("clientinformation");
     coll.Insert(clientInfo);
 }
コード例 #4
0
 public void Save(ClientInformation clientInfo)
 {
     _tableClient.CreateTableIfNotExist(CLIENT_INFO_TABLE_NAME);
     // if table exists
     if (_tableClient.DoesTableExist(CLIENT_INFO_TABLE_NAME))
     {
         // add client info record
         _dataContext.AddObject(CLIENT_INFO_TABLE_NAME, clientInfo);
         _dataContext.SaveChanges();
     }
 }
コード例 #5
0
        public void Launch()
        {
            // write the configuration file with user information
            WriteConfigFile();

            // get path to the Folding@home client application
            LocalResource foldingIo = RoleEnvironment.GetLocalResource("ClientStorage");
            String targetPath = string.Format(@"{0}client", foldingIo.RootPath);
            String targetExecutable = string.Format(@"{0}client\{1}", foldingIo.RootPath,
                RoleEnvironment.GetConfigurationSettingValue("ClientEXE"));

            // get progress polling interval (default to 15 minutes)
            Int32 pollingInterval;
            if (!Int32.TryParse(
                RoleEnvironment.GetConfigurationSettingValue("PollingInterval"),
                out pollingInterval))
                pollingInterval = 15;

            //
            // setup process
            ProcessStartInfo startInfo = new ProcessStartInfo()
                {
                    UseShellExecute = false,
                    FileName = targetExecutable,
                    WorkingDirectory = targetPath,
                    WindowStyle = ProcessWindowStyle.Hidden,
                    Arguments = "-oneunit"
                };

            // loop while there's a client info record in Azure table storage
            while (this.Identity != null)
            {

                // start a work unit
                using (Process exeProcess = Process.Start(startInfo))
                {

                    while (!exeProcess.HasExited)
                    {
                        // get current status
                        FoldingClientStatus status = ReadStatusFile();

                        // update local status table (workunit table in Azure storage)
                        if (!status.HasParseError)
                        {
                            UpdateLocalStatus(status);
                            UpdateServerStatus(status);
                        }

                        Thread.Sleep(TimeSpan.FromMinutes(pollingInterval));
                    }

                    // when work unit completes successfully
                    if (exeProcess.ExitCode == 0)
                    {
                        // make last update for completed role
                        FoldingClientStatus status = ReadStatusFile();

                        if (!status.HasParseError)
                        {
                            UpdateLocalStatus(status);
                            UpdateServerStatus(status);
                        }
                    }
                    else
                    {
                        Trace.TraceError(String.Format("Folding@home process has exited with code {0}",
                            exeProcess.ExitCode));

                        // this will leave orphan progress record in the Azure table
                    }

                    // re-check client table to make sure there's still a record there, if not, that's
                    // the cue to stop the folding process
                    this.Identity = GetClientInformation();
                }
            }
        }
コード例 #6
0
 public FoldingClient(ClientInformation clientInfo)
 {
     this.Identity = clientInfo;
 }