Ejemplo n.º 1
0
        /// <summary>
        /// 从来源获取公文
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="Url">来源</param>
        /// <param name="type">公文类型</param>
        /// <param name="rlDate"></param>
        /// <param name="provider"></param>
        /// <param name="notes"></param>
        /// <param name="isAddRecord">是否记录进数据库</param>
        public static bool GetDoc(string Title, string Url, string type = "", string rlDate = "",
            string provider = "", string notes = "", bool isAddRecord = true)
        {
            try
            {
                Uri u = new Uri(Url);
                if (u.Scheme.ToLower() == "http")
                {//网址
                    List<cWord> lw = new List<cWord>();
                    lw.Add(new cWord(Title, u.AbsoluteUri, type, rlDate, provider, notes, isAddRecord));
                    cMakeWord mw = new cMakeWord(lw);
                    Thread th = new Thread(new System.Threading.ThreadStart(mw.makeWord));
                    th.Start();
                }
                else if (u.Scheme.ToLower() == "ftp")
                {
                    string ap = u.AbsolutePath.Substring(0, u.AbsolutePath.LastIndexOf('/'));
                    string file = u.AbsolutePath.Replace(ap, "");
                    //暂时不提供ftp文件的下载
                    FTPHelper _fh = new FTPHelper(u.Authority, ap, "", "");

                    _fh.Download(cConfig.strWorkPath + "\\" + type, file);
                    if (isAddRecord)
                        cAccess.add(Title, u.AbsoluteUri, cConfig.strWorkPath + "\\" + type + "\\" + file, type, rlDate, provider, notes);
                }
                else if (u.Scheme.ToLower() == "file")
                {//本地文件
                    string HouZui = u.LocalPath.Substring(u.LocalPath.LastIndexOf('.'));

                    string pFilePath;
                    if (type == "")
                        type = cConfig.strNoType;
                    pFilePath = cConfig.strWorkPath + "\\" + type;

                    if (!(Directory.Exists(pFilePath)))
                        Directory.CreateDirectory(pFilePath);

                    pFilePath += "\\" + Title + HouZui;
                    if (File.Exists(pFilePath))
                    {
                        //MessageBox.Show("公文库中已有同名公文,请修改公文标题或类型!");
                        return true;
                    }
                    File.Copy(Url, pFilePath);
                    if (isAddRecord)
                        cAccess.add(Title, u.LocalPath, pFilePath, type, rlDate, provider, notes);
                }
                else { return false; }
                frmMain.fm.initialize();
                return true;
            }
            catch
            {
                return false;
                throw;
            }
        }
Ejemplo n.º 2
0
 private void makeWord_Click(object sender, EventArgs e)
 {
     if (listDoc.CheckedItems.Count > 0)
     {
         this.UseWaitCursor = true;
         List<cWord> lw = new List<cWord>();
         for (int i = 0; i < listDoc.CheckedItems.Count; i++)
         {
             for (int j = 0; j < cCrawler.lcl.Count; j++)
             {
                 if (listDoc.CheckedItems[i].SubItems[0].Text == cCrawler.lcl[j].ID.ToString())
                 {
                     lw.Add(new cWord(cCrawler.lcl[j].listInfo[0], cCrawler.lcl[j].URL, strType, cCrawler.lcl[j].listInfo[1], cCrawler.lcl[j].listInfo[2], "批量添加的公文"));
                     break;
                 }
             }
         }
         //执行下载操作
         cMakeWord mw = new cMakeWord(lw);
         Thread th = new Thread(new ThreadStart(mw.makeWord));
         th.Start();
         this.UseWaitCursor = false;
         tsslStatus.Text = "命令已执行!";
     }
     else { tsslStatus.Text = "请选择公文!"; }
 }
Ejemplo n.º 3
0
        ///// <summary>
        ///// 将FTP上被标记的文件下载下来
        ///// </summary>
        //public void record()
        //{
        //    for (int i = 0; i < FtpFS.typeList.Count; i++)
        //    {
        //        for (int j = 0; j < FtpFS.typeList[i].FileList.Count; j++)
        //        {
        //            if (!FtpFS.typeList[i].FileList[j].isRecord)
        //            {
        //                if (File.Exists(cConfig.strWorkPath + FtpFS.typeList[i].name + FtpFS.typeList[i].FileList[j].name))
        //                    continue;
        //                fh.Download(cConfig.strWorkPath + "\\" + FtpFS.typeList[i].name, FtpFS.typeList[i].FileList[j].name);

        //                cAccess.add(FtpFS.typeList[i].FileList[j].name, "",
        //                    cConfig.strWorkPath + FtpFS.typeList[i].name + FtpFS.typeList[i].FileList[j].name,
        //                    FtpFS.typeList[i].name, "", cConfig.FTP_IP, "从FTP上下载的文件");

        //                FtpFS.typeList[i].FileList[j].isRecord = true;
        //            }
        //        }
        //    }
        //}

        #region 静态方法

        /// <summary>
        /// 从来源获取公文
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="Url">来源</param>
        /// <param name="type">公文类型</param>
        /// <param name="rlDate"></param>
        /// <param name="provider"></param>
        /// <param name="notes"></param>
        /// <param name="isAddRecord">是否记录进数据库</param>
        public static bool GetDoc(string Title, string Url, string type = "", string rlDate = "",
                                  string provider = "", string notes = "", bool isAddRecord = true)
        {
            try
            {
                Uri u = new Uri(Url);
                if (u.Scheme.ToLower() == "http")
                {//网址
                    List <cWord> lw = new List <cWord>();
                    lw.Add(new cWord(Title, u.AbsoluteUri, type, rlDate, provider, notes, isAddRecord));
                    cMakeWord mw = new cMakeWord(lw);
                    Thread    th = new Thread(new System.Threading.ThreadStart(mw.makeWord));
                    th.Start();
                }
                else if (u.Scheme.ToLower() == "ftp")
                {
                    string ap   = u.AbsolutePath.Substring(0, u.AbsolutePath.LastIndexOf('/'));
                    string file = u.AbsolutePath.Replace(ap, "");
                    //暂时不提供ftp文件的下载
                    FTPHelper _fh = new FTPHelper(u.Authority, ap, "", "");

                    _fh.Download(cConfig.strWorkPath + "\\" + type, file);
                    if (isAddRecord)
                    {
                        cAccess.add(Title, u.AbsoluteUri, cConfig.strWorkPath + "\\" + type + "\\" + file, type, rlDate, provider, notes);
                    }
                }
                else if (u.Scheme.ToLower() == "file")
                {//本地文件
                    string HouZui = u.LocalPath.Substring(u.LocalPath.LastIndexOf('.'));

                    string pFilePath;
                    if (type == "")
                    {
                        type = cConfig.strNoType;
                    }
                    pFilePath = cConfig.strWorkPath + "\\" + type;

                    if (!(Directory.Exists(pFilePath)))
                    {
                        Directory.CreateDirectory(pFilePath);
                    }

                    pFilePath += "\\" + Title + HouZui;
                    if (File.Exists(pFilePath))
                    {
                        //MessageBox.Show("公文库中已有同名公文,请修改公文标题或类型!");
                        return(true);
                    }
                    File.Copy(Url, pFilePath);
                    if (isAddRecord)
                    {
                        cAccess.add(Title, u.LocalPath, pFilePath, type, rlDate, provider, notes);
                    }
                }
                else
                {
                    return(false);
                }
                frmMain.fm.initialize();
                return(true);
            }
            catch
            {
                return(false);

                throw;
            }
        }