コード例 #1
0
        public async Task UpdateMachine()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new MachineEntity
            {
                MachineId           = 11,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommandEntity>(),
                MachineInitCommands = new MachineInitCommandEntity[0]
            };

            rep.Get(11).Returns(machineEntity1);
            rep.GetTracking(Arg.Any <IEnumerable <int> >()).Returns(new[] { machineEntity1 });

            var machine = await ctrl.Get(11);

            machine.Name = "SuperMaxi";

            await ctrl.Update(machine);

            //await rep.Received().Update(11, Arg.Is<MachineEntity>(x => x.Name == "SuperMaxi"));
        }
コード例 #2
0
 public PciSurveyor(IEnumerable <Probe> probes, MachineEntity powerSource)
 {
     this.Probes      = probes.Index().Loop().GetEnumerator();
     this.Surveyor    = new BlockSurveyor(powerSource);
     this.Pcis        = Enumerable.Repeat <PowerConsumerInterface>(null, probes.Count()).ToList();
     this.PowerSource = powerSource;
 }
コード例 #3
0
        private static MachineEntity CreateMachine(string name)
        {
            var machine = new MachineEntity
            {
                UserId              = 1,
                ComPort             = "com47",
                Axis                = 2,
                BaudRate            = 6500,
                DtrIsReset          = true,
                Name                = name,
                SizeX               = 1m,
                SizeY               = 1m,
                SizeZ               = 1m,
                SizeA               = 1m,
                SizeB               = 1m,
                SizeC               = 1m,
                BufferSize          = 63,
                CommandToUpper      = true,
                ProbeSizeX          = 1m,
                ProbeSizeY          = 1m,
                ProbeSizeZ          = 1m,
                ProbeDistUp         = 1m,
                ProbeDist           = 1m,
                ProbeFeed           = 1m,
                MachineInitCommands = new HashSet <MachineInitCommandEntity>(),
                MachineCommands     = new HashSet <MachineCommandEntity>()
            };

            return(machine);
        }
コード例 #4
0
        /// <summary>
        ///     Checks the N/E/S/W/Up/Down directions of the Center block for any SegmentEntitys of T;
        ///     Will report whether there was a failure because a segment wasn't loaded.
        /// </summary>
        /// <typeparam name="T">The SegmentEntity class to search for.</typeparam>
        /// <param name="center">The MachineEntity to Search Around</param>
        /// <param name="encounteredNullSegments">Whether or not a Null Segment was Encountered</param>
        /// <returns></returns>
        public static List <T> CheckSurrounding <T>(this MachineEntity center, out bool encounteredNullSegment) where T : SegmentEntity
        {
            List <T> ret = new List <T>();

            long[] coords = new long[3];
            encounteredNullSegment = false;
            for (int i = 0; i < 3; ++i)
            {
                for (int j = -1; j <= 1; j += 2)
                {
                    Array.Clear(coords, 0, 3);
                    coords[i] = j;

                    long x = center.mnX + coords[0];
                    long y = center.mnY + coords[1];
                    long z = center.mnZ + coords[2];

                    Segment segment = center.AttemptGetSegment(x, y, z);
                    // Check if segment was generated (skip this point if it doesn't
                    if (segment == null)
                    {
                        encounteredNullSegment = true;
                        continue;
                    }
                    T tmcm = segment.SearchEntity(x, y, z) as T;
                    if (tmcm != null)
                    {
                        ret.Add(tmcm);
                    }
                }
            }

            return(ret);
        }
コード例 #5
0
        public async Task QueryOneMachinesNotFound()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new MachineEntity
            {
                MachineId           = 1,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommandEntity>(),
                MachineInitCommands = new MachineInitCommandEntity[0]
            };
            var machineEntity2 = new MachineEntity
            {
                MachineId           = 2,
                Name                = "Mini",
                MachineCommands     = new List <MachineCommandEntity>(),
                MachineInitCommands = new MachineInitCommandEntity[0]
            };

            rep.Get(1).Returns(machineEntity1);
            rep.Get(2).Returns(machineEntity2);

            var machine = await ctrl.Get(3);

            machine.Should().BeNull();
        }
コード例 #6
0
ファイル: NetApi32.cs プロジェクト: radtek/NetTool
        public static List <MachineEntity> GetNetWorkMachines()
        {
            ArrayList     alNetworkComputers = NetApi32.GetServerList(NetApi32.SV_101_TYPES.SV_TYPE_WORKSTATION | NetApi32.SV_101_TYPES.SV_TYPE_SERVER);
            var           returnList         = new List <MachineEntity>();
            MachineEntity machineentity      = null;
            string        computerName       = "";

            for (int nIndex = 0; nIndex < alNetworkComputers.Count; nIndex++)
            {
                computerName              = ((NetApi32.SERVER_INFO_101)alNetworkComputers[nIndex]).sv101_name;
                machineentity             = new MachineEntity();
                machineentity.MachineName = computerName;
                if (Dns.GetHostName() != computerName)
                {
                    try
                    {
                        machineentity.IPAddress = Dns.GetHostAddresses(computerName)[0].ToString();
                    }
                    catch (System.Net.Sockets.SocketException)
                    {
                        machineentity.IPAddress = "NA";
                    }
                }
                else
                {
                    machineentity.IPAddress = GetLocalIPv4(NetworkInterfaceType.Ethernet);
                }
                returnList.Add(machineentity);
            }
            return(returnList);
        }
コード例 #7
0
        public async Task DeleteMachine()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new MachineEntity
            {
                MachineId           = 11,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommandEntity>(),
                MachineInitCommands = new MachineInitCommandEntity[0]
            };

            rep.Get(1).Returns(machineEntity1);

            var machine = await ctrl.Get(1);

            machine.Name = "SuperMaxi";

            await ctrl.Delete(machine);

            rep.Received().DeleteRange(Arg.Is <IEnumerable <MachineEntity> >(x => x.First().Name == "SuperMaxi"));
            rep.Received().DeleteRange(Arg.Is <IEnumerable <MachineEntity> >(x => x.First().MachineId == 11));
        }
コード例 #8
0
ファイル: NetVis.cs プロジェクト: radtek/Netvision
        private void PopulateMachineDetail(MachineEntity item)
        {
            if (Dns.GetHostName() == item.MachineName)
            {
                WindowsMachineProvider.GetInstance().GetMachineAdditionalInformation(item.MachineName, SelectedDomain, item);
                item.MachineStatus = MachineStatus.Online;
            }

            ListViewItem lvi = new ListViewItem(Enum.GetName(typeof(MachineStatus), item.MachineStatus));

            lvi.SubItems.Add(item.MachineName);
            lvi.SubItems.Add(item.IPAddress);
            lvi.SubItems.Add(item.MachineMACAddress);
            lvi.SubItems.Add(item.OpratingSystem);
            lvi.SubItems.Add(item.OpratingSystemVersion);
            lvi.SubItems.Add(item.OpratingSystemServicePack);
            if (item.MachineStatus == MachineStatus.Online)
            {
                lvi.ImageIndex = 1;
                Online++;
            }
            else
            {
                lvi.ImageIndex = 0;
            }

            lvi.ToolTipText = "Double click to see detail of selected machine";
            lstView.Items.Add(lvi);
            pgInfo.Value++;
            lstView.ShowItemToolTips = true;
        }
コード例 #9
0
ファイル: NetVis.cs プロジェクト: radtek/NetTool
        private void FillMachines(MachineEntity item)
        {
            if (Dns.GetHostName() == item.MachineName)
            {
                MachineProvider.GetInstance().GetMachineAdditionalInformation(item.MachineName, SelectedDomain, item);
                item.MachineStatus = MachineStatus.Online;
            }

            ListViewItem lvi = new ListViewItem(Enum.GetName(typeof(MachineStatus), item.MachineStatus));

            lvi.SubItems.Add(item.MachineName);
            lvi.SubItems.Add(item.IPAddress);
            lvi.SubItems.Add(item.MachineMACAddress);
            lvi.SubItems.Add(item.OpratingSystem);
            lvi.SubItems.Add(item.OpratingSystemVersion);
            lvi.SubItems.Add(item.OpratingSystemServicePack);
            if (item.MachineStatus == MachineStatus.Online)
            {
                lvi.ImageIndex = 1;
                Online++;
            }
            else
            {
                lvi.ImageIndex = 0;
            }

            lstView.Items.Add(lvi);
            pgInfo.Value++;
        }
コード例 #10
0
        public static void TryInsertOutput(this MachineEntity entity, int outputSlotsStart, int outputSlotsEnd, int inputType, int inputStack)
        {
            //Find the first slot that the items can stack to.  If that stack isn't enough, overflow to the next slot
            for (int i = outputSlotsStart; i < outputSlotsEnd + 1; i++)
            {
                Item item = entity.RetrieveItem(i);
                if (item.IsAir)
                {
                    item.SetDefaults(inputType);
                    item.type  = inputType;
                    item.stack = inputStack;
                    break;
                }

                if (item.type == inputType && item.stack < item.maxStack)
                {
                    if (item.stack + inputStack <= item.maxStack)
                    {
                        item.stack += inputStack;
                        break;
                    }
                    else
                    {
                        inputStack -= item.maxStack - item.stack;
                        item.stack  = item.maxStack;
                    }
                }
            }
        }
コード例 #11
0
        protected override string Execute(CheckinArgs args)
        {
            var           setup   = CommandManager.CurrentSetup;
            MachineEntity machine = null;

            if (!string.IsNullOrEmpty(args.IpAddress))
            {
                machine = setup.GetMachinebyIpaddress(args.IpAddress);
            }
            else if (!string.IsNullOrEmpty(args.MachineName))
            {
                machine = setup.GetMachine(args.MachineName);
            }
            else
            {
                return("Can't find this machine, please check your input...");
            }

            if (machine != null)
            {
                machine.IsCheckout   = true;
                machine.CheckoutDate = System.DateTime.Now.ToShortTimeString();
                machine.UserName     = CommandManager.ParticipantURI;
            }

            return("Check out successfully");
        }
コード例 #12
0
        public AdjacentsSurveyor(Box box, MachineEntity anchor)
        {
            var grid = new GridBox(box);

            this.Sides     = grid.Sides().Index().Loop().GetEnumerator();
            this.Surveyor  = new BlockSurveyor(anchor);
            this.Adjacents = Enumerable.Repeat <SegmentEntity>(null, grid.SidesCount()).ToList();
        }
コード例 #13
0
        public static bool IsConveyorFacingMe(this MachineEntity center, ConveyorEntity conv)
        {
            long x = conv.mnX + (long)conv.mForwards.x;
            long y = conv.mnY + (long)conv.mForwards.y;
            long z = conv.mnZ + (long)conv.mForwards.z;

            return((x == center.mnX) &&
                   (y == center.mnY) &&
                   (z == center.mnZ));
        }
コード例 #14
0
ファイル: HomeController.cs プロジェクト: ilyas0019/NetTool
        public ActionResult Details(MachineEntity obj)
        {
            ViewBag.MachineName = obj.MachineName;
            var listOfSoftwares = MachineProvider.GetInstance().GetListOfInstalledSoftwares(obj.MachineName);

            obj = MachineProvider.GetInstance().GetMachineAdditionalInformation(obj.MachineName, obj.DomainName, obj);

            return(View(new ViewModel {
                MachineInfo = obj, SoftwareList = listOfSoftwares
            }));
        }
コード例 #15
0
        public ActionResult SaveMachine(MachineEntity machineEntity)
        {
            var user = (User)Session["CurrentUser"];

            machineEntity.UserName = user.EMPID;
            machineEntity.EDate    = DateTime.Now;

            var res = _repository.SaveMachine(machineEntity);

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #16
0
        // PUT api/values/5
        public async Task <MachineEntity> Put(string id1, string id2, [FromBody] MachineEntity value)
        {
            if (value == null)
            {
                return(new MachineEntity
                {
                    MachineName = "Error: while deserializing the body"
                });
            }

            InitializeTable();

            MachineEntity machineEntity = (from machine in this.Table.CreateQuery <MachineEntity>()
                                           where machine.PartitionKey == id1
                                           where machine.RowKey == id2
                                           select machine).FirstOrDefault();

            if (machineEntity == null)
            {
                machineEntity = new MachineEntity
                {
                    Username     = id1,
                    MachineName  = id2,
                    HostName     = value.HostName,
                    Guid         = Guid.NewGuid().ToString(),
                    PartitionKey = id1,
                    RowKey       = id2,
                    State        = MachineState.Unknown.ToString(),
                    ShouldWakeup = false,
                    Timestamp    = DateTime.UtcNow,
                };
            }
            else
            {
                if (value.State != null)
                {
                    machineEntity.State = value.State;
                }
                if (!string.IsNullOrWhiteSpace(value.MacAddress))
                {
                    machineEntity.MacAddress = value.MacAddress;
                }
                if (value.ShouldWakeup != null)
                {
                    machineEntity.ShouldWakeup = value.ShouldWakeup;
                }
            }

            await AzureTableHelper.InsertOrMergeEntityAsync(this.Table, machineEntity);

            return(machineEntity);
        }
コード例 #17
0
        public static void KillMachine(int i, int j, int type)
        {
            Tile    tile  = Main.tile[i, j];
            Machine mTile = ModContent.GetModTile(type) as Machine;

            mTile.GetDefaultParams(out _, out _, out _, out int itemType);

            int         itemIndex = Item.NewItem(i * 16, j * 16, 16, 16, itemType);
            MachineItem item      = Main.item[itemIndex].modItem as MachineItem;

            Point16 tePos = new Point16(i, j) - tile.TileCoord();

            if (TileEntity.ByPosition.ContainsKey(tePos))
            {
                MachineEntity tileEntity = TileEntity.ByPosition[tePos] as MachineEntity;
                //Drop any items the entity contains
                if (tileEntity.SlotsCount > 0)
                {
                    for (int slot = 0; slot < tileEntity.SlotsCount; slot++)
                    {
                        Item drop = tileEntity.RetrieveItem(slot);

                        //Drop the item and copy over any important data
                        if (drop.type > ItemID.None && drop.stack > 0)
                        {
                            int dropIndex = Item.NewItem(i * 16, j * 16, 16, 16, drop.type, drop.stack);
                            if (drop.modItem != null)
                            {
                                Main.item[dropIndex].modItem.Load(drop.modItem.Save());
                            }
                        }

                        tileEntity.ClearItem(slot);
                    }
                }

                item.entityData = tileEntity.Save();

                //Remove this machine from the wire networks if it's a powered machine
                if (tileEntity is PoweredMachineEntity pme)
                {
                    NetworkCollection.RemoveMachine(pme);
                }

                tileEntity.Kill(i, j);

                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    NetMessage.SendData(MessageID.TileEntitySharing, remoteClient: -1, ignoreClient: Main.myPlayer, number: tileEntity.ID);
                }
            }
        }
コード例 #18
0
 private static MachineEntity AddMachineCommands(MachineEntity machine)
 {
     machine.MachineCommands = new List <MachineCommandEntity>
     {
         new MachineCommandEntity {
             CommandName = "Name1", CommandString = "Test1", Machine = machine
         },
         new MachineCommandEntity {
             CommandName = "Name1", CommandString = "Test2", Machine = machine
         }
     };
     return(machine);
 }
コード例 #19
0
 private static MachineEntity AddMachineInitCommands(MachineEntity machine)
 {
     machine.MachineInitCommands = new List <MachineInitCommandEntity>
     {
         new MachineInitCommandEntity {
             SeqNo = 0, CommandString = "Test1", Machine = machine
         },
         new MachineInitCommandEntity {
             SeqNo = 1, CommandString = "Test2", Machine = machine
         }
     };
     return(machine);
 }
コード例 #20
0
        public string SaveMachine(MachineEntity machineEntity)
        {
            string rv = "";

            try
            {
                Insert_Update_Machine("sp_insert_machine", "save_machine_data", machineEntity);
                rv = Operation.Success.ToString();
            }
            catch (Exception ex)
            {
                rv = ex.Message;
            }
            return(rv);
        }
コード例 #21
0
        public async Task GetMachinesNone()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity = new MachineEntity[0];

            rep.GetAll().Returns(machineEntity);

            var machines = (await ctrl.GetAll()).ToArray();

            machines.Length.Should().Be(0);
        }
コード例 #22
0
    // Use this for initialization
    void Start()
    {
        MachineQrCommunication machineQrCommunication = new MachineQrCommunication();
        string ServerResponse = machineQrCommunication.ReceiveDataFromServer();

        //Receive the CAD file and save to Resources or local of the client machine
        MachineEntity machine = JsonUtility.FromJson <MachineEntity>(ServerResponse);

        instructionsEntity.operationId = machine.operationToDo;
        instructionsEntity.operationInstructionListId = machine.operationInstructionListId;
        instructionsEntity.operationInstructionList   = machine.operationInstructionList;

        //Iterprete CAD Filename
        string CadFilenameAbsolute = machine.machineCADFile;

        string[] file        = CadFilenameAbsolute.Split('/');
        int      counter     = file.Length;
        string   CadFilename = file[counter - 1]; //Exact Filename => example.obj

        //string CadFilename = "gokart_main_assy.obj";
        //This filepath can be changed according to device
        string FilePath = "C:/ARClient/ARTeamcenterClient/Assets/Resources/" + CadFilename;

        byte[] FileBuffer = machineQrCommunication.ReceiveCADFileFromServer();

        // create a file in local and write to file
        BinaryWriter bWrite = new System.IO.BinaryWriter(File.Open(FilePath, FileMode.Create));

        bWrite.Write(FileBuffer);
        bWrite.Flush();
        bWrite.Close();

        //Load CAD model to the scene
        CADImage = OBJLoader.LoadOBJFile(FilePath); //I hope this will work


        //Display first step of the operation on the screen
        InstructionList = machine.operationInstructionList;
        size            = InstructionList.Count;
        NextInformationButton.GetComponentInChildren <Text>().text = "Start";
        InformationText.text = "You will see the instructions here!" +
                               "If you feel you need more information, click the button below!";

        //Highlight the part which will be changed
    }
コード例 #23
0
        public static void StopReactionIfOutputSlotsAreFull(this MachineEntity entity, int outputSlotsStart, int outputSlotsEnd)
        {
            //Check that all slots aren't full.  If they are, abort early
            bool allFull = true;

            for (int i = outputSlotsStart; i < outputSlotsEnd + 1; i++)
            {
                if (entity.RetrieveItem(i).IsAir)
                {
                    allFull = false;
                }
            }

            if (allFull)
            {
                entity.ReactionInProgress = false;
            }
        }
コード例 #24
0
        public static bool TryFindMachineEntity(Point16 pos, out MachineEntity entity)
        {
            entity = null;

            Tile    tile  = Framing.GetTileSafely(pos);
            ModTile mTile = ModContent.GetModTile(tile.type);

            if (mTile is Machine)
            {
                Point16 origin = pos - tile.TileCoord();

                if (TileEntity.ByPosition.TryGetValue(origin, out TileEntity te) && (entity = te as MachineEntity) != null)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #25
0
        public static bool GiveToSurrounding(this MachineEntity center, ItemBase item)
        {
            bool ignore;
            List <SegmentEntity> list = center.CheckSurrounding <SegmentEntity>(out ignore);

            for (int i = 0; i < list.Count; ++i)
            {
                // Special case - Conveyor belts should only be given items if they're facing away from the machine
                if (list[i] is ConveyorEntity && center.IsConveyorFacingMe(list[i] as ConveyorEntity))
                {
                    continue;
                }
                if (ItemInterop.GiveItem(list[i], item))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #26
0
        private void ProcessMachine(DirectoryEntry machine, List <MachineEntity> computerNames)
        {
            MachineEntity machineEntity = new MachineEntity();

            string[] Ipaddr = new string[3];
            System.Net.IPHostEntry Tempaddr = null;
            byte[] ab;
            int    len;
            int    r;
            string mac = string.Empty;

            Ipaddr[0] = machine.Name;

            try
            {
                Tempaddr = (System.Net.IPHostEntry)Dns.GetHostEntry(machine.Name);
            }
            catch (Exception)
            {
                return;
            }

            foreach (IPAddress TempA in Tempaddr.AddressList)
            {
                Ipaddr[1] = TempA.ToString();
                ab        = new byte[6];
                len       = ab.Length;
                r         = SendARP(TempA.GetHashCode(), 0, ab, ref len);
                mac       = BitConverter.ToString(ab, 0, 6);
                if (mac == "00-00-00-00-00-00")
                {
                    return;
                }
                Ipaddr[2] = mac;
            }

            machineEntity.MachineStatus     = MachineStatus.Online;
            machineEntity.IPAddress         = Ipaddr[1];
            machineEntity.MachineName       = machine.Name;
            machineEntity.MachineMACAddress = Ipaddr[2];

            computerNames.Add(machineEntity);
        }
コード例 #27
0
ファイル: NetVis.cs プロジェクト: radtek/NetTool
        public void PopulateListView(List <MachineEntity> listOfMachines)
        {
            lblSoftware.Text = "";
            lblInfo.Text     = "";
            lblScanning.Text = string.Format("Scanning stared at {0}", DateTime.Now);

            lstView.Items.Clear();
            lstView.FullRowSelect = true;
            lstSoftware.Items.Clear();

            MachineEntity objMachine = new MachineEntity();

            ResetPager(listOfMachines.Count);
            Online = 0;
            foreach (var item in listOfMachines)
            {
                FillMachines(item);
            }

            lblInfo.Text = string.Format("Total no of machines is '{0}' currently online '{1}'", listOfMachines.Count, Online);
        }
コード例 #28
0
        public static ItemBase TakeFromSurrounding(this MachineEntity center, ItemBase item)
        {
            bool ignore;
            List <SegmentEntity> list = center.CheckSurrounding <SegmentEntity>(out ignore);

            ItemBase ret = null;

            for (int i = 0; i < list.Count; ++i)
            {
                if (list[i] is ConveyorEntity && !center.IsConveyorFacingMe(list[i] as ConveyorEntity))
                {
                    continue;
                }
                ret = ItemInterop.TakeItem(list[i], item);
                if (ret != null)
                {
                    break;
                }
            }
            return(ret);
        }
コード例 #29
0
        public static ItemBase TakeFromSurrounding(this MachineEntity center)
        {
            bool ignore;
            List <SegmentEntity> list = center.CheckSurrounding <SegmentEntity>(out ignore);

            ItemBase ret = null;

            for (int i = 0; i < list.Count; ++i)
            {
                // Special case - Conveyor belts should will only provide items if they're facing the machine
                if (list[i] is ConveyorEntity && !center.IsConveyorFacingMe(list[i] as ConveyorEntity))
                {
                    continue;
                }
                ret = ItemInterop.TakeAnyItem(list[i]);
                if (ret != null)
                {
                    break;
                }
            }
            return(ret);
        }
コード例 #30
0
        public MachineEntity GetStorageInfoOfMachine(string machine, string domain, MachineEntity objMachine)
        {
            ManagementScope scope = new ManagementScope();

            try
            {
                ConnectionOptions options = new ConnectionOptions();
                scope = new ManagementScope(@"\\" + machine + "\\root\\CIMV2", options);
                scope.Connect();

                SelectQuery query = new SelectQuery("SELECT * FROM Win32_LogicalDisk");

                ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
                var storageDevices = new StorageDevices();
                objMachine.ListOfStoragekDevices = new List <StorageDevices>();
                using (ManagementObjectCollection queryCollection = searcher.Get())
                {
                    foreach (ManagementObject m in queryCollection)
                    {
                        storageDevices = new StorageDevices();

                        storageDevices.Name         = m["Name"] == null ? "Unavailble" : m["Name"].ToString();
                        storageDevices.Caption      = m["Caption"] == null ? "Unavailble" : m["Caption"].ToString();
                        storageDevices.FreeSpace    = FreeSpaceInGB(m["FreeSpace"] == null ? "0" : m["FreeSpace"].ToString());
                        storageDevices.SerialNumber = m["VolumeSerialNumber"] == null ? "Unavailble" : m["VolumeSerialNumber"].ToString();

                        objMachine.ListOfStoragekDevices.Add(storageDevices);
                    }
                }
            }

            catch (Exception)
            {
                return(objMachine);
            }

            return(objMachine);
        }