Exemple #1
0
        public void GetReturnOptionObject_OptionObject2_Null()
        {
            OptionObject2  nullOptionObject   = null;
            IOptionObject2 returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(nullOptionObject);

            Assert.AreNotEqual("3", returnOptionObject.ErrorCode);
        }
        /// <summary>
        /// Transforms an <see cref="IOptionObject2"/> to <see cref="IOptionObject2015"/>.
        /// </summary>
        /// <param name="optionObject2"></param>
        /// <returns></returns>
        public static IOptionObject2015 TransformToOptionObject2015(IOptionObject2 optionObject2)
        {
            if (optionObject2 == null)
            {
                throw new ArgumentNullException(nameof(optionObject2), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
            }
            if (!IsValidErrorCode(optionObject2.ErrorCode))
            {
                throw new ArgumentException(ScriptLinkHelpers.GetLocalizedString("errorCodeIsNotValid", CultureInfo.CurrentCulture));
            }
            var optionObject2015 = new OptionObject2015
            {
                EntityID        = optionObject2.EntityID,
                EpisodeNumber   = optionObject2.EpisodeNumber,
                ErrorCode       = optionObject2.ErrorCode,
                ErrorMesg       = optionObject2.ErrorMesg,
                Facility        = optionObject2.Facility,
                NamespaceName   = optionObject2.NamespaceName,
                OptionId        = optionObject2.OptionId,
                OptionStaffId   = optionObject2.OptionStaffId,
                OptionUserId    = optionObject2.OptionUserId,
                ParentNamespace = optionObject2.ParentNamespace,
                ServerName      = optionObject2.ServerName,
                SystemCode      = optionObject2.SystemCode,
                Forms           = optionObject2.Forms.Any() ? optionObject2.Forms : new List <FormObject>()
            };

            return(optionObject2015);
        }
Exemple #3
0
        /// <summary>
        /// Transforms an <see cref="IOptionObject2"/> to <see cref="IOptionObject"/>.
        /// </summary>
        /// <param name="optionObject2"></param>
        /// <returns></returns>
        public static IOptionObject TransformToOptionObject(IOptionObject2 optionObject2)
        {
            if (optionObject2 == null)
            {
                throw new ArgumentNullException("Parameter cannot be null", "optionObject2");
            }
            if (!IsValidErrorCode(optionObject2.ErrorCode))
            {
                throw new ArgumentException("Error Code is invalid.");
            }
            var optionObject = new OptionObject
            {
                EntityID      = optionObject2.EntityID,
                EpisodeNumber = optionObject2.EpisodeNumber,
                ErrorCode     = optionObject2.ErrorCode,
                ErrorMesg     = optionObject2.ErrorMesg,
                Facility      = optionObject2.Facility,
                OptionId      = optionObject2.OptionId,
                OptionStaffId = optionObject2.OptionStaffId,
                OptionUserId  = optionObject2.OptionUserId,
                SystemCode    = optionObject2.SystemCode,
                Forms         = optionObject2.Forms.Any() ? optionObject2.Forms : new List <FormObject>()
            };

            return(optionObject);
        }
Exemple #4
0
 /// <summary>
 /// Returns <see cref="IOptionObject2"/> as an HTML string without HTML headers.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <returns></returns>
 public static string TransformToHtmlString(IOptionObject2 optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "formObject");
     }
     return(TransformToHtmlString(optionObject, false));
 }
Exemple #5
0
 /// <summary>
 /// Returns <see cref="IOptionObject2"/> as an HTML string without HTML headers.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <returns></returns>
 public static string TransformToHtmlString(IOptionObject2 optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     return(TransformToHtmlString(optionObject, false));
 }
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject2"/> as enabled by FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumber"></param>
 /// <returns></returns>
 public static IOptionObject2 SetEnabledField(IOptionObject2 optionObject, string fieldNumber)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObject(optionObject, FieldAction.Enable, fieldNumber));
 }
 /// <summary>
 /// Returns the ParentRowId of a <see cref="IFormObject"/> in the <see cref="IOptionObject2"/> by FormId.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <returns></returns>
 public static string GetParentRowId(IOptionObject2 optionObject, string formId)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetParentRowId(optionObject.ToOptionObject2015(), formId));
 }
 /// <summary>
 /// Returns the FieldValue of a specified <see cref="IFieldObject"/> in an <see cref="IOptionObject2"/> by FormId, RowId, and FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <param name="rowId"></param>
 /// <param name="fieldNumber"></param>
 /// <returns></returns>
 public static string GetFieldValue(IOptionObject2 optionObject, string formId, string rowId, string fieldNumber)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetFieldValue(optionObject.ToOptionObject2015(), formId, rowId, fieldNumber));
 }
 /// <summary>
 /// Returns whether the <see cref="IFieldObject"/> in the <see cref="IOptionObject2"/> is present by FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumber"></param>
 /// <returns></returns>
 public static bool IsFieldPresent(IOptionObject2 optionObject, string fieldNumber)
 {
     if (optionObject == null)
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     if (fieldNumber == null || fieldNumber == "")
         throw new ArgumentNullException("Parameter cannot be null or blank.", "fieldNumber");
     return IsFieldPresent(optionObject.ToOptionObject2015(), fieldNumber);
 }
Exemple #10
0
 /// <summary>
 /// Used to create the <see cref="IOptionObject2"/> for return to myAvatar.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <returns></returns>
 public static IOptionObject2 GetReturnOptionObject(IOptionObject2 optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetReturnOptionObject(optionObject, 0, ""));
 }
Exemple #11
0
 /// <summary>
 /// Used to create the <see cref="IOptionObject2"/> for return to myAvatar using provide Error Code and Error Message.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="errorCode"></param>
 /// <param name="errorMessage"></param>
 /// <returns></returns>
 public static IOptionObject2 GetReturnOptionObject(IOptionObject2 optionObject, double errorCode, string errorMessage)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetReturnOptionObject(optionObject.ToOptionObject2015(), errorCode, errorMessage).ToOptionObject2());
 }
Exemple #12
0
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject2"/> as optional by FieldNumbers.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumbers"></param>
 /// <returns></returns>
 public static IOptionObject2 SetOptionalFields(IOptionObject2 optionObject, List <string> fieldNumbers)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObjects(optionObject, FieldAction.Optional, fieldNumbers));
 }
Exemple #13
0
 /// <summary>
 /// Sets <see cref="FieldObject"/> in an <see cref="IOptionObject2"/> according to specified FieldAction.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldAction"></param>
 /// <param name="fieldNumbers"></param>
 /// <returns></returns>
 public static IOptionObject2 SetFieldObjects(IOptionObject2 optionObject, string fieldAction, List <string> fieldNumbers)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObjects(optionObject.ToOptionObject2015(), fieldAction, fieldNumbers).ToOptionObject2());
 }
Exemple #14
0
 /// <summary>
 /// Creates a <see cref="IFormObject"/> with specified FormId and adds to an <see cref="IOptionObject2"/> using provided FormId and indicating whether it is a multiple iteration table.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <param name="multipleIteration"></param>
 /// <returns></returns>
 public static IOptionObject2 AddFormObject(IOptionObject2 optionObject, string formId, bool multipleIteration)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(AddFormObject(optionObject.ToOptionObject2015(), formId, multipleIteration).ToOptionObject2());
 }
Exemple #15
0
 /// <summary>
 /// Sets all <see cref="IFieldObject"/> in the <see cref="IOptionObject2"/> to disabled, except for the FieldNumbers specified in List.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="excludedFields"></param>
 /// <returns></returns>
 public static IOptionObject2 DisableAllFieldObjects(IOptionObject2 optionObject, List <string> excludedFields)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(DisableAllFieldObjects(optionObject.ToOptionObject2015(), excludedFields).ToOptionObject2());
 }
 /// <summary>
 /// Returns whether a <see cref="IFormObject"/> in the <see cref="IOptionObject2"/> is Multiple Iteration by specified FormId.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <returns></returns>
 public static bool GetMultipleIterationStatus(IOptionObject2 optionObject, string formId)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetMultipleIterationStatus(optionObject.ToOptionObject2015(), formId));
 }
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject2"/> as disabled.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldObjects"></param>
 /// <returns></returns>
 public static IOptionObject2 SetDisabledFields(IOptionObject2 optionObject, List <FieldObject> fieldObjects)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObjects(optionObject, FieldAction.Disable, fieldObjects));
 }
 /// <summary>
 /// Used to create the <see cref="IOptionObject2"/> for return to myAvatar.
 /// </summary>
 /// <returns></returns>
 public static IOptionObject2 GetReturnOptionObject(IOptionObject2 optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     return(GetReturnOptionObject(optionObject, 0, ""));
 }
Exemple #19
0
        public static IOptionObject2 Clone(IOptionObject2 optionObject)
        {
            if (optionObject == null)
            {
                throw new ArgumentNullException("The parameter cannot be null.", "optionObject");
            }

            return(TransformToOptionObject2(optionObject.ToJson()));
        }
        /// <summary>
        /// Used to create the <see cref="IOptionObject2"/> for return to myAvatar using provide Error Code and Error Message.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <param name="errorCode"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public static IOptionObject2 GetReturnOptionObject(IOptionObject2 optionObject, double errorCode, string errorMessage)
        {
            if (optionObject == null)
            {
                throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
            }
            IOptionObject2 returnOptionObject = ((OptionObjectBase)optionObject).Clone();

            RemoveUneditedRows(returnOptionObject);
            SetErrorCodeAndMessage(returnOptionObject, errorCode, errorMessage);
            return(returnOptionObject);
        }
 /// <summary>
 /// Returns whether the <see cref="IFieldObject"/> in the <see cref="IOptionObject2"/> is required by FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumber"></param>
 /// <returns></returns>
 public static bool IsFieldRequired(IOptionObject2 optionObject, string fieldNumber)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     if (fieldNumber == null || fieldNumber == "")
     {
         throw new ArgumentNullException("Parameter cannot be null or blank.", "fieldNumber");
     }
     return(IsFieldRequired(optionObject.ToOptionObject2015(), fieldNumber));
 }
 /// <summary>
 /// Flags a <see cref="IRowObject"/> for deletion in specified <see cref="IOptionObject2"/>.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="rowObject"></param>
 /// <returns></returns>
 public static IOptionObject2 DeleteRowObject(IOptionObject2 optionObject, IRowObject rowObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     if (rowObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "rowObject");
     }
     return(DeleteRowObject(optionObject.ToOptionObject2015(), rowObject).ToOptionObject2());
 }
 /// <summary>
 /// Sets the FieldValue of a <see cref="FieldObject"/> in a <see cref="IOptionObject2"/> by FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumber"></param>
 /// <param name="fieldValue"></param>
 /// <returns></returns>
 public static IOptionObject2 SetFieldValue(IOptionObject2 optionObject, string fieldNumber, string fieldValue)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     if (fieldNumber == null || fieldNumber == "")
     {
         throw new ArgumentNullException("Parameter cannot be null or blank.", "fieldNumber");
     }
     return(SetFieldValue(optionObject.ToOptionObject2015(), fieldNumber, fieldValue).ToOptionObject2());;
 }
 /// <summary>
 /// Returns whether the <see cref="IRowObject"/> in an <see cref="IOptionObject2"/> is marked for deletion by RowId.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="rowId"></param>
 /// <returns></returns>
 public static bool IsRowMarkedForDeletion(IOptionObject2 optionObject, string rowId)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     if (rowId == null || rowId == "")
     {
         throw new ArgumentNullException("Parameter cannot be null or blank.", "rowId");
     }
     return(IsRowMarkedForDeletion(optionObject.ToOptionObject2015(), rowId));
 }
 /// <summary>
 /// Flags a <see cref="RowObject"/> for deletion in specified <see cref="IOptionObject2"/> by RowId.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="rowId"></param>
 /// <returns></returns>
 public static IOptionObject2 DeleteRowObject(IOptionObject2 optionObject, string rowId)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     if (rowId == null || rowId == "")
     {
         throw new ArgumentNullException("Parameter cannot be null or blank.", "rowId");
     }
     return(DeleteRowObject(optionObject.ToOptionObject2015(), rowId).ToOptionObject2());
 }
Exemple #26
0
 /// <summary>
 /// Adds a <see cref="IFormObject"/> to an <see cref="IOptionObject2"/>.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formObject"></param>
 /// <returns></returns>
 public static IOptionObject2 AddFormObject(IOptionObject2 optionObject, IFormObject formObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     if (formObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "formObject");
     }
     return(AddFormObject(optionObject.ToOptionObject2015(), formObject).ToOptionObject2());
 }
Exemple #27
0
 /// <summary>
 /// Returns whether a <see cref="FormObject"/> exists in an <see cref="OptionObject2"/> by <see cref="FormObject.FormId"/>.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <returns></returns>
 public static bool IsFormPresent(IOptionObject2 optionObject, string formId)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     if (formId == null || formId == "")
     {
         throw new ArgumentNullException("Parameter cannot be null or blank.", "formId");
     }
     return(IsFormPresent(optionObject.ToOptionObject2015(), formId));
 }
Exemple #28
0
        /// <summary>
        /// Returns <see cref="IOptionObject2"/> as an HTML string with or without HTML headers.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <param name="includeHtmlHeaders"></param>
        /// <returns></returns>
        public static string TransformToHtmlString(IOptionObject2 optionObject, bool includeHtmlHeaders)
        {
            if (optionObject == null)
            {
                throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(GetHeader(optionObject.GetType().ToString(), includeHtmlHeaders));
            sb.Append(GetHtmlForObject(optionObject, HtmlOutputType.Table));
            sb.Append(AddFormTables(optionObject, 2));
            sb.Append(GetFooter(includeHtmlHeaders));
            return(sb.ToString());
        }
 /// <summary>
 /// Adds a <see cref="RowObject"/> to a specified <see cref="IFormObject"/> within provided <see cref="IOptionObject2"/>.
 /// </summary>
 /// <param name="optionObject2"></param>
 /// <param name="formId"></param>
 /// <param name="rowObject"></param>
 /// <returns></returns>
 public static IOptionObject2 AddRowObject(IOptionObject2 optionObject2, string formId, IRowObject rowObject)
 {
     if (optionObject2 == null)
     {
         throw new System.ArgumentNullException("Parameter cannot be null.", "optionObject2");
     }
     if (formId == null || formId == "")
     {
         throw new System.ArgumentNullException("Parameter cannot be null or blank.", "formId");
     }
     if (rowObject == null)
     {
         throw new System.ArgumentNullException("Parameter cannot be null.", "rowObject");
     }
     return(AddRowObject(optionObject2.ToOptionObject2015(), formId, rowObject).ToOptionObject2());
 }
Exemple #30
0
        /// <summary>
        /// Returns <see cref="IOptionObject2"/> as an HTML string with or without HTML headers.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <param name="includeHtmlHeaders"></param>
        /// <returns></returns>
        public static string TransformToHtmlString(IOptionObject2 optionObject, bool includeHtmlHeaders)
        {
            if (optionObject == null)
            {
                throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
            }
            string html = "";

            html += includeHtmlHeaders ? GetHtmlHeader() : "";
            html += GetPageHeader(optionObject.GetType().ToString());
            html += "<h2>Forms</h2>";
            foreach (FormObject formObject in optionObject.Forms)
            {
                html += "<h3>Form<h3>";
                html += GetHtmlForObject(formObject, HtmlOutputType.Table);
                html += "<h4>CurrentRow</h4>";
                html += GetHtmlForObject(formObject.CurrentRow, HtmlOutputType.Table);
                html += "<h5>Fields</h5>";
                html += "<table>";
                html += GetHtmlForObject(formObject.CurrentRow.Fields.FirstOrDefault(), HtmlOutputType.TableHeaders);
                foreach (FieldObject fieldObject in formObject.CurrentRow.Fields)
                {
                    html += GetHtmlForObject(fieldObject, HtmlOutputType.TableRow);
                }
                html += "</table>";
                html += "<h4>OtherRows</h4>";
                foreach (RowObject rowObject in formObject.OtherRows)
                {
                    html += "<h5>Row</h5>";
                    html += GetHtmlForObject(rowObject, HtmlOutputType.Table);
                    html += "<h6>Fields</h6>";
                    html += "<table>";
                    html += GetHtmlForObject(formObject.CurrentRow.Fields.First(), HtmlOutputType.TableHeaders);
                    foreach (FieldObject fieldObject in formObject.CurrentRow.Fields)
                    {
                        html += GetHtmlForObject(fieldObject, HtmlOutputType.TableRow);
                    }
                    html += "</table>";
                }
            }
            html += includeHtmlHeaders ? GetHtmlFooter() : "";
            return(html);
        }