Пример #1
0
        internal FieldChange getFieldChanged()
        {
            FieldChange fc = null;

            if (!this.current_value.Equals(this.old_value))
            {
                fc          = new FieldChange();
                fc.field    = this;
                fc.oldValue = this.old_value;
                fc.newValue = this.current_value;
            }
            return(fc);
        }
Пример #2
0
        internal void populateFields(Message message, bool dynamicFieldsOnly)
        {
            Log.LogMessage(LogLevels.BASIC, "Populate fields");

            CurrentToOldValues();

            int fieldCount = message.NumElements;

            Element e = message.AsElement;

            fieldChanges = new List <FieldChange>();

            for (int i = 0; i < fieldCount; i++)
            {
                Boolean load = true;

                Element f = e.GetElement(i);

                String fieldName = f.Name.ToString();
                // Workaround for schema field nameing
                if (fieldName.Equals("EMSX_ORD_REF_ID"))
                {
                    fieldName = "EMSX_ORDER_REF_ID";
                }

                if (dynamicFieldsOnly)
                {
                    SchemaFieldDefinition sfd = null;
                    if (owner is Order)
                    {
                        Order o = (Order)owner;
                        sfd = findSchemaFieldByName(fieldName, o.parent.emsxapi.orderFields);
                    }
                    else if (owner is Route)
                    {
                        Route r = (Route)owner;
                        sfd = findSchemaFieldByName(fieldName, r.parent.emsxapi.routeFields);
                    }
                    if (sfd != null && sfd.isStatic())
                    {
                        load = false;
                    }
                }

                if (load)
                {
                    Field fd = field(fieldName);

                    if (fd == null)
                    {
                        fd = new Field(this);
                    }

                    fd.setName(fieldName);
                    // set the CURRENT value NOT the new_value. new_value is only set by client side.
                    fd.setCurrentValue(f.GetValueAsString());

                    FieldChange fc = fd.getFieldChanged();
                    if (fc != null)
                    {
                        fieldChanges.Add(fc);
                    }
                }
            }
        }