Exemple #1
0
 public static string ExportData(string CpicIds, string ColNames, string NodeId, string type, string FileType)
 {
     try
     {
         SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
         CpicIds = CpicIds.Replace(",undefined,", ",");
         List<int> listNo = CpicIds.Trim(',').Split(',').ToList<string>().ConvertAll<int>(x => Convert.ToInt32(x));
         List<xmlDataInfo> listXml = search.GetResult(listNo, type.ToUpper());
         string name = GlobalUtility.TimeRandomName() + "." + FileType;
         string strFileName = "/Images/Export/Patent" + name;
         string fullpath = System.Web.HttpContext.Current.Server.MapPath(strFileName);
         if (!Directory.Exists(Path.GetDirectoryName(fullpath)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(fullpath));
         }
         ExcelLib.NPOIHelper eh = new ExcelLib.NPOIHelper();
         fullpath = eh.DataTable2File(List2DataTable(listXml, ColNames, type, NodeId), fullpath, FileType);
         return name;
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         return "";
     }
 }
Exemple #2
0
        public static string ExportData2(string type, string db, string id, string ColNames, string beginNum, string endNum, string strSort, string FileType)
        {
            try
            {
                int userid = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserID"]);
                int bnum = Convert.ToInt32(beginNum) - 1;
                if (bnum < 0) bnum = 0;
                int endnum = Convert.ToInt32(endNum);
                int length = endnum - bnum;
                SearchInterface.ClsSearch search = new SearchInterface.ClsSearch();
                List<string> strcolnames = ColNames.Split('|').ToList<string>();
                List<int> listNo;
                List<int> fResult = new List<int>();
                switch (type.ToUpper())
                {
                    case "FI":
                    case "CN":
                    case "EN":
                        SearchPattern sp = new SearchPattern();
                        sp.SearchNo = id;
                        sp.Pattern = "";
                        if (db.ToUpper() == "CN")
                        {
                            sp.DbType = SearchDbType.Cn;
                        }
                        else
                        {
                            sp.DbType = SearchDbType.DocDB;
                        }
                        sp.UserId = userid;
                        ResultServices res = new ResultServices();
                        fResult = res.GetResultList(sp, "");
                        break;
                    case "ZT":
                    case "QY":
                        fResult = ztHelper.GetResultList(id, db);
                        break;
                    case "CO":
                        fResult = UserCollectsHelper.GetResultList(db, Convert.ToInt32(id));
                        break;
                    case "YJ0":
                    case "YJ1":
                        fResult = ProYJDLL.YJDB.getYJItemByWID(Convert.ToInt32(id), Convert.ToInt16(type.Substring(2).ToString()));
                        break;
                }

                listNo = fResult.Skip(bnum).Take(length).ToList<int>();
                List<xmlDataInfo> listXml = search.GetResult(listNo, db.ToUpper());
                string name = GlobalUtility.TimeRandomName() + "." + FileType;
                string strFileName = "/Images/Export/Patent" + name;
                string fullpath = System.Web.HttpContext.Current.Server.MapPath(strFileName);
                if (!Directory.Exists(Path.GetDirectoryName(fullpath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fullpath));
                }
                ExcelLib.NPOIHelper eh = new ExcelLib.NPOIHelper();

                fullpath = eh.DataTable2File(List2DataTable(listXml, ColNames, type, ""), fullpath, FileType);

                return name;
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                return "";
            }
        }