Exemplo n.º 1
0
 public bool Epilogue(Runner runner, FID id, Exception error)
 {
     DisposableObject.DisposeAndNull(ref m_Server);
     DisposableObject.DisposeAndNull(ref m_App);
     m_Client.Dispose();
     return(false);
 }
Exemplo n.º 2
0
 public void ApplicationFinishBeforeCleanup(IApplication application)
 {
     DisposableObject.DisposeAndNull(ref m_Nodes);
     DisposableObject.DisposeAndNull(ref m_Comments);
     DisposableObject.DisposeAndNull(ref m_Events);
     DisposableObject.DisposeAndNull(ref m_Friends);
 }
Exemplo n.º 3
0
 bool IRunHook.Epilogue(Runner runner, FID id, MethodInfo method, RunAttribute attr, Exception error)
 {
   DisposableObject.DisposeAndNull(ref store);
   ErlApp.Node.Dispose();
   ErlApp.Node = null;
   return false;
 }
Exemplo n.º 4
0
 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     m_Pile.WaitForCompleteStop();
     DisposableObject.DisposeAndNull(ref m_CLRStore);
     DisposableObject.DisposeAndNull(ref m_PileStore);
     DisposableObject.DisposeAndNull(ref m_CLRThreads);
     DisposableObject.DisposeAndNull(ref m_PileThreads);
 }
Exemplo n.º 5
0
 protected override void DoCloseStream()
 {
     if (m_Writer != null)
     {
         m_Writer.Flush();
         m_Writer.Close();
         DisposableObject.DisposeAndNull(ref m_Writer);
     }
 }
Exemplo n.º 6
0
        protected override void Destructor()
        {
            base.Destructor();

            App.Singletons.Remove <PortalHub>();

            m_Portals.ForEach(p => p.Dispose());

            DisposableObject.DisposeAndNull(ref m_ContentFS);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Starts the application container, used by daemons directly
        /// </summary>
        public static void Stop()
        {
            DisposableObject.DisposeAndNull(ref s_Server);
            DisposableObject.DisposeAndNull(ref s_Application);

            if (s_Sipc != null)
            {
                DisposableObject.DisposeAndNull(ref s_Sipc);
            }
        }
Exemplo n.º 8
0
        protected override void Destructor()
        {
            foreach (var hs in m_HostSets)
            {
                hs.Dispose();
            }

            DisposableObject.DisposeAndNull(ref m_InstrumentationEvent);
            base.Destructor();
        }
Exemplo n.º 9
0
        protected override void Destructor()
        {
            DisposableObject.DisposeAndNull(ref m_ManagementEvent);

            foreach (var server in m_Servers)
            {
                server.Dispose();
            }

            base.Destructor();
        }
Exemplo n.º 10
0
        protected override void DoStart()
        {
            if (m_TargetName.IsNullOrWhiteSpace())
            {
                throw new MDBException(StringConsts.MDB_STORE_CONFIG_NO_TARGET_NAME_ERROR);
            }

            if (m_Areas.Count == 0)
            {
                throw new MDBException(StringConsts.MDB_STORE_CONFIG_NO_AREAS_ERROR);
            }


            try
            {
                GDIDAuthorityService.CheckNameValidity(m_SchemaName);
                GDIDAuthorityService.CheckNameValidity(m_BankName);

                var gdidScope = GetGDIDScopePrefix(m_SchemaName, m_BankName);
                m_GDIDGenerator = new GDIDGenerator("GDIDGen({0})".Args(gdidScope), this, gdidScope, null);
                if (AgniSystem.IsMetabase)
                {
                    foreach (var ah in AgniSystem.Metabase.GDIDAuthorities)
                    {
                        m_GDIDGenerator.AuthorityHosts.Register(ah);
                        App.Log.Write(new NFX.Log.Message
                        {
                            Type  = NFX.Log.MessageType.InfoD,
                            Topic = SysConsts.LOG_TOPIC_MDB,
                            From  = GetType().FullName + ".makeGDIDGen()",
                            Text  = "Registered GDID authority host: " + ah.ToString()
                        });
                    }
                }
            }
            catch (Exception error)
            {
                throw new MDBException(StringConsts.MDB_STORE_CONFIG_GDID_ERROR + error.ToMessageWithType());
            }

            try
            {
                m_Cache      = new LocalCache("MDBDataStore::" + Name, this);
                m_Cache.Pile = new DefaultPile(m_Cache, "MDBDataStore::Pile::" + Name);
                m_Cache.Configure(null);
                m_Cache.Start();
            }
            catch
            {
                try { DisposableObject.DisposeAndNull(ref m_GDIDGenerator); } catch {}
                try { DisposableObject.DisposeAndNull(ref m_Cache); } catch {}
                throw;
            }
        }
Exemplo n.º 11
0
        protected override void Destructor()
        {
            base.Destructor();

            DisposableObject.DisposeAndNull(ref m_Reader);
            DisposableObject.DisposeAndNull(ref m_Command);

            if (m_Context.Transaction == null)
            {
                m_Context.Connection.Dispose();
            }
        }
Exemplo n.º 12
0
        protected override void Destructor()
        {
            lock (s_Lock)
            {
                base.Destructor();

                DisposableObject.DisposeAndNull(ref m_GraphHost);
                DisposableObject.DisposeAndNull(ref m_DataStore);

                s_Instance = null;
            }
        }
Exemplo n.º 13
0
        bool IRunnableHook.Epilogue(Runner runner, FID id, Exception error)
        {
            Console.WriteLine("{0}.{1}".Args(GetType().FullName, "RigTearDown()..."));

            DoRigTearDown();

            DisposableObject.DisposeAndNull(ref m_TestApp);
            DisposableObject.DisposeAndNull(ref m_FS);
            Console.WriteLine("{0}.{1}".Args(GetType().FullName, "...RigTearDown() DONE"));

            return(false);
        }
Exemplo n.º 14
0
        public Cursor OpenCursor(Query query)
        {
            Cursor result = null;
            var    cnn    = GetConnection();

            try
            {
                result = DoOpenCursor(cnn, null, query);
            }
            catch
            {
                DisposableObject.DisposeAndNull(ref cnn);
                throw;
            }

            return(result);
        }
Exemplo n.º 15
0
        protected override void Destructor()
        {
            DisposableObject.DisposeAndNull(ref m_ManagementEvent);

            foreach (var server in m_Servers)
            {
                server.Dispose();
            }

            base.Destructor();
            lock (s_InstanceLock)
            {
                if (this == s_Instance)
                {
                    s_Instance = null;
                }
            }
        }
Exemplo n.º 16
0
        protected override void Destructor()
        {
            lock (s_Lock)
            {
                if (s_Instance != null)
                {
                    s_Instance = null;

                    foreach (var portal in m_Portals)
                    {
                        portal.Dispose();
                    }

                    DisposableObject.DisposeAndNull(ref m_ContentFS);

                    base.Destructor();
                }
            }
        }
Exemplo n.º 17
0
        void elm_MouseClick(object sender, EventArgs e)
        {
            if (m_Balloon != null)
            {
                m_Balloon.FadeOut();
                m_Balloon = null;
            }

            var elm = sender as CandleElement;

            if (elm == null)
            {
                return;
            }

            var target = new Point(elm.DisplayRegion.Left + BAR_WIDTH / 2, elm.DisplayRegion.Top - 1);

            target = elm.Host.PointToScreen(target);

            var c = elm.Candle;

            var body = new Rectangle(target.X - 100, target.Y - 128, 200, 100);

            m_Balloon = new Balloon(body, target, Color.FromArgb(200, 255, 255, 50));

            m_Balloon.Deactivate += (s, _) => { DisposableObject.DisposeAndNull(ref m_Balloon); };

            m_Balloon.Text =
                @"{0} {1} sec
 Open: {2}
 Close: {3}
 Hi: {4}
 Low: {5}
 Buy: {6}
 Sell: {7}
".Args(c.TimeStamp, c.TimeSpanMs / 1000, c.OpenPrice, c.ClosePrice, c.LowPrice, c.HighPrice, c.BuyVolume, c.SellVolume);

            m_Balloon.DisposeOnFadeOut = true;
            m_Balloon.FadeIn();
        }
Exemplo n.º 18
0
 protected override void Destructor()
 {
     DisposableObject.DisposeAndNull(ref m_InstrumentationEvent);
     base.Destructor();
 }
Exemplo n.º 19
0
 private void btnSTOP_Click(object sender, EventArgs e)
 {
     DisposableObject.DisposeAndNull(ref m_Server);
 }
Exemplo n.º 20
0
 private void btnUnmount_Click(Object sender, EventArgs e)
 {
     DisposableObject.DisposeAndNull(ref m_Store);
 }
Exemplo n.º 21
0
 public void TearDown()
 {
     DisposableObject.DisposeAndNull(ref m_App);
 }
Exemplo n.º 22
0
 private void closeStream()
 {
     DoCloseStream();
     DisposableObject.DisposeAndNull(ref m_Stream);
 }
Exemplo n.º 23
0
 public void Dispose()
 {
     DisposableObject.DisposeAndNull(ref m_Image);
 }
Exemplo n.º 24
0
 protected override void Destructor()
 {
     base.Destructor();
     DisposableObject.DisposeAndNull(ref m_FS);
 }
Exemplo n.º 25
0
        protected override void DoHandleWork(WorkContext work)
        {
            var fp         = work.MatchedVars[VAR_FILE_PATH].AsString("none");
            var attachment = work.MatchedVars[VAR_ATTACHMENT].AsBool(true);
            var chunked    = work.MatchedVars[VAR_CHUNKED].AsBool(true);

            //Sanitize
            fp = fp.Replace("..", string.Empty)
                 .Replace(":/", string.Empty)
                 .Replace(@"\\", @"\");

            //Cut the surrogate out of path, i.e. '/static/img/@@767868768768/picture.png' -> '/static/img/picture.png'
            fp = CutVersionSegment(fp, m_VersionSegmentPrefix);


            string            fileName  = null;
            IFileSystem       fs        = null;
            FileSystemSession fsSession = null;
            FileSystemFile    fsFile    = null;
            bool exists = false;

            if (m_UsePortalHub)
            {
                var hub = PortalHub.Instance;
                fs       = hub.ContentFileSystem;
                fileName = m_RootPath != null?fs.CombinePaths(hub.ContentFileSystemRootPath, m_RootPath, fp)
                               : fs.CombinePaths(hub.ContentFileSystemRootPath, fp);

                fsSession = fs.StartSession(hub.ContentFileSystemConnectParams);
                fsFile    = fsSession[fileName] as FileSystemFile;
                exists    = fsFile != null;
            }
            else
            {
                fileName = Path.Combine(RootPath, fp);
                exists   = File.Exists(fileName);
            }

            try
            {
                if (!exists)
                {
                    var text = StringConsts.FILE_DL_HANDLER_NOT_FOUND_INFO.Args(fileName);
                    if (m_Throw)
                    {
                        throw new HTTPStatusException(WebConsts.STATUS_404, WebConsts.STATUS_404_DESCRIPTION, text);
                    }

                    work.Response.ContentType = ContentType.TEXT;
                    work.Response.Write(text);
                    work.Response.StatusCode        = WebConsts.STATUS_404;
                    work.Response.StatusDescription = WebConsts.STATUS_404_DESCRIPTION;
                    return;
                }

                if (!work.Response.WasWrittenTo)
                {
                    work.Response.Buffered = !chunked;
                }

                work.Response.SetCacheControlHeaders(CacheControl);

                if (fsFile == null)
                {
                    work.Response.WriteFile(fileName, attachment: attachment);
                }
                else
                {
                    var ext = Path.GetExtension(fsFile.Name);
                    work.Response.ContentType = NFX.Web.ContentType.ExtensionToContentType(ext, NFX.Web.ContentType.BINARY);
                    work.Response.WriteStream(fsFile.FileStream, attachmentName: attachment ? Path.GetFileName(fileName) : null);
                }
            }
            finally
            {
                DisposableObject.DisposeAndNull(ref fsSession);
            }
        }
Exemplo n.º 26
0
        protected override void DoCleanupApplication()
        {
            var FROM = GetType().FullName + ".DoCleanupApplication()";

            if (m_DynamicHostManager != null)
            {
                WriteLog(MessageType.Info, FROM, "Finalizing Dynamic Host Manager");
                try
                {
                    if (m_DynamicHostManager is Daemon)
                    {
                        ((Daemon)m_DynamicHostManager).SignalStop();
                        ((Daemon)m_DynamicHostManager).WaitForCompleteStop();
                        WriteLog(MessageType.Info, FROM, "Dynamic Host Manager STOPPED");
                    }

                    DisposableObject.DisposeAndNull(ref m_DynamicHostManager);
                    WriteLog(MessageType.Info, FROM, "Dynamic Host Manager DISPOSED");
                }
                catch (Exception error)
                {
                    WriteLog(MessageType.Error, FROM, "ERROR finalizing Dynamic Host Manager: " + error.ToMessageWithType());
                }
            }

            if (m_ProcessManager != null)
            {
                WriteLog(MessageType.Info, FROM, "Finalizing Process Manager");
                try
                {
                    if (m_ProcessManager is Daemon)
                    {
                        ((Daemon)m_ProcessManager).SignalStop();
                        ((Daemon)m_ProcessManager).WaitForCompleteStop();
                        WriteLog(MessageType.Info, FROM, "Process Manager STOPPED");
                    }

                    DisposableObject.DisposeAndNull(ref m_ProcessManager);
                    WriteLog(MessageType.Info, FROM, "Process Manager DISPOSED");
                }
                catch (Exception error)
                {
                    WriteLog(MessageType.Error, FROM, "ERROR finalizing Process Manager: " + error.ToMessageWithType());
                }
            }

            if (m_LockManager != null)
            {
                WriteLog(MessageType.Info, FROM, "Finalizing Lock Manager");
                try
                {
                    if (m_LockManager is Daemon)
                    {
                        ((Daemon)m_LockManager).SignalStop();
                        ((Daemon)m_LockManager).WaitForCompleteStop();
                        WriteLog(MessageType.Info, FROM, "Lock Manager STOPPED");
                    }

                    DisposableObject.DisposeAndNull(ref m_LockManager);
                    WriteLog(MessageType.Info, FROM, "lock manager DISPOSED");
                }
                catch (Exception error)
                {
                    WriteLog(MessageType.Error, FROM, "ERROR finalizing Lock Manager: " + error.ToMessageWithType());
                }
            }

            if (m_WebManagerServer != null)
            {
                WriteLog(MessageType.Info, FROM, "Finalizing Web Manager Server");
                try
                {
                    DisposableObject.DisposeAndNull(ref m_WebManagerServer);
                    WriteLog(MessageType.Info, FROM, "Web Manager Server DISPOSED");
                }
                catch (Exception error)
                {
                    WriteLog(MessageType.CatastrophicError, FROM, "ERROR finalizing Web Manager Server: " + error.ToMessageWithType());
                }
            }

            if (m_GDIDProvider != null)
            {
                WriteLog(MessageType.Info, FROM, "Finalizing GDIDProvider");
                try
                {
                    DisposableObject.DisposeAndNull(ref m_GDIDProvider);
                    WriteLog(MessageType.Info, FROM, "GDIDProvider DISPOSED");
                }
                catch (Exception error)
                {
                    WriteLog(MessageType.Error, FROM, "ERROR finalizing GDIDProvider: " + error.ToMessageWithType());
                }
            }
            // Shutdown - must be last
            base.DoCleanupApplication();
        }
Exemplo n.º 27
0
 protected override void Destructor()
 {
     DisposableObject.DisposeAndNull(ref m_ErlBox);
     base.Destructor();
 }
Exemplo n.º 28
0
 bool IRunnableHook.Epilogue(Runner runner, FID id, Exception error)
 {
     DisposableObject.DisposeAndNull(ref m_App);
     return(false);
 }
Exemplo n.º 29
0
 public bool Epilogue(Runner runner, FID id, MethodInfo method, RunAttribute attr, Exception error)
 {
     DisposableObject.DisposeAndNull(ref m_App);
     return(false);
 }
Exemplo n.º 30
0
 [TearDown] public void AfterTest()
 {
     DisposableObject.DisposeAndNull(ref store);
 }