Exemplo n.º 1
0
        public void Delete(int id)
        {
            using (var ctx = new Context.Context())
            {
                var usuario = ctx.Usuarios.Find(id);

                if (usuario != null)
                {
                    usuario.ConfirmacaoSenha = usuario.Senha;
                    usuario.DataExclusao     = DateTime.Now;

                    ctx.Entry(usuario).State = System.Data.Entity.EntityState.Modified;
                    ctx.SaveChanges();

                    var responsavel = ctx.Responsaveis.Where(x => x.DataExclusao == null && x.UsuarioID == usuario.ID).SingleOrDefault();

                    if (responsavel != null)
                    {
                        responsavel.UsuarioID = null;

                        ctx.Entry(responsavel).State = System.Data.Entity.EntityState.Modified;
                        ctx.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 2
0
 public override void Interpret(Context.Context context)
 {
     // 循环处理Context中的标记
     while (true)
     {
         // 如果已经没有任何标记,则退出解释
         if (context.GetCurrentToken() == null)
         {
             break;
         }
         // 如果标记为END,则不解释END并结束本次解释过程,可以继续之后的解释
         else if (context.GetCurrentToken().Equals("END", StringComparison.OrdinalIgnoreCase))
         {
             context.SkipToken("END");
             break;
         }
         // 如果为其它标记,则解释标记并加入命令集合
         else
         {
             Node node = new CommandNode();
             node.Interpret(context);
             nodeList.Add(node);
         }
     }
 }
Exemplo n.º 3
0
        public void Interpret(Context.Context context)
        {
            if (context.Input.Length == 0)
            {
                return;
            }

            if (context.Input.StartsWith(Nine()))
            {
                context.Output += (9 * Multiplier());
                context.Input   = context.Input.Substring(2);
            }
            else if (context.Input.StartsWith(Four()))
            {
                context.Output += (4 * Multiplier());
                context.Input   = context.Input.Substring(2);
            }
            else if (context.Input.StartsWith(Five()))
            {
                context.Output += (5 * Multiplier());
                context.Input   = context.Input.Substring(1);
            }

            while (context.Input.StartsWith(One()))
            {
                context.Output += (1 * Multiplier());
                context.Input   = context.Input.Substring(1);
            }
        }
Exemplo n.º 4
0
        public List <Item> GetByLocalID(int localID)
        {
            List <Item> itens = null;

            using (var ctx = new Context.Context())
            {
                itens = ctx.Itens.Include("Local.Filial").Include("Especie").Include("CamposExtras").Include("PropriedadesValores").Where(x => x.DataExclusao == null && x.LocalID == localID).ToList();
            }

            foreach (var item in itens)
            {
                var path = System.Configuration.ConfigurationManager.AppSettings["GaleriaImagens"] + item.ID;

                var files = Directory.GetFiles(path);

                foreach (var file in files)
                {
                    FileInfo info = new FileInfo(file);

                    item.Imagens.Add(System.Configuration.ConfigurationManager.AppSettings["GaleriaImagensLogico"] + item.ID + "/" + info.Name);
                }
            }

            return(itens);
        }
Exemplo n.º 5
0
        public void Insert(InventarioLocal inventarioLocal)
        {
            using (var ctx = new Context.Context())
            {
                var inventarioLocalCadastrado = ctx.InventarioLocais.Where(x => x.DataExclusao == null && x.InventarioID == inventarioLocal.InventarioID && x.LocalID == inventarioLocal.LocalID).SingleOrDefault();

                if (inventarioLocalCadastrado == null)
                {
                    ctx.InventarioLocais.Add(inventarioLocal);
                    ctx.SaveChanges();

                    var local = ctx.Locais.Find(inventarioLocal.LocalID);

                    var inventarioFilial = ctx.InventarioFiliais.Where(x => x.FilialID == local.FilialID && x.InventarioID == inventarioLocal.InventarioID).SingleOrDefault();

                    if (inventarioFilial == null)
                    {
                        ctx.InventarioFiliais.Add(new InventarioFilial()
                        {
                            FilialID     = local.FilialID,
                            InventarioID = inventarioLocal.InventarioID
                        });

                        ctx.SaveChanges();
                    }
                }
                else
                {
                    throw new ArgumentException("Local já vinculado a esse Inventário.");
                }
            }
        }
Exemplo n.º 6
0
        public List <OrdemServicoMotivo> GetAll()
        {
            List <OrdemServicoMotivo> motivos = null;

            using (var ctx = new Context.Context())
            {
                motivos = ctx.OrdemServicoMotivos.Where(x => x.DataExclusao == null).OrderBy(x => x.Nome).ToList();

                foreach (var motivo in motivos)
                {
                    string campos = string.Empty;

                    foreach (var campo in ctx.OrdemServicoMotivoCampos.Where(x => x.OrdemServicoMotivoID == motivo.ID))
                    {
                        campos += campo.OrdemServicoCampo.NomeCampo + ",";
                    }

                    campos = campos.Substring(0, campos.Length - 1);

                    motivo.CamposVinculados = campos;
                }
            }

            return(motivos);
        }
Exemplo n.º 7
0
        public List <Empresa> GetByInventarioUsuarioID(int usuarioID)
        {
            var empresas = new List <Empresa>();

            using (var ctx = new Context.Context())
            {
                var usuario = ctx.Usuarios.Where(x => x.ID == usuarioID).SingleOrDefault();

                if (usuario.PerfilID == 1)
                {
                    empresas.AddRange(ctx.Empresas.Where(x => x.DataExclusao == null));
                }
                else
                {
                    if (usuario.EmpresaID != null)
                    {
                        empresas.Add(usuario.Empresa);
                    }

                    string comm = @"select distinct
                                e.*
                                from 
                                InventarioUsuario iu
                                join Inventario i on i.ID = iu.InventarioID
                                join Empresa e on e.ID = i.EmpresaID
                                where UsuarioID = @usuarioID and iu.DataExclusao IS NULL";

                    empresas.AddRange(ctx.Empresas.SqlQuery(comm, new SqlParameter("@usuarioID", usuarioID)).ToList <Empresa>());

                    empresas = empresas.Distinct().ToList();
                }
            }

            return(empresas.OrderBy(x => x.NomeFantasia).ToList());
        }
Exemplo n.º 8
0
        public Item GetByCodigo(int empresaID, string codigo, int incorporacao)
        {
            Item item = null;

            using (var ctx = new Context.Context())
            {
                item = ctx.Itens.Include("CamposExtras").Include("PropriedadesValores").Include("Especie").Include("Local.Filial").Where(x => x.EmpresaID == empresaID && x.Codigo == codigo && x.Incorporacao == incorporacao).FirstOrDefault();
            }

            if (item != null)
            {
                var path = System.Configuration.ConfigurationManager.AppSettings["GaleriaImagens"] + item.ID;

                var files = Directory.GetFiles(path);

                foreach (var file in files)
                {
                    FileInfo info = new FileInfo(file);

                    item.Imagens.Add(System.Configuration.ConfigurationManager.AppSettings["GaleriaImagensLogico"] + item.ID + "/" + info.Name);
                }
            }

            return(item);
        }
Exemplo n.º 9
0
        public void Update(int perfilID, string funcionalidade, string metodo)
        {
            using (var ctx = new Context.Context())
            {
                var permissoes = ctx.Permissoes.Where(x => x.PerfilID == perfilID).ToList();

                var permissao = permissoes.Where(x => x.Funcionalidade.Nome.ToLower() == funcionalidade.ToLower() && x.Metodos.ToLower().Contains(metodo.ToLower())).FirstOrDefault();

                List <string> metodos = permissao.Metodos.Split(',').ToList();

                if (permissao == null)
                {
                    metodos.Add(metodo.ToUpper());
                }
                else
                {
                    metodos = metodos.Where(x => x != metodo.ToUpper()).ToList();
                }

                permissao.Metodos = string.Join(",", metodos);

                ctx.Entry(permissao).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Exemplo n.º 10
0
 public void Insert(ContaContabil contaContabil)
 {
     using (var ctx = new Context.Context())
     {
         ctx.ContasContabeis.Add(contaContabil);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public void Cleanup()
 {
     using (var context = new Context.Context())
     {
         context.Database.ExecuteSqlCommand("delete from dbo.People where Id > 1000");
         context.Database.ExecuteSqlCommand("delete from dbo.Addresses where Id > 1");
     }
 }
Exemplo n.º 12
0
 public void Update(OrdemServico ordemServico)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(ordemServico).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 13
0
 public void Insert(PropriedadeValor propriedadeValor)
 {
     using (var ctx = new Context.Context())
     {
         ctx.PropriedadeValores.Add(propriedadeValor);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 14
0
 public void Update(PropriedadeValor propriedadeValor)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(propriedadeValor).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 15
0
 public void Update(Sincronizacao sincronizacao)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(sincronizacao).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 16
0
 public void Insert(Sincronizacao sincronizacao)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Sincronizacoes.Add(sincronizacao);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 17
0
 public void Update(Filial filial)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(filial).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 18
0
 public void Insert(Filial filial)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Filiais.Add(filial);
         ctx.SaveChanges();
     }
 }
 private bool ConsentHandler(IConsent consent, Context.Context context, Cause cause) {
     if (consent.IsVetoed) {
         context.Reason = consent.Reason;
         context.ErrorCause = cause;
         return false;
     }
     return true;
 }
Exemplo n.º 20
0
 public void DeleteAll(int empresaID)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Database.ExecuteSqlCommand($"UPDATE ITEM SET DATAEXCLUSAO = GETDATE() WHERE DATAEXCLUSAO IS NULL AND EMPRESAID = {empresaID}");
         ctx.SaveChanges();
     }
 }
Exemplo n.º 21
0
 public void Insert(OrdemServicoAnexo anexo)
 {
     using (var ctx = new Context.Context())
     {
         ctx.OrdemServicoAnexos.Add(anexo);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 22
0
 public void Update(Coletor coletor)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(coletor).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 23
0
 public void Update(Upload upload)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(upload).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 24
0
 public void Insert(Upload upload)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Uploads.Add(upload);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 25
0
 public void Update(InventarioConfig config)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(config).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 26
0
 public User Authorization(string login, string password)
 {
     using (var context = new Context.Context())
     {
         var user = context.Users.Where(x => x.Login == login && CryptService.VerifyPassword(x.Password, password) == true).FirstOrDefault();
         return(user);
     }
 }
Exemplo n.º 27
0
 public void Insert(ItemEstado itemEstado)
 {
     using (var ctx = new Context.Context())
     {
         ctx.ItemEstados.Add(itemEstado);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 28
0
 public void Insert(OrdemServicoItem ordemServicoItem)
 {
     using (var ctx = new Context.Context())
     {
         ctx.OrdemServicoItens.Add(ordemServicoItem);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 29
0
 public void Update(Placa placa)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Entry(placa).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 30
0
 public void Insert(Placa placa)
 {
     using (var ctx = new Context.Context())
     {
         ctx.Placas.Add(placa);
         ctx.SaveChanges();
     }
 }
Exemplo n.º 31
0
		/// <summary>
		/// Resolves the attribute reference defined within the given match.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="match">The target item match.</param>
		/// <param name="contextTargetItem">The context target item.</param>
		/// <returns>The context attribute.</returns>
		public static Context.AttributeElement Resolve(EvaluationContext context, TargetMatchBaseReadWrite match, ctx.TargetItemBase contextTargetItem)
		{
			Context.AttributeElementReadWrite attribute = null;
			if (match.AttributeReference is pol.AttributeDesignatorBase)
			{
				var attrDesig = (pol.AttributeDesignatorBase)match.AttributeReference;
				context.Trace("Looking for attribute: {0}", attrDesig.AttributeId);
				foreach (Context.AttributeElementReadWrite tempAttribute in contextTargetItem.Attributes)
				{
					if (tempAttribute.Match(attrDesig))
					{
						attribute = tempAttribute;
						break;
					}
				}

				if (attribute == null)
				{
					context.Trace("Attribute not found, loading searching an external repository");
					attribute = GetAttribute(context, attrDesig);
				}
			}
			else if (match.AttributeReference is pol.AttributeSelectorElement)
			{
				var attrSelec = (pol.AttributeSelectorElement)match.AttributeReference;
				var content = (ctx.ResourceContentElement)((ctx.ResourceElement)contextTargetItem).ResourceContent;
				if (content != null)
				{
					XmlDocument doc = context.ContextDocument.XmlDocument;

					if (context.ContextDocument.XmlNamespaceManager == null)
					{
						context.ContextDocument.AddNamespaces(context.PolicyDocument.Namespaces);
					}

					string xpath = attrSelec.RequestContextPath;
					try
					{
						Debug.Assert(doc.DocumentElement != null, "doc.DocumentElement != null");
						XmlNode node = doc.DocumentElement.SelectSingleNode(xpath, context.ContextDocument.XmlNamespaceManager);
						if (node != null)
						{
							attribute = new ctx.AttributeElement(null, attrSelec.DataType, null, null, node.InnerText, attrSelec.SchemaVersion);
						}
					}
					catch (XPathException e)
					{
						context.Trace("ERR: {0}", e.Message);
						context.ProcessingError = true;
					}
				}
			}

			if (!context.ProcessingError && attribute == null && match.AttributeReference.MustBePresent)
			{
				context.IsMissingAttribute = true;
				context.AddMissingAttribute(match.AttributeReference);
			}

			if (attribute != null)
			{
				return new Context.AttributeElement(attribute.AttributeId, attribute.DataType, attribute.Issuer, attribute.IssueInstant,
					attribute.Value, attribute.SchemaVersion);
			}
			return null;
		}
Exemplo n.º 32
0
		/// <summary>
		/// Search for the attribute in the context target item using the attribute designator specified.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="attributeDesignator">The attribute designator instance.</param>
		/// <param name="targetItem">The target item to search in.</param>
		/// <returns>A bag value with the values of the attributes found.</returns>
		public static BagValue FindAttribute(EvaluationContext context, pol.AttributeDesignatorBase attributeDesignator, ctx.TargetItemBase targetItem)
		{
			var bag = new BagValue(GetDataType(attributeDesignator.DataType));
			foreach (ctx.AttributeElement attribute in targetItem.Attributes)
			{
				if (attribute.Match(attributeDesignator))
				{
					context.Trace("Adding target item attribute designator: {0}", attribute.ToString());
					bag.Add(attribute);
				}
			}
			return bag;
		}
Exemplo n.º 33
0
		/// <summary>
		/// Evaluate the context document using a specified policy
		/// </summary>
		/// <param name="policyDocument">The policy instance</param>
		/// <param name="contextDocument">The context document instance</param>
		/// <returns>The response document</returns>
		public ctx.ResponseElement Evaluate(pol.PolicyDocument policyDocument, ctx.ContextDocument contextDocument)
		{
			if (policyDocument == null) throw new ArgumentNullException("policyDocument");
			if (contextDocument == null) throw new ArgumentNullException("contextDocument");
			var context = new EvaluationContext(this, policyDocument, contextDocument);

			context.Trace("Start evaluation");
			context.AddIndent();

			// Check if both documents are valid
			if (!policyDocument.IsValidDocument || !contextDocument.IsValidDocument)
			{
				// If a validation error was found a response is created with the syntax error message
				var response =
					new ctx.ResponseElement(
						new[] {
							new ctx.ResultElement( 
								null, 
								Decision.Indeterminate, 
								new ctx.StatusElement( 
									new ctx.StatusCodeElement(Consts.ContextSchema.StatusCodes.SyntaxError, null, policyDocument.Version ), 
									null, 
									null, policyDocument.Version ), 
								null, policyDocument.Version ) },
					policyDocument.Version);
				return response;
			}

			// Create a new response
			contextDocument.Response = new ctx.ResponseElement((ctx.ResultElement[])null, policyDocument.Version);

			try
			{
				// Create the evaluable policy intance
				IMatchEvaluable policy = null;
				if (policyDocument.PolicySet != null)
				{
					policy = new PolicySet(this, (pol.PolicySetElement)policyDocument.PolicySet);
				}
				else if (policyDocument.Policy != null)
				{
					policy = new Policy((pol.PolicyElement)policyDocument.Policy);
				}

				// Evaluate the policy or policy set
				if (policy != null)
				{
					// Creates the evaluable policy set
					if (policy.AllResources.Count == 0)
					{
						policy.AllResources.Add("");
					}

					string requestedResourceString = String.Empty;
					Uri requestedResource = null;

					foreach (ctx.ResourceElement resource in contextDocument.Request.Resources)
					{
						// Keep the requested resource
						if (resource.IsHierarchical)
						{
							foreach (ctx.AttributeElement attribute in resource.Attributes)
							{
								if (attribute.AttributeId == Consts.ContextSchema.ResourceElement.ResourceId)
								{
									if (context.PolicyDocument.Version == XacmlVersion.Version10 ||
										context.PolicyDocument.Version == XacmlVersion.Version11)
									{
										requestedResourceString = attribute.AttributeValues[0].Contents;
									}
									else
									{
										if (attribute.AttributeValues.Count > 1)
										{
											throw new NotSupportedException("resources contains a bag of values");
										}
										requestedResourceString = attribute.AttributeValues[0].Contents;
									}
								}
							}
							if (!string.IsNullOrEmpty(requestedResourceString))
							{
								requestedResource = new Uri(requestedResourceString);
							}
						}

						// Iterate through the policy resources evaluating each resource in the context document request 
						foreach (string resourceName in policy.AllResources)
						{
							bool mustEvaluate = false;
							if (resource.IsHierarchical)
							{
								//Validate if the resource is hierarchically desdendant or children 
								//of the requested resource
								Uri policyResource = new Uri(resourceName);

								Debug.Assert(requestedResource != null, "requestedResource != null");
								if (!(mustEvaluate = requestedResource.Equals(policyResource)))
								{
									// Perform the hierarchical evaluation
									if (resource.ResourceScopeValue == ctx.ResourceScope.Children)
									{
										mustEvaluate = typ.AnyUri.IsChildrenOf(requestedResource, policyResource);
									}
									else if (resource.ResourceScopeValue == ctx.ResourceScope.Descendants)
									{
										mustEvaluate = typ.AnyUri.IsDescendantOf(requestedResource, policyResource);
									}
								}

								if (mustEvaluate)
								{
									foreach (ctx.AttributeElementReadWrite attribute in context.CurrentResource.Attributes)
									{
										if (attribute.AttributeId == Consts.ContextSchema.ResourceElement.ResourceId)
										{
											attribute.AttributeValues[0].Contents = resourceName;
											break;
										}
									}
								}
							}
							else
							{
								context.CurrentResource = resource;
								mustEvaluate = true;
							}

							if (mustEvaluate)
							{
								// Evaluates the policy set
								Decision decision = policy.Evaluate(context);

								// Create a status code using the policy execution state
								ctx.StatusCodeElement scode;
								if (context.IsMissingAttribute)
								{
									scode = new ctx.StatusCodeElement(
										Consts.ContextSchema.StatusCodes.MissingAttribute, null, policyDocument.Version);
								}
								else if (context.ProcessingError)
								{
									scode = new ctx.StatusCodeElement(
										Consts.ContextSchema.StatusCodes.ProcessingError, null, policyDocument.Version);
								}
								else
								{
									scode = new ctx.StatusCodeElement(
										Consts.ContextSchema.StatusCodes.Ok, null, policyDocument.Version);
								}

								//Stop the iteration if there is not a hierarchical request
								if (!resource.IsHierarchical)
								{
									// Ussually when a single resource is requested the ResourceId is not specified in the result
									var oblig = policy as IObligationsContainer;
									contextDocument.Response.Results.Add(
										new ctx.ResultElement("", decision,
											new ctx.StatusElement(scode, "", "", policyDocument.Version), oblig.Obligations, policyDocument.Version));
									break;
								}
								else
								{
									// Adding a resource for each requested resource, using the resourceName as the resourceId of the result
									var oblig = policy as IObligationsContainer;
									contextDocument.Response.Results.Add(
										new ctx.ResultElement(resourceName, decision,
											new ctx.StatusElement(scode, "", "", policyDocument.Version), oblig.Obligations, policyDocument.Version));
								}
							} // if( mustEvaluate )
						} // foreach( string resourceName in policy.AllResources )
					}
				} //if( policy != null )
			}
			catch (EvaluationException e)
			{
				// If a validation error was found a response is created with the syntax error message
				contextDocument.Response =
					new ctx.ResponseElement(
						new ctx.ResultElement[] {
							new ctx.ResultElement( 
								null, 
								Decision.Indeterminate, 
								new ctx.StatusElement( 
									new ctx.StatusCodeElement(Consts.ContextSchema.StatusCodes.ProcessingError, null, policyDocument.Version ), 
									e.Message, 
									e.StackTrace, policyDocument.Version ), 
								null, policyDocument.Version ) },
					policyDocument.Version);
			}

			return contextDocument.Response;
		}
Exemplo n.º 34
0
		/// <summary>
		/// Evaluate the context document using a specified policy
		/// </summary>
		/// <param name="contextDocument">The context document instance</param>
		/// <returns>The response document.</returns>
		public ctx.ResponseElement Evaluate(ctx.ContextDocument contextDocument)
		{
			var context = new EvaluationContext(this, null, contextDocument);

			try
			{
				// Validates the configuration file was found.
				if (ConfigurationRoot.Config != null)
				{
					// Search all the policies repositories to find a policy that matches the 
					// context document
					pol.PolicyDocument policyDocument = null;
					foreach (IPolicyRepository policyRep in ConfigurationRoot.Config.PolicyRepositories)
					{
						if (policyDocument == null)
						{
							policyDocument = policyRep.Match(context);
						}
						else
						{
							throw new EvaluationException(Properties.Resource.exc_duplicated_policy_in_repository);
						}
					}

					// If the policy was found evaluate the context document, otherwise use the
					// Evaluate method to generate a Response context document.
					if (policyDocument != null)
					{
						return Evaluate(policyDocument, contextDocument);
					}
					else
					{
						return Evaluate(null, null);
					}
				}
				else
				{
					throw new EvaluationException(Properties.Resource.exc_configuration_file_not_found);
				}
			}
			catch (EvaluationException e)
			{
				context.Trace("ERR: {0}", e.Message);
				return Evaluate(null, null);
			}
		}
Exemplo n.º 35
0
        /// <summary>
        /// Creates a new context document
        /// </summary>
        /// <param name="sender">The mainTree control.</param>
        /// <param name="args">THe arguements for the event.</param>
        private void CreateContextDocument(object sender, EventArgs args)
        {
            // Create a new policydocument
            var newContext = new con.ContextDocumentReadWrite(); //TODO: check version

            newContext.Namespaces.Add(string.Empty, Consts.Schema1.Namespaces.Context);
            newContext.Namespaces.Add("xsi", Consts.Schema1.Namespaces.Xsi);
            var newNode = new Context(newContext);
            _mainTree.Nodes.Add(newNode);
            _docType = DocumentType.Request;
            newNode.NodeFont = new Font(_mainTree.Font, FontStyle.Bold);
            _menuItemOpenPolicy.Enabled = false;
            _menuItemOpenRequest.Enabled = false;
            _menuItemSaveAs.Enabled = true;
            _menuItemSave.Enabled = true;
            _menuItemRunPolicy.Enabled = true;
            _menuItemRunRequest.Enabled = false;
        }