public List <IntershopWebService.ProductPrice> GetItemsPrice(List <IntershopWebService.ProductPriceIn> products, string company, string customerID)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            MessageLogger.info(string.Format("GetItemsPrice(count={0}, custaccount={1}, company={2})", (object)products.Count, (object)customerID, (object)company));
            Axapta ax = this.axLogon(company);
            List <IntershopWebService.ProductPrice> productPriceList = new List <IntershopWebService.ProductPrice>();

            try
            {
                foreach (IntershopWebService.ProductPriceIn product in products)
                {
                    object obj = ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetSalesPrice", (object)customerID, (object)product.itemId, (object)product.unitId);
                    IntershopWebService.ProductPrice productPrice = new IntershopWebService.ProductPrice()
                    {
                        itemId = product.itemId,
                        price  = Math.Round(Convert.ToDouble(obj), 2)
                    };
                    productPrice.miscCharges = this.ExtractMiscCharges(ax, productPrice.itemId, customerID, productPrice.price, (int)product.quantity, product.unitId);
                    stopwatch.Stop();
                    MessageLogger.info(string.Format("GetItemsPrice({0}, {1}, {2}) -> {3} , exec time -> {4} ms", (object)productPrice.itemId, (object)customerID, (object)company, (object)productPrice.price, (object)stopwatch.ElapsedMilliseconds));
                    productPriceList.Add(productPrice);
                }
                return(productPriceList);
            }
            catch (Exception ex)
            {
                return((List <IntershopWebService.ProductPrice>)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
        public List <IntershopWebService.ProductStock> GetItemsStock(List <IntershopWebService.ProductStockIn> products, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            MessageLogger.info(string.Format("GetItemsStock(count={0}, company={1})", (object)products.Count, (object)company));
            Axapta axapta = (Axapta)null;
            List <IntershopWebService.ProductStock> productStockList = new List <IntershopWebService.ProductStock>();

            try
            {
                axapta = this.axLogon(company);
                foreach (IntershopWebService.ProductStockIn product in products)
                {
                    string str = Convert.ToString(axapta.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetOnHandUrl", (object)product.itemId, (object)string.Empty));
                    IntershopWebService.ProductStock productStock = new IntershopWebService.ProductStock();
                    productStock.itemId     = product.itemId;
                    productStock.stockLevel = str;
                    productStockList.Add(productStock);
                    stopwatch.Stop();
                    MessageLogger.info(string.Format("GetItemsStock({0}, {1}, {2}, {3}) -> {4} , exec time -> {5} ms", (object)product.itemId, (object)product.size, (object)product.color, (object)company, (object)productStock.stockLevel, (object)stopwatch.ElapsedMilliseconds));
                }
                return(productStockList);
            }
            catch (Exception ex)
            {
                return((List <IntershopWebService.ProductStock>)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
        public IntershopWebService.ProductPrice GetItemPrice(string itemId, string customerID, string Unit, string company)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Axapta ax = this.axLogon(company);

            IntershopWebService.ProductPrice productPrice = new IntershopWebService.ProductPrice();
            try
            {
                double num = Convert.ToDouble(ax.CallStaticClassMethod("BTX_ISHItemDescriptionProxy", "GetSalesPrice", new object[4]
                {
                    (object)customerID,
                    (object)itemId,
                    (object)Unit,
                    (object)""
                }));
                productPrice.itemId      = itemId;
                productPrice.price       = num;
                productPrice.miscCharges = this.ExtractMiscCharges(ax, productPrice.itemId, customerID, productPrice.price, 1, Unit);
                stopwatch.Stop();
                MessageLogger.info(string.Format("GetItemPrice({0}, {1}, {2}, {3}) -> {4} , exec time -> {5} ms", (object)itemId, (object)customerID, (object)Unit, (object)company, (object)productPrice.price, (object)stopwatch.ElapsedMilliseconds));
                return(productPrice);
            }
            catch (Exception ex)
            {
                return((IntershopWebService.ProductPrice)null);
            }
            finally
            {
                ax.Logoff();
            }
        }
Exemplo n.º 4
0
        public void TestLo2g()
        {
            // Arrange
            var messageLogger = new MessageLogger();

            messageLogger.LogInfo("there", "here and not there");
        }
Exemplo n.º 5
0
        private void Logger_MessageWrited(object sender, MessageLogger e)
        {
            richTextBox.Do(s =>
            {
                switch (e.Severity)
                {
                case MESSAGE_SEVERITY.NORMAL:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.White);
                    break;

                case MESSAGE_SEVERITY.GOOD:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.LimeGreen);
                    break;

                case MESSAGE_SEVERITY.WARN:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.Yellow);
                    break;

                case MESSAGE_SEVERITY.ERROR:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.Red);
                    break;
                }

                if (checkBoxAutoScroll.Checked)
                {
                    s.SelectionStart = s.TextLength;
                    s.ScrollToCaret();
                }
            });
        }
Exemplo n.º 6
0
 public KafkaBroker(MessageKeyProvider messageKeyProvider, ILoggerFactory loggerFactory,
                    MessageLogger messageLogger) : base(loggerFactory)
 {
     _messageKeyProvider = messageKeyProvider;
     _loggerFactory      = loggerFactory;
     _messageLogger      = messageLogger;
 }
Exemplo n.º 7
0
        private static List <string> GetDirectoryListing()
        {
            var files = new List <string>();

            if (printerHost == null)
            {
                return(null);
            }

            try
            {
                FtpWebRequest request = GetFtpRequest(string.Format("ftp://{0}/c/", printerHost));
                request.Method = WebRequestMethods.Ftp.ListDirectory;
                FtpWebResponse response       = (FtpWebResponse)request.GetResponse();
                Stream         responseStream = response.GetResponseStream();
                StreamReader   reader         = new StreamReader(responseStream);

                string fileName;
                while ((fileName = reader.ReadLine()) != null)
                {
                    files.Add(fileName);
                }
                reader.Close();
                response.Close();
            }
            catch (WebException ex)
            {
                MessageLogger.Add(string.Format("Error getting file list via FTP for printer host {0} - see log for details", printerHost), MessageLogger.MsgLevel.error);
                MessageLogger.Add(ex.ToString(), MessageLogger.MsgLevel.additional);
                return(null);
            }
            return(files);
        }
Exemplo n.º 8
0
        /*************************************
         * FTP operations
         * ************************************/

        #region SendToPrinter
        public bool SendToPrinter()
        {
            if (printerHost == null)
            {
                return(false);
            }

            try
            {
                var request = GetFtpRequest(string.Format("ftp://{0}/c/{1}", printerHost, Path.GetFileName(fullPath)));
                request.Method = WebRequestMethods.Ftp.UploadFile;

                // Copy the contents of the file to the request stream.
                StreamReader sourceStream = new StreamReader(fullPath);
                byte[]       fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
                sourceStream.Close();
                request.ContentLength = fileContents.Length;

                Stream requestStream = request.GetRequestStream();
                requestStream.Write(fileContents, 0, fileContents.Length);
                requestStream.Close();

                FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                response.Close();
            }
            catch (Exception ex)
            {
                MessageLogger.Add(string.Format("Error uploading file {1} via FTP to printer host {0} - see log for details", printerHost, fullPath), MessageLogger.MsgLevel.error);
                MessageLogger.Add(ex.ToString(), MessageLogger.MsgLevel.additional);
                return(false);
            }
            return(true);
        }
        public IntershopWebService.TrackInfo GetTrackInfo(string company, string customerID, string salesID)
        {
            MessageLogger.info(string.Format("GetTrackInfo(company={0}, customerID={1}, salesID={2})", (object)company, (object)customerID, (object)salesID));
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            if (string.IsNullOrEmpty(customerID) || string.IsNullOrEmpty(salesID))
            {
                return new IntershopWebService.TrackInfo()
                       {
                           ErrorMsg  = "Please populate both lookup fields.",
                           ErrorCode = IntershopWebService.TrackInfoError.ERROR_NO_PARAM
                       }
            }
            ;
            Axapta axapta = this.axLogon(company);

            try
            {
                IntershopWebService.TrackInfo trackInfo = this.extractTrackInfo(Convert.ToString(axapta.CallStaticClassMethod("BTX_SharedFunctionsProxy", "getTrackAndTraceLinks", (object)customerID, (object)salesID)));

                stopwatch.Stop();
                MessageLogger.info(string.Format("GetTrackInfo() -> {0} ms", (object)stopwatch.ElapsedMilliseconds));
                return(trackInfo);
            }
            catch (Exception ex)
            {
                MessageLogger.info(string.Format("GetTrackInfo() -> error: {0}", (object)ex.Message));
                return((IntershopWebService.TrackInfo)null);
            }
            finally
            {
                axapta.Logoff();
            }
        }
Exemplo n.º 10
0
        public override Message ReadMessage(ArraySegment <byte> buffer, BufferManager bufferManager, string contentType)
        {
            if (bufferManager == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bufferManager");
            }
            if (contentType == this.ContentType)
            {
                contentType = null;
            }
            MtomBufferedMessageData messageData = this.TakeBufferedReader();

            messageData.ContentType = contentType;
            messageData.Open(buffer, bufferManager);
            RecycledMessageState recycledMessageState = messageData.TakeMessageState();

            if (recycledMessageState == null)
            {
                recycledMessageState = new RecycledMessageState();
            }
            Message message = new BufferedMessage(messageData, recycledMessageState)
            {
                Properties = { Encoder = this }
            };

            if (MessageLogger.LogMessagesAtTransportLevel)
            {
                MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive);
            }
            return(message);
        }
Exemplo n.º 11
0
            public override Message ReadMessage(Stream stream, int maxSizeOfHeaders, string contentType)
            {
                if (stream == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("stream"));
                }

                if (WcfEventSource.Instance.TextMessageDecodingStartIsEnabled())
                {
                    WcfEventSource.Instance.TextMessageDecodingStart();
                }

                XmlReader reader  = TakeStreamedReader(stream, GetEncodingFromContentType(contentType, _contentEncodingMap));
                Message   message = Message.CreateMessage(reader, maxSizeOfHeaders, _version);

                message.Properties.Encoder = this;

                if (WcfEventSource.Instance.StreamedMessageReadByEncoderIsEnabled())
                {
                    WcfEventSource.Instance.StreamedMessageReadByEncoder(EventTraceActivityHelper.TryExtractActivity(message, true));
                }

                if (MessageLogger.LogMessagesAtTransportLevel)
                {
                    MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive);
                }
                return(message);
            }
Exemplo n.º 12
0
 public void SendMessage(TestMessageLevel testMessageLevel, string message)
 {
     if (MessageLogger != null)
     {
         MessageLogger.SendMessage(testMessageLevel, message);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Performs a synchronous connect to the message broker with an optional username and password
        /// for the purposes of authentication.
        /// </summary>
        /// <param name="username">Optionally the username to authenticate as.</param>
        /// <param name="password">Optionally the password to authenticate with.</param>
        public ConnectionState Connect(string username = null, string password = null)
        {
            Log.Debug(m => m("Initiating connection to broker '{0}', port '{1}' using Client Identifier '{2}'",
                             server, port, clientIdentifier));

            if (username != null)
            {
                Log.Info(m => m("Authenticating with username '{0}' and password '{0}'", username, password));
                if (username.Trim().Length > Constants.RecommendedMaxUsernamePasswordLength)
                {
                    Log.Warn(m => m("Username length ({0}) exceeds the max recommended in the MQTT spec. ", username.Trim().Length));
                }
                if (password != null && password.Trim().Length > Constants.RecommendedMaxUsernamePasswordLength)
                {
                    Log.Warn(m => m("Password length ({0}) exceeds the max recommended in the MQTT spec. ", password.Trim().Length));
                }
            }

            var connectMessage = GetConnectMessage(username, password);

            connectionHandler = new SynchronousMqttConnectionHandler();

            // TODO: Get Get timeout from config or ctor or elsewhere.
            keepAlive            = new MqttConnectionKeepAlive(connectionHandler, 30);
            publishingManager    = new PublishingManager(connectionHandler);
            subscriptionsManager = new SubscriptionsManager(connectionHandler, publishingManager);
            messageLogger        = new MessageLogger(connectionHandler);

            return(connectionHandler.Connect(this.server, this.port, connectMessage));
        }
Exemplo n.º 14
0
        private Result ProcessCache(CacheMessage message)
        {
            try
            {
                if (message == null)
                {
                    return(ResultBuilder.Warning("Mensagem inválida."));
                }

                MessageLogger.Received(message);

                //var cacher = Cachers.Actual[message.ContentType];

                //if (cacher == null) return ResultBuilder.Warning($"{message.ContentType}: Cacher não encontrado.");

                //cacher.StoreCache(message);

                ResultBuilder.Warning($"{message.ContentType}: Cacher não encontrado.");

                MessageLogger.Consumed(message);

                return(ResultBuilder.Success());
            }
            catch (Exception)
            {
                MessageLogger.Error(message);
                throw;
            }
        }
Exemplo n.º 15
0
 protected static void LogMessage(ref Message message, ArraySegment <byte> messageData)
 {
     using (XmlDictionaryReader xmlDictionaryReader = XmlDictionaryReader.CreateTextReader(messageData.Array, messageData.Offset, messageData.Count, null, XmlDictionaryReaderQuotas.Max, null))
     {
         MessageLogger.LogMessage(ref message, xmlDictionaryReader, MessageLoggingSource.TransportSend);
     }
 }
Exemplo n.º 16
0
            public override Message ReadMessage(ArraySegment <byte> buffer, BufferManager bufferManager, string contentType)
            {
                if (bufferManager == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("bufferManager"));
                }
                UTF8BufferedMessageData messageData = this.TakeBufferedReader();

                messageData.Encoding = TextMessageEncoderFactory.GetEncodingFromContentType(contentType, this.contentEncodingMap);
                messageData.Open(buffer, bufferManager);
                RecycledMessageState recycledMessageState = messageData.TakeMessageState();

                if (recycledMessageState == null)
                {
                    recycledMessageState = new RecycledMessageState();
                }
                Message message = new BufferedMessage(messageData, recycledMessageState)
                {
                    Properties = { Encoder = this }
                };

                if (MessageLogger.LogMessagesAtTransportLevel)
                {
                    MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive);
                }
                return(message);
            }
Exemplo n.º 17
0
        public async Task FlushPendingEvents_sends_all_pending_events_correctly()
        {
            // Arrange
            var messageBus = new MessageLogger();
            var sut        = new AzureEventPublisher(s_eventTable, s_serializer, messageBus);

            var fixture = new Fixture();
            var user    = new FakeUser(Guid.NewGuid(), fixture.Create <string>());

            user.ChangeUsername(fixture.Create <string>());

            string operationId   = fixture.Create <string>();
            var    correlationId = Guid.NewGuid();
            string contributor   = fixture.Create <string>();

            var envelopes = new List <Envelope <IDomainEvent> >(
                from domainEvent in user.FlushPendingEvents()
                let messageId = Guid.NewGuid()
                                select new Envelope <IDomainEvent>(messageId, domainEvent, operationId, correlationId, contributor));

            var batch = new TableBatchOperation();

            foreach (Envelope <IDomainEvent> envelope in envelopes)
            {
                batch.Insert(PendingEvent.Create(typeof(FakeUser), envelope, s_serializer));
            }

            await s_eventTable.ExecuteBatchAsync(batch);

            // Act
            await sut.FlushPendingEvents <FakeUser>(user.Id);

            // Assert
            messageBus.Log.ShouldAllBeEquivalentTo(envelopes);
        }
Exemplo n.º 18
0
        private void WriteMessage(Message message, Stream stream, string startInfo, string boundary, string startUri, bool writeMessageHeaders)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
            }
            if (stream == null)
            {
                throw TraceUtility.ThrowHelperError(new ArgumentNullException("stream"), message);
            }
            base.ThrowIfMismatchedMessageVersion(message);
            message.Properties.Encoder = this;
            if (MessageLogger.LogMessagesAtTransportLevel)
            {
                MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend);
            }
            XmlDictionaryWriter writer = this.TakeStreamedWriter(stream, startInfo, boundary, startUri, writeMessageHeaders);

            if (this.writeEncoding.WebName == "utf-8")
            {
                message.WriteMessage(writer);
            }
            else
            {
                writer.WriteStartDocument();
                message.WriteMessage(writer);
                writer.WriteEndDocument();
            }
            writer.Flush();
            this.ReturnStreamedWriter(writer);
        }
Exemplo n.º 19
0
        private static List <Pack> ReadUnsentPacks()
        {
            var packs = new List <Pack>();

            DBOperations.OpenDBConnection();
            MySqlCommand cmd = DBOperations.myConn.CreateCommand();

            cmd.CommandText = "SELECT * FROM pck.pack WHERE sent_to_SAP IS NULL FOR UPDATE";

            try
            {
                MySqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Pack p = new Pack(rdr);
                    packs.Add(p);
                }
                rdr.Close();
            }
            catch (MySqlException ex)
            {
                MessageLogger.Add("Error reading packs to send to SAP", MessageLogger.MsgLevel.error);
                MessageLogger.Add(ex.ToString(), MessageLogger.MsgLevel.additional);
            }
            return(packs);
        }
        public void modifyBeam()
        {
            var logger  = new MessageLogger();
            var p0      = new Point3(0, 0, 0);
            var p1      = new Point3(1, 1, 0);
            var ln      = new Line3(p0, p1);
            var beam_id = "b1";

            var k3d          = new Toolkit();
            var beamBuilders = k3d.Part.LineToBeam(new List <Line3>()
            {
                ln
            }, new List <string>()
            {
                beam_id
            }, new List <CroSec>(), logger,
                                                   out var out_points);

            var beam = beamBuilders[0];

            {
                var ori = beam.Ori.Writer;
                ori.XOri  = new Vector3(1, 1, 1);
                ori.ZOri  = new Vector3(2, 2, 2);
                ori.Alpha = 0.1;
                beam.Ori  = ori.Reader;
            }
            Assert.AreEqual(beam.Ori.Alpha, 0.1, 1e-8);
        }
Exemplo n.º 21
0
            public override ArraySegment <byte> WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset)
            {
                if (message == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
                }
                if (bufferManager == null)
                {
                    throw TraceUtility.ThrowHelperError(new ArgumentNullException("bufferManager"), message);
                }
                if (maxMessageSize < 0)
                {
                    throw TraceUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxMessageSize", maxMessageSize, System.ServiceModel.SR.GetString("ValueMustBeNonNegative")), message);
                }
                if ((messageOffset < 0) || (messageOffset > maxMessageSize))
                {
                    throw TraceUtility.ThrowHelperError(new ArgumentOutOfRangeException("messageOffset", messageOffset, System.ServiceModel.SR.GetString("ValueMustBeInRange", new object[] { 0, maxMessageSize })), message);
                }
                base.ThrowIfMismatchedMessageVersion(message);
                message.Properties.Encoder = this;
                TextBufferedMessageWriter messageWriter = this.TakeBufferedWriter();
                ArraySegment <byte>       segment       = messageWriter.WriteMessage(message, bufferManager, messageOffset, maxMessageSize);

                this.ReturnMessageWriter(messageWriter);
                if (MessageLogger.LogMessagesAtTransportLevel)
                {
                    XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(segment.Array, segment.Offset, segment.Count, null, XmlDictionaryReaderQuotas.Max, null);
                    MessageLogger.LogMessage(ref message, reader, MessageLoggingSource.TransportSend);
                }
                return(segment);
            }
        public void orientShell()
        {
            var k3d    = new Toolkit();
            var logger = new MessageLogger();
            var p0     = new Point3(0, 0, 0);
            var p1     = new Point3(1, 0, 1);
            var p2     = new Point3(1, 1, 1);
            var mesh   = new Mesh3(new List <Point3>()
            {
                p0, p1, p2
            }, new List <Face3>()
            {
                new Face3(0, 1, 2)
            });

            var shells = k3d.Part.MeshToShell(new List <Mesh3>()
            {
                mesh
            }, null, null, logger, out var outPoints);
            var old_shell = shells[0];
            var new_shell = (BuilderShell)old_shell.Clone();
            var ori       = new_shell.Ori.Writer;

            ori.XOriList = new List <Vector3> {
                new Vector3(1, 1, 1)
            };
            new_shell.Ori = ori.Reader;

            Assert.True(old_shell.Ori.XOriGiven == false);
            Assert.True(new_shell.Ori.XOriGiven == true);
        }
        public void orientBeam()
        {
            var logger  = new MessageLogger();
            var p0      = new Point3(0, 0, 0);
            var p1      = new Point3(1, 1, 0);
            var ln      = new Line3(p0, p1);
            var beam_id = "b1";
            var yOriNew = new Vector3(0, 1, 1);

            var k3d          = new Toolkit();
            var beamBuilders = k3d.Part.LineToBeam(new List <Line3>()
            {
                ln
            }, new List <string>()
            {
                beam_id
            }, new List <CroSec>(), logger,
                                                   out var out_points);

            beamBuilders.Add(k3d.Part.OrientateBeam("b1", null, yOriNew));
            var model = k3d.Model.AssembleModel(beamBuilders, null, null, out var info, out var mass, out var cog, out var msg, out var warning);

            k3d.Model.Disassemble(model, logger, out var points, out var lines, out var meshes, out var beams, out var shells,
                                  out var supports, out var loads, out var materials, out var crosecs, out var joints);

            var yOri = beams[0].Ori.YOri;
            var diff = (yOri.Value - yOriNew).Length;

            Assert.AreEqual(diff, 0, 1E-10);
        }
Exemplo n.º 24
0
        public Worker(IErrorTracker errorTracker,
                      IReceiveMessages receiveMessages,
                      IActivateHandlers activateHandlers,
                      IStoreSubscriptions storeSubscriptions,
                      ISerializeMessages serializeMessages,
                      IStoreSagaData storeSagaData,
                      IInspectHandlerPipeline inspectHandlerPipeline,
                      string workerThreadName,
                      IHandleDeferredMessage handleDeferredMessage,
                      IMutateIncomingMessages mutateIncomingMessages,
                      IStoreTimeouts storeTimeouts,
                      IEnumerable <IUnitOfWorkManager> unitOfWorkManagers,
                      ConfigureAdditionalBehavior configureAdditionalBehavior,
                      MessageLogger messageLogger)
        {
            this.receiveMessages             = receiveMessages;
            this.serializeMessages           = serializeMessages;
            this.mutateIncomingMessages      = mutateIncomingMessages;
            this.unitOfWorkManagers          = unitOfWorkManagers;
            this.configureAdditionalBehavior = configureAdditionalBehavior;
            this.messageLogger               = messageLogger;
            this.errorTracker                = errorTracker;
            dispatcher                       = new Dispatcher(storeSagaData, activateHandlers, storeSubscriptions, inspectHandlerPipeline, handleDeferredMessage, storeTimeouts);
            dispatcher.UncorrelatedMessage  += RaiseUncorrelatedMessage;
            nullMessageReceivedBackoffHelper = CreateBackoffHelper(configureAdditionalBehavior.BackoffBehavior);

            workerThread = new Thread(MainLoop)
            {
                Name = workerThreadName
            };
            workerThread.Start();

            log.Info("Worker {0} created and inner thread started", WorkerThreadName);
        }
Exemplo n.º 25
0
        public override void Use(List <HexCell> cells)
        {
            try
            {
                ItadakiNoKura passiveAbility = ParentCharacter.Abilities.OfType <ItadakiNoKura>().SingleOrDefault();
                if (passiveAbility == null)
                {
                    throw new Exception("Pasywna umiejętność nie znaleziona!");
                }

                List <Character> enemyCharactersOnMap = Game.Players.Where(p => p != Active.GamePlayer).SelectMany(p => p.Characters).Where(c => c.IsOnMap).ToList();
                var damageValue = passiveAbility.CollectedEnergy / enemyCharactersOnMap.Count;
                //Animations.Instance.SonzaiNoChikara(enemyCharactersOnMap.Select(c=>c.CharacterObject.transform).ToList());
                var damage = new Damage(damageValue, DamageType.Magical);
                enemyCharactersOnMap.ForEach(c => ParentCharacter.Attack(c, damage));

                passiveAbility.CollectedEnergyCharacters.Clear();
                OnUseFinish();
            }
            catch (Exception e)
            {
                MessageLogger.DebugLog(e.Message);
                OnFailedUseFinish();
            }
        }
Exemplo n.º 26
0
            public override void WriteMessage(Message message, Stream stream)
            {
                if (message == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("message"));
                }
                if (stream == null)
                {
                    throw TraceUtility.ThrowHelperError(new ArgumentNullException("stream"), message);
                }
                base.ThrowIfMismatchedMessageVersion(message);
                message.Properties.Encoder = this;
                XmlDictionaryWriter writer = this.TakeStreamedWriter(stream);

                if (this.optimizeWriteForUTF8)
                {
                    message.WriteMessage(writer);
                }
                else
                {
                    writer.WriteStartDocument();
                    message.WriteMessage(writer);
                    writer.WriteEndDocument();
                }
                writer.Flush();
                this.ReturnStreamedWriter(writer);
                if (MessageLogger.LogMessagesAtTransportLevel)
                {
                    MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend);
                }
            }
Exemplo n.º 27
0
        public void ReinforcedPlate()
        {
            var k3d    = new Toolkit();
            var logger = new MessageLogger();

            double length = 1.0;
            var    mesh   = new Mesh3();

            mesh.AddVertex(new Point3(0, length, 0));
            mesh.AddVertex(new Point3(0, 0, 0));
            mesh.AddVertex(new Point3(length, 0, 0));
            mesh.AddVertex(new Point3(length, length, 0));
            mesh.AddFace(new Face3(0, 1, 3));
            mesh.AddFace(new Face3(1, 2, 3));

            var crosec = k3d.CroSec.ReinforcedConcreteStandardShellConst(25, 0, null, new List <double> {
                4, 4, -4, -4
            }, 0);
            var shells = k3d.Part.MeshToShell(new List <Mesh3> {
                mesh
            }, null, new List <CroSec> {
                crosec
            }, logger, out var nodes);

            // create supports
            var supportConditions = new List <bool>()
            {
                true, true, true, true, true, true
            };
            var supports = new List <Support>
            {
                k3d.Support.Support(0, supportConditions),
                k3d.Support.Support(1, supportConditions),
            };

            // create a Point-load
            var loads = new List <Load>
            {
                k3d.Load.PointLoad(2, new Vector3(), new Vector3(0, 25, 0)),
                k3d.Load.PointLoad(3, new Vector3(), new Vector3(0, 25, 0))
            };

            // create the model
            var model = k3d.Model.AssembleModel(shells, supports, loads,
                                                out var info, out var mass, out var cog, out var message, out var warning);

            model = k3d.Algorithms.OptiReinf(model, out var maxDisplacements, out var compliances, out message, out var reinfMass);

            k3d.Results.ShellForcesLocal(model, null, "0",
                                         out var nxx, out var nyy, out var nxy,
                                         out var mxx, out var myy, out var mxy,
                                         out var vx, out var vy);
            Assert.AreEqual(mxx[0][0][0], 50.082245640312429, 1E-5);
            Assert.AreEqual(mxx[0][0][1], 49.91775435968767, 1E-5);

            var crosec_shell = model.elems[0].crosec as CroSec_Shell;
            var reinf_thick  = crosec_shell.elem_crosecs[0].layers[1].height;

            Assert.AreEqual(reinf_thick, 0.00046824411288599481, 1E-5);
        }
Exemplo n.º 28
0
        private void ConfigureAgentConnect(IServiceCollection services)
        {
            var messageLogger = new MessageLogger
            {
                MessageLogFilters = new List <MessageLogFilter>
                {
                    new MessageLogFilter
                    {
                        RegexMatch       = ConstructRegex(_iocConfig.RegexStringList),
                        RegexReplacement = "<aw:filteredText>...</aw:filteredText>"
                    }
                }
            };

            services.AddSingleton <IAgentConnectConfig>(cfg => {
                return(new AgentConnectConfig
                {
                    AgentConnectUrl = ConfigurationManager.AppSettings["AgentConnectUrl"],
                    ApiVersion = ConfigurationManager.AppSettings["ApiVersion"],
                    ChannelType = ConfigurationManager.AppSettings["ChannelType"],
                    ClientSoftwareVersion = ConfigurationManager.AppSettings["ClientSoftwareVersion"],
                    PoeType = ConfigurationManager.AppSettings["PoeType"],
                    TargetAudience = ConfigurationManager.AppSettings["TargetAudience"],
                    EndpoingBehaviors = new List <IEndpointBehavior> {
                        messageLogger
                    }
                });
            });

            services.AddSingleton <IAgentConnectProxyFactory, AgentConnectProxyFactory>();
            Services.AddSingleton <MoneyGram.AgentConnect.ITrainingModeRepository,
                                   MoneyGram.AgentConnect.TrainingModeRepository>();
        }
Exemplo n.º 29
0
        public static Pack ReadSingle(ulong serial)
        {
            DBOperations.BeginTransaction();
            MySqlCommand cmd = DBOperations.myConn.CreateCommand();

            cmd.CommandText = "SELECT * FROM pck.pack WHERE serial=@serial";
            cmd.Parameters.AddWithValue("serial", serial);
            Pack p = null;

            try
            {
                MySqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    p = new Pack(rdr);
                }
                rdr.Close();
            }
            catch (MySqlException ex)
            {
                MessageLogger.Add(string.Format("Error reading single pack {0}", serial), MessageLogger.MsgLevel.error);
                MessageLogger.Add(ex.ToString(), MessageLogger.MsgLevel.additional);
            }
            DBOperations.CommitTransaction();
            return(p);
        }
Exemplo n.º 30
0
        public void InclinedBeam()
        {
            var logger  = new MessageLogger();
            var p0      = new Point3(0, 0, 0);
            var p1      = new Point3(1, 1, 0);
            var XDir    = (p1 - p0).Unitized;
            var ln      = new Line3(p0, p1);
            var beam_id = "b1";

            var k3d   = new Toolkit();
            var beams = k3d.Part.LineToBeam(new List <Line3>()
            {
                ln
            }, new List <string>()
            {
                beam_id
            }, new List <CroSec>(), logger,
                                            out var out_points);

            var points = beams[0].Pos.Points();

            Assert.That((p0 - points[0]).Length < 1E-9);
            Assert.That((p1 - points[1]).Length < 1E-9);

            var coosys = beams[0].Ori.CooSys(beams[0].Pos);
            var n0     = coosys[0];
            var n1     = coosys[1];

            Assert.That((n0 - XDir).Length < 1E-9);
        }
Exemplo n.º 31
0
    /// <summary>
    /// Logs a message that won't be caught by the LumosLogs service.
    /// </summary>
    /// <param name="logger">The function to send the message to.</param>
    /// <param name="message">The message to log.</param>
    static void LogMessage(MessageLogger logger, object message)
    {
        if (instance == null || !debug) {
            return;
        }

        logger("[Lumos] " + message);
    }
Exemplo n.º 32
0
        public frmMain()
        {
            InitializeComponent();

            mMessageLogger = new MessageLogger();
            mChatManager = new ChatManager();
            mUserManager = new UserManager(mMessageLogger);
            mQuestionManager = new QuestionManager(mUserManager);
            mAnswerManager = new AnswerManager();
            mIOProcessor = new IOProcessor(mMessageLogger, mUserManager,
                mQuestionManager, mAnswerManager, mChatManager);

            //mIOProcessor = new IOProcessor(mMessageLogger, mUserManager);
            mNetwork = new Network(mMessageLogger, mUserManager, mQuestionManager, mAnswerManager, mIOProcessor);

            // Load the registered tutors
            if (!mUserManager.LoadTutors("tutors.xml"))
            {
                mMessageLogger.NewMessage("Can't load file \"tutors.xml\" or the contents in it. " +
                    "Please use the admin tool to recreate it", mMessageLogger.MESSAGE_ERROR);
            }

            mUser = new User();

            mRunning = true;

            mDictionarySerialiser = new DictionarySerialiserMethods();

            // Attempt to load questions from the questions.xml file
            if (LoadQuestions("questions.xml") == false)
            {
                // Add some demo questions if none could be loaded from a file
                question iDemoQuestion = new question();

                // Multi-choice
                iDemoQuestion.QuestionID = 0;
                iDemoQuestion.Question = "How many days in a week?";
                iDemoQuestion.QuestionType = "MC";
                iDemoQuestion.PossibleAnswers = new string[4] { "Ten", "Three", "Seven", "Nine" };
                iDemoQuestion.Answer = "Seven";
                mQuestionManager.AddNewQuestion(iDemoQuestion);

                // True/False
                iDemoQuestion = new question();
                iDemoQuestion.QuestionID = 1;
                iDemoQuestion.Question = "Fire burns?";
                iDemoQuestion.QuestionType = "TF";
                iDemoQuestion.PossibleAnswers = new string[4] { "True", "False", "", "" };
                iDemoQuestion.Answer = "True";
                mQuestionManager.AddNewQuestion(iDemoQuestion);

                // Short Answer
                iDemoQuestion = new question();
                iDemoQuestion.QuestionID = 2;
                iDemoQuestion.Question = "What is 5x5?";
                iDemoQuestion.QuestionType = "SA";
                iDemoQuestion.PossibleAnswers = new string[4] { "", "", "", "" };
                iDemoQuestion.Answer = "";
                mQuestionManager.AddNewQuestion(iDemoQuestion);
            }
            mTimer = new System.Timers.Timer(1000);
            mTimer.Elapsed += new ElapsedEventHandler(TimeElapsed);
            mTimer.Enabled = true;
        }
Exemplo n.º 33
0
        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Save Data
            mDictionarySerialiser.SaveQuestionsToDisk("questions.xml", mQuestionManager.QuestionList);

            mRunning = false;
            mTimer.Stop();
            mNetwork.StopServer();
            mNetwork = null;
            mMessageLogger = null;
            mTimer = null;
        }
Exemplo n.º 34
0
        public UserManager(MessageLogger prMessageLogger)
        {
            mUsersOnline = new Dictionary<int, userDetails>();
            mMessageLogger = prMessageLogger;

            mXmlHandler = new XmlHandler();
        }