Ejemplo n.º 1
0
        public ShiftCheckRowValidator(WizardContext context)
        {
            //未指定 CheckField 時不進行驗證。
            _skip_validate = (context.ShiftCheckField == null);

            if (_skip_validate)
            {
                return;
            }

            _check_field = context.ShiftCheckField;

            List <string> requireFields = new List <string>();

            requireFields.AddRange(context.IdentifyField.Fields.ToInternalNames());
            requireFields.Add(context.ShiftCheckField.InternalName);

            XmlElement recordData = context.DataSource.GetShiftCheckList(requireFields.ToArray());

            List <ImportCondition> cond = new List <ImportCondition>();

            cond.Add(context.IdentifyField);

            _key_sets = new ConditionKeySetCollection(cond, recordData, "Record");
        }
Ejemplo n.º 2
0
 private void GenerateInsertXml(SheetRowSource sheetSource, XmlElement record)
 {
     foreach (string eachField in Context.SelectedFields)
     {
         ImportField field    = Context.SupportFields[eachField];
         XmlElement  xmlField = CreateChild(record, field.InternalName);
         xmlField.InnerText = sheetSource.GetFieldData(eachField);
     }
 }
Ejemplo n.º 3
0
        public static string GetImportField(RestCommand command, int importFieldID)
        {
            ImportField importField = ImportFields.GetImportField(command.LoginUser, importFieldID);

            if (importField.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(importField.GetXml("ImportField", true));
        }
Ejemplo n.º 4
0
        private bool UpdateCourseRequired()
        {
            foreach (string each in Context.SelectedFields)
            {
                ImportField field = Context.SupportFields[each];
                if (field.IsBasicField)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        private void GenerateUpdateXml(SheetRowSource sheetSource, XmlElement record)
        {
            foreach (string eachField in Context.SelectedFields)
            {
                ImportField field    = Context.SupportFields[eachField];
                XmlElement  xmlField = CreateChild(record, field.InternalName);
                xmlField.InnerText = sheetSource.GetFieldData(eachField);
            }

            XmlElement condition = CreateChild(record, "Condition");

            foreach (ImportField each in Context.IdentifyField.Fields)
            {
                XmlElement xmlField = CreateChild(condition, each.InternalName);
                xmlField.InnerText = sheetSource.GetFieldData(each.FieldName);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Instructs import command to check for duplicate contacts base on a given field
        /// </summary>
        /// <param name="field">The field according which the duplicate contact will be determined. For example ImportField.FullName</param>
        /// <returns></returns>
        public ImportFileCommand CheckingForDuplicate(ImportField field)
        {
            switch (field)
            {
            case ImportField.FullName:
            {
                checkForDuplicateFullName = true;
                break;
            }

            case ImportField.ContactEmail:
            {
                checkForDuplicateContactEmail = true;
                break;
            }

            case ImportField.OrganizationName:
            {
                checkForDuplicateOrganizationName = true;
                break;
            }

            case ImportField.OrganizationEmail:
            {
                checkForDuplicateCompanyEmail = true;
                break;
            }

            case ImportField.MainPhone:
            {
                checkForDuplicateMainPhone = true;
                break;
            }

            default:
            {
                break;
            }
            }
            return(this);
        }
Ejemplo n.º 7
0
        private void wpCollectKeyInfo_NextButtonClick(object sender, CancelEventArgs e)
        {
            e.Cancel = true;

            if (cboIdField.SelectedIndex == -1)
            {
                FISCA.Presentation.Controls.MsgBox.Show("您必須要選擇識別欄位。");
                return;
            }

            ImportCondition condition = cboIdField.SelectedItem as ImportCondition;

            if (condition != null)
            {
                Context.IdentifyField = condition;
            }

            ImportField field = cboValidateField.SelectedItem as ImportField;

            if (field == EmptyShiftField)
            {
                Context.ShiftCheckField = null;
            }
            else
            {
                Context.ShiftCheckField = field;
            }

            if (Context.ShiftCheckField != null)
            {
                if (Context.IdentifyField.ContainsAnyField(Context.ShiftCheckField.FieldName))
                {
                    FISCA.Presentation.Controls.MsgBox.Show("「識別欄」與「驗證欄」必須是不同的欄位。");
                    return;
                }
            }

            e.Cancel = false;
        }
Ejemplo n.º 8
0
 public SheetField(ImportField field)
 {
     _field = field;
     Text   = field.FieldName;
 }
        //-------------------------------------------------------------
        //
        //
        //-------------------------------------------------------------
        private void createImportFieldList(ImportFieldRow importRow)
        {
            ImportParams       importParams = (ImportParams)Session["importparams"];
            List <ImportField> fieldList    = importRow.ImportFieldsList;

            for (int j = 0; j < fieldList.Count; j++)
            {
                ImportField field = (ImportField)fieldList[j];
                string      value = "";
                field.FieldValue = field.FieldValue.Replace("'", "''");
                switch (field.FieldType.ToLower())
                {
                case "decimal":
                case "money":
                    value = field.FieldValue.Trim() == "" ? "null" : field.FieldValue;
                    Double dValue = 0;
                    if (value != null && value != "null")
                    {
                        try
                        {
                            //-------------------------------------
                            // We check to see if it is a proper
                            // value being passed, if not we reset it.
                            //-------------------------------------
                            dValue = Convert.ToDouble(value);
                        }
                        catch
                        {
                            field.FieldValue = "null";
                            value            = "null";
                        }
                    }
                    break;

                case "integer":
                    value = field.FieldValue.Trim() == "" ? "null" : field.FieldValue;
                    Int16 iValue = 0;
                    if (value != null && value != "null")
                    {
                        try
                        {
                            //-------------------------------------
                            // We check to see if it is a proper
                            // value being passed, if not we reset it.
                            //-------------------------------------
                            iValue = Convert.ToInt16(value);
                        }
                        catch
                        {
                            field.FieldValue = "null";
                            value            = "null";
                        }
                    }


                    break;

                case "date":
                    value = field.FieldValue.Trim() == "" ? "null" : "'" + field.FieldValue + "'";
                    break;

                case "boolean":
                    value = field.FieldValue.Trim() == "" ? "null" : field.FieldValue;
                    if (value != null && value != "null" &&
                        (value.ToUpper() == "TRUE" || value != "0"))
                    {
                        value = "1";
                    }
                    else
                    {
                        value = "0";
                    }

                    break;

                default:
                    value = field.FieldValue.Trim() == "" ? "null" : "'" + field.FieldValue + "'";
                    break;
                }


                if (field.FieldName != "NeverCallFlag" || importParams.exceptionType == 1)
                {
                    if (sqlCols == string.Empty)
                    {
                        sqlCols   = field.FieldName;
                        sqlValues = value;
                        strUpdate = String.Format("{0}={1}", field.FieldName, value);
                    }
                    else
                    {
                        sqlCols   += "," + field.FieldName;
                        sqlValues += "," + value;
                        strUpdate += ", " + String.Format("{0}={1}", field.FieldName, value);
                    }
                }
                if (field.FieldName == "PhoneNum")
                {
                    strPhoneNumber = field.FieldValue;
                }
            }// end for loop
            forceNeverCallFlag();
        }
        //-----------------------------------------------------------------
        //
        //
        //-----------------------------------------------------------------
        private void SetFieldValue(ImportFieldRow row, string field, string value, string datatype)
        {
            List <ImportField> list = row.ImportFieldsList;

            switch (datatype.ToLower())
            {
            case "integer":
                if (value.Trim() != "" && (!IsInt(value)))
                {
                    value = value.Trim().ToLower();
                    if (value == "true" || value == "yes")
                    {
                        value = "1";
                    }
                    else if (value == "false" || value == "no")
                    {
                        value = "0";
                    }
                    else
                    {
                        throw new Exception("BadInputData");
                    }
                }
                break;

            case "boolean":
                if (value.Trim() != "")
                {
                    value = value.Trim().ToLower();
                    if (value == "true" || value == "yes")
                    {
                        value = "1";
                    }
                    else if (value == "false" || value == "no")
                    {
                        value = "0";
                    }
                    else if (IsBool(value))
                    {
                        value = Convert.ToBoolean(value) ? "1" : "0";
                    }
                    else if (IsInt(value))
                    {
                        value = Convert.ToBoolean(Convert.ToInt32(value)) ? "1" : "0";
                    }
                    else
                    {
                        throw new Exception("BadInputData");
                    }
                }
                break;

            case "date":
                if (value.Trim() != "" && (!IsDateTime(value)))
                {
                    throw new Exception("BadInputData");
                }
                break;

            case "decimal":
            case "money":
                if (value.Trim() != "" && (!IsDouble(value)))
                {
                    throw new Exception("BadInputData");
                }
                break;
            }
            ImportField impField = new ImportField();

            impField.FieldName  = field;
            impField.FieldValue = value; //Server.UrlEncode(value);
            impField.FieldType  = datatype;
            list.Add(impField);
        }