Exemplo n.º 1
0
//---------------------------------------------------------------------------
//Процедура получения книги из базы
void __fastcall TMainForm::GetBook(TObject *Sender){
    HWND hWnd;
    AnsiString filter,path;
    path=getenv("TEMP");
    path+="\\temp.rar";
    int bkod=DM->dsTree->FieldByName("KBOOK")->Value;
    filter.printf("KOD=%d",bkod);
    DM->dsBook->Filter=filter;
    DM->dsBook->Filtered=true;
    TBlobField *bl = (TBlobField *)DM->dsBook->FieldByName("BOOK");
    bl->SaveToFile(path);
    ShellExecute(hWnd, "open",path.c_str(), NULL, NULL, SW_SHOWNORMAL);
    DM->dsBook->Filtered=false;
}
Exemplo n.º 2
0
void __fastcall TMainForm::ButtonLoadClick(TObject *Sender)
{
  if (OraQueryAllJournal->RecordCount == 0 || OraQueryDocs->RecordCount == 0)
  {
    ShowMessage ("Не выбран файл для загрузки !");
    return;
  }

  Screen->Cursor = crHourGlass;

  AnsiString temp_dir;
  TRegistry * reg = new TRegistry (KEY_READ);
  try
  {
    reg->RootKey = HKEY_LOCAL_MACHINE;
    reg->OpenKey ("\\SOFTWARE\\Gis center\\Journal", true);

    temp_dir = reg->ReadString ("TempDir");
  }
  __finally
  {
    safe_delete (reg);
//    delete reg;
  }

  if (temp_dir.IsEmpty())
  {
    ShowMessage ("Не задана временная директория для выгрузки файлов !");
    Screen->Cursor = crDefault;
    return;
  }

  ProgressForm->Show();

  AnsiString fn;

  TOraQuery * docQuery = new TOraQuery (this);
  try
  {
    docQuery->SQL->Text = "SELECT DOC_NAME, DOC_TEXT FROM " + m_shema + "." +
                           m_blob_table + " WHERE " + m_blob_primary_key + " = " +
                           OraQueryDocs->Fields->FieldByName(m_blob_primary_key)->AsString;
    docQuery->Open();
    docQuery->First();

    fn = docQuery->Fields->FieldByName ("DOC_NAME")->AsString;
    TBlobField * blob = (TBlobField*)(docQuery->Fields->FieldByName("DOC_TEXT"));
    blob->SaveToFile (temp_dir + "\\" + fn);

    docQuery->Close();
  }
  __finally
  {
    safe_delete (docQuery);
    //delete docQuery;
  }

  m_loading_docs [OraQueryDocs->Fields->FieldByName(m_blob_primary_key)->AsInteger] = temp_dir + "\\" + fn;
  ButtonSaveDoc->Enabled = true;

  Files.insert(temp_dir + "\\" + fn);

  // Проверка ассоциации
  AnsiString path;

  reg = new TRegistry (KEY_READ);
  try
  {
    reg->RootKey = HKEY_LOCAL_MACHINE;
    reg->OpenKey ("\\SOFTWARE\\Gis center\\Journal\\Associations", true);

    path = reg->ReadString (ExtractFileExt (fn).Delete(1, 1));

    reg->CloseKey();
  }
  __finally
  {
    safe_delete (reg);
    //delete reg;
  }

  if (!path.IsEmpty())
  {
    STARTUPINFO si = {sizeof (si)};
    PROCESS_INFORMATION pi;

    AnsiString dir = GetCurrentDir();
    SetCurrentDir (temp_dir);
    if (CreateProcess (NULL, ("\"" + path + "\" \"" +fn + "\"").c_str(), 0, 0, FALSE, 0,0,0, &si, &pi))
    {
      CloseHandle (pi.hThread);
      CloseHandle (pi.hProcess);
    }
    SetCurrentDir (dir);
  }
  else
  {
    ShellExecute(0, "open", AnsiString (temp_dir + "\\" + fn).c_str(), NULL, NULL, SW_SHOWNORMAL);
  }

  ProgressForm->Close();

  Screen->Cursor = crDefault;
}