コード例 #1
0
        public static DataFieldType GetFieldType(string ft)
        {
            if (string.IsNullOrEmpty(ft))
            {
                return(DataFieldType.None);
            }

            string fType = ft;

            if (ft.IndexOf('(') >= 0)
            {
                fType = ft.Substring(0, ft.IndexOf('('));
            }

            if (string.IsNullOrEmpty(ft))
            {
                return(DataFieldType.None);
            }

            DataFieldType result = DataFieldType.None;

            if (Enum.TryParse <DataFieldType>(fType, true, out result))
            {
                return(result);
            }
            return(DataFieldType.None);
        }
コード例 #2
0
ファイル: Translation.cs プロジェクト: pikju/DokuExtractor
        public static string TranslateDataFieldTypeEnum(DataFieldType fieldType)
        {
            switch (fieldType)
            {
            case DataFieldType.Text:
                return(LanguageStrings.FieldTypeText);

            case DataFieldType.Date:
                return(LanguageStrings.FieldTypeDate);

            case DataFieldType.Currency:
                return(LanguageStrings.FieldTypeCurrency);

            case DataFieldType.IBAN:
                return(LanguageStrings.FieldTypeIban);

            case DataFieldType.AnchorLessIBAN:
                return(LanguageStrings.FieldTypeAnchorlessIban);

            case DataFieldType.VatId:
                return(LanguageStrings.FieldTypeVatId);

            case DataFieldType.Term:
                return(LanguageStrings.FieldTypeTerm);

            default:
                return(string.Empty);
            }
        }
コード例 #3
0
ファイル: FormHelper.cs プロジェクト: uNormatov/FreboCms
 /// <summary>
 /// Get Data Type Name By ID
 /// </summary>
 /// <param name="dataFieldType"></param>
 /// <returns></returns>
 public static string GetDataTypeCodeByType(DataFieldType dataFieldType)
 {
     switch (dataFieldType)
     {
         case DataFieldType.Boolean:
             return DataFieldTypeCode.BOOLEAN;
         case DataFieldType.Char:
             return DataFieldTypeCode.CHAR;
         case DataFieldType.DateTime:
             return DataFieldTypeCode.DATETIME;
         case DataFieldType.Decimal:
             return DataFieldTypeCode.DECIMAL;
         case DataFieldType.GUID:
             return DataFieldTypeCode.GUID;
         case DataFieldType.File:
             return DataFieldTypeCode.FILE;
         case DataFieldType.Integer:
             return DataFieldTypeCode.INTEGER;
         case DataFieldType.Text:
             return DataFieldTypeCode.TEXT;
         case DataFieldType.Varchar:
             return DataFieldTypeCode.VARCHAR;
         case DataFieldType.Numeric:
             return DataFieldTypeCode.NUMERIC;
         default:
             return DataFieldTypeCode.UNKNOWN;
     }
 }
コード例 #4
0
 /// <summary>
 ///		Convierte el tipo de campo
 /// </summary>
 private JabberFormItem.FormItemType ConvertFieldType(DataFieldType? intType)
 {
     if (intType == null)
         return JabberFormItem.FormItemType.TextSingle;
     else
         switch (intType)
             {	case DataFieldType.Boolean:
                     return JabberFormItem.FormItemType.Boolean;
                 case DataFieldType.Fixed:
                     return JabberFormItem.FormItemType.Fixed;
                 case DataFieldType.Hidden:
                     return JabberFormItem.FormItemType.Hidden;
                 case DataFieldType.JidMulti:
                     return JabberFormItem.FormItemType.JidMulti;
                 case DataFieldType.JidSingle:
                     return JabberFormItem.FormItemType.JidSingle;
                 case DataFieldType.ListMulti:
                     return JabberFormItem.FormItemType.ListMultiple;
                 case DataFieldType.ListSingle:
                     return JabberFormItem.FormItemType.ListSingle;
                 case DataFieldType.TextMulti:
                     return JabberFormItem.FormItemType.TextMultiple;
                 case DataFieldType.TextPrivate:
                     return JabberFormItem.FormItemType.TextPrivate;
                 case DataFieldType.TextSingle:
                     return JabberFormItem.FormItemType.TextSingle;
                 default:
                     return JabberFormItem.FormItemType.Hidden;
             }
 }
コード例 #5
0
 /// <summary>
 /// Asserts the data-field is of the specified type.
 /// </summary>
 /// <param name="expected">The type to assert.</param>
 /// <exception cref="ArgumentException">The data-field is not of the
 /// expected type.</exception>
 protected void AssertType(DataFieldType expected)
 {
     if (Type != expected)
     {
         throw new ArgumentException("The specified XML element is not a " +
                                     "data-field of type '" + expected.ToString() + "'.");
     }
 }
コード例 #6
0
 public DataField(DataFieldType type, string name = null, bool required = false, string label = null, string description = null)
 {
     this.element     = Xml.Element("field", null);
     this.Type        = new DataFieldType?(type);
     this.Name        = name;
     this.Required    = required;
     this.Label       = label;
     this.Description = description;
 }
コード例 #7
0
        protected void AssertType(DataFieldType expected)
        {
            DataFieldType?nullable = this.Type;
            DataFieldType type     = expected;

            if ((((DataFieldType)nullable.GetValueOrDefault()) != type) || !nullable.HasValue)
            {
                throw new ArgumentException("The specified XML element is not a data-field of type '" + expected.ToString() + "'.");
            }
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the DataField class for use in a
 /// requesting dataform.
 /// </summary>
 /// <param name="type">The type of the field.</param>
 /// <param name="name">The name of the field.</param>
 /// <param name="required">Determines whether the field is required or
 /// optional.</param>
 /// <param name="label">A human-readable name for the field.</param>
 /// <param name="description">A natural-language description of the field,
 /// intended for presentation in a user-agent.</param>
 public DataField(DataFieldType type, string name = null, bool required = false,
                  string label = null, string description = null)
 {
     element     = Xml.Element("field");
     Type        = type;
     Name        = name;
     Required    = required;
     Label       = label;
     Description = description;
 }
コード例 #9
0
        /// <summary>
        /// Add a typed value to this form
        /// </summary>
        /// <param name="name">The name of the value</param>
        /// <param name="type">The type of the value to add</param>
        /// <param name="value">The value to add</param>
        /// <returns>This data form</returns>
        public DataForm AddValue(string name, DataFieldType type, object value)
        {
            var valueNode = Xml.Element("value", xmlns);

            if (value != null)
            {
                valueNode.Text(value.ToString());
            }

            element.Child(Xml.Element("field", xmlns).Attr("var", name).Attr("type", type.ToString()).Child(valueNode));

            return(this);
        }
コード例 #10
0
        public static void GetFieldDicKeyInfo(string ft, out DataFieldInfo keyField, out DataFieldInfo valueField)
        {
            keyField   = null;
            valueField = null;

            if (string.IsNullOrEmpty(ft))
            {
                return;
            }
            int sIndex = ft.IndexOf('(');
            int lIndex = ft.LastIndexOf(')');

            if (sIndex < 0 || lIndex < 0)
            {
                return;
            }
            string fTypeStr = ft.Substring(sIndex + 1, lIndex - sIndex - 1);

            if (fTypeStr.IndexOf('/') <= 0)
            {
                return;
            }
            string[] fTypeStrSplit = fTypeStr.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            if (fTypeStrSplit == null || fTypeStrSplit.Length != 2)
            {
                return;
            }

            DataFieldType keyFT   = GetFieldType(fTypeStrSplit[0]);
            DataFieldType valueFT = GetFieldType(fTypeStrSplit[1]);

            if (keyFT == DataFieldType.None || valueFT == DataFieldType.None)
            {
                return;
            }

            keyField      = new DataFieldInfo();
            keyField.type = keyFT;
            if (keyFT == DataFieldType.Ref)
            {
                keyField.refName = GetFieldRefName(fTypeStrSplit[0]);
            }
            valueField      = new DataFieldInfo();
            valueField.type = valueFT;
            if (valueFT == DataFieldType.Ref)
            {
                valueField.refName = GetFieldRefName(fTypeStrSplit[1]);
            }
        }
コード例 #11
0
        private string TypeToAttributeValue(DataFieldType type)
        {
            StringBuilder builder = new StringBuilder();
            string        s       = type.ToString();

            for (int i = 0; i < s.Length; i++)
            {
                if (char.IsUpper(s, i) && (i > 0))
                {
                    builder.Append('-');
                }
                builder.Append(char.ToLower(s[i]));
            }
            return(builder.ToString());
        }
コード例 #12
0
        /// <summary>
        /// Converts the specified value from the DataFieldType enumeration into
        /// its respective textual representation.
        /// </summary>
        /// <param name="type">The value to convert into a string.</param>
        /// <returns>A string representing the specified value.</returns>
        string TypeToAttributeValue(DataFieldType type)
        {
            StringBuilder b = new StringBuilder();
            string        s = type.ToString();

            for (int i = 0; i < s.Length; i++)
            {
                if (Char.IsUpper(s, i) && i > 0)
                {
                    b.Append('-');
                }
                b.Append(Char.ToLower(s[i]));
            }
            return(b.ToString());
        }
コード例 #13
0
        private void UcResultAndEditor1_RegexOrPositionHelper(Guid id, DataFieldType dataFieldType, DataFieldMode dataFieldMode)
        {
            EnableOrDisableControlsAndButtons(false);

            regexOrPositionHelperId = id;
            regexHelperFieldType    = dataFieldType;

            if (dataFieldMode == DataFieldMode.Regex)
            {
                isAnchorSelectionRunning = true;
                lblInstruction.Text      = Translation.LanguageStrings.InstructionSelectAnchor;
                lblInstruction.BackColor = Color.Orange;
            }
            else if (dataFieldMode == DataFieldMode.Position)
            {
                isPositionSelectionRunning = true;
                lblInstruction.Text        = Translation.LanguageStrings.InstructionSelectAreaPosition;
                lblInstruction.BackColor   = Color.Orange;
            }
        }
コード例 #14
0
        private void btFindRegexExpression_Click(object sender, EventArgs e)
        {
            tbRegexTextAnchor.Text = tbRegexTextAnchor.Text.Trim(' ');
            var finder = new RegexExpressionFinder();

            DataFieldType type = (DataFieldType)Enum.Parse(typeof(DataFieldType), listBox1.SelectedItem.ToString(), true);

            RegexExpressionFinderResult expressionResult;

            if (finder.TryFindRegexMatchExpress(tbInhalt.Text, tbRegexTextAnchor.Text, tbRegexTargetValue.Text, type, false, out expressionResult))
            {
                tbExtractedData.Text = "Regex expression found:" + Environment.NewLine + expressionResult.RegexExpression + Environment.NewLine
                                       + Environment.NewLine + "First matching value:" + Environment.NewLine + expressionResult.MatchingValue + Environment.NewLine + Environment.NewLine
                                       + Environment.NewLine + "All matching values: " + expressionResult.AllMatchingValues.ConcatList("; ");
            }
            else
            {
                tbExtractedData.Text = "Kein Match gefunden -.-";
            }
        }
コード例 #15
0
        public static void GetArrayFieldInfo(string ft, out DataFieldInfo valueField)
        {
            valueField = null;
            if (string.IsNullOrEmpty(ft))
            {
                return;
            }
            int sIndex = ft.IndexOf('(');
            int lIndex = ft.LastIndexOf(')');

            if (sIndex < 0 || lIndex < 0)
            {
                return;
            }
            string        fTypeStr = ft.Substring(sIndex + 1, lIndex - sIndex - 1);
            DataFieldType fType    = GetFieldType(fTypeStr);

            valueField      = new DataFieldInfo();
            valueField.type = fType;
            if (fType == DataFieldType.Ref)
            {
                valueField.refName = GetFieldRefName(ft);
            }
        }
コード例 #16
0
        //List<string> dateExpressions = new List<string>()
        //{
        // @"(\d+.\d{2}.\d+)",@"([a-zA-Z]+ \d+ , \d+)",@"(\d{2}-\d{2}-\d{4})",
        // @"([\s,\d]+-[A-Z,a-z]{3}-\d{4})",@"(\d{1,2}\w+,\d{4})",@"(\d{1,2}\. \w+ \d{4})",
        // @"(\d{4}-\d{2}-\d{2})",@"(\w+,\d{4})",@"(\d{1,2}\w+,\d{4})",@"(\d{1,2}\.\w+\d{4})",
        // @"(\d+\D+\s+\w+\s+\d+)",@"(\d+\. .+ \d{4})",
        // @"(\d{2}-\w+-\d{4})",@"(\w{1,10}\d+,\d{4})",@"(\w{3,}\d{1,2},\d{4})",@"(\d{1,2}.+\s+\d{4})",
        // @"(\d{2}\/\d{2}\/\d{4})",@"(\d+/\d+/\d+)",@"(\d+/\d+/\d{4})",@"(\d{1,2}\/\d{1,2}\/\d{4})",
        // @"(\d{4}-\d{2}-\d{2})",@"(\d{4}-\d{2}-\d{2})",@"(\d{1,2}\/\d{1,2}\/\d{4})",@"(\d{2}\,\d{2}\,\d{4})",
        // @"(\w+\s*\d+,\s*\d{4})",@"(\d{1,2}-\d{1,2}-\d{4})",@"(\d{2}/\d{2}/\d{4})",@"(\d{1,2}\.\d{1,2}\.\d{4})",@"(\d{2}.+,\s\d{4})",@"(\d+\.\d+\s\d+\s\d)"

        //};

        //List<string> currencyExpressions = new List<string>()
        //{
        // @"(\d+.?\d{0,3},\d{2})",
        // @"(\d+,\d{2})\D",
        // @"(\d+'\d{2})\D",
        // @"(\d+\D\d{2})\D",
        // @"(\d+.\d{3},\d{2})",
        // @"(\d+,\d{2})",
        // @"(\d+'\d{2})",
        // @"(\d+\D\d{2})"
        //};

        //List<string> IBANExpressions = new List<string>()
        //{
        //@"([a-zA-Z]{2}\d{2}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{2})"
        //};

        //List<string> WildCardIBANExpressions = new List<string>()
        //{
        //@"([a-zA-Z]{2}\d{2}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{4}\s?[0-9a-zA-Z]{2})"
        //};

        //List<string> VatIdExpressions = new List<string>()
        //{
        //@"([a-zA-Z]{2}\s?[0-9a-zA-Z]{3}\s?[0-9]{3}\s?[0-9a-zA-Z]{3,4})\s",
        //@"([a-zA-Z]{2}\s?[0-9a-zA-Z]{3}\s?[0-9]{3}\s?[0-9a-zA-Z]{3,4})"
        //};

        //List<string> termExpressions = new List<string>()
        //{
        // @"(.+?)\s",
        // @"(.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s",
        // @"(.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?\s.+?)\s"
        // //@"(\d+.\d{3},\d{2})",
        // //@"(\d+,\d{2})",
        // //@"(\d+'\d{2})",
        // //@"(\d+\D\d{2})"
        //};

        /// <summary>
        /// Tries to find a regex expression to match the target value in an input text based on a text anchor and the type of the target value.
        /// </summary>
        /// <param name="inputText">The text against which the regex expression will be matched</param>
        /// <param name="targetValue">The value that the regex expression needs to find. If targetValue is empty, the expression will match the next occurence of the correct dataFieldType after the text anchor.</param>
        /// <param name="textAnchor">The text anchor associated to the regex expression</param>
        /// <param name="dataFieldType">Indicates the type of data that the regex expression shall match. Different types (e.g. dates and currencies) are matched with different regex expressions. Therefore it is important to specify the correct type.</param>
        /// <param name="returnFirstMatchOnly"></param>
        /// <param name="regexResult">The result containing the regex expression and matching value (if any)</param>
        /// <returns></returns>
        public bool TryFindRegexMatchExpress(string inputText, string textAnchor, string targetValue, DataFieldType dataFieldType, bool returnFirstMatchOnly, out RegexExpressionFinderResult regexResult)
        {
            regexResult = new RegexExpressionFinderResult();

            textAnchor  = textAnchor.Trim();
            targetValue = targetValue.Trim();


            switch (dataFieldType)
            {
            case DataFieldType.Text:
                regexResult = RegHeart(textAnchor, targetValue, new List <string>()
                {
                    @"(\w+)"
                }, new List <string>()
                {
                    @"\s+"
                }, inputText, returnFirstMatchOnly);
                break;

            case DataFieldType.Date:
                regexResult = RegHeart(textAnchor, targetValue, expressions.GeneralDateExpressions, expressions.SpecificDateExpressions, inputText, returnFirstMatchOnly);
                break;

            case DataFieldType.Currency:
                regexResult = RegHeart(textAnchor, targetValue, expressions.GeneralCurrencyExpressions, expressions.SpecificCurrencyExpressions, inputText, returnFirstMatchOnly);
                break;

            case DataFieldType.IBAN:
                regexResult = RegHeart(textAnchor, targetValue, expressions.GeneralIBANExpressions, expressions.SpecificIBANExpressions, inputText, returnFirstMatchOnly);
                break;

            case DataFieldType.AnchorLessIBAN:
                regexResult = RegHeart(textAnchor, targetValue, expressions.GeneralAnchorlessIBANExpressions, expressions.SpecificAnchorlessIBANExpressions, inputText, returnFirstMatchOnly);
                break;

            case DataFieldType.VatId:
                regexResult = RegHeart(textAnchor, targetValue, expressions.GeneralVatIdExpressions, expressions.SpecificVatIdExpressions, inputText, returnFirstMatchOnly);
                break;

            case DataFieldType.Term:
                regexResult = RegHeart(textAnchor, targetValue, expressions.GeneralTermExpressions, expressions.SpecificTermExpressions, inputText, returnFirstMatchOnly);
                break;

            default:
                break;
            }

            return(regexResult.Success);
        }
コード例 #17
0
 public DataFieldAttribute(string name, DataFieldType type = DataFieldType.Table)
 {
     Name = name;
     Type = type;
 }
コード例 #18
0
ファイル: DataField.cs プロジェクト: agimenezwally/Sharp.Xmpp
 /// <summary>
 /// Converts the specified value from the DataFieldType enumeration into
 /// its respective textual representation.
 /// </summary>
 /// <param name="type">The value to convert into a string.</param>
 /// <returns>A string representing the specified value.</returns>
 private string TypeToAttributeValue(DataFieldType type)
 {
     StringBuilder b = new StringBuilder();
     string s = type.ToString();
     for (int i = 0; i < s.Length; i++)
     {
         if (Char.IsUpper(s, i) && i > 0)
             b.Append('-');
         b.Append(Char.ToLower(s[i]));
     }
     return b.ToString();
 }
コード例 #19
0
ファイル: DataField.cs プロジェクト: agimenezwally/Sharp.Xmpp
 /// <summary>
 /// Sets the type of the data-field to the specified value.
 /// </summary>
 /// <param name="type">The value to set the type of the data-field to. Can be
 /// one of the values from the DataFieldType enumeration.</param>
 private void SetType(DataFieldType? type)
 {
     if (!type.HasValue)
         element.RemoveAttribute("type");
     else
     {
         string value = TypeToAttributeValue(type.Value);
         element.SetAttribute("type", value);
     }
 }
コード例 #20
0
ファイル: DataField.cs プロジェクト: agimenezwally/Sharp.Xmpp
 /// <summary>
 /// Asserts the data-field is of the specified type.
 /// </summary>
 /// <param name="expected">The type to assert.</param>
 /// <exception cref="ArgumentException">The data-field is not of the
 /// expected type.</exception>
 protected void AssertType(DataFieldType expected)
 {
     if (Type != expected)
     {
         throw new ArgumentException("The specified XML element is not a " +
             "data-field of type '" + expected.ToString() + "'.");
     }
 }
コード例 #21
0
ファイル: DataField.cs プロジェクト: agimenezwally/Sharp.Xmpp
 /// <summary>
 /// Initializes a new instance of the DataField class for use in a
 /// requesting dataform.
 /// </summary>
 /// <param name="type">The type of the field.</param>
 /// <param name="name">The name of the field.</param>
 /// <param name="required">Determines whether the field is required or
 /// optional.</param>
 /// <param name="label">A human-readable name for the field.</param>
 /// <param name="description">A natural-language description of the field,
 /// intended for presentation in a user-agent.</param>
 public DataField(DataFieldType type, string name = null, bool required = false,
     string label = null, string description = null)
 {
     element = Xml.Element("field");
     Type = type;
     Name = name;
     Required = required;
     Label = label;
     Description = description;
 }
コード例 #22
0
ファイル: DataField.cs プロジェクト: tuxevil/Nybble-old
 public DataField(DataFieldType type)
 {
     this.Type = type;
 }
コード例 #23
0
 private void FireRegexOrPositionHelper(Guid id, DataFieldType dataFieldType, DataFieldMode dataFieldMode)
 {
     RegexOrPositionHelper?.Invoke(id, dataFieldType, dataFieldMode);
 }
コード例 #24
0
ファイル: DataSheetInfo.cs プロジェクト: radtek/DotGameTool
        private bool ParseToField(WorkSheet wsheet)
        {
            int rowCount = wsheet.RowCount();
            int colCount = wsheet.ColumnCount();

            DataFieldType preFieldType = DataFieldType.None;

            for (int i = 1; i < colCount; i++)
            {
                string fName       = wsheet.GetValue(0, i);
                string fTypeStr    = wsheet.GetValue(1, i);
                string fExportStr  = wsheet.GetValue(2, i);
                string fDesc       = wsheet.GetValue(3, i);
                string fDefault    = wsheet.GetValue(4, i);
                string fValidation = wsheet.GetValue(5, i);
                string fValidValue = wsheet.GetValue(6, i);

                if (string.IsNullOrEmpty(fName))
                {
                    if (preFieldType == DataFieldType.Dic || preFieldType == DataFieldType.Array)
                    {
                        continue;
                    }
                    else
                    {
                        logMsg.Add(new ErrorLogData1(LogConst.E_DataField_Empty, "" + i));
                        continue;
                    }
                }

                DataFieldType fType = DataHelper.GetFieldType(fTypeStr);
                if (fType == DataFieldType.None)
                {
                    logMsg.Add(new ErrorLogData2(LogConst.E_DataField_TypeNone, "" + i, string.IsNullOrEmpty(fTypeStr) ? "" : fTypeStr));
                    continue;
                }
                DataFieldExport fExport = DataHelper.GetFieldExport(fExportStr);
                if (fExport == DataFieldExport.None)
                {
                    logMsg.Add(new ErrorLogData1(LogConst.E_DataField_ExportNone, "" + i));
                    continue;
                }

                DataFieldInfo fInfo = new DataFieldInfo
                {
                    columnIndex     = i,
                    name            = fName,
                    type            = fType,
                    export          = fExport,
                    desc            = fDesc,
                    validation      = DataHelper.GetFieldValidationType(fValidation),
                    validationValue = fValidValue,
                    defaultContent  = fDefault
                };

                if (fType == DataFieldType.Dic)
                {
                    DataHelper.GetFieldDicKeyInfo(fTypeStr, out fInfo.keyField, out fInfo.valueField);
                    if (fInfo.keyField == null || fInfo.valueField == null)
                    {
                        logMsg.Add(new ErrorLogData1(LogConst.E_DataField_DicType, "" + i));
                        continue;
                    }
                    if (fInfo.keyField.type == DataFieldType.Ref)
                    {
                        if (string.IsNullOrEmpty(fInfo.keyField.refName))
                        {
                            logMsg.Add(new ErrorLogData1(LogConst.E_DataField_DicKeyRef, "" + i));
                            continue;
                        }
                    }
                    if (fInfo.valueField.type == DataFieldType.Ref)
                    {
                        if (string.IsNullOrEmpty(fInfo.valueField.refName))
                        {
                            logMsg.Add(new ErrorLogData1(LogConst.E_DataField_DicValueRef, "" + i));
                            continue;
                        }
                    }
                }
                else if (fType == DataFieldType.Array)
                {
                    DataHelper.GetArrayFieldInfo(fTypeStr, out fInfo.valueField);
                    if (fInfo.valueField == null)
                    {
                        logMsg.Add(new ErrorLogData1(LogConst.E_DataField_ArrayType, "" + i));
                        continue;
                    }
                    else if (fInfo.valueField.type == DataFieldType.Ref)
                    {
                        if (string.IsNullOrEmpty(fInfo.valueField.refName))
                        {
                            logMsg.Add(new ErrorLogData1(LogConst.E_DataField_ArrayValueRef, "" + i));
                            continue;
                        }
                    }
                }
                else if (fType == DataFieldType.Ref)
                {
                    fInfo.refName = DataHelper.GetFieldRefName(fTypeStr);
                    if (string.IsNullOrEmpty(fInfo.refName))
                    {
                        logMsg.Add(new ErrorLogData1(LogConst.E_DataField_RefRef, "" + i));
                        continue;
                    }
                }
                else if (fType == DataFieldType.Res)
                {
                    fInfo.refName = DataHelper.GetFieldRefName(fTypeStr);
                    if (string.IsNullOrEmpty(fInfo.refName))
                    {
                        logMsg.Add(new ErrorLogData1(LogConst.E_DataField_ResType, "" + i));
                        continue;
                    }
                }
                preFieldType = fType;
                if (!AddField(fInfo))
                {
                    fields.Clear();
                    return(false);
                }
            }

            return(true);
        }
コード例 #25
0
 /// <summary>
 /// Tries to generate / find a regex expression. <seealso cref="RegexExpressionFinder.TryFindRegexMatchExpress(string, string, string, DataFieldType,bool, out RegexExpressionFinderResult)"/>
 /// </summary>
 /// <param name="inputText"></param>
 /// <param name="targetValue"></param>
 /// <param name="textAnchor"></param>
 /// <param name="dataFieldType"></param>
 /// <param name="returnFirstMatchOnly"></param>
 /// <param name="regexMatchExpression"></param>
 /// <returns></returns>
 public bool TryFindRegexMatchExpress(string inputText, string textAnchor, string targetValue, DataFieldType dataFieldType, bool returnFirstMatchOnly, out RegexExpressionFinderResult regexMatchExpression)
 {
     return(finder.TryFindRegexMatchExpress(inputText, textAnchor, targetValue, dataFieldType, false, out regexMatchExpression));
 }
コード例 #26
0
ファイル: DataTable.cs プロジェクト: zolegus/GraphEngine
        public DataCellUnion Convert(DataFieldType dataType)
        {
            DataCellUnion dataUnion = new DataCellUnion();

            switch (dataType)
            {
            case DataFieldType.Double:
                dataUnion.DoubleCells = new double[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.DoubleCells[i] = new double[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        double value = 0.0d;
                        if (!double.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.DoubleCells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to double values.", RecordCount * FieldCount);
                break;

            case DataFieldType.Float:
                dataUnion.FloatCells = new float[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.FloatCells[i] = new float[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        float value = 0.0f;
                        if (!float.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.FloatCells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to float values.", RecordCount * FieldCount);
                break;

            case DataFieldType.Byte:
                dataUnion.ByteCells = new byte[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.ByteCells[i] = new byte[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        byte value = 0;
                        if (!byte.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.ByteCells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to byte values.", RecordCount * FieldCount);
                break;

            case DataFieldType.SByte:
                dataUnion.SByteCells = new sbyte[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.SByteCells[i] = new sbyte[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        sbyte value = 0;
                        if (!sbyte.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.SByteCells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to signed byte values.", RecordCount * FieldCount);
                break;

            case DataFieldType.Int16:
                dataUnion.Int16Cells = new Int16[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.Int16Cells[i] = new Int16[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        Int16 value = 0;
                        if (!Int16.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.Int16Cells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to Int16 values.", RecordCount * FieldCount);
                break;

            case DataFieldType.UInt16:
                dataUnion.UInt16Cells = new UInt16[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.UInt16Cells[i] = new UInt16[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        UInt16 value = 0;
                        if (!UInt16.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.UInt16Cells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to UInt16 values.", RecordCount * FieldCount);
                break;

            case DataFieldType.Int32:
                dataUnion.Int32Cells = new Int32[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.Int32Cells[i] = new Int32[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        Int32 value = 0;
                        if (!Int32.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.Int32Cells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to Int32 values.", RecordCount * FieldCount);
                break;

            case DataFieldType.UInt32:
                dataUnion.UInt32Cells = new UInt32[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.UInt32Cells[i] = new UInt32[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        UInt32 value = 0;
                        if (!UInt32.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.UInt32Cells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to UInt32 values.", RecordCount * FieldCount);
                break;

            case DataFieldType.Int64:
                dataUnion.Int64Cells = new Int64[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.Int64Cells[i] = new Int64[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        Int64 value = 0;
                        if (!Int64.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.Int64Cells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to Int64 values.", RecordCount * FieldCount);
                break;

            case DataFieldType.UInt64:
                dataUnion.UInt64Cells = new UInt64[RecordCount][];
                for (int i = 0; i < RecordCount; i++)
                {
                    dataUnion.UInt64Cells[i] = new UInt64[FieldCount];
                    for (int j = 0; j < FieldCount; j++)
                    {
                        UInt64 value = 0;
                        if (!UInt64.TryParse(Cells[i][j], out value))
                        {
                            Console.Error.WriteLine("Warning: cannot parse data cell {0}({1}, {2}), set its value = 0.0", Cells[i][j], i, j);
                        }
                        dataUnion.UInt64Cells[i][j] = value;
                    }
                }
                Console.WriteLine("Convert the loaded {0} cells to UInt64 values.", RecordCount * FieldCount);
                break;

            default:
                dataUnion.StringCells = Cells;
                Console.WriteLine("Convert the loaded {0} cells to string values.", RecordCount * FieldCount);
                break;
            }
            return(dataUnion);
        }
コード例 #27
0
ファイル: DataForm.cs プロジェクト: REPLDigital/Sharp.Xmpp
        /// <summary>
        /// Add a typed value to this form
        /// </summary>
        /// <param name="name">The name of the value</param>
        /// <param name="type">The type of the value to add</param>
        /// <param name="value">The value to add</param>
        /// <returns>This data form</returns>
        public DataForm AddValue(string name, DataFieldType type, object value)
        {
            var valueNode = Xml.Element("value", xmlns);
            if (value != null)
            {
                valueNode.Text(value.ToString());
            }

            Element.Child(Xml.Element("field", xmlns).Attr("var", name).Attr("type", type.ToString()).Child(valueNode));

            return this;
        }
コード例 #28
0
 public DataFieldAttribute(DataFieldType op)
 {
     Type = op;
 }
コード例 #29
0
        public void Export(string name, string dirPath)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("require(\"GameDataBase\")");
            sb.AppendLine();
            sb.AppendFormat("{0} = {{}}\n", name);
            sb.AppendLine();
            sb.AppendFormat("{0}.textPath = \"{1}\"\n", name, textPath);
            sb.AppendFormat("{0}.stringPath = \"{1}\"\n", name, strPath);
            sb.AppendFormat("{0}.count = {1}\n", name, count);
            sb.AppendFormat("{0}.subformCount = {1}\n", name, subformCount);
            sb.AppendLine();
            sb.AppendFormat("{0}.subforms = {{\n", name);
            foreach (SubformDataOfSummary subform in subforms)
            {
                sb.Append(subform.ToString());
            }
            sb.AppendLine("}");

            sb.AppendLine();
            sb.AppendFormat("{0}.textFields = {{\n", name);
            foreach (string t in textFields)
            {
                sb.AppendFormat("    \"{0}\",\n", t);
            }
            sb.AppendLine("}");

            sb.AppendLine();
            sb.AppendFormat("{0}.strFields = {{\n", name);
            foreach (string t in strFields)
            {
                sb.AppendFormat("    \"{0}\",\n", t);
            }
            sb.AppendLine("}");

            sb.AppendLine();

            sb.AppendFormat("{0}.defaultValue = {{\n", name);
            foreach (KeyValuePair <DataFieldInfo, object> kvp in defaultDic)
            {
                DataFieldType dfType = kvp.Key.type;
                switch (dfType)
                {
                case DataFieldType.Dic:
                case DataFieldType.Array:
                    continue;

                case DataFieldType.Bool:
                case DataFieldType.Float:
                case DataFieldType.Int:
                case DataFieldType.Long:
                case DataFieldType.Double:
                case DataFieldType.Ref:
                    sb.AppendFormat("    {0} = {1},\n", kvp.Key.name, ((string)kvp.Value).ToLower());
                    break;

                case DataFieldType.String:
                case DataFieldType.Stringt:
                case DataFieldType.Res:
                    sb.AppendFormat("    {0}_index = {1},\n", kvp.Key.name, ((string)kvp.Value).ToLower());
                    break;
                }
            }
            sb.AppendLine("}");

            sb.AppendLine();
            sb.AppendFormat("{0}.__index = {0}\n", name);
            sb.AppendFormat("setmetatable({0},GameDataBase.SheetBase)\n", name);

            string fileContent = sb.ToString();

            File.WriteAllText(string.Format("{0}/{1}.lua", dirPath, name), fileContent);
        }