public void DownloadExcelTemplateExecute() { VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog(); dialog.Description = "选择存储的文件夹"; dialog.UseDescriptionForTitle = true; // This applies to the Vista style dialog only, not the old dialog. dialog.ShowDialog(); string strFilePath = dialog.SelectedPath; FileService fileService = new FileService(); if (DefaultTemplateState) { ControllerOperation8001 operation = new ControllerOperation8001(); operation.DownloadDefaultEXCELTemplate(strFilePath + "//" + "默认(" + SelectedControllerType.ToString() + ")模板文件.xls", fileService, null); } else if (CustomizedTemplateState) { ExcelTemplateCustomizedInfo customizedInfo = new ExcelTemplateCustomizedInfo(); customizedInfo.ControllerType = SelectedControllerType; customizedInfo.ControllerName = ControllerName;//应该限制此控制器名称的长度 customizedInfo.MachineNumber = MachineNumber; customizedInfo.SelectedDeviceCodeLength = SelectedDeviceCodeLength; customizedInfo.SerialPortNumber = SerialPortNumber; customizedInfo.LoopAmount = LoopAmount; customizedInfo.LoopGroupAmount = LoopGroupAmount; customizedInfo.StandardLinkageFlag = StandardLinkageFlag; customizedInfo.MixedLinkageFlag = MixedLinkageFlag; customizedInfo.GeneralLinkageFlag = GeneralLinkageFlag; customizedInfo.ManualControlBoardFlag = ManualControlBoardFlag; ControllerOperation8001 operation = new ControllerOperation8001(); string fileName = ""; if (ControllerName.Length > 10) { fileName = fileName + ControllerName.Substring(0, 10) + "控制器(" + SelectedControllerType.ToString() + ")模板文件.xls"; } else { fileName = fileName + ControllerName + "控制器(" + SelectedControllerType.ToString() + ")模板文件.xls"; } operation.DownloadDefaultEXCELTemplate(strFilePath + "//" + fileName, fileService, customizedInfo); } }
public void DownloadExcelTemplateExecute() { VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog(); dialog.Description = "选择存储的文件夹"; dialog.UseDescriptionForTitle = true; // This applies to the Vista style dialog only, not the old dialog. bool?blnResult = dialog.ShowDialog(); if (blnResult != null) { if ((bool)blnResult) { string strFilePath = dialog.SelectedPath; FileService fileService = new FileService(); string suffixString = ""; if (ExcelVersionForTemplate == EXCELVersion.EXCEL2003) { suffixString = ")模板文件.xls"; } else { suffixString = ")模板文件.xlsx"; } ControllerManager controllerManager = new ControllerManager(); controllerManager.InitializeAllControllerOperation(null); IControllerOperation operation = controllerManager.GetController(SelectedControllerType); if (DefaultTemplateState) { //ControllerOperation8001 operation = new ControllerOperation8001(); // operation.DownloadDefaultEXCELTemplate(strFilePath + "//" + "默认(" + SelectedControllerType.ToString() + suffixString, fileService, null); operation.DownloadDefaultEXCELTemplate(strFilePath + "//" + "默认(" + SelectedControllerType.ToString() + suffixString, fileService, null, SelectedControllerType); } else if (CustomizedTemplateState) { ExcelTemplateCustomizedInfo customizedInfo = new ExcelTemplateCustomizedInfo(); customizedInfo.ControllerType = SelectedControllerType; customizedInfo.ControllerName = ControllerName;//应该限制此控制器名称的长度 customizedInfo.MachineNumber = MachineNumber; customizedInfo.SelectedDeviceCodeLength = SelectedDeviceCodeLength; customizedInfo.SerialPortNumber = SerialPortNumber; customizedInfo.LoopAmount = LoopAmount; customizedInfo.LoopGroupAmount = LoopGroupAmount; customizedInfo.StandardLinkageFlag = StandardLinkageFlag; customizedInfo.MixedLinkageFlag = MixedLinkageFlag; customizedInfo.GeneralLinkageFlag = GeneralLinkageFlag; customizedInfo.ManualControlBoardFlag = ManualControlBoardFlag; customizedInfo.DefaultDeviceTypeCode = SelectedDeviceTypeCode; // ControllerOperation8001 operation = new ControllerOperation8001(); //暂时写为8001,后续需要改为各控制器通用代码 string fileName = ""; if (ControllerName.Length > 10) { fileName = fileName + ControllerName.Substring(0, 10) + "控制器(" + SelectedControllerType.ToString() + suffixString; } else { fileName = fileName + ControllerName + "控制器(" + SelectedControllerType.ToString() + suffixString; } // operation.DownloadDefaultEXCELTemplate(strFilePath + "//" +fileName , fileService, customizedInfo); operation.DownloadDefaultEXCELTemplate(strFilePath + "//" + fileName, fileService, customizedInfo, SelectedControllerType); } } } }