Esempio n. 1
0
        private void SelectProtocol()
        {
            if (listView_Protocols.SelectedItems.Count > 0)
            {
                // match selected protocol to text from listview item
                for (int i = 0; i < filterList.Count; i++)
                {
                    if (listView_Protocols.SelectedItems[0].Text == filterList[i].Protocol_Name)
                    {
                        SelectedProtocol = filterList[i];
                    }
                }

                //  do something with it!!!!!
                //
                //
                //
            }
        }
Esempio n. 2
0
        public static RoboSep_Protocol generateProtocolFromFile(FileInfo Pfile)
        {
            // temp variables
            RoboSep_Protocol tempProtocol;
            string           filePath         = Pfile.FullName;
            string           FileName         = Pfile.Name;
            string           Name             = string.Empty;
            string           Species          = string.Empty;
            string           Selection        = string.Empty;
            string           SpeciesSelection = string.Empty;
            string           Class            = string.Empty;

            bool Hum = false;
            bool Mou = false;
            bool Pos = false;
            bool Neg = false;
            bool WBl = false;

            List <RoboSep_Protocol_VialBarcodes> vialBarcodes = null;

            int Q = -1;

            RoboSepProtocol ProtocolInfo = new RoboSepProtocol();

            if (File.Exists(Pfile.FullName))
            {
                // serializer
                XmlSerializer myXmlSerializer = new XmlSerializer(typeof(RoboSepProtocol));

                // Initialise a file stream for reading
                FileStream fs = new FileStream(Pfile.FullName, FileMode.Open);

                try
                {
                    // Deserialize a RoboSepProtocol XML description into a RoboSepProtocol
                    // object that matches the contents of the specified protocol file.

                    //  Oct 1, 2013 Sunny commented out
                    //  These codes are obsolete

                    /*
                     * XmlReader reader = new XmlTextReader(fs);
                     *
                     * // Create a validating reader to process the file.  Report any errors to the
                     * // validation page.
                     * XmlValidatingReader validatingReader = new XmlValidatingReader(reader);
                     * validatingReader.ValidationType = ValidationType.Schema;
                     *
                     * // Get the RoboSep protocol schema and add it to the collection for the
                     * // validator
                     * XmlSchemaCollection xsc = new XmlSchemaCollection();
                     * xsc.Add("STI",  GetProtocolXSD());
                     * validatingReader.Schemas.Add(xsc);
                     *
                     * // 'Rehydrate' the object (that is, deserialise data into the object)
                     * ProtocolInfo = (RoboSepProtocol)myXmlSerializer.Deserialize(validatingReader);
                     *
                     * //myCurrentActionContext = "User1.udb";
                     */

                    XmlReaderSettings settings = new XmlReaderSettings();
                    //settings.ValidationType = ValidationType.Schema;
                    settings.ValidationType = ValidationType.None;
                    settings.Schemas.Add("STI", GetProtocolXSD());
                    XmlReader reader = XmlReader.Create(fs, settings);
                    ProtocolInfo = (RoboSepProtocol)myXmlSerializer.Deserialize(reader);
                }
                catch (Exception ex)
                {
                    string sMsg = String.Format("Robosep Protocol File '{0}' is invalid. Exception={1}", Pfile.FullName, ex.Message);
                    System.Diagnostics.Debug.Write("!!!RoboSep_Protocols : Read Robosep Protocol failed.");


                    MessageBox.Show(sMsg);
                    //myCurrentActionContext = "User1.udb";
                }
                finally
                {
                    // Close the file stream
                    fs.Close();
                }
            }

            // get number of quadrants
            Q = Convert.ToInt32(ProtocolInfo.constraints.quadrants.number);

            // get protocol type to set bools
            string pType = ProtocolInfo.type.ToString();

            switch (pType)
            {
            case "HumanNegative":
                Hum   = true;
                Mou   = false;
                Pos   = false;
                Neg   = true;
                Class = "HN";
                break;

            case "HumanPositive":
                Hum   = true;
                Mou   = false;
                Pos   = true;
                Neg   = false;
                Class = "HP";
                break;

            case "Positive":
                Hum   = false;
                Mou   = false;
                Pos   = true;
                Neg   = false;
                Class = "Pos";
                break;

            case "Negative":
                Hum   = false;
                Mou   = false;
                Pos   = false;
                Neg   = true;
                Class = "Neg";
                break;

            case "WholeBloodPositive":
                Hum   = true;
                Mou   = false;
                Pos   = true;
                Neg   = false;
                WBl   = true;
                Class = "HP WB";
                break;

            case "WholeBloodNegative":
                Hum   = true;
                Mou   = false;
                Pos   = false;
                Neg   = true;
                WBl   = true;
                Class = "HN WB";
                break;

            case "MouseNegative":
                Hum   = false;
                Mou   = true;
                Pos   = false;
                Neg   = true;
                Class = "MN";
                break;

            case "MousePositive":
                Hum   = false;
                Mou   = true;
                Pos   = true;
                Neg   = false;
                Class = "MP";
                break;
            }

            if (ProtocolInfo.vialBarcodes != null)
            {
                for (int i = 0; i < ProtocolInfo.vialBarcodes.Length; i++)
                {
                    if (ProtocolInfo.vialBarcodes[i].quadrant.Trim() != String.Empty)
                    {
                        RoboSep_Protocol_VialBarcodes barcodeData = new RoboSep_Protocol_VialBarcodes(Convert.ToUInt32(ProtocolInfo.vialBarcodes[i].quadrant), ProtocolInfo.vialBarcodes[i].squareVialBarcode,
                                                                                                      ProtocolInfo.vialBarcodes[i].circleVialBarcode, ProtocolInfo.vialBarcodes[i].triangleVialBarcode);
                        if (vialBarcodes == null)
                        {
                            vialBarcodes = new List <RoboSep_Protocol_VialBarcodes>();
                        }
                        vialBarcodes.Add(barcodeData);
                    }
                }
            }

            #region setStrings
            // get protocol name (label)
            Name = ProtocolInfo.header.label.Trim();

            // set species string
            if (Hum || Mou)
            {
                // get rid of first 6 chars (Human or Mouse)
                Species = removeTextFromString("Human ", Name);
                Species = removeTextFromString("Mouse ", Species);
            }
            else
            {
                Species = Name;
            }

            // set selection string
            string pselect = "Positive Selection ";
            string nselect = "Negative Selection ";

            Selection = removeTextFromString(pselect, Name);
            Selection = removeTextFromString(nselect, Selection);

            if (Hum || Mou)
            {
                // get rid of first 6 chars (Human or Mouse)
                SpeciesSelection = removeTextFromString("Human ", Selection);
                SpeciesSelection = removeTextFromString("Mouse ", SpeciesSelection);
            }
            else
            {
                SpeciesSelection = Selection;
            }

            #endregion

            tempProtocol = new RoboSep_Protocol(filePath, FileName, Name, Species, Selection, SpeciesSelection, Class, Q, Hum, Mou, Pos, Neg, WBl, vialBarcodes);
            return(tempProtocol);
        }