public EntryFieldTypeView(string label, EntryFieldType type)
        {
            if (String.IsNullOrEmpty(label))
                throw new ArgumentNullException("label");

            this.Label = label;
            this.EntryFieldType = type;
        }
        private SearchCriteria GetMatchingSearchCriteriaForEntryField(EntryFieldType entryField)
        {
            SearchCriteria criteria = SearchCriteria.NoSelection;

            switch (entryField)
            {
            case EntryFieldType.Attention:
                criteria = SearchCriteria.Attention;
                break;

            case EntryFieldType.Date:
                criteria = SearchCriteria.TransmittalDate_From;
                break;

            case EntryFieldType.DesignPackages:
                criteria = SearchCriteria.DesignPackages;
                break;

            case EntryFieldType.DocumentType:
                criteria = SearchCriteria.DocumentType;
                break;

            case EntryFieldType.DocumentCategory:
                criteria = SearchCriteria.Category;
                break;

            case EntryFieldType.From:
                criteria = SearchCriteria.From;
                break;

            case EntryFieldType.MSLNumber:
                criteria = SearchCriteria.MSLNo;
                break;

            case EntryFieldType.OriginatorDocumentRef:
                criteria = SearchCriteria.OriginatorDocumentRef;
                break;

            case EntryFieldType.Segment_Area:
                criteria = SearchCriteria.SegmentArea;
                break;

            case EntryFieldType.SpecSection:
                criteria = SearchCriteria.SpecSection;
                break;

            case EntryFieldType.Title:
                criteria = SearchCriteria.Title;
                break;

            case EntryFieldType.TransmittalNumber:
                criteria = SearchCriteria.TransmittalNumber;
                break;
            }

            return(criteria);
        }
Exemple #3
0
        private KeyValuePair <EntryFieldType, string> PopulateFieldValue <T>(EntryFieldType entryField, T indexOrText, bool useContains = false)
        {
            string fieldType  = entryField.GetString(true);
            Type   argType    = indexOrText.GetType();
            object argValue   = null;
            bool   isValidArg = false;

            KeyValuePair <EntryFieldType, string> fieldValuePair;
            string fieldValue = string.Empty;

            try
            {
                if (argType == typeof(string))
                {
                    isValidArg = true;
                    argValue   = ConvertToType <string>(indexOrText);
                }
                else if (argType == typeof(int))
                {
                    isValidArg = true;
                    argValue   = ConvertToType <int>(indexOrText);
                }

                if (isValidArg)
                {
                    switch (fieldType)
                    {
                    case TEXT:
                    case DATE:
                    case FUTUREDATE:
                        if (!((string)argValue).HasValue())
                        {
                            if (fieldType.Equals(DATE) || fieldType.Equals(FUTUREDATE))
                            {
                                argValue = fieldType.Equals(DATE)
                                        ? GetShortDate()
                                        : GetFutureShortDate();
                            }
                            else
                            {
                                //argValue = GetVarForEntryField(entryField);
                                argValue = GetVar(entryField);
                                int argValueLength = ((string)argValue).Length;

                                By  inputLocator  = GetInputFieldByLocator(entryField);
                                int elemMaxLength = int.Parse(PageAction.GetAttribute(inputLocator, "maxlength"));

                                argValue = argValueLength > elemMaxLength
                                        ? ((string)argValue).Substring(0, elemMaxLength)
                                        : argValue;
                            }

                            fieldValue = (string)argValue;
                        }

                        PageAction.EnterText(By.Id(entryField.GetString()), fieldValue);

                        break;

                    case DDL:
                    case MULTIDDL:
                        if ((argType == typeof(string) && !((string)argValue).HasValue()) || (int)argValue < 1)
                        {
                            argValue = 1;
                        }

                        bool isMultiselectDDList = false;

                        if (fieldType.Equals(MULTIDDL))
                        {
                            isMultiselectDDList = true;
                        }

                        PageAction.ExpandAndSelectFromDDList(entryField, argValue, useContains, isMultiselectDDList);

                        break;

                    case RDOBTN:
                    case CHKBOX:
                        PageAction.SelectRadioBtnOrChkbox(entryField);

                        break;

                    case UPLOAD:
                        PageAction.UploadFile();

                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    log.Error($"Argument type ({argType}) is not supported : {indexOrText.ToString()}");
                }
            }
            catch (Exception e)
            {
                log.Error(e.StackTrace);
            }

            return(fieldValuePair = new KeyValuePair <EntryFieldType, string>(entryField, fieldValue));
        }