Exemple #1
0
        public DbRequest MakeDbRequest(string input, bool shouldShowAll)
        {
            input = input.TrimEnd('?');
            // input comes in as "מתי עומר נולד"
            // Now input is "עומר נולד"
            input = input.Replace(key1Lookup, "");
            // queryParts is ["עומר" ,"נולד" ]
            string[] queryParts = input.Split(' ');

            // try to find a relevant lookup field based on the last query parts
            List <string> fields     = null;
            int           fieldIndex = queryParts.Length - 1;

            for (int i = queryParts.Length - 1; i > 0; i--)
            {
                fields = FieldsAliases.getJsonFields(queryParts[i]);

                if (fields != null && fields.Count > 0)
                {
                    // the recieved field is relevant for this template
                    if (fields[0] == FieldsAliases.BIRTHDAY ||
                        fields[0] == FieldsAliases.END_OF_SERVICE)
                    {
                        lookupField = queryParts[i];
                        fieldIndex  = i;
                    }
                }
            }

            // if a field has been found, set the db request
            if (lookupField != null)
            {
                string value = "";
                // build the lookup value from all query parts except of the last one
                for (int i = 0; i < fieldIndex; i++)
                {
                    value += " " + queryParts[i];
                }

                lookupValue = value;

                var dbRequest = new DbRequest(lookupValue, shouldShowAll);
                return(dbRequest.IsValid ? dbRequest : null);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        private IEnumerable <object> createTopRowJson(string lookupField)
        {
            var objects = new List <object>();

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

            // always add display name
            objects.maybeAddDisplayFieldObject(FieldsAliases.DISPLAY_NAME, this.getDisplayName());

            if (lookupField != null && lookupField != "")
            {
                fields = FieldsAliases.getJsonFields(lookupField);

                foreach (string field in fields)
                {
                    switch (field)
                    {
                    case FieldsAliases.BIRTHDAY:
                    {
                        objects.maybeAddDisplayFieldObject(field, this.getBirthdayDisplayString());
                        break;
                    };

                    case FieldsAliases.MISPAR_ISHI:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.MisparIshi);
                        break;
                    }

                    case FieldsAliases.FIRST_NAME:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.GivenName);
                        break;
                    };

                    case FieldsAliases.LAST_NAME:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.Surname);
                        break;
                    };

                    case FieldsAliases.JOB:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.LongWorkTitle);
                        break;
                    };

                    case FieldsAliases.MOBILE_PHONE:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.Mobile);
                        break;
                    };

                    case FieldsAliases.WORK_PHONE:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.WorkPhone);
                        break;
                    };

                    case FieldsAliases.RANK:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.Darga);
                        break;
                    };

                    case FieldsAliases.END_OF_SERVICE:
                    {
                        var endOfServiceDisplayString = "";
                        if (person.EndOfService.HasValue)
                        {
                            var endOfService = person.EndOfService.Value;
                            endOfServiceDisplayString = endOfService.ToString("dd/MM/yyyy");
                        }
                        objects.maybeAddDisplayFieldObject(FieldsAliases.END_OF_SERVICE, endOfServiceDisplayString);
                        break;
                    };

                    case FieldsAliases.SEX:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.Sex);
                        break;
                    };

                    case FieldsAliases.MAIL:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.Mail);
                        break;
                    };

                    case FieldsAliases.FAX:
                    {
                        objects.maybeAddDisplayFieldObject(field, person.Fax);
                        break;
                    };
                    }
                }
            }

            // if only defaults, set this records
            if (objects.Count <= 1)
            {
                objects.maybeAddDisplayFieldObject(FieldsAliases.MOBILE_PHONE, person.Mobile);
            }

            // always add job unless already added
            if (!fields.Contains(FieldsAliases.JOB))
            {
                objects.maybeAddDisplayFieldObject(FieldsAliases.JOB, person.LongWorkTitle);
            }

            return(objects);
        }
Exemple #3
0
        private IEnumerable <object> createBottomRowJson(string lookupField)
        {
            var objects = new List <object>();

            if (lookupField != null && lookupField != "")
            {
                List <string> fields = FieldsAliases.getJsonFields(lookupField);

                if (!fields.Contains(FieldsAliases.MISPAR_ISHI))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.MISPAR_ISHI, person.MisparIshi);
                }

                if (!fields.Contains(FieldsAliases.FIRST_NAME))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.FIRST_NAME, person.GivenName);
                }

                if (!fields.Contains(FieldsAliases.LAST_NAME))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.LAST_NAME, person.Surname);
                }

                if (!fields.Contains(FieldsAliases.MOBILE_PHONE))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.MOBILE_PHONE, person.Mobile);
                }

                if (!fields.Contains(FieldsAliases.WORK_PHONE))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.WORK_PHONE, person.WorkPhone);
                }

                if (!fields.Contains(FieldsAliases.BIRTHDAY))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.BIRTHDAY, this.getBirthdayDisplayString());
                }

                if (!fields.Contains(FieldsAliases.RANK))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.RANK, person.Darga);
                }

                if (!fields.Contains(FieldsAliases.END_OF_SERVICE))
                {
                    var endOfServiceDisplayString = "";
                    if (person.EndOfService.HasValue)
                    {
                        var endOfService = person.EndOfService.Value;
                        endOfServiceDisplayString = endOfService.ToString("dd/MM/yyyy");
                    }
                    objects.maybeAddDisplayFieldObject(FieldsAliases.END_OF_SERVICE, endOfServiceDisplayString);
                }

                if (!fields.Contains(FieldsAliases.SEX))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.SEX, person.Sex);
                }

                if (!fields.Contains(FieldsAliases.MAIL))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.MAIL, person.Mail);
                }

                if (!fields.Contains(FieldsAliases.FAX))
                {
                    objects.maybeAddDisplayFieldObject(FieldsAliases.FAX, person.Fax);
                }
            }
            else
            {
                objects.maybeAddDisplayFieldObject(FieldsAliases.BIRTHDAY, this.getBirthdayDisplayString());
                objects.maybeAddDisplayFieldObject(FieldsAliases.WORK_PHONE, person.WorkPhone);
                objects.maybeAddDisplayFieldObject(FieldsAliases.RANK, person.Darga);
                objects.maybeAddDisplayFieldObject(FieldsAliases.SEX, person.Sex);
                objects.maybeAddDisplayFieldObject(FieldsAliases.MAIL, person.Mail);
                objects.maybeAddDisplayFieldObject(FieldsAliases.FAX, person.Fax);
                objects.maybeAddDisplayFieldObject(FieldsAliases.MISPAR_ISHI, person.MisparIshi);
            }

            return(objects);
        }