/// <summary> /// 查询自己清单 /// </summary> private void GetApply() { string errmsg = ""; DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); DataTable dt3 = new DataTable(); string data = Request["data"]; int page = 0; int totalnum = 0; //记录总数 int pagecount = 0; //页总数 int pagesize = 15; // string dome = Request["dome"]; // string usercode = Request["usercode"]; RequesReturnCar rm = ObjectSerializeHelper.JsonToObject <RequesReturnCar>(data); string usercode = rm.usercode; page = rm.page; BLLProposer mybll = new BLLProposer(); bool result = mybll.GetApply(usercode, pagesize, page, ref totalnum, ref pagecount, ref dt, ref dt1, ref dt2, ref dt3, ref errmsg); if (!result) { Response.Write(outjson.Replace("#code#", "-1").Replace("#msg#", errmsg)); Response.End(); } else { string json = "\"data\":" + ObjectSerializeHelper.DataTableToJson(dt, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data1\":" + ObjectSerializeHelper.DataTableToJson(dt1, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data2\":" + ObjectSerializeHelper.DataTableToJson(dt2, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data3\":" + ObjectSerializeHelper.DataTableToJson(dt3, ObjectSerializeHelper.ColumnNameLetterCase.ToLower); json += ",\"pagecount\":" + pagecount; json += ",\"totalnum\":" + totalnum; Response.Write(outjson.Replace("#code#", "0").Replace("#msg#", "").Replace("\"data\":null", json)); Response.End(); } }
/// <summary> /// 立即用车 /// </summary> private void Appli() { string errmsg = ""; DataTable dt = new DataTable(); string data = Request["data"]; RequesCarFalse rm = ObjectSerializeHelper.JsonToObject <RequesCarFalse>(data); string applycode = rm.applycode; string begin = rm.begin; BLLProposer mybll = new BLLProposer(); bool result = mybll.Appli(applycode, begin, ref errmsg); if (!result) { Response.Write(outjson.Replace("#code#", "-1").Replace("#msg#", errmsg)); Response.End(); } else { string json = "\"data\":" + ObjectSerializeHelper.DataTableToJson(dt, ObjectSerializeHelper.ColumnNameLetterCase.ToLower); Response.Write(outjson.Replace("#code#", "0").Replace("#msg#", "").Replace("\"data\":null", json)); Response.End(); } }
public void GetPdwInformation(string key) { try { ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); List <XmlObject> contents = new List <XmlObject>(); string osqlId = GetPropertyValue(PdwInfo.OsqlCustomXmlPartId); string xsltId = GetPropertyValue(PdwInfo.XsltCustomXmlPartId); string chksId = GetPropertyValue(PdwInfo.ChksCustomXmlPartId); string osql = GetCustomXmlPartContent(osqlId); string xslt = GetCustomXmlPartContent(xsltId); string chks = GetCustomXmlPartContent(chksId); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(osql)); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(xslt)); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(chks)); if (mgrPro.TemplateType == TemplateType.Pdm) { string controlsId = GetPropertyValue(PdwInfo.PdmFormControlXmlPartId); string controls = GetCustomXmlPartContent(controlsId); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(controls)); } mgrPro.XmlObjects = contents; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_GetPdwInfoError, MessageUtils.Expand(Properties.Resources.ipe_GetPdwInfoError, ex.Message), ex.StackTrace); throw mgrExp; } }
public void SavePdwInfo(string key) { try { ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); XmlObject osql = new XmlObject(mgrPro.PdwInfo.OsqlString, ContentType.Osql); XmlObject xslt = new XmlObject(mgrPro.PdwInfo.XsltString, ContentType.Xslt); XmlObject chks = new XmlObject(mgrPro.PdwInfo.ChecksumString, ContentType.Checksum); XmlObject pdeContent = new XmlObject(mgrPro.PdwInfo.PdeContent, ContentType.PdeContent); LogUtils.CreateFile("input.xsl", mgrPro.PdwInfo.XsltString); LogUtils.CreateFile("input.osql.xml", mgrPro.PdwInfo.OsqlString); string osqlId = GetPropertyValue(PdwInfo.OsqlCustomXmlPartId); string xsltId = GetPropertyValue(PdwInfo.XsltCustomXmlPartId); string chksId = GetPropertyValue(PdwInfo.ChksCustomXmlPartId); string pdeContentId = GetPropertyValue(PdwInfo.PdeContentXmlPartId); osqlId = AddCustomXmlPart(ObjectSerializeHelper.SerializeToString <XmlObject>(osql), osqlId); xsltId = AddCustomXmlPart(ObjectSerializeHelper.SerializeToString <XmlObject>(xslt), xsltId); chksId = AddCustomXmlPart(ObjectSerializeHelper.SerializeToString <XmlObject>(chks), chksId); pdeContentId = AddCustomXmlPart(ObjectSerializeHelper.SerializeToString <XmlObject>(pdeContent), pdeContentId); AddCustomProperty(PdwInfo.OsqlCustomXmlPartId, osqlId); AddCustomProperty(PdwInfo.XsltCustomXmlPartId, xsltId); AddCustomProperty(PdwInfo.ChksCustomXmlPartId, chksId); AddCustomProperty(PdwInfo.PdeContentXmlPartId, pdeContentId); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SavePdwInfoError, MessageUtils.Expand(Properties.Resources.ipe_SavePdwInfoError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// Oen pdwr file /// </summary> /// <param name="Doc"></param> public void OpenPdwr(Document Doc, ref List <string> tempFiles) { // get pdwr info string mgrKey = string.Empty; string srvKey = string.Empty; ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); mainManager.MainService.PropertyService.GetPdwrInfos(srvKey); PdwrInfo pdwrInfo = srvPro.IntegrationService.PdwrInfo; // translate pdwr // if (!string.IsNullOrEmpty(pdwrInfo.XmlString) && !string.IsNullOrEmpty(pdwrInfo.XsltString)) if (!string.IsNullOrEmpty(pdwrInfo.XmlString)) { string folderPath = AssetManager.FileAdapter.TemporaryFolderPath; string fileName = System.Guid.NewGuid().ToString(); string xmlFilePath = string.Format("{0}\\{1}{2}", folderPath, fileName, FileExtension.Xml); // mwxml string xslFilePath = string.Format("{0}\\{1}{2}", folderPath, fileName, FileExtension.Xsl); FileHelper.CreateFile(xmlFilePath, pdwrInfo.XmlString); tempFiles.Add(xmlFilePath); if (!string.IsNullOrWhiteSpace(pdwrInfo.XsltString)) // support old file { FileHelper.CreateFile(xslFilePath, pdwrInfo.XsltString); tempFiles.Add(xslFilePath); } Document newDoc = null; if (!string.IsNullOrWhiteSpace(pdwrInfo.XsltString)) // support old file { newDoc = Wkl.MainCtrl.CommonCtrl.CommonProfile.App.Documents.Open( FileName: xmlFilePath, Format: WdOpenFormat.wdOpenFormatXML, XMLTransform: xslFilePath); } else { newDoc = Wkl.MainCtrl.CommonCtrl.CommonProfile.App.Documents.Open( FileName: xmlFilePath, Format: WdOpenFormat.wdOpenFormatXML); } Wkl.MainCtrl.CommonCtrl.CommonProfile.App.ScreenUpdating = true; newDoc.ActiveWindow.View.Type = WdViewType.wdPrintView; // update pde if (!string.IsNullOrWhiteSpace(pdwrInfo.PdeContent)) { PdeContent pdeContent = ObjectSerializeHelper.Deserialize <PdeContent>(pdwrInfo.PdeContent); List <string> excelFiles = mainManager.MainService.PropertyService.RenderPdeInPdw(newDoc, pdeContent); tempFiles.AddRange(excelFiles); } newDoc.Save(); #region process RenderSetting if (!string.IsNullOrEmpty(pdwrInfo.SettingString)) { RenderSettings renderSetting = ObjectSerializeHelper.Deserialize <RenderSettings>(pdwrInfo.SettingString); if (renderSetting != null) { switch (renderSetting.Channel) { #region Media = Display case RenderSettings.ChannelType.Display: switch (renderSetting.Media) { case RenderSettings.MediaType.Pdf: newDoc.ExportAsFixedFormat(Path.ChangeExtension(xmlFilePath, FileExtension.PdfNoDot), WdExportFormat.wdExportFormatPDF, true); ((_Document)newDoc).Close(); break; case RenderSettings.MediaType.Xps: newDoc.ExportAsFixedFormat(Path.ChangeExtension(xmlFilePath, FileExtension.XpsNoDot), WdExportFormat.wdExportFormatXPS, true); ((_Document)newDoc).Close(); break; default: break; } break; #endregion #region Media = Email, Media = Attachment case RenderSettings.ChannelType.Email: case RenderSettings.ChannelType.Attachment: MailHelper.SendEmail(newDoc, renderSetting, ref tempFiles); break; #endregion #region Media = Fax case RenderSettings.ChannelType.Fax: Wkl.MainCtrl.CommonCtrl.CommonProfile.App.CommandBars.ExecuteMso( Constants.SendInternetFax); break; #endregion default: break; } } } #endregion } }
/// <summary> /// new: gen pdw file with word xml document (save docx as xml file for gen xslt) /// </summary> /// <param name="fullDocName"></param> /// <param name="isFull"></param> /// <returns></returns> public void GetPdwInfo(string key) { ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.GetProfile(key); List <ChecksumInfoItem> checksumInfoItems = new List <ChecksumInfoItem>(); srvPro.PdwInfo = new PdwInfo(); TemplateInfo template = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(srvPro.FullDocName); if (srvPro.IsFullDoc) { #region gen osql GenOsqlHelper genOsqlHelper = new GenOsqlHelper(); try { srvPro.DomainInfos = new List <DomainInfo>(); int domainCount = template.DomainNames.Count; int domainIndex = 0; while (domainIndex < domainCount) { string domainName = template.DomainNames[domainIndex]; InternalBookmarkDomain ibmDomain = template.InternalBookmark.GetInternalBookmarkDomain(domainName); if (ibmDomain != null && ibmDomain.InternalBookmarkItems != null && ibmDomain.InternalBookmarkItems.Count > 0) { srvPro.DomainInfos.Add(Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName)); domainIndex++; } else { template.RemoveDomainAt(domainIndex); domainCount--; } } genOsqlHelper.GenOsql(srvPro.DomainInfos, template.InternalBookmark); srvPro.PdwInfo.OsqlString = genOsqlHelper.OsqlString; checksumInfoItems = genOsqlHelper.ChecksumInfoItems; } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GenOsqlError); newSrvExp.Errors.Add(srvExp); LogUtils.Log("GenOsql_ServiceException", srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException( ErrorCode.ipe_GenOsqlError, MessageUtils.Expand(Properties.Resources.ipe_GenOsqlError, ex.Message), ex.StackTrace); LogUtils.Log("GenOsql_SystemException", ex); throw srvExp; } #endregion #region gen xsl GenXsltHelper genXsltHelper = new GenXsltHelper(); try { srvPro.Ibm = genOsqlHelper.Ibm; genXsltHelper.GenXsl2007(key); srvPro.PdwInfo.XsltString = srvPro.XsltString; } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GenXsltError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException( ErrorCode.ipe_GenXsltError, MessageUtils.Expand(Properties.Resources.ipe_GenXsltError, ex.Message), ex.StackTrace); throw srvExp; } #endregion // update RelationOn into InternalBookmark UpdateRelationOns(key); // pde content Integration.PdeService pdeService = new Integration.PdeService(); pdeService.AddExportXSD(template.PdeContent); foreach (PdeContentItem item in template.PdeContent.Items) { if (System.IO.File.Exists(item.FilePath)) { try { string pdeFileContent = FileHelper.ExcelToBase64(item.FilePath); item.FileContent = pdeFileContent; } catch { } } } srvPro.PdwInfo.PdeContent = ObjectSerializeHelper.SerializeToString <PdeContent>(template.PdeContent); } // get checksum GetCheckSum(srvPro, checksumInfoItems, template.InternalBookmark.DocumentSpecificColor, template.InternalBookmark.HasDocumentSpecific); }
/// <summary> /// 查询 /// </summary> private void Getfalse() { string errmsg = ""; string data = Request["data"]; DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); RequesGetFalse rm = ObjectSerializeHelper.JsonToObject <RequesGetFalse>(data); string pagecode = rm.pagecode; string nowrow = rm.nowrow; BLLUserManage mybll = new BLLUserManage(); bool result = mybll.Getfalse(pagecode, nowrow, ref dt, ref dt1, ref errmsg); if (!result) { Response.Write(outjson.Replace("#code#", "-1").Replace("#msg#", errmsg)); Response.End(); } else { string json = "\"data\":" + ObjectSerializeHelper.DataTableToJson(dt, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data1\":" + ObjectSerializeHelper.DataTableToJson(dt1, ObjectSerializeHelper.ColumnNameLetterCase.ToLower); Response.Write(outjson.Replace("#code#", "0").Replace("#msg#", "").Replace("\"data\":null", json)); Response.End(); } }
/// <summary> /// 查询行dengdeng /// </summary> private void GetRow() { string errmsg = ""; string data = Request["data"]; DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); DataTable dt3 = new DataTable(); DataTable dt4 = new DataTable(); DataTable dt5 = new DataTable(); RequestRow info = ObjectSerializeHelper.JsonToObject <RequestRow>(data); string pagecode = info.pagecode; string usercode = info.usercode; string nowrow = info.nowrow; BLLUserManage mybll = new BLLUserManage(); bool result = mybll.GetRow(pagecode, usercode, nowrow, ref dt, ref dt1, ref dt2, ref dt3, ref dt4, ref dt5, ref errmsg); if (!result) { Response.Write(outjson.Replace("#code#", "-1").Replace("#msg#", errmsg)); Response.End(); } else { string json = "\"data\":" + ObjectSerializeHelper.DataTableToJson(dt, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data1\":" + ObjectSerializeHelper.DataTableToJson(dt1, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data2\":" + ObjectSerializeHelper.DataTableToJson(dt2, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data3\":" + ObjectSerializeHelper.DataTableToJson(dt3, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data4\":" + ObjectSerializeHelper.DataTableToJson(dt4, ObjectSerializeHelper.ColumnNameLetterCase.ToLower) + ",\"data5\":" + ObjectSerializeHelper.DataTableToJson(dt5, ObjectSerializeHelper.ColumnNameLetterCase.ToLower); Response.Write(outjson.Replace("#code#", "0").Replace("#msg#", "").Replace("\"data\":null", json)); Response.End(); } }
private void button8_Click(object sender, EventArgs e) { word.Application app = new word.Application(); app.Visible = true; Thread.Sleep(2000); //disable the pdw plugin COMAddIn pdwAddin = null; COMAddIns addins = app.COMAddIns; foreach (COMAddIn addin in addins) { if (addin.Description.Equals("Pdw")) { addin.Connect = false; pdwAddin = addin; break; } } Thread.Sleep(1000); string tempFile = textBox_pdw.Text; string wordFile = tempFile.Split('.')[0] + ".docx"; File.Copy(tempFile, wordFile, true); word.Document doc = app.Documents.Open(wordFile); //change properties of document //foreach (DocumentProperty docPro in doc.CustomDocumentProperties) //{ // if (docPro.Name.StartsWith("Pronto_ImportedExcelFileName")) // { // docPro.Value = textBox_pdwpder.Text; // } //} //remove pde template and add pder file. PdeContent pdeImported = null; string xsl = null; foreach (CustomXMLPart xmlPart in doc.CustomXMLParts) { if (xmlPart.BuiltIn) { continue; } XmlObject customObject = ObjectSerializeHelper.Deserialize <XmlObject>(xmlPart.XML); if (customObject.ContentType == ContentType.ImportedPde) { pdeImported = ObjectSerializeHelper.Deserialize <PdeContent>(customObject.Content); } else if (customObject.ContentType == ContentType.Xslt) { xsl = customObject.Content; } xmlPart.Delete(); } //add pder file CustomXMLPart xmlPart_pder = doc.CustomXMLParts.Add(); pdeImported.FileContent = FileHelper.ExcelToBase64(textBox_pdwpder.Text); //pdeImported.FullFileName = textBox_pdwpder.Text; XmlObject pderObj = new XmlObject(); pderObj.ContentType = ContentType.ImportedPde; pderObj.Content = ObjectSerializeHelper.SerializeToString <PdeContent>(pdeImported); xmlPart_pder.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(pderObj)); //add xml data file XmlDocument dataXml = new XmlDocument(); dataXml.Load(textBox_pdwd.Text); XmlObject pdwrXml = new XmlObject(dataXml.InnerXml, ContentType.PdwrXml); CustomXMLPart xmlPart_xml = doc.CustomXMLParts.Add(); xmlPart_xml.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(pdwrXml)); //add xsl file XmlObject xslObj = new XmlObject(); xslObj.ContentType = ContentType.PdwrXsl; xslObj.Content = xsl; CustomXMLPart xmlpart_xsl = doc.CustomXMLParts.Add(); xmlpart_xsl.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(xslObj)); //add pdwr setting XmlObject settObj = new XmlObject(); settObj.ContentType = ContentType.PdwrSettings; settObj.Content = "<?xml version=\"1.0\" encoding=\"utf-16\"?><RenderSettings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Media>Docx</Media><Channel>Display</Channel></RenderSettings>"; CustomXMLPart xmlpart_sett = doc.CustomXMLParts.Add(); xmlpart_sett.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(settObj)); doc.Save(); doc.Close(); pdwAddin.Connect = true; app.Quit(); File.Copy(wordFile, wordFile.Split('.')[0] + ".pdwr", true); MessageBox.Show("Create pdwr file success."); }