コード例 #1
0
        public Task InstallDlBook(DlBook dlBook, string symmetricKey, CancellationToken cancelToken)
        {
            return(Task.Run(async() =>
            {
                InstallResultEnum installResult = InstallResultEnum.Failure;
                PublicationContent publicationContent = null;
                try
                {
                    var contentKey = await dlBook.GetContentKey(symmetricKey).WithCancellation <byte[]>(cancelToken);
                    publicationContent = new PublicationContent(dlBook, contentKey);

                    bool hasNotInstalled = (!await publicationContent.DlBook.IsSqliteDecryped());
                    if (hasNotInstalled)
                    {
                        await publicationContent.DlBook.UnZipFile(cancelToken);
                        if (cancelToken.IsCancellationRequested)
                        {
                            cancelToken.ThrowIfCancellationRequested();
                        }
                        await publicationContent.DecryptDataBase();
                        await publicationContent.DlBook.DeleteOriginalSqlite();
                        installResult = InstallResultEnum.Success;
                    }
                    else
                    {//has been installed
                        installResult = InstallResultEnum.Success;
                    }
                }
                catch (OperationCanceledException ex)
                {
                    if (cancelToken.IsCancellationRequested)
                    {
                        installResult = InstallResultEnum.Cancel;
                    }
                    throw ex;
                }
                catch (Exception ex)
                {
                    Logger.Log("Install error:" + ex.ToString());
                    installResult = InstallResultEnum.Failure;
                    throw ex;
                }
                finally
                {
                    if (publicationContent != null && installResult != InstallResultEnum.Success)
                    {
                        publicationContent.DlBook.DeleteDlBookInstallFile().Wait();
                    }
                }
            }));
        }
コード例 #2
0
ファイル: PDFTests.cs プロジェクト: littlefeihu/checktask
        public void Test_Init()
        {
            Stopwatch time = new Stopwatch();

            time.Start();
            TestInit.Init().Wait();
            LoginUtil.Instance.ValidateUserLogin(TestHelper.TestUsers[0].UserName, TestHelper.TestUsers[0].Password, TestHelper.TestUsers[0].CountryCode).Wait();
            DlBook dlBook = new DlBook
            {
                BookId                = 111,
                InitVector            = "QDFCMmMzRDRlNUY2ZzdIOA==",
                K2Key                 = "MXdi9JQDDUY1hf5TZCEHjeBtjKL605dInVG3xYTF76U=",
                HmacKey               = "9jU0MAYPOPufUZoZJCW7qhsQe20=",
                LastDownloadedVersion = 1,
                ServiceCode           = GlobalAccess.Instance.CurrentUserInfo.Country.CountryCode,
                Email                 = GlobalAccess.Instance.CurrentUserInfo.Email
            };
            var contentKey = dlBook.GetContentKey(GlobalAccess.Instance.CurrentUserInfo.SymmetricKey).Result;

            GlobalAccess.Instance.CurrentPublication = new PublicationContent(dlBook, contentKey);
            time.Stop();
            Console.Out.WriteLine("Time : " + time.ElapsedMilliseconds);
        }
コード例 #3
0
        public void Test_Init()
        {
            Stopwatch time = new Stopwatch();

            time.Start();
            TestInit.Init().Wait();
            LoginUtil.Instance.ValidateUserLogin(TestHelper.TestUsers[0].UserName, TestHelper.TestUsers[0].Password, TestHelper.TestUsers[0].CountryCode).Wait();
            DlBook dlBook = new DlBook
            {
                BookId                = 41,
                InitVector            = "QDFCMmMzRDRlNUY2ZzdIOA==",
                K2Key                 = "PhlFIzSW3nR9Vq6wg1g3bwqN9uAz0IqBdlJDobzzEUI=",
                HmacKey               = "+wlxbpoqFZ1h0dMv9p/mmqAdJ9Y=",
                LastDownloadedVersion = 1,
                ServiceCode           = GlobalAccess.Instance.CurrentUserInfo.Country.CountryCode,
                Email                 = GlobalAccess.Instance.CurrentUserInfo.Email
            };
            var contentKey = dlBook.GetContentKey(GlobalAccess.Instance.CurrentUserInfo.SymmetricKey).Result;

            GlobalAccess.Instance.CurrentPublication = new PublicationContent(dlBook, contentKey);
            time.Stop();
            Console.Out.WriteLine("Time : " + time.ElapsedMilliseconds);
        }
コード例 #4
0
        public void Test_Init()
        {
            Stopwatch time = new Stopwatch();

            time.Start();
            TestInit.Init().Wait();
            LoginUtil.Instance.ValidateUserLogin(TestHelper.TestUsers[0].UserName, TestHelper.TestUsers[0].Password, TestHelper.TestUsers[0].CountryCode).Wait();
            DlBook dlBook = new DlBook
            {
                BookId                = 26,
                InitVector            = "QDFCMmMzRDRlNUY2ZzdIOA==",
                K2Key                 = "Kd7qQHCj9qT05gDAAAgXsj74kxQpHA2r2Flf3FH7XLQ=",
                HmacKey               = "7PPPQbvLEVsMRwpXJJqQv49fU7c=",
                LastDownloadedVersion = 18,
                ServiceCode           = GlobalAccess.Instance.CurrentUserInfo.Country.ServiceCode,
                // CountryCode = GlobalAccess.Instance.CurrentUserInfo.Country.CountryCode,
                Email = GlobalAccess.Instance.CurrentUserInfo.Email
            };
            var contentKey = dlBook.GetContentKey(GlobalAccess.Instance.CurrentUserInfo.SymmetricKey).Result;

            GlobalAccess.Instance.CurrentPublication = new PublicationContent(dlBook, contentKey);
            time.Stop();
            Console.Out.WriteLine("Time : " + time.ElapsedMilliseconds);
        }