private void CreateReportPB_Click(object sender, RoutedEventArgs e) { ObservableCollection <ExperimentIndicatorContainer> expIndicatorList; bool success = m_wgDB.GetAllExperimentIndicatorsForExperiment(VM.CurrentExperiment.ExperimentID, out expIndicatorList); if (success) { ProjectContainer project; success = m_wgDB.GetProject(VM.CurrentProject.ProjectID, out project); if (success && project != null) { ExperimentContainer experiment; success = m_wgDB.GetExperiment(VM.CurrentExperiment.ExperimentID, out experiment); if (success && experiment != null) { ReportDialog dlg = new ReportDialog(project, experiment, expIndicatorList); dlg.ShowDialog(); } } } }
public bool WriteExperimentFile_WaveGuide(string filename, ObservableCollection <AnalysisContainer> analysisList) { bool success = true; if (File.Exists(filename)) { MessageBoxResult result = MessageBox.Show("File: " + filename + " already exists! Do you want to over write it?", "File Already Exists", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); switch (result) { case MessageBoxResult.Yes: File.Delete(filename); break; case MessageBoxResult.No: success = false; m_lastErrorString = "File already exists"; break; } } if (success) { try { string delimiter = "\t"; // \t = tab FileStream fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write); using (StreamWriter sw = new StreamWriter(fs)) { // Start writing HEADER sw.WriteLine("<HEADER>"); DateTime dt = m_experiment.TimeStamp; sw.WriteLine("Date" + delimiter + dt.ToString("yyyy-MM-dd")); // delimiter + dt.Year.ToString() + "-" + dt.Month.ToString() + "-" + dt.Day.ToString()); sw.WriteLine("Time" + delimiter + dt.ToString("HH:mm:ss")); //dt.Hour.ToString() + ":" + dt.Minute.ToString() + ":" + dt.Second.ToString()); sw.WriteLine("Instrument" + delimiter + "Panoptic"); sw.WriteLine("ProtocolName" + delimiter + m_method.Description); sw.WriteLine("AssayPlateBarcode" + delimiter + m_plate.Barcode); success = m_wgDB.GetAllExperimentCompoundPlatesForExperiment(m_experiment.ExperimentID); if (success) { foreach (ExperimentCompoundPlateContainer ecPlate in m_wgDB.m_experimentCompoundPlateList) { sw.WriteLine("AddPlateBarcode" + delimiter + ecPlate.Barcode); } } bool alreadyHaveBinning = false; string binningString = ""; ObservableCollection <ExperimentIndicatorContainer> expIndicatorList = new ObservableCollection <ExperimentIndicatorContainer>(); foreach (AnalysisContainer ac in analysisList) { ExperimentIndicatorContainer expIndicator; success = m_wgDB.GetExperimentIndicator(ac.ExperimentIndicatorID, out expIndicator); if (success && expIndicator != null) { // get the experiment binning if we don't already have it if (!alreadyHaveBinning) { ExperimentContainer experiment; success = m_wgDB.GetExperiment(expIndicator.ExperimentID, out experiment); if (success) { alreadyHaveBinning = true; binningString = experiment.HorzBinning.ToString() + " x " + experiment.VertBinning.ToString(); } } // make sure this experiment indicator isn't already in the list bool alreadyInList = false; foreach (ExperimentIndicatorContainer expCont in expIndicatorList) { if (expIndicator.ExperimentIndicatorID == expCont.ExperimentIndicatorID) { alreadyInList = true; break; } } if (!alreadyInList) { sw.WriteLine("Indicator" + delimiter + expIndicator.Description + delimiter + "Excitation" + delimiter + expIndicator.ExcitationFilterDesc + delimiter + "Emission" + delimiter + expIndicator.EmissionFilterDesc + delimiter + "Exposure" + delimiter + expIndicator.Exposure.ToString() + delimiter + "Gain" + delimiter + expIndicator.Gain.ToString()); expIndicatorList.Add(expIndicator); } } } success = m_wgDB.GetAllExperimentIndicatorsForExperiment(m_experiment.ExperimentID, out expIndicatorList); if (success) { foreach (ExperimentIndicatorContainer expIndicator in expIndicatorList) { } } sw.WriteLine("Binning" + delimiter + binningString); sw.WriteLine("NumRows" + delimiter + m_plateType.Rows.ToString()); sw.WriteLine("NumCols" + delimiter + m_plateType.Cols.ToString()); List <EventMarkerContainer> eventMarkerList; success = m_wgDB.GetAllEventMarkersForExperiment(m_experiment.ExperimentID, out eventMarkerList); if (success) { foreach (EventMarkerContainer eventMarker in eventMarkerList) { string timeString = String.Format("{0:0.000}", (float)eventMarker.SequenceNumber / 1000); sw.WriteLine("Event" + delimiter + eventMarker.Name + delimiter + eventMarker.Description + delimiter + "Time,sec" + delimiter + timeString); } } sw.WriteLine("Operator" + delimiter + m_user.Username + delimiter + m_user.Lastname + delimiter + m_user.Firstname); sw.WriteLine("Project" + delimiter + m_project.Description); sw.WriteLine("</HEADER>"); // END writing HEADER if (success) { foreach (AnalysisContainer analysis in analysisList) { ExperimentIndicatorContainer expIndicator; success = m_wgDB.GetExperimentIndicator(analysis.ExperimentIndicatorID, out expIndicator); sw.WriteLine("<INDICATOR_DATA" + delimiter + expIndicator.Description + delimiter + ">"); // START write column headers sw.Write("Time" + delimiter); StringBuilder builder = new StringBuilder(); for (int r = 0; r < m_plateType.Rows; r++) { for (int c = 0; c < m_plateType.Cols; c++) { builder.Append((char)(65 + r)).Append(c + 1).Append(delimiter); } } builder.Remove(builder.Length - delimiter.Length, delimiter.Length); // remove last delimiter sw.WriteLine(builder.ToString()); // END write column headers // START writing data frames success = m_wgDB.GetAllAnalysisFramesForAnalysis(analysis.AnalysisID); if (success) { foreach (AnalysisFrameContainer aFrame in m_wgDB.m_analysisFrameList) { string timeString = String.Format("{0:0.000}", (float)aFrame.SequenceNumber / 1000); sw.Write(timeString + delimiter); string[] values = aFrame.ValueString.Split(','); foreach (string val in values) { sw.Write(val + delimiter); } sw.WriteLine(""); } } // END writing data frames sw.WriteLine("</INDICATOR_DATA>"); } } } if (!success) { m_lastErrorString = m_wgDB.GetLastErrorMsg(); } } // end try catch (Exception e) { success = false; m_lastErrorString = e.Message; } } return(success); } // end function