DbGrid Seçilen Kayda işlem yaptıramıyorum
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
-
- Üye
- Mesajlar: 37
- Kayıt: 13 Oca 2016 10:53
DbGrid Seçilen Kayda işlem yaptıramıyorum
bu uygulamam server client mantığı ile çalışıyor uzatmadan sorunumu dile getireyim sol taraftaki iplere dosya gönderme işlemiyorum yapıyorum tümüne gönder dediğimde sorun yok gönderme işlemini yapıyor ama seçili olana gönder dediğimde dosya gönderme işlemi yapılamıyor sadece dosyayı belirttiğim yola yazıyor ama içerik eklemiyor bilgisi olan arkadaşlar yardım ederse sevinirim
- Dosya ekleri
-
- 2.png (2.07 KiB) 1228 kere görüntülendi
- fesiharslan
- Üye
- Mesajlar: 591
- Kayıt: 20 Eki 2006 11:37
- Konum: Erzurum
- İletişim:
Re: DbGrid Seçilen Kayda işlem yaptıramıyorum
Tüm IP ve Seçili IP kod kısımlarını paylaşma imkanınız olursa kod yapısından yardımcı olmaya çalışalım.
-
- Üye
- Mesajlar: 37
- Kayıt: 13 Oca 2016 10:53
Re: DbGrid Seçilen Kayda işlem yaptıramıyorum
fesiharslan yazdı:Tüm IP ve Seçili IP kod kısımlarını paylaşma imkanınız olursa kod yapısından yardımcı olmaya çalışalım.
procedure TForm1.Button2Click(Sender: TObject);
var
I, A: Integer;
begin
if ServerSocket1.Active = True then
begin
OpenDialog1.Filter := 'Ini Dosyalar (*.ini)'; // you can add more choices by adding | and followed by description and (*.extension)
OpenDialog1.FilterIndex := 1; // Here you follow which index number from above you want
if OpenDialog1.Execute then
begin
ServerSocket2.Open;
Edit1.Text := ExtractFileName(OpenDialog1.FileName); // To send as filename after
if CheckBox1.Checked = True then
begin
// A := ServerSocket1.Socket.ActiveConnections - 1;
// for I := 0 to A do
// begin
// ServerSocket1.Socket.Connections.SendText('FILE!'+Edit1.Text);
// sleep(2000); // Need to sleep so the other end has time to process the commands
// Streamsize := TFileStream.Create(OpenDialog1.FileName, fmopenread); // Stream created just to Calculate size
// Edit2.Text := inttostr(Streamsize.Size);
// Sleep(2000);
// ServerSocket1.Socket.Connections.SendText('SIZE!'+Edit2.Text); // Sends filesize through primary socket
// Streamsize.Position := 0;
// Streamsize.Free;
// sleep(2000);
// //ClientSocket2.Address := Edit3.Text;
// //ClientSocket2.Open; // ready to send file on second socket
// Application.ProcessMessages;
// AddLog(Format('%s adet socket server 2 bağlanan var.',[inttostr(ServerSocket1.Socket.ActiveConnections)]));
// Application.ProcessMessages;
// if ServerSocket2.Socket.Connections.SendStream(TFileStream.Create(OpenDialog1.FileName, fmopenRead)) then
// begin
// memo1.Lines.Add('File Sent');
// end;
// // above creates a stream and sends as a stream its in a if line because this is the only way it will automatically check the byte order and send the whole stream
// end;
A := ServerSocket1.Socket.ActiveConnections - 1;
for I := 0 to A do
begin
ServerSocket1.Socket.Connections.SendText('FILE!'+Edit1.Text);
sleep(2000); // Need to sleep so the other end has time to process the commands
end;
Streamsize := TFileStream.Create(OpenDialog1.FileName, fmopenread); // Stream created just to Calculate size
Edit2.Text := inttostr(Streamsize.Size);
Sleep(2000);
for I := 0 to A do
begin
ServerSocket1.Socket.Connections.SendText('SIZE!'+Edit2.Text); // Sends filesize through primary socket
end;
Streamsize.Position := 0;
Streamsize.Free;
sleep(2000);
//ClientSocket2.Address := Edit3.Text;
//ClientSocket2.Open; // ready to send file on second socket
Application.ProcessMessages;
// AddLog(Format('%s adet socket server2'' ye bağlanan var.',[inttostr(ServerSocket1.Socket.ActiveConnections)]));
// Application.ProcessMessages;
A := ServerSocket2.Socket.ActiveConnections - 1;
for I := 0 to A do
begin
if ServerSocket2.Socket.Connections.SendStream(TFileStream.Create(OpenDialog1.FileName, fmopenRead)) then
begin
memo1.Lines.Add('Dosya Gönderildi');
end;
end;
// above creates a stream and sends as a stream its in a if line because this is the only way it will automatically check the byte order and send the whole stream
// end;
end;
end;
end;
end;
- fesiharslan
- Üye
- Mesajlar: 591
- Kayıt: 20 Eki 2006 11:37
- Konum: Erzurum
- İletişim:
Re: DbGrid Seçilen Kayda işlem yaptıramıyorum
Dosyayı stream'a alırken fmOpenRead or fmShareDenyWrite modlarını birlikte kullanın.
Ör;
Streamsize.Free; yazdıktan sonra SendStream metodunu kullanmışsınız. Yani free direktifinden önce set edilen tüm işlemleriniz yok sayılıyor.
Ör;
Kod: Tümünü seç
fileSt := TFileStream.Create(OpenDialog1.FileName, fmOpenRead or fmShareDenyWrite);
- fesiharslan
- Üye
- Mesajlar: 591
- Kayıt: 20 Eki 2006 11:37
- Konum: Erzurum
- İletişim:
Re: DbGrid Seçilen Kayda işlem yaptıramıyorum
ServerSocket nesnesi ile dosya gönderme örneğini paylaşıyorum. Umarım faydası olur.
Kod: Tümünü seç
procedure TForm3.Button1Click(Sender: TObject);
function GetSoketileDosyaGonder(DosyaAdi: string; Soket: TServerSocket;
SoketId: Integer): Boolean;
var
KaynakDosya: TFileStream;
Gonderildi: Boolean;
begin
Gonderildi := False;
KaynakDosya := TFileStream.Create(DosyaAdi, fmOpenRead or fmShareDenyWrite);
try
Gonderildi := Soket.Socket.Connections[SoketId].SendStream(KaynakDosya);
finally
KaynakDosya.Free;
Result := Gonderildi;
end;
end;
var
i: Integer;
begin
if OpenDialog1.Execute then
begin
for I := 0 to ServerSocket2.Socket.ActiveConnections - 1 do
begin
if GetSoketileDosyaGonder(OpenDialog1.FileName, ServerSocket2, i) then
begin
Memo1.Lines.Add((i + 1).ToString + '. Kullanıcıya Dosya Gönderildi');
end;
end;
end;
end;