//Process 1 #region SaveGstr3B #region SaveGSTR3B /// <summary> /// SaveGSTR1 /// </summary> /// <param name="attrbute"></param> /// <returns></returns> public GstnResponse SaveGSTR3B(Attrbute attrbute) { var objBusiness = new UserBusiness(); var objResponse = new GstnResponse(); //generate token var token = CommonFunction.GetUniqueToken(); //table storage connection object var tblConnection = CommonFunction.GetBlob(); WEP.GSP.Service.Blob.TableStorage objTableStorage = new TableStorage(Constants.PartitionKey, Constants.RowKey , token , Constants.GSTNStageP1Table , Constants.actualTime); //log to table storage => P1 started Task.Factory.StartNew(() => objTableStorage.InsertStageToTableStorage(tblConnection.Keys, (int)WEP.GSP.Document.Stage.Validation_BEGIN)); //paylaod sizecheck int payloadSize = GetSizeOfObject(attrbute); if (payloadSize >= Constants.PayloadSize) { throw new Exception("Error : Payload size exceed 5 MB."); } // SaveGSTR3B GSTR3B(attrbute, token, tblConnection, objTableStorage); objResponse = GetRespByTokenWithRetrySmallFile(token); return(objResponse); }
public ServiceResponse <GstnResponse> GetResponseByToken() { string token = null; try { token = string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["gsptoken"].ToString()) ? null : HttpContext.Current.Request.QueryString["gsptoken"].ToString(); GstnResponse objGstnResponse = new GstnResponse(); UserBusiness objBusiness = new UserBusiness(); Blob objBlob = new Blob(); objGstnResponse = objBusiness.GetBlobConnectionByToken(token); var respone = new ServiceResponse <GstnResponse> { ResponseObject = objGstnResponse, IsError = false }; return(respone); } catch (Exception ex) { var resErr = new ServiceResponse <string> { ResponseObject = ex.Message, IsError = true }; return(resErr); } }
public GstnResponse SearchTaxpayerOld(string gstin, string action) { GstnResponse objTaxPayer = new GstnResponse(); objTaxPayer = new UserValidation(this._clientid, this._clientSecret, this._authToken, this._username ).SearchTaxpayer(gstin, action); return(objTaxPayer); }
//#region InsertResponseLog ///// <summary> ///// InsertResponseLog ///// </summary> ///// <param name="results"></param> //public void InsertResponseLog(GstnResponse results) //{ // if (results.status_cd ==1) // { // _db.ExecuteNonQuery(Constants.SPName.GSTN_Response_Log // , results.username // , results.reqtoken // , results.status_cd // , null // , null // ,results.apiAction // ,results.blobUrl // ); // } // else if (results.status_cd == 0) // { // _db.ExecuteNonQuery(Constants.SPName.GSTN_Response_Log // , results.username // , results.reqtoken // , results.status_cd // , results.error.message // , results.error.error_cd // , results.apiAction // , results.blobUrl // ); // } //} //#endregion #region InsertResponseLog /// <summary> /// InsertResponseLog /// </summary> /// <param name="results"></param> public void InsertResponseLog(GstnResponse results) { _db.ExecuteNonQuery(Constants.SPName.GSTN_Response_Log , results.username , results.reqtoken , results.status_cd , results.apiAction , results.blobUrl , results.respBlobId ); }
/// <summary> /// GetGSTR2AFileDetailsWithResponse /// </summary> /// <param name="objAttr"></param> /// <returns></returns> public GstnResponse GetGSTR2AFileDetailsWithResponse(Attrbute objAttr) { UserBusiness objBusiness = new UserBusiness(); GstnResponse objResponse = new GstnResponse(); var token = CommonFunction.GetUniqueToken(); GSTR2AFileDetails(objAttr, token); objResponse = GetRespByTokenWithRetry(token); return(objResponse); }
/// <summary> /// GetGSTR3BTrackStatusWithResponse /// </summary> /// <param name="objAttribute"></param> /// <returns></returns> public GstnResponse GetGSTR3BTrackStatusWithResponse(Attrbute objAttribute) { UserBusiness objBusiness = new UserBusiness(); GstnResponse objResponse = new GstnResponse(); var token = CommonFunction.GetUniqueToken(); GSTR3BTrackStatus(objAttribute, token); objResponse = GetRespByTokenWithRetrySmallFile(token); return(objResponse); }
/// <summary> /// GetGSTR3BSummary /// </summary> /// <param name="objAttribute"></param> /// <returns></returns> public GstnResponse GetGSTR3BSummary(Attrbute objAttribute) { var objBusiness = new UserBusiness(); var objResponse = new GstnResponse(); var token = CommonFunction.GetUniqueToken(); GSTR3BSummary(objAttribute, token); objResponse = GetRespByTokenWithRetry(token); return(objResponse); }
public GstnResponse SearchTaxpayer(string gstin, string action) { try { GstnResponse objResponse = new GstnResponse(); Authenticate objAuthToken = new Authenticate(); Attrbute objAttr = new Attrbute(); EncryptionUtils objEncrypt = new Business.EncryptionUtils(); byte[] arrKey = objEncrypt.CreateKey(); string app_key = objEncrypt.EncryptTextWithPublicKey(arrKey); string encPassword = objEncrypt.EncryptTextWithPublicKey(Constants.PublicAuthPassword); objAttr.username = Constants.PublicAuthUsername; objAttr.password = encPassword; objAttr.app_key = app_key; objAttr.action = Constants.PublicAuthAction; string clientid = Constants.PublicClientId; string clientsecret = Constants.PublicClientSecret; objAuthToken = new UserValidation(clientid, clientsecret ).CommonAuthentication(objAttr); if (objAuthToken.status_cd == "1") { objResponse = new UserValidation(clientid, clientsecret, objAuthToken.auth_token, objAttr.username ).SearchTaxpayer(gstin, action); return(objResponse); } else { objResponse.error = objAuthToken.error; return(objResponse); } } catch (Exception ex) { throw ex; } return(null); }
/// <summary> /// ExecuteGSTR2ARequestWithRetry /// </summary> /// <param name="request"></param> /// <returns></returns> public string ExecuteGSTR2ARequestWithRetry(Request request) { int remainingTries = Constants.MaxTrial; var exceptions = new List <Exception>(); string jsonRequest = new JavaScriptSerializer().Serialize(request); while (remainingTries > 0) { try { return(ExecuteGSTR2ARequest(request)); } catch (TimeoutException e) { exceptions.Add(e); } catch (CustomException cex) { exceptions.Add(cex); } catch (Exception ex) { var gstnResp = new GstnResponse(); gstnResp.status_cd = 0; gstnResp.username = request.Username; gstnResp.reqtoken = request.RequestToken; gstnResp.apiAction = request.ApiAction; gstnResp.error = new Error { error_cd = ex.Message.Split(':')[1].ToString(), message = ex.Message.ToString() }; return(JsonConvert.SerializeObject(gstnResp, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); //throw ex; } Thread.Sleep(Constants.DelayTrialms); remainingTries--; if (remainingTries == 0) //Circit breaker { //new Data.RequestData().InsertBacklogRequest(this._reqtoken, this._username, jsonRequest); } } throw new AggregateException("Could not process request. Will be re-attempt after some time", exceptions); }
public GstnResponse DownloadGstn() { string token = "a3850a97-3011-425a-8227-ff7d222c8f88_636376236940662300"; GstnResponse objGstnResponse = new GstnResponse(); UserBusiness objBusiness = new UserBusiness(); Attrbute objAttrbute = new Attrbute(); Blob objBlob = new Blob(); objGstnResponse = objBusiness.GetBlobConnectionByToken(token); return(objGstnResponse); }
public GstnResponse GetBlobConnectionByToken(string token) { UserData objData = new UserData(); Blob objBlob = new Blob(); GstnResponse objResponse = new GstnResponse(); //string response = "{\"username\":\"WeP.MH.2\",\"reqtoken\":\"6196546c-7e97-4d7b-8f48-9cb5638711e4_636373399124528642\",\"data\":\"8hanCrLzY9xGcGUzDmrgX99Y4gE45o+iOKSVcFVPZV/PXOVNODOdNk9sUwhEF2XVFyt+I+29MzPsD4FwtTmuzGQXtTcQkn2haUCYHn8ELqg=\",\"hmac\":\"i0zctLJMBiHknQfWKbmj9EAiCi8SxKNkCDVZBbLa/Is=\",\"status_cd\":1,\"rek\":\"mEt9TaWPIpiv9Qqf0A/O8fwI2VER+Pz50wZN/gsxx5mVw6sU+AiaO9wRbmJTrWds\",\"apiAction\":\"GSTR1_SaveGSTR1\",\"respBlobId\":0}"; //var results = JsonConvert.DeserializeObject<GstnResponse>(response); objBlob = objData.GetBlobConnectionByToken(token); var blobStorageRetry = new BlobWithRetry(objBlob.Connection, Constants.GstnResponseContainer , token, new Dictionary <string, string>(), objBlob.Id); objResponse = blobStorageRetry.DownloadGStnRespBlobRetry(); return(objResponse); //return null; }
//Others #region GetRespByTokenWithRetry /// <summary> /// GetRespByTokenWithRetry /// </summary> /// <param name="token"></param> /// <returns></returns> public GstnResponse GetRespByTokenWithRetry(string token) { GstnResponse objResponse = new GstnResponse(); UserBusiness objBusiness = new UserBusiness(); int remainingTries = Constants.MaxTrial; var exceptions = new List <Exception>(); string jsonRequest = new JavaScriptSerializer().Serialize(token); int sleeptime = 1; while (remainingTries > 0) { try { return(objBusiness.GetBlobConnectionByToken(token)); } catch (TimeoutException e) { exceptions.Add(e); } catch (CustomException cex) { exceptions.Add(cex); } catch (Exception ex) { exceptions.Add(ex); //throw ex; } Thread.Sleep(Constants.DelayTrialmsP1 * sleeptime); remainingTries--; sleeptime++; } throw new AggregateException("Could not process request. Will be re-attempt after some time, Token : " + token, exceptions); }
public GstnResponse DownloadGStnRespBlobRetry() { GstnResponse objGstnResponse = new GstnResponse(); int remainingTries = Constants.MaxBlobDownloadTrial; var exceptions = new List <Exception>(); while (remainingTries > 0) { try { return(objGstnResponse = DownloadGstnBlob()); } catch (TimeoutException e) { exceptions.Add(e); } catch (CustomException cex) { exceptions.Add(cex); } catch (Exception ex) { throw ex; } Thread.Sleep(Constants.DelayTrialms); remainingTries--; //if (remainingTries == 0) //Circit breaker //{ // new RequestData().InsertBacklogRequest(this._reqtoken, this._username, jsonAttribute); //} } throw new AggregateException("Could not process request for donload. Will be re-attempt after some time", exceptions); }
public ServiceResponse <GstnResponse> GetGSTR2AFileDetailsWithResponse() { var objResponse = new GstnResponse(); try { #region Headers var req = Request.Headers; _clientid = string.IsNullOrEmpty(req.GetValues("clientid").First()) ? null : req.GetValues("clientid").First(); _statecd = string.IsNullOrEmpty(req.GetValues("state-cd").First()) ? null : req.GetValues("state-cd").First(); _username = string.IsNullOrEmpty(req.GetValues("username").First()) ? null : req.GetValues("username").First(); _txn = string.IsNullOrEmpty(req.GetValues("txn").First()) ? null : req.GetValues("txn").First(); _clientSecret = string.IsNullOrEmpty(req.GetValues("client-secret").First()) ? null : req.GetValues("client-secret").First(); _ipUsr = string.IsNullOrEmpty(req.GetValues("ip-usr").First()) ? null : req.GetValues("ip-usr").First(); _authToken = string.IsNullOrEmpty(req.GetValues("auth-token").First()) ? null : req.GetValues("auth-token").First(); _gstin = string.IsNullOrEmpty(req.GetValues("gstin").First()) ? null : req.GetValues("gstin").First(); _ret_period = string.IsNullOrEmpty(req.GetValues("ret_period").First()) ? null : req.GetValues("ret_period").First(); objAttr.param_gstin = string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["gstin"].ToString()) ? null : HttpContext.Current.Request.QueryString["gstin"].ToString(); objAttr.param_ret_period = string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ret_period"].ToString()) ? null : HttpContext.Current.Request.QueryString["ret_period"].ToString(); objAttr.param_action = string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["action"].ToString()) ? null : HttpContext.Current.Request.QueryString["action"].ToString(); //objAttr.param_ref_id = string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ref_id"].ToString()) // ? null // : HttpContext.Current.Request.QueryString["ref_id"].ToString(); objAttr.param_token = string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["token"].ToString()) ? null : HttpContext.Current.Request.QueryString["token"].ToString(); objAttr.apiAction = string.IsNullOrEmpty(Constants.actionGSTR2A_GetFileDetails) ? null : Constants.actionGSTR2A_GetFileDetails; #endregion objResponse = new GSTR2ABusiness(this._clientid, this._statecd, this._username, this._txn, this._clientSecret, this._ipUsr, this._authToken, this._ret_period, this._gstin) .GetGSTR2AFileDetailsWithResponse(objAttr); var respone = new ServiceResponse <GstnResponse> { ResponseObject = objResponse, IsError = false }; return(respone); } catch (CustomException cex) { new ExceptionBusiness().InsertExceptionLog(this._username, cex.Message, Constants.actionGSTR2A_GetFileDetails, (int)Stage.GSTN_Req_API_Error); var response = new ServiceResponse <GstnResponse> { IsError = true, ExceptionObject = new ExceptionModel() { ErrorMessage = cex.Message, Source = cex.Source, KeyParameter = new[] { "ServiceError - GSP Server" } } }; return(response); } catch (Exception ex) { //Async write to Database new ExceptionBusiness().InsertExceptionLog(this._username, ex.Message, Constants.actionGSTR2A_GetFileDetails, (int)Stage.GSTN_Req_API_Error); var response = new ServiceResponse <GstnResponse> { IsError = true, ExceptionObject = new ExceptionModel() { ErrorMessage = ex.Message, Source = ex.Source, KeyParameter = new[] { "ServiceError - GSP Server" } } }; return(response); } }
public ServiceResponse <GstnResponse> GSTR3BRetOffset(Attrbute objAttr) { var objResponse = new GstnResponse(); try { #region Headers var req = Request.Headers; _clientid = string.IsNullOrEmpty(req.GetValues("clientid").First()) ? null : req.GetValues("clientid").First(); _statecd = string.IsNullOrEmpty(req.GetValues("state-cd").First()) ? null : req.GetValues("state-cd").First(); _username = string.IsNullOrEmpty(req.GetValues("username").First()) ? null : req.GetValues("username").First(); _txn = string.IsNullOrEmpty(req.GetValues("txn").First()) ? null : req.GetValues("txn").First(); _clientSecret = string.IsNullOrEmpty(req.GetValues("client-secret").First()) ? null : req.GetValues("client-secret").First(); _ipUsr = string.IsNullOrEmpty(req.GetValues("ip-usr").First()) ? null : req.GetValues("ip-usr").First(); _ret_period = string.IsNullOrEmpty(req.GetValues("ret_period").First()) ? null : req.GetValues("ret_period").First(); _gstin = string.IsNullOrEmpty(req.GetValues("gstin").First()) ? null : req.GetValues("gstin").First(); _authToken = string.IsNullOrEmpty(req.GetValues("auth-token").First()) ? null : req.GetValues("auth-token").First(); objAttr.apiAction = string.IsNullOrEmpty(Constants.actionGSTR3B_RetOffset) ? null : Constants.actionGSTR3B_RetOffset; #endregion objResponse = new GSTR3B_Business(this._clientid, this._statecd, this._username, this._txn, this._clientSecret, this._ipUsr, this._authToken, this._ret_period, this._gstin) .GSTR3BRetOffset(objAttr); var respone = new ServiceResponse <GstnResponse> { ResponseObject = objResponse, IsError = false }; return(respone); } catch (CustomException cex) { //Async write to Database new ExceptionBusiness().InsertExceptionLog(this._username, cex.Message, Constants.actionGSTR3B_RetOffset, (int)Stage.GSTN_Req_API_Error); var response = new ServiceResponse <GstnResponse> { IsError = true, ExceptionObject = new ExceptionModel() { ErrorMessage = cex.Message, Source = cex.Source, KeyParameter = new[] { "ServiceError - GSP Server" } } }; return(response); } catch (Exception ex) { //Async write to Database new ExceptionBusiness().InsertExceptionLog(this._username, ex.Message, Constants.actionGSTR3B_RetOffset, (int)Stage.GSTN_Req_API_Error); var response = new ServiceResponse <GstnResponse> { IsError = true, ExceptionObject = new ExceptionModel() { ErrorMessage = ex.Message, Source = ex.Source, KeyParameter = new[] { "ServiceError - GSP Server" } } }; return(response); } }