void OverviewErrorsWidget::contextMenuEvent(QContextMenuEvent *pEvent)
{
    QAction *tAction;

    QMenu tMenu(this);

    tAction = tMenu.addAction(QPixmap(":/images/22_22/Save.png"), Homer::Gui::OverviewErrorsWidget::tr("Save"));
    tAction = tMenu.addAction(QPixmap(":/images/22_22/Reset.png"), Homer::Gui::OverviewErrorsWidget::tr("Update"));
    tAction = tMenu.addAction(QPixmap(":/images/22_22/Reset.png"), Homer::Gui::OverviewErrorsWidget::tr("Automatic updates"));
    tAction->setCheckable(true);
    tAction->setChecked(mAutoUpdate);

    QAction* tPopupRes = tMenu.exec(pEvent->globalPos());
    if (tPopupRes != NULL)
    {
        if (tPopupRes->text().compare(Homer::Gui::OverviewErrorsWidget::tr("Save")) == 0)
        {
            SaveLog();
            return;
        }
        if (tPopupRes->text().compare(Homer::Gui::OverviewErrorsWidget::tr("Update")) == 0)
        {
            UpdateView();
            return;
        }
        if (tPopupRes->text().compare(Homer::Gui::OverviewErrorsWidget::tr("Automatic updates")) == 0)
        {
            mAutoUpdate = !mAutoUpdate;
            return;
        }
    }
}
Ejemplo n.º 2
0
/****************************************
** Author:      Joe Li
** Purpose:     Save log data
** Comments:  
****************************************/
bool DOSaveAppData::SaveLogData(const CComBSTR& targetPath, LOG_TYPE logToSave)
{
    if (targetPath.Length() != 0)
        return SaveLog(targetPath, logToSave);

	return false;
}
Ejemplo n.º 3
0
void
DebugLog::Connect ()
{
  connect (closeButton, SIGNAL (clicked()), this, SLOT(Close()));
  connect (stopButton, SIGNAL (clicked()), this, SLOT (StopLogging()));
  connect (startButton, SIGNAL (clicked()), this, SLOT (StartLogging()));
  connect (saveButton, SIGNAL (clicked()), this, SLOT (SaveLog()));
}
Ejemplo n.º 4
0
/****************************************
** Author:      Joe Li
** Purpose:     Save log data
** Comments:  
****************************************/
bool DOSaveAppData::SaveAllLogData(const CComBSTR& targetPath)
{
    if (targetPath.Length() != 0)
    {
        bool allLogsSaved = true;

        // Did not use loop to avoid casting loop index into LOG_TYPE
        allLogsSaved = SaveLog(targetPath, ALARM_LOG) && allLogsSaved;
        allLogsSaved = SaveLog(targetPath, ERROR_LOG) && allLogsSaved;
        allLogsSaved = SaveLog(targetPath, RND_LOG) && allLogsSaved;
        allLogsSaved = SaveLog(targetPath, KEYPRESS_LOG) && allLogsSaved;
        allLogsSaved = SaveLog(targetPath, EVENT_LOG) && allLogsSaved;

        return allLogsSaved;
    }

    return false;
}
Ejemplo n.º 5
0
HRESULT CHveDbController::ConnectDB()
{
	if(!m_fComIsInited)
	{
		::CoInitialize(NULL);
		m_fComIsInited = TRUE;
	}

	HRESULT hr = S_OK;
	m_fIsConnecting = TRUE;
	try
	{
		hr = m_pConnection.CreateInstance("ADODB.Connection");
		if(SUCCEEDED(hr))
		{
			m_pConnection->CommandTimeout = 15;
			m_pConnection->CursorLocation = adUseServer;
			m_pConnection->IsolationLevel = adXactReadCommitted;
			CString strConnectInfo;
			strConnectInfo.Format("Provider=SQLOLEDB;Server=%s;DATABASE=%s;UID=%s;PWD=%s",
				m_strServerIP, m_strDataBase, m_strUserName, m_strPassword);
			hr = m_pConnection->Open((_bstr_t)(strConnectInfo.GetBuffer()), "", "", adModeUnknown);

			SaveLog("数据库连接成功");
		}
	}
	catch (_com_error e)
	{
		m_fIsConnecting = FALSE;
		CString strErrorMessage;
		strErrorMessage.Format("数据库连接失败,错误信息:%s 错误码:%d\n", e.ErrorMessage(), GetLastError());
		SaveLog(strErrorMessage.GetBuffer());
		SaveLog(e.Description());
		OutPutMessage("数据库连接失败...");
	}
	return hr;
}
Ejemplo n.º 6
0
void SaveLog_L(char *buf)
{
	char temp[100];
	memset(temp,0,sizeof(temp));
	SYSTEMTIME systime;
	GetLocalTime(&systime);
	sprintf(temp,"%d年%d月%d日 %02d:%02d:%02d %s%s\r\n", 
		systime.wYear,
		systime.wMonth,
		systime.wDay,
		systime.wHour,
		systime.wMinute,
		systime.wSecond,
		buf, "\0");
	SaveLog(temp,strlen(temp));
}
Ejemplo n.º 7
0
BOOL CLogEditCtrl::OnCommand(WPARAM wParam, LPARAM /*lParam*/){
	switch (wParam) {
	case MP_COPYSELECTED:
		CopySelectedItems();
		break;
	case MP_SELECTALL:
		SelectAllItems();
		break;
	case MP_REMOVEALL:
		Reset();
		break;
	case MP_SAVELOG:
		SaveLog();
		break;
	case MP_AUTOSCROLL:
		m_bAutoScroll = !m_bAutoScroll;
		break;
	}
	return TRUE;
}
void OverviewErrorsWidget::ErrorLogCustomContextMenuEvent(const QPoint &pPos)
{
    QAction *tAction;

    QMenu tMenu(this);

    tAction = tMenu.addAction("Save error log");
    QIcon tIcon1;
    tIcon1.addPixmap(QPixmap(":/images/22_22/Save.png"), QIcon::Normal, QIcon::Off);
    tAction->setIcon(tIcon1);

    QAction* tPopupRes = tMenu.exec(QCursor::pos());
    if (tPopupRes != NULL)
    {
        if (tPopupRes->text().compare("Save error log") == 0)
        {
            SaveLog();
            return;
        }
    }
}
void OverviewErrorsWidget::contextMenuEvent(QContextMenuEvent *pContextMenuEvent)
{
    QAction *tAction;

    QMenu tMenu(this);

    tAction = tMenu.addAction("Save error log");
    QIcon tIcon1;
    tIcon1.addPixmap(QPixmap(":/images/22_22/Save.png"), QIcon::Normal, QIcon::Off);
    tAction->setIcon(tIcon1);

    QAction* tPopupRes = tMenu.exec(pContextMenuEvent->globalPos());
    if (tPopupRes != NULL)
    {
        if (tPopupRes->text().compare("Save error log") == 0)
        {
            SaveLog();
            return;
        }
    }
}
Ejemplo n.º 10
0
void CDuffDlg::OnFileSavelog()
{
	SaveLog();
}
Ejemplo n.º 11
0
DWORD WINAPI CShareGUIDlg::workerThread( LPVOID lpParam )
{
    //isProcessing = TRUE;
    TRANS_DATA *data = (TRANS_DATA*) lpParam; 
    AfxSocketInit();
    CTimeOutSocket aSocket;
    aSocket.Create();
    aSocket.SetTimeOut(10000);
    if(aSocket.Connect(L"xyc.netease.com", 8002))
    {
        
        long ulSize = filesize(data->fp);
        char szBuf[1024] = {0};
        sprintf_s(szBuf,"%s\n%ld\n",data->filename,ulSize);
        aSocket.Send(szBuf, strlen(szBuf));

        char szRecValue[1024] = {0};
        int recvCnt = 0;

        while((recvCnt = aSocket.Receive((void *)szRecValue, 1024))!=0 )
        {
            CString line(szRecValue);
            
            CString *key = NULL;
            CString *name = NULL;
            CString *csFullurl = NULL;
            TASK_ITEM *item = NULL;
            
            SaveLog(line);
            
            if (line.Find(L"KEY") != -1)
            {  
                if (!item)
                    item = new TASK_ITEM();
                key = new CString(line.Mid(line.Find(L"KEY")+4,KEY_LEN));
                item->name = key;
            }
            if (line.Find(L"NAME") != -1)
            {
                if (!item)
                    item = new TASK_ITEM();
                int pos = line.Find(L"NAME")+5;
                int posend = line.Find(L'\n',pos);
                name = new CString(line.Mid(pos,posend-pos));
                if (item)
                {    
                    csFullurl = new CString();
                    csFullurl->Format(L"http://xyc.netease.com:8001/f/%s/%s", *key, *name);
                    item->thread_id = GetCurrentThreadId();
                    item->name = name;
                    item->url = csFullurl;
                    ::PostMessage(data->target_hwnd,ID_UPDATE_URL,(WPARAM)item,NULL);
                }
                
            }
            if (line.Find(L"REQ") != -1)
            {
                int offset,length;
                CString tmp = line.Mid(line.Find(L"REQ"));
                _stscanf(tmp,L"REQ %d %d", &offset, &length);


                char buff_send[BUFF_LEN + 6] = {0};
                char compress_flag[] = "PLAIN\n";
                char buf[BUFF_LEN]={0};
                fseek(data->fp,offset,0);
                fread(buf,length,1,data->fp);
                memcpy(buff_send, compress_flag, strlen(compress_flag));
                memcpy(buff_send + strlen(compress_flag), buf, length);

                aSocket.Send(buff_send,length + strlen(compress_flag));

                int percent = ((offset + length)*1.0 /  ulSize*1.0 )* 100;
                if (percent !=0)
                    ::PostMessage(data->target_hwnd, ID_UPDATE_PROGRESS, (WPARAM)percent, (LPARAM)GetCurrentThreadId());
            }
            if (line.Find(L"QUIT") != -1)
                break;
            memset(szRecValue,0,sizeof(szRecValue));
        }
    }
    else{
        ::MessageBox(data->target_hwnd,L"Server Down!",NULL,NULL);
    }
    aSocket.KillTimeOut();
    ::PostMessage(data->target_hwnd, ID_FINISH, (WPARAM)GetCurrentThreadId(), NULL);
    //isProcessing = FALSE;
    
    return 0;

}
Ejemplo n.º 12
0
unLogFrame::~unLogFrame()
{
	SaveLog();
}
Ejemplo n.º 13
0
HRESULT CHveDbController::SaveDBElement(RESULT_ELEMENT* pElement)
{
	HRESULT hr = S_OK;
	if(!m_fIsConnecting)
	{
		SaveLog("数据库连接已经断开,尝试重新连接...");
		hr = ConnectDB();
	}

	if(!m_fIsConnecting)
	{
		char szOutPutInfo[100];
		sprintf(szOutPutInfo, "连接数据库失败,保存%s结果失败...错误码:%d", pElement->szPlateNo, GetLastError());
		SaveLog(szOutPutInfo);
		OutPutMessage(szOutPutInfo);
		return E_FAIL;
	}
	_variant_t RecordsAffected;

	CTime cTime(pElement->dw64TimeMs / 1000);
	CString strTime = cTime.Format("%Y-%m-%d %H:%M:%S");
	CString strCurTable = cTime.Format("Hve_Data_%Y%m%d");

	//int iMinute = cTime.GetMinute(); 
	//CString strTmp = cTime.Format("Hve_Data_%Y%m%d%H");
	//strCurTable.Format("%s_%d",strTmp.GetBuffer(), iMinute/10); // 10分钟一张表
	//strTmp.ReleaseBuffer();

	if(m_strLastTable != strCurTable)
	{
		char szCmdText[1024] = {0};

		//try
		//{
		//	sprintf(szCmdText, "Create TABLE %s(Record_Id bigint primary key IDENTITY   (1,   1)   NOT   NULL,\
		//					   Location_Id int NOT NULL,Pass_Time datetime NOT NULL, Plate_No char(20), Road_No int,\
		//					   Car_Speed int, Obj_Id int, Time_Headway int, Over_Line int, Cross_Line int,\
		//					   Emergency_Stop int, Reverse_Run bit, Special_Result bit, big_image_1_path char(256),\
		//					   big_image_2_path char(256), big_image_3_path char(256), big_image_4_path char(256),\
		//					   big_image_5_path char(256), small_image_path char(256), bin_image_path char(256),\
		//					   video_path char(256))", strCurTable.GetBuffer());
		//	m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
		//	sprintf(szCmdText, "CREATE INDEX [Pass_Time] ON [dbo].[%s] ([Pass_Time])", strCurTable.GetBuffer());
		//	m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
		//	sprintf(szCmdText, "CREATE INDEX [Obj_Id] ON [dbo].[%s] ([Obj_Id])", strCurTable.GetBuffer());
		//	m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
		//	sprintf(szCmdText, "CREATE INDEX [Special_Result] ON [dbo].[%s] ([Special_Result])", strCurTable.GetBuffer());
		//	m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
		//}

		//表存在则不创建
		try
		{
			sprintf(szCmdText, "if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[%s]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) \
							   Create TABLE %s(Record_Id bigint primary key IDENTITY   (1,   1)   NOT   NULL,\
							   Location_Id int NOT NULL,Pass_Time datetime NOT NULL, Plate_No char(20), Road_No int, Road_Name char(25),Road_Direct char(10),\
							   Car_Speed int, Obj_Id int, Time_Headway int, Over_Line int, Cross_Line int,\
							   Emergency_Stop int, Reverse_Run bit, Speeding bit, Special_Result bit, big_image_1_path varchar(256),\
							   big_image_2_path varchar(256), big_image_3_path varchar(256), big_image_4_path varchar(256),\
							   big_image_5_path varchar(256), small_image_path varchar(256), bin_image_path varchar(256),\
							   video_path varchar(256))",strCurTable.GetBuffer(),strCurTable.GetBuffer());
			m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
			sprintf(szCmdText, "if not exists (select * from sysindexes where name='Pass_Time')  CREATE INDEX [Pass_Time] ON [dbo].[%s] ([Pass_Time])", strCurTable.GetBuffer());
			m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
			sprintf(szCmdText, "if not exists (select * from sysindexes where name='Obj_Id') CREATE INDEX [Obj_Id] ON [dbo].[%s] ([Obj_Id])", strCurTable.GetBuffer());
			m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
			sprintf(szCmdText, "if not exists (select * from sysindexes where name='Special_Result') CREATE INDEX [Special_Result] ON [dbo].[%s] ([Special_Result])", strCurTable.GetBuffer());
			m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
		}
		catch (_com_error e)
		{
			m_fIsConnecting = FALSE;
			CString strErrorMessage;
			strErrorMessage.Format("创建表失败!错误信息:%s  错误码:%d", e.ErrorMessage(), GetLastError());
			SaveLog(strErrorMessage.GetBuffer());
			SaveLog(e.Description());
			OutPutMessage("创建数据表失败!");
		}

		///////视图创建 由查询软件创建
		//try
		//{
		//	char szCmdText[1024] = {0};
		//	sprintf(szCmdText, "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Hve_Data_View') DROP VIEW Hve_Data_View");
		//	m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);

		//}
		//catch (_com_error e)
		//{
		//	CString strErrorMessage;
		//	strErrorMessage.Format("删除视图失败! 错误信息:%s 错误码:%d", e.ErrorMessage(), GetLastError());
		//	SaveLog(strErrorMessage.GetBuffer());
		//	SaveLog(e.Description());
		//	OutPutMessage("删除视图失败...");
		//}
		
		//bool fIsCreateViewFault = true;
		//int iRetry = 0;
		//while(fIsCreateViewFault)
		//{
		//	if(iRetry++ == 5)
		//	{
		//		exit(1);  //reboot
		//	}

		//	try
		//	{
		//		_RecordsetPtr pPtr;
		//		CString strName;
		//		if(FAILED(pPtr.CreateInstance("ADODB.Recordset")))
		//		{
		//			OutPutMessage("创建ADO数据集失败...");
		//			return E_FAIL;
		//		}

		//		CString strConnectInfo;
		//		strConnectInfo.Format("Driver=SQL Server;Server=%s;DATABASE=%s;UID=%s;PWD=%s",
		//			m_strServerIP, m_strDataBase, m_strUserName, m_strPassword);
		//		CString strCommand = "SELECT name FROM sysobjects WHERE (name LIKE 'Hve_Data_%')";;
		//		if(FAILED(pPtr->Open(_variant_t(strCommand), _variant_t(strConnectInfo), adOpenStatic, adLockOptimistic, adCmdText)))
		//		{
		//			OutPutMessage("获取数据表名字失败...");
		//			pPtr.Release();
		//			return E_FAIL;
		//		}
		//		while(!pPtr->GetadoEOF())
		//		{
		//			CString strTmp = (char*)_bstr_t(pPtr->GetCollect("name"));
		//			strTmp.TrimRight();
		//			if(strName == "")
		//			{
		//				strName.Format("(SELECT * FROM %s)", strTmp);
		//			}
		//			else
		//			{
		//				strName.AppendFormat("union (SELECT * FROM %s)", strTmp);
		//			}
		//			pPtr->MoveNext();
		//		}
		//		pPtr->Close();
		//		pPtr.Release();

		//		char szCmdText[1024] = {0};
		//		sprintf(szCmdText,  "CREATE VIEW Hve_Data_View AS %s", strName);
		//		m_pConnection->Execute((_bstr_t)szCmdText, &RecordsAffected, adCmdText);
		//		fIsCreateViewFault = false;
		//	}
		//	catch (_com_error e)
		//	{
		//		fIsCreateViewFault = true;
		//		CString strErrorMessage;
		//		strErrorMessage.Format("创建视图失败... 错误码:%d", GetLastError());
		//		SaveLog(strErrorMessage.GetBuffer());
		//		SaveLog(e.Description());
		//		OutPutMessage("创建视图失败...");
		//	}
		//}
	
	}
Ejemplo n.º 14
0
//执行任务
bool __fastcall BeginJob(
    int JobMode,              //工作模式.1:本地文件模式;2:FTP文件模式
    AnsiString ListFileName,  //列表文件名
    AnsiString BillName,      //话单类型名称
    AnsiString DBName,        //数据库连接名
    AnsiString TableName,     //表名
    AnsiString LogFileName,   //日志文件名
    AnsiString TempPath,      //临时目录
    bool TransFieldValue,     //是否对字段值进行翻译
    int  MaxError,            //导入时允许的最大错误数
    bool VerifyFile,          //是否对文件进行格式检查
    AnsiString FTPServer,     //已配置好的FTP服务器名称,FTP文件模式
    AnsiString DirList,       //取文件的目录列表
    int FTPRetryCount         //列FTP文件时允许的最大重试次数
    )
{
  SaveLog(("开始运行任务."\
          "\n话单类型:" + BillName +
          "\n数据库连接:" + DBName +
          "\n导入到表:" + TableName +
          "\n日志文件:" + LogFileName +
          "\n导入数据库允许的最大错误数:" + IntToStr(MaxError) + "\n"
          "\n临时文件放置在:" + TempPath + "驱动器\n"
          ).c_str());
  if(JobMode == 1)
  {
    SaveLog(("话单文件列表是" + ListFileName + ".\n").c_str());
  }
  else if(JobMode == 2)
  {
    SaveLog(("搜索目录列表是" + DirList + "\n" +
      "FTP服务器:" + FTPServer).c_str());
  }  
  bool Result = false;
  frmMain     = NULL;
  TStringList * FileList = NULL;
  TIdFTP      * IdFTP    = NULL;
  try
  {
    frmMain = new TfrmMain(Application);
    if(TempPath != "")
    {
      if(!DirectoryExists(TempPath) && !CreateDir(TempPath))
        SaveLog(("指定的临时文件夹无效,已改为使用默认的临时文件夹:" + frmMain->TempDirectory + "\n").c_str());
      else
      {
        if(TempPath.SubString(TempPath.Length(),1) != "\\")
          TempPath = TempPath + "\\";
        frmMain->TempDirectory = TempPath;
      }
    }
    if(!frmMain->DBConfig->IsDBNameExists(DBName))
      throw new Exception("在配置文件中找不到" + DBName + "的配置信息");
    frmExportToDB = new TfrmExportToDB(NULL);
    frmExportToDB->txtDBServer->Text = frmMain->DBConfig->GetDBAttributeValue(DBName,"Server");
    if(frmExportToDB->txtDBServer->Text == "")
      throw new Exception("没有为" + DBName + "配置服务器地址");
    frmExportToDB->cbxDBType->ItemIndex =
      frmExportToDB->cbxDBType->Items->IndexOf(
        frmMain->DBConfig->GetDBAttributeValue(DBName,"DBType"));
    if(frmExportToDB->cbxDBType->ItemIndex < 0)
    {
      throw new Exception("为" + DBName + "配置的数据库类型不正确");
    }
    FileList = new TStringList;
    if(JobMode == 1)
    {
      FileList->LoadFromFile(ListFileName);
      for(int n = FileList->Count - 1;n > -1;n--)
      {
        if(FileList->Strings[n] == "")
          FileList->Delete(n);
      }
    }
    else  //FTP模式
    {
      if(!frmMain->FTPConfig->IsFTPNameExists(FTPServer))
      {
        throw new Exception("在FTP配置文件中找不到指定的FTP服务器");
      }
      IdFTP = new TIdFTP(NULL);
      IdFTP->Host = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Server");
      try
      {
        IdFTP->Port = StrToInt(frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Port"));
      }
      catch(...)
      {
        IdFTP->Port = 21;
      }
      IdFTP->Username = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"UserName");
      IdFTP->Password = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Password",true);
      IdFTP->Passive  = frmMain->FTPConfig->GetFTPAttributeValue(FTPServer,"Mode").UpperCase() == "PASV";
      AnsiString FTPString  = "ftp://" +
        frmMain->FTPConfig->EncryFTPString(IdFTP->Username) + ":" +
        frmMain->FTPConfig->EncryFTPString(IdFTP->Password) + "@" + IdFTP->Host + ":" + IntToStr(IdFTP->Port);
      AnsiString PasvString;
      if(IdFTP->Passive)
        PasvString = "|PASV|";
      else
        PasvString = "||";
      int ErrCount = 0;
      while(true)
      {
        AnsiString Status;
        TStringList * FTPDirList  = new TStringList;
        AnsiString CurFTPPath     = "";
        AnsiString SearchFileName = "";
        try
        {
          if(IdFTP->Connected())
            IdFTP->Disconnect();
          Status = "连接FTP服务器" + IdFTP->Host;
          SaveLog((Status + "\n").c_str());
          IdFTP->Connect(true,FTPTimeout);
          Status = "获取FTP文件列表";
          SaveLog((Status + "\n").c_str());
          FTPDirList->Clear();
          FTPDirList->LoadFromFile(DirList);
          AnsiString FileName;
          for(int n = FTPDirList->Count - 1;n > -1;n--)
          {
            if(FTPDirList->Strings[n] == "")
              FTPDirList->Delete(n);
          }
          FileList->Clear();
          if(FTPDirList->Count == 0)
            FTPDirList->Add("");
          for(int n = 0;n < FTPDirList->Count;n++)
          {
            CurFTPPath = FTPDirList->Strings[n];            
            if(CurFTPPath == "")
            {
              CurFTPPath     = "/";
              SearchFileName = "";
            }
            else
            {
              int pos = StrRScan(CurFTPPath.c_str(),"/",-1);
              if(pos > -1)
              {
                SearchFileName = CurFTPPath.SubString(pos + 2,CurFTPPath.Length() - pos - 1);
                CurFTPPath     = CurFTPPath.SubString(1,pos + 1);
              }
              else
              {
                SaveLog(("搜索路径[" + CurFTPPath + "]不正确,已跳过该行\n").c_str());
                continue;
              }
            }
            Status = "获取文件列表" + CurFTPPath + SearchFileName;
            try
            {
              IdFTP->ChangeDir(CurFTPPath);
            }
            catch(Exception * E)
            {
              if(E->Message.Pos("No such file or directory.") > 0)
              {
                SaveLog(("搜索路径[" + CurFTPPath + "]不正确,服务器上没有找到该目录,已放弃对该目录的搜索\n").c_str());
                continue; 
              }
              else
              {
                throw new Exception(E->Message);
              }
            }
            if(SearchFileName != "" && SearchFileName.Pos("*") < 1 && SearchFileName.Pos("?") < 1)
            {
              //检查SearchFileName在FTP上是否是目录
              IdFTP->List(NULL,"",true);
              for(int k = 0;k < IdFTP->DirectoryListing->Count;k++)
              {
                FileName = IdFTP->DirectoryListing->Items[k]->FileName;
                if(FileName == "." || FileName == "..")
                  continue;
                if(FileName.LowerCase() == SearchFileName.LowerCase() && IdFTP->DirectoryListing->Items[k]->ItemType == ditDirectory) //SearchFileName是一个目录
                {
                  CurFTPPath = CurFTPPath + FileName + "/";
                  SearchFileName = "";
                  IdFTP->ChangeDir(CurFTPPath);
                  break;
                }
              }
            }
            IdFTP->List(NULL,SearchFileName,true);
            int FileCount = 0;
            for(int k = 0;k < IdFTP->DirectoryListing->Count;k++)
            {
              FileName = IdFTP->DirectoryListing->Items[k]->FileName;
              if(FileName == "." || FileName == ".." || IdFTP->DirectoryListing->Items[k]->ItemType == ditDirectory) //目录
                continue;
              FileList->Add(FTPString + CurFTPPath + PasvString + FileName);
              ++FileCount;
            }
            SaveLog((CurFTPPath + SearchFileName + "  找到" + IntToStr(FileCount) + "个文件").c_str());
          }
          delete IdFTP;
          IdFTP = NULL;
          delete FTPDirList;
          FTPDirList = NULL;
          SaveLog(("共搜索到" + IntToStr(FileList->Count) + "个文件.\n").c_str());
          for(int n = 0;n < FileList->Count;n++)
          {
            SaveLog(("找到文件:" + GetFullFTPFileName(FileList->Strings[n])).c_str());
          }
          break;
        }
        catch(Exception * E)
        {
          ++ErrCount;
          if((FTPRetryCount > 0 && ErrCount > FTPRetryCount) || (FTPRetryCount == 0 && ErrCount > 1000))
          {
            if(FTPDirList != NULL)
            {
              delete FTPDirList;
              FTPDirList = NULL;
            }
            ProcessExitCode = 5;
            throw new Exception(Status + "发生错误:" + E->Message);
          }
          else
          {
            SaveLog((Status + "发生错误:" + E->Message + "  重试" + IntToStr(ErrCount) + "\n").c_str());
          }
        }
      }
    }
    frmExportToDB->txtDBUserName->Text = frmMain->DBConfig->GetDBAttributeValue(DBName,"UserName");
    frmExportToDB->txtDBPassword->Text = frmMain->DBConfig->GetDBAttributeValue(DBName,"Password",true);
    frmExportToDB->cbxDataBases->Items->Add(frmMain->DBConfig->GetDBAttributeValue(DBName,"DataBase"));
    frmExportToDB->cbxDataBases->ItemIndex = 0;
    frmExportToDB->txtDBPort->Text = frmMain->DBConfig->GetDBAttributeValue(DBName,"Port");
    frmExportToDB->txtTableName->Text = TableName;
    frmExportToDB->txtMaxError->Text = IntToStr(MaxError);
    frmExportToDB->cbxTransFieldValue->Checked = TransFieldValue;
    if(frmExportToDB->LoadFileList(FileList,BillName))
    {
      if(SlentMode)
      {
        if(!frmExportToDB->ManualStartJob())
        {
          if(frmExportToDB->TermByUser)
          {
            ProcessExitCode = 98;
            throw new Exception("任务被用户中止");
          }
          else
          {
            throw new Exception("发生错误");
          }
        }
      }
      else
      {
        frmExportToDB->btnStartClick(NULL);
        frmExportToDB->ShowModal();
      }
      Result = true;
    }
    else
    {
      ProcessExitCode = 5;
      throw new Exception("加载文件列表失败");
    }
  }
  catch(Exception * E)
  {
    ShowErrorMessage(Application->Handle,(E->Message).c_str(),false,99);
    if(ProcessExitCode == 0)
      ProcessExitCode = 99;
    Result = false;
  }
  SaveLog("*****************任务结束.*******************");
  if(IdFTP != NULL)
  {
    delete IdFTP;
    IdFTP = NULL;
  }
  if(FileList != NULL)
  {
    delete FileList;
    FileList = NULL;
  }
  if(frmExportToDB != NULL)
  {
    delete frmExportToDB;
    frmExportToDB = NULL;
  }
  if(frmMain != NULL)
  {
    delete frmMain;
    frmMain = NULL;
  }
  return Result;
}