// 指定Load, Lazy Load public docPubScheme LoadObject(String strXmlFile) { if (!File.Exists(strXmlFile)) { return(null); } StreamReader sr = new StreamReader(strXmlFile); String strXmlContent = sr.ReadToEnd(); sr.Close(); if (String.IsNullOrWhiteSpace(strXmlContent)) { return(null); } docPubScheme docPubSchemeObj = null; try { docPubSchemeObj = docPub.XmlUtility.DeserializeToObject <docPubScheme>(strXmlContent); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } finally { } return(docPubSchemeObj); }
public docPubScheme GetDocPubScheme(String strType, String strSchemeName) { String strKey = strType + @"/" + strSchemeName; docPubScheme docPubSchemeObj = (docPubScheme)m_hshDocPubScheme[strKey]; return(docPubSchemeObj); }
public int Save2Xml(docPubScheme docPubSchemeObj, String strType, String strSchemeName) { String strBaseDir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; String strDocPubDir = strBaseDir + @"docPub\"; String strTypeDir = strDocPubDir + @"" + strType + @"\"; String strXmlFile = strTypeDir + strSchemeName + @".xml"; if (!Directory.Exists(strTypeDir)) { Directory.CreateDirectory(strTypeDir); } int nInvalid = CheckFileNameValid(strType, strSchemeName); if (nInvalid < 0) { return(nInvalid); } String strXml = ""; try { strXml = docPub.XmlUtility.SerializeToXml <docPubScheme>(docPubSchemeObj); } catch (System.Exception ex) { MessageBox.Show(ex.Message); return(-1); } finally { } StreamWriter sw = null; try { sw = new StreamWriter(strXmlFile); sw.Write(strXml); sw.Flush(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); return(-2); } finally { sw.Close(); } return(0); }
// 验证某个XML是否合法 public int Verify(docPubScheme docPubSchemeObj) { String strXml = ""; try { strXml = docPub.XmlUtility.SerializeToXml <docPub.docPubScheme>(docPubSchemeObj); } catch (System.Exception ex) { // MessageBox.Show(ex.Message); return(-1); } finally { } return(0); }
public docPubScheme LoadObject(String strType, String strSchemeName) { // String strBaseDir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; String strDocPubDir = strBaseDir + @"docPub\"; String strXmlFile = strDocPubDir + strType + @"\" + strSchemeName + ".xml"; docPubScheme docPubSchemeObj = null; docPubSchemeObj = LoadObject(strXmlFile); if (docPubSchemeObj != null) { String strKey = strType + @"/" + strSchemeName; m_hshDocPubScheme[strKey] = docPubSchemeObj; } return(docPubSchemeObj); }
// public int Export(docPubScheme docPubSchemeObj, String strXmlFile) { String strXml = ""; try { strXml = docPub.XmlUtility.SerializeToXml <docPubScheme>(docPubSchemeObj); } catch (System.Exception ex) { MessageBox.Show(ex.Message); return(-1); } finally { } StreamWriter sw = null; try { sw = new StreamWriter(strXmlFile); sw.Write(strXml); sw.Flush(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); return(-2); } finally { sw.Close(); } return(0); }
public void copy2(docPubScheme oth) { oth.strSchemeName = strSchemeName; oth.nTocEnable = nTocEnable; oth.tocFnt.clone(tocFnt); oth.tocParaFmt.clone(tocParaFmt); oth.tocStyles.clone(tocStyles); oth.bHdSnsEnable = bHdSnsEnable; oth.hdSnFnt.clone(hdSnFnt); headingSn hdSn = null, ohdSn = null; int nCnt = oth.hdSns.Count; for (int i = 0; i < nCnt; i++) { hdSn = (headingSn)hdSns[i]; ohdSn = (headingSn)oth.hdSns[i]; ohdSn.clone(hdSn); } oth.bHdStylesEnable = bHdStylesEnable; oth.hdStyleFnt.clone(hdStyleFnt); oth.hdStyleParaFmt.clone(hdStyleParaFmt); headingStyle hdStyle = null, ohdStyle = null; nCnt = oth.hdStyles.Count; for (int i = 0; i < nCnt; i++) { hdStyle = (headingStyle)hdStyles[i]; ohdStyle = (headingStyle)oth.hdStyles[i]; ohdStyle.clone(hdStyle); } oth.nTizhuEnable = nTizhuEnable; oth.tizhuFnt.clone(tizhuFnt); oth.tizhuParaFmt.clone(tizhuParaFmt); oth.tblTizhuStyle.clone(tblTizhuStyle); oth.inShpTizhuStyle.clone(inShpTizhuStyle); oth.bTblEnable = bTblEnable; oth.tblFont.clone(tblFont); //oth.tblEveryParaFmt.clone(tblEveryParaFmt); oth.tblParaFmt.clone(tblParaFmt); oth.bInShpEnable = bInShpEnable; oth.inShpParaFmt.clone(inShpParaFmt); oth.nListParaEnable = nListParaEnable; oth.listParaFnt.clone(listParaFnt); oth.listParaParaFmt.clone(listParaParaFmt); oth.outTblListParaStyle.clone(outTblListParaStyle); oth.inTblListParaStyle.clone(inTblListParaStyle); oth.nTextBodyEnable = nTextBodyEnable; oth.textBodyFnt.clone(textBodyFnt); oth.textBodyParaFmt.clone(textBodyParaFmt); oth.outTblTextBodyStyle.clone(outTblTextBodyStyle); oth.inTblTextBodyStyle.clone(inTblTextBodyStyle); oth.nPgNumEnable = nPgNumEnable; oth.pgNumStyle.clone(pgNumStyle); pageNumStyle pgNum = null, opgNum = null; nCnt = oth.pgNumStyles.Count; for (int i = 0; i < nCnt; i++) { pgNum = (pageNumStyle)pgNumStyles[i]; opgNum = (pageNumStyle)oth.pgNumStyles[i]; // opgNum.clone(pgNum); } return; }
public void clone(docPubScheme oth) { strSchemeName = oth.strSchemeName; nTocEnable = oth.nTocEnable; tocFnt.clone(oth.tocFnt); tocParaFmt.clone(oth.tocParaFmt); tocStyles.clone(oth.tocStyles); bHdSnsEnable = oth.bHdSnsEnable; hdSnFnt.clone(oth.hdSnFnt); headingSn hdSn = null, ohdSn = null; int nCnt = hdSns.Count; for (int i = 0; i < nCnt; i++) { hdSn = (headingSn)hdSns[i]; ohdSn = (headingSn)oth.hdSns[i]; hdSn.clone(ohdSn); } bHdStylesEnable = oth.bHdStylesEnable; hdStyleFnt.clone(oth.hdStyleFnt); hdStyleParaFmt.clone(oth.hdStyleParaFmt); headingStyle hdStyle = null, ohdStyle = null; nCnt = hdStyles.Count; for (int i = 0; i < nCnt; i++) { hdStyle = (headingStyle)hdStyles[i]; ohdStyle = (headingStyle)oth.hdStyles[i]; hdStyle.clone(ohdStyle); } nTizhuEnable = oth.nTizhuEnable; tizhuFnt.clone(oth.tizhuFnt); tizhuParaFmt.clone(oth.tizhuParaFmt); tblTizhuStyle.clone(oth.tblTizhuStyle); inShpTizhuStyle.clone(oth.inShpTizhuStyle); // bTblEnable = oth.bTblEnable; tblFont.clone(oth.tblFont); //tblEveryParaFmt.clone(oth.tblEveryParaFmt); tblParaFmt.clone(oth.tblParaFmt); bInShpEnable = oth.bInShpEnable; inShpParaFmt.clone(oth.inShpParaFmt); nListParaEnable = oth.nListParaEnable; listParaFnt.clone(oth.listParaFnt); listParaParaFmt.clone(oth.listParaParaFmt); outTblListParaStyle.clone(oth.outTblListParaStyle); inTblListParaStyle.clone(oth.inTblListParaStyle); nTextBodyEnable = oth.nTextBodyEnable; textBodyFnt.clone(oth.textBodyFnt); textBodyParaFmt.clone(oth.textBodyParaFmt); outTblTextBodyStyle.clone(oth.outTblTextBodyStyle); inTblTextBodyStyle.clone(oth.inTblTextBodyStyle); nPgNumEnable = oth.nPgNumEnable; pgNumStyle.clone(oth.pgNumStyle); pageNumStyle pgNum = null, opgNum = null; nCnt = pgNumStyles.Count; for (int i = 0; i < nCnt; i++) { pgNum = (pageNumStyle)pgNumStyles[i]; opgNum = (pageNumStyle)oth.pgNumStyles[i]; // pgNum.clone(opgNum); } return; }
// public int Add(String strType, String strSchemeName, docPubScheme docPubSchemeObj) { int nRet = Save2Xml(docPubSchemeObj, strType, strSchemeName); return(nRet); }