Example #1
0
        public static Dictionary <string, object> GetVolumeCustomProperties(
            int volumeId,
            ICollection <string> properties)
        {
            Volume volume = VolumeDAL.GetVolume(volumeId);
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            if (properties == null || properties.Count == 0)
            {
                properties = volume.get_CustomProperties().Keys;
            }
            MacroParser macroParser1 = new MacroParser(new Action <string, int>(BusinessLayerOrionEvent.WriteEvent));

            macroParser1.set_ObjectType("Volume");
            macroParser1.set_ActiveObject(volume.get_ID().ToString());
            macroParser1.set_NetObjectID(volume.get_ID().ToString());
            macroParser1.set_NetObjectName(volume.get_FullName());
            macroParser1.set_NodeID(volume.get_NodeID());
            macroParser1.set_NodeName(NodeDAL.GetNode(volume.get_NodeID()).get_Name());
            MacroParser   macroParser2 = macroParser1;
            SqlConnection connection;

            macroParser2.set_MyDBConnection(connection = DatabaseFunctions.CreateConnection());
            using (connection)
            {
                foreach (string property in (IEnumerable <string>)properties)
                {
                    string key = property.Trim();
                    if (volume.get_CustomProperties().ContainsKey(key))
                    {
                        object customProperty = volume.get_CustomProperties()[key];
                        dictionary[key] = customProperty == null || !customProperty.ToString().Contains("${") ? customProperty : (object)macroParser2.ParseMacros(customProperty.ToString(), false);
                    }
                }
            }
            return(dictionary);
        }