Beispiel #1
0
  libtocc::FileInfo FSHandler::get_by_path(std::string path)
  {
    // First, we check if the specified path matches exactly with a
    // Traditional Path. If it is, we return that file.
    // Then, we check if the path contains tags and title of a file. We assume
    // each directory in the path is a tag, and the last element is title of
    // a file. If it matches a single file, we return that.

    /*
     * First try: Checking if path exactly matches a Traditional Path.
     */
    // TODO: First, check the traditional path.

    /*
     * Second try: Last element is the file title and others are tags.
     */
    std::vector<std::string> path_items = split_string(path, '/');

    if (path_items.empty())
    {
      // Returning a NULL file info.
      return get_empty_file_info();
    }

    // Assume the last element is the file title.
    libtocc::Title title_expr(path_items.back().c_str());
    path_items.pop_back();
    libtocc::And main_and(title_expr);

    if (!path_items.empty())
    {
      // Each of the items considered a tag.
      std::vector<std::string>::iterator path_items_iterator = path_items.begin();
      for (; path_items_iterator != path_items.end(); path_items_iterator++)
      {
        libtocc::Tag tag_expr(path_items_iterator->c_str());
        main_and.add(tag_expr);
      }
    }

    // Executing the query.
    libtocc::Query second_query(main_and);
    libtocc::FileInfoCollection second_query_result =
        this->libtocc_manager->search_files(second_query);

    if (second_query_result.size() == 1)
    {
      // If exactly one file found, this is what we wanted.
      libtocc::FileInfoCollection::Iterator query_result_iterator(&second_query_result);
      // Copying the pointer.
      libtocc::FileInfo result(*query_result_iterator.get());

      return result;
    }

    // Nothing found. Returning a NULL FileInfo.
    return get_empty_file_info();
  }
bool ADRES_RAPOR_FILTRESI_BATCH::RAPOR_VERILERINI_OLUSTUR ()
{

    M_ADRES_KAYIT_RAPORU_BILGILERI.clear();
    M_ADRES_ETIKET_BILGILERI.clear();
    M_TOPLU_MAIL_BILGILERI.clear();
    M_SMS_BILGILERI.clear();

    QList<int>  kayit_id_listesi;
    QStringList ADRES_KAYIT_LISTESI;

    SQL_QUERY second_query ( DB );


    if ( m_ui->checkBox_grup_secimi->isChecked() EQ true ) {
        kayit_id_listesi.clear();
        kayit_id_listesi = GRP_GRUBA_EKLI_KAYITLARI_BUL( E9_PROGRAMI , ADRES_MODULU , m_grup_idleri  );
        if ( kayit_id_listesi.isEmpty() EQ true ) {
            MSG_ERROR("Gruba ekli kayıt bulunamadı.",NULL);
            return false;
        }
    }

    SQL_QUERY sql_query ( DB );

    QString where_str = "";

    if ( m_ui->checkBox_adres_kaydi_secimi->isChecked() EQ true ) {

        int   listedeki_kayit_sayisi = m_ui->tableWidget_adres_kayitlari->rowCount();

        for ( int i = 0; i < listedeki_kayit_sayisi; i++ ) {
            ADRES_KAYIT_LISTESI.append ( m_ui->tableWidget_adres_kayitlari->item ( i, 0 )->text());
        }

        if ( where_str.isEmpty() EQ false ) {
            where_str.append (  " OR " );
        }

        where_str.append (  "adres_id = :adres_id_0 " );

        if ( listedeki_kayit_sayisi > 1 ) {
            for ( int i = 1 ; i < listedeki_kayit_sayisi ; i++ ) {
                where_str.append(" OR adres_id = :adres_id_"+ QVariant(i).toString());
            }
        }
    }

    if ( m_ui->checkBox_grup_secimi->isChecked() EQ true ) {
        for ( int i = 0; i < kayit_id_listesi.size() ; i++ ) {
            if ( where_str.isEmpty() EQ false ) {
                where_str.append (  " OR " );
            }

            where_str.append ( QString(" adres_id = %1").arg(QVariant(kayit_id_listesi.at(i)).toString()));
        }
    }

    if ( m_adres_kayit_turu NE SAHIS_ARTI_FIRMA ) {

        if ( where_str.isEmpty() EQ false ) {
            where_str.append (  " AND " );
        }

        where_str.append (  "adres_kart_turu = :adres_kart_turu ");
    }

    sql_query.PREPARE_SELECT ("adr_adresler","adres_id, firma_sahis_adi, adres_satiri_1, adres_satiri_2, adres_satiri_3,"
                              "ilce, semt, ulke, sehir, website, email, tel_ulke_kodu, "
                              "tel_alan_kodu, telefon,adres_kart_turu,cep_tel_ulke_kodu,"
                              "cep_tel_gsm_kodu,cep_telefonu,is_tel_ulke_kodu,"
                              "is_tel_alan_kodu,is_telefonu", where_str );

    if ( ADRES_KAYIT_LISTESI.size() > 0 ) {

        sql_query.SET_VALUE ( ":adres_id_0", ADRES_KAYIT_LISTESI.at(0) );
        for ( int i = 1; i < ADRES_KAYIT_LISTESI.size(); i++ ) {
            sql_query.SET_VALUE ( ":adres_id_" + QVariant(i).toString(), ADRES_KAYIT_LISTESI.at (i) );
        }
    }

    if ( m_adres_kayit_turu NE SAHIS_ARTI_FIRMA ) {
        sql_query.SET_VALUE ( ":adres_kart_turu", m_adres_kayit_turu );
    }

    if ( sql_query.SELECT("firma_sahis_adi") EQ 0 ) {
        return true;
    }

    QString telefon_bilgisi_1;
    QString telefon_bilgisi_2;
    QString cep_telefonu;

    while ( sql_query.NEXT() EQ true ) {

        telefon_bilgisi_1.clear();
        telefon_bilgisi_1 = sql_query.VALUE ( "tel_ulke_kodu" ).toString() + "-" +
                            sql_query.VALUE ( "tel_alan_kodu" ).toString() + "-" +
                            sql_query.VALUE ( "telefon" ).toString();

        telefon_bilgisi_2.clear();
        telefon_bilgisi_2 = sql_query.VALUE ( "is_tel_ulke_kodu" ).toString() + "-" +
                            sql_query.VALUE ( "is_tel_alan_kodu" ).toString() + "-" +
                            sql_query.VALUE ( "is_telefonu" ).toString();

        cep_telefonu.clear();

        cep_telefonu = sql_query.VALUE ( "cep_tel_ulke_kodu" ).toString() + "-" +
                       sql_query.VALUE ( "cep_tel_gsm_kodu" ).toString() + "-" +
                       sql_query.VALUE ( "cep_telefonu" ).toString();



        if ( sql_query.VALUE("cep_telefonu").toString().isEmpty() EQ false AND
                sql_query.VALUE("cep_tel_gsm_kodu").toString().isEmpty() EQ false AND
                sql_query.VALUE("cep_tel_ulke_kodu").toString().isEmpty() EQ false) {
            if ( M_SMS_BILGILERI.isEmpty() EQ false ) {
                M_SMS_BILGILERI.append(",");
            }

            M_SMS_BILGILERI .append(QString( sql_query.VALUE("cep_tel_ulke_kodu").toString() + sql_query.VALUE("cep_tel_gsm_kodu").toString() +
                                             sql_query.VALUE("cep_telefonu").toString()));
        }

        QString adres_kayit_raporu_satiri = sql_query.VALUE ( "firma_sahis_adi" ).toString() + "\t" +
                                            sql_query.VALUE ( "website" ).toString() + "\t" + sql_query.VALUE ( "email" ).toString() + "\t" + telefon_bilgisi_1
                                            + "\t" + telefon_bilgisi_2 + "\t" + cep_telefonu;

        M_ADRES_KAYIT_RAPORU_BILGILERI.append ( adres_kayit_raporu_satiri );

        QString adres_etiketleri_satiri = sql_query.VALUE ( "firma_sahis_adi" ).toString() + "\t" +
                                          sql_query.VALUE ( "adres_satiri_1" ).toString() + "\t" +
                                          sql_query.VALUE ( "adres_satiri_2" ).toString() + "\t" +
                                          sql_query.VALUE ( "adres_satiri_3" ).toString() + "\t" +
                                          sql_query.VALUE ( "semt" ).toString() + "\t" +
                                          sql_query.VALUE ( "ilce" ).toString() + "\t" +
                                          sql_query.VALUE ( "sehir" ).toString() + "\t" +
                                          sql_query.VALUE ( "ulke" ).toString() + "\t" +
                                          sql_query.VALUE ( "email" ).toString() + "\t";

        //int         adres_kart_turu =   sql_query.VALUE("adres_kart_turu").toInt();

        if ( M_ADRES_ETIKET_BILGILERI.contains(adres_etiketleri_satiri) EQ false ) {
            M_ADRES_ETIKET_BILGILERI.append ( adres_etiketleri_satiri );
        }


        second_query.PREPARE_SELECT ( "adr_emailler","adres_kayit_id,email_adresi","adres_kayit_id = :adres_kayit_id" );
        second_query.SET_VALUE ( ":adres_kayit_id", sql_query.VALUE( "adres_id" ).toInt() );
        if ( second_query.SELECT() EQ 0 ) {
            continue;
        }
        while ( second_query.NEXT() EQ true ) {
            if( second_query.VALUE(0).toString().isEmpty() EQ false AND second_query.VALUE(1).toString().isEmpty() EQ false ) {
                M_TOPLU_MAIL_BILGILERI.append ( QString(second_query.VALUE(0).toString() + ":" + second_query.VALUE(1).toString()) );
            }
        }
    }

    return true;
}
Beispiel #3
0
  libtocc::FileInfo FSHandler::get_by_path(std::string path)
  {
    // First, we check if the specified path matches exactly with a
    // Traditional Path. If it is, we return that file.
    // Then, we check if the path contains tags and title of a file. We assume
    // each directory in the path is a tag, and the last element is title of
    // a file. If it matches a single file, we return that.

    /*
     * First try: Checking if path exactly matches a Traditional Path.
     */
    // FIXME: The following block is commented, because of a bug in Unqlite:
    //        If database become big, this cause Segfault in UnQlite.
//    try
//    {
//      libtocc::FileInfo result =
//          this->libtocc_manager->get_file_by_traditional_path(path.c_str());
//
//      return result;
//    }
//    catch (libtocc::DatabaseScriptLogicalError& error)
//    {
//      // Nothing found.
//    }

    /*
     * Second try: Last element is the file title and others are tags.
     */
    std::vector<std::string> path_items = split_string(path, '/');

    if (path_items.empty())
    {
      // Returning a NULL file info.
      return get_empty_file_info();
    }

    // Assume the last element is the file title.
    libtocc::Title title_expr(path_items.back().c_str());
    path_items.pop_back();
    libtocc::And main_and(title_expr);

    if (!path_items.empty())
    {
      // Each of the items considered a tag.
      std::vector<std::string>::iterator path_items_iterator = path_items.begin();
      for (; path_items_iterator != path_items.end(); path_items_iterator++)
      {
        if (*path_items_iterator == ".." || *path_items_iterator == ".")
        {
          // Ignore . or ..
          continue;
        }
        libtocc::Tag tag_expr(path_items_iterator->c_str());
        main_and.add(tag_expr);
      }
    }

    // Executing the query.
    libtocc::Query second_query(main_and);
    libtocc::FileInfoCollection second_query_result =
        this->libtocc_manager->search_files(second_query);

    if (second_query_result.size() == 1)
    {
      // If exactly one file found, this is what we wanted.
      libtocc::FileInfoCollection::Iterator query_result_iterator(&second_query_result);
      // Copying the pointer.
      libtocc::FileInfo result(*query_result_iterator.get());

      return result;
    }

    // Nothing found. Returning a NULL FileInfo.
    return get_empty_file_info();
  }