Ejemplo n.º 1
0
        public ApiResponse Success()
        {
            GeetestLib geetest = new GeetestLib(GeetestConfig.publicKey, GeetestConfig.privateKey);
            Byte       gt_server_status_code = (Byte)Context.Session[GeetestLib.gtServerStatusSessionKey];
            String     userID    = (String)Context.Session["sessionID"];
            int        result    = 0;
            String     challenge = Context.Request.Form.Get(GeetestLib.fnGeetestChallenge);
            String     validate  = Context.Request.Form.Get(GeetestLib.fnGeetestValidate);
            String     seccode   = Context.Request.Form.Get(GeetestLib.fnGeetestSeccode);

            if (gt_server_status_code == 1)
            {
                result = geetest.enhencedValidateRequest(challenge, validate, seccode, userID);
            }
            else
            {
                result = geetest.failbackValidateRequest(challenge, validate, seccode);
            }
            if (result == 1)
            {
                return(ResponseHelper.CreateApiResponse(10000, "验证码校验成功"));
            }
            else
            {
                return(ResponseHelper.CreateApiResponse(10001, "验证码校验失败"));
            }
        }
Ejemplo n.º 2
0
        public async Task <ApiResponse <NESInvoice> > Insert(NESInvoice nesInvoice)
        {
            var isValidNesVoice = Validator.IsValidNESInvoice(nesInvoice);

            if (!isValidNesVoice.Key)
            {
                return(ResponseHelper.CreateApiResponse <NESInvoice>(null, isValidNesVoice.Value, 400, true));
            }

            var connector = new DbConnector(_configuration.GetConnectionString("NilveraDb"));

            await connector.Insert <PartyInfo>("insert into PartyInfo(register_number,name,address,district,city,country) values(@RegisterNumber,"
                                               + "@Name,@Address,@District,@City,@Country)", new[] { nesInvoice.CustomerInfo });

            await connector.Insert <PartyInfo>("insert into PartyInfo(register_number,name,address,district,city,country) values(@RegisterNumber,"
                                               + "@Name,@Address,@District,@City,@Country)", new[] { nesInvoice.CompanyInfo });

            await connector.Insert <InvoiceInfo>("insert into InvoiceInfo(uuid,invoice_seri_or_number) values(@UUID,@InvoiceSerieOrNumber)",
                                                 new [] { nesInvoice.InvoiceInfo });

            if (nesInvoice.ExportCustomerInfo != null)
            {
                await connector.Insert <ExportCustomerInfo>("insert into ExportCustomerInfo(party_name,person_name) values(@PartyName,@PersonName)",
                                                            new [] { nesInvoice.ExportCustomerInfo });
            }

            await connector.Insert <object>("insert into NESInvoice(id,invoice_info_id,ise_archive_invoice,customer_info_id,company_info_id) values(@Id,@InvoiceInfoId," +
                                            "@IseArchive,@CustomerInfoId,@CompanyInfoId)", new [] {
                new { Id             = Guid.NewGuid().ToString(), InvoiceInfoId = nesInvoice.InvoiceInfo.UUID, IseArchive = nesInvoice.ISEArchiveInvoice,
                      CustomerInfoId = nesInvoice.CustomerInfo.RegisterNumber, CompanyInfoId = nesInvoice.CompanyInfo.RegisterNumber }
            });

            return(ResponseHelper.CreateApiResponse <NESInvoice>(default(NESInvoice), "Success", 201, false));
        }
Ejemplo n.º 3
0
        public ApiResponse GenerateCode()
        {
            Context.Response.ContentType = "application/json";
            GeetestLib geetest        = new GeetestLib(GeetestConfig.publicKey, GeetestConfig.privateKey);
            string     appKey         = System.Guid.NewGuid().ToString();
            Byte       gtServerStatus = geetest.preProcess(appKey);

            Context.Session[GeetestLib.gtServerStatusSessionKey] = gtServerStatus;
            Context.Session["sessionID"] = appKey;
            return(ResponseHelper.CreateApiResponse(10000, "success", geetest.getResponseStr()));
        }
Ejemplo n.º 4
0
        public async Task <ApiResponse <string> > ConsumeXml(string uuid)
        {
            string auth = GetHeaderTitle("authorization");

            if (string.IsNullOrEmpty(auth))
            {
                return(ResponseHelper.CreateApiResponse <string>("", "Authorization Denied!", 400, true));
            }

            var headers = new Dictionary <string, string>();

            headers.Add("content-type", "application/json");
            headers.Add("authorization", $"bearer {auth}");

            var remoteRequestModel = new RemoteApiRequest {
                Method = RestSharp.Method.GET, Route = $"invoicegeneral/ublXmlContent/{uuid}", Headers = headers, Parameters = null
            };
            var response = await ClientHelper.SendRequestForContent <string>(remoteRequestModel);

            return(response);
        }
Ejemplo n.º 5
0
        public async Task <ApiResponse <SendInvoiceResponse> > Send(NESInvoiceSendRequest request)
        {
            string auth = GetHeaderTitle("authorization");

            if (string.IsNullOrEmpty(auth))
            {
                return(ResponseHelper.CreateApiResponse <SendInvoiceResponse>(null, "Authorization Header Must Have", 400, true));
            }

            var headers = new Dictionary <string, string>();

            headers.Add("content-type", "application/json");
            headers.Add("authorization", auth);

            var parameters = ClientHelper.AddParameter(request);

            var remoteRequestModel = new RemoteApiRequest {
                Method = RestSharp.Method.POST, Route = "invoicegeneral/sendNESInvoice", Headers = headers, Parameters = parameters
            };

            return(await ClientHelper.SendRequest <SendInvoiceResponse>(remoteRequestModel));
        }