Exemple #1
0
 public ActionResult _AddGeneralAttribute(Model.AddGeneralAttributeModel pModel)
 {
     if (ModelState.IsValid || (pModel.id_typeA == "4" && pModel.attributeA != null))
     {
         AttributeTypeDTO    attributesType = categorieProvider.getAttributeType(pModel.id_typeA).Result;
         Regex               r = new Regex(attributesType.reg_expr);
         GeneralAttributeDTO generalAttributeDTO = new GeneralAttributeDTO();
         if (attributesType.reg_expr == "" || r.Match(pModel.valueA).Success)
         {
             generalAttributeDTO.name         = pModel.attributeA;
             generalAttributeDTO.value        = pModel.valueA != null ? pModel.valueA : "";
             generalAttributeDTO.type_id      = pModel.id_typeA;
             generalAttributeDTO.user         = Request.Cookies["user_id"].Value;
             generalAttributeDTO.createdBy    = generalAttributeDTO.user;
             generalAttributeDTO.categorie_id = pModel.categorie_idA;
             if (categorieProvider.postGeneralAttribute(generalAttributeDTO).Result)
             {
                 return(_GeneralAttrList(pModel.categorie_idA));
                 //return _CategorieGeneralAtr(pModel.categorie_id);
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "Error, el campo valor es inválido"));
         }
     }
     else
     {
         return(new HttpStatusCodeResult(404, "Error, debe completar todos los campos"));
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el atributo"));
 }
        public NSObject ObjectValueForTableColumn(NSTableView table, NSTableColumn col, int row)
        {
            NSString value = NSString.Empty;

            try
            {
                if (AttributeEntries != null)
                {
                    AttributeTypeDTO record = AttributeEntries[row];
                    switch (col.Identifier)
                    {
                    case VMDirSchemaConstants.VMDIRSCHEMA_NAME:
                        value = (NSString)record.Name;
                        break;

                    case VMDirSchemaConstants.VMDIRSCHEMA_OPTIONAL_ATTR:
                        value = (NSString)Convert.ToString(record.IsOptional);
                        break;

                    case VMDirSchemaConstants.VMDIRSCHEMA_ATTR_SYNTAX:
                        value = (NSString)record.Type;
                        break;
                    }
                }
            }
            catch (Exception)
            {
                value = NSString.Empty;
            }
            return(value);
        }
Exemple #3
0
 public ActionResult _AddAttributeList(Model.AddAttributeListModel pModel)
 {
     if (ModelState.IsValid)
     {
         AttributeTypeDTO attributesTypes = categorieProvider.getAttributeType(pModel.id_typeVA).Result;
         Regex            r = new Regex(attributesTypes.reg_expr);
         AttributeListDTO attributeListDTO = new AttributeListDTO();
         if (attributesTypes.reg_expr == "" || r.Match(pModel.valueVA).Success)
         {
             attributeListDTO.name         = pModel.attributeVA;
             attributeListDTO.value        = pModel.valueVA;
             attributeListDTO.type_id      = pModel.id_typeVA;
             attributeListDTO.user         = Request.Cookies["user_id"].Value;
             attributeListDTO.createdBy    = attributeListDTO.user;
             attributeListDTO.attribute_id = pModel.attribute_idVA;
             if (categorieProvider.postAttributeList(attributeListDTO).Result)
             {
                 return(_AttributeValuesList(pModel.attribute_idVA, pModel.attribute_nameVA));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "El campo valor es inválido"));
         }
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el atributo"));
 }
Exemple #4
0
 public ActionResult _EditPersonalAttribute(Model.EditPersonalAttributeModel pModel)
 {
     if (ModelState.IsValid)
     {
         AttributeTypeDTO     attributesType = categorieProvider.getAttributeType(pModel.id_type).Result;
         Regex                r = new Regex(attributesType.reg_expr);
         PersonalAttributeDTO personalAttributeDTO = new PersonalAttributeDTO();
         if (attributesType.reg_expr == "" || r.Match(pModel.value).Success)
         {
             personalAttributeDTO.name         = pModel.attribute;
             personalAttributeDTO.value        = pModel.value;
             personalAttributeDTO.type_id      = pModel.id_type;
             personalAttributeDTO.isEnabled    = pModel.isEnabled == "on" ? "true" : "false";
             personalAttributeDTO.userLog      = Request.Cookies["user_id"].Value;
             personalAttributeDTO.id_attribute = pModel.id_attribute;
             if (categorieProvider.putPersonalAttribute(personalAttributeDTO).Result)
             {
                 return(new HttpStatusCodeResult(200, "El atributo se ha editado con éxito"));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "El campo valor es inválido"));
         }
     }
     else
     {
         return(new HttpStatusCodeResult(404, "Error, debe completar todos los campos"));
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el atributo"));
 }
Exemple #5
0
 public ActionResult _AddPersonalAttribute(Model.AddPersonalAttributeModel pModel)
 {
     if (ModelState.IsValid)
     {
         AttributeTypeDTO     attributesTypes = categorieProvider.getAttributeType(pModel.id_typePA).Result;
         Regex                r = new Regex(attributesTypes.reg_expr);
         PersonalAttributeDTO personaAttributeDTO = new PersonalAttributeDTO();
         if (attributesTypes.reg_expr == "" || r.Match(pModel.valuePA).Success)
         {
             personaAttributeDTO.name         = pModel.attributePA;
             personaAttributeDTO.value        = pModel.valuePA;
             personaAttributeDTO.type_id      = pModel.id_typePA;
             personaAttributeDTO.userLog      = Request.Cookies["user_id"].Value;
             personaAttributeDTO.createdBy    = personaAttributeDTO.userLog;
             personaAttributeDTO.categorie_id = pModel.categorie_idPA;
             if (categorieProvider.postPersonalAttribute(personaAttributeDTO).Result)
             {
                 return(_PersonalAttrList(pModel.categorie_idPA));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "El campo valor es inválido"));
         }
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el atributo"));
 }
 public JsonResult _EditUserAttribute(Model.EditUserAttributeModel model)
 {
     if (ModelState.IsValid)
     {
         AttributeTypeDTO attributesType = categorieProvider.getAttributeType(model.type_id).Result;
         Regex            r = new Regex(attributesType.reg_expr);
         if (r.Match(model.value).Success)
         {
             PersonalAttributeDTOmin userAttribute = new PersonalAttributeDTOmin();
             userAttribute.attribute_id = model.attribute_id;
             userAttribute.value        = model.value;
             userAttribute.user_id      = model.user_id;
             userAttribute.userLog      = Request.Cookies["user_id"].Value;
             if (userProvider.putUserAttribute(userAttribute).Result)
             {
                 Response.StatusCode = 200;
                 return(Json(model, JsonRequestBehavior.AllowGet));
                 //return new HttpStatusCodeResult(200, "hola");
             }
         }
         Response.StatusCode        = 400;
         Response.StatusDescription = "El campo valor es incorrecto";
         return(Json(new { error = "El campo valor es incorrecto" }, JsonRequestBehavior.AllowGet));
     }
     Response.StatusCode        = 400;
     Response.StatusDescription = "Error, debe completar todos los campos";
     return(Json(new { error = "Error, debe completar todos los campos" }, JsonRequestBehavior.AllowGet));
 }
Exemple #7
0
 public AttributeTypeWindowController(AttributeTypeDTO attrType)
     : base("AttributeTypeWindow")
 {
     isAddMode       = false;
     AttributeDTO    = attrType;
     AttributeModDTO = new AttributeTypeDTO();
 }
        /// <summary>
        ///     Adds an attribute type to the collection.
        /// </summary>
        /// <param name="attributeType">
        ///     New value.
        /// </param>
        public void AddAttributeDataType(AttributeTypeDTO attributeType)
        {
            DataStorageItem <AttributeTypeDTO> newRec = new DataStorageItem <AttributeTypeDTO>(new AttributeTypeDTO(GetNextAttributeDataTypeId(), attributeType.Description));

            newRec.Added = true;
            this.mAttributeDataTypes.Add(newRec);
            this.IsModified = true;
        }
Exemple #9
0
        public AttributeDTO(string name, string value, AttributeTypeDTO attrSyntaxDTO, bool dirty)
        {
            this.Name          = name;
            this.Value         = value;
            this.AttrSyntaxDTO = attrSyntaxDTO;

            this.Dirty = dirty;
        }
Exemple #10
0
        public VMDirSchemaAttributeEntryNode(VMDirSchemaServerNode node, AttributeTypeDTO dto)

            : base(node)

        {
            this.DisplayName = dto.Name;

            this.attrType = dto;
        }
Exemple #11
0
        public AttributeDTO(string name, string value, AttributeTypeDTO attrSyntaxDTO)

        {
            this.Name = name;

            this.Value = value;

            this.AttrSyntaxDTO = attrSyntaxDTO;
        }
Exemple #12
0
        public VMDirAttributeDTO(string name, List <LdapValue> values, AttributeTypeDTO attrSyntaxDTO)

        {
            this.Name = name;

            this.Values = values;

            this.AttrSyntaxDTO = attrSyntaxDTO;
        }
        public AttributeTypeWindow()

        {
            InitializeComponent();

            isAddMode = true;

            AttributeDTO = new AttributeTypeDTO();

            Initialise();
        }
        public AttributeTypeWindow(AttributeTypeDTO attrType)

        {
            InitializeComponent();

            isAddMode = false;

            AttributeDTO = attrType;

            AttributeModDTO = new AttributeTypeDTO();

            Initialise();
        }
 /// <summary>
 ///     Modify an attribute data type record.
 /// </summary>
 /// <param name="attributeType">
 ///     New values for the record.
 /// </param>
 public void ModifyAttributeDataType(AttributeTypeDTO attributeType)
 {
     for (int index = 0; index < this.mAttributeDataTypes.Count; ++index)
     {
         if (this.mAttributeDataTypes[index].Data.AttributeTypeId == attributeType.AttributeTypeId)
         {
             mAttributeDataTypes[index].Data.Description = attributeType.Description;
             mAttributeDataTypes[index].Modified         = true;
             this.IsModified = true;
             return;
         }
     }
 }
        public void ModifyAttributeType(AttributeTypeDTO dto)
        {
            MaintainSession(delegate()
            {
                List <LdapMod> attribute = new List <LdapMod>();

                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_REPLACE, VMDirConstants.DESCRIPTION, new string[] { dto.Description, null }));
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_REPLACE, VMDirConstants.ATTR_SINGLE_VALUED, new string[] { Convert.ToString(dto.SingleValue), null }));

                string dn = "cn=" + dto.Name + ",cn=schemacontext";
                ldConn.ModifyObject(dn, attribute.ToArray());
            });
        }
Exemple #17
0
        private static int GetOrCreateAttributeTypeDto(MpAttribute attribute, Dictionary <int, AttributeTypeDTO> attributeTypes)
        {
            var attributeTypeDto = new AttributeTypeDTO()
            {
                AttributeTypeId         = attribute.AttributeTypeId,
                Name                    = attribute.AttributeTypeName,
                AllowMultipleSelections = !attribute.PreventMultipleSelection
            };

            var key = attributeTypeDto.AttributeTypeId;

            if (!attributeTypes.ContainsKey(key))
            {
                attributeTypes[key] = attributeTypeDto;
            }
            return(key);
        }
Exemple #18
0
        public static List <AttributeDTO> ConvertToAttributeDTOList(Dictionary <string, VMDirAttributeDTO> _properties)
        {
            var attrList = new List <AttributeDTO>();

            foreach (var entry in _properties)
            {
                var valDTO      = entry.Value;
                var attrTypeDTO = valDTO.AttrSyntaxDTO;
                if (attrTypeDTO == null)
                {
                    attrTypeDTO = new AttributeTypeDTO();
                }
                foreach (var val in valDTO.Values)
                {
                    attrList.Add(new AttributeDTO(entry.Key, val.StringValue, attrTypeDTO, false));
                }
            }
            attrList.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.InvariantCultureIgnoreCase));
            return(attrList);
        }
        public async Task <AttributeTypeDTO> getAttributeType(string id_type)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(_BaseAddress);
                AttributeTypeDTO attributeType = new AttributeTypeDTO();
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken());
                HttpResponseMessage response = client.GetAsync("api/categories/AttrTypes/?id_type=" + id_type).Result;
                if (response.IsSuccessStatusCode)
                {
                    string result = await response.Content.ReadAsStringAsync();

                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    attributeType = serializer.Deserialize <AttributeTypeDTO>(result);
                }
                return(attributeType);
            }
        }
        public static List <AttributeTypeDTO> getAttributeTypes()
        {
            List <AttributeTypeDTO> atributeTypesDTO = new List <AttributeTypeDTO>();

            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_get_attributeTypes", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Connection.Open();
                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    AttributeTypeDTO attributeTypeDTO = new AttributeTypeDTO();
                    attributeTypeDTO.id_type  = rdr["id_type"].ToString();
                    attributeTypeDTO.type     = rdr["type"].ToString();
                    attributeTypeDTO.reg_expr = rdr["reg_expr"].ToString();
                    atributeTypesDTO.Add(attributeTypeDTO);
                }
            };
            return(atributeTypesDTO);
        }
        public static AttributeTypeDTO getAttributeTypes(string id_type)
        {
            AttributeTypeDTO atributeTypeDTO = new AttributeTypeDTO();

            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionRRHHDatabase"].ConnectionString))
            {
                SqlCommand command = new SqlCommand("usp_get_attributeType", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@id_type", SqlDbType.Int);
                command.Parameters["@id_type"].Value = id_type;
                command.Connection.Open();
                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    atributeTypeDTO.id_type  = rdr["id_type"].ToString();
                    atributeTypeDTO.type     = rdr["type"].ToString();
                    atributeTypeDTO.reg_expr = rdr["reg_expr"].ToString();
                }
            };
            return(atributeTypeDTO);
        }
Exemple #22
0
 public ActionResult _EditGeneralAttribute(Model.EditGeneralAttributeModel pModel)
 {
     if (ModelState.IsValid || (pModel.id_type == "4" && pModel.attribute != null))
     {
         AttributeTypeDTO    attributesType = categorieProvider.getAttributeType(pModel.id_type).Result;
         Regex               r = new Regex(attributesType.reg_expr);
         GeneralAttributeDTO generalAttributeDTO = new GeneralAttributeDTO();
         if (attributesType.reg_expr == "" || r.Match(pModel.value).Success)
         {
             generalAttributeDTO.name         = pModel.attribute;
             generalAttributeDTO.value        = pModel.value;
             generalAttributeDTO.type_id      = pModel.id_type;
             generalAttributeDTO.isEnabled    = pModel.isEnabled == "on" ? "true" : "false";
             generalAttributeDTO.user         = Request.Cookies["user_id"].Value;
             generalAttributeDTO.id_attribute = pModel.id_attribute;
             if (categorieProvider.putGeneralAttribute(generalAttributeDTO).Result)
             {
                 return(new HttpStatusCodeResult(200));
             }
         }
         else
         {
             return(new HttpStatusCodeResult(404, "El campo valor es inválido"));
         }
     }
     else
     {
         foreach (ModelState modelState in ViewData.ModelState.Values)
         {
             foreach (ModelError error in modelState.Errors)
             {
                 string sError = error.ErrorMessage;
             }
         }
         return(new HttpStatusCodeResult(404, "Error, debe completar todos los campos"));
     }
     return(new HttpStatusCodeResult(404, "Error, no se puede agregar el atributo"));
 }
        public void AddAttributeType(AttributeTypeDTO dto)
        {
            MaintainSession(delegate()
            {
                List <LdapMod> attribute = new List <LdapMod>();
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_CN, new string[] { dto.Name, null }));
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_OBJECT_CLASS, new string[] { VMDirConstants.DEFAULT_ATTR_SCHEMA_NAME, null }));
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_ID, new string[] { dto.AttributeID, null }));
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.LDAP_DISPLAY_NAME, new string[] { dto.Name, null }));
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SYNTAX, new string[] { dto.AttributeSyntax, null }));
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SINGLE_VALUED, new string[] { "TRUE", null }));
                attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.SCHEMA_ID_GUID, new string[] { dto.Name, null }));

                if (dto.Description != null && !String.IsNullOrWhiteSpace(dto.Description))
                {
                    attribute.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.DESCRIPTION, new string[] { dto.Description, null }));
                }


                string dn = "cn=" + dto.Name + ",cn=schemacontext";
                ldConn.AddObject(dn, attribute.ToArray());
            });
        }
Exemple #24
0
        /// <summary>
        ///     Event handler for the Add button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAddButtonClicked(Object sender, EventArgs e)
        {
            // The contained value of this object will be set to an instance of a DataStorageItem if a previously deleted item was restored.
            ObjectContainer <DataStorageItem <AttributeTypeDTO> > restoredRec = new ObjectContainer <DataStorageItem <AttributeTypeDTO> >();

            InputBox dlg = new InputBox(InputBoxValidationProc, null, null, restoredRec);

            switch (dlg.ShowDialog(this))
            {
            case DialogResult.OK:
            {
                if (!String.IsNullOrWhiteSpace(dlg.Value))
                {
                    AttributeTypeDTO newRec = new AttributeTypeDTO(0, dlg.Value.Trim());
                    DataStorageItem <AttributeTypeDTO> addRec = new DataStorageItem <AttributeTypeDTO>(newRec)
                    {
                        Added = true
                    };
                    this.mAttributeDataTypes.Add(addRec);

                    // Show in the list view
                    ListViewItem newListViewItem = new ListViewItem(addRec.Data.Description);
                    newListViewItem.Tag = addRec;
                    attributeTypesListView.Items.Add(newListViewItem);
                    attributeTypesListView.SelectedItems.Clear();
                    newListViewItem.Selected = true;

                    this.applyButton.Enabled = true;
                }
            }
            break;

            default:
                break;
            }
        }
Exemple #25
0
 public AttributeTypeWindowController()
     : base("AttributeTypeWindow")
 {
     isAddMode    = true;
     AttributeDTO = new AttributeTypeDTO();
 }
Exemple #26
0
 public static int AttributeTypeSort(AttributeTypeDTO lhs, AttributeTypeDTO rhs)
 {
     return(lhs.Name.CompareTo(rhs.Name));
 }
        public AttributeTypeDTO getAttributeTypes(string id_type)
        {
            AttributeTypeDTO type = CategoriesData.getAttributeTypes(id_type);

            return(type);
        }