Ejemplo n.º 1
0
            public int Compare(Object object1, Object object2)
            {
                Sample sample1, sample2;

                sample1 = (Sample)object1;
                sample2 = (Sample)object2;

                return(ChiasmaData.CompareStringWithNumbers(sample1.GetIdentifier(), sample2.GetIdentifier()));
            }
Ejemplo n.º 2
0
        public virtual int CompareTo(object obj)
        {
            if (obj is DataIdentifier)
            {
                DataIdentifier dataIdentifier = (DataIdentifier)obj;

                if (GetDataType() != dataIdentifier.GetDataType())
                {
                    return(GetDataType().ToString().CompareTo(dataIdentifier.GetDataType().ToString()));
                }
                else
                {
                    return(ChiasmaData.CompareStringWithNumbers(MyIdentifier, dataIdentifier.GetIdentifier()));
                }
            }

            throw new ArgumentException("Object is not a DataIdentifier");
        }
Ejemplo n.º 3
0
            private void UploadInternalReport(object sender, EventArgs e)
            {
                String         appName, appVersion, settingString;
                InternalReport report;
                DataTable      resultPlatesTable, itemStatTable, markerStatTable, genotypeResultsTable;

                try
                {
                    MyBackgroundWorker.ReportProgress(0, "Connecting to Chiasma database...");
                    ChiasmaData.LoginChiasmaDataBase();
                    ChiasmaData.Database.BeginTransaction();
                    appName    = Assembly.GetExecutingAssembly().GetName().Name;
                    appVersion = Assembly.GetExecutingAssembly().GetName().Version.Major + "." +
                                 Assembly.GetExecutingAssembly().GetName().Version.Minor + "." +
                                 Assembly.GetExecutingAssembly().GetName().Version.Build + "." +
                                 Assembly.GetExecutingAssembly().GetName().Version.Revision;
                    settingString = GetSettingString();
                    report        = InternalReportManager.CreateInternalReport(MyInternalReportName, UserManager.GetCurrentUser().GetId(),
                                                                               MyProject.ID, appName + " " + appVersion, false, "", settingString);

                    //Read and store included result plates.
                    MyBackgroundWorker.ReportProgress(0, "Uploading plate information...");
                    if (MyBackgroundWorker.CancellationPending)
                    {
                        throw new UserCanceledException();
                    }
                    resultPlatesTable = GetResultPlatesTable(report.GetId());
                    if (resultPlatesTable.Rows.Count < 1)
                    {
                        throw new System.Exception("No result plates found.");
                    }
                    ChiasmaData.Database.AddInternalReportResultPlates(resultPlatesTable);

                    //Read and store item statistics.
                    MyBackgroundWorker.ReportProgress(0, "Uploading item statistics...");
                    if (MyBackgroundWorker.CancellationPending)
                    {
                        throw new UserCanceledException();
                    }
                    itemStatTable = GetItemStatsTable(report.GetId());
                    if (itemStatTable.Rows.Count < 1)
                    {
                        throw new System.Exception("No item statistics found.");
                    }
                    SetNameToItemTable(ref itemStatTable);

                    ChiasmaData.Database.AddInternalReportItemStatistics(itemStatTable);

                    //Read and store marker statistics.
                    MyBackgroundWorker.ReportProgress(0, "Uploading marker statistics...");
                    if (MyBackgroundWorker.CancellationPending)
                    {
                        throw new UserCanceledException();
                    }
                    markerStatTable = GetMarkerStatsTable(report.GetId());
                    if (markerStatTable.Rows.Count < 1)
                    {
                        throw new System.Exception("No marker statistics found.");
                    }
                    ChiasmaData.Database.AddInternalReportMarkerStatistics(markerStatTable);

                    //Read and store genotype results.
                    MyBackgroundWorker.ReportProgress(0, "Uploading genotype results...");
                    if (MyBackgroundWorker.CancellationPending)
                    {
                        throw new UserCanceledException();
                    }
                    genotypeResultsTable = GetGenotypeResultsTable(report.GetId());
                    if (genotypeResultsTable.Rows.Count < 1)
                    {
                        throw new System.Exception("No genotype results found.");
                    }
                    SetNameToResultsTable(ref genotypeResultsTable);
                    ChiasmaData.Database.AddInternalReportResults(genotypeResultsTable);
                    ChiasmaData.Database.CommitTransaction();
                    MessageBox.Show("The internal report was successfully updated!", "Upload internal report", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (ConnectDatabaseException ex)
                {
                    ChiasmaData.HandleError(ex.GetMessage(), ex);
                }
                catch (InternalReportAlreadyDefinedException ex)
                {
                    ChiasmaData.Database.RollbackTransaction();
                    ChiasmaData.HandleError("Error when uploading report! ", ex);
                }
                catch (UserCanceledException ex)
                {
                    ChiasmaData.Database.RollbackTransaction();
                    MessageBox.Show(ex.GetUploadCanceledMessage(), "Upload internal report", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    ChiasmaData.Database.RollbackTransaction();
                    ChiasmaData.HandleError("Error when uploading internal report", ex);
                }
                finally
                {
                    ChiasmaData.LogoutChiasmaDatabase();
                }
            }