public ActionResult Create(GenomeModel genomeModel)
        {
            if (ModelState.IsValid)
            {
                // TODO: Consider the JELLYFISH SIZE. Rec size is est_genome_size  * estimated coverage. (This should be done in Javascript).
                // Should that be a field that we include in the model so we can calculate a safe size or just
                // have them do it? I think just have them do it with a tooltip and make it a required field.
                try
                {
                    #region Set General Information

                    HelperMethods.SetDefaultMasurcaValues(genomeModel);

                    genomeModel.OverallCurrentStep = 1;
                    genomeModel.OverallStatus      = StepDescriptions.INITIAL_STEP;
                    genomeModel.NumberOfAssemblers = HelperMethods.NumberOfAssemblers(genomeModel.UseMasurca, genomeModel.UseSGA, genomeModel.UseWGS);

                    // TODO: Potentially add the model to the DB now with junk data to reserve the UUID so we don't have to use a SEED value at all. This
                    // reduces the potential of something going wrong and two people ending up with a race condition or something.

                    genomeModel.CreatedBy = User.Identity.Name;

                    // TODO: Need to look into this to see about a translation to display to a user rather than the UK time it gives.
                    genomeModel.CreatedDate = DateTime.UtcNow;

                    #endregion

                    #region Create Scripts

                    List <string> dataSources = HelperMethods.ParseUrlString(genomeModel.DataSource);

                    Random rand = new Random();
                    int    seed = rand.Next(198, 1248712);

                    JobBuilder builder = new JobBuilder(genomeModel, dataSources, seed);
                    builder.GenerateConfigs();

                    genomeModel.Seed = builder.seed; // Set seed value here so we know it is 100% definitely set.
                    #endregion

                    #region Connect To BigDog and Test Data Connection

                    string badUrl = HelperMethods.TestJobUrls(genomeModel.SSHUser, genomeModel.SSHPass, genomeModel.DataSource);

                    if (string.IsNullOrEmpty(badUrl) && string.IsNullOrEmpty(ErrorHandling.error))
                    {
                        /// We can instead pass in the SEED variable which will be used to reference the method in Locations to grab the correct file(s).
                        /// This is the ideal solution which will be implemented only once we know that the system works with the direct URL.
                        builder.CreateJob();

                        // No error so proceed.
                        if (ErrorHandling.NoError())
                        {
                            db.GenomeModels.Add(genomeModel);
                            db.SaveChanges();

                            return(RedirectToAction("Details", new { id = genomeModel.uuid }));
                        }

                        // Redisplay the data and display the error.
                        else
                        {
                            genomeModel.JobError = "We encountered an error while trying to submit your job. The following is the error we encountered: " + ErrorHandling.error;

                            return(View(genomeModel));
                        }
                    }

                    // Redisplay the data and display the error.
                    else
                    {
                        genomeModel.JobError = "There was an error with the URLs provided. We weren't able to locate or download at least"
                                               + " one of your files. The file we had a problem with was: " + badUrl + ". Please make sure you typed the URL correctly"
                                               + " and it is accessible. If this is in error, please contact an administrator promptly with the details.";

                        if (!string.IsNullOrEmpty(ErrorHandling.error))
                        {
                            genomeModel.JobError = string.Concat(genomeModel.JobError, " The following is additional error information that we encountered: " + ErrorHandling.error);
                        }

                        return(View(genomeModel));
                    }

                    #endregion
                }

                catch (Exception e)
                {
                    genomeModel.JobError = "There has been an uncaught error. " + e;
                }
            }

            return(View(genomeModel));
        }
Esempio n. 2
0
 private void menuItemProcesarSentenciasDeReplicacion_Click(object sender, System.EventArgs e)
 {
     _jobBuilder.CreateJob("CLIENT>SERVER");
 }