示例#1
0
        public Task <List <Drive_Info> > GetDriveInfo()
        {
            var driveinfos = DriveInfo.GetDrives();
            var drivelist  = new List <Drive_Info>();

            foreach (var item in driveinfos)
            {
                Drive_Info tmp = new Drive_Info();

                try
                {
                    tmp.AvailableFreeSpace = item.AvailableFreeSpace;
                }
                catch { }
                try { tmp.DriveFormat = item.DriveFormat; } catch { }
                try { tmp.DriveType = item.DriveType; } catch { }
                try { tmp.IsReady = item.IsReady; } catch { }
                try { tmp.Name = item.Name; } catch { }
                try { tmp.TotalFreeSpace = item.TotalFreeSpace; } catch { }
                try { tmp.TotalSize = item.TotalSize; } catch { }
                try { tmp.VolumeLabel = item.VolumeLabel; } catch { }
                tmp.RootDirectory = item.RootDirectory == null ? null : new FileSysInfo();

                if (tmp.RootDirectory != null)
                {
                    try { tmp.RootDirectory.CreateTime = item.RootDirectory.CreationTime; } catch { }
                    tmp.RootDirectory.fileType = FileType.Dir;
                    tmp.RootDirectory.FullName = item.RootDirectory.FullName;
                    try { tmp.RootDirectory.LastAccessTime = item.RootDirectory.LastAccessTime; } catch { }
                    try { tmp.RootDirectory.LastWriteTime = item.RootDirectory.LastWriteTime; } catch { }

                    tmp.RootDirectory.Name = item.RootDirectory.Name;
                }

                drivelist.Add(tmp);
            }


            return(Task.FromResult(drivelist));
        }
        /// <summary>
        /// Main worker function. This function iterates each deliverable in turn and executes the main processing entry points.
        /// </summary>
        private void ProcessQueuedItems()
        {
            if (WF_WorkQueue.queue.Count >= 1)
            {
                Drive_Info drive_Info = new Drive_Info();
                for (int q = 0; q < WF_WorkQueue.queue.Count; q++)
                {
                    ConfigHandler <ITV2ADI_CONFIG> .B_IsRunning = drive_Info.GetDriveSpace();
                    if (ConfigHandler <ITV2ADI_CONFIG> .B_IsRunning)
                    {
                        WorkQueueItem itvFile = (WorkQueueItem)WF_WorkQueue.queue[q];

                        try
                        {
                            log.Info($"############### Processing STARTED For Queued item {q + 1} of {WF_WorkQueue.queue.Count}: {itvFile.file.Name} ###############\r\n\r\n");
                            IsProcessing = true;
                            Mapping      = new MapITVtoADI
                            {
                                ITV_FILE = itvFile.file.FullName
                            };

                            if (Mapping.StartItvMapping())
                            {
                                B_IsSuccess = true;
                                if (Convert.ToBoolean(ITV2ADI_CONFIG.DeleteITVFileUponSuccess))
                                {
                                    log.Info($"Delete source itv file upon success is true, removing source file: {itvFile.file.FullName}");
                                    File.Delete(itvFile.file.FullName);

                                    if (!File.Exists(itvFile.file.FullName))
                                    {
                                        log.Info($"ITV File: {itvFile.file.FullName} successfully deleted");
                                    }
                                    else
                                    {
                                        log.Error($"Failed to delete source ITV File: {itvFile.file.FullName}?");
                                    }
                                }
                                log.Info($"############### Processing SUCCESSFUL For Queued file: {Mapping.ITV_FILE} ###############\r\n\r\n");
                            }
                            else
                            {
                                throw new Exception($"Failed during itv Mapping process, check the logs for more information.");
                            }
                        }
                        catch (Exception PQI_EX)
                        {
                            log.Error($"Caught Exception during Process of Queued Items: {PQI_EX.Message}");
                            Mapping.CleanUp();
                            log.Info($"############### Processing FAILED For Queued file: {itvFile.file.Name} ###############\r\n\r\n");
                            B_IsSuccess = false;
                            continue;
                        }
                        finally
                        {
                            if (Mapping.ItvFailure)
                            {
                                log.Info($"A Product/Products were flagged as failed during processing, Removing Source ITV File: {itvFile.file.FullName}");
                                File.Delete(itvFile.file.FullName);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            IsProcessing = false;
        }