|
@@ -21,6 +21,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
#region 参数和属性
|
|
#region 参数和属性
|
|
private List<string> fileNames;
|
|
private List<string> fileNames;
|
|
|
|
|
|
|
|
+ public IDialogService dialogs;
|
|
|
|
+
|
|
private int fileNamesIndex = 0;
|
|
private int fileNamesIndex = 0;
|
|
|
|
|
|
private int FileNameNumber = 0;
|
|
private int FileNameNumber = 0;
|
|
@@ -195,7 +197,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
public DelegateCommand ADDPDFFilesCommand { get; set; }
|
|
public DelegateCommand ADDPDFFilesCommand { get; set; }
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
- public HomePageSetPasswordDialogViewModel()
|
|
|
|
|
|
+ public HomePageSetPasswordDialogViewModel(IDialogService dialogs)
|
|
{
|
|
{
|
|
PDFCurrentDataTable.Columns.Add("FileState");
|
|
PDFCurrentDataTable.Columns.Add("FileState");
|
|
PDFDataTable.Columns.Add("FileName");
|
|
PDFDataTable.Columns.Add("FileName");
|
|
@@ -212,6 +214,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
ADDOpenedPDFCommand = new DelegateCommand(addOpenedPDFFiles);
|
|
ADDOpenedPDFCommand = new DelegateCommand(addOpenedPDFFiles);
|
|
ADDPDFFilesCommand = new DelegateCommand(addpdffiles);
|
|
ADDPDFFilesCommand = new DelegateCommand(addpdffiles);
|
|
RemovePDFFileCommand = new DelegateCommand(removepdffile);
|
|
RemovePDFFileCommand = new DelegateCommand(removepdffile);
|
|
|
|
+ this.dialogs = dialogs;
|
|
}
|
|
}
|
|
|
|
|
|
#region 检查和初始化
|
|
#region 检查和初始化
|
|
@@ -274,6 +277,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
|
|
|
public void ConfirmEncrypt()
|
|
public void ConfirmEncrypt()
|
|
{
|
|
{
|
|
|
|
+ HomePageBatchProcessingDialogModel.closeDialog = true;
|
|
SafetyGridIsEnabled = "False";
|
|
SafetyGridIsEnabled = "False";
|
|
string openPassword = "";
|
|
string openPassword = "";
|
|
string editPassword = "";
|
|
string editPassword = "";
|
|
@@ -301,28 +305,48 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
{
|
|
{
|
|
PDFDataTable.Rows[fileNamesIndex]["FileState"] = "wait";
|
|
PDFDataTable.Rows[fileNamesIndex]["FileState"] = "wait";
|
|
CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
|
|
CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
|
|
- if (document == null || document.IsEncrypted)
|
|
|
|
|
|
+ if(document == null)
|
|
{
|
|
{
|
|
PDFDataTable.Rows[fileNamesIndex]["FileState"] = "error";
|
|
PDFDataTable.Rows[fileNamesIndex]["FileState"] = "error";
|
|
PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "error";
|
|
PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "error";
|
|
fileNamesIndex++;
|
|
fileNamesIndex++;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- FileInfo fileinfo = new FileInfo(filename);
|
|
|
|
- string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
|
|
|
|
- if (document == null)
|
|
|
|
|
|
+ if (document.IsLocked)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ DialogParameters value = new DialogParameters();
|
|
|
|
+ value.Add(ParameterNames.PDFDocument, document);
|
|
|
|
+ dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
|
|
|
|
+ {
|
|
|
|
+ if (e.Result == ButtonResult.OK)
|
|
|
|
+ {
|
|
|
|
+ if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
|
|
|
|
+ {
|
|
|
|
+ document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (document.IsLocked)
|
|
|
|
+ {
|
|
|
|
+ //未成功解密文档时,释放Document对象,返回
|
|
|
|
+ PDFDataTable.Rows[fileNamesIndex]["FileState"] = "error";
|
|
|
|
+ PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "error";
|
|
|
|
+ fileNamesIndex++;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ //FileInfo fileinfo = new FileInfo(filename);
|
|
|
|
+ //string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
|
|
document.Encrypt(openPassword, editPassword, permissionsInfo);
|
|
document.Encrypt(openPassword, editPassword, permissionsInfo);
|
|
document.WriteToFilePath(filename + "SetPassword");
|
|
document.WriteToFilePath(filename + "SetPassword");
|
|
-
|
|
|
|
PDFDataTable.Rows[fileNamesIndex]["FileState"] = "complete";
|
|
PDFDataTable.Rows[fileNamesIndex]["FileState"] = "complete";
|
|
PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "complete";
|
|
PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "complete";
|
|
fileNamesIndex++;
|
|
fileNamesIndex++;
|
|
document.Release();
|
|
document.Release();
|
|
}
|
|
}
|
|
SafetyGridIsEnabled = "True";
|
|
SafetyGridIsEnabled = "True";
|
|
|
|
+ HomePageBatchProcessingDialogModel.closeDialog = false;
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|