コード例 #1
0
 /// <summary>
 /// Adds a <see cref="RowObject"/> to a specified <see cref="FormObject"/> within provided <see cref="OptionObject"/>.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <param name="rowObject"></param>
 /// <returns></returns>
 public static IOptionObject AddRowObject(IOptionObject optionObject, string formId, IRowObject rowObject)
 {
     if (optionObject == null)
     {
         throw new System.ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (string.IsNullOrEmpty(formId))
     {
         throw new System.ArgumentNullException(nameof(formId), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (rowObject == null)
     {
         throw new System.ArgumentNullException(nameof(rowObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (IsFormPresent(optionObject, formId))
     {
         for (int i = 0; i < optionObject.Forms.Count; i++)
         {
             if (optionObject.Forms[i].FormId == formId)
             {
                 optionObject.Forms[i] = (FormObject)AddRowObject(optionObject.Forms[i], rowObject);
                 break;
             }
         }
     }
     return(optionObject);
 }
コード例 #2
0
 /// <summary>
 /// Sets the FieldValue of a <see cref="FieldObject"/> in a <see cref="IOptionObject"/> by FormId, RowID, and FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <param name="rowId"></param>
 /// <param name="fieldNumber"></param>
 /// <param name="fieldValue"></param>
 /// <returns></returns>
 public static IOptionObject SetFieldValue(IOptionObject optionObject, string formId, string rowId, string fieldNumber, string fieldValue)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (string.IsNullOrEmpty(formId))
     {
         throw new ArgumentNullException(nameof(formId), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (string.IsNullOrEmpty(rowId))
     {
         throw new ArgumentNullException(nameof(rowId), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (string.IsNullOrEmpty(fieldNumber))
     {
         throw new ArgumentNullException(nameof(fieldNumber), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (optionObject.Forms == null)
     {
         throw new NullReferenceException(ScriptLinkHelpers.GetLocalizedString("optionObjectMissingForms", CultureInfo.CurrentCulture));
     }
     for (int i = 0; i < optionObject.Forms.Count; i++)
     {
         if (optionObject.Forms[i].FormId == formId)
         {
             optionObject.Forms[i] = (FormObject)SetFieldValue(optionObject.Forms[i], rowId, fieldNumber, fieldValue);
         }
     }
     return(optionObject);
 }
コード例 #3
0
        public void GetReturnOptionObject_ErrorCode_Negative1_Error()
        {
            int           expected           = -1;
            IOptionObject returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(optionObject, expected, "test");

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

            return(optionObject2015);
        }
コード例 #5
0
        public void GetReturnOptionObject_ErrorMessage_AreEqual()
        {
            string        expected           = "Hello World!";
            IOptionObject returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(optionObject, 1, expected);

            Assert.AreEqual(expected, returnOptionObject.ErrorMesg);
        }
コード例 #6
0
        public void GetReturnOptionObject_ErrorCode_6_AreEqual()
        {
            int           expected           = 6;
            IOptionObject returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(optionObject, expected, "[PM]GUISYS560");

            Assert.AreEqual(expected, returnOptionObject.ErrorCode);
        }
コード例 #7
0
 /// <summary>
 /// Returns the FieldValue of a specified <see cref="IFieldObject"/> in an <see cref="IOptionObject2015"/> 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(IOptionObject optionObject, string formId, string rowId, string fieldNumber)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (string.IsNullOrEmpty(formId))
     {
         throw new ArgumentNullException(nameof(formId), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (string.IsNullOrEmpty(rowId))
     {
         throw new ArgumentNullException(nameof(rowId), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     if (string.IsNullOrEmpty(fieldNumber))
     {
         throw new ArgumentNullException(nameof(fieldNumber), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     foreach (var form in optionObject.Forms)
     {
         if (form.FormId == formId)
         {
             return(GetFieldValue(form, rowId, fieldNumber));
         }
     }
     throw new ArgumentException(ScriptLinkHelpers.GetLocalizedString("noFieldObjectsFoundByFieldNumber", CultureInfo.CurrentCulture) + fieldNumber, nameof(fieldNumber));
 }
コード例 #8
0
        public void GetReturnOptionObject_ErrorCode_6_InvalidOpenFormString()
        {
            int           expected           = 6;
            IOptionObject returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(optionObject, expected, "test");

            Assert.AreEqual(expected, returnOptionObject.ErrorCode);
        }
コード例 #9
0
        public void GetReturnOptionObject_ErrorCode_5_AreEqual()
        {
            int           expected           = 5;
            IOptionObject returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(optionObject, expected, "http://www.rcskids.org");

            Assert.AreEqual(expected, returnOptionObject.ErrorCode);
        }
コード例 #10
0
        /// <summary>
        /// Transforms an <see cref="IOptionObject"/> to <see cref="IOptionObject2"/>.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <returns></returns>
        public static IOptionObject2 TransformToOptionObject2(IOptionObject optionObject)
        {
            if (optionObject == null)
            {
                throw new ArgumentNullException("Parameter cannot be null", "optionObject2");
            }
            if (!IsValidErrorCode(optionObject.ErrorCode))
            {
                throw new ArgumentException("Error Code is invalid.");
            }
            var optionObject2 = new OptionObject2
            {
                EntityID      = optionObject.EntityID,
                EpisodeNumber = optionObject.EpisodeNumber,
                ErrorCode     = optionObject.ErrorCode,
                ErrorMesg     = optionObject.ErrorMesg,
                Facility      = optionObject.Facility,
                OptionId      = optionObject.OptionId,
                OptionStaffId = optionObject.OptionStaffId,
                OptionUserId  = optionObject.OptionUserId,
                SystemCode    = optionObject.SystemCode,
                Forms         = optionObject.Forms.Any() ? optionObject.Forms : new List <FormObject>()
            };

            return(optionObject2);
        }
コード例 #11
0
        public static IOptionObject RemoveUneditedRows(IOptionObject optionObject)
        {
            if (optionObject == null)
            {
                throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
            }

            List <FormObject> formsToRemove = new List <FormObject>();

            for (int i = 0; i < optionObject.Forms.Count; i++)
            {
                optionObject.Forms[i] = (FormObject)RemoveUneditedRows(optionObject.Forms[i]);
                if (optionObject.Forms[i].CurrentRow == null && optionObject.Forms[i].OtherRows.Count == 0)
                {
                    formsToRemove.Add(optionObject.Forms[i]);
                }
                else if (optionObject.Forms[i].OtherRows.Count == 0)
                {
                    optionObject.Forms[i].OtherRows = null;
                }
            }
            foreach (var formObject in formsToRemove)
            {
                optionObject.Forms.Remove(formObject);
            }

            return(optionObject);
        }
コード例 #12
0
        /// <summary>
        /// Sets the FieldValue of a <see cref="FieldObject"/> in a <see cref="IOptionObject"/> by FieldNumber.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <param name="fieldNumber"></param>
        /// <param name="fieldValue"></param>
        /// <returns></returns>
        public static IOptionObject SetFieldValue(IOptionObject optionObject, string fieldNumber, string fieldValue)
        {
            if (optionObject == null)
            {
                throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
            }
            if (optionObject.Forms == null)
            {
                throw new NullReferenceException(ScriptLinkHelpers.GetLocalizedString("optionObjectMissingForms", CultureInfo.CurrentCulture));
            }
            if (string.IsNullOrEmpty(fieldNumber))
            {
                throw new ArgumentNullException(nameof(fieldNumber), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
            }
            foreach (FormObject formObject in optionObject.Forms)
            {
                if (formObject.IsFieldPresent(fieldNumber))
                {
                    if (formObject.MultipleIteration && formObject.OtherRows.Count > 0)
                    {
                        throw new ArgumentException(ScriptLinkHelpers.GetLocalizedString("unableToIdentifyFieldObject", CultureInfo.CurrentCulture), nameof(optionObject));
                    }

                    string formId = formObject.FormId;
                    string rowId  = formObject.GetCurrentRowId();
                    return(SetFieldValue(optionObject, formId, rowId, fieldNumber, fieldValue));
                }
            }
            throw new ArgumentException(ScriptLinkHelpers.GetLocalizedString("noFieldObjectsFoundByFieldNumber", CultureInfo.CurrentCulture) + fieldNumber, nameof(fieldNumber));
        }
コード例 #13
0
        public void GetReturnOptionObject_OptionObject_Null()
        {
            OptionObject  nullOptionObject   = null;
            IOptionObject returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(nullOptionObject);

            Assert.AreNotEqual("3", returnOptionObject.ErrorCode);
        }
コード例 #14
0
        public void GetReturnOptionObject_ErrorCode_5_InvalidURL()
        {
            int           expected           = 5;
            IOptionObject returnOptionObject = ScriptLinkHelpers.GetReturnOptionObject(optionObject, expected, "test");

            Assert.AreEqual(expected, returnOptionObject.ErrorCode);
        }
コード例 #15
0
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject"/> as optional by FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumber"></param>
 /// <returns></returns>
 public static IOptionObject SetOptionalField(IOptionObject optionObject, string fieldNumber)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     return(SetFieldObject(optionObject, FieldAction.Optional, fieldNumber));
 }
コード例 #16
0
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject"/> as optional by FieldNumbers.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumbers"></param>
 /// <returns></returns>
 public static IOptionObject SetOptionalFields(IOptionObject optionObject, List <string> fieldNumbers)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObjects(optionObject, FieldAction.Optional, fieldNumbers));
 }
コード例 #17
0
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject"/> as disabled.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldObjects"></param>
 /// <returns></returns>
 public static IOptionObject SetDisabledFields(IOptionObject optionObject, List <FieldObject> fieldObjects)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObjects(optionObject, FieldAction.Disable, fieldObjects));
 }
コード例 #18
0
 /// <summary>
 /// Used to create the <see cref="IOptionObject"/> 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 IOptionObject GetReturnOptionObject(IOptionObject optionObject, double errorCode, string errorMessage)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetReturnOptionObject(optionObject.ToOptionObject2015(), errorCode, errorMessage).ToOptionObject());
 }
 /// <summary>
 /// Used to create the <see cref="IOptionObject"/> for return to myAvatar.
 /// </summary>
 /// <returns></returns>
 public static IOptionObject GetReturnOptionObject(IOptionObject optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     return(GetReturnOptionObject(optionObject, 0, ""));
 }
コード例 #20
0
 /// <summary>
 /// Returns the FieldValue of a specified <see cref="IFieldObject"/> in an <see cref="IOptionObject"/> 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(IOptionObject 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));
 }
コード例 #21
0
 /// <summary>
 /// Returns <see cref="IOptionObject"/> as an HTML string without HTML headers.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <returns></returns>
 public static string TransformToHtmlString(IOptionObject optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     return(TransformToHtmlString(optionObject, false));
 }
 /// <summary>
 /// Sets all <see cref="IFieldObject"/> in the <see cref="IOptionObject"/> to disabled.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <returns></returns>
 public static IOptionObject DisableAllFieldObjects(IOptionObject optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     return(DisableAllFieldObjects(optionObject, new List <string>()));
 }
コード例 #23
0
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject"/> as disabled by FieldNumbers.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumbers"></param>
 /// <returns></returns>
 public static IOptionObject SetDisabledFields(IOptionObject optionObject, List <string> fieldNumbers)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture));
     }
     return(SetFieldObjects(optionObject, FieldAction.Disable, fieldNumbers));
 }
コード例 #24
0
 /// <summary>
 /// Sets all <see cref="IFieldObject"/> in the <see cref="IOptionObject"/> to disabled, except for the FieldNumbers specified in List.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="excludedFields"></param>
 /// <returns></returns>
 public static IOptionObject DisableAllFieldObjects(IOptionObject optionObject, List <string> excludedFields)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(DisableAllFieldObjects(optionObject.ToOptionObject2015(), excludedFields).ToOptionObject());
 }
コード例 #25
0
 /// <summary>
 /// Returns the ParentRowId of a <see cref="IFormObject"/> in the <see cref="IOptionObject"/> by FormId.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="formId"></param>
 /// <returns></returns>
 public static string GetParentRowId(IOptionObject optionObject, string formId)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetParentRowId(optionObject.ToOptionObject2015(), formId));
 }
コード例 #26
0
 /// <summary>
 /// Creates a <see cref="IFormObject"/> with specified FormId and adds to an <see cref="IOptionObject"/> 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 IOptionObject AddFormObject(IOptionObject optionObject, string formId, bool multipleIteration)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(AddFormObject(optionObject.ToOptionObject2015(), formId, multipleIteration).ToOptionObject());
 }
コード例 #27
0
 /// <summary>
 /// Sets <see cref="FieldObject"/> in an <see cref="IOptionObject"/> according to specified FieldAction.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldAction"></param>
 /// <param name="fieldNumbers"></param>
 /// <returns></returns>
 public static IOptionObject SetFieldObjects(IOptionObject optionObject, string fieldAction, List <string> fieldNumbers)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObjects(optionObject.ToOptionObject2015(), fieldAction, fieldNumbers).ToOptionObject());
 }
コード例 #28
0
 /// <summary>
 /// Used to create the <see cref="IOptionObject"/> for return to myAvatar.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="errorCode"></param>
 /// <param name="errorMessage"></param>
 /// <returns></returns>
 public static IOptionObject GetReturnOptionObject(IOptionObject optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null", "optionObject");
     }
     return(GetReturnOptionObject(optionObject.ToOptionObject2015(), 0, "").ToOptionObject());
 }
コード例 #29
0
 /// <summary>
 /// Sets the <see cref="IFieldObject"/> in a <see cref="IOptionObject"/> as enabled by FieldNumber.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <param name="fieldNumber"></param>
 /// <returns></returns>
 public static IOptionObject SetEnabledField(IOptionObject optionObject, string fieldNumber)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "optionObject");
     }
     return(SetFieldObject(optionObject, FieldAction.Enable, fieldNumber));
 }
コード例 #30
0
 /// <summary>
 /// Returns <see cref="IOptionObject"/> as an HTML string without HTML headers.
 /// </summary>
 /// <param name="optionObject"></param>
 /// <returns></returns>
 public static string TransformToHtmlString(IOptionObject optionObject)
 {
     if (optionObject == null)
     {
         throw new ArgumentNullException("Parameter cannot be null.", "formObject");
     }
     return(TransformToHtmlString(optionObject, false));
 }