예제 #1
0
 /// <summary>
 /// Connect the socket.
 /// </summary>
 public void Connect(ConnectionInformations connectionInformations)
 {
     //if (m_RawSocket != null && !m_RawSocket.Connected)
     //    RawConnect();
     m_MessageInformations = new MessageInformations(account);
     if (m_IsChangingServer)
     {
         client.Close("Changing server.");
         client = new NetClient();
         this.client.Connected     += new EventHandler <NetSocketConnectedEventArgs>(client_Connected);
         this.client.DataArrived   += new EventHandler <NetSockDataArrivalEventArgs>(client_DataArrived);
         this.client.Disconnected  += new EventHandler <NetSocketDisconnectedEventArgs>(client_Disconnected);
         this.client.ErrorReceived += new EventHandler <NetSockErrorReceivedEventArgs>(client_ErrorReceived);
         this.client.StateChanged  += new EventHandler <NetSockStateChangedEventArgs>(client_StateChanged);
     }
     try
     {
         client.Connect(new IPEndPoint(IPAddress.Parse(connectionInformations.Address), connectionInformations.Port));
     }
     catch (SocketException sockEx)
     {
         account.Log(new ErrorTextInformation("[Socket Exception] " + sockEx.Message), 0);
         account.TryReconnect(10);
     }
 }
예제 #2
0
 /// <summary>
 /// FUNCTION BAPI_USER_GETLIST
 /// </summary>
 /// <param name="ROWS">No. of users selected</param>
 /// <param name="MAX_ROWS">Maximum Number of Lines of Hits</param>
 /// <param name="WITH_USERNAME">Read User with Name</param>
 /// <param name="RETURN">Return Parameter</param>
 /// <param name="SELECTION_EXP">Search for Users with Free Selections</param>
 /// <param name="SELECTION_RANGE">Search for Users with a Ranges Table</param>
 /// <param name="USERLIST">User List</param>
 public static bool Invoke(ConnectionInformations ci, out string exception, out int ROWS, int MAX_ROWS, string WITH_USERNAME, ref SapTable <BAPIRET2> RETURN, ref SapTable <BAPIUSSEXP> SELECTION_EXP, ref SapTable <BAPIUSSRGE> SELECTION_RANGE, ref SapTable <BAPIUSNAME> USERLIST)
 {
     exception = "";
     ROWS      = default(int);
     try
     {
         SapConnections.Init(ci);
         RfcRepository rfcRep   = SapConnections.Get(ci.Name).Repository;
         IRfcFunction  function = rfcRep.CreateFunction("BAPI_USER_GETLIST");
         function.SetValue("MAX_ROWS", MAX_ROWS);
         function.SetValue("WITH_USERNAME", WITH_USERNAME);
         if (RETURN != null)
         {
             function.SetValue("RETURN", RETURN.ToSapObject(ci.Name));
         }
         if (SELECTION_EXP != null)
         {
             function.SetValue("SELECTION_EXP", SELECTION_EXP.ToSapObject(ci.Name));
         }
         if (SELECTION_RANGE != null)
         {
             function.SetValue("SELECTION_RANGE", SELECTION_RANGE.ToSapObject(ci.Name));
         }
         if (USERLIST != null)
         {
             function.SetValue("USERLIST", USERLIST.ToSapObject(ci.Name));
         }
         function.Invoke(SapConnections.Get(ci.Name));
         ROWS = function.GetInt("ROWS");
         if (RETURN == null)
         {
             RETURN = new SapTable <BAPIRET2>();
         }
         RETURN.FromSapObject(function.GetTable("RETURN"));
         if (SELECTION_EXP == null)
         {
             SELECTION_EXP = new SapTable <BAPIUSSEXP>();
         }
         SELECTION_EXP.FromSapObject(function.GetTable("SELECTION_EXP"));
         if (SELECTION_RANGE == null)
         {
             SELECTION_RANGE = new SapTable <BAPIUSSRGE>();
         }
         SELECTION_RANGE.FromSapObject(function.GetTable("SELECTION_RANGE"));
         if (USERLIST == null)
         {
             USERLIST = new SapTable <BAPIUSNAME>();
         }
         USERLIST.FromSapObject(function.GetTable("USERLIST"));
         return(true);
     }
     catch (Exception ex)
     {
         exception = ex.Message;
         return(false);
     }
 }
예제 #3
0
 public void Connect(ConnectionInformations connectionInformations)
 {
     //if (MainForm.ActualMainForm.IpAdressChoice.SelectedIndex > -1)
     //{
     // IPEndPoint e = new IPEndPoint(new IPAddress(GetBytes(MainForm.ActualMainForm.IpAdressChoice.SelectedText)), 0);
     // m_Socket.Bind(e);
     //}
     if (m_RawSocket != null && !m_RawSocket.Connected)
     {
         RawConnect();
     }
     if (m_IsChangingServer)
     {
         m_Socket.Disconnect(false);
         m_Socket.Dispose();
         m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         account.SetStatus(Status.Disconnected);
     }
     try
     {
         m_Socket.Connect(connectionInformations.Address, connectionInformations.Port);
         if (m_Socket.Connected)
         {
             account.SetStatus(Status.None);
             account.LatencyFrame = new LatencyFrame(account);
             account.Log(new ConnectionTextInformation("Connexion établie au serveur " + connectionInformations.ServerName + "."), 0);
             if ((!m_IsChangingServer))
             {
                 m_ReceptionThread = new Thread(SocketReception);
                 m_ReceptionThread.Start();
             }
             m_IsChangingServer = false;
         }
         else
         {
             account.Log(new ConnectionTextInformation("Connexion échouée."), 0);
         }
     }
     catch (SocketException sockEx)
     {
         account.Log(new ErrorTextInformation("[Socket Exception] " + sockEx.Message), 0);
         account.TryReconnect(1);
     }
 }
예제 #4
0
 /// <summary>
 /// FUNCTION BAPI_MATERIAL_GETLIST
 /// </summary>
 /// <param name="MAXROWS">Maximum number of materials to be selected</param>
 /// <param name="DISTRIBUTIONCHANNELSELECTION">Selection options for distribution channel</param>
 /// <param name="MANUFACTURERPARTNUMB">Manufacturer and manufacturer part number</param>
 /// <param name="MATERIALSHORTDESCSEL">Selection options for material description</param>
 /// <param name="MATNRLIST">List of material numbers with material description</param>
 /// <param name="MATNRSELECTION">Selection options for material number</param>
 /// <param name="PLANTSELECTION">Selection options for plants</param>
 /// <param name="RETURN">Return Parameter</param>
 /// <param name="SALESORGANISATIONSELECTION">Selection options for sales organization</param>
 /// <param name="STORAGELOCATIONSELECT">Selection options for storage locations</param>
 public static bool Invoke(ConnectionInformations ci, out string exception, int MAXROWS, ref SapTable <BAPIMATRADC> DISTRIBUTIONCHANNELSELECTION, ref SapTable <BAPIMATMFRPN> MANUFACTURERPARTNUMB, ref SapTable <BAPIMATRAS> MATERIALSHORTDESCSEL, ref SapTable <BAPIMATLST> MATNRLIST, ref SapTable <BAPIMATRAM> MATNRSELECTION, ref SapTable <BAPIMATRAW> PLANTSELECTION, ref SapTable <BAPIRET2> RETURN, ref SapTable <BAPIMATRASO> SALESORGANISATIONSELECTION, ref SapTable <BAPIMATRAL> STORAGELOCATIONSELECT)
 {
     exception = "";
     try
     {
         SapConnections.Init(ci);
         RfcRepository rfcRep   = SapConnections.Get(ci.Name).Repository;
         IRfcFunction  function = rfcRep.CreateFunction("BAPI_MATERIAL_GETLIST");
         function.SetValue("MAXROWS", MAXROWS);
         if (DISTRIBUTIONCHANNELSELECTION != null)
         {
             function.SetValue("DISTRIBUTIONCHANNELSELECTION", DISTRIBUTIONCHANNELSELECTION.ToSapObject(ci.Name));
         }
         if (MANUFACTURERPARTNUMB != null)
         {
             function.SetValue("MANUFACTURERPARTNUMB", MANUFACTURERPARTNUMB.ToSapObject(ci.Name));
         }
         if (MATERIALSHORTDESCSEL != null)
         {
             function.SetValue("MATERIALSHORTDESCSEL", MATERIALSHORTDESCSEL.ToSapObject(ci.Name));
         }
         if (MATNRLIST != null)
         {
             function.SetValue("MATNRLIST", MATNRLIST.ToSapObject(ci.Name));
         }
         if (MATNRSELECTION != null)
         {
             function.SetValue("MATNRSELECTION", MATNRSELECTION.ToSapObject(ci.Name));
         }
         if (PLANTSELECTION != null)
         {
             function.SetValue("PLANTSELECTION", PLANTSELECTION.ToSapObject(ci.Name));
         }
         if (RETURN != null)
         {
             function.SetValue("RETURN", RETURN.ToSapObject(ci.Name));
         }
         if (SALESORGANISATIONSELECTION != null)
         {
             function.SetValue("SALESORGANISATIONSELECTION", SALESORGANISATIONSELECTION.ToSapObject(ci.Name));
         }
         if (STORAGELOCATIONSELECT != null)
         {
             function.SetValue("STORAGELOCATIONSELECT", STORAGELOCATIONSELECT.ToSapObject(ci.Name));
         }
         function.Invoke(SapConnections.Get(ci.Name));
         if (DISTRIBUTIONCHANNELSELECTION == null)
         {
             DISTRIBUTIONCHANNELSELECTION = new SapTable <BAPIMATRADC>();
         }
         DISTRIBUTIONCHANNELSELECTION.FromSapObject(function.GetTable("DISTRIBUTIONCHANNELSELECTION"));
         if (MANUFACTURERPARTNUMB == null)
         {
             MANUFACTURERPARTNUMB = new SapTable <BAPIMATMFRPN>();
         }
         MANUFACTURERPARTNUMB.FromSapObject(function.GetTable("MANUFACTURERPARTNUMB"));
         if (MATERIALSHORTDESCSEL == null)
         {
             MATERIALSHORTDESCSEL = new SapTable <BAPIMATRAS>();
         }
         MATERIALSHORTDESCSEL.FromSapObject(function.GetTable("MATERIALSHORTDESCSEL"));
         if (MATNRLIST == null)
         {
             MATNRLIST = new SapTable <BAPIMATLST>();
         }
         MATNRLIST.FromSapObject(function.GetTable("MATNRLIST"));
         if (MATNRSELECTION == null)
         {
             MATNRSELECTION = new SapTable <BAPIMATRAM>();
         }
         MATNRSELECTION.FromSapObject(function.GetTable("MATNRSELECTION"));
         if (PLANTSELECTION == null)
         {
             PLANTSELECTION = new SapTable <BAPIMATRAW>();
         }
         PLANTSELECTION.FromSapObject(function.GetTable("PLANTSELECTION"));
         if (RETURN == null)
         {
             RETURN = new SapTable <BAPIRET2>();
         }
         RETURN.FromSapObject(function.GetTable("RETURN"));
         if (SALESORGANISATIONSELECTION == null)
         {
             SALESORGANISATIONSELECTION = new SapTable <BAPIMATRASO>();
         }
         SALESORGANISATIONSELECTION.FromSapObject(function.GetTable("SALESORGANISATIONSELECTION"));
         if (STORAGELOCATIONSELECT == null)
         {
             STORAGELOCATIONSELECT = new SapTable <BAPIMATRAL>();
         }
         STORAGELOCATIONSELECT.FromSapObject(function.GetTable("STORAGELOCATIONSELECT"));
         return(true);
     }
     catch (Exception ex)
     {
         exception = ex.Message;
         return(false);
     }
 }