public static string Serialize(IdentityConfig config) { var ser = new XmlSerializer(typeof(IdentityConfig)); using (var textWriter = new StringWriter()) { ser.Serialize(textWriter, config); return(textWriter.ToString()); } }
/// <summary> /// Identity stage II: update EdgeObject DB (staging) with edge object from Delivery DB /// using LOCK on EdgeObject table: /// * sync last changes according transform timestamp /// * update modified EdgeObjects --> IdentityStatus = Modified /// * insert new EdgeObjects --> IdentityStatus = New /// </summary> public void UpdateEdgeObjects() { _config = String.IsNullOrEmpty(ConfigXml) ? new IdentityConfig() : IdentityConfig.Deserialize(ConfigXml); // load object dependencies Dependencies = EdgeObjectConfigLoader.GetEdgeObjectDependencies(AccountId, _objectsSqlConnection).Values.ToList(); Log("UpdateEdgeObjects:: EdgeObjects dependencies loaded"); int maxDependecyDepth = Dependencies.Max(x => x.Depth); for (int i = 0; i <= maxDependecyDepth; i++) { var currentDepth = i; Log(String.Format("UpdateEdgeObjects:: dependency depth={0}", currentDepth)); foreach (var field in Dependencies.Where(x => x.Depth == currentDepth)) { Log(String.Format("UpdateEdgeObjects:: starting update field '{0}' of type '{1}'", field.Field.Name, field.Field.FieldEdgeType.Name)); UpdateObjectDependencies(field.Field.FieldEdgeType); if (_config.UpdateExistingObjects && DeliveryContainsChanges(field.Field.FieldEdgeType, IdentityStatus.Unchanged, true)) { Log(String.Format("UpdateEdgeObjects:: delivery contains changes of {0}, starting sync", field.Field.Name)); SyncLastChangesWithLock(field.Field.FieldEdgeType); if (DeliveryContainsChanges(field.Field.FieldEdgeType, IdentityStatus.Modified)) { UpdateExistingEdgeObjectsByDelivery(field.Field.FieldEdgeType); Log(String.Format("UpdateEdgeObjects:: update modified object of type '{0}'", field.Field.FieldEdgeType)); } if (_config.CreateNewObjects && DeliveryContainsChanges(field.Field.FieldEdgeType, IdentityStatus.New)) { InsertNewEdgeObjects(field.Field.FieldEdgeType); Log(String.Format("UpdateEdgeObjects:: insert new objects of type '{0}'", field.Field.FieldEdgeType)); } } else { Log(String.Format("UpdateEdgeObjects:: delivery doen't contain changes of {0}, nothing to sync", field.Field.Name)); } CreateTempDeliveryGkTkTable(field.Field.FieldEdgeType); } } }