예제 #1
1
        /// <summary>
        /// Initializes a new instance of the BZip2DecoderStream class.
        /// </summary>
        /// <param name="stream">The compressed input stream.</param>
        /// <param name="ownsStream">Whether ownership of stream passes to the new instance.</param>
        public BZip2DecoderStream(Stream stream, Ownership ownsStream)
        {
            _compressedStream = stream;
            _ownsCompressed = ownsStream;

            _bitstream = new BigEndianBitStream(new BufferedStream(stream));

            // The Magic BZh
            byte[] magic = new byte[3];
            magic[0] = (byte)_bitstream.Read(8);
            magic[1] = (byte)_bitstream.Read(8);
            magic[2] = (byte)_bitstream.Read(8);
            if (magic[0] != 0x42 || magic[1] != 0x5A || magic[2] != 0x68)
            {
                throw new InvalidDataException("Bad magic at start of stream");
            }

            // The size of the decompression blocks in multiples of 100,000
            int blockSize = (int)_bitstream.Read(8) - 0x30;
            if (blockSize < 1 || blockSize > 9)
            {
                throw new InvalidDataException("Unexpected block size in header: " + blockSize);
            }

            blockSize *= 100000;

            _rleStream = new BZip2RleStream();
            _blockDecoder = new BZip2BlockDecoder(blockSize);
            _blockBuffer = new byte[blockSize];

            if (ReadBlock() == 0)
            {
                _eof = true;
            }
        }
        public HostedSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream)
        {
            _fileStream = file;
            _ownsFileStream = ownsFile;
            _diskOffset = diskOffset;
            _parentDiskStream = parentDiskStream;
            _ownsParentDiskStream = ownsParentDiskStream;

            file.Position = 0;
            byte[] headerSector = Utilities.ReadFully(file, Sizes.Sector);
            _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);
            if (_hostedHeader.GdOffset == -1)
            {
                // Fall back to secondary copy that (should) be at the end of the stream, just before the end-of-stream sector marker
                file.Position = file.Length - Sizes.OneKiB;
                headerSector = Utilities.ReadFully(file, Sizes.Sector);
                _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);

                if (_hostedHeader.MagicNumber != HostedSparseExtentHeader.VmdkMagicNumber)
                {
                    throw new IOException("Unable to locate valid VMDK header or footer");
                }
            }

            _header = _hostedHeader;

            if (_hostedHeader.CompressAlgorithm != 0 && _hostedHeader.CompressAlgorithm != 1)
            {
                throw new NotSupportedException("Only uncompressed and DEFLATE compressed disks supported");
            }

            _gtCoverage = _header.NumGTEsPerGT * _header.GrainSize * Sizes.Sector;

            LoadGlobalDirectory();
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the BlockCacheStream class.
        /// </summary>
        /// <param name="toWrap">The stream to wrap.</param>
        /// <param name="ownership">Whether to assume ownership of <c>toWrap</c>.</param>
        /// <param name="settings">The cache settings.</param>
        public BlockCacheStream(SparseStream toWrap, Ownership ownership, BlockCacheSettings settings)
        {
            if (!toWrap.CanRead)
            {
                throw new ArgumentException("The wrapped stream does not support reading", "toWrap");
            }

            if (!toWrap.CanSeek)
            {
                throw new ArgumentException("The wrapped stream does not support seeking", "toWrap");
            }

            _wrappedStream = toWrap;
            _ownWrapped = ownership;
            _settings = new BlockCacheSettings(settings);

            if (_settings.OptimumReadSize % _settings.BlockSize != 0)
            {
                throw new ArgumentException("Invalid settings, OptimumReadSize must be a multiple of BlockSize", "settings");
            }

            _readBuffer = new byte[_settings.OptimumReadSize];
            _blocksInReadBuffer = _settings.OptimumReadSize / _settings.BlockSize;

            int totalBlocks = (int)(_settings.ReadCacheSize / _settings.BlockSize);

            _cache = new BlockCache<Block>(_settings.BlockSize, totalBlocks);
            _stats = new BlockCacheStatistics();
            _stats.FreeReadBlocks = totalBlocks;
        }
예제 #4
0
 /// <summary>
 /// Creates a new instance from a stream.
 /// </summary>
 /// <param name="fileStream">The stream containing the .XVA file</param>
 /// <param name="ownership">Whether to transfer ownership of <c>fileStream</c> to the new instance.</param>
 public VirtualMachine(Stream fileStream, Ownership ownership)
 {
     _fileStream = fileStream;
     _ownership = ownership;
     _fileStream.Position = 0;
     _archive = new TarFile(fileStream);
 }
예제 #5
0
        public StripedStream(long stripeSize, Ownership ownsWrapped, params SparseStream[] wrapped)
        {
            _wrapped = new List<SparseStream>(wrapped);
            _stripeSize = stripeSize;
            _ownsWrapped = ownsWrapped;

            _canRead = _wrapped[0].CanRead;
            _canWrite = _wrapped[0].CanWrite;
            long subStreamLength = _wrapped[0].Length;

            foreach (var stream in _wrapped)
            {
                if (stream.CanRead != _canRead || stream.CanWrite != _canWrite)
                {
                    throw new ArgumentException("All striped streams must have the same read/write permissions", "wrapped");
                }

                if (stream.Length != subStreamLength)
                {
                    throw new ArgumentException("All striped streams must have the same length", "wrapped");
                }
            }

            _length = subStreamLength * wrapped.Length;
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the SdiFile class.
        /// </summary>
        /// <param name="stream">The stream formatted as an SDI file.</param>
        /// <param name="ownership">Whether to pass ownership of <c>stream</c> to the new instance.</param>
        public SdiFile(Stream stream, Ownership ownership)
        {
            _stream = stream;
            _ownership = ownership;

            byte[] page = Utilities.ReadFully(_stream, 512);

            _header = new FileHeader();
            _header.ReadFrom(page, 0);

            _stream.Position = _header.PageAlignment * 512;
            byte[] toc = Utilities.ReadFully(_stream, (int)(_header.PageAlignment * 512));

            _sections = new List<SectionRecord>();
            int pos = 0;
            while (Utilities.ToUInt64LittleEndian(toc, pos) != 0)
            {
                SectionRecord record = new SectionRecord();
                record.ReadFrom(toc, pos);

                _sections.Add(record);

                pos += SectionRecord.RecordSize;
            }
        }
        /// <summary>
        /// Initializes a new instance of the DiskImageFile class.
        /// </summary>
        /// <param name="stream">The stream to interpret</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        public DiskImageFile(Stream stream, Ownership ownsStream)
        {
            _stream = stream;
            _ownsStream = ownsStream;

            ReadHeader();
        }
예제 #8
0
 public ContentStream(SparseStream fileStream, BlockAllocationTable bat, long length, SparseStream parentStream, Ownership ownsParent)
 {
     _fileStream = fileStream;
     _bat = bat;
     _length = length;
     _parentStream = parentStream;
     _ownsParent = ownsParent;
 }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WrappingStream"/> class.
        /// </summary>
        /// <param name="streamBase">The wrapped stream.</param>
        /// <param name="ownership">Use Owns if the wrapped stream should be disposed when this stream is disposed.</param>
        public WrappingStream(Stream streamBase, Ownership ownership)
        {
            // check parameters
            if (streamBase == null)
                throw new ArgumentNullException("streamBase");

            m_streamBase = streamBase;
            m_ownership = ownership;
        }
예제 #10
0
        public override SparseStream OpenContent(SparseStream parent, Ownership ownsParent)
        {
            if (ownsParent == Ownership.Dispose && parent != null)
            {
                parent.Dispose();
            }

            return SparseStream.FromStream(Content, Ownership.None);
        }
예제 #11
0
        public DiskStream(Stream fileStream, Ownership ownsStream, HeaderRecord fileHeader)
        {
            _fileStream = fileStream;
            _fileHeader = fileHeader;

            _ownsStream = ownsStream;

            ReadBlockTable();
        }
예제 #12
0
        /// <summary>
        /// Initializes a new instance of the DiskImageFile class.
        /// </summary>
        /// <param name="stream">The stream to interpret</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        public DiskImageFile(Stream stream, Ownership ownsStream)
        {
            _fileStream = stream;
            _ownsStream = ownsStream;

            ReadFooter(true);

            ReadHeaders();
        }
예제 #13
0
파일: Disk.cs 프로젝트: JGTM2016/discutils
        /// <summary>
        /// Initializes a new instance of the Disk class.  Differencing disks are not supported.
        /// </summary>
        /// <param name="stream">The stream to read</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        public Disk(Stream stream, Ownership ownsStream)
        {
            _files = new List<DiscUtils.Tuple<DiskImageFile, Ownership>>();
            _files.Add(new DiscUtils.Tuple<DiskImageFile, Ownership>(new DiskImageFile(stream, ownsStream), Ownership.Dispose));

            if (_files[0].First.NeedsParent)
            {
                throw new NotSupportedException("Differencing disks cannot be opened from a stream");
            }
        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the Disk class.  Only monolithic sparse streams are supported.
        /// </summary>
        /// <param name="stream">The stream containing the VMDK file</param>
        /// <param name="ownsStream">Indicates if the new instances owns the stream.</param>
        public Disk(Stream stream, Ownership ownsStream)
        {
            FileStream fileStream = stream as FileStream;
            if (fileStream != null)
            {
                _path = fileStream.Name;
            }

            _files = new List<ThinkAway.Tuple<VirtualDiskLayer, Ownership>>();
            _files.Add(new ThinkAway.Tuple<VirtualDiskLayer, Ownership>(new DiskImageFile(stream, ownsStream), Ownership.Dispose));
        }
예제 #15
0
        /// <summary>
        /// Creates a new instance, wrapping an existing stream.
        /// </summary>
        /// <param name="toWrap">The stream to wrap</param>
        /// <param name="ownership">Whether to transfer ownership of <c>toWrap</c> to the new instance</param>
        /// <remarks>Do not directly modify <c>toWrap</c> after wrapping it, unless the thread-safe views
        /// will no longer be used.</remarks>
        public ThreadSafeStream(SparseStream toWrap, Ownership ownership)
        {
            if (!toWrap.CanSeek)
            {
                throw new ArgumentException("Wrapped stream must support seeking", "toWrap");
            }

            _common = new CommonState {
                WrappedStream = toWrap,
                WrappedStreamOwnership = ownership };
            _ownsCommon = true;
        }
예제 #16
0
        public SubStream(Stream parent, Ownership ownsParent, long first, long length)
        {
            _parent = parent;
            _ownsParent = ownsParent;
            _first = first;
            _length = length;

            if (_first + _length > _parent.Length)
            {
                throw new ArgumentException("Substream extends beyond end of parent stream");
            }
        }
예제 #17
0
        public ContentStream(SparseStream fileStream, Stream batStream, FreeSpaceTable freeSpaceTable, Metadata metadata, long length, SparseStream parentStream, Ownership ownsParent)
        {
            _fileStream = fileStream;
            _batStream = batStream;
            _freeSpaceTable = freeSpaceTable;
            _metadata = metadata;
            _fileParameters = _metadata.FileParameters;
            _length = length;
            _parentStream = parentStream;
            _ownsParent = ownsParent;

            _chunks = new ObjectCache<int, Chunk>();
        }
예제 #18
0
        /// <summary>
        /// Initializes a new instance of the DiskImageFile class.
        /// </summary>
        /// <param name="stream">The stream to interpret</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        /// <param name="geometry">The emulated geometry of the disk.</param>
        public DiskImageFile(Stream stream, Ownership ownsStream, Geometry geometry)
        {
            _content = stream as SparseStream;
            _ownsContent = ownsStream;

            if (_content == null)
            {
                _content = SparseStream.FromStream(stream, ownsStream);
                _ownsContent = Ownership.Dispose;
            }

            _geometry = geometry ?? DetectGeometry(_content);
        }
예제 #19
0
        public ConcatStream(Ownership ownsStreams, params SparseStream[] streams)
        {
            _ownsStreams = ownsStreams;
            _streams = streams;

            // Only allow writes if all streams can be written
            _canWrite = true;
            foreach (var stream in streams)
            {
                if (!stream.CanWrite)
                {
                    _canWrite = false;
                }
            }
        }
예제 #20
0
        public ServerSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream)
        {
            _fileStream = file;
            _ownsFileStream = ownsFile;
            _diskOffset = diskOffset;
            _parentDiskStream = parentDiskStream;
            _ownsParentDiskStream = ownsParentDiskStream;

            file.Position = 0;
            byte[] firstSectors = Utilities.ReadFully(file, Sizes.Sector * 4);
            _serverHeader = ServerSparseExtentHeader.Read(firstSectors, 0);
            _header = _serverHeader;

            _gtCoverage = _header.NumGTEsPerGT * (long)_header.GrainSize * Sizes.Sector;

            LoadGlobalDirectory();
        }
예제 #21
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="stream">The stream to wrap</param>
        /// <param name="ownership">Whether to dispose stream, when this object is disposed</param>
        public StreamBuffer(Stream stream, Ownership ownership)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            _stream = stream as SparseStream;
            if (_stream == null)
            {
                _stream = SparseStream.FromStream(stream, ownership);
                _ownership = Ownership.Dispose;
            }
            else
            {
                _ownership = ownership;
            }
        }
예제 #22
0
        /// <summary>
        /// Initializes a new instance of the DiskImageFile class.
        /// </summary>
        /// <param name="stream">The stream to read</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        public DiskImageFile(Stream stream, Ownership ownsStream)
        {
            _udifHeader = new UdifResourceFile();
            _stream = stream;
            _ownsStream = ownsStream;

            stream.Position = stream.Length - _udifHeader.Size;
            byte[] data = Utilities.ReadFully(stream, _udifHeader.Size);

            _udifHeader.ReadFrom(data, 0);

            if (_udifHeader.SignatureValid)
            {
                stream.Position = (long)_udifHeader.XmlOffset;
                byte[] xmlData = Utilities.ReadFully(stream, (int)_udifHeader.XmlLength);
                var plist = Plist.Parse(new MemoryStream(xmlData));

                _resources = ResourceFork.FromPlist(plist);
                _buffer = new UdifBuffer(stream, _resources, _udifHeader.SectorCount);
            }
        }
예제 #23
0
        public DynamicStream(Stream fileStream, DynamicHeader dynamicHeader, long length, SparseStream parentStream, Ownership ownsParentStream)
        {
            if (fileStream == null)
            {
                throw new ArgumentNullException("fileStream");
            }

            if (dynamicHeader == null)
            {
                throw new ArgumentNullException("dynamicHeader");
            }

            if (parentStream == null)
            {
                throw new ArgumentNullException("parentStream");
            }

            if (length < 0)
            {
                throw new ArgumentOutOfRangeException("length", length, "Negative lengths not allowed");
            }

            _fileStream = fileStream;
            _dynamicHeader = dynamicHeader;
            _length = length;
            _parentStream = parentStream;
            _ownsParentStream = ownsParentStream;

            _blockBitmaps = new byte[_dynamicHeader.MaxTableEntries][];
            _blockBitmapSize = (int)Utilities.RoundUp(Utilities.Ceil(_dynamicHeader.BlockSize, Utilities.SectorSize * 8), Utilities.SectorSize);

            ReadBlockAllocationTable();

            // Detect where next block should go (cope if the footer is missing)
            _fileStream.Position = Utilities.RoundDown(_fileStream.Length, Utilities.SectorSize) - Utilities.SectorSize;
            byte[] footerBytes = Utilities.ReadFully(_fileStream, Utilities.SectorSize);
            Footer footer = Footer.FromBytes(footerBytes, 0);
            _nextBlockStart = _fileStream.Position - (footer.IsValid() ? Utilities.SectorSize : 0);
        }
예제 #24
0
        /// <summary>
        /// Initializes a new instance of the DiscImageFile class.
        /// </summary>
        /// <param name="stream">The stream to interpret</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        /// <param name="format">The disc image format</param>
        public DiscImageFile(Stream stream, Ownership ownsStream, OpticalFormat format)
        {
            if (ownsStream == Ownership.Dispose)
            {
                _toDispose = stream;
            }

            if (format == OpticalFormat.None)
            {
                if ((stream.Length % Mode1SectorSize) == 0 && (stream.Length % Mode2SectorSize) != 0)
                {
                    _format = OpticalFormat.Mode1;
                }
                else if ((stream.Length % Mode1SectorSize) != 0 && (stream.Length % Mode2SectorSize) == 0)
                {
                    _format = OpticalFormat.Mode2;
                }
                else
                {
                    throw new IOException("Unable to detect optical disk format");
                }
            }
            else
            {
                _format = format;
            }

            _content = stream as SparseStream;
            if (_content == null)
            {
                _content = SparseStream.FromStream(stream, Ownership.None);
            }

            if (_format == OpticalFormat.Mode2)
            {
                Mode2Buffer converter = new Mode2Buffer(new StreamBuffer(_content, Ownership.None));
                _content = new BufferStream(converter, FileAccess.Read);
            }
        }
예제 #25
0
        /// <summary>
        /// Creates a new instance from a file on disk.
        /// </summary>
        /// <param name="path">The path to the disk</param>
        /// <param name="access">The desired access to the disk</param>
        public DiskImageFile(string path, FileAccess access)
        {
            _access = access;

            FileAccess fileAccess = FileAccess.Read;
            FileShare fileShare = FileShare.Read;
            if (_access != FileAccess.Read)
            {
                fileAccess = FileAccess.ReadWrite;
                fileShare = FileShare.None;
            }

            FileStream fileStream = null;
            try
            {
                fileStream = new FileStream(path, FileMode.Open, fileAccess, fileShare);
                LoadDescriptor(fileStream);

                // For monolithic disks, keep hold of the stream - we won't try to use the file name
                // from the embedded descriptor because the file may have been renamed, making the 
                // descriptor out of date.
                if (_descriptor.CreateType == DiskCreateType.StreamOptimized || _descriptor.CreateType == DiskCreateType.MonolithicSparse)
                {
                    _monolithicStream = fileStream;
                    _ownsMonolithicStream = Ownership.Dispose;
                    fileStream = null;
                }
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Dispose();
                }
            }

            _fileLocator = new LocalFileLocator(Path.GetDirectoryName(path));
        }
예제 #26
0
        public MirrorStream(Ownership ownsWrapped, params SparseStream[] wrapped)
        {
            _wrapped = new List<SparseStream>(wrapped);
            _ownsWrapped = ownsWrapped;

            _canRead = _wrapped[0].CanRead;
            _canWrite = _wrapped[0].CanWrite;
            _canSeek = _wrapped[0].CanSeek;
            _length = _wrapped[0].Length;

            foreach (var stream in _wrapped)
            {
                if (stream.CanRead != _canRead || stream.CanWrite != _canWrite || stream.CanSeek != _canSeek)
                {
                    throw new ArgumentException("All mirrored streams must have the same read/write/seek permissions", "wrapped");
                }

                if (stream.Length != _length)
                {
                    throw new ArgumentException("All mirrored streams must have the same length", "wrapped");
                }
            }
        }
예제 #27
0
 public SparseReadOnlyWrapperStream(SparseStream wrapped, Ownership ownsWrapped)
 {
     _wrapped     = wrapped;
     _ownsWrapped = ownsWrapped;
 }
예제 #28
0
 /// <summary>
 /// Converts any stream into a sparse stream.
 /// </summary>
 /// <param name="stream">The stream to convert.</param>
 /// <param name="takeOwnership"><c>true</c> to have the new stream dispose the wrapped
 /// stream when it is disposed.</param>
 /// <returns>A sparse stream</returns>
 /// <remarks>The returned stream has the entire wrapped stream as a
 /// single extent.</remarks>
 public static SparseStream FromStream(Stream stream, Ownership takeOwnership)
 {
     return(new SparseWrapperStream(stream, takeOwnership, null));
 }
        public string FTP_ChesterfieldVA(string streetno, string direction, string streetname, string city, string streettype, string unitnumber, string ownernm, string parcelNumber, string searchType, string orderNumber, string directParcel)
        {
            GlobalClass.global_orderNo             = orderNumber;
            HttpContext.Current.Session["orderNo"] = orderNumber;
            GlobalClass.global_parcelNo            = parcelNumber;
            List <string> taxinformation = new List <string>();
            string        StartTime = "", AssessmentTime = "", TaxTime = "", CitytaxTime = "", LastEndTime = "";
            string        As_of = "", Total_Due = "", MillLevy = "", Class = "", YearBuilt = "", subdivision = "";
            List <string> pdflink = new List <string>();
            string        Parcel_number = "", Tax_Authority = "", type = "", AddressCombain = "", Addresshrf = "", Pin = "", address = "", MailingAddress = "", Constructed = "";
            var           driverService = PhantomJSDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;
            //driver = new PhantomJSDriver();
            //driver = new ChromeDriver()
            using (driver = new PhantomJSDriver())
            {
                if (direction != "")
                {
                    address = streetno.Trim() + " " + direction.Trim() + " " + streetname.Trim() + " " + streettype.Trim();
                }
                else
                {
                    address = streetno.Trim() + " " + streetname.Trim() + " " + streettype.Trim();
                }
                if (searchType == "titleflex")
                {
                    gc.TitleFlexSearch(orderNumber, "", ownernm, address, "VA", "Chesterfield");
                    if ((HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes"))
                    {
                        return("MultiParcel");
                    }
                    searchType   = "parcel";
                    parcelNumber = HttpContext.Current.Session["titleparcel"].ToString().Replace(".", "");
                }
                try
                {
                    StartTime = DateTime.Now.ToString("HH:mm:ss");
                    driver.Navigate().GoToUrl("https://www.chesterfield.gov/828/Real-Estate-Assessment-Data#/");
                    if (searchType == "address")
                    {
                        driver.FindElement(By.Id("searchText")).SendKeys(address);
                        Thread.Sleep(4000);
                        gc.CreatePdf_WOP(orderNumber, "Address Search", driver, "VA", "Chesterfield");
                        driver.FindElement(By.XPath("//*[@id='read-search-toolbar']/div/div/div/button[2]/div/i")).Click();
                        Thread.Sleep(6000);
                        gc.CreatePdf_WOP(orderNumber, "Address After", driver, "VA", "Chesterfield");

                        string Recored1 = driver.FindElement(By.XPath("//*[@id='read-content']/main/div/div/div[2]/div[2]/div/div/div/div[6]")).Text;
                        string Recored  = GlobalClass.Before(Recored1, "records");
                        if (Recored.Trim().Contains("1"))
                        {
                            driver.FindElement(By.XPath("//*[@id='read-content']/main/div/div/div[2]/div[2]/div/div/div/div[3]/a/div/div/div[2]")).Click();
                            Thread.Sleep(2000);
                        }
                        if (!Recored.Trim().Contains("1"))
                        {
                            int                 Max           = 0;                         //*[@id="read-content"]/main/div/div/div[2]/div[2]/div/div/div
                            IWebElement         Multipletable = driver.FindElement(By.XPath("//*[@id='read-content']/main/div/div/div[2]/div[2]/div/div/div"));
                            IList <IWebElement> Multiplerow   = Multipletable.FindElements(By.TagName("div"));
                            IList <IWebElement> Multipleid;
                            foreach (IWebElement assessment in Multiplerow)
                            {
                                Multipleid = assessment.FindElements(By.TagName("div"));
                                if (Multipleid.Count == 3 && !assessment.Text.Contains("bedroom(s)") && assessment.Text.Trim() != "" && assessment.Text.Contains("Parcel ID:"))
                                {
                                    //string Adres1 = Multipleid[5].Text;
                                    string addres         = Multipleid[0].Text;
                                    string Parcel1        = Multipleid[2].Text;
                                    string Parcel         = GlobalClass.After(Parcel1, "Parcel ID:");
                                    string Multipleresult = addres + "~" + Parcel;
                                    gc.insert_date(orderNumber, Parcel, 2154, Multipleresult, 1, DateTime.Now);
                                    Max++;
                                }
                            }

                            if (Max > 1 && Max < 26)
                            {
                                HttpContext.Current.Session["multiparcel_Chesterfield"] = "Yes";
                                driver.Quit();
                                return("MultiParcel");
                            }
                            if (Max > 25)
                            {
                                HttpContext.Current.Session["multiParcel_Chesterfield_Multicount"] = "Maximum";
                                driver.Quit();
                                return("Maximum");
                            }
                        }
                        // gc.CreatePdf_WOP(orderNumber, "Address Search", driver, "VA", "Chesterfield");
                        try
                        {
                            string Nodata = driver.FindElement(By.XPath("//*[@id='read-content']/main/div/div/div[2]/div[2]/div/div/div/div")).Text;
                            if (Nodata.Contains("No results were found"))
                            {
                                HttpContext.Current.Session["Zero_Chesterfield"] = "Zero";
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }
                    if (searchType == "parcel")
                    {
                        driver.FindElement(By.Id("searchText")).SendKeys(parcelNumber);
                        Thread.Sleep(4000);
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcel Search", driver, "VA", "Chesterfield");
                        driver.FindElement(By.XPath("//*[@id='read-search-toolbar']/div/div/div/button[2]/div/i")).Click();
                        Thread.Sleep(6000);
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcel Search After", driver, "VA", "Chesterfield");
                        driver.FindElement(By.XPath("//*[@id='read-content']/main/div/div/div[2]/div[2]/div/div/div/div[3]/a/div/div/div[2]/div/div[4]/ul[1]")).Click();
                        Thread.Sleep(8000);
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcel Search click After", driver, "VA", "Chesterfield");
                    }
                    if (searchType == "Block")
                    {
                        driver.FindElement(By.Id("searchText")).SendKeys(unitnumber);
                        Thread.Sleep(4000);
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcel Search", driver, "VA", "Chesterfield");
                        driver.FindElement(By.XPath("//*[@id='read-search-toolbar']/div/div/div/button[2]/div/i")).Click();
                        Thread.Sleep(6000);
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcel Search After", driver, "VA", "Chesterfield");
                        driver.FindElement(By.XPath("//*[@id='read-content']/main/div/div/div[2]/div[2]/div/div/div/div[3]/a/div/div/div[2]/div/div[4]/ul[1]")).Click();
                        Thread.Sleep(8000);
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcel Search click After", driver, "VA", "Chesterfield");
                    }
                    Parcel_number = driver.FindElement(By.Id("parcelNumber")).Text;
                    string RealEstateAccount   = driver.FindElement(By.Id("accountNumber")).Text;
                    string PropertyClass       = driver.FindElement(By.Id("propClass")).Text;
                    string MagisterialDistrict = driver.FindElement(By.Id("magDistrict")).Text;
                    try
                    {
                        subdivision = driver.FindElement(By.Id("subdivision")).Text;
                    }
                    catch { }

                    string DeededAcreage    = driver.FindElement(By.Id("acres")).Text;
                    string ownerName        = driver.FindElement(By.Id("ownerName")).Text;
                    string MailingAddress1  = driver.FindElement(By.Id("mailingAddress")).Text;
                    string MailingAddress2  = driver.FindElement(By.Id("mailingAddressLine2")).Text;
                    string MailingAddress3  = MailingAddress1 + " " + MailingAddress2;
                    string OwnershipType    = driver.FindElement(By.Id("ownershipType")).Text;
                    string legalDescription = driver.FindElement(By.Id("legalDescription")).Text;
                    gc.CreatePdf(orderNumber, parcelNumber, "Overview", driver, "VA", "Chesterfield");
                    IJavaScriptExecutor js = driver as IJavaScriptExecutor;
                    //*[@id="read-content"]/div[4]/div/div/div[1]/div/div/div
                    IWebElement         Assessmentslink = driver.FindElement(By.XPath("//*[@id='read-content']/div[4]/div/div/div[1]/div/div/div"));
                    IList <IWebElement> IChargesRow     = Assessmentslink.FindElements(By.TagName("div"));
                    IList <IWebElement> IChargesTD;
                    foreach (IWebElement charge in IChargesRow)
                    {
                        IChargesTD = charge.FindElements(By.TagName("a"));
                        if (IChargesTD.Count != 0)
                        {
                            try
                            {
                                string strcharges = IChargesTD[0].GetAttribute("innerText");
                                if (strcharges.Contains("RESIDENTIAL"))
                                {
                                    IWebElement IChargesSearch = IChargesTD[0];
                                    js.ExecuteScript("arguments[0].click();", IChargesSearch);
                                    Thread.Sleep(3000);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    Thread.Sleep(2000);

                    gc.CreatePdf(orderNumber, parcelNumber, "Residential", driver, "VA", "Chesterfield");
                    try
                    {
                        YearBuilt = driver.FindElement(By.Id("yearBuilt_0")).Text;
                    }
                    catch { }
                    string Propertydetail = RealEstateAccount + "~" + PropertyClass + "~" + MagisterialDistrict + "~" + subdivision + "~" + DeededAcreage + "~" + ownerName + "~" + MailingAddress3 + "~" + OwnershipType + "~" + legalDescription + "~" + YearBuilt;
                    gc.insert_date(orderNumber, Parcel_number, 2140, Propertydetail, 1, DateTime.Now);

                    // Assessmentslink.Click();
                    //Thread.Sleep(2000);
                    IWebElement         Assessmentslink1 = driver.FindElement(By.XPath("//*[@id='read-content']/div[4]/div/div/div[1]/div/div/div"));
                    IList <IWebElement> IChargesRow1     = Assessmentslink1.FindElements(By.TagName("div"));
                    IList <IWebElement> IChargesTD1;
                    foreach (IWebElement charge1 in IChargesRow1)
                    {
                        IChargesTD1 = charge1.FindElements(By.TagName("a"));
                        if (IChargesTD1.Count != 0)
                        {
                            try
                            {
                                string strcharges = IChargesTD1[0].GetAttribute("innerText");
                                if (strcharges.Contains("ASSESSMENTS"))
                                {
                                    IWebElement IChargesSearch = IChargesTD1[0];
                                    js.ExecuteScript("arguments[0].click();", IChargesSearch);
                                    Thread.Sleep(3000);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    Thread.Sleep(2000);
                    gc.CreatePdf(orderNumber, parcelNumber, "Assessment", driver, "VA", "Chesterfield");
                    IWebElement         Assessmenttable = driver.FindElement(By.XPath("//*[@id='tab_Assessments']/div/div[2]/div/div[1]/div/table/tbody"));
                    IList <IWebElement> Assessmentrow   = Assessmenttable.FindElements(By.TagName("tr"));
                    IList <IWebElement> assessmentid;
                    foreach (IWebElement assessment in Assessmentrow)
                    {
                        assessmentid = assessment.FindElements(By.TagName("td"));
                        if (assessmentid.Count != 0 && !assessment.Text.Contains("Assessment Year:") && assessment.Text.Trim() != "")
                        {
                            string Assessmentresult = assessmentid[1].Text + "~" + assessmentid[2].Text + "~" + assessmentid[3].Text + "~" + assessmentid[4].Text + "~" + assessmentid[5].Text + "~" + assessmentid[6].Text;
                            gc.insert_date(orderNumber, Parcel_number, 2141, Assessmentresult, 1, DateTime.Now);
                        }
                    }
                    IWebElement         Assessmentslink2 = driver.FindElement(By.XPath("//*[@id='read-content']/div[4]/div/div/div[1]/div/div/div"));
                    IList <IWebElement> IChargesRow2     = Assessmentslink2.FindElements(By.TagName("div"));
                    IList <IWebElement> IChargesTD2;
                    foreach (IWebElement charge2 in IChargesRow2)
                    {
                        IChargesTD2 = charge2.FindElements(By.TagName("a"));
                        if (IChargesTD2.Count != 0)
                        {
                            try
                            {
                                string strcharges = IChargesTD2[0].GetAttribute("innerText");
                                if (strcharges.Contains("IMPROVEMENTS"))
                                {
                                    IWebElement IChargesSearch = IChargesTD2[0];
                                    js.ExecuteScript("arguments[0].click();", IChargesSearch);
                                    Thread.Sleep(3000);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    gc.CreatePdf(orderNumber, parcelNumber, "Improvements", driver, "VA", "Chesterfield");
                    IWebElement         Improvementtable = driver.FindElement(By.XPath("//*[@id='tab_Improvements']/div/div[2]/div/div[1]/div/table/tbody"));
                    IList <IWebElement> Improvementrow   = Improvementtable.FindElements(By.TagName("tr"));
                    IList <IWebElement> Improvementid;
                    foreach (IWebElement Improvement in Improvementrow)
                    {
                        Improvementid = Improvement.FindElements(By.TagName("td"));
                        if (Improvementid.Count > 1)
                        {
                            string Improvementresult = Improvementid[0].Text + "~" + Improvementid[1].Text + "~" + Improvementid[2].Text + "~" + Improvementid[3].Text + "~" + Improvementid[4].Text + "~" + Improvementid[5].Text;
                            gc.insert_date(orderNumber, Parcel_number, 2142, Improvementresult, 1, DateTime.Now);
                        }
                    }

                    IWebElement         Assessmentslink3 = driver.FindElement(By.XPath("//*[@id='read-content']/div[4]/div/div/div[1]/div/div/div"));
                    IList <IWebElement> IChargesRow3     = Assessmentslink3.FindElements(By.TagName("div"));
                    IList <IWebElement> IChargesTD3;
                    foreach (IWebElement charge3 in IChargesRow3)
                    {
                        IChargesTD3 = charge3.FindElements(By.TagName("a"));
                        if (IChargesTD3.Count != 0)
                        {
                            try
                            {
                                string strcharges = IChargesTD3[0].GetAttribute("innerText");
                                if (strcharges.Contains("LAND"))
                                {
                                    IWebElement IChargesSearch = IChargesTD3[0];
                                    js.ExecuteScript("arguments[0].click();", IChargesSearch);
                                    Thread.Sleep(3000);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    gc.CreatePdf(orderNumber, parcelNumber, "Land", driver, "VA", "Chesterfield");
                    string Deeded_Acreage         = "";
                    IList <IWebElement> Acreslist = driver.FindElements(By.Id("acres"));
                    foreach (IWebElement Acres in Acreslist)
                    {
                        string Deered = Acres.Text;
                        if (Deered != "")
                        {
                            Deeded_Acreage = Deered;
                        }
                    }
                    string floodPlain     = driver.FindElement(By.Id("floodPlain")).Text;
                    string Easement       = driver.FindElement(By.Id("easement")).Text;
                    string CountyWater    = driver.FindElement(By.Id("countyWater")).Text;
                    string CountySewer    = driver.FindElement(By.Id("countySewer")).Text;
                    string Well           = driver.FindElement(By.Id("well")).Text;
                    string Septic         = driver.FindElement(By.Id("septic")).Text;
                    string Gas            = driver.FindElement(By.Id("gas")).Text;
                    string electricity    = driver.FindElement(By.Id("electricity")).Text;
                    string PavedStreets   = driver.FindElement(By.Id("pavedStreets")).Text;
                    string StormDrains    = driver.FindElement(By.Id("stormDrains")).Text;
                    string curbing        = driver.FindElement(By.Id("curbing")).Text;
                    string Zoning         = driver.FindElement(By.XPath("//*[@id='read-zoning']/div[2]/div/ul/li/div")).Text;
                    string LandLinkresult = Deeded_Acreage + "~" + floodPlain + "~" + Easement + "~" + CountyWater + "~" + Well + "~" + Septic + "~" + Gas + "~" + electricity + "~" + PavedStreets + "~" + StormDrains + "~" + curbing + "~" + Zoning;
                    gc.insert_date(orderNumber, Parcel_number, 2143, LandLinkresult, 1, DateTime.Now);
                    IWebElement         Assessmentslink4 = driver.FindElement(By.XPath("//*[@id='read-content']/div[4]/div/div/div[1]/div/div/div"));
                    IList <IWebElement> IChargesRow4     = Assessmentslink4.FindElements(By.TagName("div"));
                    IList <IWebElement> IChargesTD4;
                    foreach (IWebElement charge4 in IChargesRow4)
                    {
                        IChargesTD4 = charge4.FindElements(By.TagName("a"));
                        if (IChargesTD4.Count != 0)
                        {
                            try
                            {
                                string strcharges = IChargesTD4[0].GetAttribute("innerText");
                                if (strcharges.Contains("OWNERSHIP"))
                                {
                                    IWebElement IChargesSearch = IChargesTD4[0];
                                    js.ExecuteScript("arguments[0].click();", IChargesSearch);
                                    Thread.Sleep(3000);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    gc.CreatePdf(orderNumber, parcelNumber, "Ownership", driver, "VA", "Chesterfield");
                    IWebElement         Ownershiptable = driver.FindElement(By.XPath("//*[@id='tab_Ownership']/div/div[2]/div/div[1]/div/table/tbody"));
                    IList <IWebElement> Ownershiprow   = Ownershiptable.FindElements(By.TagName("tr"));
                    IList <IWebElement> Ownershipid;
                    foreach (IWebElement Ownership in Ownershiprow)
                    {
                        Ownershipid = Ownership.FindElements(By.TagName("td"));
                        if (Ownershipid.Count > 1)
                        {
                            string Ownershipresult = Ownershipid[1].Text + "~" + Ownershipid[2].Text + "~" + Ownershipid[3].Text + "~" + Ownershipid[4].Text + "~" + Ownershipid[5].Text + "~" + Ownershipid[6].Text + "~" + Ownershipid[7].Text + "~" + Ownershipid[8].Text + "~" + Ownershipid[9].Text + "~" + Ownershipid[10].Text;
                            gc.insert_date(orderNumber, Parcel_number, 2153, Ownershipresult, 1, DateTime.Now);
                        }
                    }
                    //Tax Site
                    TaxTime = DateTime.Now.ToString("HH:mm:ss");
                    IWebElement         Assessmentslink5 = driver.FindElement(By.XPath("//*[@id='read-content']/div[4]/div/div/div[1]/div/div/div"));
                    IList <IWebElement> IChargesRow5     = Assessmentslink5.FindElements(By.TagName("div"));
                    IList <IWebElement> IChargesTD5;
                    foreach (IWebElement charge5 in IChargesRow5)
                    {
                        IChargesTD5 = charge5.FindElements(By.TagName("a"));
                        if (IChargesTD5.Count != 0)
                        {
                            try
                            {
                                string strcharges = IChargesTD5[0].GetAttribute("innerText");
                                if (strcharges.Contains("TAX"))
                                {
                                    IWebElement IChargesSearch = IChargesTD5[0];
                                    js.ExecuteScript("arguments[0].click();", IChargesSearch);
                                    Thread.Sleep(3000);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    gc.CreatePdf(orderNumber, parcelNumber, "TaxHistory", driver, "VA", "Chesterfield");
                    string              taxAccount         = driver.FindElement(By.Id("taxAccount")).Text;
                    string              Currentbalance1    = driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[2]/div/div/div/ul/li/div[1]")).Text;
                    string              currentbalncedate  = GlobalClass.After(Currentbalance1, "as of");
                    string              currentbalanceamt  = driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[2]/div/div/div/ul/li/div[2]")).Text;
                    IWebElement         TaxAssessmenttable = driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[3]/div[2]/div/div/table/tbody"));
                    IList <IWebElement> TaxAssessmentrow   = TaxAssessmenttable.FindElements(By.TagName("tr"));
                    IList <IWebElement> TaxAssessmentid;
                    foreach (IWebElement TaxAssessment in TaxAssessmentrow)
                    {
                        TaxAssessmentid = TaxAssessment.FindElements(By.TagName("td"));
                        if (TaxAssessmentid.Count != 0)
                        {
                            string TaxAssessmentresult = taxAccount + "~" + currentbalncedate + "~" + currentbalanceamt + "~" + TaxAssessmentid[0].Text + "~" + TaxAssessmentid[1].Text + "~" + TaxAssessmentid[2].Text + "~" + TaxAssessmentid[3].Text;
                            gc.insert_date(orderNumber, Parcel_number, 2144, TaxAssessmentresult, 1, DateTime.Now);
                        }
                    }
                    driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[6]/div/div[1]/div[1]")).Click();
                    Thread.Sleep(6000);
                    IList <IWebElement> Licount = driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[6]/div/div[2]/div/ul")).FindElements(By.TagName("li"));
                    try
                    {
                        for (int I = 1; I <= 6; I++)
                        {
                            //*[@id="tab_Tax"]/div/div[2]/div/ul/li[6]/div/div[2]/div/ul/li[1]
                            IWebElement Halfclick = driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[6]/div/div[2]/div/ul/li[" + I + "]"));
                            Halfclick.SendKeys(Keys.Enter);
                            //js.ExecuteScript("arguments[0].click();", Halfclick);
                            Thread.Sleep(4000);
                            string Taxyear1 = driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[6]/div/div[2]/div/ul/li[" + I + "]/div[1]")).Text;
                            string taxyear  = GlobalClass.Before(Taxyear1, ":");
                            gc.CreatePdf(orderNumber, parcelNumber, "TaxHistory" + I, driver, "VA", "Chesterfield");
                            IWebElement         TaxaccountHistorytable = driver.FindElement(By.XPath("//*[@id='tab_Tax']/div/div[2]/div/ul/li[6]/div/div[2]/div/ul/li[" + I + "]/div[2]/div/div/div/table/tbody"));
                            IList <IWebElement> TaxaccountHistoryrow   = TaxaccountHistorytable.FindElements(By.TagName("tr"));
                            IList <IWebElement> TaxaccountHistoryid;
                            foreach (IWebElement TaxaccountHistory in TaxaccountHistoryrow)
                            {
                                TaxaccountHistoryid = TaxaccountHistory.FindElements(By.TagName("td"));
                                if (TaxaccountHistoryid.Count != 0)
                                {
                                    string TaxaccountHistoryresult = taxyear + "~" + TaxaccountHistoryid[0].Text + "~" + TaxaccountHistoryid[1].Text + "~" + TaxaccountHistoryid[2].Text + "~" + TaxaccountHistoryid[3].Text + "~" + TaxaccountHistoryid[4].Text + "~" + TaxaccountHistoryid[5].Text + "~" + TaxaccountHistoryid[6].Text;
                                    gc.insert_date(orderNumber, Parcel_number, 2145, TaxaccountHistoryresult, 1, DateTime.Now);
                                }
                            }
                        }
                    }
                    catch { }

                    LastEndTime = DateTime.Now.ToString("HH:mm:ss");
                    gc.insert_TakenTime(orderNumber, "VA", "Chesterfield", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime);
                    driver.Quit();
                    //HttpContext.Current.Session["titleparcel"] = null;
                    gc.mergpdf(orderNumber, "VA", "Chesterfield");
                    return("Data Inserted Successfully");
                }
                catch (Exception ex)
                {
                    driver.Quit();
                    GlobalClass.LogError(ex, orderNumber);
                    throw ex;
                }
            }
        }
예제 #30
0
 /// <summary>
 /// Initializes a stream as a fixed-sized VHD file.
 /// </summary>
 /// <param name="stream">The stream to initialize.</param>
 /// <param name="ownsStream">Indicates if the new instance controls the lifetime of the stream.</param>
 /// <param name="capacity">The desired capacity of the new disk</param>
 /// <param name="geometry">The desired geometry of the new disk, or <c>null</c> for default</param>
 /// <returns>An object that accesses the stream as a VHD file</returns>
 public static DiskImageFile InitializeFixed(Stream stream, Ownership ownsStream, long capacity, Geometry geometry)
 {
     InitializeFixedInternal(stream, capacity, geometry);
     return(new DiskImageFile(stream, ownsStream));
 }
예제 #31
0
 /// <summary>
 /// Initializes a stream as a fixed-sized VHD file.
 /// </summary>
 /// <param name="stream">The stream to initialize.</param>
 /// <param name="ownsStream">Indicates if the new instance controls the lifetime of the stream.</param>
 /// <param name="capacity">The desired capacity of the new disk</param>
 /// <returns>An object that accesses the stream as a VHD file</returns>
 public static DiskImageFile InitializeFixed(Stream stream, Ownership ownsStream, long capacity)
 {
     return(InitializeFixed(stream, ownsStream, capacity, null));
 }
예제 #32
0
 internal DiskImageFile(FileLocator locator, string path, Stream stream, Ownership ownsStream)
     : this(stream, ownsStream)
 {
     _fileLocator = locator.GetRelativeLocator(locator.GetDirectoryFromPath(path));
     FileName     = locator.GetFileFromPath(path);
 }
예제 #33
0
 private void MergeOwnership(Ownership originalOwnership, OwnershipRequest Ownership)
 {
     originalOwnership.Address  = Ownership.Address;
     originalOwnership.Category = Ownership.Category;
 }
예제 #34
0
 public Ownership UpdateOwnership(Ownership originalOwnership, OwnershipRequest Ownership)
 {
     this.MergeOwnership(originalOwnership, Ownership);
     OwnershipRepository.Update(originalOwnership);
     return(originalOwnership);
 }
예제 #35
0
 /// <summary>
 /// Gets the content of this extent.
 /// </summary>
 /// <param name="parent">The parent stream (if any).</param>
 /// <param name="ownsParent">Controls ownership of the parent stream.</param>
 /// <returns>The content as a stream.</returns>
 public abstract MappedStream OpenContent(SparseStream parent, Ownership ownsParent);
예제 #36
0
 public HashStreamDotnet(Stream wrapped, Ownership ownsWrapped, HashAlgorithm hashAlg)
 {
     _wrapped    = wrapped;
     _ownWrapped = ownsWrapped;
     _hashAlg    = hashAlg;
 }
 /// <summary>
 /// Converts any stream into a non-linear stream.
 /// </summary>
 /// <param name="stream">The stream to convert.</param>
 /// <param name="takeOwnership"><c>true</c> to have the new stream dispose the wrapped
 /// stream when it is disposed.</param>
 /// <param name="extents">The set of extents actually stored in <c>stream</c></param>
 /// <returns>A sparse stream</returns>
 /// <remarks>The wrapped stream is assumed to be a linear stream (such that any byte range
 /// maps directly onto the parent stream)</remarks>
 public static new MappedStream FromStream(Stream stream, Ownership takeOwnership, IEnumerable <StreamExtent> extents)
 {
     return(new WrappingMappedStream <Stream>(stream, takeOwnership, extents));
 }
예제 #38
0
 /// <summary>
 /// Initializes a stream as a dynamically-sized VHD file.
 /// </summary>
 /// <param name="stream">The stream to initialize.</param>
 /// <param name="ownsStream">Indicates if the new instance controls the lifetime of the stream.</param>
 /// <param name="capacity">The desired capacity of the new disk</param>
 /// <param name="geometry">The desired geometry of the new disk, or <c>null</c> for default</param>
 /// <returns>An object that accesses the stream as a VHD file</returns>
 public static DiskImageFile InitializeDynamic(Stream stream, Ownership ownsStream, long capacity, Geometry geometry)
 {
     return(InitializeDynamic(stream, ownsStream, capacity, geometry, DynamicHeader.DefaultBlockSize));
 }
 /// <summary>
 /// Converts any stream into a non-linear stream.
 /// </summary>
 /// <param name="stream">The stream to convert.</param>
 /// <param name="takeOwnership"><c>true</c> to have the new stream dispose the wrapped
 /// stream when it is disposed.</param>
 /// <returns>A sparse stream</returns>
 /// <remarks>The wrapped stream is assumed to be a linear stream (such that any byte range
 /// maps directly onto the parent stream)</remarks>
 public static new MappedStream FromStream(Stream stream, Ownership takeOwnership)
 {
     return(new WrappingMappedStream <Stream>(stream, takeOwnership, null));
 }
예제 #40
0
 /// <summary>
 /// Initializes a stream as a dynamically-sized VHD file.
 /// </summary>
 /// <param name="stream">The stream to initialize.</param>
 /// <param name="ownsStream">Indicates if the new instance controls the lifetime of the stream.</param>
 /// <param name="capacity">The desired capacity of the new disk.</param>
 /// <param name="blockSize">The size of each block (unit of allocation).</param>
 /// <returns>An object that accesses the stream as a VHD file.</returns>
 public static DiskImageFile InitializeDynamic(Stream stream, Ownership ownsStream, long capacity, long blockSize)
 {
     return(InitializeDynamic(stream, ownsStream, capacity, null, blockSize));
 }
예제 #41
0
        /// <summary>
        /// Uses <see cref="RebasedStream"/> and/or <see cref="TruncatedStream"/> to create a
        /// read-only partial stream wrapper.
        /// </summary>
        /// <param name="stream">The stream to wrap.</param>
        /// <param name="offset">The desired offset into the wrapped stream, which is immediately
        /// seeked to that position.</param>
        /// <param name="length">The desired length of the partial stream (optional).</param>
        /// <param name="ownership">Indicates the ownership of the wrapped stream.</param>
        /// <returns>The read-only partial stream wrapper.</returns>
        /// <remarks>If <paramref name="offset"/> is zero and <paramref name="length"/> is null,
        /// the stream is returned unwrapped.</remarks>
        public static Stream CreatePartialStream(Stream stream, long offset, long?length, Ownership ownership)
        {
            if (offset != 0)
            {
                stream.Position = offset;
                stream          = new RebasedStream(stream, ownership);
            }

            if (length != null)
            {
                stream = new TruncatedStream(stream, length.Value, ownership);
            }

            return(stream);
        }
예제 #42
0
 /// <summary>
 /// Converts any stream into a sparse stream.
 /// </summary>
 /// <param name="stream">The stream to convert.</param>
 /// <param name="takeOwnership"><c>true</c> to have the new stream dispose the wrapped
 /// stream when it is disposed.</param>
 /// <param name="extents">The set of extents actually stored in <c>stream</c></param>
 /// <returns>A sparse stream</returns>
 /// <remarks>The returned stream has the entire wrapped stream as a
 /// single extent.</remarks>
 public static SparseStream FromStream(Stream stream, Ownership takeOwnership, IEnumerable <StreamExtent> extents)
 {
     return(new SparseWrapperStream(stream, takeOwnership, extents));
 }
예제 #43
0
        RedeemUserKey(string id)
        {
            //See if the key from pay load is present in the DB or is already redeemed
            var key = (await Database.GameKeys())
                      .Where(k => k.Key == id)
                      .FirstOrDefault();

            if (key == null)
            {
                return(Unauthorized("Invalid Key"));
            }

            if (key.IsRedeemed)
            {
                return(Unauthorized("Key has already been redeemed"));
            }

            //get user ID and date of birth from claims
            var identity = HttpContext.User.Identity as ClaimsIdentity;

            var userAccountId = identity.Claims
                                .Where(c => c.Type == ClaimTypes.NameIdentifier)
                                .FirstOrDefault()
                                .Value;

            var userDateOfBirth = identity.Claims
                                  .Where(c => c.Type == ClaimTypes.DateOfBirth)
                                  .FirstOrDefault()
                                  .Value;

            var userAge = DateTime.Now.Year - Convert.ToDateTime(userDateOfBirth).Year;

            var game = (await Database.Games())
                       .Where(g => g.GameId == key.GameId)
                       .FirstOrDefault();

            //User age is used to verify that the user is above game age restriction, also verify that the game exsists
            if (game == null)
            {
                return(BadRequest("Game does not exsist"));
            }

            if ((game.AgeRestriction - userAge) >= 0)
            {
                return(Unauthorized("Users age is below age restriction"));
            }

            //With the data, generate an ownership and call the AddUserGame method to generate a new ownership
            var aOwnerShip = new Ownership {
                GameId        = key.GameId,
                UserAccountId = userAccountId
            };

            var addOwnershipResponse = await AddUserGame(aOwnerShip);

            var httpResponseCode = (int)addOwnershipResponse
                                   .GetType()
                                   .GetProperty("StatusCode")
                                   .GetValue(addOwnershipResponse, null);

            //If new ownership is confirmed the key is updated to status redeemed and saved to DB
            if (httpResponseCode == 200)
            {
                var keys = (await Database.GameKeys())
                           .ToList();

                var keyIndex = keys.IndexOf(key);

                key.IsRedeemed = true;

                keys[keyIndex] = key;

                Database.SaveGameKeys(keys);
            }



            return(addOwnershipResponse);
        }
예제 #44
0
 /// <summary>
 /// Adds a disk image to the XVA file.
 /// </summary>
 /// <param name="label">The admin-visible name of the disk.</param>
 /// <param name="content">The content of the disk.</param>
 /// <param name="ownsContent">Indicates if ownership of content is transfered.</param>
 public void AddDisk(string label, Stream content, Ownership ownsContent)
 {
     _disks.Add(new DiskRecord(label, SparseStream.FromStream(content, ownsContent), Ownership.Dispose));
 }
예제 #45
0
 public HashStreamCore(Stream wrapped, Ownership ownsWrapped, IncrementalHash hashAlg)
 {
     _wrapped    = wrapped;
     _ownWrapped = ownsWrapped;
     _hashAlg    = hashAlg;
 }
예제 #46
0
파일: eina_strbuf.cs 프로젝트: sav/efl
 ///<summary>Creates a new Strbuf from an existing IntPtr.</summary>
 public Strbuf(IntPtr ptr, Ownership ownership)
 {
     this.Handle    = ptr;
     this.Ownership = ownership;
 }
        private SparseStream OpenExtent(ExtentDescriptor extent, long extentStart, SparseStream parent, Ownership ownsParent)
        {
            FileAccess access = FileAccess.Read;
            FileShare  share  = FileShare.Read;

            if (extent.Access == ExtentAccess.ReadWrite && _access != FileAccess.Read)
            {
                access = FileAccess.ReadWrite;
                share  = FileShare.None;
            }

            if (extent.Type != ExtentType.Sparse && extent.Type != ExtentType.VmfsSparse)
            {
                if (ownsParent == Ownership.Dispose && parent != null)
                {
                    parent.Dispose();
                }
            }

            switch (extent.Type)
            {
            case ExtentType.Flat:
            case ExtentType.Vmfs:
                return(SparseStream.FromStream(
                           _fileLocator.Open(extent.FileName, FileMode.Open, access, share),
                           Ownership.Dispose));

            case ExtentType.Zero:
                return(new ZeroStream(extent.SizeInSectors * Utilities.SectorSize));

            case ExtentType.Sparse:
                return(new HostedSparseExtentStream(
                           _fileLocator.Open(extent.FileName, FileMode.Open, access, share),
                           Ownership.Dispose,
                           extentStart,
                           parent,
                           ownsParent));

            case ExtentType.VmfsSparse:
                return(new ServerSparseExtentStream(
                           _fileLocator.Open(extent.FileName, FileMode.Open, access, share),
                           Ownership.Dispose,
                           extentStart,
                           parent,
                           ownsParent));

            default:
                throw new NotSupportedException();
            }
        }
예제 #48
0
 /// <summary>
 /// Creates a new instance from an existing stream, differencing disks not supported.
 /// </summary>
 /// <param name="stream">The stream to read</param>
 /// <param name="ownsStream">Indicates if the new disk should take ownership of <paramref name="stream"/> lifetime.</param>
 public Disk(Stream stream, Ownership ownsStream)
 {
     _diskImage = new DiskImageFile(stream, ownsStream);
 }
예제 #49
0
파일: eina_strbuf.cs 프로젝트: sav/efl
 /// <summary>Takes the ownership of the underlying value to the Managed runtime.</summary>
 public void TakeOwnership()
 {
     this.Ownership = Ownership.Managed;
 }
예제 #50
0
 public BuilderStreamExtent(long start, Stream source, Ownership ownership)
     : base(start, source.Length)
 {
     _source    = source;
     _ownership = ownership;
 }
예제 #51
0
파일: eina_strbuf.cs 프로젝트: sav/efl
 /// <summary>Releases the ownership of the underlying value to C.</summary>
 public void ReleaseOwnership()
 {
     this.Ownership = Ownership.Unmanaged;
 }
예제 #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CachingStream"/> class.
 /// </summary>
 /// <param name="stream">The stream to be cached.</param>
 /// <param name="ownership">Use <see cref="Ownership.Owns"/> if the cached stream should be disposed when this stream is disposed.</param>
 public CachingStream(Stream stream, Ownership ownership)
     : base(stream, ownership)
 {
     m_blocks   = new List <byte[]>();
     m_position = stream.Position;
 }
예제 #53
0
 /// <summary>
 /// Wraps a sparse stream in a read-only wrapper, preventing modification.
 /// </summary>
 /// <param name="toWrap">The stream to make read-only</param>
 /// <param name="ownership">Whether to transfer responsibility for calling Dispose on <c>toWrap</c></param>
 /// <returns>The read-only stream.</returns>
 public static SparseStream ReadOnly(SparseStream toWrap, Ownership ownership)
 {
     return(new SparseReadOnlyWrapperStream(toWrap, ownership));
 }
예제 #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WrappingStream"/> class.
 /// </summary>
 /// <param name="stream">The wrapped stream.</param>
 /// <param name="ownership">Use Owns if the wrapped stream should be disposed when this stream is disposed.</param>
 public WrappingStream(Stream stream, Ownership ownership)
 {
     m_wrappedStream = stream ?? throw new ArgumentNullException(nameof(stream));
     m_ownership     = ownership;
 }
예제 #55
0
 /// <summary>
 /// Initializes a stream as a dynamically-sized VDI file.
 /// </summary>
 /// <param name="stream">The stream to initialize.</param>
 /// <param name="ownsStream">Indicates if the new instance controls the lifetime of the stream.</param>
 /// <param name="capacity">The desired capacity of the new disk</param>
 /// <returns>An object that accesses the stream as a VDI file</returns>
 public static Disk InitializeDynamic(Stream stream, Ownership ownsStream, long capacity)
 {
     return new Disk(DiskImageFile.InitializeDynamic(stream, ownsStream, capacity));
 }
예제 #56
0
        public HostedSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream)
        {
            _fileStream           = file;
            _ownsFileStream       = ownsFile;
            _diskOffset           = diskOffset;
            _parentDiskStream     = parentDiskStream;
            _ownsParentDiskStream = ownsParentDiskStream;

            file.Position = 0;
            byte[] headerSector = Utilities.ReadFully(file, Sizes.Sector);
            _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);
            if (_hostedHeader.GdOffset == -1)
            {
                // Fall back to secondary copy that (should) be at the end of the stream, just before the end-of-stream sector marker
                file.Position = file.Length - Sizes.OneKiB;
                headerSector  = Utilities.ReadFully(file, Sizes.Sector);
                _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);

                if (_hostedHeader.MagicNumber != HostedSparseExtentHeader.VmdkMagicNumber)
                {
                    throw new IOException("Unable to locate valid VMDK header or footer");
                }
            }

            _header = _hostedHeader;

            if (_hostedHeader.CompressAlgorithm != 0 && _hostedHeader.CompressAlgorithm != 1)
            {
                throw new NotSupportedException("Only uncompressed and DEFLATE compressed disks supported");
            }

            _gtCoverage = _header.NumGTEsPerGT * _header.GrainSize * Sizes.Sector;

            LoadGlobalDirectory();
        }
예제 #57
0
 /// <summary>
 /// Adds a sparse disk image to the XVA file.
 /// </summary>
 /// <param name="label">The admin-visible name of the disk.</param>
 /// <param name="content">The content of the disk.</param>
 /// <param name="ownsContent">Indicates if ownership of content is transfered.</param>
 public void AddDisk(string label, SparseStream content, Ownership ownsContent)
 {
     _disks.Add(new DiskRecord(label, content, ownsContent));
 }
예제 #58
0
 /// <summary>
 /// Opens the content of the disk image file as a stream.
 /// </summary>
 /// <param name="parent">The parent file's content (if any).</param>
 /// <param name="ownsParent">Whether the created stream assumes ownership of parent stream.</param>
 /// <returns>The new content stream.</returns>
 public override SparseStream OpenContent(SparseStream parent, Ownership ownsParent)
 {
     return(DoOpenContent(parent, ownsParent));
 }
예제 #59
0
 /// <summary>
 /// Initializes a new instance of the Disk class.
 /// </summary>
 /// <param name="stream">The stream to read</param>
 /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
 /// <param name="geometry">The emulated geometry of the disk.</param>
 public Disk(Stream stream, Ownership ownsStream, Geometry geometry)
 {
     _file = new DiskImageFile(stream, ownsStream, geometry);
 }
예제 #60
0
파일: eina_strbuf.cs 프로젝트: sav/efl
 ///<summary>Creates a new Strbuf. By default its lifetime is managed.</summary>
 public Strbuf(Ownership ownership = Ownership.Managed)
 {
     this.Handle    = eina_strbuf_new();
     this.Ownership = ownership;
 }