コード例 #1
0
        /// <summary>
        /// This method gets called when the user clicks the "Compare" button on the UI. The data loading process does not actually happen here,
        /// so take a look in the btnLoadData_Click() method (Preview button Click handler) for details.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRead_Click(object sender, EventArgs e)
        {
            // NOTE: on this page the values for the ComparisonData class get read in when you hit the "Preview" button

            bool isTest = sender is FST.Web.Admin.frmTestCenter;

            FST.Web.Admin.frmTestCenter testPage = isTest ? sender as FST.Web.Admin.frmTestCenter : null;
            if (isTest)
            {
                throw new NotImplementedException("The File Upload functionality was never finished for the testing center on the new pages. If this must be tested independently of the manual entry, there shouldn't be that much work to do. Copy the way this works from the manual entry page. Most of it should already be in place.");        //comparisonData = testPage.comparisonData;
            }
            comparisonData.ReportDate = DateTime.Now;

            // validate form
            if (!isTest && !FieldChecks())
            {
                return;
            }

            // go to the background service if we're doing a bulk or an individual search that runs long
            if (comparisonData.Bulk || comparisonData.RunIndividualOnService)
            {
                ProcessInBackgroundService(testPage);
            }
            else
            {
                if (!isTest)
                {
                    Log.Info(Context.User.Identity.Name, Request.FilePath, Session, "Comparison Start", comparisonData.HpHead + "/" + comparisonData.HdHead);
                }

                // instantiate the comparison class with our comparison data
                FST.Common.Comparison comparison = new Comparison(comparisonData);

                Dictionary <string, float> result = comparison.DoCompare(null, null, null, null, null, null);

                if (!isTest)
                {
                    Log.Info(Context.User.Identity.Name, Request.FilePath, Session, "Comparison End", comparisonData.HpHead + "/" + comparisonData.HdHead);
                }

                // print a PDF report
                Print();
            }
        }
コード例 #2
0
        /// <summary>
        /// This method is called if we're running a report in the Windows Serivce. It checks if a comparisons file was uploaded for a bulk report
        /// using the "From File" method and processes that if we have one. Then we save the serialized comparison data along with the file to
        /// the database, and we call the web service which the windows service extends to notify it of the new job to be processed.
        /// </summary>
        /// <param name="testPage">If this is a test, we pass it in so we can get our comparison data.</param>
        private void ProcessInBackgroundService(FST.Web.Admin.frmTestCenter testPage)
        {
            bool isTest = testPage != null;

            DataTable fromFileTable = null;
            Guid      jobGuid       = Guid.Empty;

            // if we're doing a bulk comparison or we're doing a test
            if (comparisonData.BulkType == ComparisonData.enBulkType.FromFile || isTest)
            {
                // this is the GUID we send to the database that identifies this set of profiles as associated with this comparison
                Guid fromFileID = Guid.NewGuid();
                // if this isn't the test, process the uploaded file. read the Business_Interfae.GetProfilesFromFile() method for details on file format and other peculiarities
                fromFileTable = isTest ? testPage.comparisonProfiles : bi.GetProfilesFromFile(fuPopulationUpload, Server.MapPath("~/Admin/Upload/"), comparisonData.LabKitID);
                comparisonData.FromFileName = isTest ? string.Empty : fuPopulationUpload.FileName;
                if (fromFileTable == null)
                {
                    return;                        // the error message comes from Business_Interface.GetProfilesFromFile((, don't worry
                }
                fromFileTable.Columns.Add(new DataColumn("GUID", typeof(Guid)));
                // set our GUID for each of the rows
                foreach (DataRow dr in fromFileTable.Rows)
                {
                    dr["GUID"] = fromFileID;
                }
                // set our GUID so we know how to get the data back when we get to the Windows Service
                comparisonData.FromFileGuid = fromFileID;
            }

            // serialize the ComparisonData class
            string xml = comparisonData.Serialize();

            // write the "Case" which is the ComparisonData class, a set of associated parameters, and the associated 'from file' data, if any.
            bi.SaveCase(
                xml,
                Session["FST_VERSION"].ToString(),
                comparisonData.DNAAmount.ToString(),
                comparisonData.FB1,
                comparisonData.Comparison,
                comparisonData.FB2,
                comparisonData.Item,
                comparisonData.UserName,
                comparisonData.Theta.ToString(),
                comparisonData.CompareMethodID,
                comparisonData.Deducible ? "Yes" : "No",
                comparisonData.Degradation == ComparisonData.enDegradation.None ? "ND" : comparisonData.Degradation == ComparisonData.enDegradation.Mild ? "MD" : "SD",
                string.Empty,
                comparisonData.HdHead,
                comparisonData.HpHead,
                comparisonData.Bulk ? "B" : "N",
                comparisonData.BulkType == ComparisonData.enBulkType.FromFile ? "From File" : comparisonData.BulkType == ComparisonData.enBulkType.LabTypes ? "Lab Types" : "Population",
                "N",
                comparisonData.LabKitID.ToString(),
                comparisonData.FromFileGuid,
                fromFileTable,
                out jobGuid);

            // call the webservice in a separate thread to notify it that we're trying to run a comparison
            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object o)
            {
                try
                {
                    FSTWebService.FSTWebServiceClient webSvcClient = new FSTWebService.FSTWebServiceClient();
                    webSvcClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(ConfigurationManager.AppSettings["FST_SERVICE_ADDRESS"]);
                    webSvcClient.RunJob(jobGuid.ToString());
                }
                catch (Exception ex)
                {
                    Log.Error(User.Identity.Name.ToString(), (string)o, isTest ? null : Session, "Web Service Exception", string.Empty, ex);
                }
            }), isTest ? null : (object)Request.FilePath);

            // notify the user that the comparison will run in the background
            if (!isTest)
            {
                MessageBox.Show("Your comparison will run in the background, and you will receive an e-mail with the results.");
            }
        }
コード例 #3
0
        /// <summary>
        /// This method is called from either the UI or the frmTestCenter page, and uses the ComparisonData class and potentially the TestCenter class
        /// to run a comparison. If this is an individual comparison that is being run on this page, this method runs the comparison here. Othewrise,
        /// the ProcessInBackgroundService() method is called to handle the case in the Windows Service component.
        /// </summary>
        /// <param name="sender">The button that was clicked, or the frmTestCenter class.</param>
        /// <param name="e"></param>
        public void btnCompare_Click(object sender, EventArgs e)
        {
            // this is used to get information about whether this is being called from this page or from the tesing center, and the associated data if it's from the testing center
            bool isTest = sender is FST.Web.Admin.frmTestCenter;

            FST.Web.Admin.frmTestCenter testPage = isTest ? sender as FST.Web.Admin.frmTestCenter : null;
            if (isTest)
            {
                comparisonData = testPage.comparisonData;
            }

            comparisonData.ReportDate = DateTime.Now;

            // validate form
            if (!isTest && !FieldChecks())
            {
                return;
            }

            // if we're not running a test (and we don't already have data), we get the data from the controls on the page
            if (!isTest)
            {
                // get the evidence from the eviAlleles Evidence control via the GetEvidenceDictionary() method. check it for details
                comparisonData.EvidenceAlleles = eviAlleles.GetEvidenceDictionary();

                // we only get comaprison data if we're not doing a bulk, otherwise the comparison data comes from an alternate source.
                // this source is the Knowns table in DB where files using the
                if (!comparisonData.Bulk)
                {
                    comparisonData.ComparisonAlleles.Clear();

                    // we check for comparison profiles in the denominator too. it was easier to c/p the code, and it's ready in case comparisons ever make it into the denominator
                    // the data comes from the proComparison1Alleles (or whichever) Profile control's GetProfileDictionary() method. check it for details
                    // we do the same for the known profiles below
                    if (comparisonData.NumeratorProfiles.ComparisonCount >= 1 || comparisonData.DenominatorProfiles.ComparisonCount >= 1)
                    {
                        comparisonData.ComparisonAlleles.Add(1, proComparison1Alleles.GetProfileDictionary());
                    }

                    if (comparisonData.NumeratorProfiles.ComparisonCount >= 2 || comparisonData.DenominatorProfiles.ComparisonCount >= 2)
                    {
                        comparisonData.ComparisonAlleles.Add(2, proComparison2Alleles.GetProfileDictionary());
                    }

                    if (comparisonData.NumeratorProfiles.ComparisonCount >= 3 || comparisonData.DenominatorProfiles.ComparisonCount >= 3)
                    {
                        comparisonData.ComparisonAlleles.Add(3, proComparison3Alleles.GetProfileDictionary());
                    }

                    if (comparisonData.NumeratorProfiles.ComparisonCount >= 4 || comparisonData.DenominatorProfiles.ComparisonCount >= 4)
                    {
                        comparisonData.ComparisonAlleles.Add(4, proComparison4Alleles.GetProfileDictionary());
                    }
                }

                comparisonData.KnownsAlleles.Clear();

                if (comparisonData.NumeratorProfiles.KnownCount >= 1 || comparisonData.DenominatorProfiles.KnownCount >= 1)
                {
                    comparisonData.KnownsAlleles.Add(1, proKnown1Alleles.GetProfileDictionary());
                }

                if (comparisonData.NumeratorProfiles.KnownCount >= 2 || comparisonData.DenominatorProfiles.KnownCount >= 2)
                {
                    comparisonData.KnownsAlleles.Add(2, proKnown2Alleles.GetProfileDictionary());
                }

                if (comparisonData.NumeratorProfiles.KnownCount >= 3 || comparisonData.DenominatorProfiles.KnownCount >= 3)
                {
                    comparisonData.KnownsAlleles.Add(3, proKnown3Alleles.GetProfileDictionary());
                }

                if (comparisonData.NumeratorProfiles.KnownCount >= 4 || comparisonData.DenominatorProfiles.KnownCount >= 4)
                {
                    comparisonData.KnownsAlleles.Add(4, proKnown4Alleles.GetProfileDictionary());
                }
            }

            // go to the background service if we're doing a bulk or an individual search that runs long
            if (comparisonData.Bulk || comparisonData.RunIndividualOnService)
            {
                ProcessInBackgroundService(testPage);
            }
            else // otherwise we process here
            {
                if (!isTest)
                {
                    Log.Info(Context.User.Identity.Name, Request.FilePath, Session, "Comparison Start", comparisonData.HpHead + "/" + comparisonData.HdHead);
                }

                // instantiate the comparison class with our comparison data
                FST.Common.Comparison comparison = new Comparison(comparisonData);

                // if we're using DEBUGOUT functionality, set up the debugData dictionary and the username. the debugOut functionality runs if the debugData dictionary != null
                if ("true" == ConfigurationManager.AppSettings.Get("DEBUGOUT"))
                {
                    comparison.debugData = new Dictionary <string, Comparison.DebugData>();
                    comparison.UserName  = User.Identity.Name;
                }

                Dictionary <string, float> result = comparison.DoCompare();

                if (!isTest)
                {
                    Log.Info(Context.User.Identity.Name, Request.FilePath, Session, "Comparison End", comparisonData.HpHead + "/" + comparisonData.HdHead);
                }

                // if we're not testing we print a PDF report, otherwise we write the test results to the DB
                if (!isTest)
                {
                    Print();
                }
                else
                {
                    bi.WriteTestResults(
                        testPage.subTestID.ToString(),
                        testPage.comparisonID.ToString(),
                        result["Asian"].ToString(),
                        result["Black"].ToString(),
                        result["Caucasian"].ToString(),
                        result["Hispanic"].ToString()
                        );
                }
            }
        }