public void ExportImportTest() { EFDbConnect EFDbConnectDemoBase = CreateDemoBase("Save_test.db"); ILogger ILoggerMock = Mock.Of<ILogger>(); // Export DiskOperation ExportIO = new DiskOperation(ILoggerMock,new SQLitePlatformWin32(),EFDbConnectDemoBase); string exportpath = PathToDb("export.db"); ExportIO.ExportLearningItem(exportpath, EFDbConnectDemoBase.Table<LearningItem>().Where(x=>x.Name == "First").First().id , false); EFDbConnect dbConnect = new EFDbConnect(new SQLitePlatformWin32(), exportpath,false); QuantityTest(dbConnect); dbConnect.Close(); EFDbConnectDemoBase.Close(); // Import to empty db EFDbConnect DestConnect = RecreateDB("dest.db"); DiskOperation ImportIO = new DiskOperation(ILoggerMock,new SQLitePlatformWin32(),DestConnect); ImportIO.ImportLearningItem(exportpath, false); QuantityTest(DestConnect); // Update DestConnect.Delete(DestConnect.Table<Subtitles>().First()); DestConnect.Delete(DestConnect.Table<AudioTrack>().First()); DestConnect.Delete(DestConnect.Table<TranslationOfWord>().First()); Assert.IsTrue(DestConnect.Table<Subtitles>().Count() == 1); Assert.IsTrue(DestConnect.Table<AudioTrack>().Count() == 1); Assert.IsTrue(DestConnect.Table<TranslationOfWord>().Count() == 1); ImportIO.ImportLearningItem(exportpath, false); QuantityTest(DestConnect); DestConnect.Close(); }
public OperationFinishedEventArgs(bool done, bool success, OperationFinishedState operationState, DiskOperation diskOperation, Exception exception) { Done = done; Success = success; OperationState = operationState; DiskOperation = diskOperation; Exception = exception; }
public DiskOperation Update(DiskOperation diskOperation) { Operation operation = this.Info(diskOperation.Id); diskOperation.LastUpdated = operation.LastUpdated; diskOperation.Step = operation.Step; return diskOperation; }
private void Button_Click(object sender, RoutedEventArgs e) { DiskOperation diskop = new DiskOperation(Mvx.Resolve<ILogger>(),new SQLitePlatformWin32(),Mvx.Resolve<EFDbConnect>()); diskop.ExportLearningItem(Path.Combine(FileService.GetPathToApplicationDataFolder(), "upload.db"), new UUID("9a0d3d5b-2600-d043-baa8-bfe8cece6afb"), true); //Disk_Operations io = new Disk_Operations(); // io.Backup(@"C:\tmp\backup\bkp.xml"); /* Assembly asm = Assembly.GetExecutingAssembly(); foreach(Type type in asm.GetTypes()) { int i = 9; } var lst = asm.GetTypes().Where(x => x.CustomAttributes.Any(m => m.AttributeType == typeof(System.ComponentModel.DataAnnotations.Schema.TableAttribute))); */ //System.Type[] types = GetTypesInNamespace(Assembly.Get) //string url = @"http://www.youtube.com/watch?v=wyx6JDQCslE&list=PLirAqAtl_h2pRAtj2DgTa3uWIZ3-0LKTA&index=127"; //string url = @"http://www.youtube.com/watch?v=3Q2bkCYjrHk"; //string url = @"http://www.youtube.com/watch?v=FG1NrQYXjLU"; //var lst = API.YoutubeDownloader.GetVideoInfo(url); //bool isExternalAudio; //string ExternalAudioPath; //System.Threading.Tasks.Task.Run(() => // API.YoutubeDownloader.Download(lst, lst.OrderByDescending(x=>x.Resolution).First(), @"C:\tmp\1\video.mp4",out isExternalAudio,out ExternalAudioPath) //); //Model.Language en = ViewModelLocator.Instance.Languages.First(x => x.Code == "en"); //Model.Language ru = ViewModelLocator.Instance.Languages.First(x => x.Code == "ru"); //var lst = API.LanguageServices.GetServices(en,ru); }
public void ExportTest() { EFDbConnect EFDbConnectDemoBase = CreateDemoBase("Save_test.db"); ILogger ILoggerMock = Mock.Of<ILogger>(); DiskOperation diskop = new DiskOperation(ILoggerMock,new SQLitePlatformWin32(),EFDbConnectDemoBase); string path = PathToDb("upload.db"); diskop.ExportLearningItem(path, EFDbConnectDemoBase.Table<LearningItem>().Where(x=>x.Name == "First").First().id , true); EFDbConnect dbConnect = new EFDbConnect(new SQLitePlatformWin32(), path,false); Assert.IsTrue(dbConnect.Table<LearningItem>().Count() == 1); Assert.IsTrue(dbConnect.Table<Subtitles>().Count() == 2); Assert.IsTrue(dbConnect.Table<SubtitleItem>().Count() == 4); Assert.IsTrue(dbConnect.Table<SubtitleItem.Word>().Count() == 2); Assert.IsTrue(dbConnect.Table<WordOfDictionary>().Count() == 2); Assert.IsTrue(dbConnect.Table<TranslationOfWord>().Count() == 2); Assert.IsTrue(dbConnect.Table<Dictionary>().Count() == 1); Assert.IsTrue(dbConnect.Table<AudioTrack>().Count() == 2); Assert.IsTrue(dbConnect.Table<FrequencyDictionary>().Count() == 1); Assert.IsTrue(dbConnect.Table<FrequencyDictionary.Item>().Count() == 2); dbConnect.Close(); }
public OperationProgressChangedEventArgs(int progress, ulong averageBps, DiskOperation diskOperation) { Progress = progress; AverageBps = averageBps; DiskOperation = diskOperation; }
private void SetVhdProp() { try { if (Path.GetExtension(WTGModel.imageFilePath) == ".vhd" || Path.GetExtension(WTGModel.imageFilePath) == ".vhdx") { VhdType = string.Empty; VhdSize = string.Empty; VhdFileName = string.Empty; ExtensionType = string.Empty; VhdPath = WTGModel.imageFilePath; NeedCopy = true; } else { // ////////////////vhd设定/////////////////////// // string vhd_type = "expandable"; // vhd_size = ""; if (WTGModel.isFixedVHD) { VhdType = "fixed"; } else { VhdType = "expandable"; } if (WTGModel.userSetSize != 0) { VhdSize = (WTGModel.userSetSize * 1024).ToString(); } else { long hardDiskFreeSpace = (long)WTGModel.UdObj.Size / 1048576; //MessageBox.Show(hardDiskFreeSpace.ToString ()); //MessageBox.Show(hardDiskFreeSpace.ToString()); if (!WTGModel.isWimBoot) { if (hardDiskFreeSpace >= (int.Parse(vhdDefaultSize) + 1024)) { VhdSize = vhdDefaultSize; } else { VhdSize = hardDiskFreeSpace == 0 ? vhdDefaultSize : (hardDiskFreeSpace - 500).ToString(); } } else { if (hardDiskFreeSpace >= (int.Parse(vhdDefaultSize) + 4096)) { VhdSize = vhdDefaultSize; } else { VhdSize = hardDiskFreeSpace == 0 ? vhdDefaultSize : (hardDiskFreeSpace - 4096).ToString(); } } } //Win8VHDFileName = userSettings.VHDNameWithoutExt + "." + choosedFileType; ////////////////判断临时文件夹,VHD needcopy?/////////////////// int vhdmaxsize; if (WTGModel.isFixedVHD) { vhdmaxsize = int.Parse(VhdSize) * 1024 + 1024; } else { vhdmaxsize = 10485670;//10GB } if (DiskOperation.GetHardDiskFreeSpace(WTGModel.vhdTempPath.Substring(0, 2) + "\\") <= vhdmaxsize || StringUtility.IsChina(WTGModel.vhdTempPath) || (WTGModel.isUefiGpt && !WTGModel.isLegacyUdiskUefi) || WTGModel.isUefiMbr || WTGModel.isWimBoot || WTGModel.isNoTemp) { this.NeedCopy = false; this.VhdPath = StringUtility.Combine(WTGModel.ud, WTGModel.win8VHDFileName); } else { this.NeedCopy = true; this.VhdPath = StringUtility.Combine(WTGModel.vhdTempPath, WTGModel.win8VHDFileName); } } StringBuilder sb = new StringBuilder(); sb.AppendLine(this.ExtensionType); sb.AppendLine(this.NeedCopy.ToString()); sb.AppendLine(this.VhdFileName); sb.AppendLine(this.VhdPath); sb.AppendLine(this.VhdSize); sb.AppendLine(this.VhdType); Log.WriteLog("VHDInfo.log", sb.ToString()); } catch (Exception ex) { Log.WriteLog("SetVhdProp.log", ex.ToString()); ErrorMsg er = new ErrorMsg(MsgManager.GetResString("Msg_VHDCreationError", MsgManager.ci)); er.ShowDialog(); } }