ECGrid Forums  

Go Back   ECGrid Forums > Electronic Commerce > ECGridOS > ECGridOS Developer

ECGridOS Developer Development related posts.

Reply
 
Thread Tools Display Modes
  #1  
Old 09-10-2010, 09:04 AM
marcthib marcthib is offline
New Member
 
Join Date: Sep 2010
Posts: 4
Send a message via Yahoo to marcthib Send a message via Skype™ to marcthib
Default Need Sample Site

Does anyone have a sample site built using all the API calls they would not mind sharing as a training tool? I am just getting started with ECGridOS and would very much appreciate dissecting an already working site to help as I build my own. Thanks in advance.

Marc Thibault
Reply With Quote
  #2  
Old 09-10-2010, 11:07 AM
MarcNelson MarcNelson is offline
New Member
 
Join Date: Mar 2010
Posts: 10
Default

You can view an example of a site that has been put together - http://www.youtube.com/netediltd.
Reply With Quote
  #3  
Old 09-10-2010, 12:22 PM
marcthib marcthib is offline
New Member
 
Join Date: Sep 2010
Posts: 4
Send a message via Yahoo to marcthib Send a message via Skype™ to marcthib
Default

thanks Marc! quick question - any chance of getting a zip file of code and screens? doesn't have to be NetEDI, would love to study.... thx again!
Reply With Quote
  #4  
Old 09-11-2010, 10:28 AM
dkyle dkyle is offline
New Member
 
Join Date: Jul 2010
Location: The Raymond I.T. Group, Inc.
Posts: 2
Send a message via AIM to dkyle
Default Sample Code

I can give you some sample code of what I'm currently working on. It is a c#.net web application that will serve as a VAN administration portal for me (currently working on client connectivity/authentication).

I encapsulated the ECGridOS API calls into a series of objects that I make calls on (this way I can minimize the number of times I hit the API to gather info).

Here is a snippet of output code in an ASP.NET Web-site:

Code:
<div class="info" style="float: left;">
 <span class="infoHeader">User Information:</span>
 <br />
 <span class="infoItem"><b>ID: </b><%=ConnInfo.UserInfo.UserID %></span>
 <span class="infoItem"><b>Name: </b><%=ConnInfo.UserInfo.LoginName %></span>
 <span class="infoItem"><b>E-mail: </b><%=ConnInfo.UserInfo.EMail %></span>
</div>
Then, in the code behind page, I create an Object of the class I created.
Code:
private ECGridConnect _ecConn;
I also expose it so that the web-page can use it.
Code:
    public ECGridConnect ConnInfo {
        get {
            if (_ecConn != null) {
                return _ecConn;
            } else {
                _ecConn = new ECGridConnect();
                return _ecConn;
            } // end if/else
        }
    } // end property ConnInfo
In a different file, I have the class definition. Here is a snippet from that class (unfortunately I can't give full source).

Code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using net.ecgridos;
using System.Xml;
using System.Web.Services;
using System.Web.Services.Protocols;

/// <summary>
/// Summary description for ECGridConnect
/// </summary>
public class ECGridConnect {

    private String _sessionID;
    private int _iChangeQual;
    private String _interchangeID;
    private String _password;
    private String _userID;
    public event LoggingInEventHandler LoggingIn;
    public event LoggedInEventHandler LoggedIn;
    public event LoggingOutEventHandler LoggingOut;
    public event LoggedOutEventHandler LoggedOut;
    private ECGridOSAPIv2 _ecGrid;
    private ParcelIDInfo[] _pInfo;
    private UserIDInfo _uInfo;
    private SessionInfo _sInfo;
    private NetworkIDInfo _nInfo;


    /// <summary>
    /// Creates a new object of the ECGridConnect class.
    /// </summary>
    public ECGridConnect() {
        _ecGrid = new ECGridOSAPIv2();
        _pInfo = null;
        _uInfo = null;
        _sInfo = null;
        _nInfo = null;
        LoggingIn += new LoggingInEventHandler(ECGridConnect_LoggingIn);
        LoggedIn += new LoggedInEventHandler(ECGridConnect_LoggedIn);
        LoggingOut += new LoggingOutEventHandler(ECGridConnect_LoggingOut);
        LoggedOut += new LoggedOutEventHandler(ECGridConnect_LoggedOut);
    } // end default no-argument constructor

    private void Connect() {
        LoggingIn(_userID);
        _sessionID = _ecGrid.Login(_userID, _password);
        if (_sessionID.Length > 0) {
            //TODO: Nothing to do.  We have a successfull login.
        } else {
            throw new Exception(String.Format("Login failed for user {0}",_userID));
        } // end if/else
        LoggedIn(_userID,_sessionID);
    } // end method Connect

    private void Disconnect() {
        if (String.IsNullOrEmpty(_sessionID)) {
        } else {
            LoggingOut(_userID, _sessionID);
            _ecGrid.Logout(_sessionID);
            LoggedOut(_userID, _sessionID);
        } // end if/else
    } // end method Disconnect

    public void LoadUserInfo() {
        _uInfo = null;
        if(_sInfo != null) {
        } else {
            LoadSessionInfo();
        } // end if/else
        try {
            Connect();
            _uInfo = _ecGrid.UserInfo(_sessionID, _sInfo.UserID);
            Disconnect();
            //There is good data in the InnerXML
            //which can be parsed and used to processes specific exceptions
        } catch (SoapException ex) {
            XmlDocument doc = new XmlDocument();
            XmlNode node;
            doc.LoadXml(ex.Detail.OuterXml);
            node = doc.DocumentElement.SelectSingleNode("ErrorInfo");
            if (node != null) {
                HttpContext.Current.Response.Write(String.Format("SOAP Exception: ({0}) {1}", node.SelectSingleNode("ErrorCode").InnerText, node.SelectSingleNode("ErrorString").InnerText, "<br />\n"));
                HttpContext.Current.Response.Write(String.Format(" Error Item: {0}", node.SelectSingleNode("ErrorItem").InnerText, "<br />"));
                HttpContext.Current.Response.Write(String.Format(" Msg: {0}", node.SelectSingleNode("ErrorMessage").InnerText, "<br />"));
            } else {
                HttpContext.Current.Response.Write("ERROR: " + ex.Message.ToString() + "<br />" + ex.StackTrace + "<br />");
            } // end if/else
        } catch (Exception ex) {
            HttpContext.Current.Response.Write("Error:<br />");
            HttpContext.Current.Response.Write(ex.Message + "<br />");
            HttpContext.Current.Response.Write(ex.StackTrace + "<br />");
        } finally {
            Disconnect();
        } // end try/catch/finally
    } // end method LoadUserInfo

    public void GetInbox() {
        _pInfo = null;
        try {
            Connect();
            _pInfo = _ecGrid.ParcelInBox(_sessionID);
            Disconnect();
            //There is good data in the InnerXML
            //which can be parsed and used to processes specific exceptions
        } catch (SoapException ex) {
            XmlDocument doc = new XmlDocument();
            XmlNode node;
            doc.LoadXml(ex.Detail.OuterXml);
            node = doc.DocumentElement.SelectSingleNode("ErrorInfo");
            if (node != null) {
                HttpContext.Current.Response.Write(String.Format("SOAP Exception: ({0}) {1}", node.SelectSingleNode("ErrorCode").InnerText, node.SelectSingleNode("ErrorString").InnerText, "<br />\n"));
                HttpContext.Current.Response.Write(String.Format(" Error Item: {0}", node.SelectSingleNode("ErrorItem").InnerText, "<br />"));
                HttpContext.Current.Response.Write(String.Format(" Msg: {0}", node.SelectSingleNode("ErrorMessage").InnerText, "<br />"));
            } else {
                HttpContext.Current.Response.Write("ERROR: " + ex.Message.ToString() + "<br />" + ex.StackTrace + "<br />");
            } // end if/else
        } catch (Exception ex) {
            HttpContext.Current.Response.Write("Error:<br />");
            HttpContext.Current.Response.Write(ex.Message + "<br />");
            HttpContext.Current.Response.Write(ex.StackTrace + "<br />");
        } finally {
            Disconnect();
        } // end try/catch/finally
    } // end method GetInbox

    /// <summary>
    /// Retrieves the contents of the inbox for the mailbox.
    /// </summary>
    public ParcelIDInfo[] Inbox {
        get {
            if (_pInfo != null) {
                return _pInfo;
            } else {
                GetInbox();
                return _pInfo;
            } // end if/else
        }
    } // end property Inbox

    /// <summary>
    /// Gets the user information associated with the current login.
    /// </summary>
    public UserIDInfo UserInfo {
        get {
            if (_uInfo != null) {
                return _uInfo;
            } else {
                LoadUserInfo();
                return _uInfo;
            } // end if/else
        }
    } // end property UserInfo

} // end class ECGridConnect
In this way, you can see how in the sample output I provided, I wire-up the class property UserInfo so that I can access all of the variables, manage the connection and display information to the user much faster. I also have custom event handlers set up to detect successful logons and logoffs so that I am sure to close my connection to the ECGridOS system.

I am attempting to setup some kind of caching for the responses from ECGridOS so that it comes back even faster.

Similarly, I encapsulate the inbox so that on a separate "inbox" page, I can bind the ParcelIDInfo property Inbox, to a GridView or other .NET Databound Control.

Hope this helps to give you more information.
Reply With Quote
  #5  
Old 09-11-2010, 11:17 PM
marcthib marcthib is offline
New Member
 
Join Date: Sep 2010
Posts: 4
Send a message via Yahoo to marcthib Send a message via Skype™ to marcthib
Default

thanks dkyle! will be happy to look at it, much appreciated!
Reply With Quote
  #6  
Old 09-13-2010, 02:02 PM
Todd Gould's Avatar
Todd Gould Todd Gould is offline
Loren Data Corp.
 
Join Date: May 2005
Location: Loren Data Corp.
Posts: 303
Send a message via Skype™ to Todd Gould
Default

marcthib, I've posted more links for sample code at http://forums.ecgrid.com/showthread.php?t=144.

dkyle, great posting. I've linked it to the Sample Code thread above. Thank you!

MarcNelson, your site is a great example of ECGridOS coding. If there were any way you could post some samples without having to giveaway all your secrets, that would be great.

-=tg=-
Reply With Quote
  #7  
Old 09-13-2010, 02:13 PM
marcthib marcthib is offline
New Member
 
Join Date: Sep 2010
Posts: 4
Send a message via Yahoo to marcthib Send a message via Skype™ to marcthib
Default

excellent, thank you!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample Code Todd Gould ECGridOS Developer 3 09-13-2010 05:58 PM


All times are GMT -4. The time now is 07:49 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
ECGrid® is a registered service mark of Loren Data Corp.