예제 #1
0
        public static KeyValuePair <long, long> Extract(this CassetteInfo cassette, string archRelativePath, string inArchivePath)
        {
            KeyValuePair <long, long> inArchivePosLength = new KeyValuePair <long, long>();
            string key  = cassette.cassette.Name + "/" + archRelativePath + "/" + inArchivePath;
            bool   isOk = false;

            CachedArchives.Add(cassette.cassette.Name + "/" + archRelativePath, true);
            CachedArchives[cassette.cassette.Name + "/" + archRelativePath] = ExtractArchiveToMemory(cassette.cassette.Name, inArchivePath, cassette.url, archRelativePath);
            //task.GetAwaiter().OnCompleted(() => CachedArchives[cassette.Name + "/" + archRelativePath] = task.Result);
            //while (task.Status == TaskStatus.Running && (isOk = !CacheInArchives.TryGetValue(key, out inArchivePosLength)))
            //{}
            if (!isOk && !CacheInArchives.TryGetValue(key, out inArchivePosLength))
            {
                LOG.WriteLine("Нет в архиве " + cassette.url + archRelativePath + " файла " + inArchivePath);
                throw new Exception();//return null;
            }
            return
                (new KeyValuePair <long, long>(inArchivePosLength.Key, inArchivePosLength.Value));
            //CacheInArchives = CacheInArchives.Concat()
            //             .ToDictionary(i => i.Key, i => i.Value); Task<bool>   Tuple.Create
        }
예제 #2
0
        //public static CassetteInfo LoadCassette(string cassetteFolder) { return LoadCassette(cassetteFolder, true); }
        public static CassetteInfo LoadCassette(string cassetteFolder, bool loaddata, bool iseditable)
        {
            //var cassetteFolder = cassettePath.Value;
            //if (!Directory.Exists(cassetteFolder) || (!File.Exists(cassetteFolder + "cassette.finfo"))) return null;
            var cassette = new Cassette(cassetteFolder, loaddata);
            List <RDFDocumentInfo> di_list = null;

            if (loaddata)
            {
                di_list = new List <RDFDocumentInfo>();
                var dd = cassette.DataDocuments().ToList();
                foreach (var xDoc in dd)
                {
                    di_list.Add(
                        new RDFDocumentInfo(xDoc, cassetteFolder));
                }
            }

            var cassetteInfo =
                new CassetteInfo
            {
                fullName   = "iiss://" + cassette.Name + "@iis.nsk.su",
                cassette   = cassette,
                url        = cassette.Dir.FullName + '/',
                docsInfo   = di_list,
                loaddata   = loaddata,
                iseditable = iseditable,
                owner      = cassette.Owner
            };

            if (loaddata)
            {
                cassetteInfo.docsInfo.Add(new RDFDocumentInfo(cassette, true));
            }
            return(cassetteInfo);
        }