/// <summary>
 ///	Overloaded Constructor with two arguments for setting up the result dataset and Sesion
 /// </summary>
 /// <param name="ds">DataSet Object</param>
 /// <param name="sess">OFISession Object</param>
 public NandanaResult(DataSet ds, NandanaSession sess)
 {
     // default set the Result to SUCCESS
     status = StatusType.SUCCESS;
     // Also set the dataset
     resultDS  = ds;
     resultObj = null;
     session   = sess;
 }
 /// <summary>
 ///	Overloaded Constructor with two arguments for setting up Error code and session
 /// </summary>
 /// <param name="errCode">ErrorCode</param>
 /// <param name="sess">OFISession Object</param>
 public NandanaResult(NandanaError.ErrorType errCode, NandanaSession sess)
 {
     status    = StatusType.ERROR;
     errorCode = errCode;
     resultDS  = null;
     resultObj = null;
     session   = sess;
     NandanaError.PostError(this);
 }
 /// <summary>
 ///	Overloaded Constructor with session object as argument
 /// </summary>
 /// <param name="sess">OFISession Object</param>
 public NandanaResult(NandanaSession sess)
 {
     // default set the Result to SUCCESS
     status         = StatusType.SUCCESS;
     errorException = null;
     resultDS       = null;
     resultObj      = null;
     session        = sess;
 }
 /// <summary>
 ///	Overloaded Constructor with three arguments for setting up Error code, Error Desc and session
 /// </summary>
 /// <param name="errCode">ErrorCode</param>
 /// <param name="errDesc">Error Description Object</param>
 /// <param name="sess">OFISession Object</param>
 public NandanaResult(NandanaError.ErrorType errCode, string errDesc, NandanaSession sess)
 {
     status    = StatusType.ERROR;
     errorCode = errCode;
     resultDS  = null;
     resultObj = null;
     session   = sess;
     // append the description to the existing one
     errorDescr += (null != errorDescr && 0 < errorDescr.Length && null != errDesc && 0 < errDesc.Length ? " : ":"") + errDesc;
     NandanaError.PostError(this);
 }
        /// <summary>
        ///	Overloaded Constructor with four arguments for setting up Error code, Error Desc, session and exception
        /// </summary>
        /// <param name="errCode">ErrorCode</param>
        /// <param name="errDesc">Error Description Object</param>
        /// <param name="sess">OFISession Object</param>
        /// <param name="exp">Exception Object</param>
        public NandanaResult(NandanaError.ErrorType errCode, string errDesc, NandanaSession sess, Exception exp)
        {
            status         = StatusType.ERROR;
            errorCode      = errCode;
            errorException = exp;
            resultDS       = null;
            resultObj      = null;
            session        = sess;
            // append the description to the existing one, set by IBCError object
            errorDescr += (null != errorDescr && 0 < errorDescr.Length && null != errDesc && 0 < errDesc.Length ? " : ":"") + errDesc;
            if (null != exp)
            {
#if (DEBUG)
                errorDescr += (null != errorDescr && 0 < errorDescr.Length ? " : ":"") + exp.ToString();
#else
                errorDescr += (null != errorDescr && 0 < errorDescr.Length ? " : ":"") + exp.Message;
#endif
            }
            NandanaError.PostError(this);
        }
        private static XmlElement CreateSessionElement(XmlDocument oRoot, NandanaSession s)
        {
            XmlElement oSession;

            oSession = CreateNode(oRoot, "Session", null, null);
            if (s.TimeZone != 0)
            {
                oSession.AppendChild(CreateNode(oRoot, "TimeZone", null, s.TimeZone.ToString()));
            }
            if (s.UserID != 0)
            {
                oSession.AppendChild(CreateNode(oRoot, "UserID", null, s.UserID.ToString()));
            }
            if (s.UserName != null && s.UserName.Length > 0)
            {
                oSession.AppendChild(CreateNode(oRoot, "UserName", null, s.UserName));
            }

            oSession.AppendChild(CreateRequestElement(oRoot));

            return(oSession);
        }
 /// <summary>
 ///	Check Condition function to validate a condition and fire the error.
 /// </summary>
 public static NandanaResult CheckCondition(bool condition, NandanaError.ErrorType errCode, string errDesc, NandanaSession sess)
 {
     if (!condition)
     {
         if ((null == errDesc) || (0 == errDesc.Length))
         {
             return(new NandanaResult(errCode, sess));
         }
         else
         {
             return(new NandanaResult(errCode, errDesc, sess, null));
         }
     }
     else
     {
         return(new NandanaResult());
     }
 }