コード例 #1
0
        public void TestNaturalKey()
        {
            //arrange
            var schema = new DatabaseSchema(null, null);

            var diagrams = schema.AddTable("Diagrams")
                           .AddColumn("diagram_id", DbType.Int32).AddPrimaryKey()
                           .AddColumn <string>("name").AddLength(10).AddUniqueKey()
                           .AddColumn <int>("principal_id")
                           .Table;

            diagrams.UniqueKeys.Single().AddColumn(diagrams.FindColumn("principal_id"));

            DatabaseSchemaFixer.UpdateReferences(schema);

            var settings = new CodeWriterSettings {
                Namespace = "MyTest", CodeTarget = CodeTarget.PocoNHibernateHbm
            };

            PrepareSchemaNames.Prepare(schema, settings.Namer);

            //act
            var target = new MappingWriter(diagrams, settings);
            var txt    = target.Write();

            //assert
            var errors = Validate(txt);

            Assert.IsFalse(errors);
        }
コード例 #2
0
        public void TestSimpleMapping()
        {
            //arrange
            var schema = new DatabaseSchema(null, null);

            schema.AddTable("Categories")
            .AddColumn("CategoryId", DbType.Int32).AddPrimaryKey()
            .AddColumn("CategoryName", DbType.String);

            var products = schema.AddTable("Products")
                           .AddColumn("ProductId", DbType.Int32).AddPrimaryKey()
                           .AddColumn("ProductName", DbType.String)
                           .AddColumn("CategoryId", DbType.Int32).AddForeignKey("fk", "Categories")
                           .Table;

            DatabaseSchemaFixer.UpdateReferences(schema);

            var settings = new CodeWriterSettings {
                Namespace = "MyTest", CodeTarget = CodeTarget.PocoNHibernateHbm
            };

            PrepareSchemaNames.Prepare(schema, settings.Namer);

            //act
            var target = new MappingWriter(products, settings);
            var txt    = target.Write();

            //assert
            var errors = Validate(txt);

            Assert.IsFalse(errors);
        }
コード例 #3
0
        public void TestCompositeKey()
        {
            //arrange
            var schema = new DatabaseSchema(null, null);

            var orderDetail = schema.AddTable("OrderDetails")
                              .AddColumn("OrderID", DbType.Int32).AddPrimaryKey()
                              .AddColumn("ProductID", DbType.Int32)
                              .AddColumn <int>("UnitPrice")
                              .Table;

            orderDetail.PrimaryKey.AddColumn(orderDetail.FindColumn("ProductID"));

            DatabaseSchemaFixer.UpdateReferences(schema);

            var settings = new CodeWriterSettings {
                Namespace = "MyTest", CodeTarget = CodeTarget.PocoNHibernateHbm
            };

            PrepareSchemaNames.Prepare(schema, settings.Namer);

            //act
            var target = new MappingWriter(orderDetail, settings);
            var txt    = target.Write();

            //assert
            var errors = Validate(txt);

            Assert.IsFalse(errors);
        }
コード例 #4
0
        private void WriteMapping(DatabaseTable table, ProjectWriter pw)
        {
            string fileName;

            switch (_codeWriterSettings.CodeTarget)
            {
            case CodeTarget.PocoNHibernateFluent:
                fileName = WriteFluentMapping(table);
                pw.AddClass(@"Mapping\" + fileName);
                break;

            case CodeTarget.PocoNHibernateHbm:
                var mw  = new MappingWriter(table, _codeWriterSettings);
                var txt = mw.Write();

                fileName = table.NetName + ".hbm.xml";
                var path = Path.Combine(_mappingPath, fileName);
                File.WriteAllText(path, txt);
                pw.AddMap(@"mapping\" + fileName);
                break;

            case CodeTarget.PocoEntityCodeFirst:
            case CodeTarget.PocoRiaServices:
                var cfmw  = new CodeFirstMappingWriter(table, _codeWriterSettings, _mappingNamer);
                var cfmap = cfmw.Write();

                fileName = cfmw.MappingClassName + ".cs";

                var filePath = Path.Combine(_mappingPath, fileName);
                File.WriteAllText(filePath, cfmap);
                pw.AddClass(@"Mapping\" + fileName);
                break;
            }
        }
コード例 #5
0
ファイル: DataHub.cs プロジェクト: lulzzz/openECA
        public string UpdateMapping(string udtFileContents, string mappingFileContents, string identifier, string newident)
        {
            StringReader udtsr     = new StringReader(udtFileContents);
            StringReader mappingsr = new StringReader(mappingFileContents);

            UDTCompiler udtCompiler = new UDTCompiler();

            udtCompiler.Compile(udtsr);

            MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler);

            mappingCompiler.Compile(mappingsr);

            foreach (TypeMapping tm in mappingCompiler.DefinedMappings)
            {
                if (tm.Identifier == identifier)
                {
                    tm.Identifier = newident;
                }
            }

            MappingWriter mappingWriter = new MappingWriter();

            mappingWriter.Mappings.AddRange(mappingCompiler.DefinedMappings);

            StringBuilder sb = new StringBuilder();

            mappingWriter.Write(new StringWriter(sb));

            return(sb.ToString());
        }
コード例 #6
0
ファイル: DataHub.cs プロジェクト: contributor51/openECA
        public void ImportData(IEnumerable <UserDefinedType> userDefinedTypes, IEnumerable <TypeMapping> typeMappings)
        {
            if (!userDefinedTypes.Any())
            {
                return;
            }

            UDTWriter udtWriter = new UDTWriter();

            foreach (UserDefinedType type in userDefinedTypes)
            {
                udtWriter.Types.Add(type);
            }

            lock (s_udtLock)
                udtWriter.WriteFiles(s_udtDirectory);

            if (!typeMappings.Any())
            {
                return;
            }

            MappingWriter mappingWriter = new MappingWriter();

            foreach (TypeMapping mapping in typeMappings)
            {
                mappingWriter.Mappings.Add(mapping);
            }

            lock (s_udmLock)
                mappingWriter.WriteFiles(s_udmDirectory);
        }
コード例 #7
0
        internal override string Serialize(RepresentationFormat format, URI baseUri, ExtensionInjector extensions)
        {
            MappingWriter writer = format.SerializeMapping(Type);

            Serializer.InjectExtensions(writer, this, baseUri, extensions);
            Serialize(new MappingSerializer(writer, baseUri, extensions));
            writer.Done();
            return(format.Complete(writer));
        }
コード例 #8
0
ファイル: DataHub.cs プロジェクト: lulzzz/openECA
        public void AddOutputMapping(TypeMapping typeMapping)
        {
            TypeMapping tm = ParseTimeWindow(typeMapping);

            MappingWriter mappingWriter = new MappingWriter();

            mappingWriter.Mappings.Add(tm);

            lock (s_udomLock)
                mappingWriter.WriteFiles(s_udomDirectory);
        }
コード例 #9
0
ファイル: DataHub.cs プロジェクト: lulzzz/openECA
        public void ExportOutputMappings(IEnumerable <TypeMapping> list, string file)
        {
            MappingWriter mappingWriter = new MappingWriter();

            foreach (TypeMapping tm in list)
            {
                mappingWriter.Mappings.Add(tm);
            }

            lock (s_udomLock)
                mappingWriter.Write(file);
        }
コード例 #10
0
ファイル: DataHub.cs プロジェクト: contributor51/openECA
        public void UpdateUDT(UserDefinedType udt, string oldCat, string oldIdent)
        {
            UDTCompiler udtCompiler = CreateUDTCompiler();

            MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler);

            mappingCompiler.Scan(s_udmDirectory);

            foreach (UserDefinedType dt in udtCompiler.DefinedTypes.OfType <UserDefinedType>())
            {
                if (dt.Category == oldCat && dt.Identifier == oldIdent)
                {
                    dt.Fields.Clear();
                    foreach (UDTField dataType in udt.Fields)
                    {
                        dt.Fields.Add(dataType);
                    }

                    dt.Category   = udt.Category;
                    dt.Identifier = udt.Identifier;
                }
            }

            string categoryPath = Path.Combine(s_udtDirectory, oldCat);
            string typePath     = Path.Combine(categoryPath, oldIdent + ".ecaidl");

            lock (s_udtLock)
            {
                File.Delete(typePath);

                if (!Directory.EnumerateFileSystemEntries(categoryPath).Any())
                {
                    Directory.Delete(categoryPath);
                }
            }


            UDTWriter udtWriter = new UDTWriter();

            udtWriter.Types.AddRange(udtCompiler.DefinedTypes.OfType <UserDefinedType>());

            lock (s_udtLock)
                udtWriter.WriteFiles(s_udtDirectory);

            MappingWriter mappingWriter = new MappingWriter();

            mappingWriter.Mappings.AddRange(mappingCompiler.DefinedMappings);

            lock (s_udmLock)
                mappingWriter.WriteFiles(s_udmDirectory);
        }
コード例 #11
0
        // Writes the UDT and mapping files to the specified path, containing the specified types and mappings.
        private void WriteMappingsTo(string path, IEnumerable <UserDefinedType> userDefinedTypes, IEnumerable <TypeMapping> userDefinedMappings)
        {
            // Determine the paths to the UDT and mapping files
            string udtFilePath     = Path.Combine(path, "UserDefinedTypes.ecaidl");
            string mappingFilePath = Path.Combine(path, "UserDefinedMappings.ecamap");

            // Create the writers to generate the files
            UDTWriter     udtWriter     = new UDTWriter();
            MappingWriter mappingWriter = new MappingWriter();

            // Add the UDTs and mappings to the writers
            udtWriter.Types.AddRange(userDefinedTypes);
            mappingWriter.Mappings.AddRange(userDefinedMappings);

            // Generate the files
            udtWriter.Write(udtFilePath);
            mappingWriter.Write(mappingFilePath);
        }
コード例 #12
0
        public void WriteNHibernateMappingInverseForeignKeyTest()
        {
            //arrange
            var schema = ArrangeSchema();
            var table  = schema.FindTableByName("Orders");

            var cw = new MappingWriter(table, new CodeWriterSettings());

            //act
            var txt = cw.Write();

            //assert
            var hasBillingAddress  = txt.Contains("<many-to-one name=\"BillingAddress\" class=\"Address\" />");
            var hasDeliveryAddress = txt.Contains("<many-to-one name=\"DeliveryAddress\" class=\"Address\" />");

            Assert.IsTrue(hasBillingAddress);
            Assert.IsTrue(hasDeliveryAddress);
        }
コード例 #13
0
        public void WriteNHibernateMappingForeignKeyTest()
        {
            //arrange
            var schema = ArrangeSchema();
            var table  = schema.FindTableByName("Address");

            var cw = new MappingWriter(table, new CodeWriterSettings());

            //act
            var txt = cw.Write();

            //assert
            var hasBillingAddress  = txt.Contains("<bag name=\"BillingAddressCollection\" table=\"`Orders`\"");
            var hasDeliveryAddress = txt.Contains("<bag name=\"DeliveryAddressCollection\" table=\"`Orders`\"");

            Assert.IsTrue(hasBillingAddress);
            Assert.IsTrue(hasDeliveryAddress);
        }
コード例 #14
0
ファイル: DataHub.cs プロジェクト: lulzzz/openECA
        public void ImportData(IEnumerable <UserDefinedType> userDefinedTypes, IEnumerable <TypeMapping> inputTypeMappings, IEnumerable <TypeMapping> outputTypeMappings)
        {
            if (userDefinedTypes.Any())
            {
                UDTWriter udtWriter = new UDTWriter();

                foreach (UserDefinedType type in userDefinedTypes)
                {
                    udtWriter.Types.Add(type);
                }

                lock (s_udtLock)
                    udtWriter.WriteFiles(s_udtDirectory);
            }

            if (inputTypeMappings.Any())
            {
                MappingWriter mappingWriter = new MappingWriter();

                foreach (TypeMapping mapping in inputTypeMappings)
                {
                    mappingWriter.Mappings.Add(mapping);
                }

                lock (s_udimLock)
                    mappingWriter.WriteFiles(s_udimDirectory);
            }
            if (outputTypeMappings.Any())
            {
                MappingWriter mappingWriter = new MappingWriter();

                foreach (TypeMapping mapping in outputTypeMappings)
                {
                    mappingWriter.Mappings.Add(mapping);
                }

                lock (s_udomLock)
                    mappingWriter.WriteFiles(s_udomDirectory);
            }
        }
コード例 #15
0
ファイル: DataHub.cs プロジェクト: lulzzz/openECA
        public string UpdateMappingForUDT(string udtFileContents, string mappingFileContents, string category, string identifier, string newcat, string newident)
        {
            StringReader udtsr     = new StringReader(udtFileContents);
            StringReader mappingsr = new StringReader(mappingFileContents);

            UDTCompiler udtCompiler = new UDTCompiler();

            udtCompiler.Compile(udtsr);
            MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler);

            mappingCompiler.Compile(mappingsr);

            foreach (DataType dt in udtCompiler.DefinedTypes)
            {
                if (dt.Category == category && dt.Identifier == identifier)
                {
                    if (newcat != null)
                    {
                        dt.Category = newcat;
                    }
                    if (newident != null)
                    {
                        dt.Identifier = newident;
                    }
                }
            }

            MappingWriter mappingWriter = new MappingWriter();

            mappingWriter.Mappings.AddRange(mappingCompiler.DefinedMappings);

            StringBuilder sb = new StringBuilder();

            mappingWriter.Write(new StringWriter(sb));

            return(sb.ToString());
        }
コード例 #16
0
 protected internal override string Complete(MappingWriter serializer)
 {
     return((( HtmlMap )serializer).Complete());
 }
コード例 #17
0
 protected internal override string Complete(MappingWriter serializer)
 {
     Flush();
     return(null);                        // already done in done()
 }
コード例 #18
0
 protected internal override string Complete(MappingWriter serializer)
 {
     throw new System.NotSupportedException();
 }
コード例 #19
0
ファイル: MainWindow.cs プロジェクト: contributor51/openECA
        public static void CheckPhasorTypesAndMappings()
        {
            string appData           = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string ecaClientDataPath = Path.Combine(appData, "Grid Protection Alliance", "openECAClient");
            string udtDirectory      = Path.Combine(ecaClientDataPath, "UserDefinedTypes");
            string udmDirectory      = Path.Combine(ecaClientDataPath, "UserDefinedMappings");

            UDTCompiler udtCompiler = new UDTCompiler();

            if (Directory.Exists(udtDirectory))
            {
                udtCompiler.Scan(udtDirectory);
            }

            if (!udtCompiler.DefinedTypes.Where(x => x.IsUserDefined).ToList().Any(x => x.Category == "ECA" && x.Identifier == "Phasor"))
            {
                UserDefinedType udt = new UserDefinedType();
                udt.Identifier = "Phasor";
                udt.Category   = "ECA";
                udt.Fields     = new List <UDTField>();
                UDTField magnitude = new UDTField();
                magnitude.Type = new DataType()
                {
                    Category = "FloatingPoint", Identifier = "Double"
                };
                magnitude.Identifier = "Magnitude";
                udt.Fields.Add(magnitude);
                UDTField angle = new UDTField();
                angle.Type = new DataType()
                {
                    Category = "FloatingPoint", Identifier = "Double"
                };
                angle.Identifier = "Angle";
                udt.Fields.Add(angle);
                UDTWriter udtWriter = new UDTWriter();

                udtWriter.Types.Add(udt);

                udtWriter.WriteFiles(udtDirectory);
            }

            udtCompiler = new UDTCompiler();

            if (Directory.Exists(udtDirectory))
            {
                udtCompiler.Scan(udtDirectory);
            }

            MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler);

            if (Directory.Exists(udmDirectory))
            {
                mappingCompiler.Scan(udmDirectory);
            }

            DataHub dataHub = new DataHub();

            dataHub.Context = new HubCallerContext(null, Guid.NewGuid().ToString());

            dataHub.RegisterMetadataRecieved(() =>
            {
                IEnumerable <PhasorDetail> phasorDetails    = dataHub.GetPhasorDetails();
                List <MeasurementDetail> measurementDetails = dataHub.GetMeasurementDetails().ToList();
                MappingWriter mappingWriter = new MappingWriter();

                foreach (PhasorDetail pd in phasorDetails)
                {
                    string identifier = (pd.DeviceAcronym + '_' +
                                         pd.Label + '_' +
                                         pd.Phase.Replace(" ", "_").Replace("+", "pos").Replace("-", "neg") + '_' +
                                         pd.Type)
                                        .Replace(" ", "_").Replace("\\", "_").Replace("/", "_").Replace("!", "_").Replace("-", "_").Replace("#", "").Replace("'", "").Replace("(", "").Replace(")", "");

                    if (!mappingCompiler.DefinedMappings.Any(x => x.Identifier == identifier))
                    {
                        TypeMapping tm = new TypeMapping();
                        tm.Identifier  = identifier;
                        tm.Type        = (UserDefinedType)udtCompiler.DefinedTypes.Find(x => x.Category == "ECA" && x.Identifier == "Phasor");
                        tm.FieldMappings.Add(new FieldMapping()
                        {
                            Field = tm.Type.Fields[0], Expression = measurementDetails.Find(x => x.DeviceAcronym == pd.DeviceAcronym && x.PhasorSourceIndex == pd.SourceIndex && x.SignalAcronym.Contains("PHM")).SignalID.ToString()
                        });
                        tm.FieldMappings.Add(new FieldMapping()
                        {
                            Field = tm.Type.Fields[1], Expression = measurementDetails.Find(x => x.DeviceAcronym == pd.DeviceAcronym && x.PhasorSourceIndex == pd.SourceIndex && x.SignalAcronym.Contains("PHA")).SignalID.ToString()
                        });
                        mappingWriter.Mappings.Add(tm);
                    }
                }

                mappingWriter.WriteFiles(udmDirectory);
            });

            dataHub.InitializeSubscriptions();
        }
コード例 #20
0
 protected internal override string Complete(MappingWriter serializer)
 {
     return(JsonHelper.createJsonFrom((( MapWrappingWriter )serializer).Data));
 }
コード例 #21
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: protected String complete(final org.neo4j.server.rest.repr.MappingWriter serializer)
        protected internal override string Complete(MappingWriter serializer)
        {
            throw new Exception("Not implemented!");
        }
コード例 #22
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: protected String complete(final org.neo4j.server.rest.repr.MappingWriter serializer)
        protected internal override string Complete(MappingWriter serializer)
        {
            throw new MediaTypeNotSupportedException(Response.Status.NOT_ACCEPTABLE, _supported, _requested);
        }
コード例 #23
0
 protected internal override string Complete(MappingWriter serializer)
 {
     return((( CompactJsonWriter )serializer).Complete());
 }
コード例 #24
0
ファイル: MainWindow.cs プロジェクト: lulzzz/openECA
        public static void CheckPhasorTypesAndMappings()
        {
            string appData           = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string ecaClientDataPath = Path.Combine(appData, "Grid Protection Alliance", "openECAClient");
            string udtDirectory      = Path.Combine(ecaClientDataPath, "UserDefinedTypes");
            string udmDirectory      = Path.Combine(ecaClientDataPath, "UserDefinedInputMappings");

            UDTCompiler udtCompiler = new UDTCompiler();

            if (Directory.Exists(udtDirectory))
            {
                udtCompiler.Scan(udtDirectory);
            }

            if (!udtCompiler.DefinedTypes.Where(x => x.IsUserDefined).ToList().Any(x => x.Category == "ECA" && x.Identifier == "Phasor"))
            {
                UserDefinedType udt = new UserDefinedType();
                udt.Identifier = "Phasor";
                udt.Category   = "ECA";
                udt.Fields     = new List <UDTField>();
                UDTField magnitude = new UDTField();
                magnitude.Type = new DataType {
                    Category = "FloatingPoint", Identifier = "Double"
                };
                magnitude.Identifier = "Magnitude";
                udt.Fields.Add(magnitude);
                UDTField angle = new UDTField();
                angle.Type = new DataType {
                    Category = "FloatingPoint", Identifier = "Double"
                };
                angle.Identifier = "Angle";
                udt.Fields.Add(angle);
                UDTWriter udtWriter = new UDTWriter();

                udtWriter.Types.Add(udt);

                udtWriter.WriteFiles(udtDirectory);
            }

            if (!udtCompiler.DefinedTypes.Where(x => x.IsUserDefined).ToList().Any(x => x.Category == "ECA" && x.Identifier == "VIPair"))
            {
                UserDefinedType udt = new UserDefinedType();
                udt.Identifier = "VIPair";
                udt.Category   = "ECA";
                udt.Fields     = new List <UDTField>();
                UDTField voltage = new UDTField();
                voltage.Type = new DataType {
                    Category = "ECA", Identifier = "Phasor"
                };
                voltage.Identifier = "Voltage";
                udt.Fields.Add(voltage);
                UDTField current = new UDTField();
                current.Type = new DataType {
                    Category = "ECA", Identifier = "Phasor"
                };
                current.Identifier = "Current";
                udt.Fields.Add(current);
                UDTWriter udtWriter = new UDTWriter();

                udtWriter.Types.Add(udt);

                udtWriter.WriteFiles(udtDirectory);
            }

            udtCompiler = new UDTCompiler();

            if (Directory.Exists(udtDirectory))
            {
                udtCompiler.Scan(udtDirectory);
            }

            MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler);

            if (Directory.Exists(udmDirectory))
            {
                mappingCompiler.Scan(udmDirectory);
            }

            DataHub dataHub = new DataHub();

            dataHub.Context = new HubCallerContext(null, Guid.NewGuid().ToString());

            dataHub.RegisterMetadataReceivedHandler(() =>
            {
                try
                {
                    Program.LogStatus("Synchronizing ECA.Phasor mappings with accessible phasor meta-data...");

                    Dictionary <Guid, string> mappingLookup = new Dictionary <Guid, string>();

                    IEnumerable <PhasorDetail> phasorDetails           = dataHub.GetPhasorDetails() ?? new PhasorDetail[0];
                    IEnumerable <PowerCalculation> powerCalculations   = dataHub.GetPowerCalculation() ?? new PowerCalculation[0];
                    IEnumerable <MeasurementDetail> measurementDetails = dataHub.GetMeasurementDetails() ?? new MeasurementDetail[0];
                    MappingWriter mappingWriter = new MappingWriter();

                    foreach (PhasorDetail detail in phasorDetails)
                    {
                        Guid magnitudeID = measurementDetails.FirstOrDefault(measurement => measurement.DeviceAcronym == detail.DeviceAcronym && measurement.PhasorSourceIndex == detail.SourceIndex && (measurement.SignalAcronym?.Contains("PHM") ?? false))?.SignalID ?? Guid.Empty;
                        Guid angleID     = measurementDetails.FirstOrDefault(measurement => measurement.DeviceAcronym == detail.DeviceAcronym && measurement.PhasorSourceIndex == detail.SourceIndex && (measurement.SignalAcronym?.Contains("PHA") ?? false))?.SignalID ?? Guid.Empty;

                        if (magnitudeID == Guid.Empty || angleID == Guid.Empty)
                        {
                            continue;
                        }

                        string identifier = (detail.DeviceAcronym + '_' + detail.Label + '_' + detail.Phase?.Replace(" ", "_").Replace("+", "pos").Replace("-", "neg") + '_' + detail.Type)
                                            .Replace("\\", "_").Replace("#", "").Replace("'", "").Replace("(", "").Replace(")", "").ReplaceCharacters('_', x => !char.IsLetterOrDigit(x));

                        if (mappingCompiler.DefinedMappings.All(typeMapping => typeMapping.Identifier != identifier))
                        {
                            TypeMapping mapping = new TypeMapping
                            {
                                Identifier = identifier,
                                Type       = (UserDefinedType)udtCompiler.GetType("ECA", "Phasor")
                            };

                            if (mapping.Type.Fields.Count > 1)
                            {
                                mapping.FieldMappings.Add(new FieldMapping
                                {
                                    Field      = mapping.Type.Fields[0],
                                    Expression = magnitudeID.ToString()
                                });

                                mapping.FieldMappings.Add(new FieldMapping
                                {
                                    Field      = mapping.Type.Fields[1],
                                    Expression = angleID.ToString()
                                });

                                mappingWriter.Mappings.Add(mapping);
                            }
                        }

                        mappingLookup.Add(angleID, identifier);
                    }

                    foreach (PowerCalculation calculation in powerCalculations)
                    {
                        Guid voltageAngleID = calculation.VoltageAngleID;
                        Guid currentAngleID = calculation.CurrentAngleID;

                        string voltageMappingIdentifier;
                        string currentMappingIdentifier;

                        if (mappingLookup.TryGetValue(voltageAngleID, out voltageMappingIdentifier) && mappingLookup.TryGetValue(currentAngleID, out currentMappingIdentifier) &&
                            !string.IsNullOrEmpty(voltageMappingIdentifier) && !string.IsNullOrEmpty(currentMappingIdentifier))
                        {
                            TypeMapping mapping = new TypeMapping
                            {
                                Identifier = $"{voltageMappingIdentifier}__{currentMappingIdentifier}"
                            };

                            mapping.Identifier = mapping.Identifier.Replace("+", "pos").Replace("-", "neg").Replace("\\", "_").Replace("#", "").Replace("'", "").Replace("(", "").Replace(")", "").ReplaceCharacters('_', x => !char.IsLetterOrDigit(x));

                            mapping.Type = (UserDefinedType)udtCompiler.GetType("ECA", "VIPair");

                            if (mapping.Type.Fields.Count > 1)
                            {
                                mapping.FieldMappings.Add(new FieldMapping
                                {
                                    Field      = mapping.Type.Fields[0],
                                    Expression = voltageMappingIdentifier
                                });

                                mapping.FieldMappings.Add(new FieldMapping
                                {
                                    Field      = mapping.Type.Fields[1],
                                    Expression = currentMappingIdentifier
                                });

                                mappingWriter.Mappings.Add(mapping);
                            }
                        }
                    }

                    mappingWriter.WriteFiles(udmDirectory);

                    Program.LogStatus("Completed synchronization of mappings with accessible phasor meta-data.", true);
                }
                catch (Exception ex)
                {
                    Program.LogException(new InvalidOperationException($"Failed while synchronizing ECA.Phasor mappings with accessible phasor meta-data: {ex.Message}", ex), true);
                }
                finally
                {
                    dataHub.OnDisconnected(true);
                }
            });

            dataHub.InitializeSubscriptions();
        }