From 82cacacfde5b64501ecd902ecf13121d5c9a9362 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 15 Feb 2023 19:14:51 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- build-release.bat | 4 +- install-script.sh | 87 ++++++++++++++++++++++++++++++ server/biz/GlobalBizSettingsBiz.cs | 39 ++++++++------ update-script.txt | 7 +++ 5 files changed, 121 insertions(+), 18 deletions(-) create mode 100644 install-script.sh create mode 100644 update-script.txt diff --git a/.vscode/launch.json b/.vscode/launch.json index 7cade77..d5d28f8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,7 +33,7 @@ "SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;", "SOCKEYE_DATA_PATH": "c:\\temp\\sockeye", "SOCKEYE_USE_URLS": "http://*:7676;", - //"SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true", + "SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true", //"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1", "SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin" }, diff --git a/build-release.bat b/build-release.bat index 64dd023..630ab79 100644 --- a/build-release.bat +++ b/build-release.bat @@ -8,13 +8,13 @@ mkdir C:\data\code\sockeye\dist\installers @echo ******************** BUILD CLIENT **************************** -cd c:\data\code\sockeye\client +cd c:\data\code\sockeye-client call npm run build IF %ERRORLEVEL% NEQ 0 ( set m=CLIENT FAILED TO BUILD goto FAIL ) -xcopy c:\data\code\sockeye\client\dist\* C:\data\code\sockeye\server\wwwroot\ /e +xcopy c:\data\code\sockeye-client\dist\* C:\data\code\sockeye\server\wwwroot\ /e IF %ERRORLEVEL% NEQ 0 ( set m=CLIENT FAILED TO COPY goto FAIL diff --git a/install-script.sh b/install-script.sh new file mode 100644 index 0000000..5d858fc --- /dev/null +++ b/install-script.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# MUST have this script and sockeye-linux-x64-server.zip in coreapps folder + +############################# +echo STARTING... +echo INSTALL .NET CORE +apt-get install -y aspnetcore-runtime-6.0 +echo INSTALL POSTGRESQL +sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - +sudo apt-get update +sudo apt-get -y install postgresql +sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'yourcaraintgotnobrakesitsjustlaughingatyou';" +echo INSTALL REPORTING LIBS +sudo apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \ +libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \ +libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \ +libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libgbm1 \ +ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget +echo INSTALL SOCKEYE +apt install zip unzip -y +mkdir /srv/coreapps/sockeye +mkdir /srv/coreapps/sockeye/data +mkdir /srv/coreapps/sockeye/.local-chromium +cd /srv/coreapps/sockeye +unzip -o ../sockeye-linux-x64-server.zip +chown -vR :www-data /srv/coreapps/sockeye +chmod -R g+rw /srv/coreapps/sockeye/data +chmod -R g+rwx /srv/coreapps/sockeye/.local-chromium +echo '[Unit]' >> /etc/systemd/system/sockeye.service +echo 'Description=sockeye server' >> /etc/systemd/system/sockeye.service +echo '' >> /etc/systemd/system/sockeye.service +echo '[Service]' >> /etc/systemd/system/sockeye.service +echo 'WorkingDirectory=/srv/coreapps/sockeye' >> /etc/systemd/system/sockeye.service +echo 'ExecStart=/usr/bin/dotnet /srv/coreapps/sockeye/sockeye.dll' >> /etc/systemd/system/sockeye.service +echo 'Restart=always' >> /etc/systemd/system/sockeye.service +echo 'RestartSec=10' >> /etc/systemd/system/sockeye.service +echo 'KillSignal=SIGINT' >> /etc/systemd/system/sockeye.service +echo 'SyslogIdentifier=sockeye-server' >> /etc/systemd/system/sockeye.service +echo 'User=www-data' >> /etc/systemd/system/sockeye.service +echo 'Environment=ASPNETCORE_ENVIRONMENT=Production' >> /etc/systemd/system/sockeye.service +echo 'Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false' >> /etc/systemd/system/sockeye.service +echo '' >> /etc/systemd/system/sockeye.service +echo '[Install]' >> /etc/systemd/system/sockeye.service +echo 'WantedBy=multi-user.target' >> /etc/systemd/system/sockeye.service +systemctl enable sockeye.service +echo START SOCKEYE SERVICE +systemctl start sockeye.service +# echo INSTALL NGINX +# apt install nginx -y +# echo 'server {' > /etc/nginx/sites-available/default +# echo ' listen 80;' >> /etc/nginx/sites-available/default +# echo " server_name $DOMAINNAME;" >> /etc/nginx/sites-available/default +# echo ' location / {' >> /etc/nginx/sites-available/default +# echo ' add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;' >> /etc/nginx/sites-available/default +# echo ' add_header X-XSS-Protection "1; mode=block" always;' >> /etc/nginx/sites-available/default +# echo ' add_header X-Content-Type-Options "nosniff" always;' >> /etc/nginx/sites-available/default +# echo ' add_header X-Frame-Options "SAMEORIGIN" always;' >> /etc/nginx/sites-available/default +# echo ' add_header Referrer-Policy "strict-origin" always;' >> /etc/nginx/sites-available/default +# echo ' gzip on;' >> /etc/nginx/sites-available/default +# echo ' gzip_vary on;' >> /etc/nginx/sites-available/default +# echo ' gzip_min_length 10240;' >> /etc/nginx/sites-available/default +# echo ' gzip_proxied expired no-cache no-store private auth;' >> /etc/nginx/sites-available/default +# echo ' gzip_http_version 1.1;' >> /etc/nginx/sites-available/default +# echo ' gzip_types application/javascript text/css application/json text/plain;' >> /etc/nginx/sites-available/default +# echo '' >> /etc/nginx/sites-available/default +# echo ' proxy_pass http://127.0.0.1:7575;' >> /etc/nginx/sites-available/default +# echo ' proxy_http_version 1.1;' >> /etc/nginx/sites-available/default +# echo ' proxy_set_header Upgrade $http_upgrade;' >> /etc/nginx/sites-available/default +# echo ' proxy_set_header Connection keep-alive;' >> /etc/nginx/sites-available/default +# echo ' proxy_set_header Host $host;' >> /etc/nginx/sites-available/default +# echo ' proxy_cache_bypass $http_upgrade;' >> /etc/nginx/sites-available/default +# echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> /etc/nginx/sites-available/default +# echo ' proxy_set_header X-Forwarded-Proto $scheme;' >> /etc/nginx/sites-available/default +# echo ' proxy_connect_timeout 3600;' >> /etc/nginx/sites-available/default +# echo ' proxy_send_timeout 3600;' >> /etc/nginx/sites-available/default +# echo ' proxy_read_timeout 3600;' >> /etc/nginx/sites-available/default +# echo ' send_timeout 3600; ' >> /etc/nginx/sites-available/default +# echo ' client_max_body_size 25M;' >> /etc/nginx/sites-available/default +# echo ' }' >> /etc/nginx/sites-available/default +# echo '}' >> /etc/nginx/sites-available/default +# systemctl restart nginx +# echo INSTALL CERTBOT +# apt install certbot python3-certbot-nginx -y +# echo GET CERTIFICATE +# certbot --nginx --noninteractive --agree-tos --email ops@onsockeye.com --no-eff-email -d $DOMAINNAME +echo ...COMPLETED diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index 8219fd7..a3b8811 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -253,7 +253,7 @@ namespace Sockeye.Biz //create product if not exist then import //Get product id if exists var ProductName = jPurchase["name"].Value(); - bool maybeRenewal=ProductName.ToLowerInvariant().Contains("renew"); + bool maybeRenewal = ProductName.ToLowerInvariant().Contains("renew"); ProductName = ProductName.Replace("- Renewal", "").Replace(" Renewal", "").Replace(" RENEWAL", "").Replace("CANCELLED ", "").Replace("CANCELED ", ""); var p = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.VendorCode == jPurchase["productCode"].Value()); @@ -294,7 +294,7 @@ namespace Sockeye.Biz s.ProductId = p.Id; s.PGroup = p.PGroup; s.CustomerId = CurrentCustomerId; - s.RegTo=CustomerName; + s.RegTo = CustomerName; s.CancelDate = DateUtil.EpochToDateNullIsNull(jPurchase["cancelDate"].Value()); s.CouponCode = jPurchase["couponCode"].Value(); s.ExpireDate = DateUtil.EpochToDateNullIsNull(jPurchase["expireDate"].Value()); @@ -305,7 +305,7 @@ namespace Sockeye.Biz s.RenewNoticeSent = jPurchase["renewNoticeSent"].Value(); s.SalesOrderNumber = jPurchase["salesOrderNumber"].Value(); s.Notes = jPurchase["notes"].Value(); - s.IsRenewal=maybeRenewal; + s.IsRenewal = maybeRenewal; PurchaseBiz biz = PurchaseBiz.GetBiz(ct); await biz.CreateAsync(s); } @@ -361,12 +361,12 @@ namespace Sockeye.Biz await ct.SaveChangesAsync(); -// #if (DEBUG) -// //Test dev stuff -// #warning DEV TEST ORDER PROCESSING REMOVE THIS WHEN DONE -// if (!string.IsNullOrWhiteSpace(vn.VendorData)) -// await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log); -// #endif + // #if (DEBUG) + // //Test dev stuff + // #warning DEV TEST ORDER PROCESSING REMOVE THIS WHEN DONE + // if (!string.IsNullOrWhiteSpace(vn.VendorData)) + // await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log); + // #endif } }// all vendor notifications loop @@ -440,20 +440,29 @@ namespace Sockeye.Biz //priority to tags g.Tags.Add($"{jRFCase["priority"].Value()}-priority"); + + //check for attachments and just add as a note, don't bother with actual transfer of attachment, there aren't a lot and most are way in the past and not required for anything //if needed in future can manually xfer it over from the rockfish.sqlite db directly using DB BRowser for sqlite which allows opening the blob from the rfcaseblob table and saving it res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/{g.CaseId}/attachments"); responseText = await res.Content.ReadAsStringAsync(); - var jAttachments = JObject.Parse(responseText); - if (jAttachments["attach"].Count() > 0) + try { - g.Notes += "\n********\nRockfish attachments\n"; - foreach (JObject jAttachmentRecord in jAttachments["attach"]) + var jAttachments = JObject.Parse(responseText); + if (jAttachments["attach"].Count() > 0) { - g.Notes += $"File: \"{jAttachmentRecord["name"].Value()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value()}\n"; + g.Notes += "\n********\nRockfish attachments\n"; + foreach (JObject jAttachmentRecord in jAttachments["attach"]) + { + g.Notes += $"File: \"{jAttachmentRecord["name"].Value()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value()}\n"; + } + g.Notes += "\n********\n"; } - g.Notes += "\n********\n"; + } + catch (Newtonsoft.Json.JsonReaderException jre) + { + log.LogError(jre, $"Error parsing attachment check for case {g.CaseId}, response text was {responseText}"); } GZCaseBiz biz = GZCaseBiz.GetBiz(ct); diff --git a/update-script.txt b/update-script.txt new file mode 100644 index 0000000..b50132d --- /dev/null +++ b/update-script.txt @@ -0,0 +1,7 @@ +cd /srv/coreapps/sockeye && \ +sudo systemctl stop sockeye.service && \ +sudo rm *.dll && \ +sudo rm -r ./resource && \ +sudo rm -r ./wwwroot && \ +sudo unzip -o ../sockeye-linux-x64-server.zip -x "config.json" && \ +sudo systemctl start sockeye.service