Exemplo n.º 1
0
        public ViewEntity PostView([FromBody] ViewEntity entity, int id)
        {
            //favoriteCharacters.Insert(id, entity.ToModel());
            favoriteCharacters.Add(entity.ToModel());

            return(entity);
        }
Exemplo n.º 2
0
 public SPOViewPipeBind()
 {
     _viewEntity = null;
     _view = null;
     _id = Guid.Empty;
     _name = string.Empty;
 }
        public ViewEntity PostView([FromBody] ViewEntity view, int id)
        {
            // add this view entity into the student model at {id}


            return(view);
        }
Exemplo n.º 4
0
        void SetSprite(ViewEntity viewEntity, Sprite sprite)
        {
            SpriteVisual spriteVisual = viewEntity.spriteVisual.value;

            spriteVisual.sprite = sprite;
            viewEntity.ReplaceSpriteVisual(spriteVisual);
        }
Exemplo n.º 5
0
 public SPOViewPipeBind()
 {
     _viewEntity = null;
     _view       = null;
     _id         = Guid.Empty;
     _name       = string.Empty;
 }
Exemplo n.º 6
0
 public bool AddView(ViewEntity addView)
 {
     using (var context = new ContentContext())
     {
         context.ViewEntity.Add(addView);
         return(context.SaveChanges() > 0);
     }
 }
Exemplo n.º 7
0
 public bool UpdateView(ViewEntity updateView)
 {
     using (var context = new ContentContext())
     {
         context.ViewEntity.Attach(updateView);
         context.Entry(updateView).State = EntityState.Modified;
         return(context.SaveChanges() > 0);
     }
 }
Exemplo n.º 8
0
        public ViewEntity GetView(string connStr, string databaseName, string schemaName, string viewName)
        {
            ViewEntity result = new ViewEntity();

            result.DatabaseName = databaseName;
            result.ViewName     = viewName;
            result.Columns      = GetViewColumns(connStr, databaseName, schemaName, viewName);
            return(result);
        }
Exemplo n.º 9
0
 public StructureModel(ViewEntity viewEntity)
 {
     Type = "v";
     Name = viewEntity.ViewName;
     if (string.IsNullOrEmpty(viewEntity.Comment) == false)
     {
         Comment = viewEntity.Comment;
     }
     Items = new List <StructureItemModel>();
 }
Exemplo n.º 10
0
        public void IndexTest()
        {
            mockDbContext        = CreateMock();
            textEditorControlelr = new TextEditorController(mockDbContext);

            var mockControllerContext = new Mock <ControllerContext>();

            SetMockController();
            TestAndDebug();

            IDbContext CreateMock()
            {
                var list = new List <IEntity>()
                {
                    new TextFilesList {
                        FileId = 1, FileName = "testFileList", UserId = 1, Update = DateTime.Parse("2018/05/01 12:34:56")
                    },
                    new TextFilesList {
                        FileId = 2, FileName = "testFileList", UserId = 1, Update = DateTime.Parse("2018/05/01 12:37:56")
                    },
                    new TextFilesList {
                        FileId = 4, FileName = "testFileList", UserId = 2, Update = DateTime.Parse("2019/06/01 12:34:56")
                    }
                };

                var mock = new MockCreator(list);

                return(mock.GetMockContext().Object);
            }

            void TestAndDebug()
            {
                string Before1
                    = ViewEntity.WriteEntityData(
                          mockDbContext.TextFilesList.ToList()
                          );

                Debug.WriteLine($"Before List :\r {Before1}");

                ViewResult result = textEditorControlelr.Index() as ViewResult;

                string After1
                    = ViewEntity.WriteEntityData(
                          (IEnumerable <IEntity>)result.Model
                          );

                Debug.WriteLine($"After View :\r {After1}");
            }

            void SetMockController()
            {
                textEditorControlelr.ControllerContext = mockControllerContext.Object;
                textEditorControlelr.ModelState.AddModelError("SessionName", "Required");
            }
        }
Exemplo n.º 11
0
        public void Initialize()
        {
            GameObject poolParentObject = new GameObject(name);

            this.viewPoolEntity = this.viewContext.CreateEntity();
            this.viewPoolEntity.AddViewPool(
                this.assetBundleManager.LoadAsset(this.assetDefinition).Wait(),
                new List <GameObject>(),
                new List <GameObject>(),
                poolParentObject.transform);
        }
        public void CrateFileTest()
        {
            mockDbContext           = CreateMock();
            mvcHtmlStringController = new MvcHtmlStringController(mockDbContext);

            var mockControllerContext = new Mock <ControllerContext>();
            var mockSession           = new Mock <HttpSessionStateBase>();
            var mockContoroller       = new Mock <TextEditorController>();

            SetMockSession();

            DebugAndGetViewResult("TestName");

            IDbContext CreateMock()
            {
                var mock = new MockCreator();

                mock.SetMockTextFilesList();
                mock.SetMockEidtText();
                return(mock.GetMockContext().Object);
            }

            MvcHtmlString DebugAndGetViewResult(string fileName)
            {
                string Before1
                    = ViewEntity.WriteEntityData(mockDbContext.TextFilesList.ToList());

                string Before2
                    = ViewEntity.WriteEntityData(mockDbContext.EditText.ToList());

                Debug.WriteLine($"Check Data Before :\r {Before1} \r {Before2}");

                var result = mvcHtmlStringController.CrateFile(fileName);

                string After1
                    = ViewEntity.WriteEntityData(mockDbContext.TextFilesList.ToList());

                string After2
                    = ViewEntity.WriteEntityData(mockDbContext.EditText.ToList());

                Debug.WriteLine($"Check Data After : \r {After1} \r {After2}");

                Debug.WriteLine($"\r=======\r {result.ToHtmlString()}");

                return(result);
            }

            void SetMockSession()
            {
                mockControllerContext.Setup(x => x.HttpContext.Session["FileId"]).Returns("1");
                mockControllerContext.Setup(x => x.HttpContext.Session["MaxFileId"]).Returns("");
                mockControllerContext.Setup(x => x.HttpContext.Session["UserId"]).Returns("2");
            }
        }
Exemplo n.º 13
0
 public void CreateViews(int count)
 {
     for (int i = 0; i != count; i++)
     {
         var user     = this.Autors[randomizer.GetRandomNumber(0, this.Autors.Count - 1)];
         var content  = this.Manga[randomizer.GetRandomNumber(0, this.Manga.Count - 1)];
         var platform = this.Platforms[randomizer.GetRandomNumber(0, this.Autors.Count - 1)];
         var view     = ViewEntity.CreateRandomView(this.randomizer, user, content, platform);
         this.Views.Add(view);
     }
 }
Exemplo n.º 14
0
        public void TestMethod1()
        {
            using (var testContext = new TextEditorContext())
            {
                var list = testContext.ServiceUser;


                Debug.WriteLine(
                    ViewEntity.WriteEntityData(
                        list.ToList()
                        )
                    );
            }
        }
Exemplo n.º 15
0
        public void CreateMap(ViewEntity entity, IRenderState renderState, int index, Dictionary <Enums.EntityType, Matrix4x4[]> transforms, Dictionary <Enums.EntityType, int> instanceCounts, Dictionary <Enums.EntityType, ITexture2D> textures, Dictionary <Enums.EntityType, ITexture2D> normalMaps, Dictionary <Enums.EntityType, ITexture2D> heightMaps, Dictionary <Enums.EntityType, Vector4> intensityMap, List <Enums.EntityType> disableBackFaceCulling, List <LightSource> lightSources, ITransformation camera, float time)
        {
            _entity = entity;
            _camera = camera;

            Vector3 position = new Vector3(entity.Transform.M41, entity.Transform.M42,
                                           entity.Transform.M43);

            transforms[entity.Type][index] = transforms[entity.Type][transforms[entity.Type].Length - 1];
            instanceCounts[entity.Type]--;

            _deferred.UpdateTransforms(transforms);

            for (int i = 0; i < 6; i++)
            {
                _positions[i].Location = position;
                _deferred.Draw(renderState, _cameras[i], instanceCounts, textures, normalMaps, heightMaps, intensityMap, disableBackFaceCulling, time);
                _shadowMapping.Draw(renderState, _cameras[i], instanceCounts, _deferred.Depth, lightSources[0].Direction, disableBackFaceCulling, _deferred.Position, _deferred.Normal);
                _lighting.Draw(_cameras[i], _deferred.Color, _deferred.Normal, _deferred.Position, _shadowMapping.Output, _deferred.IntensityMap, lightSources);
                _lighting.Draw(_cameras[i], _deferred.Color, _deferred.Normal, _deferred.Position, _shadowMapping.Output, _deferred.IntensityMap, lightSources);
                _skybox.Draw(_cameras[i], 2);
                _add.Draw(_skybox.Output, _lighting.Output);

                _mapSurfaces[i].Activate();
                TextureDrawer.Draw(_add.Output);
                _mapSurfaces[i].Deactivate();
            }

            transforms[entity.Type][index] = entity.Transform;
            instanceCounts[entity.Type]++;

            for (int i = 0; i < 6; i++)
            {
                _bloom[i].Draw(_mapSurfaces[i].Texture);
            }

            _cubeFbo.Activate();
            for (int i = 0; i < 6; i++)
            {
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.TextureCubeMapPositiveX + i, _cubeFbo.Texture.ID, 0);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                TextureDrawer.Draw(_bloom[i].Output);
            }
            _cubeFbo.Deactivate();

            _cubeFbo.Texture.Activate();
            GL.GenerateMipmap(GenerateMipmapTarget.TextureCubeMap);
            _cubeFbo.Texture.Deactivate();
        }
Exemplo n.º 16
0
        private void EmitSurface(GuiModelSurface surface, Matrix modelMatrix, Matrix modelViewMatrix, bool depthHack)
        {
            if (surface.VertexCount == 0)
            {
                // nothing in the surface
                return;
            }

            // copy verts and indexes
            Surface tri = new Surface();

            tri.Indexes  = new int[surface.IndexCount];
            tri.Vertices = new Vertex[surface.VertexCount];

            _indexes.CopyTo(surface.FirstIndex, tri.Indexes, 0, surface.IndexCount);

            // we might be able to avoid copying these and just let them reference the list vars
            // but some things, like deforms and recursive
            // guis, need to access the verts in cpu space, not just through the vertex range
            _vertices.CopyTo(surface.FirstVertex, tri.Vertices, 0, surface.VertexCount);

            // move the verts to the vertex cache
            tri.AmbientCache = idE.RenderSystem.AllocateVertexCacheFrameTemporary(tri.Vertices);

            // if we are out of vertex cache, don't create the surface
            if (tri.AmbientCache == null)
            {
                return;
            }

            RenderEntityComponent renderEntity = new RenderEntityComponent();

            renderEntity.MaterialParameters[0] = surface.Color.X;
            renderEntity.MaterialParameters[1] = surface.Color.Y;
            renderEntity.MaterialParameters[2] = surface.Color.Z;
            renderEntity.MaterialParameters[3] = surface.Color.W;

            ViewEntity guiSpace = new ViewEntity();

            guiSpace.ModelMatrix     = modelMatrix;
            guiSpace.ModelViewMatrix = modelViewMatrix;
            guiSpace.WeaponDepthHack = depthHack;

            // add the surface, which might recursively create another gui
            idE.RenderSystem.AddDrawSurface(tri, guiSpace, renderEntity, surface.Material, idE.RenderSystem.ViewDefinition.Scissor);
        }
Exemplo n.º 17
0
        public void Execute()
        {
            foreach (var snake in this.snakes.GetEntities())
            {
                bool alreadyHadVisual     = snake.hasSnakeVisual;
                List <ViewEntity> visuals = alreadyHadVisual ? snake.snakeVisual.linkedVisuals : new List <ViewEntity>();
                Definitions.SnakeVisualDefinition snakeVisualDefinition = alreadyHadVisual ?
                                                                          snake.snakeVisual.snakeVisualDefinition :
                                                                          this.assetBundleManager.LoadAsset(new AssetDefinition <Definitions.SnakeVisualDefinition>("definitions", "Main Player Snake")).Wait();

                for (int i = 0; i < snake.snakePosition.positions.Count; i++)
                {
                    if (visuals.Count <= i)
                    {
                        ViewEntity newVisual = this.viewContext.CreateEntity();
                        newVisual.AddCreateView(typeof(SpriteRenderer));
                        Components.SpriteVisual spriteVisual = new Components.SpriteVisual()
                        {
                            sprite       = this.assetBundleManager.LoadAsset(new AssetDefinition <Sprite>("art", "Snake_Tile0")).Wait(),
                            sortingLayer = "Default",
                            sortingOrder = 5
                        };
                        newVisual.AddSpriteVisual(spriteVisual);
                        newVisual.AddPosition(snake.snakePosition.positions[i]);
                        visuals.Add(newVisual);
                    }
                }

                if (!alreadyHadVisual)
                {
                    snake.AddSnakeVisual(snakeVisualDefinition, visuals);
                }
                else
                {
                    snake.ReplaceSnakeVisual(snakeVisualDefinition, visuals);
                }
            }
        }
Exemplo n.º 18
0
        public override IList <ViewEntity> GetViews(DataBaseEntity database)
        {
            IList <ViewEntity> list = null;

            using (MySqlConnection connection = new MySqlConnection(database.DbConnectionStringBuilder.ConnectionString))
            {
                connection.Open();
                DataTable views = connection.GetSchema(SqlClientMetaDataCollectionNames.Views, new string[] { null, null, null, null });
                if (views != null && views.Rows.Count > 0)
                {
                    list = new List <ViewEntity>();
                    foreach (DataRow table in views.Rows)
                    {
                        string     name = string.Format("{0}", table["TABLE_NAME"]);
                        string     des  = string.Format("{0}.{1}", table["TABLE_SCHEMA"], table["TABLE_NAME"]);
                        ViewEntity view = new ViewEntity(database.DbConnectionStringBuilder, name, des);
                        view.DataBase = database;
                        list.Add(view);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 19
0
        public ViewEntity PostView([FromBody] ViewEntity entity, int id)
        {
            // add this view entity to the student model at "id"

            return(entity);
        }
Exemplo n.º 20
0
        public void MapEntity()
        {
            Func <object> userNameFunction    = delegate() { return(Environment.UserName); };
            Func <object> nowFunction         = delegate() { return(DateTime.Now); };
            Func <object> dbNowFunction       = delegate() { return(DB.CallFunction <DateTime>(CommonDefinitions.Connection, CommonDefinitions.Schema, DBFunction.FGET_DATE)); };
            Func <object> dbTimestampFunction = delegate() { DateTime dbNow = DB.CallFunction <DateTime>(CommonDefinitions.Connection, CommonDefinitions.Schema, DBFunction.FGET_DATE); if (CommonDefinitions.Connection == MyConnection.OracleTest)
                                                             {
                                                                 return(dbNow);
                                                             }
                                                             else
                                                             {
                                                                 return(BitConverter.GetBytes(dbNow.Ticks));
                                                             } };

            Func <object> newTestIdFunction = delegate() { return(DB.CallFunction <int>(CommonDefinitions.Connection, CommonDefinitions.Schema, DBFunction.FTEST_ID_NEXTVAL)); };

            TableEntity <Test>
            .Table(Table.TEST2, CommonDefinitions.Schema, CommonDefinitions.Connection, CommonDefinitions.PrimaryKeyValueProvider, CommonDefinitions.TimestampValueProvider)
            .PrimaryKeys
            .Add(TEST.TEST_ID, x => x.Inner.TestId, Sequence.S_TEST, CommonDefinitions.Schema, DBFunction.FTEST_ID_NEXTVAL, null)
            .Timestamp(TEST.LOCK_TIMESTAMP, x => x.Inner.InnerInner.Timestamp, null, null, dbTimestampFunction)
            .AutoSetColumns
            .Add(Before.Insert, TEST.INS_DATE, CommonDefinitions.Schema, DBFunction.FGET_DATE, null, AutoSetValueProvider.DBFunction)
            .Add(Before.Insert, TEST.INS_OS_USER, null, null, userNameFunction, AutoSetValueProvider.AppFunctionDelegate)
            .Add(Before.Update, TEST.UPD_DATE, CommonDefinitions.Schema, DBFunction.FGET_DATE, null, AutoSetValueProvider.DBFunction)
            .Add(Before.Update, TEST.UPD_OS_USER, null, null, userNameFunction, AutoSetValueProvider.AppFunctionDelegate)
            .Add(Before.LogicalDelete, TEST.DEL_DATE, CommonDefinitions.Schema, DBFunction.FGET_DATE, null, AutoSetValueProvider.DBFunction)
            .Add(Before.LogicalDelete, TEST.DEL_OS_USER, null, null, userNameFunction, AutoSetValueProvider.AppFunctionDelegate)
            .TriggerActions
            .AddForBeforeSelectCommand(authorizationTrigger)
            .Add(When.AfterSelectForEachRow, logTrigger)
            .Add(When.BeforeInsertForEachRow, authorizationTrigger)
            .Add(When.AfterInsertForEachRow, logTrigger)
            .Add(When.BeforeUpdateForEachRow, authorizationTrigger)
            .Add(When.AfterUpdateForEachRow, logTrigger)
            .Add(When.BeforeDeleteForEachRow, authorizationTrigger)
            .Add(When.AfterDeleteForEachRow, logTrigger)
            .TableColumns
            .Add(x => x.Name, TEST.NAME)
            .Add(x => x.Text, TEST.TEXT)
            .Add(x => x.Price, TEST.PRICE)
            .Add(x => x.Quantity, TEST.QUANTITY)
            .Add(x => x.OrderDate, TEST.ORDER_DATE, true)
            .Add(x => x.ItemType, TEST.ITEM_TYPE)
            .Add(x => x.Inner.InnerInner.InnerDescription, TEST.DESCRIPTION)
            .Add(x => x.Inner.InnerInner.DeleteDate, TEST.DEL_DATE)                             //bu tanımlanmasa da olur tanımlanmışsa logical delete'de doldurulur
            .Add(x => x.Inner.InnerInner.InsertOSUserName, TEST.INS_OS_USER)                    //bu tanımlanmasa da olur tanımlanmışsa insert'de doldurulur
            .Add(x => x.Inner.InnerInner.UpdateOSUserName, TEST.UPD_OS_USER)                    //bu tanımlanmasa da olur tanımlanmışsa update'de doldurulur
            .Add(x => x.Inner.InnerInner.DeleteOSUserName, TEST.DEL_OS_USER)                    //bu tanımlanmasa da olur tanımlanmışsa delete'de doldurulur
            .ViewColumns
            .Add(x => x.Inner.InnerDescription1, TEST.DESCRIPTION1)
            .Add(x => x.Inner.InnerDescription2, TEST.DESCRIPTION2)
            .Add(x => x.WhatIsThis, TEST.WHAT_IS_THIS)
            .Queries
            .Add(Query.SelectAll,
                 @"SELECT 1 AS WHAT, T.QUANTITY, -99 AS WHAT_IS_THIS, T.DESCRIPTION, 
							T.DESCRIPTION AS DESCRIPTION1, T.DESCRIPTION AS DESCRIPTION2, 
							T.TEST_ID, T.TEXT, T.PRICE, T.LOCK_TIMESTAMP, T.ORDER_DATE, T.ITEM_TYPE 
							FROM TEST2 T 
							WHERE TEST_ID <= 200"                            )
            .Add(Query.SelectByTestId,
                 @"SELECT T.UPD_OS_USER, T.QUANTITY, -99 AS WHAT_IS_THIS, T.DESCRIPTION, 
							T.DESCRIPTION AS DESCRIPTION1, T.DESCRIPTION AS DESCRIPTION2, 
							T.TEST_ID, T.TEXT, T.PRICE, T.LOCK_TIMESTAMP, T.ORDER_DATE, T.ITEM_TYPE 
							FROM TEST2 T 
							WHERE TEST_ID = :testId"                            , true,
                 new InputParameterNameType("testId", typeof(int))
                 )
            .Add(Query.SelectByTestIdForFoo,
                 @"SELECT T.QUANTITY, -99 AS WHAT_IS_THIS, T.DESCRIPTION, 
							T.TEST_ID, T.TEXT, T.PRICE, T.LOCK_TIMESTAMP
							FROM TEST2 T 
							WHERE TEST_ID = :testId"                            , true,
                 new InputParameterNameType("testId", typeof(int))
                 )
            .Add(Query.SelectByTestIdAndQuantity,
                 @"SELECT * 
							FROM TEST2 
							WHERE TEST_ID = :testId 
							AND QUANTITY = :quantity"                            ,
                 new InputParameterNameType("testId", typeof(int)),
                 new InputParameterNameType("quantity", typeof(int))
                 )
            .Add(Query.SelectWithPaging,
                 @"WITH r AS 
							(
							SELECT
							ROW_NUMBER() OVER (ORDER BY t1.name desc) AS row_number, t2.TEST_ID,t2.INS_DATE,t2.NAME,t2.TEXT 
							FROM test2 t1, test2 t2
							where t1.TEST_ID = t2.TEST_ID and t1.INS_DATE = t2.INS_DATE and t1.LOCK_TIMESTAMP = t2.LOCK_TIMESTAMP
							)
							SELECT * FROM r
							where row_number between :pageSize*(:pageNumber-1) + 1 and :pageSize*:pageNumber
							ORDER BY name desc"                            ,
                 new InputParameterNameType("pageSize", typeof(int)),
                 new InputParameterNameType("pageNumber", typeof(int))
                 );

            ViewEntity <TestReport>
            .Connection(CommonDefinitions.Connection)
            .TriggerActions
            .AddForBeforeSelectCommand(authorizationTrigger)
            .Add(When.AfterSelectForEachRow, logTrigger)
            .ViewColumns
            .Add(x => x.A, TEST_REPORT.A)
            .Add(x => x.B, TEST_REPORT.B)
            .Queries
            .Add(Query.SelectReport,
                 @"SELECT :a AS A, GETDATE() AS B 
							FROM DUAL 
							WHERE :a = :aaa 
							AND 1 in (:list)"                            , true,
                 new InputParameterNameType("a", typeof(string)),
                 new InputParameterNameType("aaa", typeof(string)),
                 new InputParameterNameType("list", typeof(string))
                 );
        }
Exemplo n.º 21
0
		/// <summary>
		/// The triangle functions can check backEnd.currentSpace != surf->space
		/// to see if they need to perform any new matrix setup.  The modelview
		/// matrix will already have been loaded, and backEnd.currentSpace will
		/// be updated after the triangle function completes.
		/// </summary>
		/// <param name="surfaces"></param>
		/// <param name="handler"></param>
		private void RenderDrawSurfaceListWithFunction(DrawSurface[] surfaces, RenderHandler handler)
		{
			int count = surfaces.Length;

			for(int i = 0; i < count; i++)
			{
				DrawSurface surface = surfaces[i];

				// change the matrix if needed
				if(surface.Space != _currentSpace)
				{
					_effect.View = surface.Space.ModelViewMatrix;
				}

				if(surface.Space.WeaponDepthHack == true)
				{
					idConsole.Warning("TODO: RB_EnterWeaponDepthHack();");
				}

				if(surface.Space.ModelDepthHack != 0.0f)
				{
					idConsole.Warning("TODO: RB_EnterModelDepthHack( drawSurf->space->modelDepthHack );");
				}

				// change the scissor if needed
				if((idE.CvarSystem.GetBool("r_useScissor") == true) && (_currentScissor != surface.ScissorRectangle))
				{
					_currentScissor = surface.ScissorRectangle;

					_graphicsDevice.ScissorRectangle = new Rectangle(
						_viewDef.ViewPort.X1 + _currentScissor.X1,
						_viewDef.ViewPort.Y1 + _currentScissor.Y1,
						_currentScissor.X2 + 1 - _currentScissor.X1,
						_currentScissor.Y2 + 1 - _currentScissor.Y1);
				}

				// render it
				handler(surface);

				if((surface.Space.WeaponDepthHack == true) || (surface.Space.ModelDepthHack != 0.0f))
				{
					idConsole.Warning("TODO: RB_LeaveDepthHack();");
				}

				_currentSpace = surface.Space;
			}
		}
Exemplo n.º 22
0
		private void RenderMaterialPasses(DrawSurface surface)
		{
			Surface tri = surface.Geometry;
			idMaterial material = surface.Material;
			int count;

			if(material.HasAmbient == false)
			{
				// disabled because we don't do lighting right now
				//TODO: return;
			}

			if(material.IsPortalSky == true)
			{
				return;
			}

			// change the matrix if needed
			if(surface.Space != _currentSpace)
			{
				_effect.View = surface.Space.ModelViewMatrix;
				_currentSpace = surface.Space;
				//idConsole.Warning("TODO: RB_SetProgramEnvironmentSpace();");
			}

			// change the scissor if needed
			if((idE.CvarSystem.GetBool("r_useScissor") == true) && (_currentScissor != surface.ScissorRectangle))
			{
				_currentScissor = surface.ScissorRectangle;

				_graphicsDevice.ScissorRectangle = new Rectangle(
					_viewDef.ViewPort.X1 + _currentScissor.X1,
					_viewDef.ViewPort.Y1 + _currentScissor.Y1,
					_currentScissor.X2 + 1 - _currentScissor.X1,
					_currentScissor.Y2 + 1 - _currentScissor.Y1);
			}

			// some deforms may disable themselves by setting numIndexes = 0
			if(tri.Indexes.Length == 0)
			{
				return;
			}

			if(tri.AmbientCache == null)
			{
				idConsole.WriteLine("RenderShaderPasses: !tri.AmbientCache");
				return;
			}

			// get the expressions for conditionals / color / texcoords
			float[] registers = surface.MaterialRegisters;

			// set face culling appropriately
			SetCull(material.CullType);

			// set polygon offset if necessary
			if(material.TestMaterialFlag(MaterialFlags.PolygonOffset) == true)
			{
				idConsole.Warning("TODO: polygon offset fill");
				//Gl.glEnable(Gl.GL_POLYGON_OFFSET_FILL);
				//Gl.glPolygonOffset(idE.CvarSystem.GetFloat("r_offsetFactor"), idE.CvarSystem.GetFloat("r_offsetUnits") * material.PolygonOffset);
			}

			if(surface.Space.WeaponDepthHack == true)
			{
				idConsole.Warning("TODO: RB_EnterWeaponDepthHack();");
			}

			if(surface.Space.ModelDepthHack != 0.0f)
			{
				idConsole.Warning("TODO: RB_EnterModelDepthHack( surf->space->modelDepthHack );");
			}

			foreach(MaterialStage stage in material.Stages)
			{
				// check the enable condition
				if(registers[stage.ConditionRegister] == 0)
				{
					continue;
				}

				// skip the stages involved in lighting
				if(stage.Lighting != StageLighting.Ambient)
				{
					// disabled because we don't do lighting right now
					// TODO: continue;
				}

				// skip if the stage is ( GL_ZERO, GL_ONE ), which is used for some alpha masks
				if((stage.DrawStateBits & (MaterialStates.SourceBlendBits | MaterialStates.DestinationBlendBits))
					== (MaterialStates.SourceBlendZero | MaterialStates.DestinationBlendOne))
				{
					continue;
				}

				// see if we are a new-style stage
				NewMaterialStage newStage = stage.NewStage;

				if(newStage.IsEmpty == false)
				{
					throw new Exception("THIS MIGHT NOT WORK!!!");
					//--------------------------
					//
					// new style stages
					//
					//--------------------------

					if(idE.CvarSystem.GetBool("r_skipNewAmbient") == true)
					{
						continue;
					}

					idConsole.Warning("TODO: render");
					/*Gl.glColorPointer(4, Gl.GL_UNSIGNED_BYTE, Marshal.SizeOf(typeof(Vertex)), (void*) &ambientCacheData->color);
					Gl.glVertexAttribPointerARB(9, 3, Gl.GL_FLOAT, false, Marshal.SizeOf(typeof(Vertex)), ambientCacheData->tangents[0].ToFloatPtr());
					Gl.glVertexAttribPointerARB(10, 3, Gl.GL_FLOAT, false, Marshal.SizeOf(typeof(Vertex)), ambientCacheData->tangents[1].ToFloatPtr());
					Gl.glNormalPointer(Gl.GL_FLOAT, Marshal.SizeOf(typeof(Vertex)), ambientCacheData->normal.ToFloatPtr());*/

					//Gl.glEnableClientState(Gl.GL_COLOR_ARRAY);
					//Gl.glEnableVertexAttribArray(9);
					//Gl.glEnableVertexAttribArray(10);
					//Gl.glEnableClientState(Gl.GL_NORMAL_ARRAY);

					SetState(stage.DrawStateBits);

					idConsole.Warning("TODO: glBindProgramARB");
					/*Gl.glBindProgramARB(Gl.GL_VERTEX_PROGRAM_ARB, newStage.VertexProgram);
					Gl.glEnable(Gl.GL_VERTEX_PROGRAM_ARB);*/

					// megaTextures bind a lot of images and set a lot of parameters
					// TODO: megatextures
					/*if ( newStage->megaTexture ) {
						newStage->megaTexture->SetMappingForSurface( tri );
						idVec3	localViewer;
						R_GlobalPointToLocal( surf->space->modelMatrix, backEnd.viewDef->renderView.vieworg, localViewer );
						newStage->megaTexture->BindForViewOrigin( localViewer );
					}*/

					count = newStage.VertexParameters.Length;

					for(int i = 0; i < count; i++)
					{
						float[] parm = new float[4];
						parm[0] = registers[newStage.VertexParameters[i, 0]];
						parm[1] = registers[newStage.VertexParameters[i, 1]];
						parm[2] = registers[newStage.VertexParameters[i, 2]];
						parm[3] = registers[newStage.VertexParameters[i, 3]];

						//Gl.glProgramLocalParameter4fvARB(Gl.GL_VERTEX_PROGRAM_ARB, i, parm);
					}

					count = newStage.FragmentProgramImages.Length;

					for(int i = 0; i < count; i++)
					{
						if(newStage.FragmentProgramImages[i] != null)
						{
							SetTextureUnit(i);
							newStage.FragmentProgramImages[i].Bind();
						}
					}

					//Gl.glBindProgramARB(Gl.GL_FRAGMENT_PROGRAM_ARB, newStage.FragmentProgram);
					//Gl.glEnable(Gl.GL_FRAGMENT_PROGRAM_ARB);

					// draw it
					DrawElementsWithCounters(tri);

					count = newStage.FragmentProgramImages.Length;

					for(int i = 1; i < count; i++)
					{
						if(newStage.FragmentProgramImages[i] != null)
						{
							SetTextureUnit(i);
							idE.ImageManager.BindNullTexture();
						}
					}

					// TODO: megatexture
					/*if ( newStage->megaTexture ) {
						newStage->megaTexture->Unbind();
					}*/

					SetTextureUnit(0);

					//Gl.glDisable(Gl.GL_VERTEX_PROGRAM_ARB);
					//Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB);
					// Fixme: Hack to get around an apparent bug in ATI drivers.  Should remove as soon as it gets fixed.
					//Gl.glBindProgramARB(Gl.GL_VERTEX_PROGRAM_ARB, 0);

					//Gl.glDisableClientState(Gl.GL_COLOR_ARRAY);
					//Gl.glDisableVertexAttribArrayARB(9);
					//Gl.glDisableVertexAttribArrayARB(10);
					//Gl.glDisableClientState(Gl.GL_NORMAL_ARRAY);

					continue;
				}
				else
				{
					//--------------------------
					//
					// old style stages
					//
					//--------------------------

					// set the color
					float[] color = new float[4];
					color[0] = registers[stage.Color.Registers[0]];
					color[1] = registers[stage.Color.Registers[1]];
					color[2] = registers[stage.Color.Registers[2]];
					color[3] = registers[stage.Color.Registers[3]];

					// skip the entire stage if an add would be black
					if(((stage.DrawStateBits & (MaterialStates.SourceBlendBits & MaterialStates.DestinationBlendBits)) == (MaterialStates.SourceBlendOne | MaterialStates.DestinationBlendOne))
						&& (color[0] <= 0) && (color[1] <= 0) && (color[2] <= 0))
					{
						continue;
					}

					// skip the entire stage if a blend would be completely transparent
					if(((stage.DrawStateBits & (MaterialStates.SourceBlendBits & MaterialStates.DestinationBlendBits)) == (MaterialStates.SourceBlendSourceAlpha | MaterialStates.DestinationBlendOneMinusSourceAlpha))
						&& (color[3] <= 0))
					{
						continue;
					}

					// select the vertex color source
					if(stage.VertexColor == StageVertexColor.Ignore)
					{
						_effect.DiffuseColor = new Vector3(color[0], color[1], color[2]);
						_effect.Alpha = color[3];
					}
					else
					{
						if(stage.VertexColor == StageVertexColor.InverseModulate)
						{
							idConsole.Warning("TODO: InverseModulate");
							//GL_TextureEnvironment(Gl.GL_COMBINE_ARB);

							/*GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.CombineRgb, (int) All.Modulate);
							GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.Source0Rgb, (int) All.Texture);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE1_RGB_ARB, Gl.GL_PRIMARY_COLOR_ARB);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_OPERAND0_RGB_ARB, Gl.GL_SRC_COLOR);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_OPERAND1_RGB_ARB, Gl.GL_ONE_MINUS_SRC_COLOR);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_RGB_SCALE_ARB, 1);*/
						}

						// for vertex color and modulated color, we need to enable a second texture stage
						if(color[0] != 1 || color[1] != 1 || color[2] != 1 || color[3] != 1)
						{
							SetTextureUnit(1);
							idE.ImageManager.WhiteImage.Bind();
							idConsole.Warning("TODO: vertex color");
							// GL_TextureEnvironment(Gl.GL_COMBINE_ARB);

							/*Gl.glTexEnvfv(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_COLOR, color);

							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_COMBINE_RGB_ARB, Gl.GL_MODULATE);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE0_RGB_ARB, Gl.GL_PREVIOUS_ARB);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE1_RGB_ARB, Gl.GL_CONSTANT_ARB);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_OPERAND0_RGB_ARB, Gl.GL_SRC_COLOR);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_OPERAND1_RGB_ARB, Gl.GL_SRC_COLOR);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_RGB_SCALE_ARB, 1);

							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_COMBINE_ALPHA_ARB, Gl.GL_MODULATE);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE0_ALPHA_ARB, Gl.GL_PREVIOUS_ARB);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE1_ALPHA_ARB, Gl.GL_CONSTANT_ARB);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_OPERAND0_ALPHA_ARB, Gl.GL_SRC_ALPHA);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_OPERAND1_ALPHA_ARB, Gl.GL_SRC_ALPHA);
							Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_ALPHA_SCALE, 1);

							GL_SelectTexture(0);*/
						}
					}

					// bind the texture
					BindVariableStageImage(stage.Texture, registers);

					// set the state
					SetState(stage.DrawStateBits);

					PrepareStageTexturing(stage, surface, tri.AmbientCache.Data);

					// draw it
					DrawElementsWithCounters(tri);

					FinishStageTexturing(stage, surface, tri.AmbientCache.Data);

					if(stage.VertexColor != StageVertexColor.Ignore)
					{
						idConsole.Warning("TODO: SVC ignore");
						/*GL.DisableClientState(ArrayCap.ColorArray);*/

						SetTextureUnit(1);
						SetTextureEnvironment(Gl.GL_MODULATE);

						idE.ImageManager.BindNullTexture();

						SetTextureUnit(0);
						SetTextureEnvironment(Gl.GL_MODULATE);
					}
				}

				// reset polygon offset
				if(material.TestMaterialFlag(MaterialFlags.PolygonOffset) == true)
				{
					// TODO: Gl.glDisable(Gl.GL_POLYGON_OFFSET_FILL);
				}

				if((surface.Space.WeaponDepthHack == true) || (surface.Space.ModelDepthHack != 0.0f))
				{
					idConsole.Warning("TODO: RB_LeaveDepthHack();");
				}
			}
		}
Exemplo n.º 23
0
 protected override bool Filter(ViewEntity entity)
 {
     return(entity.hasCreateView && entity.createView.type == typeof(PooledObjectType));
 }
Exemplo n.º 24
0
        public static void Run(PlayerContext context)
        {
            // Permissions
            PermissionEntity systemAdminPermission;

            if (!context.Permissions.Where(x => x.Key == "SystemAdmin").Any())
            {
                systemAdminPermission = new PermissionEntity
                {
                    Id          = Guid.NewGuid(),
                    Key         = "SystemAdmin",
                    Description = "Can do anything",
                    ReadOnly    = true,
                    Value       = "True"
                };
                context.Permissions.Add(systemAdminPermission);
            }
            else
            {
                systemAdminPermission = context.Permissions.Where(x => x.Key == "SystemAdmin").FirstOrDefault();
            }
            PermissionEntity viewAdminPermission;

            if (!context.Permissions.Where(x => x.Key == "ViewAdmin").Any())
            {
                viewAdminPermission = new PermissionEntity
                {
                    Id          = Guid.NewGuid(),
                    Key         = "ViewAdmin",
                    Description = "Can edit an View, Add/Remove Teams/Members, etc",
                    ReadOnly    = true,
                    Value       = "True"
                };
                context.Permissions.Add(viewAdminPermission);
            }
            else
            {
                viewAdminPermission = context.Permissions.Where(x => x.Key == "ViewAdmin").FirstOrDefault();
            }
            var ostAdminPermission = new PermissionEntity {
                Id = Guid.NewGuid(), Key = "OsTicketAdmin", Description = "Admin in OsTicket"
            };
            var ostAgentPermission = new PermissionEntity {
                Id = Guid.NewGuid(), Key = "OsTicketAgent", Description = "Agent in OsTicket"
            };
            var viewAllVmsPermission = new PermissionEntity {
                Id = Guid.NewGuid(), Key = "ViewAllMachines", Description = "View all Virtual Machines"
            };

            context.Permissions.Add(ostAdminPermission);
            context.Permissions.Add(ostAgentPermission);
            context.Permissions.Add(viewAllVmsPermission);

            // Roles
            var superUserRole = new RoleEntity {
                Id = Guid.Parse("f16d7689-4c22-498f-b975-021348b19120"), Name = "Super User"
            };

            superUserRole.Permissions.Add(new RolePermissionEntity {
                Id = Guid.NewGuid(), Permission = systemAdminPermission
            });

            var viewAdminRole = new RoleEntity {
                Id = Guid.Parse("b8f2c55b-f47d-4ec9-8fce-606753c4af72"), Name = "View Administrator"
            };

            viewAdminRole.Permissions.Add(new RolePermissionEntity {
                Id = Guid.NewGuid(), Permission = viewAdminPermission
            });
            viewAdminRole.Permissions.Add(new RolePermissionEntity {
                Id = Guid.NewGuid(), Permission = ostAdminPermission
            });
            viewAdminRole.Permissions.Add(new RolePermissionEntity {
                Id = Guid.NewGuid(), Permission = ostAgentPermission
            });
            viewAdminRole.Permissions.Add(new RolePermissionEntity {
                Id = Guid.NewGuid(), Permission = viewAllVmsPermission
            });

            context.Roles.Add(superUserRole);
            context.Roles.Add(viewAdminRole);

            // sketch users
            var uEnder = new UserEntity {
                Id = Guid.Parse("3269cb19-1d39-40d3-a55e-e3e9779b6e0b"), Name = "Ender"
            };
            var uBean = new UserEntity {
                Id = Guid.Parse("ac4d3e32-c2d6-4f99-9aef-0fcd62a568a6"), Name = "Bean"
            };
            var uGraff = new UserEntity {
                Id = Guid.Parse("b7977ce5-0a17-45e1-aa2e-55c57bfffeb6"), Name = "Graff"
            };
            var uBonzo = new UserEntity {
                Id = Guid.Parse("1db2856b-7a3c-4b82-95d4-e41fb18de516"), Name = "Bonzo"
            };
            var uBob = new UserEntity {
                Id = Guid.Parse("9149f2ec-2e55-44f6-b92d-988ede6ca1f9"), Name = "Bob"
            };
            var uAdministrator = new UserEntity {
                Id = Guid.Parse("9fd3c38e-58b0-4af1-80d1-1895af91f1f9"), Name = "admin user", Role = superUserRole
            };

            context.Users.Add(uEnder);
            context.Users.Add(uBean);
            context.Users.Add(uGraff);
            context.Users.Add(uBonzo);
            context.Users.Add(uBob);
            context.Users.Add(uAdministrator);

            // view 1
            var view1 = new ViewEntity
            {
                Id          = Guid.Parse("453d394e-bf18-499b-9786-149b0f8d69ec"),
                Name        = "RCC -E EM 2018",
                Description = "Cyber views for evaluating the team.",
                Status      = ViewStatus.Active
            };

            var tBlue = new TeamEntity {
                Id = Guid.Parse("df7b7157-1727-48b5-803d-cfdb208767c0"), Name = "Blue"
            };

            tBlue.Permissions.Add(new TeamPermissionEntity(tBlue.Id, ostAdminPermission.Id));

            var tAdmin = new TeamEntity {
                Id = Guid.Parse("453e0508-0515-402d-85e9-24e567096f7a"), Name = "Admin", Role = viewAdminRole
            };

            //view1.ViewUsers.Add(new ViewUserEntity { ViewId = view1.Id, UserId = uEnder.Id, PrimaryTeamId = tBlue.Id });
            //view1.ViewUsers.Add(new ViewUserEntity { ViewId = view1.Id, UserId = uBean.Id, PrimaryTeamId = tRed.Id });
            //view1.ViewUsers.Add(new ViewUserEntity { ViewId = view1.Id, UserId = uGraff.Id, PrimaryTeamId = tWhite.Id });
            //view1.ViewUsers.Add(new ViewUserEntity { ViewId = view1.Id, UserId = uBonzo.Id, PrimaryTeamId = tSupport.Id });
            //view1.ViewUsers.Add(new ViewUserEntity { ViewId = view1.Id, UserId = uBob.Id, PrimaryTeamId = tBlue.Id });
            //view1.ViewUsers.Add(new ViewUserEntity { ViewId = view1.Id, UserId = uAdministrator.Id, PrimaryTeamId = tAdmin.Id });



            //tBlue.Memberships.Add(new TeamMembershipEntity { Team = tBlue, User = uAdministrator,  });

            //tBlue.TeamUsers.Add(new TeamUserEntity { TeamId = tBlue.Id, UserId = uEnder.Id });
            //tBlue.TeamUsers.Add(new TeamUserEntity { TeamId = tBlue.Id, UserId = uBob.Id });
            //tBlue.TeamUsers.Add(new TeamUserEntity { TeamId = tBlue.Id, UserId = uBonzo.Id });

            var tRed = new TeamEntity {
                Id = Guid.Parse("51484d68-8ad9-487e-98d6-30db812fa355"), Name = "Red"
            };
            //tRed.TeamUsers.Add(new TeamUserEntity { TeamId = tRed.Id, UserId = uBean.Id });

            var tWhite = new TeamEntity {
                Id = Guid.Parse("66925bea-68fd-40dd-9b19-d3c1fb5fa1bf"), Name = "White"
            };
            //tWhite.TeamUsers.Add(new TeamUserEntity { TeamId = tWhite.Id, UserId = uGraff.Id });

            var tSupport = new TeamEntity {
                Id = Guid.Parse("b7ca71d3-330c-4ae4-aab5-21fdcf8ee775"), Name = "Support"
            };

            //tSupport.TeamUsers.Add(new TeamUserEntity { TeamId = tSupport.Id, UserId = uBonzo.Id });
            //tSupport.TeamUsers.Add(new TeamUserEntity { TeamId = tSupport.Id, UserId = uAdministrator.Id });


            //tAdmin.TeamUsers.Add(new TeamUserEntity { TeamId = tAdmin.Id, UserId = uAdministrator.Id });

            view1.Teams.Add(tBlue);
            view1.Teams.Add(tRed);
            view1.Teams.Add(tWhite);
            view1.Teams.Add(tSupport);
            view1.Teams.Add(tAdmin);

            //// view 2
            //var view2 = new ViewEntity
            //{
            //    Id = Guid.Parse("fc41c788-063b-4018-9f28-5f68a52f4e76"),
            //    Name = "View 2",
            //    Description = "Another View",
            //    Status = ViewStatus.Active
            //};

            var a = new ApplicationEntity
            {
                Name       = "Virtual Machines",
                Url        = "http://localhost:4303/views/{viewId}",
                Embeddable = true,
            };

            a.Icon = "/assets/img/SP_Icon_Virtual.png";

            var b = new ApplicationEntity
            {
                Name       = "Intel Doc",
                Url        = "https://www3.epa.gov/ttn/naaqs/standards/co/data/2009_04_COScopeandMethodsPlan.pdf",
                Embeddable = true,
            };

            b.Icon = "/assets/img/SP_Icon_Intel.png";

            var c = new ApplicationEntity
            {
                Name       = "Chat",
                Url        = "https://chatterbox.sky.cert.org?geid={viewId}",
                Embeddable = false,
            };

            c.Icon = "/assets/img/SP_Icon_Chat.png";


            var d = new ApplicationEntity
            {
                Name       = "View Hub",
                Url        = "https://hub.com?geid={viewId}",
                Embeddable = true,
            };

            d.Icon = "/assets/img/SP_Icon_Hub.png";

            var e = new ApplicationEntity
            {
                Name             = "Help Desk",
                Url              = "http://localhost/osticket/login.php?do=ext&bk=identity.client",
                Embeddable       = true,
                LoadInBackground = true
            };

            e.Icon = "/assets/img/SP_Icon_Help.png";

            view1.Applications.Add(a);
            view1.Applications.Add(b);
            view1.Applications.Add(c);
            view1.Applications.Add(d);
            view1.Applications.Add(e);

            ApplicationInstanceEntity blueVmAppInstance = new ApplicationInstanceEntity {
                Application = a, DisplayOrder = 0
            };
            ApplicationInstanceEntity blueIntelAppInstance = new ApplicationInstanceEntity {
                Application = b, DisplayOrder = 1
            };
            ApplicationInstanceEntity blueChatAppInstance = new ApplicationInstanceEntity {
                Application = c, DisplayOrder = 2
            };
            ApplicationInstanceEntity blueHubAppInstance = new ApplicationInstanceEntity {
                Application = d, DisplayOrder = 3
            };
            ApplicationInstanceEntity blueHelpdeskAppInstance = new ApplicationInstanceEntity {
                Application = e, DisplayOrder = 4
            };

            ApplicationInstanceEntity redVmAppInstance = new ApplicationInstanceEntity {
                Application = a, DisplayOrder = 0
            };
            ApplicationInstanceEntity redHelpdeskAppInstance = new ApplicationInstanceEntity {
                Application = e, DisplayOrder = 1
            };

            ApplicationInstanceEntity whiteVmAppInstance = new ApplicationInstanceEntity {
                Application = a, DisplayOrder = 0
            };
            ApplicationInstanceEntity whiteHelpdeskAppInstance = new ApplicationInstanceEntity {
                Application = e, DisplayOrder = 1
            };

            ApplicationInstanceEntity supportVmAppInstance = new ApplicationInstanceEntity {
                Application = a, DisplayOrder = 0
            };
            ApplicationInstanceEntity supportHelpdeskAppInstance = new ApplicationInstanceEntity {
                Application = e, DisplayOrder = 1
            };

            ApplicationInstanceEntity adminVmAppInstance = new ApplicationInstanceEntity {
                Application = a, DisplayOrder = 0
            };
            ApplicationInstanceEntity adminHelpdeskAppInstance = new ApplicationInstanceEntity {
                Application = e, DisplayOrder = 1
            };

            tBlue.Applications.Add(blueVmAppInstance);
            tBlue.Applications.Add(blueIntelAppInstance);
            tBlue.Applications.Add(blueChatAppInstance);
            tBlue.Applications.Add(blueHubAppInstance);
            tBlue.Applications.Add(blueHelpdeskAppInstance);

            tRed.Applications.Add(redVmAppInstance);
            tRed.Applications.Add(redHelpdeskAppInstance);

            tWhite.Applications.Add(whiteVmAppInstance);
            tWhite.Applications.Add(whiteHelpdeskAppInstance);

            tSupport.Applications.Add(supportVmAppInstance);
            tSupport.Applications.Add(supportHelpdeskAppInstance);

            tAdmin.Applications.Add(adminVmAppInstance);
            tAdmin.Applications.Add(adminHelpdeskAppInstance);

            context.Views.Add(view1);
            //context.Views.Add(view2);

            var exMembership1 = new ViewMembershipEntity {
                View = view1, UserId = uEnder.Id
            };

            view1.Memberships.Add(exMembership1);
            context.SaveChanges();

            var enderBlueMembership = new TeamMembershipEntity {
                Team = tBlue, User = uEnder, ViewMembership = exMembership1, Role = viewAdminRole
            };

            exMembership1.PrimaryTeamMembership = enderBlueMembership;

            context.SaveChanges();
        }
Exemplo n.º 25
0
        public void EditPageTest()
        {
            mockDbContext        = CreateMock();
            textEditorControlelr = new TextEditorController(mockDbContext);

            var mockControllerContext = new Mock <ControllerContext>();

            SetMockSession();
            SetMockController();
            TestAndDebug();

            IDbContext CreateMock()
            {
                var fileList = new List <IEntity>()
                {
                    new EditText {
                        FileId = 1, Text = "testFileList",
                    },
                    new EditText {
                        FileId = 2, Text = "testFileList2",
                    },
                };

                var markerList = new List <IEntity>()
                {
                    new Marker()
                    {
                        MarkerId = 1, Name = "color1", UserId = 1, Color = "#998877", DisplayOrder = 1
                    },
                    new Marker()
                    {
                        MarkerId = 1, Name = "color2", UserId = 1, Color = "#998877", DisplayOrder = 2
                    },
                    new Marker()
                    {
                        MarkerId = 2, Name = "color3", UserId = 2, Color = "#665544", DisplayOrder = 2
                    },
                };

                var mock = new MockCreator(fileList);

                mock.SetMock(markerList);
                return(mock.GetMockContext().Object);
            }

            void TestAndDebug()
            {
                string Before1
                    = ViewEntity.WriteEntityData(
                          mockDbContext.Marker.ToArray()
                          );

                Debug.WriteLine($"Before List :\r {Before1}");

                int UserId = 1;

                ViewResult result = textEditorControlelr.EditPage(UserId) as ViewResult;

                EditPageDto editPageDto = (EditPageDto)result.Model;

                string After1
                    = ViewEntity.WriteEntityData(
                          editPageDto.MarkerList
                          );

                Debug.WriteLine($"After View :\r {After1}");
            }

            void SetMockSession()
            {
                mockControllerContext.Setup(x => x.HttpContext.Session["UserId"]).Returns("1");
            }

            void SetMockController()
            {
                textEditorControlelr.ControllerContext = mockControllerContext.Object;
                textEditorControlelr.ModelState.AddModelError("SessionName", "Required");
            }
        }
Exemplo n.º 26
0
        public void GetViewTest()
        {
            mockDbContext        = CreateMock();
            textEditorControlelr = new TextEditorController(mockDbContext);


            var mockControllerContext = new Mock <ControllerContext>();

            SetMockSession();
            SetMockController();
            TestAndDebug();
            IDbContext CreateMock()
            {
                var list = new List <IEntity>()
                {
                    new EditText {
                        FileId = 1, Text = "aaabbcc"
                    },
                    new EditText {
                        FileId = 2, Text = "ddeeff"
                    }
                };

                var mock = new MockCreator(list);

                return(mock.GetMockContext().Object);
            }

            void SetMockSession()
            {
                HttpSessionStateManager.SetVaue(SessionBaseName.MaxFileId, 1);
            }

            void SetMockController()
            {
                textEditorControlelr.ControllerContext = mockControllerContext.Object;
                textEditorControlelr.ModelState.AddModelError("SessionName", "Required");
            }

            void TestAndDebug()
            {
                string Before1
                    = ViewEntity.WriteEntityData(
                          mockDbContext.EditText.ToArray()
                          );

                Debug.WriteLine($"Before List :\r {Before1}");

                textEditorControlelr.GetView("11223344");

                Type type = textEditorControlelr.GetType();

                FieldInfo newContext = type.GetField("_context", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance);

                TextEditorContext context
                    = newContext.GetValue(textEditorControlelr) as TextEditorContext;

                string After1
                    = ViewEntity.WriteEntityData(
                          context.EditText.ToArray()
                          );

                Debug.WriteLine($"After View :\r {After1}");
            }
        }
Exemplo n.º 27
0
 public SPOViewPipeBind(ViewEntity view)
 {
     this._viewEntity = view;
 }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            ConfigDcConfig.GetServerName(out string serverName);
            Util.ConfigDc.ProtoProxy.ServerAddressReply serverAddressReply = ConfigDcUtilClientImp.GetServerAddress(serverName).Result;
            string Ip   = serverAddressReply.ServerIp;
            int    Port = serverAddressReply.ServerPort;


            Console.Title = "B2B监听服务";
            try
            {
                IServiceCollection services = new ServiceCollection();

                #region  EF Context注册
                services.AddDbContext <B2bDbContext>(options =>
                                                     options.UseSqlServer
                                                     (
                                                         ConfigDcUtilClientImp.GetDbConnectionConfig().GetAwaiter().GetResult()
                                                     )
                                                     );
                ConsoleExtendsions.WriteLineSuccess("EF Context 注册成功... ");
                #endregion


                #region DI注入
                IServiceProvider serviceProvider = ServerRegisterModuleIoc.GrpcServerModule.ServiceDIRegister(services);
                ConsoleExtendsions.WriteLineSuccess("DI 注入成功... ");
                #endregion


                #region 视图重置
                string[]          files          = FileHelper.GetFiles("cfgViews");
                List <ViewEntity> viewEntityList = new List <ViewEntity>();
                Console.WriteLine();
                Console.WriteLine($"共检测到 {files.Length} 个视图需要重置,正在重置...");
                CreateInitView createInitView = new CreateInitView(serviceProvider.GetService <DbContext>());
                for (int i = 0; i < files.Length; i++)
                {
                    string     fileContent = FileHelper.FileReadAllText(files[i]);
                    ViewEntity v           = new ViewEntity(FileHelper.GetFileName(files[i]), fileContent);
                    createInitView.RunInitCreate(v);
                    ConsoleExtendsions.WriteLineSuccess($"{i + 1}. {v.viewName} 视图重置成功... ");
                }
                ConsoleExtendsions.WriteLineSuccess("重置数据库视图完成... ");
                Console.WriteLine();
                #endregion

                #region Oracle 配置
                DbStartConfig.DbOracleConnectionString = ConfigDcUtilClientImp.GetDbConnectionConfig("OracleDbConnectionString").GetAwaiter().GetResult();
                #endregion



                Server server = new Server()
                {
                    Ports    = { new ServerPort(Ip, Port, ServerCredentials.Insecure) },
                    Services =
                    {
                        MenuProxy.BindService(new MenuProxyService(() => serviceProvider.GetService <IBaseService <B2B_MENU> >())),
                        LookUpValuesAllProxy.BindService(new LookUpValuesAllProxyService(() => serviceProvider.GetService <IBaseService <B2B_LOOKUP_VALUES_ALL> >())),

                        LookUpValuesProxy.BindService(new LookUpValuesProxyService(() => serviceProvider.GetService <IB2B_LOOKUP_VALUES_Service>())),

                        MessagesProxy.BindService(new MessagesProxyService(() => serviceProvider.GetService <IB2B_MESSAGES_Service>())),
                        UserProxy.BindService(new UserProxyService(() => serviceProvider.GetService <IB2B_USER_Service>())),

                        UserMenuProxy.BindService(new UserMenuProxyService(() => serviceProvider.GetService <IB2B_USER_MENU_Service>())),
                        MenuFunctionProxy.BindService(new MenuFunctionProxyService(() => serviceProvider.GetService <IBaseService <B2B_MENU_FUNCTION> >())),
                        UserFunctionProxy.BindService(new UserFunctionProxyService(() => serviceProvider.GetService <IB2B_USER_FUNCTION_Service>())),
                    }
                };
                server.Start();

                ConsoleExtendsions.WriteLineSuccess("gRPC 服务启动成功,正在监听:port " + Port);
                Console.WriteLine("任意键退出...");
                Console.ReadKey();

                server.ShutdownAsync().Wait();
            }
            catch (Exception ex)
            {
                ConsoleExtendsions.WriteLineError($"gRPC 服务监听启动失败!失败 port:{Port}!错误详细信息:{ex.GetBaseException().ToString()}");
                Console.WriteLine("任意键退出...");
                Console.ReadKey();
                logger.Error(ex: ex);
            }
        }
Exemplo n.º 29
0
        private static System.Collections.Generic.List <ulong> sequenceIds = new System.Collections.Generic.List <ulong>(); //List of all current Sequence Ids, could probably split this out to a separate class with all the specific methods

        static int Main(string[] arguments)
        {
            //"${IMPROBABLE_RECEPTIONIST_HOST}", "${IMPROBABLE_RECEPTIONIST_PORT}", "${IMPROBABLE_WORKER_ID}" defined as passed in as part of config
            string hostName = arguments[0];
            ushort port     = Convert.ToUInt16(arguments[1]);
            string workerId = arguments[2];

            Assembly.Load("GeneratedCode");

            using (var connection = ConnectWorker(workerId, hostName, port))
            {
                using (var dispatcher = new Dispatcher())
                {
                    IsConnected = true;

                    dispatcher.OnDisconnect(op =>
                    {
                        Console.Error.WriteLine("[disconnect] {0}", op.Reason);
                        IsConnected = false;
                    });

                    dispatcher.OnLogMessage(op =>
                    {
                        connection.SendLogMessage(op.Level, LoggerName, op.Message);
                        Console.WriteLine("Log Message: {0}", op.Message);
                        if (op.Level == LogLevel.Fatal)
                        {
                            Console.Error.WriteLine("Fatal error: {0}", op.Message);
                            Environment.Exit(ErrorExitStatus);
                        }
                    });

                    dispatcher.OnAuthorityChange <Life>(op =>
                    {
                        ViewEntity entity;
                        if (EntityView.TryGetValue(op.EntityId, out entity))
                        {
                            if (op.Authority == Authority.Authoritative)
                            {
                                entity.hasAuthority = true;
                            }
                            else if (op.Authority == Authority.NotAuthoritative)
                            {
                                entity.hasAuthority = false;
                            }
                            else if (op.Authority == Authority.AuthorityLossImminent)
                            {
                                entity.hasAuthority = false;
                            }
                        }
                    });

                    dispatcher.OnAddComponent <Life>(op =>
                    {
                        ViewEntity entity;
                        if (EntityView.TryGetValue(op.EntityId, out entity))
                        {
                            entity.entity.Add <Life>(op.Data);
                        }
                        else
                        {
                            ViewEntity newEntity = new ViewEntity();
                            EntityView.Add(op.EntityId, newEntity);
                            newEntity.entity.Add <Life>(op.Data);
                        }
                    });

                    dispatcher.OnComponentUpdate <Life>(op =>
                    {
                        ViewEntity entity;
                        if (EntityView.TryGetValue(op.EntityId, out entity))
                        {
                            var update = op.Update.Get();
                            entity.entity.Update <Life>(update);
                        }
                    });
                    dispatcher.OnAddComponent <Neighbors>(op =>
                    {
                        ViewEntity entity;
                        if (EntityView.TryGetValue(op.EntityId, out entity))
                        {
                            entity.entity.Add <Neighbors>(op.Data);
                        }
                        else
                        {
                            ViewEntity newEntity = new ViewEntity();
                            EntityView.Add(op.EntityId, newEntity);
                            newEntity.entity.Add <Neighbors>(op.Data);
                        }
                    });

                    dispatcher.OnComponentUpdate <Neighbors>(op =>
                    {
                        ViewEntity entity;
                        if (EntityView.TryGetValue(op.EntityId, out entity))
                        {
                            var update = op.Update.Get();
                            entity.entity.Update <Neighbors>(update);
                        }
                    });
                    dispatcher.OnAddEntity(op =>
                    {
                        //AddEntity will always be followed by OnAddComponent
                        ViewEntity newEntity   = new ViewEntity();
                        newEntity.hasAuthority = true;
                        newEntity.entity       = new Entity();
                        ViewEntity oldEntity;
                        if (!EntityView.TryGetValue(op.EntityId, out oldEntity))
                        {
                            EntityView.Add(op.EntityId, newEntity);
                        }
                    });
                    dispatcher.OnRemoveEntity(op =>
                    {
                        EntityView.Remove(op.EntityId);
                    });

                    WorkerConnection = connection;
                    WorkerConnection.SendLogMessage(LogLevel.Info, "LifeWorker", "Worker Connected");
                    RunEventLoop(connection, dispatcher);
                }
            }
            return(0);
        }
Exemplo n.º 30
0
 /// <summary>
 /// Clear all updates from a single view entity
 /// </summary>
 /// <param name="viewEntity"></param>
 private static void ClearEntityUpdates(ViewEntity viewEntity)
 {
     viewEntity.hasUpdate      = false;
     viewEntity.lifeUpdate     = null;
     viewEntity.metadataUpdate = null;
 }
Exemplo n.º 31
0
 public SPOViewPipeBind(ViewEntity view)
 {
     this._viewEntity = view;
 }