Esempio n. 1
0
            }             // func TruncateAsync

            #endregion

            #region -- Commit/Transmission State --------------------------------------

            public async Task CommitFileAsync(long recordCount, long unitCount)
            {
                if (readOnly)
                {
                    throw new InvalidOperationException();
                }

                // validate file size
                if (RecordCount != recordCount)
                {
                    throw new OdetteFileServiceException(OdetteAnswerReason.InvalidRecordCount, String.Format("Invalid record count (local: {0}, endpoint: {1}).", RecordCount, recordCount));
                }
                if (TotalLength != unitCount)
                {
                    throw new OdetteFileServiceException(OdetteAnswerReason.InvalidByteCount, String.Format("Invalid record count (local: {0}, endpoint: {1}).", TotalLength, unitCount));
                }

                // close the stream
                Procs.FreeAndNil(ref stream);

                // rename file to show that it is received
                await ChangeInFileStateAsync(fileItem.FileInfo, OdetteInFileState.Received);

                // notify that the file is received
                await fileItem.NotifyFileReceivedAsync();
            }             // proc CommitFileAsync
Esempio n. 2
0
            }             // proc Dispose

            protected virtual void Dispose(bool disposing)
            {
                if (disposing)
                {
                    Procs.FreeAndNil(ref stream);
                }
            }             // prop Dispsoe
Esempio n. 3
0
        }         // ctor

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Procs.FreeAndNil(ref currentListener);
            }

            base.Dispose(disposing);
        }         // proc Dispose
Esempio n. 4
0
        }         // ctor

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Procs.FreeAndNil(ref logFile);
                ConfigLogItemCount--;
            }
            base.Dispose(disposing);
        }         // proc Disposing
Esempio n. 5
0
        }         // proc ProcessReceiveLine

        private void ProcessExited(object state, bool timeout)
        {
            if (!NativeMethods.GetExitCodeProcess(exitWaitHandle.SafeWaitHandle, out var exitCode))
            {
                exitCode = UInt32.MaxValue;
            }

            try
            {
                Log.LogMsg(LogMsgType.Information, "Process closed (ExitCode={0})", unchecked ((int)exitCode));

                if (this["ProcessStopped"] != null)
                {
                    CallMemberDirect("ProcessStopped", new object[] { (Process)state }, throwExceptions: false);
                }

                HttpRefreshProperties();
            }
            finally
            {
                Procs.FreeAndNil(ref exitWaitHandle);
                waitHandle = null;

                try
                {
                    if (hUser != IntPtr.Zero)
                    {
                        Debug.Print("UnloadProfile={0}", NativeMethods.UnloadUserProfile(hUser, hProfile));
                        Debug.Print("CloseUserHandle={0}", NativeMethods.CloseHandle(hUser));
                    }

                    if (arOutputStream != null)
                    {
                        procProcessLogLine.EndInvoke(arOutputStream);
                    }
                    if (arErrorStream != null)
                    {
                        procProcessLogLine.EndInvoke(arErrorStream);
                    }

                    arOutputStream = null;
                    arErrorStream  = null;

                    Procs.FreeAndNil(ref inputStream);
                    Procs.FreeAndNil(ref outputStream);
                    Procs.FreeAndNil(ref errorStream);
                }
                finally
                {
                    waitForExitEvent.Set();
                    Procs.FreeAndNil(ref waitForExitEvent);

                    process = null;
                }
            }
        }         // proc ProcessExited
Esempio n. 6
0
        }         // ctor

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Procs.FreeAndNil(ref propertyNextRun);
                Procs.FreeAndNil(ref propertyLastTime);
                Procs.FreeAndNil(ref propertyIsRunning);
            }
            base.Dispose(disposing);
        }         // proc Dispose
Esempio n. 7
0
        }         // proc Dispose

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Liste wieder austragen
                configItem.UnregisterList(this);

                // Sperren zerstören
                Procs.FreeAndNil(ref listLock);
            }
        }         // proc Dispose
Esempio n. 8
0
            }             // proc Dispose

            #endregion

            #region -- Compile --------------------------------------------------------------

            protected virtual void Compile(Func <TextReader> open, KeyValuePair <string, Type>[] args)
            {
                lock (chunkLock)
                {
                    // clear the current chunk
                    Procs.FreeAndNil(ref chunk);

                    // recompile the script
                    using (var tr = open())
                        chunk = Lua.CompileChunk(tr, scriptId, compiledWithDebugger ? engine.debugOptions : null, args);
                }
            }             // proc Compile
Esempio n. 9
0
        }         // ctor

        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    Procs.FreeAndNil(ref propertyScriptCount);

                    this.GetService <IServiceContainer>(false)?.RemoveService(typeof(IDELuaEngine));
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }         // proc Dispose
Esempio n. 10
0
            }             // proc Dispose

            protected virtual void Dispose(bool disposing)
            {
                if (disposing)
                {
                    foreach (var g in engine.GetAttachedGlobals(scriptId))
                    {
                        g.ResetScript();
                    }

                    // Remove the script from the engine
                    engine.RemoveScript(this);
                    log.Info("Entfernt.");

                    Procs.FreeAndNil(ref chunk);
                }
            }             // proc Dispose
Esempio n. 11
0
        }         // proc Dispose

        protected virtual void Dispose(bool disposing)
        {
            stoppingEvent?.Set();
            if (disposing)
            {
                // stop the thread
                if (!thread.Join(3000))
                {
                    thread.Abort();
                }
                thread = null;

                // clear objects
                Procs.FreeAndNil(ref stoppingEvent);

                // Remove properties
                Procs.FreeAndNil(ref propertyRestarts);
                Procs.FreeAndNil(ref propertyRunning);
            }
        }         // proc Dispose
Esempio n. 12
0
        }         // ctor

        protected void StartThread(string name, ThreadPriority priority = ThreadPriority.Normal, bool isBackground = false, ApartmentState apartmentState = ApartmentState.MTA)
        {
            // create the thread
            thread = new Thread(Execute);
            thread.SetApartmentState(apartmentState);
            thread.IsBackground = isBackground;
            thread.Priority     = priority;
            thread.Name         = name;

            // start the thread
            startedEvent  = new ManualResetEventSlim(false);
            stoppingEvent = new ManualResetEventSlim(false);
            thread.Start();
            if (!startedEvent.Wait(3000))
            {
                throw new Exception(String.Format("Could not start thread '{0}'.", name));
            }

            Procs.FreeAndNil(ref startedEvent);
        }         // proc StartThread
Esempio n. 13
0
            }             // proc SetTransmissionErrorAsync

            public async Task SetTransmissionStateAsync()
            {
                if (!readOnly)
                {
                    throw new InvalidOperationException();
                }

                // close the stream
                Procs.FreeAndNil(ref stream);

                // clear answer state to successful
                var xSend = EnforceSendElement();

                xSend.SetAttributeValue("reasonCode", 0);
                xSend.SetAttributeValue("reasonText", String.Empty);

                await fileItem.SaveExtensionsAsync();

                // chanhe state
                await ChangeOutFileStateAsync(fileItem.FileInfo, OdetteOutFileState.WaitEndToEnd);
            }             // proc ChangeOutFileStateAsync
Esempio n. 14
0
        }         // proc OnBeginReadConfiguration

        protected override void OnEndReadConfiguration(IDEConfigLoading config)
        {
            base.OnEndReadConfiguration(config);

            var listenerAddress = Config.GetAttribute("address", "0.0.0.0");
            var listenerPort    = Config.GetAttribute("port", serverCertificate == null ? 3305 : 6619);

            skipInvalidCertificate    = Config.GetAttribute("skipInvalidCertificate", false);
            clientCertificateRequired = Config.GetAttribute("clientCertificateRequired", true);
            sslProtocols = (SslProtocols)Config.GetAttribute("sslProtocols", (int)defaultSslProtocols);

            Log.Info("Register Listener (port={0}, addr={1}, ssl={2})", listenerPort, listenerAddress, serverCertificate == null ? "<plain>" : serverCertificate.Subject);
            var endPoint = new IPEndPoint(IPAddress.Parse(listenerAddress), listenerPort);

            // start the listener
            Procs.FreeAndNil(ref currentListener);
            currentListener = serverTcp.RegisterListener(endPoint,
                                                         serverCertificate != null ?
                                                         new Action <Stream>(CreateSslHandler) :
                                                         new Action <Stream>(CreateHandler)
                                                         );
        }         // proc OnEndReadConfiguration
Esempio n. 15
0
        } // ctor

        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    CancelJobs();

                    CronIdleActive = false;
                    Server.Queue.CancelCommand(procCancelJobs);
                    Server.Queue.CancelCommand(procRefreshCronServices);

                    this.GetService <IServiceContainer>(false)?.RemoveService(typeof(IDECronEngine));

                    Procs.FreeAndNil(ref currentJobs);
                    Procs.FreeAndNil(ref cronItemCacheController);
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }         // proc Dispose
Esempio n. 16
0
            }             // func EnforceSendElement

            public async Task SetTransmissionErrorAsync(OdetteAnswerReason answerReason, string reasonText, bool retryFlag)
            {
                if (!readOnly)
                {
                    throw new InvalidOperationException();
                }

                // close the stream
                Procs.FreeAndNil(ref stream);

                // write answer
                var xSend = EnforceSendElement();

                xSend.SetAttributeValue("reasonCode", (int)answerReason);
                xSend.SetAttributeValue("reasonText", reasonText);

                await fileItem.SaveExtensionsAsync();

                // no retry, mark as finished
                if (!retryFlag)
                {
                    await ChangeOutFileStateAsync(fileItem.FileInfo, OdetteOutFileState.Finished);
                }
            }             // proc SetTransmissionErrorAsync
Esempio n. 17
0
        }         // ctor

        public void Dispose()
        {
            Procs.FreeAndNil(ref streamOutput);
            Procs.FreeAndNil(ref textOutput);
        }         // proc Dispose
Esempio n. 18
0
 public void Dispose()
 {
     Procs.FreeAndNil(ref hStdInput);
     Procs.FreeAndNil(ref hStdOutput);
     Procs.FreeAndNil(ref hStdError);
 }
Esempio n. 19
0
        }         // ctor

        public void Dispose()
        {
            Procs.FreeAndNil(ref enumBase);
            Procs.FreeAndNil(ref lockScope);
        }         // proc Dispose
Esempio n. 20
0
        }         // proc OnBeginReadConfiguration

        public override bool Request(IDEContext r)
        {
            if (assembly == null || namespaceRoot == null)
            {
                return(false);
            }

            // create the resource name
            var resourceName = namespaceRoot + r.RelativeSubPath.Replace('/', '.');

            var src = (Stream)null;

            try
            {
                DateTime stamp;
                // try to open the resource stream
                var forceAlternativeCheck = nonePresentAlternativeExtensions != null && nonePresentAlternativeExtensions.FirstOrDefault(c => resourceName.EndsWith(c, StringComparison.OrdinalIgnoreCase)) != null;
                src = assembly.GetManifestResourceStream(resourceName);
                if (src == null && !forceAlternativeCheck)                 // nothing...
                {
                    return(false);
                }

                // check if there is a newer file
                if (alternativeRoots != null)
                {
                    var relativeFileName = ProcsDE.GetLocalPath(r.RelativeSubPath);
                    var alternativeFile  = (from c in alternativeRoots
                                            let fi = new FileInfo(Path.Combine(c, relativeFileName))
                                                     where fi.Exists && (forceAlternativeCheck || fi.LastWriteTimeUtc > assemblyStamp)
                                                     orderby fi.LastWriteTimeUtc descending
                                                     select fi).FirstOrDefault();

                    if (alternativeFile != null)
                    {
                        src?.Close();
                        src   = alternativeFile.OpenRead();
                        stamp = alternativeFile.LastWriteTimeUtc;
                    }
                    else
                    {
                        stamp = assemblyStamp;
                        if (forceAlternativeCheck && src == null)
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    stamp = assemblyStamp;
                    if (forceAlternativeCheck && src == null)
                    {
                        return(false);
                    }
                }

                // security
                DemandFile(r, resourceName);
                // send the file
                r.SetLastModified(stamp)
                .WriteStream(src, GetFileContentType(resourceName) ?? r.Server.GetContentType(Path.GetExtension(resourceName)));
                return(true);
            }
            finally
            {
                Procs.FreeAndNil(ref src);
            }
        }         // func Request