Clomosy | Forum Ana Sayfa
Forum Anasayfa Forum Anasayfa > Genel Programlama > Clomosy ile değişken kullanımı
  Aktif Konular Aktif Konular RSS - Açılan Console Ekranını Kapatma
  SSS SSS  Forumu Ara   Etkinlikler   Kayıt Ol Kayıt Ol  Giriş Giriş

Clomosy Resmi Forum Sitesidir. Amacımız kullanıcılarımıza, iş ortaklarımıza, danışmanlara, yazılımcılara programlarımız hakkında destek ve bilgi vermektir.

Açılan Console Ekranını Kapatma

 Yanıt Yaz Yanıt Yaz
Yazar
Mesaj
  Konu Arama Konu Arama  Topic Seçenekleri Topic Seçenekleri
M-Guney Açılır Kutu İzle
Kıdemli Üye
Kıdemli Üye


Kayıt Tarihi: 16 Eylül 2025
Konum: Konya, Meram, K
Durum: Aktif Değil
Puanlar: 153
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı M-Guney Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Konu: Açılan Console Ekranını Kapatma
    Gönderim Zamanı: 2 Saat 35 Dakika Önce Saat 14:46
Kodumda eğer ki bilgiler yanlış girilirse timeout veriyor ve ardından bir console ekranı açılıyor o ekranı kapatmanın yolunu bulamadım. Mobilde o ekran geldikten sonra Edit inputlarını bozuyor değişmiş olan input u görmüyor eskiye sabit kalıyor.

var
  ConfigList : TClStringList;
  ConfigPath : String;
  WatchdogTimer : TClTimer;
  IsChecking : Boolean;
  InheritedForm : TclForm;
  CheckQuery : TClSqlQuery;

void InitForm(AForm : TclForm);
{
  InheritedForm = AForm;
}

void InitConfig;
{
  try
    ConfigPath = Clomosy.AppFilesPath + 'db_config.txt';
    
    if (ConfigList == nil)
    {
      ConfigList = Clomosy.StringListNew;
    }
    
    if (clFileExists('db_config.txt', Clomosy.AppFilesPath))
    {
      ConfigList.Text = clLoadFromFile(ConfigPath);
    }
  except
    ShowMessage('InitConfig Exception: ' + LastExceptionMessage);
  }
}

void SaveDBConnection(AHost, AUser, APass, ADBName : String; APort: Integer);
{
  try
    if (ConfigList == nil) { ConfigList = Clomosy.StringListNew; }
    ConfigList.Clear;
    ConfigList.Add('Host=' + AHost);
    ConfigList.Add('User=' + AUser);
    ConfigList.Add('Pass=' + APass);
    ConfigList.Add('DB=' + ADBName);
    ConfigList.Add('Port=' + IntToStr(APort));
    
    clSaveToFile(ConfigPath, ConfigList.Text);
    ShowMessage('Database configuration saved successfully.');
  except
    ShowMessage('SaveDBConnection Exception: ' + LastExceptionMessage);
  }
}

void OnHealthTimeout;
{
  if (IsChecking == True)
  {
    IsChecking = False;
    WatchdogTimer.Enabled = False;
    ShowMessage('Connection Timeout: Server 5 saniye içinde cevap vermedi.');
  }
}

void SetupTimer;
{
  if ((WatchdogTimer == nil) && (InheritedForm <> nil))
  {
    WatchdogTimer = InheritedForm.AddNewTimer(InheritedForm, 'WatchdogTimer', 5000);
    WatchdogTimer.Enabled = False;
    InheritedForm.AddNewEvent(WatchdogTimer, tbeOnTimer, 'OnHealthTimeout');
  }
}

function CheckDatabaseHealth(AHost, AUser, APass, ADBName : String; APort: Integer): Boolean;
{
  try
    Result = False;
    SetupTimer;
    
    if (WatchdogTimer == nil)
    {
      ShowMessage('Hata: Timer başlatılamadı. InitForm çağrıldığından emin olun.');
      exit;
    }

    IsChecking = True;
    WatchdogTimer.Interval = 5000; 
    WatchdogTimer.Enabled = True;

    // Step 1: Connectivity Check
    Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
    
    // Step 2: Lazy Initialization of Query
    CheckQuery.SQL.Text = 'SELECT DB_ID(' + QuotedStr(ADBName) + ') as db_found';
    CheckQuery.Open;
    
    if (IsChecking == True)
    {
      IsChecking = False;
      WatchdogTimer.Enabled = False;

      if (CheckQuery.FieldByName('db_found').AsString == '')
      {
        ShowMessage('Hata: Database bulunamadı.');
        Result = False;
      }
      else
      {
        Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
        Result = True;
      }
    }
  except
    IsChecking = False;
    if (WatchdogTimer <> nil)
    {
      WatchdogTimer.Enabled = False;
    }
    ShowMessage('Bağlantı Hatası: ' + LastExceptionMessage);
    Result = False;
  }
}

function LoadAndConnect: Boolean;
var
  vHost, vUser, vPass, vDB : String;
  vPort : Integer;
{
  InitConfig;
  try
    Result = False;
    if (ConfigList.Count > 0)
    {
      vHost = ConfigList.Values['Host'];
      vUser = ConfigList.Values['User'];
      vPass = ConfigList.Values['Pass'];
      vDB   = ConfigList.Values['DB'];
      
      if (ConfigList.Values['Port'] == '')
      {
        vPort = 1433;
      }
      else
      {
        vPort = StrToInt(ConfigList.Values['Port']);
      }
  
      Result = CheckDatabaseHealth(vHost, vUser, vPass, vDB, vPort);
    }
    else 
    {
      ShowMessage('Ayarlar bulunamadı.');
      Result = False;
    }
  except
    ShowMessage('LoadAndConnect Exception: ' + LastExceptionMessage);
    Result = False;
  }
}
{
  WatchdogTimer = nil;
}
https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
M-Guney Açılır Kutu İzle
Kıdemli Üye
Kıdemli Üye


Kayıt Tarihi: 16 Eylül 2025
Konum: Konya, Meram, K
Durum: Aktif Değil
Puanlar: 153
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı M-Guney Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 2 Saat 31 Dakika Önce Saat 14:50
Kodun Doğru Hali





var
  ConfigList : TClStringList;
  ConfigPath : String;
  WatchdogTimer : TClTimer;
  IsChecking : Boolean;
  InheritedForm : TclForm;
  CheckQuery : TClSqlQuery;

void InitForm(AForm : TclForm);
{
  InheritedForm = AForm;
}

void InitConfig;
{
  try
    ConfigPath = Clomosy.AppFilesPath + 'db_config.txt';
    
    if (ConfigList == nil)
    {
      ConfigList = Clomosy.StringListNew;
    }
    
    if (clFileExists('db_config.txt', Clomosy.AppFilesPath))
    {
      ConfigList.Text = clLoadFromFile(ConfigPath);
    }
  except
    ShowMessage('InitConfig Exception: ' + LastExceptionMessage);
  }
}

void SaveDBConnection(AHost, AUser, APass, ADBName : String; APort: Integer);
{
  try
    if (ConfigList == nil) { ConfigList = Clomosy.StringListNew; }
    ConfigList.Clear;
    ConfigList.Add('Host=' + AHost);
    ConfigList.Add('User=' + AUser);
    ConfigList.Add('Pass=' + APass);
    ConfigList.Add('DB=' + ADBName);
    ConfigList.Add('Port=' + IntToStr(APort));
    
    clSaveToFile(ConfigPath, ConfigList.Text);
    ShowMessage('Database configuration saved successfully.');
  except
    ShowMessage('SaveDBConnection Exception: ' + LastExceptionMessage);
  }
}

void OnHealthTimeout;
{
  if (IsChecking == True)
  {
    IsChecking = False;
    WatchdogTimer.Enabled = False;
    ShowMessage('Connection Timeout: Server 5 saniye içinde cevap vermedi.');
  }
}

void SetupTimer;
{
  if ((WatchdogTimer == nil) && (InheritedForm <> nil))
  {
    WatchdogTimer = InheritedForm.AddNewTimer(InheritedForm, 'WatchdogTimer', 5000);
    WatchdogTimer.Enabled = False;
    InheritedForm.AddNewEvent(WatchdogTimer, tbeOnTimer, 'OnHealthTimeout');
  }
}

function CheckDatabaseHealth(AHost, AUser, APass, ADBName : String; APort: Integer): Boolean;
{
  try
    Result = False;
    SetupTimer;
    
    if (WatchdogTimer == nil)
    {
      ShowMessage('Hata: Timer başlatılamadı. InitForm çağrıldığından emin olun.');
      exit;
    }

    IsChecking = True;
    WatchdogTimer.Interval = 5000; 
    WatchdogTimer.Enabled = True;

    // Step 1: Connectivity Check
    Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
    
    // Step 2: Lazy Initialization of Query
    CheckQuery = Clomosy.DBSQLServerQuery;
    CheckQuery.SQL.Text = 'SELECT DB_ID(' + QuotedStr(ADBName) + ') as db_found';
    CheckQuery.Open;
    
    if (IsChecking == True)
    {
      IsChecking = False;
      WatchdogTimer.Enabled = False;

      if (CheckQuery.FieldByName('db_found').AsString == '')
      {
        ShowMessage('Hata: Database bulunamadı.');
        Result = False;
      }
      else
      {
        Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
        Result = True;
      }
    }
  except
    IsChecking = False;
    if (WatchdogTimer <> nil)
    {
      WatchdogTimer.Enabled = False;
    }
    ShowMessage('Bağlantı Hatası: ' + LastExceptionMessage);
    Result = False;
  }
}

function LoadAndConnect: Boolean;
var
  vHost, vUser, vPass, vDB : String;
  vPort : Integer;
{
  InitConfig;
  try
    Result = False;
    if (ConfigList.Count > 0)
    {
      vHost = ConfigList.Values['Host'];
      vUser = ConfigList.Values['User'];
      vPass = ConfigList.Values['Pass'];
      vDB   = ConfigList.Values['DB'];
      
      if (ConfigList.Values['Port'] == '')
      {
        vPort = 1433;
      }
      else
      {
        vPort = StrToInt(ConfigList.Values['Port']);
      }
  
      Result = CheckDatabaseHealth(vHost, vUser, vPass, vDB, vPort);
    }
    else 
    {
      ShowMessage('Ayarlar bulunamadı.');
      Result = False;
    }
  except
    ShowMessage('LoadAndConnect Exception: ' + LastExceptionMessage);
    Result = False;
  }
}
{

  WatchdogTimer = nil;
}





https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
 Yanıt Yaz Yanıt Yaz

Forum Atla Forum İzinleri Açılır Kutu İzle

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.

Bu Sayfa 0,047 Saniyede Yüklendi.