Beispiel #1
0
        public RemoteMessanger(RemoteProcessType processType, UploadStationInfo authParam, RemoteRequestType requestType = RemoteRequestType.Registration, Method method = Method.POST)
        {
            try
            {
                if (authParam == null || authParam.StationInfoId < 1 || string.IsNullOrEmpty(authParam.APIAccessKey))
                {
                    throw new ApplicationException("Empty / Invalid Remote Server Authentication Parameters");
                }
                var servAdd = authParam.HostServerAddress;
                if (string.IsNullOrEmpty(servAdd) || servAdd.Length < 5)
                {
                    throw new ApplicationException("Remote Server Address Not Configured");
                }
                _client = new RestClient(servAdd);
                switch (requestType)
                {
                case RemoteRequestType.Registration:
                    _request = new RestRequest("bioEnroll/DataKiosk/" + processType, method)
                    {
                        JsonSerializer = new JsonSerializer(),
                        RequestFormat  = DataFormat.Json
                    };
                    break;

                case RemoteRequestType.Report:
                    _request = new RestRequest("Messaging/LRServiceCloud/" + processType, method)
                    {
                        JsonSerializer = new JsonSerializer(),
                        RequestFormat  = DataFormat.Json
                    };
                    break;
                }

                _request.AddHeader("content-type", "application/json");
                _request.AddHeader("APIAccessKey", string.Format("{0}", authParam.APIAccessKey));
                _request.AddHeader("StationName", string.Format("{0}", authParam.StationName));
                _request.AddHeader("StationId", string.Format("{0}", authParam.StationKey));
                _request.AddHeader("EnrollerRegId", string.Format("{0}", authParam.EnrollerRegId));
                _request.AddHeader("ApiVersion", string.Format("{0}", 1));
                // _request.Timeout = 180000;
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Remote Server Address Not Configured");
            }
        }
        public BulkBeneficiaryRegResponseObj UploadBulkData(BulkBeneficiaryRegObj bulkItems, UploadStationInfo stationInfo)
        {
            var response = new BulkBeneficiaryRegResponseObj
            {
                MainStatus = new ResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new ResponseMessage()
                }
            };

            try
            {
                return(_beneficiaryRepository.UploadBulkData(bulkItems, stationInfo));
            }
            catch (Exception ex)
            {
                response.MainStatus.Message.FriendlyMessage  = "Processing Error Occurred! Please try again later";
                response.MainStatus.Message.TechnicalMessage = "Error: " + ex.Message;
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(response);
            }
        }