コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="IsCL"></param>
        /// <returns></returns>
        public static BDCFilterResult ImportFromFC(bool IsCL)
        {
            int             fileCount = 0;
            bool            IsSuccess = false;
            BDCFilterResult res       = new BDCFilterResult();

            DataTable dt = null;

            if (IsCL)
            {
                dt = ImportBLL.GetCLSLBH();
            }
            else
            {
                dt = ImportDAL.GetPushedSLBH();
            }
            if (null != dt && dt.Rows.Count > 0)
            {
                FC_REWRITE_TAG tag = new FC_REWRITE_TAG();
                foreach (DataRow row in dt.Rows)
                {
                    string slbh   = row[0].ToString();
                    string fcslbh = "";
                    if (CanImport(slbh))
                    {
                        try
                        {
                            List <DOC_BINFILE> doc_bin = GetDoc_Binfile(slbh, fcslbh);

                            if (UseFtp.Equals("是") || UseFtp.ToLower().Equals("true"))
                            {
                                if (null != doc_bin && doc_bin.Count > 0)
                                {
                                    fileCount = doc_bin.Count;
                                    foreach (DOC_BINFILE item in doc_bin)
                                    {
                                        tag.FILENAME += tag.FILENAME != null ? item.FILENAME : ("," + item.FILENAME);
                                        //using (TransactionScope ts = new TransactionScope())
                                        //{
                                        UploadToFtp(slbh, item);
                                        item.FTPATH = ChangeFTPPath(item.FTPATH);
                                        ImportDAL.InsertDoc_binfile(item);

                                        //ts.Complete();
                                        //}
                                    }
                                    tag.FILECOUNT = fileCount.ToString();
                                    //tag.FILENAME =doc_bin[0].BINID
                                    tag.ID        = Guid.NewGuid().ToString();
                                    tag.SLBH      = slbh;
                                    tag.PUSHDATE  = DateTime.Now;
                                    tag.ISSUCCESS = "1";
                                    tag.MESSAGE   = "成功";
                                    IsSuccess     = true;
                                    ImportDAL.InsertLog(tag);
                                }
                                else
                                {
                                    tag.FILECOUNT = fileCount.ToString();
                                    //tag.FILENAME =doc_bin[0].BINID
                                    tag.ID        = Guid.NewGuid().ToString();
                                    tag.SLBH      = slbh;
                                    tag.PUSHDATE  = DateTime.Now;
                                    tag.ISSUCCESS = "0";
                                    tag.MESSAGE   = "失败!不动产库中无此受理编号记录。";
                                    //IsSuccess = true;
                                    ImportDAL.InsertLog(tag);
                                }
                            }
                            else
                            {
                                DOC_FILE doc_file = GetDoc_file(slbh);
                                ImportDAL.InsertDoc_File(doc_file);
                            }
                        }
                        catch (Exception ex)
                        {
                            tag.FILECOUNT = fileCount.ToString();
                            //tag.FILENAME =doc_bin[0].BINID
                            tag.ID        = Guid.NewGuid().ToString();
                            tag.SLBH      = slbh;
                            tag.PUSHDATE  = DateTime.Now;
                            tag.ISSUCCESS = "0";
                            tag.MESSAGE   = "失败!" + ex.Message;
                            ImportDAL.InsertLog(tag);
                            continue;
                        }
                    }
                }
                res.ConfirmType = 0;
                res.IsSuccess   = IsSuccess;
                res.Message     = tag.MESSAGE;
            }
            return(res);
        }