Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // if we haven't picked an FST version, we get the one from the config file, match it with the one in the database, set it on match, error on mismatch
            if (Session["FST_VERSION"] == null)
            {
                try
                {
                    string appConfigVersion = ConfigurationManager.AppSettings.Get("FST_VERSION");
                    string databaseVersion  = string.Empty;
                    try
                    {
                        FST.Common.Database db = new FST.Common.Database();
                        databaseVersion = db.getVersion();
                    }
                    catch
                    {
                        Response.Write("Database conenction failed or internal application permissions were insufficient. Please notify the person responsible for this application.");
                        Response.End();
                        return;
                    }

                    // we have a version mismatch, so print an error
                    if (appConfigVersion != databaseVersion)
                    {
                        Response.Write("Current database version and application version do not match. This may be a configuration or deployment issue. Please notify the person responsible for this application.");
                        Response.End();
                        return;
                    }

                    Session["FST_VERSION"] = FST_VERSION = appConfigVersion;
                }
                catch
                {
                }
            }
            else
            {
                FST_VERSION = Convert.ToString(Session["FST_VERSION"]);
            }

            try
            {
                // generate the proper path to the root URL. this actually comes out different on PWS vs IIS, so be careful about changing this.
                ImagePath  = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
                ImagePath += (ImagePath.LastIndexOf('/') == ImagePath.Length - 1 ? string.Empty : "/");
            }
            catch
            {
            }

            if (!IsPostBack)
            {
                lblConfirmation.Visible = false;
            }
        }
        protected void btnLoadData_Click(object sender, EventArgs e)
        {
            FST.Common.Database db             = new FST.Common.Database();
            DataTable           locusSortOrder = db.getLocusSortOrder(Guid.Parse(Session["LabKitID"].ToString()));

            // clear any data we had before
            comparisonData.ComparisonAlleles.Clear();
            comparisonData.KnownsAlleles.Clear();

            // we don't read in the comparison profile for a bulk because it comes from either the 'from file' upload, or from the lab types/population database
            if (!comparisonData.Bulk && comparisonData.NumeratorProfiles.ComparisonCount >= 1)
            {
                // read our posted file to a dictionary and add it to our comparisonData class
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspectInput.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.ComparisonAlleles.Add(1, val);
                }
                // convert it to a table and set it as the source for the associated gridview
                gvSuspect.DataSource = convertKnownFromDictionaryToTable(comparisonData.ComparisonAlleles, locusSortOrder, 1);
                gvSuspect.DataBind();
                // set our client-side filename for printing in the report later
                comparisonData.Comparison1FileName = txtFileSuspectInput.PostedFile.FileName;
                // set up our name and show the grid view
                if (comparisonData.Comparison1Name.Trim() == string.Empty)
                {
                    this.lblSuspect.Text = Convert.ToString("Profile of (Comparison 1)");
                }
                else
                {
                    this.lblSuspect.Text = Convert.ToString("Profile of ") + comparisonData.Comparison1Name;
                }
                pnlSuspect.Visible = true;
            }
            if (comparisonData.NumeratorProfiles.ComparisonCount >= 2)
            {
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspect2Input.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.ComparisonAlleles.Add(2, val);
                }
                gvSuspect2.DataSource = convertKnownFromDictionaryToTable(comparisonData.ComparisonAlleles, locusSortOrder, 2);
                gvSuspect2.DataBind();
                comparisonData.Comparison2FileName = txtFileSuspect2Input.PostedFile.FileName;
                if (comparisonData.Comparison2Name.Trim() == string.Empty)
                {
                    this.lblSuspect2.Text = Convert.ToString("Profile of (Comparison 2)");
                }
                else
                {
                    this.lblSuspect2.Text = Convert.ToString("Profile of ") + comparisonData.Comparison2Name;
                }
                pnlSuspect2.Visible = true;
            }
            if (comparisonData.NumeratorProfiles.ComparisonCount >= 3)
            {
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspect3Input.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.ComparisonAlleles.Add(3, val);
                }
                gvSuspect3.DataSource = convertKnownFromDictionaryToTable(comparisonData.ComparisonAlleles, locusSortOrder, 3);
                gvSuspect3.DataBind();
                comparisonData.Comparison3FileName = txtFileSuspect3Input.PostedFile.FileName;
                if (comparisonData.Comparison3Name.Trim() == string.Empty)
                {
                    this.lblSuspect3.Text = Convert.ToString("Profile of (Comparison 3)");
                }
                else
                {
                    this.lblSuspect3.Text = Convert.ToString("Profile of ") + comparisonData.Comparison3Name;
                }
                pnlSuspect3.Visible = true;
            }
            if (comparisonData.NumeratorProfiles.ComparisonCount >= 4)
            {
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspect4Input.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.ComparisonAlleles.Add(4, val);
                }
                gvSuspect4.DataSource = convertKnownFromDictionaryToTable(comparisonData.ComparisonAlleles, locusSortOrder, 4);
                gvSuspect4.DataBind();
                comparisonData.Comparison4FileName = txtFileSuspect4Input.PostedFile.FileName;
                if (comparisonData.Comparison4Name.Trim() == string.Empty)
                {
                    this.lblSuspect4.Text = Convert.ToString("Profile of (Comparison 4)");
                }
                else
                {
                    this.lblSuspect4.Text = Convert.ToString("Profile of ") + comparisonData.Comparison4Name;
                }
                pnlSuspect4.Visible = true;
            }
            if (comparisonData.NumeratorProfiles.KnownCount >= 1 || comparisonData.DenominatorProfiles.KnownCount >= 1)
            {
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspect5Input.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.KnownsAlleles.Add(1, val);
                }
                gvSuspect5.DataSource = convertKnownFromDictionaryToTable(comparisonData.KnownsAlleles, locusSortOrder, 1);
                gvSuspect5.DataBind();
                comparisonData.Known1FileName = txtFileSuspect5Input.PostedFile.FileName;
                if (comparisonData.Known1Name.Trim() == string.Empty)
                {
                    this.lblSuspect5.Text = Convert.ToString("Profile of (Known 1)");
                }
                else
                {
                    this.lblSuspect5.Text = Convert.ToString("Profile of ") + comparisonData.Known1Name;
                }
                pnlSuspect5.Visible = true;
            }
            if (comparisonData.NumeratorProfiles.KnownCount >= 2 || comparisonData.DenominatorProfiles.KnownCount >= 2)
            {
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspect6Input.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.KnownsAlleles.Add(2, val);
                }
                gvSuspect6.DataSource = convertKnownFromDictionaryToTable(comparisonData.KnownsAlleles, locusSortOrder, 2);
                gvSuspect6.DataBind();
                comparisonData.Known2FileName = txtFileSuspect6Input.PostedFile.FileName;
                if (comparisonData.Known2Name.Trim() == string.Empty)
                {
                    this.lblSuspect6.Text = Convert.ToString("Profile of (Known 2)");
                }
                else
                {
                    this.lblSuspect6.Text = Convert.ToString("Profile of ") + comparisonData.Known2Name;
                }
                pnlSuspect6.Visible = true;
            }
            if (comparisonData.NumeratorProfiles.KnownCount >= 3 || comparisonData.DenominatorProfiles.KnownCount >= 3)
            {
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspect7Input.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.KnownsAlleles.Add(3, val);
                }
                gvSuspect7.DataSource = convertKnownFromDictionaryToTable(comparisonData.KnownsAlleles, locusSortOrder, 3);
                gvSuspect7.DataBind();
                comparisonData.Known3FileName = txtFileSuspect7Input.PostedFile.FileName;
                if (comparisonData.Known3Name.Trim() == string.Empty)
                {
                    this.lblSuspect7.Text = Convert.ToString("Profile of (Known 3)");
                }
                else
                {
                    this.lblSuspect7.Text = Convert.ToString("Profile of ") + comparisonData.Known3Name;
                }
                pnlSuspect7.Visible = true;
            }
            if (comparisonData.NumeratorProfiles.KnownCount >= 4 || comparisonData.DenominatorProfiles.KnownCount >= 4)
            {
                Dictionary <string, string> val = readKnownFileToDictionary(txtFileSuspect8Input.PostedFile, locusSortOrder);
                if (val == null)
                {
                    return;
                }
                else
                {
                    comparisonData.KnownsAlleles.Add(4, val);
                }
                gvSuspect8.DataSource = convertKnownFromDictionaryToTable(comparisonData.KnownsAlleles, locusSortOrder, 4);
                gvSuspect8.DataBind();
                comparisonData.Known4FileName = txtFileSuspect8Input.PostedFile.FileName;
                if (comparisonData.Known4Name.Trim() == string.Empty)
                {
                    this.lblSuspect8.Text = Convert.ToString("Profile of (Known 4)");
                }
                else
                {
                    this.lblSuspect8.Text = Convert.ToString("Profile of ") + comparisonData.Known4Name;
                }
                pnlSuspect8.Visible = true;
            }

            // read the evidence into a dictionary and add it to the comparisonData class
            Dictionary <string, Dictionary <int, string> > lan = readEvidenceFileToDictionary(txtFileUnknownInput.PostedFile, locusSortOrder);

            if (lan == null)
            {
                return;
            }
            else
            {
                comparisonData.EvidenceAlleles = lan;
            }
            // set our client-side filename for printing in the report later
            comparisonData.EvidenceFileName = txtFileUnknownInput.PostedFile.FileName;
            // convert it to a table and set it as the source for the associated gridview
            gvUnknown.DataSource = ConvertEvidenceFromDictionaryToDataTable(lan, locusSortOrder);
            gvUnknown.DataBind();
            // set our label text (done this way for consistency with code above) and show the gridview
            this.lblUnknown.Text = Convert.ToString("Evidence ");
            pnlUnknown.Visible   = true;

            // this checks to see that the data that was successfully loaded from the uploaded files matches the profiles in the comparisonData class
            // if it does not, we do not show the "Compare" button because it would cause the Comparison class to generate a false comparison
            if (
                (gvSuspect.Rows.Count > 0 || comparisonData.Bulk)
                &&
                (gvSuspect2.Rows.Count > 0 || comparisonData.NumeratorProfiles.ComparisonCount < 2)
                &&
                (gvSuspect3.Rows.Count > 0 || comparisonData.NumeratorProfiles.ComparisonCount < 3)
                &&
                (gvSuspect4.Rows.Count > 0 || comparisonData.NumeratorProfiles.ComparisonCount < 4)
                &&
                (gvSuspect5.Rows.Count > 0 || comparisonData.NumeratorProfiles.KnownCount < 1 || comparisonData.DenominatorProfiles.KnownCount < 1)
                &&
                (gvSuspect6.Rows.Count > 0 || comparisonData.NumeratorProfiles.KnownCount < 2 || comparisonData.DenominatorProfiles.KnownCount < 2)
                &&
                (gvSuspect7.Rows.Count > 0 || comparisonData.NumeratorProfiles.KnownCount < 3 || comparisonData.DenominatorProfiles.KnownCount < 3)
                &&
                (gvSuspect8.Rows.Count > 0 || comparisonData.NumeratorProfiles.KnownCount < 4 || comparisonData.DenominatorProfiles.KnownCount < 4)
                &&
                gvUnknown.Rows.Count > 0)
            {
                btnRead.Visible = true;
            }

            // if comparison profiles were update for a bulk search using the 'from file' upload functionaly, we process it here
            lblKnownFileName.Text = "";
            if (dlTypes.Text == "From File" && comparisonData.Bulk)
            {
                // get a datatable and store it in the session (read Business_Interface.GetProfilesFromFile() for more information on the format)
                Session["Known_FromFile"]     = bi.GetProfilesFromFile(fuPopulationUpload, Server.MapPath("~/Admin/Upload/"), comparisonData.LabKitID);
                Session["Known_FromFileName"] = fuPopulationUpload.FileName;
                // notify the user that we are running against this file so they are aware of whether this is happening or not.
                if (Session["Known_FromFile"] != null)
                {
                    lblKnownFileName.Text = "Running against population from file: " + fuPopulationUpload.FileName;
                }
                if (Session["Known_FromFile"] == null)
                {
                    btnRead.Style["visibility"] = "hidden";
                }
                else
                {
                    btnRead.Style["visibility"] = "visible";
                }
            }
            else
            {
                btnRead.Style["visibility"] = "visible";
            }
        }