public void SaveTextProperty(int versionId, PropertyType propertyType, string value) { INodeWriter writer = this.CreateNodeWriter(); writer.SaveTextProperty(versionId, propertyType, true, value); writer.Close(); }
private static void SaveNodeProperties(NodeData nodeData, SavingAlgorithm savingAlgorithm, INodeWriter writer, bool isNewNode) { int versionId = nodeData.VersionId; foreach (var propertyType in nodeData.PropertyTypes) { var slotValue = nodeData.GetDynamicRawData(propertyType) ?? propertyType.DefaultValue; bool isModified = nodeData.IsModified(propertyType); if (!isModified && !isNewNode) { continue; } switch (propertyType.DataType) { case DataType.String: writer.SaveStringProperty(versionId, propertyType, (string)slotValue); break; case DataType.DateTime: writer.SaveDateTimeProperty(versionId, propertyType, (DateTime)slotValue); break; case DataType.Int: writer.SaveIntProperty(versionId, propertyType, (int)slotValue); break; case DataType.Currency: writer.SaveCurrencyProperty(versionId, propertyType, (decimal)slotValue); break; case DataType.Text: writer.SaveTextProperty(versionId, propertyType, true, (string)slotValue); //TODO: ?? isLoaded property handling BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeTextProperties, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); break; case DataType.Reference: var ids = (IEnumerable <int>)slotValue; if (!isNewNode || (ids != null && ids.Count() > 0)) { var ids1 = ids.Distinct().ToList(); if (ids1.Count != ids.Count()) { nodeData.SetDynamicRawData(propertyType, ids1); } writer.SaveReferenceProperty(versionId, propertyType, ids1); } BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeReferenceProperties, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); break; case DataType.Binary: var binValue = (BinaryDataValue)slotValue; if (binValue != null) { if (!binValue.IsEmpty) { var vId = nodeData.SharedData == null ? nodeData.VersionId : nodeData.SharedData.VersionId; if (binValue.Stream == null && binValue.Size != -1) { binValue.Stream = DataBackingStore.GetBinaryStream(vId, propertyType.Id); } } } if (binValue == null || binValue.IsEmpty) { writer.DeleteBinaryProperty(versionId, propertyType); } else if (binValue.Id == 0 || savingAlgorithm != SavingAlgorithm.UpdateSameVersion) { var id = writer.InsertBinaryProperty(versionId, propertyType.Id, binValue, isNewNode); binValue.Id = id; } else { writer.UpdateBinaryProperty(binValue.Id, binValue); } BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.SaveNodeBinaries, nodeData.SavingTimer.ElapsedTicks); nodeData.SavingTimer.Restart(); break; default: throw new NotSupportedException(propertyType.DataType.ToString()); } } }