Ms Visual C Sharp

Post Reply
User avatar
kajot
Posts: 309
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

Ms Visual C Sharp

Post by kajot »

Is possible use MS Visual C Sharp with xHarbour ?
best regards
kajot
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Ms Visual C Sharp

Post by Antonio Linares »

Kajot,

C sharp uses .NET and neither Harbour/xHarbour support it yet.

Anyhow, there is a way to use .NET from them :-)

I take the opportunity to announce that we are working on a new FiveNet product that allows to use .NET libraries from Harbour/xHarbour :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Ms Visual C Sharp

Post by Antonio Linares »

Dear Enrico,

Its just a matter of work and some luck :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Ms Visual C Sharp

Post by Enrico Maria Giordano »

Antonio Linares wrote:Dear Enrico,

Its just a matter of work and some luck :-)
Yes, plus a big head like you. :-)

EMG
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Ms Visual C Sharp

Post by Rick Lipkin »

Antonio

I have tried to stay away from .net but I welcome your efforts .. I know I get a lot of flack from the Visual Studio crowd because they are considered ( mainstream ) .net programmers be it in either C#, or Visual Basic.

I dislike run-times .. but it looks like the .net train is gathering a lot of motion. Please look at both the .net ADO connectivity as well as the .net controls in your research.

I will follow this thread with much interest !!

Rick Lipkin
sajith
Posts: 110
Joined: Wed Feb 18, 2009 9:58 am
Location: India
Contact:

Re: Ms Visual C Sharp

Post by sajith »

Dear Antonio,
I take the opportunity to announce that we are working on a new FiveNet product that allows to use .NET libraries from Harbour/xHarbour
Wish u all success in ur effort.
I want to know whether .Net Framework is needed for using .NET libraries.

Regards,
sajith
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Ms Visual C Sharp

Post by Antonio Linares »

Sajith,

> I want to know whether .Net Framework is needed for using .NET libraries.

yes, of course

.NET has to be installed on the computer where you want to use your app
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Ms Visual C Sharp

Post by MarcoBoschi »

Antonio,
do you think that a program like this may translated into xharbour/Fivewin?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using INNOVAPHONE.test.Cs.pbx_wsdl;

namespace INNOVAPHONE.test.Cs
{
//
// this form will merely show a window with cumulating PBX events
// its purpose is to demonstrate the use of async events in VB.Net
//
public partial class FrmMain : Form
{
// the forms PBX link
myPBX pbx;

// PBX access data
// assuming the controling user is "_TAPI_" which has a user-password "access"
const string httpUser = "admin";
const string httpPw = "ip800";
const string pbxUser = "_TAPI_";
const string pbxMonitor = "Marco Boschi";
const string pbxUrl = "http://172.28.2.240/PBX0/user.soap";

// PBX runtime data
public int pbxKey;
public int pbxSession;
public int pbxUserId;


public FrmMain()
{
InitializeComponent();
}

// initalize pbx link on load
private void FrmMain_Load(object sender, System.EventArgs e)
{
FrmMain frm = (FrmMain)sender;
try
{
// create the link
pbx = new myPBX(ref frm, addEvent, showEchoResult, callStarted);
// set the URL
pbx.Url = pbxUrl;
// set the HTTP level credentials
pbx.Credentials = new System.Net.NetworkCredential(httpUser, httpPw, "");
// initialize the session, remember the session-id and -key
pbxSession = pbx.Initialize(pbxUser, "VBNet SOAP Test", true, true, out pbxKey);
// monitor a user
pbxUserId = pbx.UserInitialize(pbxSession, pbxMonitor, false);
// start async retrieval of events from pbx
pbx.startPolling();
}
catch (Exception err)
{
string msg1;
string msg2;
msg1 = err.Message;
if (err.InnerException != null)
{
msg2 = err.InnerException.Message;
}
else
{
msg2 = "";
}
MessageBox.Show("pbx link initialization failed: " + msg1 + " / " + msg2);

}

}

public void addEvent(string ev)
{
events.Items.Add(ev);
}

private void btnEcho_Click(object sender, EventArgs e)
{
try
{
FrmMain main = this;
myPBX _m = new myPBX(ref main, addEvent, showEchoResult, callStarted);
// set the URL
_m.Url = pbxUrl;
// set the HTTP level credentials
_m.Credentials = new System.Net.NetworkCredential(httpUser, httpPw, "");
// initialize the session, remember the session-id and -key
int _mKey;
int _mSession = _m.Initialize(pbxUser, "VBNet SOAP Test", true, true, out _mKey);
// monitor a user
//int _mUserId = _m.UserInitialize(pbxSession, pbxMonitor, false);
_m.startEcho(pbxSession, pbxKey);
}
catch (Exception ex)
{
MessageBox.Show("Eccezione in esecuzione richiesta.");
}
}

public void showEchoResult(string res)
{
MessageBox.Show(res);
}

public void callStarted(string res)
{
MessageBox.Show(res);
}

private void btnCall_Click(object sender, EventArgs e)
{
try
{
pbx.createCall();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

// the PBX link
// we need a derived class to be able to handle the async events
public class myPBX : pbx_wsdl.pbx
{

// derive from the auto-generated soap class
// link to form
private FrmMain form;

public delegate void AddEventDelegate(string ev);
private AddEventDelegate _addEventDelegate;

public delegate void ShowEchoResultDelegate(string res);
private ShowEchoResultDelegate _showEchoResultDelegate;

public delegate void CallStartedDelegate(string res);
private CallStartedDelegate _callStartedDelegate;

// constructor to save the form link
public myPBX(ref FrmMain form, AddEventDelegate eventD, ShowEchoResultDelegate echoD, CallStartedDelegate callD)
{
//preparo i metodi esterni per la gestione asincrona dei risultati dei vari metodi
_addEventDelegate = eventD;
_showEchoResultDelegate = echoD;
_callStartedDelegate = callD;

//prendo il form per poter invocare il metodo corretto
this.form = form;

//collego i miei metodi di gestione dei risultati a quelli del webService
this.PollCompleted += new pbx_wsdl.PollCompletedEventHandler(pollCB);
this.EchoCompleted += new pbx_wsdl.EchoCompletedEventHandler(echoCB);
this.UserCallCompleted += new pbx_wsdl.UserCallCompletedEventHandler(userCallCB);
}

// setup an async Poll
public void startPolling()
{
try
{
this.PollAsync(form.pbxSession);
}
catch (Exception e)
{
MessageBox.Show("start poll failed: " + e.Message + " / " + e.InnerException.ToString());
}
}

// setup an async call request
public void createCall()
{
try
{
int key;
int session_h = this.Initialize("Marco Boschi", "demo", true, true, out key);
int user_h = this.UserInitialize(session_h, "Marco Boschi", true);
this.UserCallAsync(user_h, "", "267", "", 0, null);
}
catch (Exception e)
{
MessageBox.Show("start call failed: " + e.Message + " / " + e.InnerException.ToString());
}
}

//setup an async Exho (Nicola 14/11/2008
public void startEcho(int _session, int _key)
{
try
{
this.EchoAsync(_session, _key);
}
catch (Exception ex)
{
MessageBox.Show("start echo failed: " + ex.Message + " / " + ex.InnerException.ToString());
}
}



// handle an async Poll result
private void pollCB(object sender, pbx_wsdl.PollCompletedEventArgs e)
{
// scan user and call events
foreach (pbx_wsdl.UserInfo ui in e.Result.user)
{
string description = "user ";
if (!String.IsNullOrEmpty(ui.cn))
{
description = description + "(" + ui.type + ") " + ui.cn;
}

// Me.form.events.Items.Add("user " + ui.cn) -- dangerous
this.form.Invoke(_addEventDelegate, new object[] { description });
}
foreach (pbx_wsdl.CallInfo ci in e.Result.call)
{
// Me.form.events.Items.Add("call -> " + ci.msg) -- dangerous
this.form.Invoke(_addEventDelegate, new object[] { "call -> " + ci.msg });
}
// schedule next async Poll
this.startPolling();
}

//handle an async Echo result
private void echoCB(object sender, pbx_wsdl.EchoCompletedEventArgs e)
{
this.form.Invoke(_showEchoResultDelegate, new object[] { String.Concat("il controllo di sessione ha risposto: ", e.Result) });
}

//handle an async userCall result
private void userCallCB(object sender, pbx_wsdl.UserCallCompletedEventArgs e)
{
string error = "";
if (e.Error != null)
{
error = e.Error.Message;
}
string message = String.Format("Creazione cancellata ({0}). Errore: {1}.\r\nRisultato: {2}.\r\nUserState: {3}.", e.Cancelled, error, e.Result, e.UserState.ToString());
this.form.Invoke(_callStartedDelegate, new object[] { message });
}

}

}
Marco Boschi
info@marcoboschi.it
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Ms Visual C Sharp

Post by Antonio Linares »

Marco,

Its almost impossible to translate it, but this FWH example may help you to do what you want (unless I did not properly understand what you want to do):

http://forums.fivetechsupport.com/viewt ... 257#p63257

GetPostData() source code is here:
http://forums.fivetechsupport.com/viewt ... 199#p63199
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply