private static FlowPropertyResource ToResource(FlowProperty fp)
 {
     // this is solely to account for FlowPropertyID 186, c79145ca-cc90-49b1-905a-51aaedc0e36b, whose unitgroup is missing
     string unit;
     if (fp.UnitGroup == null)
         unit = "null";
     else
         unit = fp.UnitGroup.ReferenceUnit;
     return new FlowPropertyResource
     {
         FlowPropertyID = fp.FlowPropertyID,
         Name = fp.Name,
         ReferenceUnit = unit,
         UUID = fp.ILCDEntity.UUID,
         Version = fp.ILCDEntity.Version
     };
 }
예제 #2
0
        /// <summary>
        /// Import data from loaded flowproperty file to new FlowProperty entity
        /// </summary>
        /// <param name="ilcdDb">Database context wrapper object</param>
        /// <returns>true iff data was imported</returns>
        private bool SaveFlowProperty(DbContextWrapper ilcdDb)
        {
            bool isSaved = false;
            string ugUUID;
            string uuid = GetCommonUUID();
            if (!ilcdDb.IlcdEntityAlreadyExists<FlowProperty>(uuid)) {
                FlowProperty flowProperty = new FlowProperty();
                SaveIlcdEntity(ilcdDb, flowProperty, DataTypeEnum.FlowProperty);
                flowProperty.Name = GetCommonName();
                ugUUID = GetElementAttributeValue(ElementName("referenceToReferenceUnitGroup"), "refObjectId");
                if (ugUUID == null) {
                    Program.Logger.WarnFormat("Unable to find referenceToReferenceUnitGroup in flow property {0}",
                        flowProperty.ILCDEntity.UUID);
                }
                else {
                    int ugID;
                    if (ilcdDb.FindRefIlcdEntityID<UnitGroup>(ugUUID, out ugID)) {
                        flowProperty.UnitGroupID = ugID;
                    }
                }

                isSaved = ilcdDb.AddIlcdEntity(flowProperty, uuid);
            }

            return isSaved;
        }