ATMLModelLibrary.model.equipment.TestStationDescription11.Serialize C# (CSharp) Метод

Serialize() публичный Метод

Serializes current TestStationDescription11 object into an XML string
public Serialize ( ) : string
Результат string
        public virtual string Serialize()
        {
            StreamReader streamReader = null;
            MemoryStream memoryStream = null;
            try
            {
                memoryStream = new MemoryStream();
                Serializer.Serialize(memoryStream, this);
                memoryStream.Seek(0, SeekOrigin.Begin);
                streamReader = new StreamReader(memoryStream);
                return streamReader.ReadToEnd();
            }
            finally
            {
                if ((streamReader != null))
                {
                    streamReader.Dispose();
                }
                if ((memoryStream != null))
                {
                    memoryStream.Dispose();
                }
            }
        }
        

Usage Example

Пример #1
0
        /**
         *
         */
        public string InitializeTestStaion(string stationType,
            string station,
            string changeNo,
            string dateEntry,
            string fst)
        {
            string refNo = "";
            bool usesRF = false;
            bool usesCNI = false;
            bool usesEO = false;
            bool usesHPDTS = false;
            bool usesSGMA = false;
            bool isHybrid = false;
            bool isRTCass = false;
            bool isECass = false;

            stationType = stationType.ToUpper();
            station = station.ToUpper();

            if (string.IsNullOrWhiteSpace(station))
                station = CASS;

            if (string.IsNullOrWhiteSpace(stationType))
                stationType = station;

            usesRF = stationType.Contains(RF);
            usesCNI = stationType.Contains(CNI);
            usesEO = stationType.Contains(EO);
            usesHPDTS = stationType.Contains(HPDTS);
            usesSGMA = stationType.Contains(SGMA);
            isHybrid = stationType.Contains(HYBRID);
            isRTCass = stationType.Contains(RTCASS);
            isECass = stationType.Contains(ECASS);

            if (!isRTCass && stationType.Contains(CASS))
                station = CASS;
            else if (isRTCass)
                station = RTCASS;
            else if (isECass)
                station = ECASS;
            else if (isHybrid)
                station = HYBRID;

            if (usesRF)
                station = station + "_" + RF;
            if (usesCNI)
                station = station + "_" + CNI;
            if (usesEO)
                station = station + "_" + EO;
            if (usesHPDTS)
                station = station + "_" + HPDTS;
            if (usesSGMA)
                station = station + "_" + SGMA;

            const string assetType = "Model";
            const string contentType = "text/xml";
            string documentType = Enum.GetName(typeof (dbDocument.DocumentType),
                                               dbDocument.DocumentType.TEST_STATION_DESCRIPTION);

            AssetIdentificationBean asset = DocumentManager.FindAsset(assetType, station);
            if (asset != null)
            {
                refNo = asset.uuid.ToString();
            }
            else
            {
                refNo = DocumentManager.CreateDocumentPlaceHolder
                    (
                        station, //Part Number
                        assetType, //Asset Type
                        contentType, //Content Type
                        documentType, //Document Type
                        station + " 1671.6 Test Station Description" //Description
                    );
                var ts = new TestStationDescription11();
                ts.Identification = new ItemDescriptionIdentification();
                ts.name = station;
                ts.uuid = refNo;
                ts.Identification.ModelName = station;
                Document document = DocumentManager.GetDocument(refNo);
                document.DocumentContent = Encoding.UTF8.GetBytes(ts.Serialize());
                DocumentManager.SaveDocument(document);
            }

            return refNo;
        }
All Usage Examples Of ATMLModelLibrary.model.equipment.TestStationDescription11::Serialize