コード例 #1
0
        /// <summary>
        /// 导入模板
        /// </summary>
        /// <param name="PubConnectString"></param>
        /// <param name="sysPath"></param>
        /// <param name="allMoudleType"></param>
        /// <param name="mType"></param>
        /// <param name="errTxt"></param>
        /// <returns></returns>
        public int ImportModule(string PubConnectString, string sysPath, string allMoudleType, string mType, ref string errTxt)
        {
            string[] mArr = allMoudleType.Split(',');
            string   tmpPath = "", fileName = "";
            int      numCount = 0;
            PrintDac prt      = new PrintDac(PubConnectString);

            foreach (string s in mArr)
            {
                if (s.Length == 0)
                {
                    continue;
                }
                tmpPath = Path.Combine(sysPath, s);
                DirectoryInfo df = new DirectoryInfo(tmpPath);
                if (df.Exists)
                {
                    FileInfo[] fis = df.GetFiles("*.xml");
                    foreach (FileInfo f in fis)
                    {
                        fileName = f.Name;
                        if (!prt.CheckFtmTemplate(fileName, mType))
                        {
                            continue;
                        }
                        FileStream fStream = File.OpenRead(f.FullName);
                        byte[]     bTemp   = new byte[fStream.Length];
                        fStream.Read(bTemp, 0, bTemp.Length);
                        fStream.Flush();
                        fStream.Close();
                        if (mType == "sys")
                        {
                            numCount += prt.ImportSysTemplate(fileName, bTemp);
                        }
                        else
                        {
                            numCount += prt.ImportUserTemplate(fileName, bTemp);
                        }
                    }
                }
            }
            return(numCount);
        }
コード例 #2
0
        /// <summary>
        /// 导入模板
        /// </summary>
        /// <param name="PubConnectString"></param>
        /// <param name="sysPath"></param>
        /// <param name="allMoudleType"></param>
        /// <param name="mType"></param>
        /// <param name="errTxt"></param>
        /// <returns></returns>
        public int ImportModule(string PubConnectString, string sysPath, string allMoudleType, string mType, ref string errTxt)
        {
            string[] mArr = allMoudleType.Split(',');
            string   tmpPath = "", fileName = "";
            int      numCount = 0;
            PrintDac prt      = new PrintDac(PubConnectString);

            foreach (string moduleno in mArr)
            {
                if (moduleno.Length == 0)
                {
                    continue;
                }
                tmpPath = Path.Combine(sysPath, moduleno);
                DirectoryInfo df = new DirectoryInfo(tmpPath);
                if (df.Exists)
                {
                    FileInfo[] fis = df.GetFiles("*.xml");
                    foreach (FileInfo f in fis)
                    {
                        fileName = f.Name;
                        string def_int2 = "0";
                        switch (mType)
                        {
                        case "sys":
                            def_int2 = "1";
                            break;

                        case "sys_pdf":
                            def_int2 = "3";
                            break;

                        default:
                            def_int2 = "0";
                            break;
                        }
                        if (!prt.CheckFtmTemplate(fileName, def_int2))
                        {
                            continue;
                        }
                        FileStream fStream = File.OpenRead(f.FullName);
                        byte[]     bTemp   = new byte[fStream.Length];
                        fStream.Read(bTemp, 0, bTemp.Length);
                        fStream.Flush();
                        fStream.Close();
                        string billname = fileName.Substring(0, fileName.Length - 4);
                        int    b        = billname.LastIndexOf("[") + 1;
                        int    e        = billname.Length - 1;
                        string typeFile = billname.Substring(b, e - b);
                        billname = billname.Replace("[" + typeFile + "]", "");
                        if (def_int2 == "0")
                        {
                            string ret = prt.Insert(new Dictionary <string, object>()
                            {
                                { "typefile", typeFile },
                                { "moduleno", moduleno },
                                { "billname", billname },
                                { "filename", fileName },
                                { "def_int2", def_int2 },
                                { "def_str3", "supcan" },
                                { "remarks", "" },
                                { "bfile", bTemp },
                                { "iscompress", "0" },
                                { "ispub", "0" },
                                { "def_str1", NG3.AppInfoBase.UCode },
                                { "def_int1", "1" },
                                { "previeweditflg", "0" }
                            }, ref fileName, true);
                            if (!string.IsNullOrEmpty(ret))
                            {
                                numCount++;
                            }
                        }
                        else
                        {
                            string ret = prt.InsertTemplate(moduleno, typeFile, billname, ref fileName, bTemp, def_int2);
                            if (!string.IsNullOrEmpty(ret))
                            {
                                numCount++;
                            }
                        }
                    }
                }
            }
            return(numCount);
        }