Beispiel #1
0
        private string BuildUpdateRequestJsonContent(G2RecordBase record)
        {
            var recordContent = JsonConvert.SerializeObject(record, Formatting.None, new JsonSerializerSettings() { DateTimeZoneHandling = DateTimeZoneHandling.Utc });

            var sb = new StringBuilder();

            sb.Append("{");
            sb.Append("\"add\":{");
            sb.Append("\"commitWithin\":10000,");
            sb.Append("\"overwrite\":true,");
            sb.Append("\"doc\":" + recordContent);
            sb.Append("},");
            sb.Append("\"commit\":{");
            sb.Append("\"expungeDeletes\":true,");
            sb.Append("\"waitSearcher\":false");
            sb.Append("}");
            sb.Append("}");

            return sb.ToString();
        }
Beispiel #2
0
        /// <summary>
        /// Updates the associated org units that are "Sites" with the index record
        /// </summary>
        /// <param name="context">the ObjectContext</param>
        /// <param name="entityTypeId">the Entity Type</param>
        /// <param name="entityId">the Id of the Entity</param>
        /// <param name="record">the SearchG2 index record to update</param>
        public void UpdateEntityLocationAssociations(ObjectContext context, LocationEntityTypes entityType, int entityId, G2RecordBase record)
        {
            var entityAssociation = context.CreateObjectSet<OrgUnitEntityAssociation>()
                .Where(o => o.OrgUnitEntityTypeId == (int)entityType)
                .Where(o => o.EntityId == entityId)
                .SingleOrDefault();

            if(entityAssociation != null)
            {
                foreach (var association in entityAssociation.DirectOrgUnits.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries))
                {
                    var orgUnitId = association.Replace("-", string.Empty);
                    record.DirectLocationIds.Add(orgUnitId);
                }

                foreach (var association in entityAssociation.DirectAndParentOrgUnits.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries))
                {
                    var orgUnitId = association.Replace("-", string.Empty);
                    record.DirectAndParentLocationIds.Add(orgUnitId);
                }
            }
        }
Beispiel #3
0
 public void SendUpdateRecordToSearchG2(G2RecordBase record)
 {
     var requestBody = BuildUpdateRequestJsonContent(record);
     SendWebRequest(requestBody);
 }