public ItemUri([NotNull] DatabaseUri databaseUri, [NotNull] ItemId itemId) { Assert.ArgumentNotNull(databaseUri, nameof(databaseUri)); Assert.ArgumentNotNull(itemId, nameof(itemId)); DatabaseUri = databaseUri; ItemId = itemId; }
public FieldUri Clone() { var databaseUri = new DatabaseUri(ItemVersionUri.Site, ItemVersionUri.DatabaseName); var itemUri = new ItemUri(databaseUri, ItemVersionUri.ItemId); var itemVersionUri = new ItemVersionUri(itemUri, ItemVersionUri.Language, ItemVersionUri.Version); return(new FieldUri(itemVersionUri, FieldId)); }
public bool Equals([CanBeNull] DatabaseUri other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.DatabaseName, DatabaseName) && Equals(other.Site, Site)); }
internal static void Edit([NotNull] DatabaseUri databaseUri, [NotNull] List <Field> fields, bool modifiedOnly, [NotNull] ExecuteCompleted callback) { Debug.ArgumentNotNull(databaseUri, nameof(databaseUri)); Debug.ArgumentNotNull(fields, nameof(fields)); Debug.ArgumentNotNull(callback, nameof(callback)); if ((databaseUri.Site.DataService.FeatureCapabilities & DataServiceFeatureCapabilities.Execute) == DataServiceFeatureCapabilities.Execute) { var xml = GetXml(fields, modifiedOnly); databaseUri.Site.DataService.ExecuteAsync("Items.Save", callback, xml, databaseUri.DatabaseName.Name); } else { databaseUri.Site.DataService.Save(databaseUri.DatabaseName, fields); callback(string.Empty, new ExecuteResult(databaseUri.Site.DataService, null, false)); } }
public static void Edit([NotNull] DatabaseUri databaseUri, [NotNull] List <Tuple <FieldUri, string> > fieldValues) { Assert.ArgumentNotNull(databaseUri, nameof(databaseUri)); Assert.ArgumentNotNull(fieldValues, nameof(fieldValues)); var fields = new List <Field>(); foreach (var fieldValue in fieldValues) { var field = new Field { Value = fieldValue.Item2, HasValue = true }; field.FieldUris.Add(fieldValue.Item1); fields.Add(field); } Edit(databaseUri, fields, false); }
public static void Edit([NotNull] DatabaseUri databaseUri, [NotNull] List <Field> fields, bool modifiedOnly) { Assert.ArgumentNotNull(databaseUri, nameof(databaseUri)); Assert.ArgumentNotNull(fields, nameof(fields)); ExecuteCompleted callback = delegate(string response, ExecuteResult executeResult) { if (!DataService.HandleExecute(response, executeResult)) { AppHost.MessageBox("Failed to save changes.\n\n" + response, "Information", MessageBoxButton.OK, MessageBoxImage.Information); return; } foreach (var field in fields) { foreach (var fieldUri in field.FieldUris) { Notifications.RaiseFieldChanged(fieldUri, fieldUri, field.Value); } } }; Edit(databaseUri, fields, modifiedOnly, callback); }
public abstract void GetTemplatesAsync([NotNull] DatabaseUri databaseUri, [NotNull] GetItemsCompleted <TemplateHeader> getTemplatesCallback);
public abstract IEnumerable <ItemHeader> GetRootItems([NotNull] DatabaseUri databaseUri);
public abstract IEnumerable <ItemPath> GetItemPath([NotNull] DatabaseUri databaseUri, [NotNull] string itemPath);
public static ItemHeader Parse([NotNull] DatabaseUri databaseUri, [NotNull] XElement element) { Assert.ArgumentNotNull(element, nameof(element)); Assert.ArgumentNotNull(databaseUri, nameof(databaseUri)); var templateId = ItemId.Empty; var standardValuesField = ItemId.Empty; var standardValuesId = ItemId.Empty; var sortorder = 0; var name = element.Value; var path = element.GetAttributeValue("path"); var templateName = element.GetAttributeValue("templatename"); var category = element.GetAttributeValue("category"); var updatedBy = element.GetAttributeValue("updatedby"); var updated = DateTimeExtensions.FromIso(element.GetAttributeValue("updated")); var locked = element.GetAttributeValue("locked"); var ownership = element.GetAttributeValue("owner"); var parentName = element.GetAttributeValue("parentname"); var isClone = element.GetAttributeValue("clone") == "1"; var source = element.GetAttributeValue("source"); var serializationStatus = SerializationStatus.NotSerialized; var value = element.GetAttributeValue("templateid"); if (!string.IsNullOrEmpty(value)) { templateId = new ItemId(new Guid(value)); } value = element.GetAttributeValue("standardvaluesid"); if (!string.IsNullOrEmpty(value)) { Guid guid; standardValuesId = Guid.TryParse(value, out guid) ? new ItemId(guid) : ItemId.Empty; } value = element.GetAttributeValue("standardvaluesfield"); if (!string.IsNullOrEmpty(value)) { Guid guid; standardValuesField = Guid.TryParse(value, out guid) ? new ItemId(guid) : ItemId.Empty; } value = element.GetAttributeValue("sortorder"); if (!string.IsNullOrEmpty(value)) { int.TryParse(value, out sortorder); } value = element.GetAttributeValue("serializationstatus"); if (!string.IsNullOrEmpty(value)) { switch (value) { case "0": serializationStatus = SerializationStatus.NotSerialized; break; case "1": serializationStatus = SerializationStatus.Serialized; break; case "2": serializationStatus = SerializationStatus.Modified; break; case "3": serializationStatus = SerializationStatus.Error; break; } } var itemDatabaseUri = databaseUri; var databaseName = element.GetAttributeValue("database"); if (!string.IsNullOrEmpty(databaseName) && databaseName != databaseUri.DatabaseName.Name) { itemDatabaseUri = new DatabaseUri(databaseUri.Site, new DatabaseName(databaseName)); } var result = new ItemHeader { HasChildren = element.GetAttributeValue("haschildren") == @"1", Name = name, TemplateId = templateId, StandardValuesId = standardValuesId, StandardValuesField = standardValuesField, Icon = new Icon(itemDatabaseUri.Site, element.GetAttributeValue("icon")), ItemUri = new ItemUri(itemDatabaseUri, new ItemId(new Guid(element.GetAttributeValue("id")))), TemplateName = templateName, Path = path, Category = category, SortOrder = sortorder, UpdatedBy = updatedBy, Updated = updated, Locked = locked, Ownership = ownership, ParentName = parentName, /* IsClone = isClone, */ Source = source, SerializationStatus = serializationStatus }; foreach (var attribute in element.Attributes()) { if (attribute.Name.ToString().StartsWith(@"ex.")) { result.SetData(attribute.Name.ToString(), attribute.Value); } } return(result); }