Exemplo n.º 1
0
        public async Task <object> AddBadge(AddBadge_DTO newBadge, string path, string user, string pass)
        {
            try
            {
                ManagementScope badgeScope = _dataConduITMgr.GetManagementScope(path, user, pass);

                ManagementClass badgeClass = new ManagementClass(badgeScope, new ManagementPath("Lnl_Badge"), null);

                ManagementObject newBadgeInstance = badgeClass.CreateInstance();

                string fechaDesactivacion = newBadge.fechaActivacion.ToString("yyyyMMdd") + "000000.000000-300";

                newBadgeInstance["ID"]          = newBadge.id;
                newBadgeInstance["PERSONID"]    = newBadge.personId;
                newBadgeInstance["STATUS"]      = newBadge.status;     //Active
                newBadgeInstance["TYPE"]        = newBadge.type;       // Employee
                newBadgeInstance["DEST_EXEMPT"] = newBadge.dest_exemp; // Sometimes teh value is required
                newBadgeInstance["ACTIVATE"]    = newBadge.fechaActivacion.ToString("yyyyMMdd") + "000000.000000-300";
                newBadgeInstance["DEACTIVATE"]  = newBadge.fechaDesactivacion.ToString("yyyyMMdd") + "000000.000000-300";

                ManagementBaseObject inParams = badgeClass.GetMethodParameters("AddBadge");
                inParams.Properties["BadgeIn"].Value = newBadgeInstance;

                //Execute the method
                ManagementBaseObject outParamObject = badgeClass.InvokeMethod("AddBadge", inParams, null);

                if (outParamObject != null)
                {
                    //Display results
                    object outObj = outParamObject["BadgeOut"];
                    ManagementBaseObject addedBadge = (ManagementBaseObject)outObj;
                    return(addedBadge["BADGEKEY"]);
                }
                else
                {
                    throw new Exception("No se pudo crear el nuevo Badge");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        public async Task <object> CrearBadge([FromBody] AddBadge_DTO newBadge)
        {
            try
            {
                object result = new
                {
                    success = true,
                    status  = 200,
                    data    = await _badge_REP_LOCAL.CrearBadge(newBadge)
                };
                return(result);
            }
            catch (Exception ex)
            {
                object result = new
                {
                    success = false,
                    status  = 400,
                    data    = ex.Message
                };

                return(BadRequest(result));
            }
        }
 public async Task <object> CrearBadge(AddBadge_DTO newBadge)
 {
     return(await _badge_REP.AddBadge(newBadge, _path, _user, _pass));
 }
Exemplo n.º 4
0
 public async Task <object> CrearBadge([FromBody] AddBadge_DTO newBadge)
 {
     return(await _badge_REP_LOCAL.CrearBadge(newBadge));
 }
Exemplo n.º 5
0
 public async Task <object> CrearBadge(AddBadge_DTO newBadge)
 {
     return(await _badge_REP.AddBadge(newBadge));
 }