コード例 #1
0
ファイル: Module.cs プロジェクト: xafdelta/xafdelta
 internal bool DoBeforeLoadSession(LoadSessionArgs e)
 {
     var handler = BeforeLoadSession;
     if (handler != null) handler(this, e);
     return e.Done;
 }
コード例 #2
0
        private void loadTopSession(LoadPackageSessionContext context)
        {
            var objectSpace = context.ObjectSpace;
            var criteria = CriteriaOperator.Parse("SessionId = ?", context.PackageSession.SessionId);

            // avoid duplicate session loading
            if (objectSpace.FindObject<ProtocolSession>(criteria, true) == null)
            {
                var sessionTree = context.PackageSession.AllChildren;
                var allRecords = (from s in sessionTree from r in s.PackageRecords
                                  orderby r.ModifiedOn select r).ToList();

                allRecords = allRecords.Distinct().ToList();

                var args = new LoadSessionArgs(context, allRecords);
                var activeObjectSpaces = new Dictionary<Guid, IObjectSpace>();
                try
                {
                    if (!Owner.DoBeforeLoadSession(args))
                    {
                        allRecords.ForEach(y => loadPackageRecord(new LoadPackageRecordContext(context,
                            y, activeObjectSpaces)));
                    }
                    if (activeObjectSpaces.Count > 0)
                    {
                        commitObjectSpaceOnLoad(activeObjectSpaces.Values.ElementAt(0), activeObjectSpaces);
                        activeObjectSpaces.Clear();
                    }
                }
                finally
                {
                    if (activeObjectSpaces.Count > 0)
                    {
                        // first element in values is top session
                        activeObjectSpaces.Values.ElementAt(0).Rollback();
                        activeObjectSpaces.Values.ElementAt(0).Dispose();
                        activeObjectSpaces.Clear();
                    }
                }

                createProtocolRecords(allRecords, context);

                Owner.DoAfterLoadSession(args);
            }
            else
            {
                var errorText = string.Format(Localizer.SessionAlreadyLoaded,
                    context.PackageSession.SessionId);

                context.Worker.ReportProgress(Color.BlueViolet, errorText);
                context.Package.CreateLogRecord(PackageEventType.SessionAlreadyLoaded, errorText);
            }
        }
コード例 #3
0
ファイル: Module.cs プロジェクト: xafdelta/xafdelta
 internal void DoAfterLoadSession(LoadSessionArgs e)
 {
     var handler = AfterLoadSession;
     if (handler != null) handler(this, e);
 }