Пример #1
0
        public void LogEvents()
        {
            // Assemble and register your BaseBatch
            var batch = new BaseBatch();

            batch.Environment    = Batch.EnvironmentEnum.Development;
            batch.UserIdentities = new BatchUserIdentities()
            {
                CustomerId = "1234",
                Email      = "*****@*****.**"
            };
            MParticle.Instance.BaseBatch = batch;

            // Create your events
            var customAttributes = new Dictionary <string, string>();

            customAttributes["foo"] = "bar";
            var customEvent = new CustomEvent("foo event", CustomEvent.CustomEventTypeEnum.Location);

            var screenEvent = new ScreenViewEvent("foo screen");

            // Log events
            MParticle.Instance.LogEvent(customEvent);
            MParticle.Instance.LogEvent(screenEvent);

            //(optional) Force an immediate upload (before the UploadInterval is finished, this will restart the UploadInterval)
            MParticle.Instance.Upload();
        }
Пример #2
0
        public void BaseBatch_ToFile(string fileName, string fileExtention, string path, bool timeStampToken, bool sessionIdInFileName)
        {
            //Arrange

            var localBatch = new BaseBatch();

            localBatch.BatchContext = new ContextInvoker()
            {
                SessionId = Guid.NewGuid()
            };
            var ExpectedFileName = createFullFileName(fileName, fileExtention, path, timeStampToken, sessionIdInFileName, localBatch.BatchContext);

            //Act
            string fullFileName = "";
            var    ex           = Record.Exception(() => fullFileName = localBatch.ToFile("Text to write Text to write Text to write Text to write Text to write ",
                                                                                          fileName,
                                                                                          fileExtention,
                                                                                          path,
                                                                                          timeStampToken,
                                                                                          sessionIdInFileName));

            //Assert
            Assert.Null(ex);
            Assert.Equal(ExpectedFileName, fullFileName);
        }
Пример #3
0
        public void BaseBatch_ToFileContentAndFileName()
        {
            //Arrange
            var localBatch = new BaseBatch();

            localBatch.BatchContext = new ContextInvoker()
            {
                SessionId = Guid.NewGuid()
            };


            //Act
            string fullFileName = "";
            var    ex           = Record.Exception(() => fullFileName = localBatch.ToFile("Text to write Text to write Text to write Text to write Text to write ", "test.txt"));

            //Assert
            Assert.Null(ex);
            Assert.Equal("test.txt", fullFileName);
        }
Пример #4
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Interface File From ADM to IPPCS is started");
                string functionId = "InterfaceFromADM";

                // Start Calling Batch Proces
                Assembly  assembly = typeof(Program).Assembly; // in the same assembly!
                Type      type     = assembly.GetType("InterfaceFromADM.AppCode." + functionId);
                BaseBatch batch    = (BaseBatch)Activator.CreateInstance(type);
                batch.ExecuteBatch();
                // End Calling Batch Process

                Console.WriteLine("Interface File From ADM to IPPCS is ended");
                Thread.Sleep(1000);
            }
            catch (Exception AE)
            {
                Console.WriteLine(AE.Message);
                Console.WriteLine("Interface File From ADM to IPPCS is ended");
                Thread.Sleep(3000);
            }
        }
Пример #5
0
 public override void AddToBatch(BaseBatch batch, uint tint, Affine2f tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh)
 {
     throw new System.NotImplementedException();
 }
Пример #6
0
 public override void AddToBatch(BaseBatch batch, uint tint, Affine2f tx, float x, float y, float width, float height)
 {
     throw new System.NotImplementedException();
 }
Пример #7
0
        public void BaseBatch_ToTrackingStringContent()
        {
            //Arrange
            var serializedContent = "";

            var modelSerializer = new Mock <IModelSerializer>(MockBehavior.Strict);

            modelSerializer.Setup((s) => s.Serialize(It.IsAny <object>())).Returns(serializedContent);

            var trackingProvider = new Mock <ISharpBatchTracking>(MockBehavior.Strict);

            trackingProvider.Setup((s) => s.AddMessageAsync(It.IsAny <Guid>(), It.IsAny <string>())).Returns(Task.CompletedTask).Verifiable();

            var trackingFactory = new Mock <ISharpBatchTrackingFactory>(MockBehavior.Strict);

            trackingFactory.Setup((s) => s.getTrakingProvider()).Returns(trackingProvider.Object).Verifiable();

            var requestService = new Mock <IServiceProvider>(MockBehavior.Strict);

            requestService.Setup((s) => s.GetService(It.Is <Type>(t => t.Name.Equals(nameof(ISharpBatchTrackingFactory)))))
            .Returns(trackingFactory.Object)
            .Verifiable();
            requestService.Setup((s) => s.GetService(It.Is <Type>(t => t.Name.Equals(nameof(IModelSerializer)))))
            .Returns(modelSerializer.Object)
            .Verifiable();

            Stream bodyStream   = new MemoryStream();
            var    httpResponse = new Mock <HttpResponse>(MockBehavior.Strict);

            httpResponse.Setup((s) => s.Body).Returns(bodyStream).Verifiable();

            var httpRequest = new Mock <HttpRequest>(MockBehavior.Strict);

            httpRequest.Setup((s) => s.QueryString)
            .Returns(new QueryString("?param=123"));

            var localBatch = new BaseBatch();

            var context = new Mock <HttpContext>(MockBehavior.Strict);

            context.Setup((s) => s.RequestServices).Returns(requestService.Object).Verifiable();
            context.Setup((s) => s.Request).Returns(httpRequest.Object).Verifiable();
            context.Setup((s) => s.Response).Returns(httpResponse.Object).Verifiable();


            localBatch.BatchContext           = ContextInvoker.Create(context.Object);
            localBatch.BatchContext.SessionId = Guid.NewGuid();

            var dataTotrack = new TestData()
            {
                Name    = "name",
                Surname = "surname"
            };

            //Act
            var ex = Record.Exception(() =>
            {
                localBatch.ToTracking(dataTotrack);
                requestService.Verify();
            });

            //Assert
            Assert.Null(ex);
        }
Пример #8
0
        public override void Draw(DrawContext dc)
        {
            BaseBatch baseBatch = (BarSubtexture == null) ? ((BaseBatch)dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None)) : ((BaseBatch)dc.PrimitivesRenderer2D.TexturedBatch(BarSubtexture.Texture, useAlphaTest: false, 0, DepthStencilState.None, null, null, TextureLinearFilter ? SamplerState.LinearClamp : SamplerState.PointClamp));
            int       num       = 0;
            int       start     = 0;

            if (baseBatch is TexturedBatch2D)
            {
                num = ((TexturedBatch2D)baseBatch).TriangleVertices.Count;
            }
            else
            {
                start = ((FlatBatch2D)baseBatch).LineVertices.Count;
                num   = ((FlatBatch2D)baseBatch).TriangleVertices.Count;
            }
            Vector2 zero = Vector2.Zero;

            if (m_layoutDirection == LayoutDirection.Horizontal)
            {
                zero.X += Spacing / 2f;
            }
            else
            {
                zero.Y += Spacing / 2f;
            }
            int num2 = HalfBars ? 1 : 2;

            for (int i = 0; i < 2 * BarsCount; i += num2)
            {
                bool  flag = i % 2 == 0;
                float num3 = 0.5f * (float)i;
                float num4 = 0f;
                num4 = ((!FlipDirection) ? MathUtils.Clamp((Value - num3 / (float)BarsCount) * (float)BarsCount, 0f, 1f) : MathUtils.Clamp((Value - ((float)BarsCount - num3 - 1f) / (float)BarsCount) * (float)BarsCount, 0f, 1f));
                if (!BarBlending)
                {
                    num4 = MathUtils.Ceiling(num4);
                }
                float s = (m_flashCount > 0f) ? (1f - MathUtils.Abs(MathUtils.Sin(m_flashCount * (float)Math.PI))) : 1f;
                Color c = LitBarColor;
                if (LitBarColor2 != Color.Transparent && BarsCount > 1)
                {
                    c = Color.Lerp(LitBarColor, LitBarColor2, num3 / (float)(BarsCount - 1));
                }
                Color color = Color.Lerp(UnlitBarColor, c, num4) * s * base.GlobalColorTransform;
                if (HalfBars)
                {
                    if (flag)
                    {
                        Vector2 zero2 = Vector2.Zero;
                        Vector2 v     = (m_layoutDirection == LayoutDirection.Horizontal) ? new Vector2(0.5f, 1f) : new Vector2(1f, 0.5f);
                        if (baseBatch is TexturedBatch2D)
                        {
                            Vector2 topLeft  = BarSubtexture.TopLeft;
                            Vector2 texCoord = new Vector2(MathUtils.Lerp(BarSubtexture.TopLeft.X, BarSubtexture.BottomRight.X, v.X), MathUtils.Lerp(BarSubtexture.TopLeft.Y, BarSubtexture.BottomRight.Y, v.Y));
                            ((TexturedBatch2D)baseBatch).QueueQuad(zero + zero2 * BarSize, zero + v * BarSize, 0f, topLeft, texCoord, color);
                        }
                        else
                        {
                            ((FlatBatch2D)baseBatch).QueueQuad(zero + zero2 * BarSize, zero + v * BarSize, 0f, color);
                        }
                    }
                    else
                    {
                        Vector2 v2  = (m_layoutDirection == LayoutDirection.Horizontal) ? new Vector2(0.5f, 0f) : new Vector2(0f, 0.5f);
                        Vector2 one = Vector2.One;
                        if (baseBatch is TexturedBatch2D)
                        {
                            Vector2 texCoord2   = new Vector2(MathUtils.Lerp(BarSubtexture.TopLeft.X, BarSubtexture.BottomRight.X, v2.X), MathUtils.Lerp(BarSubtexture.TopLeft.Y, BarSubtexture.BottomRight.Y, v2.Y));
                            Vector2 bottomRight = BarSubtexture.BottomRight;
                            ((TexturedBatch2D)baseBatch).QueueQuad(zero + v2 * BarSize, zero + one * BarSize, 0f, texCoord2, bottomRight, color);
                        }
                        else
                        {
                            ((FlatBatch2D)baseBatch).QueueQuad(zero + v2 * BarSize, zero + one * BarSize, 0f, color);
                        }
                    }
                }
                else
                {
                    Vector2 zero3 = Vector2.Zero;
                    Vector2 one2  = Vector2.One;
                    if (baseBatch is TexturedBatch2D)
                    {
                        Vector2 topLeft2     = BarSubtexture.TopLeft;
                        Vector2 bottomRight2 = BarSubtexture.BottomRight;
                        ((TexturedBatch2D)baseBatch).QueueQuad(zero + zero3 * BarSize, zero + one2 * BarSize, 0f, topLeft2, bottomRight2, color);
                    }
                    else
                    {
                        ((FlatBatch2D)baseBatch).QueueQuad(zero + zero3 * BarSize, zero + one2 * BarSize, 0f, color);
                        ((FlatBatch2D)baseBatch).QueueRectangle(zero + zero3 * BarSize, zero + one2 * BarSize, 0f, Color.MultiplyColorOnly(color, 0.75f));
                    }
                }
                if (!flag || !HalfBars)
                {
                    if (m_layoutDirection == LayoutDirection.Horizontal)
                    {
                        zero.X += BarSize.X + Spacing;
                    }
                    else
                    {
                        zero.Y += BarSize.Y + Spacing;
                    }
                }
            }
            if (baseBatch is TexturedBatch2D)
            {
                ((TexturedBatch2D)baseBatch).TransformTriangles(base.GlobalTransform, num);
            }
            else
            {
                ((FlatBatch2D)baseBatch).TransformLines(base.GlobalTransform, start);
                ((FlatBatch2D)baseBatch).TransformTriangles(base.GlobalTransform, num);
            }
            m_flashCount = MathUtils.Max(m_flashCount - 4f * Time.FrameDuration, 0f);
        }