VI.DB/VI.DB.Entities/XOriginEntityLogic.cs
Decompiler Source FileVI.DB.XOriginEntityLogicDecompiled Source
Interpretation
- Decompiled source file. Use method/event registrations and call-site extraction to connect back to DialogMethod, QBMEvent, and API layers.
Relations
- Method registration: AssignDirect at line 265
Typed Edges
- No typed edges extracted for this source.
References
- No direct source references extracted.
Referenced By
- No direct source references extracted.
C# source-derived context
Generated by pattern extraction from the decompiled C# source and decompile index. This is factual source evidence, not inferred behavior.
reads entity values references DB/Dialog objects
Summary: classes XOriginEntityLogic; methods MoveNext, SetStateMachine, OnSavingAsync, _Log; references ESet; markers reads entity values, references DB/Dialog objects
Classes
XOriginEntityLogicDB/Dialog object references
OIM key/entity markers
None extracted.API/entity calls
GetValueAsync IsToDeleteRegistrations / handlers
None extracted.
Complete Source
1using System;2using System.Collections.Generic;3using System.Diagnostics;4using System.Runtime.CompilerServices;5using System.Runtime.InteropServices;6using System.Threading;7using System.Threading.Tasks;8using NLog;9using VI.Base;1011namespace VI.DB.Entities;1213internal class XOriginEntityLogic : StateLessEntityLogic14{15 [StructLayout((LayoutKind)3)]16 [CompilerGenerated]17 private struct _003COnSavingAsync_003Ed__3 : IAsyncStateMachine18 {19 public int _003C_003E1__state;2021 public AsyncTaskMethodBuilder<Diff> _003C_003Et__builder;2223 public IEntity entity;2425 public CancellationToken ct;2627 public LogicReadWriteParameters parameters;2829 public XOriginEntityLogic _003C_003E4__this;3031 private Diff _003Cchanges_003E5__2;3233 private bool _003ChasXIsInEffect_003E5__3;3435 private ConfiguredValueTaskAwaiter<int> _003C_003Eu__1;3637 private ConfiguredTaskAwaiter<Diff> _003C_003Eu__2;3839 private void MoveNext()40 {41 //IL_00bb: Unknown result type (might be due to invalid IL or missing references)42 //IL_00c0: Unknown result type (might be due to invalid IL or missing references)43 //IL_00c8: Unknown result type (might be due to invalid IL or missing references)44 //IL_022d: Unknown result type (might be due to invalid IL or missing references)45 //IL_0232: Unknown result type (might be due to invalid IL or missing references)46 //IL_023a: Unknown result type (might be due to invalid IL or missing references)47 //IL_038f: Unknown result type (might be due to invalid IL or missing references)48 //IL_0394: Unknown result type (might be due to invalid IL or missing references)49 //IL_039c: Unknown result type (might be due to invalid IL or missing references)50 //IL_044e: Unknown result type (might be due to invalid IL or missing references)51 //IL_0453: Unknown result type (might be due to invalid IL or missing references)52 //IL_045b: Unknown result type (might be due to invalid IL or missing references)53 //IL_006e: Unknown result type (might be due to invalid IL or missing references)54 //IL_007d: Unknown result type (might be due to invalid IL or missing references)55 //IL_0082: Unknown result type (might be due to invalid IL or missing references)56 //IL_0086: Unknown result type (might be due to invalid IL or missing references)57 //IL_008b: Unknown result type (might be due to invalid IL or missing references)58 //IL_0405: Unknown result type (might be due to invalid IL or missing references)59 //IL_0410: Unknown result type (might be due to invalid IL or missing references)60 //IL_0415: Unknown result type (might be due to invalid IL or missing references)61 //IL_0419: Unknown result type (might be due to invalid IL or missing references)62 //IL_041e: Unknown result type (might be due to invalid IL or missing references)63 //IL_00a0: Unknown result type (might be due to invalid IL or missing references)64 //IL_00a2: Unknown result type (might be due to invalid IL or missing references)65 //IL_0433: Unknown result type (might be due to invalid IL or missing references)66 //IL_0435: Unknown result type (might be due to invalid IL or missing references)67 //IL_0342: Unknown result type (might be due to invalid IL or missing references)68 //IL_0351: Unknown result type (might be due to invalid IL or missing references)69 //IL_0356: Unknown result type (might be due to invalid IL or missing references)70 //IL_035a: Unknown result type (might be due to invalid IL or missing references)71 //IL_035f: Unknown result type (might be due to invalid IL or missing references)72 //IL_0374: Unknown result type (might be due to invalid IL or missing references)73 //IL_0376: Unknown result type (might be due to invalid IL or missing references)74 //IL_01e0: Unknown result type (might be due to invalid IL or missing references)75 //IL_01ef: Unknown result type (might be due to invalid IL or missing references)76 //IL_01f4: Unknown result type (might be due to invalid IL or missing references)77 //IL_01f8: Unknown result type (might be due to invalid IL or missing references)78 //IL_01fd: Unknown result type (might be due to invalid IL or missing references)79 //IL_0212: Unknown result type (might be due to invalid IL or missing references)80 //IL_0214: Unknown result type (might be due to invalid IL or missing references)81 int num = _003C_003E1__state;82 XOriginEntityLogic xOriginEntityLogic = _003C_003E4__this;83 Diff result3;84 try85 {86 bool flag;87 ConfiguredValueTaskAwaiter<int> val2;88 ConfiguredTaskAwaiter<Diff> val;89 int result;90 List<DiffOperation> obj;91 List<DiffOperation> val3;92 switch (num)93 {94 default:95 {96 _003Cchanges_003E5__2 = null;97 IEntityColumn entityColumn = entity.Columns["xorigin"];98 _003ChasXIsInEffect_003E5__3 = entity.Columns.Contains("xisineffect");99 if (!entity.IsLoaded)100 {101 val2 = entityColumn.GetValueAsync<int>(ct).ConfigureAwait(false).GetAwaiter();102 if (!val2.IsCompleted)103 {104 num = (_003C_003E1__state = 0);105 _003C_003Eu__1 = val2;106 _003C_003Et__builder.AwaitUnsafeOnCompleted<ConfiguredValueTaskAwaiter<int>, _003COnSavingAsync_003Ed__3>(ref val2, ref this);107 return;108 }109 goto IL_00d7;110 }111 if (entity.IsToDelete() && !parameters.Session.Variables.Contains("XORIGINEMPTY"))112 {113 _Log(parameters.Session, "Removing Direct flag from XOrigin instead of deleting item.");114 if (entity.State.HasFlagFast(EntityState.OutStanding))115 {116 IVarContext variables = parameters.Session.Variables;117 if (!variables.Get<bool>("FULLSYNC") && !variables.Get<bool>("ManageOutstanding"))118 {119 throw new ViException(810319, ExceptionRelevance.EndUser);120 }121 }122 val2 = entityColumn.GetValueAsync<int>(ct).ConfigureAwait(false).GetAwaiter();123 if (!val2.IsCompleted)124 {125 num = (_003C_003E1__state = 1);126 _003C_003Eu__1 = val2;127 _003C_003Et__builder.AwaitUnsafeOnCompleted<ConfiguredValueTaskAwaiter<int>, _003COnSavingAsync_003Ed__3>(ref val2, ref this);128 return;129 }130 goto IL_0249;131 }132 flag = entityColumn.IsDifferent & _003ChasXIsInEffect_003E5__3;133 if (flag)134 {135 val2 = entityColumn.GetValueAsync<int>(ct).ConfigureAwait(false).GetAwaiter();136 if (!val2.IsCompleted)137 {138 num = (_003C_003E1__state = 2);139 _003C_003Eu__1 = val2;140 _003C_003Et__builder.AwaitUnsafeOnCompleted<ConfiguredValueTaskAwaiter<int>, _003COnSavingAsync_003Ed__3>(ref val2, ref this);141 return;142 }143 goto IL_03ab;144 }145 goto IL_03b7;146 }147 case 0:148 val2 = _003C_003Eu__1;149 _003C_003Eu__1 = default(ConfiguredValueTaskAwaiter<int>);150 num = (_003C_003E1__state = -1);151 goto IL_00d7;152 case 1:153 val2 = _003C_003Eu__1;154 _003C_003Eu__1 = default(ConfiguredValueTaskAwaiter<int>);155 num = (_003C_003E1__state = -1);156 goto IL_0249;157 case 2:158 val2 = _003C_003Eu__1;159 _003C_003Eu__1 = default(ConfiguredValueTaskAwaiter<int>);160 num = (_003C_003E1__state = -1);161 goto IL_03ab;162 case 3:163 {164 val = _003C_003Eu__2;165 _003C_003Eu__2 = default(ConfiguredTaskAwaiter<Diff>);166 num = (_003C_003E1__state = -1);167 break;168 }169 IL_03ab:170 flag = val2.GetResult() == 0;171 goto IL_03b7;172 IL_0249:173 result = val2.GetResult();174 if (parameters.Options.Flags.HasFlagFast(PutFlags.FromReferentialIntegrity))175 {176 _Log(parameters.Session, "Coming from referential integrity -> resetting all bits of XOrigin");177 result = 0;178 }179 else180 {181 result &= -2;182 }183 obj = new List<DiffOperation>();184 obj.Add(new DiffOperation185 {186 Type = DiffOperationType.Value,187 Name = "xorigin",188 Value = result189 });190 val3 = obj;191 if ((result == 0) & _003ChasXIsInEffect_003E5__3)192 {193 val3.Add(new DiffOperation194 {195 Type = DiffOperationType.Value,196 Name = "xisineffect",197 Value = false198 });199 }200 _003Cchanges_003E5__2 = new Diff(new DiffData201 {202 State = (entity.State & ~EntityState.Deleted)203 }, (System.Collections.Generic.IEnumerable<DiffOperation>)val3);204 goto IL_03f7;205 IL_00d7:206 if (val2.GetResult() == 0)207 {208 _Log(parameters.Session, "No XOrigin value provided, assuming {0}.", XOrigin.Direct);209 _003Cchanges_003E5__2 = new Diff(new DiffData(), new DiffOperation210 {211 Type = DiffOperationType.Value,212 Name = "xorigin",213 Value = 1214 });215 }216 goto IL_03f7;217 IL_03b7:218 if (flag)219 {220 _003Cchanges_003E5__2 = new Diff(new DiffData(), new DiffOperation221 {222 Type = DiffOperationType.Value,223 Name = "xisineffect",224 Value = false225 });226 }227 goto IL_03f7;228 IL_03f7:229 val = ((EntityLogicBase)xOriginEntityLogic).OnSavingAsync(entity, parameters, ct).ConfigureAwait(false).GetAwaiter();230 if (!val.IsCompleted)231 {232 num = (_003C_003E1__state = 3);233 _003C_003Eu__2 = val;234 _003C_003Et__builder.AwaitUnsafeOnCompleted<ConfiguredTaskAwaiter<Diff>, _003COnSavingAsync_003Ed__3>(ref val, ref this);235 return;236 }237 break;238 }239 Diff result2 = val.GetResult();240 result3 = ((_003Cchanges_003E5__2 != null) ? result2.Concat(_003Cchanges_003E5__2) : result2);241 }242 catch (System.Exception exception)243 {244 _003C_003E1__state = -2;245 _003Cchanges_003E5__2 = null;246 _003C_003Et__builder.SetException(exception);247 return;248 }249 _003C_003E1__state = -2;250 _003Cchanges_003E5__2 = null;251 _003C_003Et__builder.SetResult(result3);252 }253254 [DebuggerHidden]255 private void SetStateMachine(IAsyncStateMachine stateMachine)256 {257 _003C_003Et__builder.SetStateMachine(stateMachine);258 }259 }260261 public override int Priority => 22;262263 public XOriginEntityLogic()264 {265 RegisterMethod("AssignDirect").As([AsyncStateMachine(typeof(_003C_003Ec._003C_003C_002Dctor_003Eb__0_0_003Ed))] (ISession s, IEntity e, CancellationToken ct) =>266 {267 //IL_0002: Unknown result type (might be due to invalid IL or missing references)268 //IL_0007: Unknown result type (might be due to invalid IL or missing references)269 //IL_0016: Unknown result type (might be due to invalid IL or missing references)270 //IL_0017: Unknown result type (might be due to invalid IL or missing references)271 _003C_003Ec._003C_003C_002Dctor_003Eb__0_0_003Ed _003C_003C_002Dctor_003Eb__0_0_003Ed = default(_003C_003Ec._003C_003C_002Dctor_003Eb__0_0_003Ed);272 _003C_003C_002Dctor_003Eb__0_0_003Ed._003C_003Et__builder = AsyncTaskMethodBuilder.Create();273 _003C_003C_002Dctor_003Eb__0_0_003Ed.e = e;274 _003C_003C_002Dctor_003Eb__0_0_003Ed.ct = ct;275 _003C_003C_002Dctor_003Eb__0_0_003Ed._003C_003E1__state = -1;276 ((AsyncTaskMethodBuilder)(ref _003C_003C_002Dctor_003Eb__0_0_003Ed._003C_003Et__builder)).Start<_003C_003Ec._003C_003C_002Dctor_003Eb__0_0_003Ed>(ref _003C_003C_002Dctor_003Eb__0_0_003Ed);277 return ((AsyncTaskMethodBuilder)(ref _003C_003C_002Dctor_003Eb__0_0_003Ed._003C_003Et__builder)).Task;278 });279 }280281 [AsyncStateMachine(typeof(_003COnSavingAsync_003Ed__3))]282 public override async System.Threading.Tasks.Task<Diff> OnSavingAsync(IEntity entity, LogicReadWriteParameters parameters, CancellationToken ct)283 {284 //IL_0002: Unknown result type (might be due to invalid IL or missing references)285 //IL_0007: Unknown result type (might be due to invalid IL or missing references)286 //IL_0026: Unknown result type (might be due to invalid IL or missing references)287 //IL_0027: Unknown result type (might be due to invalid IL or missing references)288 Diff changes = null;289 IEntityColumn entityColumn = entity.Columns["xorigin"];290 bool hasXIsInEffect = entity.Columns.Contains("xisineffect");291 if (!entity.IsLoaded)292 {293 if (await entityColumn.GetValueAsync<int>(ct).ConfigureAwait(false) == 0)294 {295 _Log(parameters.Session, "No XOrigin value provided, assuming {0}.", XOrigin.Direct);296 changes = new Diff(new DiffData(), new DiffOperation297 {298 Type = DiffOperationType.Value,299 Name = "xorigin",300 Value = 1301 });302 }303 }304 else if (entity.IsToDelete() && !parameters.Session.Variables.Contains("XORIGINEMPTY"))305 {306 _Log(parameters.Session, "Removing Direct flag from XOrigin instead of deleting item.");307 if (entity.State.HasFlagFast(EntityState.OutStanding))308 {309 IVarContext variables = parameters.Session.Variables;310 if (!variables.Get<bool>("FULLSYNC") && !variables.Get<bool>("ManageOutstanding"))311 {312 throw new ViException(810319, ExceptionRelevance.EndUser);313 }314 }315 int num = await entityColumn.GetValueAsync<int>(ct).ConfigureAwait(false);316 if (parameters.Options.Flags.HasFlagFast(PutFlags.FromReferentialIntegrity))317 {318 _Log(parameters.Session, "Coming from referential integrity -> resetting all bits of XOrigin");319 num = 0;320 }321 else322 {323 num &= -2;324 }325 List<DiffOperation> obj = new List<DiffOperation>();326 obj.Add(new DiffOperation327 {328 Type = DiffOperationType.Value,329 Name = "xorigin",330 Value = num331 });332 List<DiffOperation> val = obj;333 if (num == 0 && hasXIsInEffect)334 {335 val.Add(new DiffOperation336 {337 Type = DiffOperationType.Value,338 Name = "xisineffect",339 Value = false340 });341 }342 changes = new Diff(new DiffData343 {344 State = (entity.State & ~EntityState.Deleted)345 }, (System.Collections.Generic.IEnumerable<DiffOperation>)val);346 }347 else348 {349 bool flag = entityColumn.IsDifferent && hasXIsInEffect;350 if (flag)351 {352 flag = await entityColumn.GetValueAsync<int>(ct).ConfigureAwait(false) == 0;353 }354 if (flag)355 {356 changes = new Diff(new DiffData(), new DiffOperation357 {358 Type = DiffOperationType.Value,359 Name = "xisineffect",360 Value = false361 });362 }363 }364 Diff diff = await base.OnSavingAsync(entity, parameters, ct).ConfigureAwait(false);365 return (changes != null) ? diff.Concat(changes) : diff;366 }367368 private static void _Log(ISession session, string message, params object[] parameters)369 {370 Logger logger = LogManager.GetLogger("ObjectLog");371 LogSessionId sessionId = new LogSessionId(session.Id, useMultiLanguage: false);372 NLogExtensions.Debug(logger, sessionId, message, parameters);373 }374}375