Esempio n. 1
0
            protected int ImportRow(string sline, EntityData entity, ref string hint, ref string Name)
            {
                int num = -1;

                hint = "";
                try
                {
                    int     index;
                    DataRow row;
                    string  fieldName;
                    string  val;
                    if (sline.Trim() == "")
                    {
                        hint = "行为空";
                        return(num);
                    }
                    string[] arr = ImportRule.SplitCsvLine(sline);
                    if (arr.Length < this.MinColCount)
                    {
                        hint = string.Format("列不足{0}个", this.MinColCount);
                        return(num);
                    }
                    int count = this.tbDefine.Rows.Count;
                    for (index = 0; index < count; index++)
                    {
                        row       = this.tbDefine.Rows[index];
                        fieldName = ConvertRule.ToString(row["FieldName"]);
                        string text2 = ConvertRule.ToString(row["FieldName"]);
                        bool   flag  = ConvertRule.ToBool(row["NotNull"]);
                        val = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if (flag && (val == ""))
                        {
                            hint = string.Format("{0}不能为空", text2);
                            return(num);
                        }
                        if (!this.CustomCheckValid(fieldName, val, text2, ref hint))
                        {
                            return(num);
                        }
                    }
                    if (!this.CustomCheckValid(arr, ref hint))
                    {
                        return(num);
                    }
                    if (this.ImportNewRow(arr) == null)
                    {
                        throw new Exception("未定义导入函数ImportNewRow");
                    }
                    for (index = 0; index < count; index++)
                    {
                        row       = this.tbDefine.Rows[index];
                        fieldName = row["FieldName"].ToString();
                        if (fieldName != "")
                        {
                            val = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                            this.GetImportFieldValue(fieldName, val);
                        }
                    }
                    num = 1;
                }
                catch (Exception exception)
                {
                    hint = "异常出错:" + exception.Message;
                }
                return(num);
            }