// cloud only public AutomationConnection(Connection cloudConnection, ConnectionType cloudConnectionType) : base(cloudConnection.Name, null, cloudConnection.Properties.LastModifiedTime.LocalDateTime) { this.ConnectionType = cloudConnectionType.Name; JavaScriptSerializer jss = new JavaScriptSerializer(); this.ValueFields = new Dictionary<string, Object>(); foreach(KeyValuePair<string, string> field in cloudConnection.Properties.FieldDefinitionValues) { if(cloudConnectionType.Properties.FieldDefinitions[field.Key].Type.Equals(AutomationISE.Model.Constants.ConnectionTypeFieldType.String)) { this.ValueFields.Add(field.Key, field.Value); } else { try { var value = jss.DeserializeObject(field.Value.ToLower()); this.ValueFields.Add(field.Key, value); } catch { this.ValueFields.Add(field.Key, field.Value); } } } }
// cloud only public AutomationConnection(Connection cloudConnection) : base(cloudConnection.Name, null, cloudConnection.Properties.LastModifiedTime.LocalDateTime) { this.ValueFields = new Dictionary<string, Object>(); foreach (var key in cloudConnection.Properties.FieldDefinitionValues.Keys) { string jsonValue = "null"; cloudConnection.Properties.FieldDefinitionValues.TryGetValue(key, out jsonValue); JavaScriptSerializer jss = new JavaScriptSerializer(); var value = jss.DeserializeObject(jsonValue); this.ValueFields.Add(key, value); } }
// both cloud and local public AutomationConnection(ConnectionJson localJson, Connection cloudCredential) : base(localJson, cloudCredential.Properties.LastModifiedTime.LocalDateTime) { this.ValueFields = localJson.ValueFields; }