Ejemplo n.º 1
0
        // Token: 0x06001052 RID: 4178 RVA: 0x0005EF08 File Offset: 0x0005D108
        public static DtmfMapGenerationMetadata Deserialize(string filePath)
        {
            ValidateArgument.NotNullOrEmpty(filePath, "filePath");
            Utilities.DebugTrace(ExTraceGlobals.DtmfMapGeneratorTracer, "DtmfMapGenerationMetadata.Deserialize - filePath='{0}'", new object[]
            {
                filePath
            });
            DtmfMapGenerationMetadata result = null;

            try
            {
                using (Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    using (XmlTextReader xmlTextReader = new XmlTextReader(stream))
                    {
                        xmlTextReader.ReadToFollowing("DtmfMapGeneration");
                        xmlTextReader.MoveToAttribute("metadataVersion");
                        string attribute       = xmlTextReader.GetAttribute("metadataVersion");
                        int    metadataVersion = int.Parse(attribute);
                        xmlTextReader.MoveToAttribute("tenantId");
                        string attribute2 = xmlTextReader.GetAttribute("tenantId");
                        xmlTextReader.MoveToAttribute("runId");
                        string attribute3 = xmlTextReader.GetAttribute("runId");
                        Guid   runId      = Guid.Parse(attribute3);
                        xmlTextReader.MoveToAttribute("serverName");
                        string attribute4 = xmlTextReader.GetAttribute("serverName");
                        xmlTextReader.MoveToAttribute("serverVersion");
                        string attribute5 = xmlTextReader.GetAttribute("serverVersion");
                        xmlTextReader.MoveToAttribute("lastIncrementalUpdateTimeUtc");
                        string   attribute6 = xmlTextReader.GetAttribute("lastIncrementalUpdateTimeUtc");
                        DateTime lastIncrementalUpdateTimeUtc = DateTime.Parse(attribute6, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.RoundtripKind);
                        xmlTextReader.MoveToAttribute("lastFullUpdateTimeUtc");
                        string   attribute7            = xmlTextReader.GetAttribute("lastFullUpdateTimeUtc");
                        DateTime lastFullUpdateTimeUtc = DateTime.Parse(attribute7, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.RoundtripKind);
                        result = new DtmfMapGenerationMetadata(metadataVersion, attribute2, runId, attribute4, attribute5, lastIncrementalUpdateTimeUtc, lastFullUpdateTimeUtc);
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.DebugTrace(ExTraceGlobals.DtmfMapGeneratorTracer, "DtmfMapGenerationMetadata.Serialize - exception='{0}'", new object[]
                {
                    ex
                });
                UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_LoadDtmfMapGenerationMetadataFailed, null, new object[]
                {
                    filePath,
                    CommonUtil.ToEventLogString(ex)
                });
                if (!DtmfMapGenerationMetadata.IsExpectedException(ex))
                {
                    throw;
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        // Token: 0x06001051 RID: 4177 RVA: 0x0005ECFC File Offset: 0x0005CEFC
        public static string Serialize(DtmfMapGenerationMetadata metadata, string fileName, string folderPath)
        {
            ValidateArgument.NotNull(metadata, "metadata");
            ValidateArgument.NotNullOrEmpty(fileName, "fileName");
            ValidateArgument.NotNullOrEmpty(folderPath, "folderPath");
            Utilities.DebugTrace(ExTraceGlobals.DtmfMapGeneratorTracer, "DtmfMapGenerationMetadata.Serialize - fileName='{0}', folderPath='{1}'", new object[]
            {
                fileName,
                folderPath
            });
            string text = Path.Combine(folderPath, fileName);

            try
            {
                Directory.CreateDirectory(folderPath);
                using (Stream stream = new FileStream(text, FileMode.Create, FileAccess.ReadWrite))
                {
                    using (XmlTextWriter xmlTextWriter = new XmlTextWriter(stream, Encoding.UTF8))
                    {
                        xmlTextWriter.WriteStartDocument();
                        xmlTextWriter.WriteStartElement("DtmfMapGeneration");
                        xmlTextWriter.WriteAttributeString("metadataVersion", metadata.MetadataVersion.ToString("d"));
                        xmlTextWriter.WriteAttributeString("tenantId", metadata.TenantId);
                        xmlTextWriter.WriteAttributeString("runId", metadata.RunId.ToString());
                        xmlTextWriter.WriteAttributeString("serverName", metadata.ServerName);
                        xmlTextWriter.WriteAttributeString("serverVersion", metadata.ServerVersion);
                        xmlTextWriter.WriteAttributeString("lastIncrementalUpdateTimeUtc", metadata.LastIncrementalUpdateTimeUtc.ToString("u", DateTimeFormatInfo.InvariantInfo));
                        xmlTextWriter.WriteAttributeString("lastFullUpdateTimeUtc", metadata.LastFullUpdateTimeUtc.ToString("u", DateTimeFormatInfo.InvariantInfo));
                        xmlTextWriter.WriteEndElement();
                        xmlTextWriter.WriteEndDocument();
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.DebugTrace(ExTraceGlobals.DtmfMapGeneratorTracer, "DtmfMapGenerationMetadata.Serialize - exception='{0}'", new object[]
                {
                    ex
                });
                UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_SaveDtmfMapGenerationMetadataFailed, null, new object[]
                {
                    text,
                    CommonUtil.ToEventLogString(ex)
                });
                if (!DtmfMapGenerationMetadata.IsExpectedException(ex))
                {
                    throw;
                }
                text = null;
            }
            return(text);
        }