VSERVERWS/Program.cs
2023-11-10 15:14:17 -05:00

106 lines
2.1 KiB
C#

using CVRLIB.CVENVIRONMENT;
using static CVRLIB.CVGlobal;
using CA_ANC.Formatters;
using CVRLIB;
using CVRLIB.Inventory;
using CVRLIB.Customers;
//ZXING.dll does not copy properly to publish folder, copy manually from another lib, ie cvrlib-nf.
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
//builder.Services.AddControllers().AddJsonOptions((options => {
// //was changing PRINTER_NAME to printeR_NAME (pascal Case: https://github.com/dotnet/runtime/issues/30887)
// options.JsonSerializerOptions.PropertyNamingPolicy = null;
//}));
builder.Services
.AddControllers(options => { options.InputFormatters.Add(new ByteArrayInputFormatter()); })
.AddNewtonsoftJson()
;
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
var env = builder.Environment;
//X:\CVRCO\C#\VSERVERWS\VSERVERWS\wwwroot
AppPath = env.WebRootPath;
//X:\CVRCO\C#\VSERVERWS\VSERVERWS\
HTTPROOT = env.ContentRootPath;
VSERVERWS.Global.Globals.IsDevelopment = app.Environment.IsDevelopment();
//VSERVERWS.Global.Globals.IsDevelopment = false;
VSERVERWS.Global.Globals.LoadPrinters();
CVGlobal.TryGlobalPRELoadCVCollections(new[] { typeof(CVINVENTORY), typeof(CVCustomers) });
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapControllers();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
public partial class Program {
public static CVSECRETS? CVS { get; set; } = null;
public static string AppPath { get; set; } = "";
public static string HTTPROOT { get; set; } = "";
public static bool IsDevMode { get; set; } = false;
public static string XDRIVE {
get {
if (Directory.Exists("X:\\Shares\\cvrdata")) {
return "X:\\Shares\\cvrdata";
} else {
return "X:";
}
}
}
}