private int GetInboundCount(int differenceCount, DifferenceDetail detail, string size) { int inboundCount = 0; if (this.isCheckStoreOrder) { foreach (CheckStoreDetail checkStoreDetail in checkStoreDetails) { if (checkStoreDetail.CostumeID == detail.CostumeID && checkStoreDetail.ColorName == detail.ColorName) { inboundCount = Convert.ToInt32(CJBasic.Helpers.ReflectionHelper.GetProperty(checkStoreDetail, size)); break; } } } else { foreach (BoundDetail inboundDetail in inboundDetails) { if (inboundDetail.CostumeID == detail.CostumeID && inboundDetail.ColorName == detail.ColorName) { inboundCount = Convert.ToInt32(CJBasic.Helpers.ReflectionHelper.GetProperty(inboundDetail, size)); break; } } } return(inboundCount); }
private int GetChangeCount(DifferenceDetail detail, string size) { int count = 0; foreach (CheckStoreDetail checkStoreDetail in checkStoreDetails) { if (checkStoreDetail.CostumeID == detail.CostumeID && checkStoreDetail.ColorName == detail.ColorName) { count = Convert.ToInt32(CJBasic.Helpers.ReflectionHelper.GetProperty(checkStoreDetail, size + "Atm")); break; } } return(count); }
private int GetOutboundCount(DifferenceDetail detail, string size) { int count = 0; //if (shots != null) //{ // CostumeStoreSnapshotInfo shotInfo = shots.Find(t => t.Costume.ID == detail.CostumeID); // if (shotInfo != null) // { // foreach (CostumeStoreSnapshot checkStoreDetail in shotInfo.CostumeStoreSnapshots) // { // if (checkStoreDetail.CostumeID == detail.CostumeID && checkStoreDetail.ColorName == detail.ColorName) // { // count = Convert.ToInt32(CJBasic.Helpers.ReflectionHelper.GetProperty(checkStoreDetail, size)); // break; // } // } // } //} return(count); }
private IEnumerable <DifferenceDetail> WalkForDiffDetails(byte[] left, byte[] right) { // WalkForDiffDetails compares arrays byte-to-byte. // When difference is met we begin new DifferenceDetail saving offsets in it. // Then difference consider finished when: // 1) Left byte is equal to right where detail have started. // 2) Right byte is equal to left where detail have started. // 3) Left byte is equal to right. // The algorithm is simple enough and doesn't play good because it can't go // back. We have to switch to more sophisticated method in a future. For example: // https://www.codeproject.com/Articles/6943/A-Generic-Reusable-Diff-Algorithm-in-C-II var l = 0; var r = 0; DifferenceDetail d = null; while (l < left.Length && r < right.Length) { if (d != null) { var diffFound = false; if (left[l] == right[d.RightOffset]) { // Change is in left but not in right. d.LeftLength = l - d.LeftOffset; r = d.RightOffset; diffFound = true; } else if (right[r] == left[d.LeftOffset]) { // Change is in right but not in left. d.RightLength = r - d.RightOffset; l = d.LeftOffset; diffFound = true; } else if (left[l] == right[r]) { // Both sides have equal difference of change. d.LeftLength = l - d.LeftOffset; d.RightLength = r - d.RightOffset; diffFound = true; } if (diffFound) { yield return(d); d = null; } } else if (left[l] != right[r]) { // We meet the difference after equality. // Start new detail at positions. d = new DifferenceDetail { LeftOffset = l, RightOffset = r, }; } l++; r++; } // Check whether change stretches to the end. if (d != null) { d.LeftLength = left.Length - d.LeftOffset; d.RightLength = right.Length - d.RightOffset; yield return(d); } }