This commit is contained in:
2023-02-15 19:14:51 +00:00
parent 8c2ed59e91
commit 82cacacfde
5 changed files with 121 additions and 18 deletions

2
.vscode/launch.json vendored
View File

@@ -33,7 +33,7 @@
"SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;", "SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;",
"SOCKEYE_DATA_PATH": "c:\\temp\\sockeye", "SOCKEYE_DATA_PATH": "c:\\temp\\sockeye",
"SOCKEYE_USE_URLS": "http://*:7676;", "SOCKEYE_USE_URLS": "http://*:7676;",
//"SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true", "SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true",
//"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1", //"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1",
"SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin" "SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin"
}, },

View File

@@ -8,13 +8,13 @@ mkdir C:\data\code\sockeye\dist\installers
@echo ******************** BUILD CLIENT **************************** @echo ******************** BUILD CLIENT ****************************
cd c:\data\code\sockeye\client cd c:\data\code\sockeye-client
call npm run build call npm run build
IF %ERRORLEVEL% NEQ 0 ( IF %ERRORLEVEL% NEQ 0 (
set m=CLIENT FAILED TO BUILD set m=CLIENT FAILED TO BUILD
goto FAIL 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 ( IF %ERRORLEVEL% NEQ 0 (
set m=CLIENT FAILED TO COPY set m=CLIENT FAILED TO COPY
goto FAIL goto FAIL

87
install-script.sh Normal file
View File

@@ -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

View File

@@ -253,7 +253,7 @@ namespace Sockeye.Biz
//create product if not exist then import //create product if not exist then import
//Get product id if exists //Get product id if exists
var ProductName = jPurchase["name"].Value<string>(); var ProductName = jPurchase["name"].Value<string>();
bool maybeRenewal=ProductName.ToLowerInvariant().Contains("renew"); bool maybeRenewal = ProductName.ToLowerInvariant().Contains("renew");
ProductName = ProductName.Replace("- Renewal", "").Replace(" Renewal", "").Replace(" RENEWAL", "").Replace("CANCELLED ", "").Replace("CANCELED ", ""); 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<string>()); var p = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.VendorCode == jPurchase["productCode"].Value<string>());
@@ -294,7 +294,7 @@ namespace Sockeye.Biz
s.ProductId = p.Id; s.ProductId = p.Id;
s.PGroup = p.PGroup; s.PGroup = p.PGroup;
s.CustomerId = CurrentCustomerId; s.CustomerId = CurrentCustomerId;
s.RegTo=CustomerName; s.RegTo = CustomerName;
s.CancelDate = DateUtil.EpochToDateNullIsNull(jPurchase["cancelDate"].Value<long?>()); s.CancelDate = DateUtil.EpochToDateNullIsNull(jPurchase["cancelDate"].Value<long?>());
s.CouponCode = jPurchase["couponCode"].Value<string>(); s.CouponCode = jPurchase["couponCode"].Value<string>();
s.ExpireDate = DateUtil.EpochToDateNullIsNull(jPurchase["expireDate"].Value<long?>()); s.ExpireDate = DateUtil.EpochToDateNullIsNull(jPurchase["expireDate"].Value<long?>());
@@ -305,7 +305,7 @@ namespace Sockeye.Biz
s.RenewNoticeSent = jPurchase["renewNoticeSent"].Value<bool>(); s.RenewNoticeSent = jPurchase["renewNoticeSent"].Value<bool>();
s.SalesOrderNumber = jPurchase["salesOrderNumber"].Value<string>(); s.SalesOrderNumber = jPurchase["salesOrderNumber"].Value<string>();
s.Notes = jPurchase["notes"].Value<string>(); s.Notes = jPurchase["notes"].Value<string>();
s.IsRenewal=maybeRenewal; s.IsRenewal = maybeRenewal;
PurchaseBiz biz = PurchaseBiz.GetBiz(ct); PurchaseBiz biz = PurchaseBiz.GetBiz(ct);
await biz.CreateAsync(s); await biz.CreateAsync(s);
} }
@@ -361,12 +361,12 @@ namespace Sockeye.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
// #if (DEBUG) // #if (DEBUG)
// //Test dev stuff // //Test dev stuff
// #warning DEV TEST ORDER PROCESSING REMOVE THIS WHEN DONE // #warning DEV TEST ORDER PROCESSING REMOVE THIS WHEN DONE
// if (!string.IsNullOrWhiteSpace(vn.VendorData)) // if (!string.IsNullOrWhiteSpace(vn.VendorData))
// await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log); // await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log);
// #endif // #endif
} }
}// all vendor notifications loop }// all vendor notifications loop
@@ -440,20 +440,29 @@ namespace Sockeye.Biz
//priority to tags //priority to tags
g.Tags.Add($"{jRFCase["priority"].Value<long>()}-priority"); g.Tags.Add($"{jRFCase["priority"].Value<long>()}-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 //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 //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"); res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/{g.CaseId}/attachments");
responseText = await res.Content.ReadAsStringAsync(); responseText = await res.Content.ReadAsStringAsync();
var jAttachments = JObject.Parse(responseText); try
if (jAttachments["attach"].Count() > 0)
{ {
g.Notes += "\n********\nRockfish attachments\n"; var jAttachments = JObject.Parse(responseText);
foreach (JObject jAttachmentRecord in jAttachments["attach"]) if (jAttachments["attach"].Count() > 0)
{ {
g.Notes += $"File: \"{jAttachmentRecord["name"].Value<string>()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value<long>()}\n"; g.Notes += "\n********\nRockfish attachments\n";
foreach (JObject jAttachmentRecord in jAttachments["attach"])
{
g.Notes += $"File: \"{jAttachmentRecord["name"].Value<string>()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value<long>()}\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); GZCaseBiz biz = GZCaseBiz.GetBiz(ct);

7
update-script.txt Normal file
View File

@@ -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