예제 #1
0
        public void MountDiskDrive(DiskDrive drive)
        {
            logger.Warn("This method is more of a stub than something functional");

            m_CurrentDiskDrive = drive;
            logger.Debug("A disk drive has been inserted into the slot");
        }
예제 #2
0
        public void ReleaseDiskDrive()
        {
            logger.Warn("This method is more of a stub than something functional");
            logger.Debug("Releasing current disk drive");

            m_CurrentDiskDrive = null;
        }
예제 #3
0
        public override void MainMethod()
        {
            Ensure.Init();
            CPU.DisableInts();
            GDT.Init();
            IDT.Init();
            ISR.Init();
            Console.Clear();
            ACPI.Init();
            ACPI.Enable();
            PageManager.Init();
            Heap.Init();
            GC.Init();
            Paging.Init();
            PIT.Init();
            RTC.Init();
            Scheduler.Init();
            CPU.EnableInts();
            DiskDrive.Init();
            //FatFileSystem.Init();
            PCI.Init();
            Driver.Init();
            AudioMixer.Init();

            new Thread(Event.Init, "Events").Start();
            new Thread(new SCI().Main, "Shell").Start();

            Scheduler.Idle();
        }
        public IActionResult PostDiskDrive([FromBody] DiskDrive diskDrive)
        {
            idiskDrive.AddDiskDrive(diskDrive);


            return(CreatedAtAction("GetDiskDrive", new { id = diskDrive.DiskDriveId }, diskDrive));
        }
예제 #5
0
        public SharedDirectory GetNetworkDisk(string clientUserID, string netDiskID, string dirPath)
        {
            var rootPath = this.networkDiskPathManager.GetNetworkDiskRootPath(clientUserID, netDiskID);

            if (rootPath == null)
            {
                return(null);
            }

            var iniDirName  = this.networkDiskPathManager.GetNetworkDiskIniDirName(clientUserID, netDiskID);
            var diskRpotDir = rootPath + "\\" + iniDirName + "\\";

            if (!Directory.Exists(diskRpotDir))
            {
                Directory.CreateDirectory(diskRpotDir);
            }

            if (dirPath == null)
            {
                var dir  = new SharedDirectory();
                var disk = new DiskDrive();
                disk.Name               = iniDirName;
                disk.TotalSize          = this.networkDiskPathManager.GetNetworkDiskTotalSize(clientUserID, netDiskID);
                disk.AvailableFreeSpace = disk.TotalSize - this.networkDiskPathManager.GetNetworkDiskSizeUsed(clientUserID, netDiskID);

                dir.DriveList.Add(disk);
                return(dir);
            }

            return(SharedDirectory.GetSharedDirectory(rootPath + dirPath));
        }
예제 #6
0
        // This is pretty gross and didn't work out how I hoped... Refactor one day but sick of it for now.
        public static void CreateOrUpdateCollection(ICollection <DiskDrive> existing, ICollection <DiskDrive> entity, DbContext context)
        {
            // Remove any previously encountered entries that are not longer present (pulled from the system?)
            // ToList creates a copy and prevents loop corruption..
            foreach (DiskDrive e in existing.ToList())
            {
                if (!entity.Any(d => d.SerialNumber == e.SerialNumber))
                {
                    existing.Remove(e);
                }
            }

            foreach (DiskDrive e in entity)
            {
                DiskDrive found = existing.SingleOrDefault(d => d.SerialNumber == e.SerialNumber);
                if (found == null)
                {
                    existing.Add(e);
                }
                else
                {
                    context.Entry(found).CurrentValues.SetValues(e);
                }
            }
        }
예제 #7
0
 public Partition(DiskDrive host, ulong offset, ulong size, uint id)
 {
     this.host   = host;
     this.offset = offset;
     this.size   = size;
     this.id     = id;
 }
        /// <summary>
        /// DT_SMART_ANALYSIS_RESULTテーブルからDtSmartAnalysisResultを取得する
        /// </summary>
        /// <param name="diskDrive">ディスクドライブ</param>
        /// <returns>取得したデータ</returns>
        public DtSmartAnalysisResult ReadDtSmartAnalysisResult(DiskDrive diskDrive)
        {
            DtSmartAnalysisResult model = null;

            try
            {
                _logger.EnterJson("{0}", diskDrive);

                DBAccessor.Models.DtSmartAnalysisResult entity = null;
                _dbPolly.Execute(() =>
                {
                    using (DBAccessor.Models.RmsDbContext db = new DBAccessor.Models.RmsDbContext(_appSettings))
                    {
                        entity = db.DtSmartAnalysisResult.FirstOrDefault(x => x.EquipmentUid == diskDrive.SourceEquipmentUid && x.DiskSerialNumber == diskDrive.SerialNo);
                    }
                });

                if (entity != null)
                {
                    model = entity.ToModel();
                }

                return(model);
            }
            catch (Exception e)
            {
                throw new RmsException("DT_SMART_ANALYSIS_RESULTテーブルのSelectに失敗しました。", e);
            }
            finally
            {
                _logger.LeaveJson("{0}", model);
            }
        }
예제 #9
0
 private bool CheckFilename(string filename, DiskDrive dd, bool write)
 {
     if (dd == null)
     {
         MessageBox.Show("Choose valid SD drive first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
     if (filename.Length == 0)
     {
         MessageBox.Show("Image file name is missing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
     filename = Path.GetFullPath(filename);
     if (dd.Volumes.Any(z => z.Name == Path.GetPathRoot(filename)))
     {
         MessageBox.Show("Image file must not be located on SD drive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
     if (write && File.Exists(filename))
     {
         if (MessageBox.Show("Image file already exists. Do you want to overwrite?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #10
0
        public SharedDirectory GetNetworkDisk(string userID, string dirPath)
        {
            string rootPath = this.networkDiskPathManager.GetNetworkDiskRootPath(userID);

            if (rootPath == null)
            {
                return(null);
            }

            if (!Directory.Exists(rootPath + userID))
            {
                Directory.CreateDirectory(rootPath + userID);
            }

            if (dirPath == null)
            {
                SharedDirectory dir  = new SharedDirectory();
                DiskDrive       disk = new DiskDrive();
                disk.Name               = userID;
                disk.TotalSize          = this.networkDiskPathManager.GetNetworkDiskTotalSize(userID);
                disk.AvailableFreeSpace = disk.TotalSize - this.networkDiskPathManager.GetNetworkDiskSizeUsed(userID);

                dir.DriveList.Add(disk);
                return(dir);
            }

            return(SharedDirectory.GetSharedDirectory(rootPath + dirPath));
        }
예제 #11
0
        async Task Wipe(DiskDrive disk)
        {
            _canceler.Dispose();
            _canceler = new CancellationTokenSource();

            ToggleControls(true);
            try
            {
                var progress = new Progress <int>(percent =>
                {
                    randomWipeProgress.Value = percent;
                });

                var wipeType = (DataWipeType)randomWipeType.SelectedItem;

                await Task.Run(() =>
                {
                    DeviceWiper.WipePhysicalDrive(wipeType.SourceFactory, disk.DeviceNumber, progress, _canceler.Token);
                }, _canceler.Token);
            }
            catch (OperationCanceledException)
            {
                // whatevs
            }
            finally
            {
                randomWipeProgress.Value = 0;
                ToggleControls(false);
            }
        }
예제 #12
0
        private async void btnWipe_Click(object sender, EventArgs e)
        {
            DiskDrive dd = (DiskDrive)lstDiskDrive.SelectedItem;

            if (dd == null)
            {
                MessageBox.Show("Choose valid SD drive first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show("All data on SD card will be erased and partitions deleted. Are you sure?", "Warning",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            Operation = "Wiping";
            if (!TryLockVolumes(dd))
            {
                return;
            }
            SetButtons(false);
            using (Stream source = new ConstantStream(0xff), dest = dd.CreateStream(FileAccess.Write))
            {
                var mbr = Properties.Resources.MBR;
                dest.Write(mbr, 0, mbr.Length);

                progress.Value   = 0;
                progress.Maximum = (int)(((long)dd.GetDriveSize() - mbr.Length) / (1024 * 1024)) + 1;

                cts = new CancellationTokenSource();
                try
                {
                    await CopyStreamAsync(source, dest, (long)dd.GetDriveSize() - mbr.Length, cts.Token, null);
                }
                catch (Exception ex)
                {
                    if (!(ex is OperationCanceledException))
                    {
                        MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK);
                    }
                    cts.Cancel();
                }
            }
            dd.DismountVolumes();
            dd.UnlockVolumes();
            dd.MountVolumes();
            ResetProgress();

            FillDriveList();
            if (!cts.IsCancellationRequested)
            {
                MessageBox.Show("Erasing complete.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            SetButtons(true);
            cts = null;
        }
예제 #13
0
        public static List <DiskDrive> GetAvailableDisks()
        {
            List <DiskDrive> DiskDrives = new List <DiskDrive>();

            // browse all USB WMI physical disks
            foreach (ManagementObject drive in
                     new ManagementObjectSearcher(
                         "select DeviceID, MediaType,InterfaceType from Win32_DiskDrive").Get())
            {
                // associate physical disks with partitions
                ManagementObjectCollection partitionCollection = new ManagementObjectSearcher(String.Format(
                                                                                                  "associators of {{Win32_DiskDrive.DeviceID='{0}'}} " +
                                                                                                  "where AssocClass = Win32_DiskDriveToDiskPartition",
                                                                                                  drive["DeviceID"])).Get();

                foreach (ManagementObject partition in partitionCollection)
                {
                    if (partition != null)
                    {
                        // associate partitions with logical disks (drive letter volumes)
                        ManagementObjectCollection logicalCollection = new ManagementObjectSearcher(String.Format(
                                                                                                        "associators of {{Win32_DiskPartition.DeviceID='{0}'}} " +
                                                                                                        "where AssocClass= Win32_LogicalDiskToPartition",
                                                                                                        partition["DeviceID"])).Get();

                        foreach (ManagementObject logical in logicalCollection)
                        {
                            if (logical != null)
                            {
                                // finally find the logical disk entry
                                ManagementObjectCollection.ManagementObjectEnumerator volumeEnumerator = new ManagementObjectSearcher(String.Format(
                                                                                                                                          "select * from Win32_LogicalDisk " +
                                                                                                                                          "where Name='{0}'",
                                                                                                                                          logical["Name"])).Get().GetEnumerator();

                                volumeEnumerator.MoveNext();

                                ManagementObject volume = (ManagementObject)volumeEnumerator.Current;

                                DiskDrive disk = new DiskDrive();

                                disk.MediaType     = drive["MediaType"].ToString();
                                disk.DriveLetter   = volume["DeviceID"].ToString();
                                disk.Freespace     = (ulong)volume["Freespace"];
                                disk.Size          = (ulong)volume["Size"];
                                disk.InterfaceType = drive["InterfaceType"].ToString();
                                disk.VolumeName    = volume["VolumeName"].ToString();
                                DiskDrives.Add(disk);
                            }
                        }
                    }
                }
            }

            return(DiskDrives);
        }
예제 #14
0
        public async Task CreateHDD(DiskDrive diskDrive)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var response = await client.PostAsJsonAsync("api/DiskDrives", diskDrive);
        }
예제 #15
0
        public async Task <ICollection <DiskDrive> > Update()
        {
            ICollection <DiskDrive> disks = new List <DiskDrive>();

            IDiskDriveService service = new DiskDriveService(new LabSystemsContextFactory());

            ManagementObjectCollection drives = _driveClass.GetInstances();

            string firmware    = "FirmwareRevision";
            string model       = "Model";
            string serial      = "SerialNumber";
            string PNPDeviceId = "PNPDeviceID";

            foreach (ManagementObject drive in drives)
            {
                DiskDrive driveModel = new DiskDrive();

                foreach (PropertyData property in drive.Properties)
                {
                    if (property.Name == firmware)
                    {
                        driveModel.Firmware = property.Value.ToString();
                        continue;
                    }
                    if (property.Name == model)
                    {
                        driveModel.ModelNumber = property.Value.ToString();
                        continue;
                    }
                    if (property.Name == serial)
                    {
                        driveModel.SerialNumber = property.Value.ToString();

                        DiskDrive existingDisk = await service.Get(property.Value.ToString());

                        if (existingDisk != null)
                        {
                            driveModel.LabSystemId = existingDisk.LabSystemId;
                            driveModel.Id          = existingDisk.Id;
                        }

                        continue;
                    }
                    if (property.Name == PNPDeviceId)
                    {
                        AddDriverInfo(driveModel, property.Value.ToString());
                        continue;
                    }
                }

                disks.Add(driveModel);
            }

            return(disks);
        }
예제 #16
0
        public DiskDriveViewModel(DiskDrive diskDrive)
        {
            Name     = diskDrive.Name;
            DeviceId = diskDrive.DeviceId;

            StringBuilder capabs = new StringBuilder();

            foreach (KeyValuePair <string, string> capability in diskDrive.CapabilityDescriptionDictionary)
            {
                capabs.Append(capability.Key);
                capabs.Append("(");
                capabs.Append(capability.Value);
                capabs.Append(");");
            }

            Capabilities = capabs.ToString();

            Availability           = diskDrive.Availability;
            BytesPerSector         = diskDrive.BytesPerSector;
            DefaultBlockSize       = diskDrive.DefaultBlockSize;
            MaxBlockSize           = diskDrive.MaxBlockSize;
            MinBlockSize           = diskDrive.MinBlockSize;
            Caption                = diskDrive.Caption;
            ConfigManagerErrorCode = diskDrive.ConfigManagerErrorCode;
            ErrorDescription       = diskDrive.ErrorDescription;
            ErrorMethodology       = diskDrive.ErrorMethodology;
            InterfaceType          = diskDrive.InterfaceType;
            Manufacturer           = diskDrive.Manufacturer;
            Model            = diskDrive.Model;
            IsMediaLoaded    = diskDrive.IsMediaLoaded;
            DoesNeedCleaning = diskDrive.DoesNeedCleaning;
            MediaType        = diskDrive.MediaType;
            PartitionCount   = diskDrive.PartitionCount;
            PnpDeviceID      = diskDrive.PnpDeviceID;

            capabs.Clear();

            foreach (string capability in diskDrive.PowerManagementCapabilities)
            {
                capabs.Append(capability);
                capabs.Append(";");
            }

            PowerManagementCapabilities = capabs.ToString();

            IsPowerManagementSupported = diskDrive.IsPowerManagementSupported;
            SerialNumber   = diskDrive.SerialNumber;
            Signature      = diskDrive.Signature;
            Size           = MemoryDisplayFormatter.Format(diskDrive.Size);
            Status         = diskDrive.Status;
            TotalCylinders = diskDrive.TotalCylinders;
            TotalHeads     = diskDrive.TotalHeads;
            TotalSectors   = diskDrive.TotalSectors;
            TotalTracks    = diskDrive.TotalTracks;
        }
예제 #17
0
        private async void btnWrite_Click(object sender, EventArgs e)
        {
            DiskDrive dd = (DiskDrive)lstDiskDrive.SelectedItem;

            if (!CheckFilename(txtFilename.Text, dd, false))
            {
                txtFilename.Focus();
                return;
            }
            var filename = Path.GetFullPath(txtFilename.Text);

            if (MessageBox.Show("All data on SD card will be erased and overwritten. Are you sure?", "Warning",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            Operation = "Writing";
            if (!TryLockVolumes(dd))
            {
                return;
            }
            SetButtons(false);
            using (Stream source = new FileStream(txtFilename.Text, FileMode.Open, FileAccess.Read, FileShare.Read),
                   dest = dd.CreateStream(FileAccess.Write))
            {
                progress.Maximum = (int)(source.Length / (1024 * 1024)) + 1;
                progress.Value   = 0;
                cts = new CancellationTokenSource();
                try
                {
                    await CopyStreamAsync(source, dest, source.Length, cts.Token, null);
                }
                catch (Exception ex)
                {
                    if (!(ex is OperationCanceledException))
                    {
                        MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK);
                    }
                    cts.Cancel();
                }
            }
            dd.DismountVolumes();
            dd.UnlockVolumes();
            dd.MountVolumes();

            FillDriveList();
            if (!cts.IsCancellationRequested)
            {
                MessageBox.Show("Writing complete.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            ResetProgress();
            cts = null;
        }
예제 #18
0
파일: Southbridge.cs 프로젝트: griderd/gsvm
        public Southbridge(DiskDrive cmos)
        {
            deviceType = 1;
            GenerateID();
            devices = new List <IGenericDeviceBus>();
            //ports = new MemoryMap<int>();
            interruptChannels = new Dictionary <int, int>();

            InitializePorts();
            AddDevice(cmos);
        }
예제 #19
0
        public IActionResult Get(string id)
        {
            DiskDrive diskDrive = _diskDriveService.GetDiskDriveById(id);

            if (diskDrive != null)
            {
                return(Ok(diskDrive));
            }
            else
            {
                return(NotFound());
            }
        }
예제 #20
0
 private bool TryLockVolumes(DiskDrive disk)
 {
     try
     {
         disk.LockVolumes();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Could not lock volume(s) on disk drive {0}. Please ensure that no other program is accessing this drive.\n\nException: {1}",
                                       disk.ID, ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
 }
        public bool DeleteDiskDriveById(string id)
        {
            DiskDrive diskDrive = _unitOfWork.DiskDrives.Get(id);

            if (diskDrive == null)
            {
                return(false);
            }
            else
            {
                _unitOfWork.DiskDrives.Remove(diskDrive);
                _unitOfWork.SaveChanges();
                return(true);
            }
        }
예제 #22
0
        public async void getHDD()
        {
            ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");


            foreach (ManagementObject mj in mos.Get())
            {
                DiskDrive diskDrive = new DiskDrive();
                //Console.WriteLine("DiskDrive Name : " + Convert.ToString(mj["Caption"]));
                //Console.WriteLine("Size DiskDrive : " + (((Convert.ToUInt64(mj["Size"]) / 1024) / 1024)/1024) + " GB");
                diskDrive.Caption = Convert.ToString(mj["Caption"]);
                diskDrive.Size    = Convert.ToInt32(((Convert.ToUInt64(mj["Size"]) / 1024) / 1024) / 1024);
                //  diskDrive.ProcessorId = computer.ProcessorId;
                await sendData.CreateHDD(diskDrive);
            }
        }
예제 #23
0
        public List <DiskDrive> GetDiskDrive()
        {
            ManagementObjectSearcher mos        = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
            List <DiskDrive>         diskDrives = new List <DiskDrive>();

            foreach (ManagementObject mj in mos.Get())
            {
                DiskDrive diskDrive = new DiskDrive();
                //Console.WriteLine("DiskDrive Name : " + Convert.ToString(mj["Caption"]));
                //Console.WriteLine("Size DiskDrive : " + (((Convert.ToUInt64(mj["Size"]) / 1024) / 1024)/1024) + " GB");
                diskDrive.Caption = Convert.ToString(mj["Caption"]);
                diskDrive.Size    = Convert.ToInt32(((Convert.ToUInt64(mj["Size"]) / 1000) / 1000) / 1000);
                diskDrives.Add(diskDrive);
            }

            return(diskDrives);
        }
        public IActionResult PutDiskDrive([FromRoute] int id, [FromBody] DiskDrive diskDrive)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != diskDrive.DiskDriveId)
            {
                return(BadRequest());
            }

            idiskDrive.PutDiskDrive(id, diskDrive);


            return(NoContent());
        }
예제 #25
0
        private async void btnRead_Click(object sender, EventArgs e)
        {
            DiskDrive dd = (DiskDrive)lstDiskDrive.SelectedItem;

            if (!CheckFilename(txtFilename.Text, dd, true))
            {
                txtFilename.Focus();
                return;
            }
            var filename = Path.GetFullPath(txtFilename.Text);

            Operation = "Reading";
            if (!TryLockVolumes(dd))
            {
                return;
            }
            SetButtons(false);
            using (Stream dest = new FileStream(txtFilename.Text, FileMode.Create, FileAccess.Write, FileShare.None),
                   source = dd.CreateStream(FileAccess.Read))
            {
                progress.Maximum = (int)(dd.GetDriveSize() / (1024 * 1024)) + 1;
                progress.Value   = 0;
                cts = new CancellationTokenSource();
                try
                {
                    await CopyStreamAsync(source, dest, (long)dd.GetDriveSize(), cts.Token, null);
                }
                catch (Exception ex)
                {
                    if (!(ex is OperationCanceledException))
                    {
                        MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK);
                    }
                    cts.Cancel();
                }
            }
            dd.UnlockVolumes();

            if (!cts.IsCancellationRequested)
            {
                MessageBox.Show("Reading complete.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            ResetProgress();
            SetButtons(true);
            cts = null;
        }
예제 #26
0
        /// <summary>
        /// 受信メッセージからID=C5のSMART属性情報を取得する
        /// </summary>
        /// <param name="diskDrive">ディスクドライブ</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="smartAttirubteInfoC5">SMART属性情報C5</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool ReadSmartAttirubteInfoC5(DiskDrive diskDrive, string messageId, out DiskDrive.SmartAttributeInfoSchema smartAttirubteInfoC5)
        {
            smartAttirubteInfoC5 = null;

            try
            {
                _logger.EnterJson("{0}", new { diskDrive, messageId });

                // ID=C5のSMART属性情報を取得
                var smartAttributeInfos = diskDrive.SmartAttributeInfo?.Where(x => x.Id == SmartAttributeInfoIdC5);

                // SMART属性情報が存在しない場合は正常
                if (smartAttributeInfos == null || smartAttributeInfos.Count() == 0)
                {
                    return(true);
                }

                // SMART属性情報が複数存在する場合はエラー
                if (smartAttributeInfos.Count() > 1)
                {
                    throw new RmsException("SMART属性情報が複数存在しています(ID=C5)");
                }

                smartAttirubteInfoC5 = smartAttributeInfos.First();

                // SMART属性情報のC5生の値が存在しない場合はエラー
                if (string.IsNullOrEmpty(smartAttirubteInfoC5.RawData))
                {
                    throw new RmsException("SMART属性情報の生の値がnullまたは空文字です(ID=C5)");
                }

                return(true);
            }
            catch (RmsException e)
            {
                // SMART属性情報異常
                _logger.Error(e, nameof(Resources.UT_DDP_DDP_002), new object[] { messageId, e.Message });
                return(false);
            }
            finally
            {
                _logger.LeaveJson("{0}", new { smartAttirubteInfoC5 });
            }
        }
예제 #27
0
        /// <summary>
        /// アラーム情報を作成しQueueStorageへ登録する
        /// </summary>
        /// <param name="diskDrive">ディスクドライブ</param>
        /// <param name="smartAttirubteInfoC5">SMART属性情報(C5)</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="analysisResult">解析判定結果</param>
        /// <param name="alarmDef">アラーム定義</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool CreateAndEnqueueAlarmInfo(DiskDrive diskDrive, DiskDrive.SmartAttributeInfoSchema smartAttirubteInfoC5, string messageId, DtSmartAnalysisResult analysisResult, DtAlarmSmartPremonitor alarmDef)
        {
            _logger.EnterJson("{0}", new { diskDrive, smartAttirubteInfoC5, messageId, analysisResult, alarmDef });

            string message = null;

            try
            {
                // アラームキューを生成する
                var alarmInfo = new AlarmInfo
                {
                    SourceEquipmentUid = diskDrive.SourceEquipmentUid,
                    TypeCode           = string.Empty,
                    ErrorCode          = alarmDef.AnalysisResultErrorCode,
                    AlarmLevel         = alarmDef.AlarmLevel,
                    AlarmTitle         = alarmDef.AlarmTitle,
                    AlarmDescription   = string.Format(alarmDef.AlarmDescription, analysisResult.DiskSerialNumber, analysisResult.C5ChangesThreshholdOverCount, analysisResult.C5ChangesThreshholdLastDatetime?.ToString(Utility.Const.AlarmQueueDateTimeFormat)),
                    AlarmDatetime      = _timeProvider.UtcNow.ToString(Utility.Const.AlarmQueueDateTimeFormat),
                    EventDatetime      = diskDrive.CollectDt,
                    AlarmDefId         = $"{_settings.SystemName}_{_settings.SubSystemName}_{alarmDef.Sid.ToString()}",
                    MessageId          = messageId
                };

                message = JsonConvert.SerializeObject(alarmInfo);

                // キューを登録する
                _queueRepository.SendMessageToAlarmQueue(message);

                return(true);
            }
            catch (Exception e)
            {
                // アラーム生成エラー or アラームキューにアラーム情報を送信できない(基本設計書 5.1.2.4 エラー処理)
                _logger.Error(e, string.IsNullOrEmpty(message) ? nameof(Resources.UT_DDP_DDP_007) : nameof(Resources.UT_DDP_DDP_008), new object[] { messageId });
                return(false);
            }
            finally
            {
                _logger.Leave();
            }
        }
 private void FetchDiskDrives()
 {
     settings.DiskDrives = new List <DiskDrive>();
     // Enclosed in try/catch as some drives cause exceptions
     foreach (var drive in DriveInfo.GetDrives())
     {
         try
         {
             if (drive.IsReady)
             {
                 var diskDrive = new DiskDrive(drive);
                 if (!String.IsNullOrEmpty(diskDrive.DisplayName) && !string.IsNullOrEmpty(diskDrive.Name))
                 {
                     settings.DiskDrives.Add(diskDrive);
                 }
             }
         }
         catch { }
     }
     SaveSettings();
 }
예제 #29
0
        public void UpdateDiskDrives(string computerLogin, IEnumerable <DiskDriveDTO> diskDrives)
        {
            IEnumerable <DiskDrive> diskDrivesEntity = _unitOfWork.DiskDrives.GetDiskDrivesByComputerLogin(computerLogin);

            if (diskDrivesEntity != null)
            {
                foreach (DiskDrive diskDrive in diskDrivesEntity)
                {
                    _unitOfWork.DiskDrives.Remove(diskDrive);
                }
            }
            string computerId = _unitOfWork.Computers.GetIdByLogin(computerLogin);

            foreach (DiskDriveDTO diskDrive in diskDrives)
            {
                DiskDrive diskDriveEntity = _mapper.Map <DiskDriveDTO, DiskDrive>(diskDrive);
                diskDriveEntity.ComputerId = computerId;
                _unitOfWork.DiskDrives.Add(diskDriveEntity);
            }
            _unitOfWork.SaveChanges();
        }
예제 #30
0
        private void AddDriverInfo(DiskDrive driveModel, string pnpString)
        {
            // Not great :( ......... Takes 11 seconds to run.....
            string DriverProviderName = "DriverProviderName";
            string DriverVersion      = "DriverVersion";
            string DeviceId           = "DeviceID";

            SelectQuery query = new SelectQuery($"SELECT {DeviceId},{DriverProviderName},{DriverVersion} FROM Win32_PnPSignedDriver WHERE DeviceClass = 'DISKDRIVE'");
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

            foreach (ManagementObject mo in searcher.Get())
            {
                bool matched = false;
                foreach (PropertyData property in mo.Properties)
                {
                    if (property.Name == DeviceId && property.Value.ToString() == pnpString)
                    {
                        matched = true;
                        break;
                    }
                }

                if (matched == true)
                {
                    foreach (PropertyData property in mo.Properties)
                    {
                        if (property.Name == DriverProviderName)
                        {
                            driveModel.DriverProviderName = property.Value.ToString();
                            continue;
                        }
                        if (property.Name == DriverVersion)
                        {
                            driveModel.DriverVersion = property.Value.ToString();
                            continue;
                        }
                    }
                }
            }
        }
예제 #31
0
 public void MountDiskDrive(DiskDrive diskDrive)
 {
     throw new NotSupportedException();
 }
예제 #32
0
        public void ReleaseDiskDrive()
        {
            logger.Warn("This method is more of a stub than something functional");
            logger.Debug("Releasing current disk drive");

            m_CurrentDiskDrive = null;
        }
예제 #33
0
        public SharedDirectory GetNetworkDisk(string userID, string dirPath)
        {
            string rootPath = this.networkDiskPathManager.GetNetworkDiskRootPath(userID);
            if (rootPath == null)
            {
                return null;
            }

            if (!Directory.Exists(rootPath + userID))
            {
                Directory.CreateDirectory(rootPath + userID);
            }

            if (dirPath == null)
            {
                SharedDirectory dir = new SharedDirectory();
                DiskDrive disk = new DiskDrive();
                disk.Name = userID;
                disk.TotalSize = this.networkDiskPathManager.GetNetworkDiskTotalSize(userID);
                disk.AvailableFreeSpace = disk.TotalSize - this.networkDiskPathManager.GetNetworkDiskSizeUsed(userID);

                dir.DriveList.Add(disk);
                return dir;
            }

            return SharedDirectory.GetSharedDirectory(rootPath + dirPath);
        }
예제 #34
0
        public void MountDiskDrive(DiskDrive drive)
        {
            logger.Warn("This method is more of a stub than something functional");

            m_CurrentDiskDrive = drive;
            m_PIDataStream.MountDiskDrive(drive);
            logger.Debug("A disk drive has been inserted into the slot");
        }