From d62b8afa4e49b77f35e5daa13949a01afe25630e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 10 Aug 2021 18:49:11 +0000 Subject: [PATCH] --- server/AyaNova/biz/WorkOrderBiz.cs | 15 +++++ server/AyaNova/models/WorkOrder.cs | 3 + server/AyaNova/util/SigV7Util.cs | 97 ++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 server/AyaNova/util/SigV7Util.cs diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index b80885ba..27e5363c 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -113,6 +113,21 @@ namespace AyaNova.Biz return null; else { + //Only set on v7 migrate to v8 + if(!string.IsNullOrWhiteSpace(newObject.v7SigStrokePath)){ + //todo: convert v7 style strokepath signature to svg for v8 + /* + v7 sig + 71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5, + 61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5, + 62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5, + 48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219 + */ + Console.WriteLine("v7 sig"); + Console.WriteLine(newObject.v7SigStrokePath); + newObject.CustomerSignature=Util.SigV7Util.v7StrokePathTov8SVG(newObject.v7SigStrokePath); + } + await WorkOrderBizActionsAsync(AyaEvent.Created, newObject, null, null); newObject.Tags = TagBiz.NormalizeTags(newObject.Tags); newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields); diff --git a/server/AyaNova/models/WorkOrder.cs b/server/AyaNova/models/WorkOrder.cs index 69192e1f..aeca1047 100644 --- a/server/AyaNova/models/WorkOrder.cs +++ b/server/AyaNova/models/WorkOrder.cs @@ -111,6 +111,9 @@ namespace AyaNova.Models [NotMapped, JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public AyaTypeId GenCopyAttachmentsFrom { get; set; }//INTERNAL, USED TO SIGNIFY ATTACHMENTS NEED TO BE COPIED ON SAVE + [NotMapped, JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string v7SigStrokePath { get; set; }//INTERNAL, USED TO EXPORT v7 SIGNATURES TO V8 + [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.WorkOrder; } diff --git a/server/AyaNova/util/SigV7Util.cs b/server/AyaNova/util/SigV7Util.cs new file mode 100644 index 00000000..9a9e344c --- /dev/null +++ b/server/AyaNova/util/SigV7Util.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; + +namespace AyaNova.Util +{ + internal static class SigV7Util + { + public static string v7StrokePathTov8SVG(string spath) + { + string svg=string.Empty; + + + List> lPoints = new List>(); + + string[] sLines = spath.Split('X'); + + foreach (string sLine in sLines) + { + string[] sPoints = sLine.Trim().Split(' '); + + if (sPoints.Length > 0) + { + foreach (string s in sPoints) + { + lPoints.Add(StringToPoint(s)); + } + } + } +/* +71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5, +61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5, +62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5, +48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219 +*/ + +//"71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5,61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5,62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5,48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219" +//Now turn lPoints into svg and return +// +//https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths +//NOTE: v7 sigpad is 300 by 100 pixels +//so first guess is to treat the canvas as that size for svg +// + + return svg; + } + + + private static Tuple StringToPoint(string s) + { + + if (string.IsNullOrWhiteSpace(s)) + return new Tuple(0, 0); + + if (!s.Contains(',')) + return new Tuple(0, 0); + + string[] spoint = s.Split(','); + + //case 1939 - can't treat the input in the parse as integers as they can apparently contain decimals now + //I suspect that the conversion with decimal is likely slower than checking to see if it has a decimal first so + //I'm breaking this out into two separate streams for performance + if (s.Contains('.')) + { + // if it contains a decimal then convert differently + return new Tuple( + Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[0]))), + Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[1]))) + ); + // return new Point( + // Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[0]))), + // Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[1]))) + // ); + } + else + { + //if it doesn't contain a decimal then use the original method + //case 1978 wrap this in a try catch block due to one customer having NaN values + //in their signature stroke path string. + try + { + return new Tuple(int.Parse(spoint[0]), int.Parse(spoint[1])); + } + catch (System.FormatException ) + { + return new Tuple(0, 0); + } + } + + + + + } + + + }//eoc + +}//eons \ No newline at end of file