/// <summary> /// Создание нового версионного слоя. Возвращает главный объект слоя (например, для контракта объект из /// слоя типа crmComplexContractVersion) /// </summary> /// <param name="sourceObj"></param> /// <returns></returns> public virtual IVersionSupport CreateNewVersion(IVersionSupport sourceObj, VersionHelper vHelper) { source = sourceObj as IXPSimpleObject; if (source == null) { return(null); } // Алгоритм. // 1. Вычисляется версионный слой sourceVersionStrate // 2. Создаётся массив пар зависмых объектов и их клонов - dict // 3. Все вхождения подобъектов в исходный версионный слой, говоря приблизительно, заменяются на их клоны согласно dict // 4. У нового версионного слоя у всех входящих в него версионных объектов проставляется статус VERSION_PROJECT // Версионный слой от sourceObj - это версионный слой, из которого будет делаться новый версионный слой // Замечание. Свм объект по построению входит в свой версионный слой. List <IVersionSupport> sourceVersionStrate = GetVersionedStrate(sourceObj, vHelper); // Создаём словарь с копиями объектов из newVersionStrate Dictionary <IVersionSupport, IVersionSupport> dict = GenerateCopyOfObjects(sourceVersionStrate, source.Session, sourceObj); // Проставляем статус и некоторые другие свойства SetVersionState(dict, VersionStates.VERSION_PROJECT); // Меняем свойства на версионные ResetVersionProperty(vHelper.sourceSession, ignoredProperties, dict); // На выходе - копия основного объекта новой версии return(dict[sourceObj]); }
/// <summary> /// Добавление объекта в список /// </summary> /// <param name="obj"></param> /// <param name="dependentObjectList"></param> public static void AddObjectToList(IVersionSupport obj, List <IVersionSupport> dependentObjectList) { if (dependentObjectList.Contains((IVersionSupport)obj)) { return; } dependentObjectList.Add((IVersionSupport)obj); }
public void SetVersionStateExt(IVersionSupport obj, VersionStates vs) { List <IVersionSupport> sourceVersionStrate = GetVersionedStrate(obj, this); foreach (IVersionSupport elem in sourceVersionStrate) { elem.VersionState = vs; } }
/// <summary> /// Initializes a new instance of the Connection class. /// </summary> /// <param name="socket">The kafka socket initialized to the kafka server.</param> /// <param name="configuration">The configuration, including connection and request timeouts.</param> /// <param name="log">Logging interface used to record any log messages created by the connection.</param> public Connection(ITcpSocket socket, IConnectionConfiguration configuration = null, ILog log = null) { _socket = socket; _log = log ?? TraceLog.Log; _configuration = configuration ?? new ConnectionConfiguration(); _versionSupport = _configuration.VersionSupport.IsDynamic ? null : _configuration.VersionSupport; // This thread will poll the receive stream for data, parse a message out // and trigger an event with the message payload _receiveTask = Task.Factory.StartNew(DedicatedReceiveTask, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
public void Approve(IVersionSupport obj) { crmDealLongServiceVersion approvingObj = obj as crmDealLongServiceVersion; if (approvingObj == null) { DevExpress.XtraEditors.XtraMessageBox.Show("Документ не может быть утверждён"); return; } ApproveVersion(approvingObj); }
private async Task <short> GetVersionAsync(ApiKey apiKey, CancellationToken cancellationToken) { var configuredSupport = _configuration.VersionSupport as DynamicVersionSupport; if (configuredSupport == null) { return(_configuration.VersionSupport.GetVersion(apiKey).GetValueOrDefault()); } var versionSupport = _versionSupport; if (versionSupport != null) { return(versionSupport.GetVersion(apiKey).GetValueOrDefault()); } return(await _versionSupportSemaphore.LockAsync( async() => { try { return await _configuration.ConnectionRetry.TryAsync( async(retryAttempt, elapsed) => { var response = await SendAsync(new ApiVersionsRequest(), cancellationToken, new RequestContext(version: 0)).ConfigureAwait(false); if (response.error_code.IsRetryable()) { return RetryAttempt <short> .Retry; } if (!response.error_code.IsSuccess()) { return RetryAttempt <short> .Abort; } var supportedVersions = response.api_versions.ToImmutableDictionary( _ => _.api_key, _ => configuredSupport.UseMaxSupported ? _.max_version : _.min_version); _versionSupport = new VersionSupport(supportedVersions); return new RetryAttempt <short>(_versionSupport.GetVersion(apiKey).GetValueOrDefault()); }, (exception, retryAttempt, retryDelay) => { _log.Debug(() => LogEvent.Create(exception, $"Failed getting version info on retry {retryAttempt}: Will retry in {retryDelay}")); exception.PrepareForRethrow(); }, () => _versionSupport = _configuration.VersionSupport, // fall back to default support in this case cancellationToken); } catch (Exception ex) { _log.Error(LogEvent.Create(ex)); _versionSupport = _configuration.VersionSupport; // fall back to default support in this case return (short)0; } }, cancellationToken ).ConfigureAwait(false)); }
/// <summary> /// Метод генерирует копии (не клоны!) объектов, заданных в коллекции. /// </summary> /// <returns></returns> public virtual Dictionary <IVersionSupport, IVersionSupport> GenerateCopyOfObjects(List <IVersionSupport> list, Session ssn, IVersionSupport sourceObj) { // Составляем пары из объектов и их копий Dictionary <IVersionSupport, IVersionSupport> dict = new Dictionary <IVersionSupport, IVersionSupport>(); foreach (IVersionSupport vr in list) { IVersionSupport vrClone = (IVersionSupport)CopyForVersion(vr as IXPSimpleObject); dict.Add(vr, vrClone); } return(dict); }
private void CreateNewVersionAction_Execute(object sender, SimpleActionExecuteEventArgs e) { View view = View; Frame frame = Frame; object currentObj = View.CurrentObject; IVersionBusinessLogicSupport currentVersObj = View.CurrentObject as IVersionBusinessLogicSupport; if (currentVersObj == null) { DevExpress.XtraEditors.XtraMessageBox.Show("Документ не поддерживает создание версий", "Система версионирования документов"); return; } this.ObjectSpace.CommitChanges(); IObjectSpace objectSpace = Application.CreateObjectSpace(); IVersionBusinessLogicSupport passedCurrentObj = objectSpace.GetObject(currentObj) as IVersionBusinessLogicSupport; // Новая версия: IVersionSupport newVers = passedCurrentObj.CreateNewVersion(); //IVersionSupport newVers = ((IVersionBusinessLogicSupport)currentObj).CreateNewVersion(); //objectSpace.CommitChanges(); // Показ новой версии // Определяем DetailView string DetailViewId = frame.Application.FindDetailViewId(newVers.GetType()); // Показываем: TargetWindow openMode = TargetWindow.Current; //CommonMethods.ShowConcreteDetailViewInWindow(frame, objectSpace, DetailViewId, newVers, openMode); DetailView dv = frame.Application.CreateDetailView(objectSpace, DetailViewId, true, newVers); //DetailView dv = frame.Application.CreateDetailView(objectSpace, DetailViewId, true, passedCurrentObj); //DetailView dv = frame.Application.CreateDetailView(objectSpace, newVers, true); //DetailView dv = frame.Application.CreateDetailView(objectSpace, newVers, true); ShowViewParameters svp = new ShowViewParameters() { CreatedView = dv, TargetWindow = openMode, Context = TemplateContext.View, CreateAllControllers = true }; e.ShowViewParameters.Assign(svp); ////object passedNewObj = this.ObjectSpace.GetObject(newVers); //DetailView dv = frame.Application.CreateDetailView(this.ObjectSpace, DetailViewId, true, newVers); //e.ShowViewParameters.CreatedView = dv; ////e.ShowViewParameters.CreatedView.CurrentObject = newVers; // passedNewObj; }
public static IConnectionConfiguration CopyWith( this IConnectionConfiguration configuration, IRetry connectionRetry = null, IVersionSupport versionSupport = null, TimeSpan?requestTimeout = null, int?readBufferSize = null, int?writeBufferSize = null, bool?isTcpKeepalive = null, IEnumerable <IMembershipEncoder> encoders = null, ISslConfiguration sslConfiguration = null, ConnectError onDisconnected = null, Connecting onConnecting = null, Connecting onConnected = null, Writing onWriting = null, StartingBytes onWritingBytes = null, FinishedBytes onWroteBytes = null, WriteSuccess onWritten = null, WriteError onWriteFailed = null, Reading onReading = null, StartingBytes onReadingBytes = null, FinishedBytes onReadBytes = null, ReadSuccess onRead = null, ReadError onReadFailed = null, ProduceRequestMessages onProduceRequestMessages = null) { return(new ConnectionConfiguration( connectionRetry ?? configuration.ConnectionRetry, versionSupport ?? configuration.VersionSupport, requestTimeout ?? configuration.RequestTimeout, readBufferSize ?? configuration.ReadBufferSize, writeBufferSize ?? configuration.WriteBufferSize, isTcpKeepalive ?? configuration.IsTcpKeepalive, encoders ?? configuration.Encoders.Values, sslConfiguration ?? configuration.SslConfiguration, onDisconnected ?? configuration.OnDisconnected, onConnecting ?? configuration.OnConnecting, onConnected ?? configuration.OnConnected, onWriting ?? configuration.OnWriting, onWritingBytes ?? configuration.OnWritingBytes, onWroteBytes ?? configuration.OnWroteBytes, onWritten ?? configuration.OnWritten, onWriteFailed ?? configuration.OnWriteFailed, onReading ?? configuration.OnReading, onReadingBytes ?? configuration.OnReadingBytes, onReadBytes ?? configuration.OnReadBytes, onRead ?? configuration.OnRead, onReadFailed ?? configuration.OnReadFailed, onProduceRequestMessages ?? configuration.OnProduceRequestMessages)); }
protected override void OnActivated() { base.OnActivated(); if (View.GetType() == typeof(DashboardView)) { return; } object currentObject = View.CurrentObject; string reason = "allowedition"; // View.AllowEdit.Clear(); // View.Refresh(); // Нужные объекты помечены интерфейсом IVersionMainObject if (currentObject is IVersionMainObject) { IVersionMainObject obj = currentObject as IVersionMainObject; if (obj != null) { bool bAllowEdit = false; View.AllowEdit.SetItemValue(reason, bAllowEdit); View.IsRoot = true; } return; } if (currentObject is IVersionSupport) { IVersionSupport obj = (IVersionSupport)currentObject; if (obj != null) { bool bAllowEdit = false; if (obj.VersionState == VersionStates.VERSION_NEW | obj.VersionState == VersionStates.VERSION_PROJECT) { bAllowEdit = true; } View.AllowEdit.SetItemValue(reason, bAllowEdit); //View.Refresh(); View.IsRoot = true; } return; } }
/// <summary> /// Configuration for the tcp connection. /// </summary> /// <param name="connectionRetry">Retry details for (re)establishing the connection.</param> /// <param name="versionSupport">Support for different protocol versions for Kakfa requests and responses.</param> /// <param name="requestTimeout">The maximum time to wait for requests.</param> /// <param name="readBufferSize">The buffer size to use for the socket, when receiving bytes.</param> /// <param name="writeBufferSize">The buffer size to use for the socket, when sending bytes.</param> /// <param name="isTcpKeepalive">TCP keepalive option.</param> /// <param name="encoders">Custom Encoding support for different protocol types</param> /// <param name="sslConfiguration">Configuration for SSL encrypted communication</param> /// <param name="onDisconnected">Triggered when the tcp socket is disconnected.</param> /// <param name="onConnecting">Triggered when the tcp socket is connecting.</param> /// <param name="onConnected">Triggered after the tcp socket is successfully connected.</param> /// <param name="onWriting">Triggered when writing to the tcp stream.</param> /// <param name="onWritingBytes">Triggered when writing a chunk of bytes to the tcp stream.</param> /// <param name="onWroteBytes">Triggered after successfully writing a chunk of bytes to the tcp stream.</param> /// <param name="onWritten">Triggered after having successfully written to the tcp stream.</param> /// <param name="onWriteFailed">Triggered after failing to write to the tcp stream.</param> /// <param name="onReading">Triggered when starting to read a message's bytes from the tcp stream.</param> /// <param name="onReadingBytes">Triggered when reading a chunk of bytes from the tcp stream.</param> /// <param name="onReadBytes">Triggered after successfully reading a chunk of bytes from the tcp stream.</param> /// <param name="onRead">Triggered after having successfully read a message's bytes from the tcp stream.</param> /// <param name="onReadFailed">Triggered after failing to read from the tcp stream.</param> /// <param name="onProduceRequestMessages">Triggered when encoding ProduceRequest messages.</param> public ConnectionConfiguration( IRetry connectionRetry = null, IVersionSupport versionSupport = null, TimeSpan?requestTimeout = null, int?readBufferSize = null, int?writeBufferSize = null, bool?isTcpKeepalive = null, IEnumerable <IMembershipEncoder> encoders = null, ISslConfiguration sslConfiguration = null, ConnectError onDisconnected = null, Connecting onConnecting = null, Connecting onConnected = null, Writing onWriting = null, StartingBytes onWritingBytes = null, FinishedBytes onWroteBytes = null, WriteSuccess onWritten = null, WriteError onWriteFailed = null, Reading onReading = null, StartingBytes onReadingBytes = null, FinishedBytes onReadBytes = null, ReadSuccess onRead = null, ReadError onReadFailed = null, ProduceRequestMessages onProduceRequestMessages = null ) { ConnectionRetry = connectionRetry ?? Defaults.ConnectionRetry(); VersionSupport = versionSupport ?? Connections.VersionSupport.Kafka10; RequestTimeout = requestTimeout ?? TimeSpan.FromSeconds(Defaults.RequestTimeoutSeconds); ReadBufferSize = readBufferSize.GetValueOrDefault(Defaults.BufferSize); WriteBufferSize = writeBufferSize.GetValueOrDefault(Defaults.BufferSize); IsTcpKeepalive = isTcpKeepalive ?? Defaults.IsTcpKeepalive; Encoders = Defaults.Encoders(encoders); SslConfiguration = sslConfiguration; OnDisconnected = onDisconnected; OnConnecting = onConnecting; OnConnected = onConnected; OnWriting = onWriting; OnWritingBytes = onWritingBytes; OnWroteBytes = onWroteBytes; OnWritten = onWritten; OnWriteFailed = onWriteFailed; OnReading = onReading; OnReadingBytes = onReadingBytes; OnReadBytes = onReadBytes; OnRead = onRead; OnReadFailed = onReadFailed; OnProduceRequestMessages = onProduceRequestMessages; }
/// <summary> /// Копирование объекта. Результат - это копия объекта, в котором все обычные, но неверсионные, свойства копируются из прежнего объекта /// </summary> /// <param name="source"></param> /// <param name="targetSession"></param> /// <param name="synchronize"></param> /// <returns></returns> public object CopyForVersion(IXPSimpleObject source) { if (source == null) { return(null); } XPClassInfo classInfo = sourceSession.GetClassInfo(source.GetType()); // Копия объекта. Есть проблема. Если в AfterConstruction объекта создаётся некий версионный объект, то // этот версионный объект окажется незамещённым никакой копией из исходного объекта и тем самым "повиснет" IVersionSupport copy = (IVersionSupport)classInfo.CreateNewObject(sourceSession); // Паша copy.IsProcessCloning = true; foreach (XPMemberInfo m in classInfo.PersistentProperties) { if (m is DevExpress.Xpo.Metadata.Helpers.ServiceField || m.IsKey) { continue; } if (m is IVersionSupport) { continue; } m.SetValue(copy, m.GetValue(source)); } foreach (XPMemberInfo m in classInfo.CollectionProperties) { if (m.HasAttribute(typeof(AggregatedAttribute))) { XPBaseCollection colCopy = (XPBaseCollection)m.GetValue(copy); XPBaseCollection colSource = (XPBaseCollection)m.GetValue(source); foreach (IXPSimpleObject obj in new ArrayList(colSource)) { if (obj is IVersionSupport) { continue; } colCopy.BaseAdd(obj); } } } return(copy); }
/// <summary> /// Этот метод позволяет создать другой объект, чем тот, что задаётся выбором пункта меню или подменю New. /// Однако, не удаётся пока передать этот объект дальше в метод CustomNewActionController_CustomAddObjectToCollection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CustomNewActionController_ObjectCreating(object sender, ObjectCreatingEventArgs e) { foreach (Type type in e.ObjectType.GetInterfaces()) { if (type == typeof(IVersionSupport)) { e.NewObject = e.ObjectSpace.CreateObject(e.ObjectType); IVersionSupport vobj = e.NewObject as IVersionSupport; if (vobj != null) { //!!!Паша нужно правильно определить vobj.VersionState сейчас заглушка vobj.VersionState = VersionStates.VERSION_NEW; vobj.VersionAfterConstruction(); } } } }
/* * public virtual Dictionary<IVersionSupport, IVersionSupport> CreateNewVersionStep1(IVersionSupport sourceObj, VersionHelper vHelper) { * source = sourceObj as IXPSimpleObject; * if (source == null) return null; * * // Алгоритм. * // 1. Вычисляется версионный слой sourceVersionStrate * // 2. Создаётся массив пар зависмых объектов и их клонов - dict * // 3. Все вхождения подобъектов в исходный версионный слой, говоря приблизительно, заменяются на их клоны согласно dict * // 4. У нового версионного слоя у всех входящих в него версионных объектов проставляется статус VERSION_PROJECT * * // Версионный слой от sourceObj - это версионный слой, из которого будет делаться новый версионный слой * // Замечание. Свм объект по построению входит в свой версионный слой. * List<IVersionSupport> sourceVersionStrate = GetVersionedStrate(sourceObj, vHelper); * * // Создаём словарь с копиями объектов из newVersionStrate * Dictionary<IVersionSupport, IVersionSupport> dict = GenerateCopyOfObjects(sourceVersionStrate, source.Session, sourceObj); * * return dict; * } * * * public virtual IVersionSupport CreateNewVersionStep2(IVersionSupport sourceObj, Dictionary<IVersionSupport, IVersionSupport> dict, VersionHelper vHelper) { * * // Проставляем статус и некоторые другие свойства * SetVersionState(dict, VersionStates.VERSION_PROJECT); * * // Меняем свойства на версионные * ResetVersionProperty(vHelper.sourceSession, ignoredProperties, dict); * * // На выходе - копия основного объекта новой версии * return dict[sourceObj]; * } */ #endregion /// <summary> /// Нерекурсивный метод создания версионного слоя по заданному объекту /// </summary> /// <param name="sourceObj"></param> /// <param name="vHelper"></param> /// <returns></returns> public virtual List <IVersionSupport> GetVersionedStrate(IVersionSupport sourceObj, VersionHelper vHelper) { // Коллекция проверенных List <IVersionSupport> processedList = new List <IVersionSupport>(); List <IVersionSupport> vStrate = new List <IVersionSupport>() { sourceObj }; //List<IVersionSupport> vStrate = GetFirstDependentList(sourceObj, vHelper); int count; for (;;) { count = vStrate.Count; List <IVersionSupport> tempCol = new List <IVersionSupport>(); foreach (IVersionSupport obj in vStrate) { if (processedList.Contains(obj)) { continue; } List <IVersionSupport> list = GetFirstDependentList(obj, vHelper); foreach (IVersionSupport elem in list) { AddObjectToList(elem, tempCol); } AddObjectToList(obj, processedList); } foreach (IVersionSupport elem in tempCol) { AddObjectToList(elem, vStrate); } if (count == vStrate.Count) { break; } } return(vStrate); }
/// <summary> /// Снятие непосредственно прилегающих к объекту версионных объектов /// </summary> /// <param name="sourceObj"></param> /// <param name="dependentObjectList"></param> /// <param name="vHelper"></param> /// <returns></returns> public List <IVersionSupport> GetFirstDependentList(IVersionSupport sourceObj, VersionHelper vHelper) { List <IVersionSupport> ResList = new List <IVersionSupport>(); if (sourceObj == null) { return(ResList); } IXPSimpleObject sourceObject = (IXPSimpleObject)sourceObj; XPClassInfo sourceClassInfo = sourceObject.ClassInfo; // sourceSession.GetClassInfo(sourceObject); foreach (XPMemberInfo m in sourceClassInfo.PersistentProperties) { if (m is DevExpress.Xpo.Metadata.Helpers.ServiceField || m.IsKey) { continue; } if (m.ReferenceType != null) { IVersionSupport ob = m.GetValue(sourceObj) as IVersionSupport; if (ob != null) { AddObjectToList(ob, ResList); } } } foreach (XPMemberInfo m in sourceClassInfo.CollectionProperties) { //if (m.HasAttribute(typeof(AggregatedAttribute))) { XPBaseCollection colSource = (XPBaseCollection)m.GetValue(sourceObj); foreach (IXPSimpleObject obj in colSource) { if (obj is IVersionSupport) { AddObjectToList((IVersionSupport)obj, ResList); } } //} } return(ResList); }
/// <summary> /// Configuration for the tcp connection. /// </summary> /// <param name="connectionRetry">Retry details for (re)establishing the connection.</param> /// <param name="versionSupport">Support for different protocol versions for Kakfa requests and responses.</param> /// <param name="requestTimeout">The maximum time to wait for requests.</param> /// <param name="encoders">Custom Encoding support for different protocol types</param> /// <param name="sslConfiguration">Configuration for SSL encrypted communication</param> /// <param name="onDisconnected">Triggered when the tcp socket is disconnected.</param> /// <param name="onConnecting">Triggered when the tcp socket is connecting.</param> /// <param name="onConnected">Triggered after the tcp socket is successfully connected.</param> /// <param name="onWriteEnqueued">Triggered after enqueing async write task for writing to the tcp stream.</param> /// <param name="onWriting">Triggered when writing to the tcp stream.</param> /// <param name="onWritten">Triggered after having successfully written to the tcp stream.</param> /// <param name="onWriteFailed">Triggered after failing to write to the tcp stream.</param> /// <param name="onReading">Triggered when starting to read a message's bytes from the tcp stream.</param> /// <param name="onReadingChunk">Triggered when reading a chunk of bytes from the tcp stream.</param> /// <param name="onReadChunk">Triggered after successfully reading a chunk of bytes from the tcp stream.</param> /// <param name="onRead">Triggered after having successfully read a message's bytes from the tcp stream.</param> /// <param name="onReadFailed">Triggered after failing to read from the tcp stream.</param> /// <param name="onProduceRequestMessages">Triggered when encoding ProduceRequest messages.</param> public ConnectionConfiguration( IRetry connectionRetry = null, IVersionSupport versionSupport = null, TimeSpan?requestTimeout = null, IEnumerable <IProtocolTypeEncoder> encoders = null, ISslConfiguration sslConfiguration = null, ConnectError onDisconnected = null, Connecting onConnecting = null, Connecting onConnected = null, Writing onWriteEnqueued = null, Writing onWriting = null, WriteSuccess onWritten = null, WriteError onWriteFailed = null, Reading onReading = null, ReadingChunk onReadingChunk = null, ReadChunk onReadChunk = null, Read onRead = null, ReadError onReadFailed = null, ProduceRequestMessages onProduceRequestMessages = null ) { ConnectionRetry = connectionRetry ?? Defaults.ConnectionRetry(); VersionSupport = versionSupport ?? Connections.VersionSupport.Kafka8; RequestTimeout = requestTimeout ?? TimeSpan.FromSeconds(Defaults.RequestTimeoutSeconds); Encoders = encoders != null ? encoders.ToImmutableDictionary(e => e.Type) : ImmutableDictionary <string, IProtocolTypeEncoder> .Empty; SslConfiguration = sslConfiguration; OnDisconnected = onDisconnected; OnConnecting = onConnecting; OnConnected = onConnected; OnWriteEnqueued = onWriteEnqueued; OnWriting = onWriting; OnWritten = onWritten; OnWriteFailed = onWriteFailed; OnReading = onReading; OnReadingChunk = onReadingChunk; OnReadChunk = onReadChunk; OnRead = onRead; OnReadFailed = onReadFailed; OnProduceRequestMessages = onProduceRequestMessages; }
private async Task <short> GetVersionAsync(ApiKeyRequestType requestType, CancellationToken cancellationToken) { if (!_configuration.VersionSupport.IsDynamic) { return(_configuration.VersionSupport.GetVersion(requestType).GetValueOrDefault()); } using (await _versionSupportLock.ReaderLockAsync(cancellationToken).ConfigureAwait(false)) { if (_versionSupport != null) { return(_versionSupport.GetVersion(requestType).GetValueOrDefault()); } } using (await _versionSupportLock.WriterLockAsync(cancellationToken).ConfigureAwait(false)) { return(await _configuration.ConnectionRetry.AttemptAsync( async (attempt, timer) => { var response = await SendAsync(new ApiVersionsRequest(), cancellationToken, new RequestContext(version: 0)).ConfigureAwait(false); if (response.ErrorCode.IsRetryable()) { return RetryAttempt <short> .Retry; } if (!response.ErrorCode.IsSuccess()) { return RetryAttempt <short> .Abort; } var supportedVersions = response.SupportedVersions.ToImmutableDictionary( _ => _.ApiKey, _ => _.MaxVersion); _versionSupport = new VersionSupport(supportedVersions); return new RetryAttempt <short>(_versionSupport.GetVersion(requestType).GetValueOrDefault()); }, (attempt, timer) => _log.Debug(() => LogEvent.Create($"Retrying {nameof(GetVersionAsync)} attempt {attempt}")), attempt => _versionSupport = _configuration.VersionSupport, exception => _log.Error(LogEvent.Create(exception)), cancellationToken)); } }
public virtual Dictionary <IVersionSupport, IVersionSupport> GenerateCopyOfObjects(List <IVersionSupport> list, Session ssn, IVersionSupport sourceObj) { VersionHelper vHelper = new VersionHelper(this.Session); return(vHelper.GenerateCopyOfObjects(list, ssn, sourceObj)); }
public virtual void SetVersionStateExt(IVersionSupport obj, VersionStates vs) { VersionHelper vHelper = new VersionHelper(this.Session); vHelper.SetVersionStateExt(obj, vs); }
/// <summary> /// /// </summary> /// <param name="ivCopiedObj">основной объект для копированя</param> /// <param name="ivTargetObj">Новая версия объекта ivCopiedObj</param> /// <param name="ignoredProperties">Список игнорируемых свойств</param> /// <param name="dict">Словарь с копиями версионируемых объектов</param> public void ResetVersionProperty(Session ssn, string ignoredProperties, Dictionary <IVersionSupport, IVersionSupport> dict) { if (dict == null || dict.Count == 0) { return; } //if (ivCopiedObj == null) return; //Session ssn = ivCopiedObj.Session; ArrayList IgnoredPropertiesList = new ArrayList(ignoredProperties.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)); // Прогон по словарю объектов foreach (IVersionSupport sourceObj in dict.Keys) { if (dict[sourceObj] == null) { continue; } IXPSimpleObject sourceObject = (IXPSimpleObject)sourceObj; IXPSimpleObject targetObject = (IXPSimpleObject)dict[sourceObj]; // Паша IVersionSupport to = (IVersionSupport)targetObject; XPClassInfo sourceClassInfo = sourceObject.ClassInfo; // ssn.GetClassInfo(sourceObject.GetType()); foreach (XPMemberInfo m in sourceClassInfo.PersistentProperties) { if (m is DevExpress.Xpo.Metadata.Helpers.ServiceField || m.IsKey) { continue; } if (IgnoredPropertiesList.Contains(m.Name)) { continue; } //if (m.GetValue(sourceObject) is IVersionSupport == null) continue; IVersionSupport ob = m.GetValue(sourceObject) as IVersionSupport; if (ob != null && dict.ContainsKey(ob)) { IXPSimpleObject newValue = dict[ob] as IXPSimpleObject; if (newValue != null) { m.SetValue(targetObject, newValue); } } } // Здесь надо иметь основной объект исходного слоя(source) и его версию (clone) foreach (XPMemberInfo m in sourceClassInfo.CollectionProperties) { //if (m.HasAttribute(typeof(AggregatedAttribute))) { XPBaseCollection colSource = (XPBaseCollection)m.GetValue(sourceObject); XPBaseCollection colTarget = (XPBaseCollection)m.GetValue(targetObject); foreach (IXPSimpleObject obj in new ArrayList(colSource)) { if (obj == null) { continue; } if (obj is IVersionSupport) { if (dict.ContainsKey((IVersionSupport)obj)) { IVersionSupport objClone = dict[(IVersionSupport)obj]; colTarget.BaseAdd(objClone); } } else { colTarget.BaseAdd(obj); } } //} } to.IsProcessCloning = false; } }
public virtual List <IVersionSupport> GetVersionedStrate(IVersionSupport sourceObj, VersionHelper vHelper) { return(vHelper.GetVersionedStrate(sourceObj, vHelper)); }
public void AddObjectToList(IVersionSupport obj, List <IVersionSupport> dependentObjectList) { VersionHelper.AddObjectToList(obj, dependentObjectList); }
/// <summary> /// Configuration for the tcp connection. /// </summary> /// <param name="tracker">Mechanism for tracking telemetry.</param> /// <param name="connectionRetry">Retry details for (re)establishing the connection.</param> /// <param name="versionSupport">Support for different protocol versions for Kakfa requests and responses.</param> /// <param name="requestTimeout">The maximum time to wait for requests.</param> /// <param name="encoders">Custom Encoding support for different protocol types</param> public ConnectionConfiguration(ITrackEvents tracker, IRetry connectionRetry = null, IVersionSupport versionSupport = null, TimeSpan?requestTimeout = null, IEnumerable <IProtocolTypeEncoder> encoders = null) : this(connectionRetry, versionSupport, requestTimeout, encoders, null, tracker != null ? (ConnectError)tracker.Disconnected : null, tracker != null ? (Connecting)tracker.Connecting : null, tracker != null ? (Connecting)tracker.Connected : null, tracker != null ? (Writing)tracker.WriteEnqueued : null, tracker != null ? (Writing)tracker.Writing : null, tracker != null ? (WriteSuccess)tracker.Written : null, tracker != null ? (WriteError)tracker.WriteFailed : null, tracker != null ? (Reading)tracker.Reading : null, tracker != null ? (ReadingChunk)tracker.ReadingChunk : null, tracker != null ? (ReadChunk)tracker.ReadChunk : null, tracker != null ? (Read)tracker.Read : null, tracker != null ? (ReadError)tracker.ReadFailed: null, tracker != null ? (ProduceRequestMessages)tracker.ProduceRequestMessages : null) { }
public virtual IVersionSupport CreateNewVersion(IVersionSupport sourceObj, VersionHelper vHelper) { IVersionSupport newVersionObj = vHelper.CreateNewVersion(sourceObj, vHelper); return(newVersionObj); }
public void Approve(IVersionSupport obj) { }
public virtual List <IVersionSupport> GetFirstDependentList(IVersionSupport sourceObj, List <IVersionSupport> dependentObjectList, VersionHelper vHelper) { return(new List <IVersionSupport>()); }