Beispiel #1
0
        public Response <List <GetPrintBatchDetails> > GetApprovedPrintBatches(string token)
        {
            string message = String.Empty;

            try
            {
                List <GetPrintBatchDetails> _list = new List <GetPrintBatchDetails>();
                Guid checkGuid; string sessionKey; long userId; string nextToken;
                if (BackOfficeAPIController.ValidateToken(token, _Action, 0, out checkGuid, out sessionKey, out userId, out nextToken))
                {
                    var result = _distManController.GetPrintBatchesForUser(null, null, null, 1, null, 1, null, null, 0, 20, 1, userId, "test");
                    foreach (var item in result.Value)
                    {
                        _list.Add(new GetPrintBatchDetails()
                        {
                            PrintBatchId = item.print_batch_id, PrintBatchReference = item.print_batch_reference, ProductId = item.product_id, PrintBatchStatusId = item.print_batch_statuses_id, CreatedDateTime = (DateTime)item.date_created, NoOfRequests = (int)item.no_cards
                        });
                    }
                    return(new Response <List <GetPrintBatchDetails> >(true, message, _list, nextToken));
                }
                else
                {
                    message = "Invalid Token";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                _log.Error(ex);
            }

            return(new Response <List <GetPrintBatchDetails> >(false, message, null, ""));
        }
Beispiel #2
0
        public int CheckStatusRest(string guid)
        {
            try
            {
                Guid sessionGuid;
                if (Guid.TryParse(guid, out sessionGuid))
                {
                    var status = BackOfficeAPIController.CheckStatusSession(sessionGuid);
                    _log.Debug(d => d("Status for " + guid + " is " + status));

                    return(status);
                }
                else
                {
                    _log.Warn("GUID Format incorrect.");
                    HttpContext.Current.Response.TrySkipIisCustomErrors = true;
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.StatusCode = 500;
                    throw new HttpException(500, "GUID format incorrect");
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                HttpContext.Current.Response.TrySkipIisCustomErrors = true;
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.StatusCode = 500;
                throw new HttpException(500, ex.Message);
            }
        }
Beispiel #3
0
        public Response <string[]> GetWorkStationKey(string WorkStation, int size, string token)
        {
            string message = String.Empty;

            try
            {
                Guid checkGuid; string sessionKey; long userId; string nextToken;
                if (BackOfficeAPIController.ValidateToken(token, _Action, 0, out checkGuid, out sessionKey, out userId, out nextToken))
                {
                    var response = _distManController.GetWorkStationKey(WorkStation, size);
                    if (response != null)
                    {
                        return(new Response <string[]>(true, message, response.Value, nextToken));
                    }
                }
                else
                {
                    message = "Invalid Token";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                _log.Error(ex);
            }
            return(new Response <string[]>(false, message, null, ""));
        }
Beispiel #4
0
        public Response <bool> updatePrintBatchStatus(UpdatePrintBatchDetails _printBatch, string token)
        {
            string message = String.Empty;

            try
            {
                Guid checkGuid; string sessionKey; long userId; string nextToken;
                if (BackOfficeAPIController.ValidateToken(token, _Action, 0, out checkGuid, out sessionKey, out userId, out nextToken))
                {
                    List <RequestData> targetList = _printBatch.RequestDetails
                                                    .Select(x => new RequestData()
                    {
                        request_id = x.RequestId, card_number = x.PAN, request_statues_id = x.RequestStatuesId == null? 0 : (int)x.RequestStatuesId
                    })

                                                    .ToList();

                    var response = _distManController.UpdatePrintBatchRequestsStatus((long)_printBatch.PrintBatchId, (int)_printBatch.PrintBatchStatusId, _printBatch.Successful, targetList, _printBatch.Cardstobespoiled, _printBatch.notes, 0, userId, "API");
                    if (response.Value)
                    {
                        return(new Response <bool>(true, message, true, nextToken));
                    }
                }
                else
                {
                    message = "Invalid Token";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                _log.Error(ex);
            }
            return(new Response <bool>(true, message, false, ""));
        }
Beispiel #5
0
        public void CreateTokenTest()
        {
            var token = BackOfficeAPIController.CreateToken(Guid.NewGuid(), new indigoCardIssuingWeb.Old_App_Code.security.IndigoIdentity(new GenericIdentity("Test"),
                                                                                                                                          1, "1", "2", "em", true, false, "abcd"),
                                                            Veneka.Indigo.BackOffice.API.Action.PrintCard);

            long   userId;
            string nextToken;

            BackOfficeAPIController.ValidateToken(token, Veneka.Indigo.BackOffice.API.Action.PrintCard, 0, out Guid checkGuid, out string sessionKey, out userId, out nextToken);
        }
        public AuthenticationResponse Login(string username, string password)
        {
            string message = String.Empty;

            try
            {
                string encryptedUsername = EncryptionManager.EncryptString(username,
                                                                           Veneka.Indigo.Common.Utilities.StaticFields.USE_HASHING_FOR_ENCRYPTION,
                                                                           Veneka.Indigo.Common.Utilities.StaticFields.EXTERNAL_SECURITY_KEY);
                string encryptedpwd = EncryptionManager.EncryptString(password,
                                                                      Veneka.Indigo.Common.Utilities.StaticFields.USE_HASHING_FOR_ENCRYPTION,
                                                                      Veneka.Indigo.Common.Utilities.StaticFields.EXTERNAL_SECURITY_KEY);

                string workstation = EncryptionManager.EncryptString("APILoginAttempt" + DateTime.Now.ToString(),
                                                                     Veneka.Indigo.Common.Utilities.StaticFields.USE_HASHING_FOR_ENCRYPTION,
                                                                     Veneka.Indigo.Common.Utilities.StaticFields.EXTERNAL_SECURITY_KEY);
                var responseObj = _userManContoller.LogIn(encryptedUsername, encryptedpwd, workstation);
                if (responseObj.ResponseType == ResponseType.SUCCESSFUL)
                {
                    string SessionKey = EncryptionManager.DecryptString(responseObj.Value.encryptedSessionKey,
                                                                        Veneka.Indigo.Common.Utilities.StaticFields.USE_HASHING_FOR_ENCRYPTION,
                                                                        Veneka.Indigo.Common.Utilities.StaticFields.EXTERNAL_SECURITY_KEY);
                    string UserId = EncryptionManager.DecryptString(responseObj.Value.encryptedUserId,
                                                                    Veneka.Indigo.Common.Utilities.StaticFields.USE_HASHING_FOR_ENCRYPTION,
                                                                    Veneka.Indigo.Common.Utilities.StaticFields.EXTERNAL_SECURITY_KEY);
                    var token = BackOfficeAPIController.CreateToken(Guid.NewGuid(), SessionKey, int.Parse(UserId), bll.Action.PrintCard);


                    return(new AuthenticationResponse()
                    {
                        ResponseCode = "00", ResponseMessage = "SUCCESSFUL", AuthToken = token
                    });
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                _log.Error(ex);
            }

            return(new AuthenticationResponse()
            {
                ResponseCode = "01", ResponseMessage = "failed", AuthToken = null
            });
        }
Beispiel #7
0
        public Response <List <Veneka.Indigo.BackOffice.API.RequestDetails> > GetRequestsforBatch(long print_batch_id, int startindex, int size, string token)
        {
            string message = String.Empty;

            try
            {
                List <Veneka.Indigo.BackOffice.API.RequestDetails> _list = new List <Veneka.Indigo.BackOffice.API.RequestDetails>();
                Guid checkGuid; string sessionKey; long userId; string nextToken;
                if (BackOfficeAPIController.ValidateToken(token, _Action, 0, out checkGuid, out sessionKey, out userId, out nextToken))
                {
                    var result = _distManController.GetPrintBatchRequests(print_batch_id, startindex, size, userId, "API");
                    foreach (var item in result.Value)
                    {
                        Veneka.Indigo.BackOffice.API.RequestDetails _request_result = new Veneka.Indigo.BackOffice.API.RequestDetails()
                        {
                            RequestId = item.request_id, RequestReference = item.request_reference, RequestStatuesId = item.hybrid_request_statuses_id
                        };
                        _request_result.ProdTemplateList = new List <ProductTemplate>();

                        foreach (var j in item.ProductFields)
                        {
                            _request_result.ProdTemplateList.Add(new ProductTemplate()
                            {
                                ProductPrintFieldId = j.ProductPrintFieldId, Value = j.Value, font = j.Font, fontColourRGB = j.FontColourRGB.ToString(), font_size = j.FontSize, x = j.X, y = (float)((j.Y) * (2.94)), productPrintFieldTypeId = j.ProductPrintFieldTypeId, PrintSide = j.PrintSide
                            });
                        }
                        _list.Add(_request_result);
                    }

                    return(new Response <List <Veneka.Indigo.BackOffice.API.RequestDetails> >(true, message, _list, nextToken));
                }
                else
                {
                    message = "Invalid Token";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                _log.Error(ex);
            }

            return(new Response <List <Veneka.Indigo.BackOffice.API.RequestDetails> >(false, message, null, ""));
        }
Beispiel #8
0
        public Response <List <ProductTemplate> > GetProductTemplate(int productid, string token)
        {
            string message = String.Empty;

            try
            {
                List <Veneka.Indigo.BackOffice.API.ProductTemplate> _list = new List <Veneka.Indigo.BackOffice.API.ProductTemplate>();
                Guid checkGuid; string sessionKey; long userId; string nextToken;
                if (BackOfficeAPIController.ValidateToken(token, _Action, 0, out checkGuid, out sessionKey, out userId, out nextToken))
                {
                    var result = _issueCardController.GetPrintFieldsByProductid(productid);

                    foreach (var j in result.Value)
                    {
                        _list.Add(new ProductTemplate()
                        {
                            ProductPrintFieldId = j.ProductPrintFieldId, productPrintFieldTypeId = j.ProductPrintFieldTypeId, font_size = j.FontSize
                        });
                    }


                    return(new Response <List <Veneka.Indigo.BackOffice.API.ProductTemplate> >(true, message, _list, nextToken));
                }
                else
                {
                    message = "Invalid Token";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                _log.Error(ex);
            }

            return(new Response <List <Veneka.Indigo.BackOffice.API.ProductTemplate> >(false, message, null, ""));
        }