Пример #1
0
        protected override bool beforeDelete()
        {
            //判断删除excel数据提取的数据
            if (string.IsNullOrWhiteSpace(this.FK_FrmAttachment))
            {
                return(true);
            }

            //是一个流程先判断流程是否结束,如果结束了,就不让删除.
            //   string nodeID = this.FK_MapData.Replace("ND", "");
            //  if (DataType.IsNumStr(nodeID) = true)
            // {
            //}



            FrmAttachment ath = new FrmAttachment(this.FK_FrmAttachment);

            try
            {
                // @于庆海需要翻译.
                if (ath.AthSaveWay == Sys.AthSaveWay.IISServer)
                {
                    System.IO.File.Delete(this.FileFullName);
                }

                if (ath.AthSaveWay == Sys.AthSaveWay.FTPServer)
                {
                    FtpSupport.FtpConnection ftpconn = new FtpSupport.FtpConnection(SystemConfig.FTPServerIP,
                                                                                    SystemConfig.FTPUserNo, SystemConfig.FTPUserPassword);

                    string fullName = this.FileFullName;
                    ftpconn.DeleteFile(fullName);
                }
            }
            catch (Exception ex)
            {
                Log.DebugWriteError(ex.Message);
            }



            //没有看明白这是什么意思.
            string fkefs = ath.GetParaString("FK_ExcelFile", null);

            if (DataType.IsNullOrEmpty(fkefs) == false)
            {
                string[]    efarr = fkefs.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                ExcelFile   ef    = null;
                ExcelTables ets   = null;
                foreach (string fk_ef in efarr)
                {
                    ef    = new ExcelFile();
                    ef.No = fk_ef;

                    if (ef.RetrieveFromDBSources() > 0)
                    {
                        ets = new ExcelTables(fk_ef);
                        foreach (ExcelTable et in ets)
                        {
                            if (DBAccess.IsExitsObject(et.No))
                            {
                                DBAccess.RunSQL(string.Format("DELETE FROM {0} WHERE FK_FrmAttachmentDB = '{1}'", et.No, this.MyPK));
                            }
                        }
                    }
                }
            }


            return(base.beforeDelete());
        }