diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/Back/.config/dotnet-tools.json b/Back/.config/dotnet-tools.json new file mode 100644 index 0000000..b0e38ab --- /dev/null +++ b/Back/.config/dotnet-tools.json @@ -0,0 +1,5 @@ +{ + "version": 1, + "isRoot": true, + "tools": {} +} \ No newline at end of file diff --git a/Back/Back.csproj b/Back/Back.csproj index 6229a00..b100761 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -4,12 +4,15 @@ net8.0 enable enable + 3a1884b0-3dfb-48c8-8b55-fac6d02b8d35 + Linux + @@ -25,7 +28,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -36,10 +39,4 @@ - - - C:\Dlls\Service.dll - - - diff --git a/Back/Controllers/CustomerController.cs b/Back/Controllers/CustomerController.cs index 27556a6..4097096 100644 --- a/Back/Controllers/CustomerController.cs +++ b/Back/Controllers/CustomerController.cs @@ -4,7 +4,6 @@ using Back.Services; using Back.Validations; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Service; using Shared.DTOs; using System.Net; using System.Reflection.Emit; diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs index ae59eb9..95cdac8 100644 --- a/Back/Controllers/TaxPayerController.cs +++ b/Back/Controllers/TaxPayerController.cs @@ -6,18 +6,10 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json; -using Org.BouncyCastle.Asn1.Cmp; -using Org.BouncyCastle.Ocsp; -using Org.BouncyCastle.Utilities; + using Shared.DTOs; using Shared.DTOs.Serch; -using System; -using System.Security.Cryptography; -using TaxCollectData.Library.Dto.Content; -using TaxCollectData.Library.Dto.Transfer; using static Shared.DTOs._TaxPayer; -using static System.Collections.Specialized.BitVector32; namespace Back.Controllers { @@ -152,326 +144,326 @@ namespace Back.Controllers [HttpGet("SendInvoice/{InvoiceID}")] public async Task> SendInvoice(int InvoiceID) { - //return BadRequest(new List { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); + return BadRequest(new List { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); - var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); - var UserID = claim.Value; - var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); - if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) - return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); + //var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); + //var UserID = claim.Value; + //var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); + //if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) + // return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); - var result = await _servTaxPayer.GetInvoice(user.RolUsers.First().CompanyID, InvoiceID); - if (result == null) - return BadRequest(new List { "صورتحساب یافت نشد" }); + //var result = await _servTaxPayer.GetInvoice(user.RolUsers.First().CompanyID, InvoiceID); + //if (result == null) + // return BadRequest(new List { "صورتحساب یافت نشد" }); - else - { - if (!result.PatternID.HasValue) - return BadRequest(new List { "ابتدا برای این صورتحساب الگو در نظر بگیرید" }); + //else + //{ + // if (!result.PatternID.HasValue) + // return BadRequest(new List { "ابتدا برای این صورتحساب الگو در نظر بگیرید" }); - if (result.invoiceType == InvoiceType.Bidding) - return BadRequest(new List { "صورتحساب در وضعیت پیش نویس نمیتواند ارسال شود" }); + // if (result.invoiceType == InvoiceType.Bidding) + // return BadRequest(new List { "صورتحساب در وضعیت پیش نویس نمیتواند ارسال شود" }); - if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result)) - return BadRequest(new List { "این صورتحساب قبلا به سازمان ارسال شده" }); + // if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result)) + // return BadRequest(new List { "این صورتحساب قبلا به سازمان ارسال شده" }); - if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair) - && !result.BillReference.HasValue) - return BadRequest(new List { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع وجود داشته باشد" }); + // if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair) + // && !result.BillReference.HasValue) + // return BadRequest(new List { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع وجود داشته باشد" }); - if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair) - && !await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result.invoice)) - return BadRequest(new List { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" }); + // if ((result.invoiceType == InvoiceType.BackFrmSale || result.invoiceType == InvoiceType.Repair) + // && !await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(result.invoice)) + // return BadRequest(new List { "در وضعیت برگشت از فروش و اصلاحی باید صورتحساب مرجع به سامانه مودیان ارسال شده باشد" }); - if (result.invoiceType == InvoiceType.Cancellation && string.IsNullOrEmpty(result.taxid)) - { - return BadRequest(new List { "صورتحساب در وضعیت ابطالی باید صورتحساب مرجع آن به سامانه مودیان ارسال شده باشد" }); + // if (result.invoiceType == InvoiceType.Cancellation && string.IsNullOrEmpty(result.taxid)) + // { + // return BadRequest(new List { "صورتحساب در وضعیت ابطالی باید صورتحساب مرجع آن به سامانه مودیان ارسال شده باشد" }); - } - #region Inital Send - InvoiceHeaderDto header = new InvoiceHeaderDto(); - PreparationHeaderTaxInvoice preparation = new PreparationHeaderTaxInvoice(result, _actionTaxPayer); + // } + // #region Inital Send + // InvoiceHeaderDto header = new InvoiceHeaderDto(); + // PreparationHeaderTaxInvoice preparation = new PreparationHeaderTaxInvoice(result, _actionTaxPayer); - int level = result.pattern.ID; + // int level = result.pattern.ID; - //header - #region header - header = new InvoiceHeaderDto - { - //شماره منحصر به فرد مالیاتی - Taxid = preparation.Taxid, - //زمان صدور - Indatim = preparation.Indatim, - //زمان ایجاد - Indati2m = preparation.Indati2m, - // صورتحساب نوع * - Inty = preparation.Inty, - //سریال صورت حساب - Inno = preparation.Inno, - //شماره منحصر به فرد مالیاتی صورتحساب مرجع - Irtaxid = preparation.Irtaxid, - //الگوی صورتحساب * - Inp = preparation.Inp, - //موضوع صورتحساب * - Ins = preparation.Ins, - //شماره اقتصادی فروشنده به جاش شناسه ملی داده شد - Tins = preparation.Tins, - //نوع شخص خریدار - Tob = preparation.Tob, - //شماره/شناسه ملی/شناسه مشارکت مدنی / کد فراگیر - Bid = preparation.Bid, - //شماره اقتصادی خریدار - Tinb = preparation.Tinb, - //کد شعبه فروشنده - Sbc = preparation.Sbc, - //کد پستی خریدار - Bpc = preparation.Bpc, - //کد شعبه خریدار - Bbc = preparation.Bbc, - //نوع پرواز - Ft = preparation.Ft, - //شماره گذرنامه خریدار - Bpn = preparation.Bpn, - //شماره پروانه گمرکی - Scln = preparation.Scln, - //کد گمرک محل اظهار فروشنده - Scc = preparation.Scc, - //شماره کدتاژ اظهارنامه گمرکی - Cdcn = preparation.Cdcn, - //تاریخ کوتاژ اظهارنامه گمرکی - Cdcd = preparation.Cdcd, - //شناسه یکتای ثبت قزارداد فروشنده - Crn = preparation.Crn, - //شماره اشتراک/شناسه قبض بهره بردار - Billid = preparation.Billid, - //مجموع مبلغ قبل از کسر تخفیف - Tprdis = preparation.Tprdis, - //مجموع تخفیفات - Tdis = preparation.Tdis, - // مجموع مبلغ پس از کسر تخفیف - Tadis = preparation.Tadis, - //مجموع مالیات بر ارزش افزوده - Tvam = preparation.Tvam, - // مجموع سایر مالیات، عوارض و وجوه قانونی - Todam = preparation.Todam, - //صورتحساب مجموع - Tbill = preparation.Tbill, - //مجموع وزن خالض - Tonw = preparation.Tonw, - //مجموع ارزش ریالی - Torv = preparation.Torv, - //مجموع ارزش ارزی - Tocv = preparation.Tocv, - // تسویه روش - Setm = preparation.Setm, - //نقدی پرداختی مبلغ - Cap = preparation.Cap, - //پرداختی نسیه - Insp = preparation.Insp, - //مجموع سهم مالیات بر ارزش افزوده از پرداخت - Tvop = preparation.Tvop, - //مالیات موضوع 17 - Tax17 = preparation.Tax17, - //شماره اقتصادی آژانس - Tinc = preparation.Tinc, - //تاریخ اعلامیه فروش - Asd=null, - //شماره اعلامیه فروش - Asn = null, - //شماره ناوگان - Cno=null, - //شهر مقصد - Dci = null, - //کشور مقصد - Dco = null, - //کد ملی/ کد فراگیر اتباع غیر ایرانی راننده) در حمل و نقل جاده ای( - Did = null, - //شماره بارنامه - Lno = null, - //شماره بارنامه مرجع - Lrno = null, - //نوع بارنامه/ نوع حمل - Lt = null, - //شهر مبدا - Oci = null, - //کشور مبدا - Ocu = null, - //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی گیرنده - Rid = null, - //کالاهای حمل شده - Sg = new List(), - //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی / کد فراگیر اتباع غیر ایرانی فرستنده - Tid =null + // //header + // #region header + // header = new InvoiceHeaderDto + // { + // //شماره منحصر به فرد مالیاتی + // Taxid = preparation.Taxid, + // //زمان صدور + // Indatim = preparation.Indatim, + // //زمان ایجاد + // Indati2m = preparation.Indati2m, + // // صورتحساب نوع * + // Inty = preparation.Inty, + // //سریال صورت حساب + // Inno = preparation.Inno, + // //شماره منحصر به فرد مالیاتی صورتحساب مرجع + // Irtaxid = preparation.Irtaxid, + // //الگوی صورتحساب * + // Inp = preparation.Inp, + // //موضوع صورتحساب * + // Ins = preparation.Ins, + // //شماره اقتصادی فروشنده به جاش شناسه ملی داده شد + // Tins = preparation.Tins, + // //نوع شخص خریدار + // Tob = preparation.Tob, + // //شماره/شناسه ملی/شناسه مشارکت مدنی / کد فراگیر + // Bid = preparation.Bid, + // //شماره اقتصادی خریدار + // Tinb = preparation.Tinb, + // //کد شعبه فروشنده + // Sbc = preparation.Sbc, + // //کد پستی خریدار + // Bpc = preparation.Bpc, + // //کد شعبه خریدار + // Bbc = preparation.Bbc, + // //نوع پرواز + // Ft = preparation.Ft, + // //شماره گذرنامه خریدار + // Bpn = preparation.Bpn, + // //شماره پروانه گمرکی + // Scln = preparation.Scln, + // //کد گمرک محل اظهار فروشنده + // Scc = preparation.Scc, + // //شماره کدتاژ اظهارنامه گمرکی + // Cdcn = preparation.Cdcn, + // //تاریخ کوتاژ اظهارنامه گمرکی + // Cdcd = preparation.Cdcd, + // //شناسه یکتای ثبت قزارداد فروشنده + // Crn = preparation.Crn, + // //شماره اشتراک/شناسه قبض بهره بردار + // Billid = preparation.Billid, + // //مجموع مبلغ قبل از کسر تخفیف + // Tprdis = preparation.Tprdis, + // //مجموع تخفیفات + // Tdis = preparation.Tdis, + // // مجموع مبلغ پس از کسر تخفیف + // Tadis = preparation.Tadis, + // //مجموع مالیات بر ارزش افزوده + // Tvam = preparation.Tvam, + // // مجموع سایر مالیات، عوارض و وجوه قانونی + // Todam = preparation.Todam, + // //صورتحساب مجموع + // Tbill = preparation.Tbill, + // //مجموع وزن خالض + // Tonw = preparation.Tonw, + // //مجموع ارزش ریالی + // Torv = preparation.Torv, + // //مجموع ارزش ارزی + // Tocv = preparation.Tocv, + // // تسویه روش + // Setm = preparation.Setm, + // //نقدی پرداختی مبلغ + // Cap = preparation.Cap, + // //پرداختی نسیه + // Insp = preparation.Insp, + // //مجموع سهم مالیات بر ارزش افزوده از پرداخت + // Tvop = preparation.Tvop, + // //مالیات موضوع 17 + // Tax17 = preparation.Tax17, + // //شماره اقتصادی آژانس + // Tinc = preparation.Tinc, + // //تاریخ اعلامیه فروش + // Asd=null, + // //شماره اعلامیه فروش + // Asn = null, + // //شماره ناوگان + // Cno=null, + // //شهر مقصد + // Dci = null, + // //کشور مقصد + // Dco = null, + // //کد ملی/ کد فراگیر اتباع غیر ایرانی راننده) در حمل و نقل جاده ای( + // Did = null, + // //شماره بارنامه + // Lno = null, + // //شماره بارنامه مرجع + // Lrno = null, + // //نوع بارنامه/ نوع حمل + // Lt = null, + // //شهر مبدا + // Oci = null, + // //کشور مبدا + // Ocu = null, + // //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی/ کد فراگیر اتباع غیر ایرانی گیرنده + // Rid = null, + // //کالاهای حمل شده + // Sg = new List(), + // //شناسه ملی/ شماره ملی/ شناسه مشارکت مدنی / کد فراگیر اتباع غیر ایرانی فرستنده + // Tid =null - }; - #endregion header + // }; + // #endregion header - //body - List InvoiceBody = new List(); - foreach (var bitem in result.invoiceDetails) - { - InvoiceBodyDto item = new InvoiceBodyDto(); - PreparationBodyTaxInvoice preparationBody = new PreparationBodyTaxInvoice(bitem, level); - #region body + // //body + // List InvoiceBody = new List(); + // foreach (var bitem in result.invoiceDetails) + // { + // InvoiceBodyDto item = new InvoiceBodyDto(); + // PreparationBodyTaxInvoice preparationBody = new PreparationBodyTaxInvoice(bitem, level); + // #region body - item = new InvoiceBodyDto - { - //شناسه کالا / خدمت - Sstid = preparationBody.Sstid, - //شرح کاال/خدمت - Sstt = preparationBody.Sstt, - // تعداد - Am = preparationBody.Am, - //واحد اندازه گیری - Mu = preparationBody.Mu, - //وزن خالص - Nw= preparationBody.Nw, - // مبلغ واحد - Fee = preparationBody.Fee, - //میزان ارز - Cfee = preparationBody.Cfee , - //نوع ارز - Cut = preparationBody.Cut, - //نرخ برابری ارز با ریال - Exr = preparationBody.Exr, - // ارزش ریالی کاا - Ssrv= preparationBody.Ssrv, - // ارزش ارزی کاا - Sscv= preparationBody.Sscv, - //مبلغ قبل از تخفیف - Prdis = preparationBody.Prdis, - //مبلغ تخفیف - Dis = preparationBody.Dis, - //مبلغ بعد از تخفیف - Adis = preparationBody.Adis, - //نرخ مالیات بر ارزش افزوده - Vra = preparationBody.Vra, - //مبلغ مالیات بر ارزش افزوده - Vam = preparationBody.Vam, - //موضوع سایر مالیات و عوارض - Odt = preparationBody.Odt, - //نرخ سایر مالیات و عوارض - Odr = preparationBody.Odr, - //مبلغ سایر مالیات و عوارض - Odam = preparationBody.Odam, - //موضوع سایر وجوه قانونی - Olt = preparationBody.Olt, - //نرخ سایر وجوه قانونی - Olr = preparationBody.Olr, - //مبلغ سایر وجوه قانونی - Olam = preparationBody.Olam, - //اجرت ساخت - Consfee = preparationBody.Consfee, - // سود فروشنده - Spro= preparationBody.Spro, - //حقالعمل - Bros= preparationBody.Bros, - //جمع کل اجرت، حقالعمل و سود - Tcpbs= preparationBody.Tcpbs, - //سهم نقدی از پرداخت - Cop = preparationBody.Cop, - //سهم مالیات بر لرزش افزوده از پرداخت - Vop = preparationBody.Vop, - //شناسه یکتای ثبت قرارداد حق العمل کاری - Bsrn = preparationBody.Bsrn, - // مبلغ کل کالا / خدمت - Tsstam = preparationBody.Tsstam, - //عیار - Cui = preparationBody.Cui, - // نرخ خرید ارز - Cpr = preparationBody.Cpr, - //ماخذ مالیات بر ارزش افزوده در الگوی فروش ارز - Sovat = preparationBody.Sovat - }; - #endregion - InvoiceBody.Add(item); - } + // item = new InvoiceBodyDto + // { + // //شناسه کالا / خدمت + // Sstid = preparationBody.Sstid, + // //شرح کاال/خدمت + // Sstt = preparationBody.Sstt, + // // تعداد + // Am = preparationBody.Am, + // //واحد اندازه گیری + // Mu = preparationBody.Mu, + // //وزن خالص + // Nw= preparationBody.Nw, + // // مبلغ واحد + // Fee = preparationBody.Fee, + // //میزان ارز + // Cfee = preparationBody.Cfee , + // //نوع ارز + // Cut = preparationBody.Cut, + // //نرخ برابری ارز با ریال + // Exr = preparationBody.Exr, + // // ارزش ریالی کاا + // Ssrv= preparationBody.Ssrv, + // // ارزش ارزی کاا + // Sscv= preparationBody.Sscv, + // //مبلغ قبل از تخفیف + // Prdis = preparationBody.Prdis, + // //مبلغ تخفیف + // Dis = preparationBody.Dis, + // //مبلغ بعد از تخفیف + // Adis = preparationBody.Adis, + // //نرخ مالیات بر ارزش افزوده + // Vra = preparationBody.Vra, + // //مبلغ مالیات بر ارزش افزوده + // Vam = preparationBody.Vam, + // //موضوع سایر مالیات و عوارض + // Odt = preparationBody.Odt, + // //نرخ سایر مالیات و عوارض + // Odr = preparationBody.Odr, + // //مبلغ سایر مالیات و عوارض + // Odam = preparationBody.Odam, + // //موضوع سایر وجوه قانونی + // Olt = preparationBody.Olt, + // //نرخ سایر وجوه قانونی + // Olr = preparationBody.Olr, + // //مبلغ سایر وجوه قانونی + // Olam = preparationBody.Olam, + // //اجرت ساخت + // Consfee = preparationBody.Consfee, + // // سود فروشنده + // Spro= preparationBody.Spro, + // //حقالعمل + // Bros= preparationBody.Bros, + // //جمع کل اجرت، حقالعمل و سود + // Tcpbs= preparationBody.Tcpbs, + // //سهم نقدی از پرداخت + // Cop = preparationBody.Cop, + // //سهم مالیات بر لرزش افزوده از پرداخت + // Vop = preparationBody.Vop, + // //شناسه یکتای ثبت قرارداد حق العمل کاری + // Bsrn = preparationBody.Bsrn, + // // مبلغ کل کالا / خدمت + // Tsstam = preparationBody.Tsstam, + // //عیار + // Cui = preparationBody.Cui, + // // نرخ خرید ارز + // Cpr = preparationBody.Cpr, + // //ماخذ مالیات بر ارزش افزوده در الگوی فروش ارز + // Sovat = preparationBody.Sovat + // }; + // #endregion + // InvoiceBody.Add(item); + // } - //Pay - List InvoicePay = new List(); - if (result.setm==1 || result.setm == 3) - { - if (level != 10) - foreach (var pitem in result.payments) - { + // //Pay + // List InvoicePay = new List(); + // if (result.setm==1 || result.setm == 3) + // { + // if (level != 10) + // foreach (var pitem in result.payments) + // { - PaymentDto payment = new PaymentDto(); - payment = new PaymentDto - { - Iinn = pitem.iinn, - Acn = pitem.acn, - Trmn = pitem.trmn, - Pmt = pitem.pmt, - Trn = pitem.trn, - Pcn = pitem.pcn, - Pid = pitem.pid, - Pdt = pitem.pdt, - Pv = pitem.pv, + // PaymentDto payment = new PaymentDto(); + // payment = new PaymentDto + // { + // Iinn = pitem.iinn, + // Acn = pitem.acn, + // Trmn = pitem.trmn, + // Pmt = pitem.pmt, + // Trn = pitem.trn, + // Pcn = pitem.pcn, + // Pid = pitem.pid, + // Pdt = pitem.pdt, + // Pv = pitem.pv, - }; + // }; - InvoicePay.Add(payment); - } - } + // InvoicePay.Add(payment); + // } + // } - var responseModel = await _actionTaxPayer.SendInvoice(user.RolUsers.First().CompanyID, header, InvoiceBody, InvoicePay); - if (responseModel == null) - { - return BadRequest(new List { "خطا در ورود به سامانه مودیان" }); - } - else if (responseModel.Status == 200 && (responseModel.Body.Errors == null || responseModel.Body.Errors.Count == 0)) - { - foreach (var item in responseModel.Body.Result) - { + // var responseModel = await _actionTaxPayer.SendInvoice(user.RolUsers.First().CompanyID, header, InvoiceBody, InvoicePay); + // if (responseModel == null) + // { + // return BadRequest(new List { "خطا در ورود به سامانه مودیان" }); + // } + // else if (responseModel.Status == 200 && (responseModel.Body.Errors == null || responseModel.Body.Errors.Count == 0)) + // { + // foreach (var item in responseModel.Body.Result) + // { - var ressenttax = new SentTax - { - InvoiceID = result.ID, - Date = DateTime.Now.ConvertMiladiToShamsi(), - Time = $"{DateTime.Now.Hour}:{DateTime.Now.Minute}:{DateTime.Now.Second}", - InvoiceType = result.invoiceType, - ReferenceNumber = item.ReferenceNumber, - uId = item.Uid, - SentStatus = SentStatus.Send, - InvoiceModel = JsonConvert.SerializeObject(result, Formatting.Indented, new JsonSerializerSettings - { - PreserveReferencesHandling = PreserveReferencesHandling.Objects - }), - ResponseModel = JsonConvert.SerializeObject(responseModel) + // var ressenttax = new SentTax + // { + // InvoiceID = result.ID, + // Date = DateTime.Now.ConvertMiladiToShamsi(), + // Time = $"{DateTime.Now.Hour}:{DateTime.Now.Minute}:{DateTime.Now.Second}", + // InvoiceType = result.invoiceType, + // ReferenceNumber = item.ReferenceNumber, + // uId = item.Uid, + // SentStatus = SentStatus.Send, + // InvoiceModel = JsonConvert.SerializeObject(result, Formatting.Indented, new JsonSerializerSettings + // { + // PreserveReferencesHandling = PreserveReferencesHandling.Objects + // }), + // ResponseModel = JsonConvert.SerializeObject(responseModel) - }; - await _servTaxPayer.AddSentTax(ressenttax); - } - result.taxid = header.Taxid; - result.irtaxid = header.Irtaxid; - return Ok(await _servTaxPayer.UpdateInvoice(result)); - } - else - { - string errors = ""; - foreach (var item in responseModel.Body.Errors) - errors += '\n' + $"{item.ErrorCode}:{item.Detail}"; + // }; + // await _servTaxPayer.AddSentTax(ressenttax); + // } + // result.taxid = header.Taxid; + // result.irtaxid = header.Irtaxid; + // return Ok(await _servTaxPayer.UpdateInvoice(result)); + // } + // else + // { + // string errors = ""; + // foreach (var item in responseModel.Body.Errors) + // errors += '\n' + $"{item.ErrorCode}:{item.Detail}"; - return BadRequest(new List { errors }); - } + // return BadRequest(new List { errors }); + // } - #endregion + // #endregion - } + //} } [HttpPost("GetAllSentTax")] public async Task>> GetSentTax([FromBody] ItemSerchGetSentTax item) @@ -484,88 +476,90 @@ namespace Back.Controllers [HttpGet("GetResult/{ID}")] public async Task> GetResultByUid(int ID) { - try - { - var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); - var UserID = claim.Value; - var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); - var item = await _servTaxPayer.GetSentTax(user.RolUsers.First().CompanyID, ID); - if (item == null) - return BadRequest(new List { "یافت نشد" }); + return BadRequest(new List { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); - if (string.IsNullOrEmpty(item.uId)) - return BadRequest(new List { "کد پیگیری یافت نشد" }); + //try + //{ + // var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); + // var UserID = claim.Value; + // var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); + // var item = await _servTaxPayer.GetSentTax(user.RolUsers.First().CompanyID, ID); + // if (item == null) + // return BadRequest(new List { "یافت نشد" }); - if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) - return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); + // if (string.IsNullOrEmpty(item.uId)) + // return BadRequest(new List { "کد پیگیری یافت نشد" }); - DataInSendTaxDto desData = new DataInSendTaxDto(); + // if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) + // return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); + + // DataInSendTaxDto desData = new DataInSendTaxDto(); - if (item.SentStatus == SentStatus.Unsuccessful && !string.IsNullOrEmpty(item.ErrorsModel)) - { - List inquiryerrorResult = JsonConvert.DeserializeObject>(item.ErrorsModel); + // if (item.SentStatus == SentStatus.Unsuccessful && !string.IsNullOrEmpty(item.ErrorsModel)) + // { + // List inquiryerrorResult = JsonConvert.DeserializeObject>(item.ErrorsModel); - InquiryResultModel inquiryResult = JsonConvert.DeserializeObject(item.InquiryResultModel); - if (inquiryResult.Data != null) - { + // InquiryResultModel inquiryResult = JsonConvert.DeserializeObject(item.InquiryResultModel); + // if (inquiryResult.Data != null) + // { - desData = new DataInSendTaxDto(); - desData.SentStatus = SentStatus.Unsuccessful; - desData.error = inquiryerrorResult; + // desData = new DataInSendTaxDto(); + // desData.SentStatus = SentStatus.Unsuccessful; + // desData.error = inquiryerrorResult; - } - return Ok(desData); - } - else if (item.SentStatus == SentStatus.Send - || item.SentStatus == SentStatus.pending - || item.SentStatus == SentStatus.IN_PROGRESS - || item.SentStatus == SentStatus.Unsuccessful) - { + // } + // return Ok(desData); + // } + // else if (item.SentStatus == SentStatus.Send + // || item.SentStatus == SentStatus.pending + // || item.SentStatus == SentStatus.IN_PROGRESS + // || item.SentStatus == SentStatus.Unsuccessful) + // { - //ta imja - var result = await _actionTaxPayer.GetResultByUid(user.RolUsers.First().CompanyID, item.uId); - if (result == null) - return BadRequest(new List { "پاسخی از سازمان دریافت نشد" }); + // //ta imja + // var result = await _actionTaxPayer.GetResultByUid(user.RolUsers.First().CompanyID, item.uId); + // if (result == null) + // return BadRequest(new List { "پاسخی از سازمان دریافت نشد" }); - else - { - item.InquiryResultModel = JsonConvert.SerializeObject(result); - if (result.Data != null) - { - desData = JsonConvert.DeserializeObject(result.Data.ToString()); - if (desData == null) - { - desData = new DataInSendTaxDto(); - desData.error = JsonConvert.DeserializeObject>(result.Data.ToString()); - } - } + // else + // { + // item.InquiryResultModel = JsonConvert.SerializeObject(result); + // if (result.Data != null) + // { + // desData = JsonConvert.DeserializeObject(result.Data.ToString()); + // if (desData == null) + // { + // desData = new DataInSendTaxDto(); + // desData.error = JsonConvert.DeserializeObject>(result.Data.ToString()); + // } + // } - desData.SentStatus = item.SentStatus = - result.Status == "FAILED" ? SentStatus.Unsuccessful - : result.Status == "PENDING" ? SentStatus.pending - : result.Status == "SUCCESS" ? SentStatus.Successful - : result.Status == "NOT_FOUND" ? SentStatus.NOT_FOUND - : result.Status == "IN_PROGRESS" ? SentStatus.IN_PROGRESS - : SentStatus.Unknown; + // desData.SentStatus = item.SentStatus = + // result.Status == "FAILED" ? SentStatus.Unsuccessful + // : result.Status == "PENDING" ? SentStatus.pending + // : result.Status == "SUCCESS" ? SentStatus.Successful + // : result.Status == "NOT_FOUND" ? SentStatus.NOT_FOUND + // : result.Status == "IN_PROGRESS" ? SentStatus.IN_PROGRESS + // : SentStatus.Unknown; - if (item.SentStatus == SentStatus.Unsuccessful) - item.ErrorsModel = JsonConvert.SerializeObject(desData.error); - } + // if (item.SentStatus == SentStatus.Unsuccessful) + // item.ErrorsModel = JsonConvert.SerializeObject(desData.error); + // } - if (await _servTaxPayer.UpdateSentTax(item)) return Ok(desData); + // if (await _servTaxPayer.UpdateSentTax(item)) return Ok(desData); - else return BadRequest(new List { "خطای در ذخیره سازی" }); - } - return BadRequest(new List { "در این وضعیت امکان پذیر نمی باشد" }); - } - catch (Exception ex) - { - return BadRequest(new List { "خطای ناشناخته" }); - } + // else return BadRequest(new List { "خطای در ذخیره سازی" }); + // } + // return BadRequest(new List { "در این وضعیت امکان پذیر نمی باشد" }); + //} + //catch (Exception ex) + //{ + // return BadRequest(new List { "خطای ناشناخته" }); + //} } [HttpGet("GetBillTypes")] public async Task>>> GetBillTypes() @@ -585,26 +579,30 @@ namespace Back.Controllers [HttpGet("EconomicCodeInformation")] public async Task> GetEconomicCodeInformation(string item) { - var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); - var UserID = claim.Value; - var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); - if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) - return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); - var result=await _actionTaxPayer.GetEconomicCodeInformation(item); - if (result == null) return NotFound(); - return Ok(result); + return BadRequest(new List { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); + + //var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); + //var UserID = claim.Value; + //var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); + //if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) + // return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); + //var result=await _actionTaxPayer.GetEconomicCodeInformation(item); + //if (result == null) return NotFound(); + //return Ok(result); } [HttpGet("FiscalInformation")] public async Task> GetFiscalInformation(string item) { - var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); - var UserID = claim.Value; - var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); - if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) - return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); - var result=await _actionTaxPayer.GetFiscalInformation(item); - if (result == null) return NotFound(); - return Ok(result); + return BadRequest(new List { "در حال حاضر سامانه مودیان در دسترس نمی باشد" }); + + //var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); + //var UserID = claim.Value; + //var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); + //if (!await _actionTaxPayer.login(user.RolUsers.First().CompanyID)) + // return BadRequest(new List { "خطا در احراز هویت سازمان مالیاتی" }); + //var result=await _actionTaxPayer.GetFiscalInformation(item); + //if (result == null) return NotFound(); + //return Ok(result); } [HttpGet("CodInTaxPayerHaveBeenSentSuccessfully/{CODID}")] public async Task> CodInTaxPayerHaveBeenSentSuccessfully(int CODID) diff --git a/Back/Controllers/stuffController.cs b/Back/Controllers/stuffController.cs index 06e4862..85fa83f 100644 --- a/Back/Controllers/stuffController.cs +++ b/Back/Controllers/stuffController.cs @@ -3,7 +3,6 @@ using Back.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json; using Shared.DTOs; using Shared.DTOs.Serch; diff --git a/Back/Data/Models/Invoice.cs b/Back/Data/Models/Invoice.cs index ac0595b..4d62533 100644 --- a/Back/Data/Models/Invoice.cs +++ b/Back/Data/Models/Invoice.cs @@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; using Back.Common; using Shared.DTOs; -using TaxCollectData.Library.Dto.Content; namespace Back.Data.Models { public class Invoice : ICloneable diff --git a/Back/DockerCommand.txt b/Back/DockerCommand.txt new file mode 100644 index 0000000..4b964a9 --- /dev/null +++ b/Back/DockerCommand.txt @@ -0,0 +1,15 @@ + from run E:\TaxPayerFULL + + docker build -f back\Dockerfile -t api_moadiran . +docker run --name api_moadiran -d -p 3201:8080 api_moadiran + + یکی از مشکلات این پروژه یکی کنابخانه سامانه مودیان بود که وقتی خود کنابخانه رو ریختیم کنار پروژه و در داکزفایل آدرسشو دادیم درست شد ولی ما کلا حذفش کردیم + یکی هم taxtools بود که اونم باید میومد کنار پروؤه ولی ما فعلا خذفش کردیم + + کلا داکر نمیتونه به درایو ها دسترسی داشته باشه همه چی باید در خود پروژه باشه + + -------------------------------------------------------------------------------------------- + in local => docker build -f back\Dockerfile -t mmrbnjd/api_moadiran:latest . + in local => docker push mmrbnjd/api_moadiran:latest + in server => docker pull mmrbnjd/api_moadiran:latest + in server => docker run -d -p 3201:8080 --restart always mmrbnjd/api_moadiran:latest diff --git a/Back/Dockerfile b/Back/Dockerfile new file mode 100644 index 0000000..ec3500f --- /dev/null +++ b/Back/Dockerfile @@ -0,0 +1,30 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +WORKDIR /app +EXPOSE 8080 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src + +# کپی csproj ها +COPY Back/Back.csproj Back/ +COPY Shared/Shared.csproj Shared/ + +# کپی کردن سورس لوکال و NuGet.config (از داخل Back) +#COPY Back/NuGet.config ./ +#COPY Back/LocalPackages ./LocalPackages + +RUN dotnet restore "./Back/Back.csproj" + +COPY . . +WORKDIR "/src/Back" +RUN dotnet build "./Back.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./Back.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Back.dll"] diff --git a/Back/Features/IgnorePropertiesResolver.cs b/Back/Features/IgnorePropertiesResolver.cs index 2334787..53681ca 100644 --- a/Back/Features/IgnorePropertiesResolver.cs +++ b/Back/Features/IgnorePropertiesResolver.cs @@ -1,25 +1,24 @@ -using Newtonsoft.Json.Serialization; -using Newtonsoft.Json; + using System.Reflection; namespace Back.Features { - public class IgnorePropertiesResolver : DefaultContractResolver - { - private readonly HashSet ignoreProps; - public IgnorePropertiesResolver(IEnumerable propNamesToIgnore) - { - this.ignoreProps = new HashSet(propNamesToIgnore); - } + //public class IgnorePropertiesResolver : DefaultContractResolver + //{ + // private readonly HashSet ignoreProps; + // public IgnorePropertiesResolver(IEnumerable propNamesToIgnore) + // { + // this.ignoreProps = new HashSet(propNamesToIgnore); + // } - protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) - { - JsonProperty property = base.CreateProperty(member, memberSerialization); - if (this.ignoreProps.Contains(property.PropertyName)) - { - property.ShouldSerialize = _ => false; - } - return property; - } - } + // protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) + // { + // JsonProperty property = base.CreateProperty(member, memberSerialization); + // if (this.ignoreProps.Contains(property.PropertyName)) + // { + // property.ShouldSerialize = _ => false; + // } + // return property; + // } + //} } diff --git a/Back/NuGet.config b/Back/NuGet.config new file mode 100644 index 0000000..6a8893a --- /dev/null +++ b/Back/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Back/Program.cs b/Back/Program.cs index c05c32b..782c9c0 100644 --- a/Back/Program.cs +++ b/Back/Program.cs @@ -55,7 +55,7 @@ builder.Services.AddScoped(typeof(IAsyncRepository<>), typeof(RepositoryBase<>)) builder.Services.AddScoped(typeof(RepositoryBase<>), typeof(RepositoryBase<>)); builder.Services.AddScoped(); builder.Services.AddScoped (); -builder.Services.AddScoped(); +//builder.Services.AddScoped(); builder.Services.AddScoped (); builder.Services.AddScoped(); builder.Services.AddScoped (); @@ -104,10 +104,11 @@ builder.Services.AddCors(options => options.AddPolicy(origins, policy => { - policy.WithOrigins("https://localhost:7224", "http://localhost:5107" - , "http://195.88.208.142", "http://moadiran.ir" - , "https://195.88.208.142", "https://moadiran.ir" - , "https://195.88.208.142:440", "https://moadiran.ir:440", "https://localhost:44346") + policy.AllowAnyOrigin() + //.WithOrigins("https://localhost:7224", "http://localhost:5107" + // , "http://195.88.208.142", "http://moadiran.ir" + // , "https://195.88.208.142", "https://moadiran.ir" + //, "https://195.88.208.142:440", "https://moadiran.ir:440", "https://localhost:44346") .AllowAnyHeader() .WithHeaders(HeaderNames.ContentType) .AllowAnyMethod(); @@ -135,7 +136,7 @@ builder.Services.AddAuthentication("Bearer") var app = builder.Build(); // Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) +if (true || app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); diff --git a/Back/Properties/launchSettings.json b/Back/Properties/launchSettings.json index aaf6d00..9b01a7b 100644 --- a/Back/Properties/launchSettings.json +++ b/Back/Properties/launchSettings.json @@ -27,6 +27,17 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true } }, "$schema": "http://json.schemastore.org/launchsettings.json", diff --git a/Back/Services/ActionTaxPayer.cs b/Back/Services/ActionTaxPayer.cs index f17a60a..8841b3d 100644 --- a/Back/Services/ActionTaxPayer.cs +++ b/Back/Services/ActionTaxPayer.cs @@ -1,13 +1,8 @@ using Back.Common; using Microsoft.IdentityModel.Tokens; -using Newtonsoft.Json; + using Shared.DTOs; -using TaxCollectData.Library.Business; -using TaxCollectData.Library.Dto.Config; -using TaxCollectData.Library.Dto.Content; -using TaxCollectData.Library.Dto.Properties; -using TaxCollectData.Library.Dto.Transfer; -using TaxCollectData.Library.Enums; + namespace Back.Services { @@ -26,77 +21,77 @@ namespace Back.Services public string GenerateTaxid(string FactorNo, string InvoiceDate) { - //return "testTaxid"; - return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory, - Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi()); + return "testTaxid"; + //return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory, + // Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi()); } - public async Task GetResultByUid(int CompanyID, string uid) - { + //public async Task GetResultByUid(int CompanyID, string uid) + //{ - var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory); - var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId }); - if (inquiryResultModels.Count > 0) - return inquiryResultModels[0]; - return null; - } - public async Task> SendInvoice(int CompanyID,InvoiceHeaderDto header, List InvoiceBody, List payments) - { - return await TaxApiService.Instance.TaxApis.SendInvoicesAsync(new List() - { - new() - { - Header =header,Body =InvoiceBody,Payments = payments - } - } - , null); - } - public async Task GetEconomicCodeInformation(string Item) - { + // var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory); + // var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId }); + // if (inquiryResultModels.Count > 0) + // return inquiryResultModels[0]; + // return null; + //} + //public async Task> SendInvoice(int CompanyID,InvoiceHeaderDto header, List InvoiceBody, List payments) + //{ + // return await TaxApiService.Instance.TaxApis.SendInvoicesAsync(new List() + // { + // new() + // { + // Header =header,Body =InvoiceBody,Payments = payments + // } + // } + // , null); + //} + //public async Task GetEconomicCodeInformation(string Item) + //{ - return await TaxApiService.Instance.TaxApis.GetEconomicCodeInformationAsync(Item); + // return await TaxApiService.Instance.TaxApis.GetEconomicCodeInformationAsync(Item); - } - public async Task GetFiscalInformation(string Item) - { - return await TaxApiService.Instance.TaxApis.GetFiscalInformationAsync(Item); - } + //} + //public async Task GetFiscalInformation(string Item) + //{ + // return await TaxApiService.Instance.TaxApis.GetFiscalInformationAsync(Item); + //} //-------------------internal public async Task login(int CompanyID) { + return false; + //try + //{ + // #region TokenTax + // var resquth = await _servCompany.GetTaxAuth(CompanyID); + // if (string.IsNullOrEmpty(resquth.UniqueMemory) || string.IsNullOrEmpty(resquth.PrivateKey)) + // return false; - try - { - #region TokenTax - var resquth = await _servCompany.GetTaxAuth(CompanyID); - if (string.IsNullOrEmpty(resquth.UniqueMemory) || string.IsNullOrEmpty(resquth.PrivateKey)) - return false; - - if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey)) - { + // if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey)) + // { - //string taxapi = _configuration.GetSection("TaxPayerApi").Value; - string taxapi = "https://sandboxrc.tax.gov.ir/req/api/"; - _UniqueMemory = resquth.UniqueMemory; - _PrivateKey = resquth.PrivateKey; - TaxApiService.Instance.Init(_UniqueMemory, - new SignatoryConfig(_PrivateKey, null), - new NormalProperties(ClientType.SELF_TSP), taxapi); - await TaxApiService.Instance.TaxApis.GetServerInformationAsync(); - } - #endregion + // //string taxapi = _configuration.GetSection("TaxPayerApi").Value; + // string taxapi = "https://sandboxrc.tax.gov.ir/req/api/"; + // _UniqueMemory = resquth.UniqueMemory; + // _PrivateKey = resquth.PrivateKey; + // TaxApiService.Instance.Init(_UniqueMemory, + // new SignatoryConfig(_PrivateKey, null), + // new NormalProperties(ClientType.SELF_TSP), taxapi); + // await TaxApiService.Instance.TaxApis.GetServerInformationAsync(); + // } + // #endregion - if (TaxApiService.Instance.TaxApis.GetToken() is null) - { - if (await TaxApiService.Instance.TaxApis.RequestTokenAsync() == null) - return false; - } - return true; - } - catch (Exception) - { - return false; - } + // if (TaxApiService.Instance.TaxApis.GetToken() is null) + // { + // if (await TaxApiService.Instance.TaxApis.RequestTokenAsync() == null) + // return false; + // } + // return true; + //} + //catch (Exception) + //{ + // return false; + //} } diff --git a/Back/Services/ServBase.cs b/Back/Services/ServBase.cs index 30dc617..4ed5a31 100644 --- a/Back/Services/ServBase.cs +++ b/Back/Services/ServBase.cs @@ -16,15 +16,15 @@ namespace Back.Services private readonly IAsyncRepository _repoBlog; private readonly IAsyncRepository _repoQuestion; private readonly IAsyncRepository _repoSaleLead; - private readonly Service.Main _Taxtools; + // private readonly Service.Main _Taxtools; public ServBase(IAsyncRepository repoPricing, IAsyncRepository repoBlog, IAsyncRepository repoQuestion - , Service.Main taxtools, IAsyncRepository repoSaleLead) + /* , Service.Main taxtools*/, IAsyncRepository repoSaleLead) { _repoPricing = repoPricing; _repoBlog = repoBlog; _repoQuestion = repoQuestion; - _Taxtools = taxtools; + // _Taxtools = taxtools; _repoSaleLead = repoSaleLead; } public async Task> GetBasePrice() @@ -89,63 +89,63 @@ namespace Back.Services public async Task CreateCsrAndPrivateKey(CsrPrivateKeyDto model) { TaxToolsDTO taxTools = null; - List values = new List() - { - new Service.PrmValue(){Prm="CN",Value=model.cn}, - new Service.PrmValue(){Prm="serialNumber",Value=model.sn}, - new Service.PrmValue(){Prm="O",Value="Non-Governmental"}, - new Service.PrmValue(){Prm="3.OU",Value=model.company}, - new Service.PrmValue(){Prm="2.OU",Value=model.company}, - new Service.PrmValue(){Prm="1.OU",Value=model.company}, - new Service.PrmValue(){Prm="C",Value="IR"}, - }; - string msg = ""; - if (_Taxtools.CraeteCnfFile(values, ref msg)) - { - if (_Taxtools.CreateCsrAndPrivateKey(model.cn, ref msg)) - { - taxTools = new TaxToolsDTO(); - //خواندن - Stream stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.Csr", FileMode.Open); - byte[] buffer = new byte[stream.Length]; - stream.Read(buffer, 0, (int)stream.Length); - string csr = Encoding.UTF8.GetString(buffer); - stream.Flush(); - stream.Close(); - taxTools.Base64csr = Convert.ToBase64String(buffer); - taxTools.typecsr = "Csr"; - stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.key", FileMode.Open); - buffer = new byte[stream.Length]; - stream.Read(buffer, 0, (int)stream.Length); - string key = Encoding.UTF8.GetString(buffer); - taxTools.Base64key = Convert.ToBase64String(buffer); - taxTools.typekey = "key"; - stream.Flush(); - stream.Close(); + //List values = new List() + //{ + // new Service.PrmValue(){Prm="CN",Value=model.cn}, + // new Service.PrmValue(){Prm="serialNumber",Value=model.sn}, + // new Service.PrmValue(){Prm="O",Value="Non-Governmental"}, + // new Service.PrmValue(){Prm="3.OU",Value=model.company}, + // new Service.PrmValue(){Prm="2.OU",Value=model.company}, + // new Service.PrmValue(){Prm="1.OU",Value=model.company}, + // new Service.PrmValue(){Prm="C",Value="IR"}, + //}; + //string msg = ""; + //if (_Taxtools.CraeteCnfFile(values, ref msg)) + //{ + // if (_Taxtools.CreateCsrAndPrivateKey(model.cn, ref msg)) + // { + // taxTools = new TaxToolsDTO(); + // //خواندن + // Stream stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.Csr", FileMode.Open); + // byte[] buffer = new byte[stream.Length]; + // stream.Read(buffer, 0, (int)stream.Length); + // string csr = Encoding.UTF8.GetString(buffer); + // stream.Flush(); + // stream.Close(); + // taxTools.Base64csr = Convert.ToBase64String(buffer); + // taxTools.typecsr = "Csr"; + // stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.key", FileMode.Open); + // buffer = new byte[stream.Length]; + // stream.Read(buffer, 0, (int)stream.Length); + // string key = Encoding.UTF8.GetString(buffer); + // taxTools.Base64key = Convert.ToBase64String(buffer); + // taxTools.typekey = "key"; + // stream.Flush(); + // stream.Close(); - //_contextMongodb.InsertItem(new SysLog() - //{ - // TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier, - // Datetime = DateTime.Now.ConvertMiladiToShamsi(), - // Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/CreateCsrAndPrivateKey", - // Value = JsonConvert.SerializeObject(model), - // Route = _httpContextAccessor.HttpContext.Request.Path, - // Type = "User" - //}); - await _repoSaleLead.AddAsync(new SaleLead - { - cn = model.cn, - company = model.company, - csr = csr, - Key = key, - Mobile = model.Mobile, - sn = model.sn - }); - } + // //_contextMongodb.InsertItem(new SysLog() + // //{ + // // TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier, + // // Datetime = DateTime.Now.ConvertMiladiToShamsi(), + // // Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/CreateCsrAndPrivateKey", + // // Value = JsonConvert.SerializeObject(model), + // // Route = _httpContextAccessor.HttpContext.Request.Path, + // // Type = "User" + // //}); + // await _repoSaleLead.AddAsync(new SaleLead + // { + // cn = model.cn, + // company = model.company, + // csr = csr, + // Key = key, + // Mobile = model.Mobile, + // sn = model.sn + // }); + // } - } + //} - if (string.IsNullOrEmpty(msg)) + // if (string.IsNullOrEmpty(msg)) { //_contextMongodb.InsertItem(new SysLog() //{ diff --git a/Back/Services/servUser.cs b/Back/Services/servUser.cs index ebbd0d9..b529aa8 100644 --- a/Back/Services/servUser.cs +++ b/Back/Services/servUser.cs @@ -4,7 +4,6 @@ using Back.Data.Infrastructure.Repository; using Back.Data.Models; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; -using Org.BouncyCastle.Crypto.Tls; using Shared.DTOs; using System.ComponentModel.Design; using System.Data.SqlTypes; diff --git a/Back/Validations/AddOrUpdateInvoiceValidation.cs b/Back/Validations/AddOrUpdateInvoiceValidation.cs index b4c424a..99f3a42 100644 --- a/Back/Validations/AddOrUpdateInvoiceValidation.cs +++ b/Back/Validations/AddOrUpdateInvoiceValidation.cs @@ -5,7 +5,6 @@ using Back.Services; using FluentValidation; using Microsoft.EntityFrameworkCore; using Shared.DTOs; -using TaxCollectData.Library.Dto.Content; namespace Back.Validations { diff --git a/Back/Validations/TaxSystemRules.cs b/Back/Validations/TaxSystemRules.cs index 450289c..0479532 100644 --- a/Back/Validations/TaxSystemRules.cs +++ b/Back/Validations/TaxSystemRules.cs @@ -1,9 +1,8 @@ using FluentValidation; -using TaxCollectData.Library.Dto.Content; namespace Back.Validations { - public class TaxSystemRules : AbstractValidator, PaymentDto>> - { - } + //public class TaxSystemRules : AbstractValidator, PaymentDto>> + //{ + //} } diff --git a/Back/Validations/Warehouse/Receipt/ADDValidation.cs b/Back/Validations/Warehouse/Receipt/ADDValidation.cs index 725a409..e4b5b1e 100644 --- a/Back/Validations/Warehouse/Receipt/ADDValidation.cs +++ b/Back/Validations/Warehouse/Receipt/ADDValidation.cs @@ -1,7 +1,6 @@ using Back.Data.Contracts; using FluentValidation; using Shared.DTOs.Warehouse; -using Net.Pkcs11Interop.Common; using Back.Services; using Back.Data.Models; using Back.Common; diff --git a/Back/appsettings.json b/Back/appsettings.json index b8fd607..11d0648 100644 --- a/Back/appsettings.json +++ b/Back/appsettings.json @@ -6,5 +6,14 @@ } }, "AllowedHosts": "*", - "TaxPayerApi": "https://tp.tax.gov.ir/req/api/" + "TaxPayerApi": "https://tp.tax.gov.ir/req/api/", + "ConnectionStrings": { + "Base": "Data Source=195.88.208.142;Initial Catalog=TaxPayer020713;User ID=sa;Password=M439610m@;TrustServerCertificate=True" + + }, + "Fixedvalues": { + "Jwt_Lifetime_Minutes": "144000" + }, + "CreateReportFileName": "E:\\CreateReport\\CreateReport.exe", + "ReportLog": "E:\\Report\\log.txt" } diff --git a/TaxPayerFull/DockerCommand.txt b/TaxPayerFull/DockerCommand.txt new file mode 100644 index 0000000..170e838 --- /dev/null +++ b/TaxPayerFull/DockerCommand.txt @@ -0,0 +1,10 @@ + from run E:\TaxPayerFULL + docker build -f TaxPayerFULL\Dockerfile -t app_moadiran . + docker run --name app_moadiran -d -p 82:5107 app_moadiran + + + -------------------------------------------------------------------------------------------- + in local => docker build -f TaxPayerFULL\Dockerfile -t mmrbnjd/app_moadiran:latest . + in local => docker push mmrbnjd/app_moadiran:latest + in server => docker pull mmrbnjd/app_moadiran:latest + in server => docker run -d -p 3102:5107 --restart always mmrbnjd/app_moadiran:latest \ No newline at end of file diff --git a/TaxPayerFull/Dockerfile b/TaxPayerFull/Dockerfile new file mode 100644 index 0000000..ec6859a --- /dev/null +++ b/TaxPayerFull/Dockerfile @@ -0,0 +1,98 @@ +# مرحله ۱: Build پروژه Blazor WASM با .NET 9 +# اینجا باید از SDK استفاده کنید نه aspnet +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +WORKDIR /src + +# نصب وابستگی‌ها برای emscripten (python3 + سایر ابزارها) +RUN apt-get update && apt-get install -y python3 make cmake clang zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* + +# کپی کردن فایل‌های پروژه +COPY TaxPayerFull/Front.csproj Front/ +COPY Shared/Shared.csproj Shared/ +COPY . . + +# پاک‌سازی workloadهای قدیمی (اختیاری) +RUN dotnet workload clean + +# نصب wasm-tools برای Blazor +RUN dotnet workload install wasm-tools + +# انتشار (Publish) خروجی در حالت Release +RUN dotnet publish "TaxPayerFull/Front.csproj" -c Release -o /app \ + -p:TreatWarningsAsErrors=false \ + -p:RunAOTCompilation=false \ + -p:PublishTrimmed=false + +# مرحله ۲: سرو کردن با Nginx +FROM nginx:alpine AS final +WORKDIR /usr/share/nginx/html + +# حذف محتوای پیشفرض nginx +RUN rm -rf ./* + +# کپی خروجی Blazor WASM +COPY --from=build /app/wwwroot ./ + +# فقط بلوک server داخل default.conf +RUN printf 'server {\n\ + listen 5107;\n\ + server_name localhost;\n\ +\n\ + root /usr/share/nginx/html;\n\ + index index.html;\n\ +\n\ + location / {\n\ + try_files $uri $uri/ /index.html;\n\ + }\n\ + +\n\ + location /_framework/ {\n\ + expires 1y;\n\ + add_header Cache-Control "public, immutable";\n\ + }\n\ +\n\ + location /_content/ {\n\ + expires 1y;\n\ + add_header Cache-Control "public, immutable";\n\ + }\n\ +\n\ + location /assets/ {\n\ + expires 7d;\n\ + add_header Cache-Control "public";\n\ + }\n\ + \n\ + location /css/ {\n\ + expires 7d;\n\ + add_header Cache-Control "public";\n\ + }\n\ + \n\ + location /fonts/ {\n\ + expires 7d;\n\ + add_header Cache-Control "public";\n\ + }\n\ + \n\ + location /img/ {\n\ + expires 7d;\n\ + add_header Cache-Control "public";\n\ + }\n\ + \n\ + location /js/ {\n\ + expires 7d;\n\ + add_header Cache-Control "public";\n\ + }\n\ +\n\ + location ~ \\.dll$ { add_header Content-Type application/octet-stream; }\n\ + location ~ \\.wasm$ { add_header Content-Type application/wasm; }\n\ + location ~ \\.pdb$ { add_header Content-Type application/octet-stream; }\n\ + location ~ \\.dat$ { add_header Content-Type application/octet-stream; }\n\ +\n\ + gzip on;\n\ + gzip_types text/plain application/xml text/css application/javascript application/json application/wasm;\n\ + gzip_min_length 256;\n\ +\n\ + error_page 404 /index.html;\n\ +}' > /etc/nginx/conf.d/default.conf + +EXPOSE 5107 +CMD ["nginx", "-g", "daemon off;"] diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index af12307..998e0bf 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -31,13 +31,14 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO() enterDate =new DateTime(), exitDate = new DateTime(), }) ; - +string BaseAddress = builder.Configuration.GetSection("BaseAddress").Value; +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(BaseAddress) }); // Server //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") }); //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://moadiran.ir:444/api/") }); //Home -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); //farzan //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); diff --git a/TaxPayerFull/default.conf b/TaxPayerFull/default.conf new file mode 100644 index 0000000..a963ff3 --- /dev/null +++ b/TaxPayerFull/default.conf @@ -0,0 +1,21 @@ +server { + listen 8084; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|eot|ttf|svg)$ { + expires 6M; + access_log off; + add_header Cache-Control "public"; + } + + location = /index.html { + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; + } +} diff --git a/TaxPayerFull/nginx.conf b/TaxPayerFull/nginx.conf new file mode 100644 index 0000000..8964913 --- /dev/null +++ b/TaxPayerFull/nginx.conf @@ -0,0 +1,12 @@ +worker_processes 1; + +events { worker_connections 1024; } + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + +} diff --git a/TaxPayerFull/wwwroot/appsettings.json b/TaxPayerFull/wwwroot/appsettings.json new file mode 100644 index 0000000..d780cbe --- /dev/null +++ b/TaxPayerFull/wwwroot/appsettings.json @@ -0,0 +1,10 @@ +{ + "BaseAddress": "http://192.168.1.14:3201/api/", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3558b76 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,48 @@ +version: '3.9' + +services: + webapi: + build: + context: . + dockerfile: back/Dockerfile + image: moadiran.webapi:latest + container_name: moadiran-webapi + environment: + - ASPNETCORE_ENVIRONMENT=Production + ports: + - "1013:8080" + # networks: + # - moadirannet + + land: + build: + context: . + dockerfile: moadiran/Dockerfile + image: moadiran.land:latest + container_name: moadiran-land + environment: + - ASPNETCORE_ENVIRONMENT=Production + ports: + - "81:7050" + depends_on: + - webapi + # networks: + # - moadirannet + + webapp: + build: + context: . + dockerfile: TaxPayerFull/Dockerfile + image: moadiran.webapp:latest + container_name: moadiran-webapp + ports: + - "82:5107" + depends_on: + - webapi + # networks: + # - moadirannet + + + + + diff --git a/moadiran/.config/dotnet-tools.json b/moadiran/.config/dotnet-tools.json new file mode 100644 index 0000000..b0e38ab --- /dev/null +++ b/moadiran/.config/dotnet-tools.json @@ -0,0 +1,5 @@ +{ + "version": 1, + "isRoot": true, + "tools": {} +} \ No newline at end of file diff --git a/moadiran/DockerCommand.txt b/moadiran/DockerCommand.txt new file mode 100644 index 0000000..09e731a --- /dev/null +++ b/moadiran/DockerCommand.txt @@ -0,0 +1,11 @@ + from run E:\TaxPayerFULL + docker build -f moadiran\Dockerfile -t land_moadiran . + +docker run --name land_moadiran -d -p 81:8080 land_moadiran + + + -------------------------------------------------------------------------------------------- + in local => docker build -f moadiran\Dockerfile -t mmrbnjd/land_moadiran:latest . + in local => docker push mmrbnjd/land_moadiran:latest + in server => docker pull mmrbnjd/land_moadiran:latest + in server => docker run -d -p 3101:8080 --restart always mmrbnjd/land_moadiran:latest \ No newline at end of file diff --git a/moadiran/Dockerfile b/moadiran/Dockerfile new file mode 100644 index 0000000..ce9933b --- /dev/null +++ b/moadiran/Dockerfile @@ -0,0 +1,30 @@ +# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# This stage is used when running from VS in fast mode (Default for Debug configuration) +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 + + +# This stage is used to build the service project +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["moadiran/moadiran.csproj", "moadiran/"] +COPY ["Shared/Shared.csproj", "Shared/"] +RUN dotnet restore "./moadiran/moadiran.csproj" +COPY . . +WORKDIR "/src/moadiran" +RUN dotnet build "./moadiran.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# This stage is used to publish the service project to be copied to the final stage +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./moadiran.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "moadiran.dll"] \ No newline at end of file diff --git a/moadiran/Program.cs b/moadiran/Program.cs index a6f7b67..bae90d8 100644 --- a/moadiran/Program.cs +++ b/moadiran/Program.cs @@ -34,13 +34,15 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO() exitDate = new DateTime(), }); +string BaseAddress = builder.Configuration.GetSection("BaseAddress").Value; +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(BaseAddress) }); // Server //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") }); -// builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://moadiran.ir:444/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://moadiran.ir:444/api/") }); //Home -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); //farzan //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); diff --git a/moadiran/Properties/launchSettings.json b/moadiran/Properties/launchSettings.json index 93dc72e..9ae6866 100644 --- a/moadiran/Properties/launchSettings.json +++ b/moadiran/Properties/launchSettings.json @@ -1,21 +1,13 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:60550", - "sslPort": 44360 - } - }, "profiles": { "moadiran": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7050;http://localhost:5219", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7050;http://localhost:5219" }, "IIS Express": { "commandName": "IISExpress", @@ -23,6 +15,25 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:60550", + "sslPort": 44360 } } -} +} \ No newline at end of file diff --git a/moadiran/appsettings.json b/moadiran/appsettings.json index aefc728..c10c532 100644 --- a/moadiran/appsettings.json +++ b/moadiran/appsettings.json @@ -1,4 +1,5 @@ { + "BaseAddress": "http://192.168.1.14:3201/api/", "Logging": { "LogLevel": { "Default": "Information", diff --git a/moadiran/moadiran.csproj b/moadiran/moadiran.csproj index dd3fd90..9f20fcb 100644 --- a/moadiran/moadiran.csproj +++ b/moadiran/moadiran.csproj @@ -4,6 +4,8 @@ net8.0 enable enable + a89579cc-1c94-4d4e-93a1-86ce286e98ac + Linux @@ -12,6 +14,7 @@ +