Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2007, 04:54 AM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default working with DLL event, method in JavaScript

Dear friend,

1.
i need to work out with a device DLL (it has events, methods, properties) on client machine,
whereas the data for this device is from database (ASP .NET)...

i need to create a new object from a DLL class, add the event handler, add the event trigger, methods and properties..
and especially this DLL will listen to USB port, send status all the time and trigger event if a card is detected.

could you pls tell me how to do it in Javascript ?

below is the source code in windows app (C#), but i can not find
sample code to do it in JavaScript...

Thank you,

hendy

========= source code in windows application =========================
private void fUJITIPE_Load(object sender, System.EventArgs e)
{

   pbFound.Visible=true;
   _ACR = new ACR120DLL.ACR120DLL ();
   _ACR.TotalBlocks = 44;//TOTAL BLOCK-1
   _AddListHandler = new ACR120DLL.ACR120DLL.AddListHandler(AddList);
   _ACR.AddList += _AddListHandler ;

   _ACR.SelectList +=new ACR120DLL.ACR120DLL.SelectListHandler (SelectList);

   _ACR.MsgBox +=new ACR120DLL.ACR120DLL.MsgBoxHandler (MsgBox);
   _ACR.TriggerPerformStep +=new ACR120DLL.ACR120DLL.ProgressStepHandler (progress_StepEvents);

    _ACR.TriggerReadyImg +=new ACR120DLL.ACR120DLL.ReadyImgHandler(Image_Events);

    _ACR.Connect();
   Timer1 = new System.Timers.Timer();
   Timer1.Elapsed +=new System.Timers.ElapsedEventHandler (TriggerReadData);
    Timer1.Interval = 1000;
    Timer1.AutoReset = true;
    Timer1.Start();

}

private void AddList(string Msg)
{
    if (Msg.EndsWith("-3030"))
    {
        MessageBox.Show("Ada kesalahan ! Mohon diulangi proses pembacaan kartu !");
        _ACR.AddList-= _AddListHandler;
        DisposeObjectReader();
        InitReader();
        return;
    }
    List1.Items.Add(Msg);
}

private void SelectList()
{
    List1.SelectedIndex = List1.Items.Count - 1;
}

private void MsgBox(string Msg)
{
    char[] _chr=new char[1];
    _chr[0]=':';
    string[] Message = Msg.Split(_chr);
    MessageBox.Show(Message[1], Message[0], MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

private void TriggerReadData(object o, System.Timers.ElapsedEventArgs e)
{
    ArrayList alData = new ArrayList();
    Timer1.Stop();
    progress.Value=1;
    alData= _ACR.ReadData();
    if (alData.Count == 45) //TOTAL BLOCKS
    {
        //
        string Nomor = alData[0].ToString().Replace ("\0","");
        string Perusahaan = alData[1].ToString().Replace ("\0","");
        string Alamat1 = alData[2].ToString().Replace ("\0","");
        string Alamat2 = alData[3].ToString().Replace ("\0","");
        string Alamat = Alamat1 + Alamat2;
        string Merek = alData[4].ToString().Replace ("\0","");
        string Tipe = alData[5].ToString().Replace ("\0","");
        string Jenis = alData[6].ToString().Replace ("\0","");
        string Peruntukan = alData[7].ToString().Replace ("\0","");
        string Varian = alData.ToString().Replace ("\0","");
        string KendaraanDiuji = alData[9].ToString().Replace ("\0","");
        string NomorRangka = alData[10].ToString().Replace ("\0","");
        string NomorMotorPenggerak = alData[11].ToString().Replace ("\0","");
        string PenanggungJawabPerusahaan = alData[12].ToString().Replace ("\0","");
        string KonfigurasiSumbu= alData[13].ToString().Replace ("\0","");
        string JarakSumbuIsampaiII= alData[14].ToString().Replace ("\0","");
        string JarakSumbuIIsampaiIII= alData[15].ToString().Replace ("\0","");
        string JarakSumbuIIIsampaiIV= alData[16].ToString().Replace ("\0","");
        string DimensiLebarTotal= alData[17].ToString().Replace ("\0","");
        string DimensiTinggiTotal= alData[18].ToString().Replace ("\0","");
        string DimensiJulurDepan= alData[19].ToString().Replace ("\0","");
        string DimensiJulurBelakang= alData[20].ToString().Replace ("\0","");
        string JumlahSilinder= alData[21].ToString().Replace ("\0","");
        string IsiSilinder= alData[22].ToString().Replace ("\0","");
        string DayaMotorPenggerakMaksimum= alData[23].ToString().Replace ("\0","");
        string BahanBakar= alData[24].ToString().Replace ("\0","");
        string UkuranBanSumbuI= alData[25].ToString().Replace ("\0","");
        string UkuranBanSumbuII= alData[26].ToString().Replace ("\0","");
        string UkuranBanSumbuIII= alData[27].ToString().Replace ("\0","");
        string UkuranBanSumbuIV= alData[28].ToString().Replace ("\0","");
        string KekuatanRancanganSumbuI= alData[29].ToString().Replace ("\0","");
        string KekuatanRancanganSumbuII= alData[30].ToString().Replace ("\0","");
        string KekuatanRancanganSumbuIII= alData[31].ToString().Replace ("\0","");
        string KekuatanRancanganSumbuIV= alData[32].ToString().Replace ("\0","");
        string JBBatauJBKB= alData[33].ToString().Replace ("\0","");
        string BeratKosong= alData[34].ToString().Replace ("\0","");
        string JBIatauJBKI= alData[35].ToString().Replace ("\0","");
        string DayaAngkutKg= alData[36].ToString().Replace ("\0","");
        string DayaAngkutOrang= alData[37].ToString().Replace ("\0","");
        string DayaAngkutBarang= alData[38].ToString().Replace ("\0","");
        string KelasJalanTerendah= alData[39].ToString().Replace ("\0","");
        string Berdasarkan= alData[40].ToString().Replace ("\0","");
        string TglTtd= alData[41].ToString().Replace ("\0","");
        string TempatTtd= alData[42].ToString().Replace ("\0","");
        string NamaPejabat= alData[43].ToString().Replace ("\0","");
        string NIPPejabat= alData[44].ToString().Replace ("\0","");

        //KIR
        txtNomor.Text = Nomor;
        txtPerusahaan.Text=Perusahaan;
        txtAlamat.Text=Alamat.Trim();
        txtMerek.Text=Merek;
        txtTipe.Text =Tipe;
        txtJenis.Text =Jenis;
        txtPeruntukan.Text =Peruntukan;
        txtVarian.Text =Varian;
        txtKendaraanDiuji.Text=KendaraanDiuji;
        txtNomorRangka.Text =NomorRangka;
        txtNomorMotorPenggerak.Text =NomorMotorPenggerak;
        txtPenanggungJawabPerusahaan.Text =PenanggungJawabPerusahaan;
        txtKonfigurasiSumbu.Text =KonfigurasiSumbu;
        txtJarakSumbuIsampaiII.Value =Convert.ToDecimal(JarakSumbuIsampaiII);
        txtJarakSumbuIIsampaiIII.Value=Convert.ToDecimal(J arakSumbuIIsampaiIII);
        txtJarakSumbuIIIsampaiIV.Value =Convert.ToDecimal(JarakSumbuIIIsampaiIV);
        txtDimensiLebarTotal.Value =Convert.ToDecimal(DimensiLebarTotal);
        txtDimensiTinggiTotal.Value = Convert.ToDecimal(DimensiTinggiTotal);
        txtDimensiJulurDepan.Value =Convert.ToDecimal(DimensiJulurDepan);
        txtDimensiJulurBelakang.Value =Convert.ToDecimal(DimensiJulurBelakang);
        txtJumlahSilinder.Value =Convert.ToInt32(JumlahSilinder);
        txtIsiSilinder.Value =Convert.ToDecimal(IsiSilinder);
        txtDayaMotorPenggerakMaksimum.Value =Convert.ToDecimal(DayaMotorPenggerakMaksimum);
        txtBahanBakar.Text =BahanBakar;
        txtUkuranBanSumbuI.Value =Convert.ToDecimal(UkuranBanSumbuI);
        txtUkuranBanSumbuII.Value =Convert.ToDecimal(UkuranBanSumbuII);
        txtUkuranBanSumbuIII.Value =Convert.ToDecimal(UkuranBanSumbuIII);
        txtUkuranBanSumbuIV.Value =Convert.ToDecimal(UkuranBanSumbuIV);
        txtKekuatanRancanganSumbuI.Value =Convert.ToDecimal(KekuatanRancanganSumbuI);
        txtKekuatanRancanganSumbuII.Value =Convert.ToDecimal(KekuatanRancanganSumbuII);
        txtKekuatanRancanganSumbuIII.Value =Convert.ToDecimal(KekuatanRancanganSumbuIII);
        txtKekuatanRancanganSumbuIV.Value =Convert.ToDecimal(KekuatanRancanganSumbuIV);
        txtJBBatauJBKB.Value =Convert.ToDecimal(JBBatauJBKB);
        txtBeratKosong.Value =Convert.ToDecimal(BeratKosong);
        txtJBIatauJBKI.Value =Convert.ToDecimal(JBIatauJBKI);
        txtDayaAngkutKg.Value =Convert.ToDecimal(DayaAngkutKg);
        txtDayaAngkutOrang.Value =Convert.ToInt32(DayaAngkutOrang);
        txtDayaAngkutBarang.Value =Convert.ToDecimal(DayaAngkutBarang);

        txtKelasJalanTerendah.Text =KelasJalanTerendah;
        txtBerdasarkan.Text =Berdasarkan;

        string _temp = TglTtd;
        if (_temp.EndsWith(":"))
            _temp += "00 ";
        else
            _temp += ":00 ";
        dtTglTtd.Value = Convert.ToDateTime(_temp);

        txtTempatTtd.Text=TempatTtd;
        txtNamaPejabat.Text =NamaPejabat;
        txtNIPPejabat.Text =NIPPejabat;
        //
        MessageBox.Show("Selesai dibaca dari kartu !");
        RefreshForm(Nomor);
        _ACR.WaitAMinute();
    }
    Timer1.Start();
}

private void RefreshForm(string nomor)
{
    _db = new Database.DatabaseReg();
    _con = _db.Connection;
    if (_con.State == ConnectionState.Open)
        _con.Close ();
    _da = _db.GetSqlDataAdapter ("sp_UJITIPE",CommandType.StoredProcedure );
    //
    _da.SelectCommand.Parameters.Add ("@Nomor",SqlDbType.VarChar).Value= nomor;
    _da.SelectCommand.Parameters.Add ("@Perusahaan",SqlDbType.VarChar ).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@Merek",SqlDbType.VarChar ).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@Tipe",SqlDbType.VarChar ).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@Jenis",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@Peruntukan",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@Varian",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@KendaraanDiuji",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@NomorRangka",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@NomorMotorPenggerak",SqlDbType.VarChar).Valu e= "" ;
    _da.SelectCommand.Parameters.Add ("@PenanggungJawabPerusahaan",SqlDbType.VarChar).V alue= "" ;
    _da.SelectCommand.Parameters.Add ("@TglTtd",SqlDbType.DateTime ).Value= Convert.DBNull;
    _da.SelectCommand.Parameters.Add ("@TempatTtd",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@NamaPejabat",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@NIPPejabat",SqlDbType.VarChar).Value= "" ;
    _da.SelectCommand.Parameters.Add ("@KelasJalanTerendah",SqlDbType.VarChar).Value = "" ;
    _da.SelectCommand.Connection=_con;
    _con.Open ();
    _dt = new DataTable("UJITIPE");
    _da.Fill(_dt);
    _con.Close ();
    _da = null;
    //BindCtrls();
    BindCtrlsImageOnly();
}
private void DisposeObjectReader()
{
    Timer1.Stop();
    _ACR.NAR(Timer1);
    _ACR.NAR(_ACR);
}








Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call DLL Method in Javascritp? URGENT!!!!!! prabhakar123 Javascript 26 November 28th, 2011 07:06 AM
how to catch event of a DLL in JavaScript ? hendyhanusin Javascript 2 April 4th, 2007 06:50 AM
working with DLL event, method in JavaScript hendyhanusin Javascript How-To 0 March 23rd, 2007 05:12 AM
Calling a method defined inside a .NET dll rajen C# 2005 0 September 19th, 2006 12:58 AM
POST method not working ganesh15 Beginning PHP 2 February 18th, 2006 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.