private void FullChainRoot_InnerDomain(string[] args, bool needRepair) { Par2LibraryArguments par2args = new Par2LibraryArguments(); if (!Parser.ParseArgumentsWithUsage(args, par2args)) { return; } switch (par2args.action) { case ParAction.ParCreate: if (par2args.inputFiles.Length == 0 || (par2args.redundancy == -1 && par2args.recoveryblockcount == -1)) { Parser.ArgumentsUsage(par2args.GetType()); return; } break; case ParAction.ParVerify: case ParAction.ParRepair: if (par2args.recoveryFiles.Length == 0) { Parser.ArgumentsUsage(par2args.GetType()); return; } break; } Par2Library library = new Par2Library(par2args.multithreadCPU, par2args.multithreadIO); List <string> inputFiles = new List <string>(par2args.inputFiles); List <string> recoveryFiles = new List <string>(par2args.recoveryFiles); if (string.IsNullOrEmpty(par2args.targetPath)) { if (par2args.action == ParAction.ParCreate) { par2args.targetPath = Path.GetDirectoryName(par2args.inputFiles[0]); } else { par2args.targetPath = Path.GetDirectoryName(par2args.recoveryFiles[0]); } } ParResult result = library.Process(par2args); Assert.AreEqual <ParResult>(ParResult.Success, result); }
private ParResult Repair(ref List <string> inputFiles, ref List <string> recoveryFiles) { ParResult verifyResult = Verify(ref inputFiles, ref recoveryFiles); if (verifyResult != ParResult.Success && verifyResult != ParResult.RepairPossible) { return(verifyResult); } // Add code to find setid propelry string setid = setids.Keys.First(); // Rename any damaged or missnamed target files. if (!setids[setid].RenameTargetFiles()) { return(ParResult.FileIOError); } // Are we still missing any files if (setids[setid].completefilecount < setids[setid].MainPacket.recoverablefilecount) { // Work out which files are being repaired, create them, and allocate // target DataBlocks to them, and remember them for later verification. if (!setids[setid].CreateTargetFiles()) { return(ParResult.FileIOError); } // Work out which data blocks are available, which need to be copied // directly to the output, and which need to be recreated, and compute // the appropriate Reed Solomon matrix. if (!setids[setid].ComputeRSmatrix()) { // Delete all of the partly reconstructed files setids[setid].DeleteIncompleteTargetFiles(); return(ParResult.FileIOError); } // if (noiselevel > CommandLine::nlSilent) // cout << endl; // Allocate memory buffers for reading and writing data to disk. if (!setids[setid].AllocateBuffers(GetMemoryLimit())) { // Delete all of the partly reconstructed files setids[setid].DeleteIncompleteTargetFiles(); return(ParResult.MemoryError); } // Set the total amount of data to be processed. setids[setid].totaldata = setids[setid].MainPacket.blocksize * setids[setid].sourceblockcount * (setids[setid].missingblockcount > 0 ? setids[setid].missingblockcount : 1); // Start at an offset of 0 within a block. ulong blockoffset = 0; while (blockoffset < setids[setid].MainPacket.blocksize) // Continue until the end of the block. { // Work out how much data to process this time. uint blocklength = (uint)Math.Min((ulong)setids[setid].chunksize, setids[setid].MainPacket.blocksize - blockoffset); // Read source data, process it through the RS matrix and write it to disk. if (!setids[setid].ProcessData(blockoffset, blocklength)) { // Delete all of the partly reconstructed files setids[setid].DeleteIncompleteTargetFiles(); return(ParResult.FileIOError); } // Advance to the need offset within each block blockoffset += blocklength; } // if (noiselevel > CommandLine::nlSilent) // cout << endl << "Verifying repaired files:" << endl << endl; // Verify that all of the reconstructed target files are now correct if (!setids[setid].VerifyTargetFiles()) { // Delete all of the partly reconstructed files //setids[setid].DeleteIncompleteTargetFiles(); return(ParResult.FileIOError); } } // Are all of the target files now complete? if (setids[setid].completefilecount < setids[setid].MainPacket.recoverablefilecount) { //cerr << "Repair Failed." << endl; return(ParResult.RepairFailed); } else { //if (noiselevel > CommandLine::nlSilent) // cout << endl << "Repair complete." << endl; return(ParResult.Success); } }
protected void SaveHandler(object sender, BeforeStoreChangedEventArgs e) { if (cbbCheckDept.SelectedIndex == -1 || cbbforcheckDept.SelectedIndex == -1) { Ext.Msg.Alert("提示", "请填写完整信息!").Show(); return; } XmlNode xml = e.DataHandler.XmlData; XmlNode updated = xml.SelectSingleNode("records/Updated"); if (Check(updated)) { string type = Request.QueryString["Type"].Trim(); decimal strrid = 0; if (type == "new") { ParResult pr = new ParResult { Checkdate = dfDate.SelectedDate, Checkdept = cbbCheckDept.SelectedItem.Value, Checkfordept = cbbforcheckDept.SelectedItem.Value, Pkindid = decimal.Parse(Request.QueryString["Pkindid"]), Rstatus = "1", Total = 0 }; try { pr.Banci = cbbBanci.SelectedItem.Value; } catch { } if (fb_zrr.SelectedIndex > -1) { pr.Bkhperson = fb_zrr.SelectedItem.Value; } if (cbb_khr.SelectedIndex > -1) { pr.Khperson = cbb_khr.SelectedItem.Value; } if (cbbplace.SelectedIndex > -1) { pr.Placeid = cbbplace.SelectedItem.Value; } dc.ParResult.InsertOnSubmit(pr); dc.SubmitChanges(); strrid = dc.ParResult.Max(p => p.Rid); } else { var result = dc.ParResult.First(p => p.Rid == decimal.Parse(Request.QueryString["Rid"])); result.Checkfordept = cbbforcheckDept.SelectedItem.Value; result.Placeid = cbbplace.SelectedItem.Value; result.Checkdate = dfDate.SelectedDate; if (fb_zrr.SelectedIndex > -1) { result.Bkhperson = fb_zrr.SelectedItem.Value; } if (cbb_khr.SelectedIndex > -1) { result.Khperson = cbb_khr.SelectedItem.Value; } dc.SubmitChanges(); strrid = result.Rid; } if (updated != null) { XmlNodeList uRecords = updated.SelectNodes("record"); decimal total = 0; if (uRecords.Count > 0) { foreach (XmlNode record in uRecords) { if (record != null) { total += record.SelectSingleNode("Jeom").InnerText.Trim() == "" ? 0 : decimal.Parse(record.SelectSingleNode("Jeom").InnerText); if (type == "new") { if (record.SelectSingleNode("Jcid").InnerText.Trim().Substring(0, 1) == "j") { AddDetail(record, strrid); } else { AddRAdetail(record, strrid); } } else { if (record.SelectSingleNode("Jcid").InnerText.Trim().Substring(0, 1) == "j") { if (record.SelectSingleNode("Rdid").InnerText.Trim() == "-1") { AddDetail(record, strrid); } else { UpdateDetail(record); } } else { if (record.SelectSingleNode("Rdid").InnerText.Trim() == "-1") { AddRAdetail(record, strrid); } else { UpdateRADetail(record); } } } } } var res = dc.ParResult.First(p => p.Rid == strrid); res.Total = dc.ParKind.First(p => p.Pkindid == res.Pkindid).Fullscore.Value - total; dc.SubmitChanges(); } e.Cancel = true; GVLoad(strrid.ToString()); } Ext.Msg.Alert("提示", "保存成功").Show(); } else { Ext.Msg.Alert("提示", "扣分超过最大值").Show(); } }
/* * Repair commandline /mt- /rf:"C:\Users\Jerome\Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\Tests\EntLib50.par2" /action:ParRepair * * * Create commandline /if:"C:\Users\Jerome\Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\CreateTests\EntLib50.chm" /action:ParCreate /rbc:10 /mtcpu- /mtio- * * * /mtio- /mtcpu- /a:ParVerify /rf:C:\Users\Jerome\Documents\5150.Rue.Des.Ormes.LIMITED.FRENCHDVDRIP.XVID.AC3-TBoss\5150.par2 * * /if:"C:\Users\Jerome\Documents\BigCreate\5150.Rue.Des.Ormes.LIMITED.FRENCHDVDRIP.XVID.AC3-TBoss.part01.rar" /if:"C:\Users\Jerome\Documents\BigCreate\5150.Rue.Des.Ormes.LIMITED.FRENCHDVDRIP.XVID.AC3-TBoss.part02.rar" /if:"C:\Users\Jerome\Documents\BigCreate\5150.Rue.Des.Ormes.LIMITED.FRENCHDVDRIP.XVID.AC3-TBoss.part03.rar" /action:ParCreate /rbc:10 /mtcpu- /mtio- * * /if:"C:\Users\Jerome\Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\CreateTests\EntLib50.chm" /if:"C:\Users\Jerome\Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\CreateTests\EntLib50_copy.chm" /if:"C:\Users\Jerome\Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\CreateTests\EntLib50_copy2.chm" /rbc:30 /mtio- /mtcpu+ /action:ParCreate * */ static void Main(string[] args) { Par2LibraryArguments par2args = new Par2LibraryArguments(); if (!Parser.ParseArgumentsWithUsage(args, par2args)) { return; } switch (par2args.action) { case ParAction.ParCreate: if (par2args.inputFiles.Length == 0 || (par2args.redundancy == -1 && par2args.recoveryblockcount == -1)) { Parser.ArgumentsUsage(par2args.GetType()); return; } break; case ParAction.ParVerify: case ParAction.ParRepair: if (par2args.recoveryFiles.Length == 0) { Parser.ArgumentsUsage(par2args.GetType()); return; } break; } Par2Library library = new Par2Library(par2args.multithreadCPU, par2args.multithreadIO); List <string> inputFiles = new List <string>(par2args.inputFiles); List <string> recoveryFiles = new List <string>(par2args.recoveryFiles); if (string.IsNullOrEmpty(par2args.targetPath)) { if (par2args.action == ParAction.ParCreate) { par2args.targetPath = Path.GetDirectoryName(par2args.inputFiles[0]); } else { par2args.targetPath = Path.GetDirectoryName(par2args.recoveryFiles[0]); } } #if TimeTrack DateTime startTime = DateTime.Now; #endif ParResult result = library.Process(par2args); #if TimeTrack DateTime endTime = DateTime.Now; TimeSpan duration = endTime - startTime; System.Console.WriteLine("Duration : {0}h{1}m{2}s{3}ms", duration.Hours, duration.Minutes, duration.Seconds, duration.Milliseconds); #endif System.Console.WriteLine("Par2NET result : {0}", result); //recoveryFiles.Add(@"C:\USERS\Projects\__Perso\Par2NET\Par2NET\Tests\EntLib50.vol10+10.PAR2"); //recoveryFiles.Add(@"C:\Documents and Settings\Jerome\My Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\Tests\EntLib50.vol10+10.PAR2"); //recoveryFiles.Add(@"C:\Users\Jerome\Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\Tests\EntLib50.vol10+10.PAR2"); //ParResult result = library.Process(ParVersion.Par2, inputFiles, recoveryFiles, ParAction.ParVerify, @"C:\Documents and Settings\Jerome\My Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\Tests"); //ParResult result = library.Process(ParVersion.Par2, inputFiles, recoveryFiles, ParAction.ParRepair, @"C:\Documents and Settings\Jerome\My Documents\Visual Studio 2010\Projects\Par2NET\Par2NET\Tests"); }