This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graphical fixes added script with some products
- Loading branch information
1 parent
1f6eb1c
commit bc48002
Showing
8 changed files
with
91 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ public MainWindow() | |
|
||
|
||
InitializeComponent(); | ||
Style = (Style)FindResource(typeof(Window)); | ||
reader = new BarcodeReader(); | ||
networkDriver = new NetworkDriver(requestProcessing, messageProcessing); | ||
onlineProductManager = new OnlineProductManager(dbConnect, barcodesToBeSearchedOnline); | ||
|
@@ -82,23 +83,17 @@ private NetworkResponse requestProcessing(NetworkRequest request) | |
Bitmap image2 = new Bitmap(image); | ||
// show the image | ||
this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new ImageConsumer(displayImage), image2); | ||
// do the barcode scan | ||
ArrayList barcodes = new ArrayList(); | ||
//BarcodeScanner.FullScanPage(ref barcodes, image, 100); | ||
|
||
var result = reader.Decode(image); | ||
|
||
//string result = codeScanner.ScanPage(image); | ||
int rotation = 0; | ||
while (result == null && rotation < 36) | ||
int rotations = 0; | ||
Result result = null; | ||
// attempt recognition of codes multiple times rotating the images | ||
do | ||
{ | ||
//image = rotateImage90(image); | ||
var image_tmp = RotateImg(image, rotation * 10, System.Drawing.Color.Transparent); | ||
var image_tmp = RotateImg(image, rotations * 10, System.Drawing.Color.Transparent); | ||
result = reader.Decode(image_tmp); | ||
rotation++; | ||
this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new ImageConsumer(displayImage), image_tmp); | ||
rotations++; | ||
} | ||
//messageProcessing("Scan done. Found " + barcodes.Count + "barcodes"); | ||
while (result == null && rotations < 36); | ||
|
||
NetworkResponse response; | ||
if (result != null) | ||
{ | ||
|
@@ -148,8 +143,7 @@ private NetworkResponse requestProcessing(NetworkRequest request) | |
} | ||
else | ||
{ | ||
messageProcessing("No barcodes found"); | ||
//response = new NetworkResponse(NetworkResponse.ResponseType.ImageProcessingResult, Encoding.UTF8.GetBytes("{\"ID\":\"10\",\"Name\":\"Martino\",\"Surname\":\"Mensio\",\"Email\":\"[email protected]\"}")); | ||
messageProcessing("No codes found"); | ||
response = new NetworkResponse(NetworkResponse.ResponseType.ImageProcessingError, Utils.StringToBytes("Error")); | ||
} | ||
return response; | ||
|
@@ -158,10 +152,11 @@ private NetworkResponse requestProcessing(NetworkRequest request) | |
{ | ||
try | ||
{ | ||
string req = UDPNetwork.Utils.BytesToString(request.Payload); | ||
string req = Utils.BytesToString(request.Payload); | ||
JObject receipt = JObject.Parse(req); | ||
// get customerId | ||
String userId = receipt["UserID"].ToString(); | ||
messageProcessing("received a receipt with userId: " + userId); | ||
JArray list = receipt["List"] as JArray; | ||
IList<JToken> products = list.Children().ToList(); | ||
Receipt receiptObj = new Receipt(userId); | ||
|
@@ -183,22 +178,20 @@ private NetworkResponse requestProcessing(NetworkRequest request) | |
catch (Exception e) | ||
{ | ||
// some exception | ||
Console.WriteLine("Exception catched reading a receipt: " + e.Message); | ||
messageProcessing("Exception catched processing the receipt: " + e.Message); | ||
return new NetworkResponse(NetworkResponse.ResponseType.ReceiptStorageError, Utils.StringToBytes("Error")); | ||
} | ||
} | ||
else | ||
{ | ||
// some errors | ||
Console.WriteLine("Unknown request type"); | ||
messageProcessing("Unknown request type"); | ||
return new NetworkResponse(NetworkResponse.ResponseType.ReceiptStorageError, Utils.StringToBytes("Error")); | ||
} | ||
} | ||
|
||
private void displayImage(Bitmap image) | ||
{ | ||
//addMessageToLog("Trying to display image"); | ||
//ImageDisplay.Source = (ImageSource)new ImageSourceConverter().ConvertFrom(image); | ||
ImageDisplay.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(image.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); | ||
} | ||
|
||
|
@@ -220,11 +213,6 @@ private void Window_Closed(object sender, EventArgs e) | |
//Application.Current.Shutdown(); not necessary because other thread is background | ||
} | ||
|
||
private void button_Click(object sender, RoutedEventArgs e) | ||
{ | ||
barcodesToBeSearchedOnline.Add(barcode_txt.Text); | ||
} | ||
|
||
private Bitmap rotateImage90(Bitmap b) | ||
{ | ||
Bitmap returnBitmap = new Bitmap(b.Height, b.Width); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
INSERT INTO `product` (`Barcode`, `Name`, `Price`, `StoreQty`, `WarehouseQty`, `Points`) VALUES | ||
(8000340479919, 'SKIPPER kiwi mela', 1.5, 10, 40, 15), | ||
(90370762, 'coca cola', 1, 10, 40, 10), | ||
(5410041000900, 'TUC crackers', 1.2, 8, 10, 7), | ||
(80007951, 'Acqua san Benedetto', 0.25, 3, 20, 5), | ||
(8010333001850, 'Acqua Martina frizzante', 0.50, 7, 20, 5); |