public dtoCallSubmissionFile(RequestedFile requestedFile, Boolean allowRemove, Boolean allowUpload)
 {
     Id           = requestedFile.Id;
     FileToSubmit = new dtoCallRequestedFile(requestedFile);
     AllowRemove  = allowRemove;
     AllowUpload  = allowUpload;
     FieldError   = Domain.FieldError.None;
 }
 private void Address1_Validated(object sender, EventArgs e)
 {
     if (!Validator.ValidateTextField(Address1.Text))
     {
         FieldError.SetError(Address1, "Required Field");
     }
     else
     {
         FieldError.SetError(Address1, "");
     }
 }
 private void City_Validated(object sender, EventArgs e)
 {
     if (!Validator.ValidateTextField(City.Text))
     {
         FieldError.SetError(City, "Required Field");
     }
     else
     {
         FieldError.SetError(City, "");
     }
 }
 private void Proof_Validated(object sender, EventArgs e)
 {
     if (!Validator.ValidateComboBox(Proof.SelectedItem))
     {
         FieldError.SetError(Proof, "Required Field");
     }
     else
     {
         FieldError.SetError(Proof, "");
     }
 }
 private void Date_Validated(object sender, EventArgs e)
 {
     if (!Validator.ValidateDate(Date.Value))
     {
         FieldError.SetError(Date, "Cannot Select Future Date");
     }
     else
     {
         FieldError.SetError(Date, "");
     }
 }
 private void lastName_validate(object sender, EventArgs e)
 {
     if (!Validator.ValidateTextField(lastName.Text))
     {
         FieldError.SetError(lastName, "Required Field");
     }
     else
     {
         FieldError.SetError(lastName, "");
     }
 }
 private void middleInitial_validated(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Minitial.Text) && !Validator.ValidateInitial(Minitial.Text))
     {
         Minitial.ForeColor = Color.Red;
         FieldError.SetError(Minitial, "Invalid Character");
     }
     else
     {
         Minitial.ForeColor = Color.Black;
         FieldError.SetError(Minitial, "");
     }
 }
 public void SetError(Dictionary <long, FieldError> errors)
 {
     if (errors == null)
     {
         FieldError = Domain.FieldError.None;
     }
     else if (errors.ContainsKey(Id))
     {
         FieldError = errors[Id];
     }
     else
     {
         FieldError = Domain.FieldError.None;
     }
 }
 public async Task Invoke(HttpContext context)
 {
     try {
         await _next(context);
     }
     catch (ValidationException e) {
         await Write(context, null, e.Errors);
     }
     catch (ValidationFieldException e) {
         await Write(context, null, FieldError.Of(e.Field, e.Error));
     }
     catch (NotAllowedException e) {
         await Write(context, e.Message);
     }
 }
        public static void AddFieldError(this InterchangeErrors errors, string segmentName, int errorCode, string errorDescription, int positionInSegment, string fieldValue)
        {
            int    positionInField = -1;
            int    repetitionCount = 0;
            string refDesignator   = "";

            if (errors == null)
            {
                throw new ArgumentNullException("errors");
            }

            FieldError fieldError = new FieldError(positionInSegment, positionInField, repetitionCount, errorCode, errorDescription, fieldValue, refDesignator);

            EdiSectionErrors ediSectionErrors = GetEdiSectionErrors(errors, segmentName);

            ediSectionErrors.FieldErrorList.Add(fieldError);
        }
Exemple #11
0
        public ActionResult AjaxSubmit(string data)
        {
            List <FileViewModel> uploadedFiles = new List <FileViewModel>();

            if (Request.Files.Count > 0)
            {
                uploadedFiles = Request.Files.AllKeys.Select(x => new FileViewModel {
                    file = Request.Files[x], name = x
                }).Where(x => x.file.ContentLength > 0).ToList();
            }

            Result           result = new Result();
            List <FieldData> fields = null;

            try
            {
                fields = JsonConvert.DeserializeObject <List <FieldData> >(data);
            }
            catch (Exception ex)
            {
                FieldError fieldError = new FieldError {
                    FieldName = "global", ErrorType = "JSON form parse error"
                };
                result.Errors.Add(fieldError);
                result.Status  = "fail";
                result.Message = ex.Message;
            }

            if (result.Status != "fail")
            {
                FormCollection formCollection = new FormCollection();
                foreach (var field in fields)
                {
                    formCollection.Add(field.Name, field.Value);
                }

                result         = formService.Submit(formCollection, uploadedFiles);
                result.Message = !string.IsNullOrEmpty(result.Message) ? result.Message : result.Status;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #12
0
 private void Email_Validated(object sender, EventArgs e)
 {
     if (!Validator.ValidateEmailAddress(Email.Text))
     {
         if (string.IsNullOrWhiteSpace(Email.Text))
         {
             FieldError.SetError(Email, "Required Field");
         }
         else
         {
             Email.ForeColor = Color.Red;
             FieldError.SetError(Email, "Invalid Email Address");
         }
     }
     else
     {
         Email.ForeColor = Color.Black;
         FieldError.SetError(Email, "");
     }
 }
Exemple #13
0
 private void Zip_Validated(object sender, EventArgs e)
 {
     if (!Validator.ValidateZipCode(Zip.Text))
     {
         if (string.IsNullOrWhiteSpace(Zip.Text.Remove(5, 1).Trim()))
         {
             FieldError.SetError(Zip, "Required Field");
         }
         else
         {
             Zip.ForeColor = Color.Red;
             FieldError.SetError(Zip, "Invalid Zip Code");
         }
     }
     else
     {
         Zip.ForeColor = Color.Black;
         FieldError.SetError(Zip, "");
     }
 }
Exemple #14
0
 private void Phone_Validated(object sender, EventArgs e)
 {
     if (!Validator.ValidatePhoneNumber(Phone.Text))
     {
         if (string.IsNullOrWhiteSpace(Phone.Text.Replace("(", "")
                                       .Replace(")", "").Replace("-", "").Trim()))
         {
             FieldError.SetError(Phone, "Required Field");
         }
         else
         {
             Phone.ForeColor = Color.Red;
             FieldError.SetError(Phone, "Invalid Phone Number");
         }
     }
     else
     {
         Email.ForeColor = Color.Black;
         FieldError.SetError(Email, "");
     }
 }
Exemple #15
0
        private void ClearForm()
        {
            // clear all fields
            firstName.Clear();
            Minitial.Clear();
            lastName.Clear();
            Address1.Clear();
            Address2.Clear();
            City.Clear();
            State.SelectedItem = null;
            Zip.Clear();
            Gender.SelectedItem = null;;
            Phone.Clear();
            Email.Clear();
            Proof.SelectedItem = null;
            Date.Value         = DateTime.Today;

            // clear errors
            FieldError.SetError(firstName, "");
            FieldError.SetError(Minitial, "");
            FieldError.SetError(lastName, "");
            FieldError.SetError(Address1, "");
            FieldError.SetError(Address2, "");
            FieldError.SetError(City, "");
            FieldError.SetError(State, "");
            FieldError.SetError(Zip, "");
            FieldError.SetError(Gender, "");
            FieldError.SetError(Phone, "");
            FieldError.SetError(Email, "");
            FieldError.SetError(Proof, "");
            FieldError.SetError(Date, "");


            firstName.Select();
            SetAddMode();
        }
Exemple #16
0
        public override bool Check(ref List <Error> checkResult)
        {
            IFeatureWorkspace ipFtWS = (IFeatureWorkspace)m_BaseWorkspace;

            try
            {
                List <Error>  pResult   = new List <Error>();
                string        strAlias  = m_pFieldPara.strAlias;
                List <string> listLayer = m_pFieldPara.m_LyrFldMap;
                System.Collections.Hashtable hashtable = new System.Collections.Hashtable();

                for (int i = 0; i < listLayer.Count; i++)
                {
                    string strTemp = listLayer[i];
                    int    nIndex  = strTemp.IndexOf('&');
                    if (nIndex < 0)
                    {
                        continue;
                    }
                    string str = strTemp.Substring(0, nIndex);
                    if (!hashtable.Contains(str))
                    {
                        hashtable.Add(str, "");
                    }
                }

                DataTable dtLayer = new DataTable();
                string    strSQL  = "select AttrTableName,LayerName,LayerID from LR_DicLayer";

                dtLayer = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(SysDbHelper.GetSysDbConnection(), strSQL);
                if (dtLayer == null)
                {
                    return(false);
                }

                foreach (DataRow drLayer in dtLayer.Rows)
                {
                    if (drLayer != null)
                    {
                        string strLayerCode = drLayer["AttrTableName"].ToString();
                        string strLayerName = drLayer["LayerName"].ToString();
                        int    nLayerID     = Convert.ToInt32(drLayer["LayerID"]);

                        if (!hashtable.Contains(strLayerName))
                        {
                            continue;
                        }

                        IFeatureClass pFtCls = null;
                        try
                        {
                            pFtCls = ipFtWS.OpenFeatureClass(strLayerCode);
                        }
                        catch
                        {
                            continue;
                        }
                        IFields pFields = pFtCls.Fields;

                        if (pFields == null)
                        {
                            continue;
                        }
                        int    lFieldCount = pFields.FieldCount;
                        IField pField;

                        DataTable dtFields     = new DataTable();
                        string    strSQLFields = "select * from LR_DicField where LayerID = " + nLayerID + "";
                        dtFields = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(SysDbHelper.GetSysDbConnection(), strSQLFields);
                        if (dtFields == null)
                        {
                            FieldError LRFieldErrorInfo = new FieldError();
                            LRFieldErrorInfo.DefectLevel     = this.DefectLevel;
                            LRFieldErrorInfo.strAttrTabName  = strLayerName;
                            LRFieldErrorInfo.strFieldName    = null;
                            LRFieldErrorInfo.m_strRuleInstID = this.m_InstanceID;
                            LRFieldErrorInfo.strErrorMsg     = string.Format("{0}层对应的属性字段,在《土地利用现状数据库标准》中不存在", strLayerName);

                            pResult.Add(LRFieldErrorInfo);

                            continue;
                        }

                        ///检查图层中是否存在多余字段
                        for (int i = 0; i < lFieldCount; i++)
                        {
                            if (strLayerName == "注记")
                            {
                                break;
                            }
                            pField = pFields.get_Field(i);
                            if (pField.Name.ToUpper().Contains("OBJECTID") ||
                                pField.Name.ToLower().Contains("shape"))
                            {
                                continue;
                            }

                            int k           = 0;
                            int nFieldCount = dtFields.Rows.Count;
                            for (k = 0; k < nFieldCount; k++)
                            {
                                DataRow drField    = dtFields.Rows[k];
                                string  strStdName = drField["FieldName"].ToString();
                                string  strStdCode = drField["FieldCode"].ToString();
                                if (strStdCode.Trim().Equals("objectid", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("object id", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("shape", StringComparison.OrdinalIgnoreCase))
                                {
                                    continue;
                                }
                                if (pField.Name.Trim().Equals(strStdCode.Trim(), StringComparison.OrdinalIgnoreCase))
                                {
                                    break;
                                }
                            }
                            if (k == nFieldCount)
                            {
                                if (!pField.AliasName.Contains("本软件"))
                                {
                                    FieldError LRFieldErrorInfo2 = new FieldError();
                                    LRFieldErrorInfo2.DefectLevel     = this.DefectLevel;
                                    LRFieldErrorInfo2.strAttrTabName  = strLayerName;
                                    LRFieldErrorInfo2.strFieldName    = pField.Name;
                                    LRFieldErrorInfo2.m_strRuleInstID = this.m_InstanceID;
                                    LRFieldErrorInfo2.strErrorMsg     = string.Format(Helper.ErrMsgFormat.ERR_410100001_1, strLayerName, pField.Name);

                                    pResult.Add(LRFieldErrorInfo2);
                                }
                            }
                        }

                        ///检查标准中的字段在图层中是否存在,已经图层的字段是否和标准相符合
                        //二次for循环迭代控制器,add by wangxiang 20111201
                        int flag = 0;
                        foreach (DataRow drField in dtFields.Rows)
                        {
                            if (drField != null)
                            {
                                string strStdName = drField["FieldName"].ToString();
                                string strStdCode = drField["FieldCode"].ToString();

                                if (strStdCode.Trim().Equals("objectid", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("object id", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("shape", StringComparison.OrdinalIgnoreCase))
                                {
                                    continue;
                                }

                                int nStdType = Convert.ToInt32(drField["FieldType"]);


                                string strStdFldType = Hy.Common.Utility.Data.AdoDbHelper.GetFieldTypeName(nStdType);

                                FieldError FieldErrInfo1 = new FieldError();
                                FieldErrInfo1.DefectLevel     = this.DefectLevel;
                                FieldErrInfo1.strAttrTabName  = strLayerName;
                                FieldErrInfo1.strFieldName    = "" + strStdCode + "(" + strStdName + ")";
                                FieldErrInfo1.strStdFieldType = strStdFldType;
                                FieldErrInfo1.m_strRuleInstID = this.m_InstanceID;

                                int i = 0;
                                for (i = 0; i < lFieldCount && flag < lFieldCount; i++)
                                {
                                    pField = pFields.get_Field(i);


                                    if (pField.Name.Trim() == strStdCode.Trim())
                                    {
                                        flag++;
                                        esriFieldType pType = pField.Type;

                                        if (nStdType == 3)
                                        {
                                            nStdType = 4;
                                        }
                                        esriFieldType pDTType = TopoHelper.en_GetEsriFieldByEnum(nStdType);
                                        if (pType == pDTType)
                                        {
                                            if (pType != esriFieldType.esriFieldTypeString)
                                            {
                                                break;
                                            }

                                            if (pField.Length != Convert.ToInt32(drField["Length"])) //字段长度不正确
                                            {
                                                if (strLayerCode.Equals("JBNTBHTB", StringComparison.OrdinalIgnoreCase) && pField.Name.Trim().Equals("jbnttbbh", StringComparison.OrdinalIgnoreCase))
                                                {
                                                    FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_4, strLayerName, pField.Name, pField.Length, Convert.ToInt32(drField["Length"]));
                                                }
                                                else
                                                {
                                                    FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_4, strLayerName, pField.Name, pField.Length, Convert.ToInt32(drField["Length"]));
                                                }
                                                pResult.Add(FieldErrInfo1);
                                                break;
                                            }


                                            break;
                                        }
                                        else
                                        {
                                            if (pDTType != esriFieldType.esriFieldTypeBlob)
                                            {
                                                FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_3, strLayerName, pField.Name, TopoHelper.en_GetFieldTypebyEsriField(pType), TopoHelper.en_GetFieldTypebyEsriField(pDTType));
                                                pResult.Add(FieldErrInfo1);
                                            }

                                            break;
                                        }
                                    }
                                }

                                if (i == lFieldCount)
                                {
                                    if (drField["FieldOption"].ToString().Trim() != "fz")
                                    {
                                        FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_2, strLayerName, drField["FieldName"].ToString());
                                        pResult.Add(FieldErrInfo1);
                                    }
                                }
                            }
                        }
                        if (pFtCls != null)
                        {
                            Marshal.ReleaseComObject(pFtCls);
                            pFtCls = null;
                        }
                    }
                }

                checkResult = pResult;
            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, ex.ToString());
                return(false);
            }

            return(true);
        }
Exemple #17
0
        // Enables save function if all fields are valid and required fields have been entered and no duplicates.

        private void CanSave()
        {
            // check if all required fields have been filled
            bool valid_Entry = Validator.ValidateTextField(firstName.Text) &&
                               Validator.ValidateInitial(Minitial.Text) &&
                               Validator.ValidateTextField(lastName.Text) &&
                               Validator.ValidateTextField(Address1.Text) &&
                               Validator.ValidateTextField(City.Text) &&
                               Validator.ValidateComboBox(State.SelectedItem) &&
                               Validator.ValidateZipCode(Zip.Text) &&
                               Validator.ValidateComboBox(Gender.SelectedItem) &&
                               Validator.ValidatePhoneNumber(Phone.Text) &&
                               Validator.ValidateEmailAddress(Email.Text) &&
                               Validator.ValidateComboBox(Proof.SelectedItem) &&
                               Validator.ValidateDate(Date.Value);
            RebateRecord entered_Record = new RebateRecord();

            if (curr_Mode == MODIFY && RebateList.SelectedItems.Count != 0)
            {
                entered_Record = new RebateRecord((RebateRecord)RebateList.SelectedItems[0].Tag);
            }
            entered_Record.firstName     = firstName.Text;
            entered_Record.middleInitial = Minitial.Text;
            entered_Record.lastName      = lastName.Text;
            entered_Record.Address1      = Address1.Text;
            entered_Record.Address2      = Address2.Text;
            entered_Record.City          = City.Text;
            entered_Record.State         = State.Text;
            entered_Record.Zip           = new string(Zip.Text.Where(char.IsDigit).ToArray());   //zipcode should only be numbers
            entered_Record.Gender        = Gender.Text;
            entered_Record.Phone         = new string(Phone.Text.Where(char.IsDigit).ToArray()); // phone number should only have numbers
            entered_Record.Email         = Email.Text;
            entered_Record.Proof         = Proof.Text;
            entered_Record.Date          = Date.Value;
            switch (curr_Mode)
            {
            case ADD:
                if (start_time.CompareTo(DateTime.MinValue) == 0)
                {
                    start_time = DateTime.Now;
                }

                if (valid_Entry && !SearchListViewItem(RebateList, entered_Record))     //Duplicate records checked
                {
                    Save.Enabled = true;
                    FieldError.SetError(firstName, "");
                    FieldError.SetError(lastName, "");
                    FieldError.SetError(Phone, "");
                }
                else
                {
                    Save.Enabled = false;
                    if (SearchListViewItem(RebateList, entered_Record))
                    {
                        FieldError.SetError(firstName, "Found existing rebate with same name and phone number!");
                        FieldError.SetError(lastName, "Found existing rebate with same name and phone number!");
                        FieldError.SetError(Phone, "Found existing rebate with same name and phone number!");
                    }
                }
                break;

            case MODIFY:
                if (valid_Entry && !SearchListViewItem(RebateList, entered_Record))
                {
                    Save.Enabled = true;
                    FieldError.SetError(firstName, "");
                    FieldError.SetError(lastName, "");
                    FieldError.SetError(Phone, "");
                }
                else
                {
                    Save.Enabled = false;
                    if (SearchListViewItem(RebateList, entered_Record))
                    {
                        FieldError.SetError(firstName, "Found existing rebate with same name and phone number!");
                        FieldError.SetError(lastName, "Found existing rebate with same name and phone number!");
                        FieldError.SetError(Phone, "Found existing rebate with same name and phone number!");
                    }
                }
                break;
            }
        }
        public Result Validate(Form formModel, List <FileViewModel> uploadedFiles)
        {
            Result result = new Result
            {
                Status = "success",
                Errors = new List <FieldError>()
            };
            bool          isValid       = true;
            ActionMessage actionMessage = new ActionMessage();

            actionMessage.Message   = new Message();
            actionMessage.IsSuccess = isValid;
            foreach (Field field in formModel.Fields)
            {
                field.IsRequiredValid = true;
                field.IsFormatValid   = true;
                field.IsContainHTML   = false;

                if (field.Mandatory)
                {
                    if (field.FieldType.Type.Equals(PropertyAlias.DragDropUpload) ||
                        field.FieldType.Type.Equals(PropertyAlias.Upload))
                    {
                        foreach (var uploadFile in uploadedFiles)
                        {
                            if (field.Id != uploadFile.name.Split('[', ']')[1])
                            {
                                field.IsRequiredValid = false;
                                isValid = false;
                            }
                            else
                            {
                                field.IsRequiredValid = true;
                                isValid = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(field.Value))
                        {
                            field.IsRequiredValid = false;
                            isValid = false;
                        }
                    }
                }

                /***************************** Refactor ***********************/
                // use else if

                if (field.FieldType.Type.Equals(PropertyAlias.Email))
                {
                    if (!string.IsNullOrEmpty(field.Value))
                    {
                        try
                        {
                            MailAddress address = new MailAddress(field.Value);
                        }
                        catch (FormatException)
                        {
                            field.IsFormatValid = false;
                            isValid             = false;
                        }
                    }
                }

                if (field.FieldType.Type.Equals(PropertyAlias.Phone))
                {
                    if (!string.IsNullOrEmpty(field.Value))
                    {
                        Regex pPattrn = new Regex("[0-9]+");
                        if (!pPattrn.IsMatch(field.Value))
                        {
                            field.IsFormatValid = false;
                            isValid             = false;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(field.Value))
                {
                    if (field.Value.Contains(">") || field.Value.Contains("<"))
                    {
                        field.IsContainHTML = true;
                        isValid             = false;
                    }
                }
                if (field.FieldType.Type.Equals(PropertyAlias.HoneyPot))
                {
                    if (!string.IsNullOrEmpty(field.Value))
                    {
                        field.IsFormatValid = false;
                        isValid             = false;
                    }
                }
            }
            if (!isValid)
            {
                result.Status = "fail";

                // Why loop again

                foreach (Field field in formModel.Fields)
                {
                    if (!(field.IsRequiredValid && field.IsFormatValid))
                    {
                        string errorType              = !field.IsRequiredValid ? "require" : "format";
                        string errorMessageMandatory  = string.Empty;
                        string errorMessageValidation = string.Empty;

                        errorMessageMandatory  = !string.IsNullOrEmpty(field.MessageMandatory) ? field.MessageMandatory : string.Empty;
                        errorMessageValidation = !string.IsNullOrEmpty(field.MessageInvalidFormat) ? field.MessageInvalidFormat : string.Empty;

                        FieldError fieldError = new FieldError
                        {
                            ErrorType              = errorType,
                            FieldName              = field.Name.ToString(),
                            FieldId                = field.Id.ToString(),
                            ErrorMessageMandatory  = errorMessageMandatory,
                            ErrorMessageValidation = errorMessageValidation
                        };
                        result.Errors.Add(fieldError);
                    }
                }
                result.Message = "fail";
            }
            else
            {
                actionMessage.IsSuccess = true;
                result.Message          = "success";
            }
            return(result);
        }
 public dtoCallSubmissionFile()
 {
     FieldError = Domain.FieldError.None;
 }
Exemple #20
0
        public override bool Check(ref List<Error> checkResult)
        {
            IFeatureWorkspace ipFtWS = (IFeatureWorkspace)m_BaseWorkspace;

            try
            {
                List<Error> pResult = new List<Error>();
                string strAlias = m_pFieldPara.strAlias;
                List<string> listLayer = m_pFieldPara.m_LyrFldMap;
                System.Collections.Hashtable hashtable = new System.Collections.Hashtable();

                for (int i = 0; i < listLayer.Count; i++)
                {
                    string strTemp = listLayer[i];
                    int nIndex = strTemp.IndexOf('&');
                    if (nIndex < 0)
                    {
                        continue;
                    }
                    string str = strTemp.Substring(0, nIndex);
                    if (!hashtable.Contains(str))
                    {
                        hashtable.Add(str, "");
                    }
                }

                DataTable dtLayer = new DataTable();
                string strSQL = "select AttrTableName,LayerName,LayerID from LR_DicLayer";

                dtLayer = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(SysDbHelper.GetSysDbConnection(), strSQL);
                if (dtLayer==null)
                {
                    return false;
                }

                foreach (DataRow drLayer in dtLayer.Rows)
                {
                    if (drLayer != null)
                    {
                        string strLayerCode = drLayer["AttrTableName"].ToString();
                        string strLayerName = drLayer["LayerName"].ToString();
                        int nLayerID = Convert.ToInt32(drLayer["LayerID"]);

                        if (!hashtable.Contains(strLayerName))
                        {
                            continue;
                        }

                        IFeatureClass pFtCls = null;
                        try
                        {
                            pFtCls = ipFtWS.OpenFeatureClass(strLayerCode);
                        }
                        catch
                        {
                            continue;
                        }
                        IFields pFields = pFtCls.Fields;

                        if (pFields == null)
                        {
                            continue;
                        }
                        int lFieldCount = pFields.FieldCount;
                        IField pField;

                        DataTable dtFields = new DataTable();
                        string strSQLFields = "select * from LR_DicField where LayerID = " + nLayerID + "";
                        dtFields = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(SysDbHelper.GetSysDbConnection(), strSQLFields);
                        if (dtFields==null)
                        {
                            FieldError LRFieldErrorInfo = new FieldError();
                            LRFieldErrorInfo.DefectLevel = this.DefectLevel;
                            LRFieldErrorInfo.strAttrTabName = strLayerName;
                            LRFieldErrorInfo.strFieldName = null;
                            LRFieldErrorInfo.m_strRuleInstID = this.m_InstanceID;
                            LRFieldErrorInfo.strErrorMsg = string.Format("{0}���Ӧ�������ֶΣ��ڡ�����������״���ݿ��׼���в�����", strLayerName);

                            pResult.Add(LRFieldErrorInfo);

                            continue;
                        }

                        ///���ͼ�����Ƿ���ڶ����ֶ�
                        for (int i = 0; i < lFieldCount; i++)
                        {
                            if (strLayerName == "ע��")
                            {
                                break;
                            }
                            pField = pFields.get_Field(i);
                            if (pField.Name.ToUpper().Contains("OBJECTID") ||
                                pField.Name.ToLower().Contains("shape"))
                            {
                                continue;
                            }

                            int k = 0;
                            int nFieldCount = dtFields.Rows.Count;
                            for (k = 0; k < nFieldCount; k++)
                            {
                                DataRow drField = dtFields.Rows[k];
                                string strStdName = drField["FieldName"].ToString();
                                string strStdCode = drField["FieldCode"].ToString();
                                if (strStdCode.Trim().Equals("objectid", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("object id", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("shape", StringComparison.OrdinalIgnoreCase))
                                {
                                    continue;
                                }
                                if (pField.Name.Trim().Equals(strStdCode.Trim(), StringComparison.OrdinalIgnoreCase))
                                {
                                    break;
                                }
                            }
                            if (k == nFieldCount)
                            {
                                if (!pField.AliasName.Contains("�����"))
                                {

                                    FieldError LRFieldErrorInfo2 = new FieldError();
                                    LRFieldErrorInfo2.DefectLevel = this.DefectLevel;
                                    LRFieldErrorInfo2.strAttrTabName = strLayerName;
                                    LRFieldErrorInfo2.strFieldName = pField.Name;
                                    LRFieldErrorInfo2.m_strRuleInstID = this.m_InstanceID;
                                    LRFieldErrorInfo2.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_1, strLayerName, pField.Name);

                                    pResult.Add(LRFieldErrorInfo2);
                                }

                            }
                        }

                        ///����׼�е��ֶ���ͼ�����Ƿ���ڣ��Ѿ�ͼ����ֶ��Ƿ�ͱ�׼�����
                        //����forѭ��������������add by wangxiang 20111201
                        int flag = 0;
                        foreach (DataRow drField in dtFields.Rows)
                        {
                            if (drField != null)
                            {
                                string strStdName = drField["FieldName"].ToString();
                                string strStdCode = drField["FieldCode"].ToString();

                                if (strStdCode.Trim().Equals("objectid", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("object id", StringComparison.OrdinalIgnoreCase) ||
                                    strStdCode.Trim().Equals("shape", StringComparison.OrdinalIgnoreCase))
                                {
                                    continue;
                                }

                                int nStdType = Convert.ToInt32(drField["FieldType"]);

                                string strStdFldType = Hy.Common.Utility.Data.AdoDbHelper.GetFieldTypeName(nStdType);

                                FieldError FieldErrInfo1  = new FieldError();
                                FieldErrInfo1.DefectLevel = this.DefectLevel;
                                FieldErrInfo1.strAttrTabName = strLayerName;
                                FieldErrInfo1.strFieldName = "" + strStdCode + "(" + strStdName + ")";
                                FieldErrInfo1.strStdFieldType = strStdFldType;
                                FieldErrInfo1.m_strRuleInstID = this.m_InstanceID;

                                int i = 0;
                                for (i = 0; i < lFieldCount && flag < lFieldCount; i++)
                                {
                                    pField = pFields.get_Field(i);

                                    if (pField.Name.Trim() == strStdCode.Trim())
                                    {
                                        flag++;
                                        esriFieldType pType = pField.Type;

                                        if (nStdType == 3)
                                        {
                                            nStdType = 4;
                                        }
                                        esriFieldType pDTType = TopoHelper.en_GetEsriFieldByEnum(nStdType);
                                        if (pType == pDTType)
                                        {
                                            if (pType != esriFieldType.esriFieldTypeString)
                                            {
                                                break;
                                            }

                                            if (pField.Length != Convert.ToInt32(drField["Length"])) //�ֶγ��Ȳ���ȷ
                                            {
                                                if (strLayerCode.Equals("JBNTBHTB", StringComparison.OrdinalIgnoreCase) && pField.Name.Trim().Equals("jbnttbbh", StringComparison.OrdinalIgnoreCase))
                                                {
                                                    FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_4, strLayerName, pField.Name, pField.Length, Convert.ToInt32(drField["Length"]));
                                                }
                                                else
                                                {
                                                    FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_4, strLayerName, pField.Name, pField.Length, Convert.ToInt32(drField["Length"]));
                                                }
                                                pResult.Add(FieldErrInfo1);
                                                break;
                                            }

                                            break;
                                        }
                                        else
                                        {
                                            if (pDTType != esriFieldType.esriFieldTypeBlob)
                                            {
                                                FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_3, strLayerName, pField.Name, TopoHelper.en_GetFieldTypebyEsriField(pType), TopoHelper.en_GetFieldTypebyEsriField(pDTType));
                                                pResult.Add(FieldErrInfo1);
                                            }

                                            break;
                                        }
                                    }
                                }

                                if (i == lFieldCount)
                                {
                                    if (drField["FieldOption"].ToString().Trim() != "fz")
                                    {
                                        FieldErrInfo1.strErrorMsg = string.Format(Helper.ErrMsgFormat.ERR_410100001_2, strLayerName, drField["FieldName"].ToString());
                                        pResult.Add(FieldErrInfo1);
                                    }

                                 }
                            }
                        }
                        if (pFtCls != null)
                        {
                            Marshal.ReleaseComObject(pFtCls);
                            pFtCls = null;
                        }
                    }
                }

            checkResult = pResult;
            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, ex.ToString());
                return false;
            }

            return true;
        }
Exemple #21
0
        // Return value indicate if ST segment is valid or not
        private bool ProcessSTSegment()
        {
            string location = "EDIReader.ProcessSTSegment";
            string errors   = string.Empty;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            LastState = EDIState.ST;
            int currentTransactionSetType;

            if (CurrentSegmentDetails == null || CurrentSegmentDetails.Length < 2 ||
                int.TryParse(CurrentSegmentDetails[1], out currentTransactionSetType) == false)
            {
                InvalidTransactionSetCount++;

                //TODO: Add error
                Logger.Error(location, EventId.EDIReaderInvalidSegment, "{0} - Invalid segment - {1}", GetCurrentPosContext(), CurrentSegment);
                Errors.AddSegmentError(CurrentSegment, X12ErrorCode.UnexpectedSegmentCode
                                       , X12ErrorCode.GetStandardSegmentErrorDescription(X12ErrorCode.UnexpectedSegmentCode), SegmentNumber
                                       , this.CurrentSegmentStartPos, this.CurrentSegmentEndPos - 1, EdiErrorType.Error);
            }
            else
            {
                ValidTransactionSetCount++;
                // TODO: Optimization - Load DocumentPlug, reconstruct ISA and GA segment if transaction set type changed
                //if (PrevTransactionSetType != currentTransactionSetType)
                {
                    // Make sure that ISA and GA fields are already present
                    if (ISARecordFields == null || GSRecordFields == null)
                    {
                        throw new EDIReaderException(
                                  string.Format("ISA and GA segments should be present before ST segment. {0}", GetCurrentPosContext()));
                    }

                    if (ISARecordFields.Length != MaxISAFieldRecordCount || GSRecordFields.Length == 0)
                    {
                        throw new EDIReaderException(
                                  string.Format("ISA and GA segments length ({0}, {1}) does not match expected length ({2}, non-zero). {3}",
                                                ISARecordFields.Length, GSRecordFields.Length, MaxISAFieldRecordCount, GetCurrentPosContext()));
                    }

                    //TODO: For testing invoking DocumentPlugFactory.CreateEDIDocumentPlug
                    if (DocumentPlug == null)
                    {
                        if (FPManager == null)
                        {
                            DocumentPlug = DocumentPlugFactory.CreateEDIDocumentPlug(currentTransactionSetType);
                        }
                        else
                        {
                            DocumentPlug = CreateEDIDocumentPlug(currentTransactionSetType, ISARecordFields);
                        }
                    }
                    else // Make sure that DocumentPlug and ST document type match
                    {
                        // DocumentPlug.DocumentType = 0 indicates that there was problem retrieving DocumentType
                        // while constructing DocumentPlug
                        if (DocumentPlug.DocumentType != 0 && DocumentPlug.DocumentType != currentTransactionSetType)
                        {
                            string errorDescription = "Spec Cert relates to document {0}, however ST01 value is {1}.; test File is rejected";
                            errorDescription = string.Format(errorDescription, DocumentPlug.DocumentType, currentTransactionSetType);

                            FieldError fieldError = DataTypeHelper.GenerateFieldError(X12ErrorCode.DeInvalidCodeValueCode, errorDescription, CurrentSegmentDetails[0]);

                            long currentSegmentFieldStartIndex = this.CurrentSegmentStartPos + 3; // length of "ST<delimiter>"
                            long currentSegmentFieldEndIndex   = currentSegmentFieldStartIndex + CurrentSegmentDetails[1].Length - 1;

                            Logger.Error(location, EventId.EDIReaderInvalidTransactionSetType, errorDescription);
                            Errors.AddFieldError(CurrentSegmentDetails[0], "ST01", fieldError.ErrorCode, fieldError.Description, SegmentNumber, 1,
                                                 CurrentSegmentDetails[1], currentSegmentFieldStartIndex,
                                                 currentSegmentFieldEndIndex, EdiErrorType.Error);

                            return(false);
                        }
                    }

                    CurrentPluglet = DocumentPlug.RootPluglet;

                    CurrentPluglet.ResetCurrentOccurances();

                    // Construct start segment list
                    CurrentPluglet.InitializeStartSegmentList();

                    FatpipeDocumentInst.TransactionSetType = currentTransactionSetType;
                    if (CurrentSegmentDetails.Length > 2)
                    {
                        FatpipeDocumentInst.TransactionNumber = CurrentSegmentDetails[2];
                    }
                    FatpipeDocumentInst.DocumentPlug = DocumentPlug;
                    FatpipeDocumentInst.RootFragment = CurrentPluglet.ConstructDocumentFragment(null, null);

                    // Construct ISA node
                    //CreateAndAddNewSegment(EDIState.ISA.ToString(), ISARecordFields);

                    // Construct GS node
                    //CreateAndAddNewSegment(EDIState.GS.ToString(), GSRecordFields);
                    //GSSegmentProcessed = true;
                    //GSPluglet = CurrentPluglet;

                    PrevTransactionSetType = currentTransactionSetType;
                }
                //else
                //{
                //    // Move to GS node to start new segment
                //    CurrentPluglet = GSPluglet;

                //    // Remove previous TransactionSet
                //    if (FatpipeDocumentInst.RootFragment.Children != null)
                //    {
                //        IDocumentFragment transactionSetChild = FatpipeDocumentInst.RootFragment.Children.Any( c => c.Pluglet.Tag == "TransactionSet");
                //        FatpipeDocumentInst.RootFragment.Children.Remove(transactionSetChild);
                //    }

                //    // Set errors to null
                //    FatpipeDocumentInst.Errors = null;
                //}

                // Construct ST node
                CreateAndAddNewSegment(EDIState.ST.ToString(), CurrentSegmentDetails);
            }

            sw.Stop();
            Logger.Debug(location, "Stop - {0}. Elapsed time {1} ms", GetCurrentPosContext(), sw.ElapsedMilliseconds);

            return(true);
        }