Ejemplo n.º 1
0
        public static int InsertVolume(Volume volume)
        {
            SqlCommand textCommand = SqlHelper.GetTextCommand("\r\nIF NOT EXISTS (SELECT * FROM Volumes WHERE NodeID = @NodeID AND VolumeDescription = @VolumeDescription)\r\nBEGIN \r\n    INSERT INTO Volumes\r\n        ([NodeID]\r\n        ,[LastSync]\r\n        ,[VolumeIndex]\r\n        ,[Caption]\r\n        ,[PollInterval]\r\n        ,[StatCollection]\r\n        ,[RediscoveryInterval]\r\n        ,[UnManaged]\r\n        ,[UnManageFrom]\r\n        ,[UnManageUntil]\r\n        ,[VolumeDescription]\r\n        ,[VolumeTypeID]\r\n        ,[VolumeType]\r\n        ,[VolumeTypeIcon]\r\n        ,[VolumePercentUsed]\r\n        ,[VolumeSpaceUsed]\r\n        ,[VolumeSpaceAvailable]\r\n        ,[VolumeSize]\r\n        ,[Status]\r\n        ,[StatusLED]\r\n        ,[VolumeResponding]\r\n        ,[VolumeAllocationFailuresThisHour]\r\n        ,[VolumeAllocationFailuresToday]\r\n        ,[NextPoll]\r\n        ,[NextRediscovery]\r\n        ,[FullName]\r\n        ,[DiskQueueLength]\r\n        ,[DiskTransfer]\r\n        ,[DiskReads]\r\n        ,[DiskWrites]\r\n        ,[TotalDiskIOPS]\r\n        ,[DeviceId]\r\n        ,[DiskSerialNumber]\r\n\t\t,[InterfaceType]\r\n        ,[SCSITargetId]\r\n        ,[SCSIPortId]\r\n        ,[SCSILunId]\r\n        ,[SCSIControllerId]\r\n        ,[SCSIPortOffset])\r\n    VALUES \r\n        (@NodeID \r\n        ,@LastSync\r\n        ,@VolumeIndex\r\n        ,@Caption\r\n        ,@PollInterval\r\n        ,@StatCollection\r\n        ,@RediscoveryInterval\r\n\t\t,@UnManaged\r\n\t\t,@UnManageFrom\r\n\t\t,@UnManageUntil\r\n\t\t,@VolumeDescription\r\n        ,@VolumeTypeID\r\n        ,@VolumeType\r\n        ,@VolumeTypeIcon\r\n        ,@VolumePercentUsed\r\n        ,@VolumeSpaceUsed\r\n        ,@VolumeSpaceAvailable\r\n        ,@VolumeSize\r\n        ,@Status\r\n        ,@StatusLED\r\n        ,@VolumeResponding\r\n        ,@VolumeAllocationFailuresThisHour\r\n        ,@VolumeAllocationFailuresToday\r\n        ,@NextPoll\r\n        ,@NextRediscovery\r\n        ,@FullName\r\n        ,@DiskQueueLength\r\n        ,@DiskTransfer\r\n        ,@DiskReads\r\n        ,@DiskWrites\r\n        ,@TotalDiskIOPS\r\n        ,@DeviceId\r\n        ,@DiskSerialNumber\r\n\t\t,@InterfaceType\r\n        ,@SCSITargetId\r\n        ,@SCSIPortId\r\n        ,@SCSILunId\r\n        ,@SCSIControllerId\r\n        ,@SCSIPortOffset);\r\n\r\n    SELECT scope_identity();\r\nEND\r\nELSE\r\nBEGIN\r\n    SELECT -1;\r\nEND\r\n");

            volume = new DALHelper <Volume>().Initialize(volume);
            VolumeDAL.LoadCommandParams(volume, textCommand, true);
            VolumeDAL.log.TraceFormat("Inserting volume. Locking thread. NodeID: {0}, Name: {1}", new object[2]
            {
                (object)volume.get_NodeID(),
                (object)volume.get_VolumeDescription()
            });
            lock (VolumeDAL.insertVolumeLock)
            {
                VolumeDAL.log.TraceFormat("Inserting volume. Thread locked. NodeID: {0}, Name: {1}", new object[2]
                {
                    (object)volume.get_NodeID(),
                    (object)volume.get_VolumeDescription()
                });
                volume.set_VolumeId(Convert.ToInt32(SqlHelper.ExecuteScalar(textCommand)));
                if (volume.get_VolumeId() > 0)
                {
                    VolumeDAL.log.DebugFormat("Volume [{0}] inserted with ID {1} on node {2}", (object)volume.get_VolumeDescription(), (object)volume.get_VolumeId(), (object)volume.get_NodeID());
                }
                else
                {
                    VolumeDAL.log.DebugFormat("Volume [{0}] managed already on node {1}", (object)volume.get_VolumeDescription(), (object)volume.get_NodeID());
                }
            }
            return(volume.get_VolumeId());
        }
Ejemplo n.º 2
0
        // Token: 0x06000880 RID: 2176 RVA: 0x0003E0E0 File Offset: 0x0003C2E0
        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.CustomProperties.Keys;
            }
            MacroParser macroParser = new MacroParser(new Action <string, int>(BusinessLayerOrionEvent.WriteEvent))
            {
                ObjectType    = "Volume",
                ActiveObject  = volume.ID.ToString(),
                NetObjectID   = volume.ID.ToString(),
                NetObjectName = volume.FullName,
                NodeID        = volume.NodeID,
                NodeName      = NodeDAL.GetNode(volume.NodeID).Name
            };

            using (macroParser.MyDBConnection = DatabaseFunctions.CreateConnection())
            {
                foreach (string text in properties)
                {
                    string key = text.Trim();
                    if (volume.CustomProperties.ContainsKey(key))
                    {
                        object obj = volume.CustomProperties[key];
                        if (obj != null && obj.ToString().Contains("${"))
                        {
                            dictionary[key] = macroParser.ParseMacros(obj.ToString(), false);
                        }
                        else
                        {
                            dictionary[key] = obj;
                        }
                    }
                }
            }
            return(dictionary);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public static Volumes GetNodeVolumes(int nodeID)
        {
            Volumes volumes = new Volumes();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand("SELECT * FROM Volumes WHERE NodeID=@NodeId"))
            {
                textCommand.Parameters.Add("@NodeId", SqlDbType.Int).Value = (object)nodeID;
                using (IDataReader reader = SqlHelper.ExecuteReader(textCommand))
                {
                    while (reader.Read())
                    {
                        ((Collection <int, Volume>)volumes).Add(DatabaseFunctions.GetInt32(reader, "VolumeID"), VolumeDAL.CreateVolume(reader));
                    }
                }
            }
            return(volumes);
        }
Ejemplo n.º 5
0
        public static PropertyBag UpdateVolume(Volume volume)
        {
            PropertyBag propertyBag1 = new PropertyBag();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand("\r\n                DECLARE @tempTable TABLE (Caption nvarchar(75), FullName nvarchar(255), Status int, PollInterval int, StatCollection int, RediscoveryInterval int, VolumeIndex int, VolumeType nvarchar(40), VolumeDescription nvarchar(512), VolumeSize float, VolumeResponding char(1));\r\n\t\t\t\tUPDATE [Volumes] SET \r\n\t\t\t\t[LastSync] = @LastSync     \r\n\t\t\t\t,[VolumeIndex] = @VolumeIndex\r\n\t\t\t\t,[Caption] = @Caption\r\n\t\t\t\t,[PollInterval] = @PollInterval\r\n\t\t\t\t,[StatCollection] = @StatCollection\r\n\t\t\t\t,[RediscoveryInterval] = @RediscoveryInterval\r\n                ,[UnManaged] = @UnManaged\r\n                ,[UnManageFrom] = @UnManageFrom\r\n                ,[UnManageUntil] = @UnManageUntil\r\n\t\t\t\t,[VolumeDescription] = @VolumeDescription\r\n                ,[VolumeTypeID] = @VolumeTypeID\r\n\t\t\t\t,[VolumeType] = @VolumeType\r\n\t\t\t\t,[VolumeTypeIcon] = @VolumeTypeIcon\r\n\t\t\t\t,[VolumePercentUsed] = @VolumePercentUsed\r\n\t\t\t\t,[VolumeSpaceUsed] = @VolumeSpaceUsed\r\n\t\t\t\t,[VolumeSpaceAvailable] = @VolumeSpaceAvailable\r\n\t\t\t\t,[VolumeSize] = @VolumeSize\r\n\t\t\t\t,[Status] = @Status\r\n\t\t\t\t,[StatusLED] = @StatusLED\r\n\t\t\t\t,[VolumeResponding] = @VolumeResponding\r\n\t\t\t\t,[VolumeAllocationFailuresThisHour] = @VolumeAllocationFailuresThisHour\r\n\t\t\t\t,[VolumeAllocationFailuresToday] = @VolumeAllocationFailuresToday\r\n\t\t\t\t,[NextPoll] = @NextPoll\r\n\t\t\t\t,[NextRediscovery] = @NextRediscovery\r\n\t\t\t\t,[FullName] = @FullName\r\n                ,[DiskQueueLength] = @DiskQueueLength\r\n                ,[DiskTransfer] = @DiskTransfer\r\n                ,[DiskReads] = @DiskReads\r\n                ,[DiskWrites] = @DiskWrites\r\n                ,[TotalDiskIOPS] = @TotalDiskIOPS\r\n                ,[DeviceId] = @DeviceId\r\n                ,[DiskSerialNumber] = @DiskSerialNumber\r\n\t\t\t\t,[InterfaceType] = @InterfaceType\r\n                ,[SCSITargetId] = @SCSITargetId\r\n                ,[SCSIPortId] = @SCSIPortId\r\n                ,[SCSILunId] = @SCSILunId\r\n                ,[SCSIControllerId] = @SCSIControllerId\r\n                ,[SCSIPortOffset] = @SCSIPortOffset\r\n                OUTPUT DELETED.Caption, \r\n                       DELETED.FullName, \r\n                       DELETED.Status, \r\n                       DELETED.PollInterval, \r\n                       DELETED.StatCollection,\r\n                       DELETED.RediscoveryInterval,\r\n                       DELETED.VolumeIndex,\r\n                       DELETED.VolumeType,\r\n                       DELETED.VolumeDescription,\r\n                       DELETED.VolumeSize,\r\n                       DELETED.VolumeResponding INTO @tempTable\r\n\t\t\t\tWHERE VolumeID = @VolumeID;\r\n                SELECT * FROM @tempTable;"))
            {
                VolumeDAL.LoadCommandParams(volume, textCommand, true);
                using (DataTable dataTable = SqlHelper.ExecuteDataTable(textCommand))
                {
                    if (dataTable.Rows.Count == 1)
                    {
                        VolumeDAL.UpdateCustomProperties(volume);
                        foreach (DataRow row in (InternalDataCollectionBase)dataTable.Rows)
                        {
                            PropertyBag propertyBag2 = new PropertyBag();
                            foreach (DataColumn column in (InternalDataCollectionBase)dataTable.Columns)
                            {
                                object obj1     = row[column] == DBNull.Value ? (object)null : row[column];
                                object obj2     = (object)null;
                                bool?  nullable = new bool?();
                                if (column.ColumnName.Equals("Caption", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_Caption();
                                }
                                else if (column.ColumnName.Equals("FullName", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_FullName();
                                }
                                else if (column.ColumnName.Equals("Status", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_Status();
                                }
                                else if (column.ColumnName.Equals("PollInterval", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_PollInterval();
                                }
                                else if (column.ColumnName.Equals("StatCollection", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_StatCollection();
                                }
                                else if (column.ColumnName.Equals("RediscoveryInterval", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_RediscoveryInterval();
                                }
                                else if (column.ColumnName.Equals("VolumeDescription", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_VolumeDescription();
                                }
                                else if (column.ColumnName.Equals("VolumeSize", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_VolumeSize();
                                }
                                else if (column.ColumnName.Equals("VolumeIndex", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_VolumeIndex();
                                }
                                else if (column.ColumnName.Equals("VolumeType", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_VolumeType();
                                }
                                else if (column.ColumnName.Equals("VolumeResponding", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj2 = (object)volume.get_VolumeResponding();
                                    bool flag = obj1 != null && string.Equals(obj1.ToString(), "Y", StringComparison.OrdinalIgnoreCase);
                                    nullable = new bool?((bool)obj2 == flag);
                                }
                                if (obj1 == null && obj2 != null || obj1 != null && obj2 == null || !nullable.HasValue && obj2 != null && (obj1 != null && !string.Equals(obj2.ToString(), obj1.ToString(), StringComparison.Ordinal)) || nullable.HasValue && !nullable.Value)
                                {
                                    ((Dictionary <string, object>)propertyBag1).Add(column.ColumnName, obj2);
                                    ((Dictionary <string, object>)propertyBag2).Add(column.ColumnName, obj1);
                                }
                            }
                            if (((Dictionary <string, object>)propertyBag2).Count != 0)
                            {
                                ((Dictionary <string, object>)propertyBag1).Add("PreviousProperties", (object)propertyBag2);
                            }
                        }
                    }
                }
            }
            return(propertyBag1);
        }
Ejemplo n.º 6
0
        // Token: 0x06000877 RID: 2167 RVA: 0x0003D090 File Offset: 0x0003B290
        public static PropertyBag UpdateVolume(Volume volume)
        {
            PropertyBag propertyBag = new PropertyBag();

            using (SqlCommand textCommand = SqlHelper.GetTextCommand("\r\n                DECLARE @tempTable TABLE (Caption nvarchar(75), FullName nvarchar(255), Status int, PollInterval int, StatCollection int, RediscoveryInterval int, VolumeIndex int, VolumeType nvarchar(40), VolumeDescription nvarchar(512), VolumeSize float, VolumeResponding char(1));\r\n\t\t\t\tUPDATE [Volumes] SET \r\n\t\t\t\t[LastSync] = @LastSync     \r\n\t\t\t\t,[VolumeIndex] = @VolumeIndex\r\n\t\t\t\t,[Caption] = @Caption\r\n\t\t\t\t,[PollInterval] = @PollInterval\r\n\t\t\t\t,[StatCollection] = @StatCollection\r\n\t\t\t\t,[RediscoveryInterval] = @RediscoveryInterval\r\n\t\t\t\t,[VolumeDescription] = @VolumeDescription\r\n                ,[VolumeTypeID] = @VolumeTypeID\r\n\t\t\t\t,[VolumeType] = @VolumeType\r\n\t\t\t\t,[VolumeTypeIcon] = @VolumeTypeIcon\r\n\t\t\t\t,[VolumePercentUsed] = @VolumePercentUsed\r\n\t\t\t\t,[VolumeSpaceUsed] = @VolumeSpaceUsed\r\n\t\t\t\t,[VolumeSpaceAvailable] = @VolumeSpaceAvailable\r\n\t\t\t\t,[VolumeSize] = @VolumeSize\r\n\t\t\t\t,[Status] = @Status\r\n\t\t\t\t,[StatusLED] = @StatusLED\r\n\t\t\t\t,[VolumeResponding] = @VolumeResponding\r\n\t\t\t\t,[VolumeAllocationFailuresThisHour] = @VolumeAllocationFailuresThisHour\r\n\t\t\t\t,[VolumeAllocationFailuresToday] = @VolumeAllocationFailuresToday\r\n\t\t\t\t,[NextPoll] = @NextPoll\r\n\t\t\t\t,[NextRediscovery] = @NextRediscovery\r\n\t\t\t\t,[FullName] = @FullName\r\n                ,[DiskQueueLength] = @DiskQueueLength\r\n                ,[DiskTransfer] = @DiskTransfer\r\n                ,[DiskReads] = @DiskReads\r\n                ,[DiskWrites] = @DiskWrites\r\n                ,[TotalDiskIOPS] = @TotalDiskIOPS\r\n                ,[DeviceId] = @DeviceId\r\n                ,[DiskSerialNumber] = @DiskSerialNumber\r\n\t\t\t\t,[InterfaceType] = @InterfaceType\r\n                ,[SCSITargetId] = @SCSITargetId\r\n                ,[SCSIPortId] = @SCSIPortId\r\n                ,[SCSILunId] = @SCSILunId\r\n                ,[SCSIControllerId] = @SCSIControllerId\r\n                ,[SCSIPortOffset] = @SCSIPortOffset\r\n                OUTPUT DELETED.Caption, \r\n                       DELETED.FullName, \r\n                       DELETED.Status, \r\n                       DELETED.PollInterval, \r\n                       DELETED.StatCollection,\r\n                       DELETED.RediscoveryInterval,\r\n                       DELETED.VolumeIndex,\r\n                       DELETED.VolumeType,\r\n                       DELETED.VolumeDescription,\r\n                       DELETED.VolumeSize,\r\n                       DELETED.VolumeResponding INTO @tempTable\r\n\t\t\t\tWHERE VolumeID = @VolumeID;\r\n                SELECT * FROM @tempTable;"))
            {
                VolumeDAL.LoadCommandParams(volume, textCommand, true);
                using (DataTable dataTable = SqlHelper.ExecuteDataTable(textCommand))
                {
                    if (dataTable.Rows.Count == 1)
                    {
                        VolumeDAL.UpdateCustomProperties(volume);
                        foreach (object obj in dataTable.Rows)
                        {
                            DataRow     dataRow      = (DataRow)obj;
                            PropertyBag propertyBag2 = new PropertyBag();
                            foreach (object obj2 in dataTable.Columns)
                            {
                                DataColumn dataColumn = (DataColumn)obj2;
                                object     obj3       = (dataRow[dataColumn] == DBNull.Value) ? null : dataRow[dataColumn];
                                object     obj4       = null;
                                bool?      flag       = null;
                                if (dataColumn.ColumnName.Equals("Caption", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.Caption;
                                }
                                else if (dataColumn.ColumnName.Equals("FullName", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.FullName;
                                }
                                else if (dataColumn.ColumnName.Equals("Status", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.Status;
                                }
                                else if (dataColumn.ColumnName.Equals("PollInterval", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.PollInterval;
                                }
                                else if (dataColumn.ColumnName.Equals("StatCollection", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.StatCollection;
                                }
                                else if (dataColumn.ColumnName.Equals("RediscoveryInterval", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.RediscoveryInterval;
                                }
                                else if (dataColumn.ColumnName.Equals("VolumeDescription", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.VolumeDescription;
                                }
                                else if (dataColumn.ColumnName.Equals("VolumeSize", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.VolumeSize;
                                }
                                else if (dataColumn.ColumnName.Equals("VolumeIndex", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.VolumeIndex;
                                }
                                else if (dataColumn.ColumnName.Equals("VolumeType", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.VolumeType;
                                }
                                else if (dataColumn.ColumnName.Equals("VolumeResponding", StringComparison.OrdinalIgnoreCase))
                                {
                                    obj4 = volume.VolumeResponding;
                                    bool flag2 = obj3 != null && string.Equals(obj3.ToString(), "Y", StringComparison.OrdinalIgnoreCase);
                                    flag = new bool?((bool)obj4 == flag2);
                                }
                                if ((obj3 == null && obj4 != null) || (obj3 != null && obj4 == null) || (flag == null && obj4 != null && obj3 != null && !string.Equals(obj4.ToString(), obj3.ToString(), StringComparison.Ordinal)) || (flag != null && !flag.Value))
                                {
                                    propertyBag.Add(dataColumn.ColumnName, obj4);
                                    propertyBag2.Add(dataColumn.ColumnName, obj3);
                                }
                            }
                            if (propertyBag2.Count != 0)
                            {
                                propertyBag.Add("PreviousProperties", propertyBag2);
                            }
                        }
                    }
                }
            }
            return(propertyBag);
        }