From 4afb09b2218d7faf1bca75b9ad7caff6b3f3768c Mon Sep 17 00:00:00 2001
From: wugang <1029149336@qq.com>
Date: Wed, 8 Nov 2017 22:08:43 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=90=8C=E6=AD=A5?=
=?UTF-8?q?=E7=9A=84=E5=9F=BA=E7=B1=BB=20@=E6=98=93=E6=B3=A2=20=E5=8F=AF?=
=?UTF-8?q?=E4=BB=A5=E5=8F=82=E8=80=83=E4=B8=80=E4=B8=8B=20=E5=A5=BD?=
=?UTF-8?q?=E7=9C=81=E4=BA=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BO/BO.csproj | 10 +
BO/BO/LocalSyncBase.cs | 68 +++++
BO/LocalDmoSession.cs | 276 ++++++++++++++++++
BO/LocalForSyncList.cs | 23 ++
BO/SyncToServerBase.cs | 85 ++++++
BO/Utils/BillRpc/GradeAndWeightRpc.cs | 53 +---
BO/Utils/UrlUtil.cs | 127 ++++++++
.../ButcherManageClient.csproj | 4 -
.../LocalSyncBO/TrunksIousOutInStoreRecord.cs | 35 +++
.../TrunksIousOutInStoreFormDto.cs | 10 +-
.../Rpc/TrunksIousOutInStoreRecordRpc.cs | 62 ++++
.../TrunksIousOutInStore.csproj | 20 +-
.../TrunksIousOutInStoreForm.Designer.cs | 239 ++++++++-------
.../TrunksIousOutInStoreForm.cs | 155 ++++++----
.../TrunksIousOutInStoreForm.resx | 17 +-
WeighAndGrading/GradeFrom.cs | 2 +-
16 files changed, 966 insertions(+), 220 deletions(-)
create mode 100644 BO/BO/LocalSyncBase.cs
create mode 100644 BO/LocalDmoSession.cs
create mode 100644 BO/LocalForSyncList.cs
create mode 100644 BO/SyncToServerBase.cs
create mode 100644 BO/Utils/UrlUtil.cs
create mode 100644 TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs
rename TrunksIousOutInStore/{Dto => Rpc}/TrunksIousOutInStoreFormDto.cs (68%)
create mode 100644 TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs
diff --git a/BO/BO.csproj b/BO/BO.csproj
index 61c4c69..aa3b607 100644
--- a/BO/BO.csproj
+++ b/BO/BO.csproj
@@ -46,8 +46,13 @@
False
..\..\..\tsref\Debug\Forks.Utils.dll
+
+ False
+ ..\..\..\tsref\Debug\Newtonsoft.Json.dll
+
+
@@ -78,8 +83,12 @@
+
+
+
+
@@ -100,6 +109,7 @@
+
diff --git a/BO/BO/LocalSyncBase.cs b/BO/BO/LocalSyncBase.cs
new file mode 100644
index 0000000..1757200
--- /dev/null
+++ b/BO/BO/LocalSyncBase.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BO.BO
+{
+ public abstract class LocalSyncBase
+ {
+ ///
+ /// 本地自增ID
+ ///
+ public long ID { get; set; }
+
+ ///
+ /// 是否同步到中间服务器上
+ ///
+ public bool IsSynced { get; set; }
+
+ ///
+ /// 中间服务器ID
+ ///
+ public long? Service_ID { get; set; }
+
+
+ ///
+ /// 上传中间服务器时间
+ ///
+ public DateTime? SyncTime { get; set; }
+
+ ///
+ /// 是否要在服务器上删除 此字段为了删除服务器上的数据用的
+ ///
+ public bool WillBeDeleted{ get; set; }
+
+ ///
+ /// 是否要在服务器上修改 此字段为了修改服务器上的数据用的
+ ///
+ public bool WillBeUpdated { get; set; }
+
+
+ //已经删除的记录 相当于作废的记录 查询的时候要过滤 为了保存原始的记录 用删除标记
+ public bool IsDeleted { get; set; }
+
+ ///
+ /// 设置删除的时间
+ ///
+ public DateTime? DeleteTime { get; set; }
+
+ protected DateTime mCreateTime=DateTime.Now;
+
+ ///
+ /// 每条记录都要记录创建时间
+ ///
+ public DateTime CreateTime
+ { get { return mCreateTime; }
+ set { mCreateTime = value; }
+ }
+
+ ///
+ /// 每条记录都要记录创建人 将来可可以记录标识用
+ ///
+ public string CreateUserName { get; set; }
+
+
+ }
+}
diff --git a/BO/LocalDmoSession.cs b/BO/LocalDmoSession.cs
new file mode 100644
index 0000000..7fde59f
--- /dev/null
+++ b/BO/LocalDmoSession.cs
@@ -0,0 +1,276 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BO.BO;
+using BO.BO.Bill;
+using BO.Utils;
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.EnterpriseServices.SqlDoms;
+
+namespace BO
+{
+ public class LocalDmoSession
+ {
+ public static IDmoSessionWithTransaction New()
+ {
+ return Dmo.NewSession(ButcherAppContext.Context.UrlConfig.OfflineSqlConnection);
+ }
+
+ public static bool ConnectionTest()
+ {
+ using (var session = LocalDmoSession.New())
+ {
+ try
+ {
+ var q = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
+ q.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "c"));
+ q.Range = SelectRange.Top(1);
+ session.ExecuteScalar(q);
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ }
+ ///
+ /// 新增
+ ///
+ ///
+ ///
+ public static void Insert(T detail) where T : LocalSyncBase
+ {
+ using (var session = LocalDmoSession.New())
+ {
+ if (detail.ID != 0)
+ throw new Exception("Insert时要保证ID不为0");
+ session.Insert(detail);
+ session.Commit();
+ }
+ }
+
+ ///
+ /// 同步修改到服务器之后调用
+ ///
+ ///
+ ///
+ ///
+ public static void UpdateAfterInsertSynced(long id, long serviceid) where T : LocalSyncBase
+ {
+ var updateDom = new DQUpdateDom(typeof(T));
+ updateDom.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ updateDom.Columns.Add(new DQUpdateColumn("IsSynced", true));
+ updateDom.Columns.Add(new DQUpdateColumn("SyncTime", DateTime.Now));
+ updateDom.Columns.Add(new DQUpdateColumn("Service_ID", serviceid));
+
+ using (var session = LocalDmoSession.New())
+ {
+ session.ExecuteNonQuery(updateDom);
+ session.Commit();
+ }
+ }
+
+ ///
+ /// 同步更改到服务器之后调用
+ ///
+ ///
+ ///
+ public static void UpdateAfterUpdateSynced(long id) where T : LocalSyncBase
+ {
+ var updateDom = new DQUpdateDom(typeof(T));
+ updateDom.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ updateDom.Columns.Add(new DQUpdateColumn("WillBeUpdated", false));
+ using (var session = LocalDmoSession.New())
+ {
+ session.ExecuteNonQuery(updateDom);
+ session.Commit();
+ }
+ }
+
+ ///
+ /// 同步删除到服务器之后调用
+ ///
+ ///
+ ///
+ public static void UpdateAfterDeleteSynced(long id) where T : LocalSyncBase
+ {
+ var updateDom = new DQUpdateDom(typeof(T));
+ updateDom.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ updateDom.Columns.Add(new DQUpdateColumn("WillBeDeleted", false));
+ using (var session = LocalDmoSession.New())
+ {
+ session.ExecuteNonQuery(updateDom);
+ session.Commit();
+ }
+ }
+
+ ///
+ /// 置删除标记 不是真正的删除
+ ///
+ ///
+ public static void SaveDelete(long id) where T : LocalSyncBase
+ {
+ var updateDom = new DQUpdateDom(typeof(T));
+ updateDom.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ updateDom.Columns.Add(new DQUpdateColumn("IsDeleted", true));
+ updateDom.Columns.Add(new DQUpdateColumn("WillBeDeleted", true));
+ updateDom.Columns.Add(new DQUpdateColumn("DeleteTime", DateTime.Now));
+ using (var session = LocalDmoSession.New())
+ {
+ session.ExecuteNonQuery(updateDom);
+ session.Commit();
+ }
+ }
+
+ public static void Update(T detail, params string[] properties) where T : LocalSyncBase
+ {
+ var type = typeof(T);
+ using (var session = LocalDmoSession.New())
+ {
+ if (detail.ID == 0)
+ throw new Exception("Update时要保证ID不能为0");
+ if (properties.Contains("ID"))
+ throw new Exception("ID不能通过该方法维护");
+ if (properties.Length == 0)
+ throw new Exception("Update时要给出属性数组");
+ var update = new DQUpdateDom(type);
+ update.Where.Conditions.Add(DQCondition.EQ("ID", detail.ID));
+ foreach (var p in properties)
+ {
+ // if (p == "Sync" && detail.Sync)
+ // detail.Sync = false;
+ update.Columns.Add(new DQUpdateColumn(p, type.GetProperty(p).GetValue(detail)));
+ }
+ session.ExecuteNonQuery(update);
+ session.Commit();
+ }
+ }
+
+
+ ///
+ /// 根据条件获取获取没有被删除的集合
+ ///
+ ///
+ ///
+ public static BindingList GetNotDeleteListByDate(DateTime date) where T : LocalSyncBase
+ {
+ List list;
+ DateTime minDate = date.Date;
+ DateTime maxDate = date.Date.AddDays(1);
+ var query = new DmoQuery(typeof(T));
+ query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", minDate));
+ query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", maxDate));
+ query.Where.Conditions.Add(DQCondition.EQ("IsDeleted", false));
+ using (var session = LocalDmoSession.New())
+ {
+ list = session.ExecuteList(query).Cast().ToList();
+ }
+ var bindingList = new BindingList();
+ foreach (T t in list)
+ {
+ bindingList.Add(t);
+ }
+ return bindingList;
+ }
+
+
+ ///
+ /// 根据条件获取获取没有被删除的集合
+ ///
+ ///
+ ///
+ public static BindingList GetNotDeleteList(Dictionary eqdic, int? top) where T : LocalSyncBase
+ {
+ List list;
+ var query = new DmoQuery(typeof(T));
+ if (top.HasValue)
+ {
+ query.Range = SelectRange.Top(top.Value);
+ }
+ query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
+
+ if (eqdic != null)
+ {
+ foreach (KeyValuePair pair in eqdic)
+ {
+ query.Where.Conditions.Add(DQCondition.EQ(pair.Value, pair.Value));
+ }
+ }
+
+ query.Where.Conditions.Add(DQCondition.EQ("IsDeleted", false));
+ using (var session = LocalDmoSession.New())
+ {
+ list = session.ExecuteList(query).Cast().ToList();
+ }
+
+ var bindingList = new BindingList();
+ foreach (T t in list)
+ {
+ bindingList.Add(t);
+ }
+ return bindingList;
+ }
+
+ ///
+ /// 获取需要同步的数据 默认一次50条
+ ///
+ ///
+ public static LocalForSyncList GetNeedSyncList(int top = 50) where T : LocalSyncBase
+ {
+ var result = new LocalForSyncList();
+
+ var query = new DmoQuery(typeof(T));
+ var 没同步 = DQCondition.EQ("IsSynced", false);
+ var 已同步将要删除或者将要修改 = DQCondition.And(DQCondition.EQ("IsSynced", true), DQCondition.Or(DQCondition.EQ("WillBeDeleted", true), DQCondition.EQ("WillBeUpdated", true)));
+
+ query.Where.Conditions.Add(DQCondition.Or(没同步, 已同步将要删除或者将要修改));
+ query.Range = SelectRange.Top(top);
+ query.Where.Conditions.Add(DQCondition.EQ("IsDeleted", false));
+
+ List list;
+ using (var session = LocalDmoSession.New())
+ {
+ list = session.ExecuteList(query).Cast().ToList();
+ }
+
+ var willInsertList = new List();
+ var willUpdateList = new List();
+ var willDeleteList = new List();
+ foreach (T t in list)
+ {
+ if (!t.IsSynced)
+ {
+ //没同步的插入
+ willInsertList.Add(t);
+ }
+ else
+ {
+ //如果已同步
+ if (t.WillBeDeleted)
+ {
+ //如果要删除
+
+ willDeleteList.Add(t);
+ }
+ else
+ {
+ //已同步 如果没删除 要更新
+ willUpdateList.Add(t);
+
+ }
+ }
+ }
+
+ result.WillInsertList = willInsertList;
+ result.WillUpdateList = willUpdateList;
+ result.WillDeleteList = willDeleteList;
+
+ return result;
+ }
+ }
+}
diff --git a/BO/LocalForSyncList.cs b/BO/LocalForSyncList.cs
new file mode 100644
index 0000000..d2de27b
--- /dev/null
+++ b/BO/LocalForSyncList.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BO.BO;
+
+namespace BO
+{
+ public class LocalForSyncList where T:LocalSyncBase
+ {
+ public LocalForSyncList()
+ {
+ WillInsertList=new List();
+ WillUpdateList = new List();
+ WillDeleteList = new List();
+ }
+
+ public List WillInsertList { get; set; }
+ public List WillUpdateList { get; set; }
+ public List WillDeleteList { get; set; }
+ }
+}
diff --git a/BO/SyncToServerBase.cs b/BO/SyncToServerBase.cs
new file mode 100644
index 0000000..d5df033
--- /dev/null
+++ b/BO/SyncToServerBase.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BO.BO;
+using Forks.JsonRpc.Client;
+using Newtonsoft.Json;
+
+namespace BO
+{
+ public abstract class SyncToServerBase where T:LocalSyncBase
+ {
+
+ private static object lockObj=new object();
+ private static object lockSucessedObj=new object();
+
+ protected abstract string InsertRpcUrl { get; }
+ protected abstract string UpdateRpcUrl { get; }
+ protected abstract string DeleteRpcUrl { get; }
+
+ ///
+ /// 是否同步完成
+ ///
+ ///
+ public bool IsSyncSucessed()
+ {
+ lock (lockSucessedObj)
+ {
+ var forList = LocalDmoSession.GetNeedSyncList();
+ //所有集合长度为0时
+ return forList.WillInsertList.Count == 0 && forList.WillUpdateList.Count == 0 &&forList.WillDeleteList.Count == 0;
+ }
+ }
+
+ public void SyncToServer()
+ {
+ lock (lockObj)
+ {
+ var forList = LocalDmoSession.GetNeedSyncList();
+ foreach (T record in forList.WillInsertList)
+ {
+ Insert(record);
+ }
+
+ foreach (T record in forList.WillUpdateList)
+ {
+ Update(record);
+ }
+
+ foreach (T record in forList.WillDeleteList)
+ {
+ Delete(record);
+ }
+ }
+ }
+
+ private long Insert(T record)
+ {
+ var json = JsonConvert.SerializeObject(record);
+ var serviceid = RpcFacade.Call(InsertRpcUrl, json);
+ LocalDmoSession.UpdateAfterInsertSynced(record.ID, serviceid);
+ return serviceid;
+ }
+
+ private void Update(T record)
+ {
+ var json = JsonConvert.SerializeObject(record);
+ RpcFacade.Call(UpdateRpcUrl, json);
+ LocalDmoSession.UpdateAfterUpdateSynced(record.ID);
+ }
+
+
+ private void Delete(T record)
+ {
+ var serviceId = record.Service_ID;
+ if (serviceId == null)
+ {
+ return;
+ }
+ RpcFacade.Call(DeleteRpcUrl, serviceId.Value);
+ LocalDmoSession.UpdateAfterDeleteSynced(record.ID);
+ }
+ }
+}
diff --git a/BO/Utils/BillRpc/GradeAndWeightRpc.cs b/BO/Utils/BillRpc/GradeAndWeightRpc.cs
index 5406d84..29b2ee4 100644
--- a/BO/Utils/BillRpc/GradeAndWeightRpc.cs
+++ b/BO/Utils/BillRpc/GradeAndWeightRpc.cs
@@ -51,39 +51,16 @@ namespace BO.Utils.BillRpc
{
static JavaScriptSerializer serializer = new JavaScriptSerializer();
- public class DmoSession
- {
- public static IDmoSessionWithTransaction New()
- {
- return Dmo.NewSession(ButcherAppContext.Context.UrlConfig.OfflineSqlConnection);
- }
- }
- public static bool ConnectionTest()
- {
- using (var session = DmoSession.New())
- {
- try
- {
- var q = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
- q.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "c"));
- q.Range = SelectRange.Top(1);
- session.ExecuteScalar(q);
- return true;
- }
- catch
- {
- return false;
- }
- }
- }
+
+
public static void ClearWeightBySID(long sid)
{
var updateDom = new DQUpdateDom(typeof(GradeAndWeight_Detail));
updateDom.Where.Conditions.Add(DQCondition.EQ("SID", sid));
updateDom.Columns.Add(new DQUpdateColumn("Weight", DQExpression.NULL));
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
session.ExecuteNonQuery(updateDom);
session.Commit();
@@ -94,7 +71,7 @@ namespace BO.Utils.BillRpc
{
var delDom = new DQDeleteDom(typeof(GradeAndWeight_Detail));
delDom.Where.Conditions.Add(DQCondition.EQ("SID", sid));
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
session.ExecuteNonQuery(delDom);
session.Commit();
@@ -107,7 +84,7 @@ namespace BO.Utils.BillRpc
updateDom.Where.Conditions.Add(DQCondition.EQ("SID", sid));
updateDom.Columns.Add(new DQUpdateColumn("IsLostWeight", true));
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
session.ExecuteNonQuery(updateDom);
session.Commit();
@@ -124,7 +101,7 @@ namespace BO.Utils.BillRpc
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true));
query.Range = SelectRange.Top(top);
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
list = session.ExecuteList(query).Cast().ToList();
}
@@ -141,7 +118,7 @@ namespace BO.Utils.BillRpc
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.EQ("Technics_Name", "烫褪"));
query.Columns.Add(DQSelectColumn.Count());
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
return Convert.ToInt32(session.ExecuteScalar(query));
}
@@ -153,7 +130,7 @@ namespace BO.Utils.BillRpc
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.EQ("Technics_Name", "毛剥"));
query.Columns.Add(DQSelectColumn.Count());
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
return Convert.ToInt32(session.ExecuteScalar(query));
}
@@ -167,7 +144,7 @@ namespace BO.Utils.BillRpc
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true));
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
return session.ExecuteList(query).Cast().ToList();
}
@@ -175,7 +152,7 @@ namespace BO.Utils.BillRpc
public static void Insert(GradeAndWeight_Detail detail)
{
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
if (detail.SID != 0)
throw new Exception("Insert时要保证SID不为0");
@@ -187,7 +164,7 @@ namespace BO.Utils.BillRpc
public static void Update(GradeAndWeight_Detail detail, params string[] properties)
{
var type = typeof(GradeAndWeight_Detail);
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
if (detail.SID == 0)
throw new Exception("Update时要保证SID不能为0");
@@ -222,7 +199,7 @@ namespace BO.Utils.BillRpc
static IEnumerable GetAllNeedSyncDetails()
{
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
var query = new DmoQuery(typeof(GradeAndWeight_Detail));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("SID"));
@@ -235,7 +212,7 @@ namespace BO.Utils.BillRpc
static void SetDetailSynced(GradeAndWeight_Detail detail, long id)
{
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
var update = new DQUpdateDom(typeof(GradeAndWeight_Detail));
update.Columns.Add(new DQUpdateColumn("Sync", true));
@@ -252,7 +229,7 @@ namespace BO.Utils.BillRpc
public static void SaveWeightData(decimal weight)
{
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
var record = new WeightData {Weight = weight, Time = DateTime.Now};
session.Insert(record);
@@ -265,7 +242,7 @@ namespace BO.Utils.BillRpc
var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
query.Columns.Add(DQSelectColumn.Count());
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
- using (var session = DmoSession.New())
+ using (var session = LocalDmoSession.New())
{
return Convert.ToInt32(session.ExecuteScalar(query));
}
diff --git a/BO/Utils/UrlUtil.cs b/BO/Utils/UrlUtil.cs
new file mode 100644
index 0000000..8155909
--- /dev/null
+++ b/BO/Utils/UrlUtil.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+
+namespace BO.Utils
+{
+ public class UrlUtil
+ {
+ public static string GetBarCode(string barCode)
+ {
+ //如果是链接
+ if (barCode.Contains("?") && barCode.ToLower().Contains("http"))
+ {
+ Uri uri = new Uri(barCode);
+ string queryString = uri.Query;
+ NameValueCollection col = GetQueryString(queryString);
+ string code = col["code"];
+
+ return code;
+ }
+ else
+ {
+ return barCode;
+ }
+
+ }
+
+ public static string GetGoodsName(string barCode)
+ {
+ //如果是链接
+ if (barCode.Contains("?") && barCode.ToLower().Contains("http"))
+ {
+ Uri uri = new Uri(barCode);
+ string queryString = uri.Query;
+ NameValueCollection col = GetQueryString(queryString);
+ string name = col["name"];
+ return name;
+ }
+ else
+ {
+ return "";
+ }
+
+ }
+
+ private static NameValueCollection GetQueryString(string queryString)
+ {
+ return GetQueryString(queryString, null, true);
+ }
+
+ private static NameValueCollection GetQueryString(string queryString, Encoding encoding, bool isEncoded)
+ {
+ queryString = queryString.Replace("?", "");
+ NameValueCollection result = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
+ if (!String.IsNullOrEmpty(queryString))
+ {
+ int count = queryString.Length;
+ for (int i = 0; i < count; i++)
+ {
+ int startIndex = i;
+ int index = -1;
+ while (i < count)
+ {
+ char item = queryString[i];
+ if (item == '=')
+ {
+ if (index < 0)
+ {
+ index = i;
+ }
+ }
+ else if (item == '&')
+ {
+ break;
+ }
+ i++;
+ }
+ string key = null;
+ string value = null;
+ if (index >= 0)
+ {
+ key = queryString.Substring(startIndex, index - startIndex);
+ value = queryString.Substring(index + 1, (i - index) - 1);
+ }
+ else
+ {
+ key = queryString.Substring(startIndex, i - startIndex);
+ }
+ if (isEncoded)
+ {
+ result[(string) MyUrlDeCode(key, encoding)] = MyUrlDeCode(value, encoding);
+ }
+ else
+ {
+ result[key] = value;
+ }
+ if ((i == (count - 1)) && (queryString[i] == '&'))
+ {
+ result[key] = String.Empty;
+ }
+ }
+ }
+ return result;
+ }
+
+ private static string MyUrlDeCode(string str, Encoding encoding)
+ {
+ if (encoding == null)
+ {
+ Encoding utf8 = Encoding.UTF8;
+ //首先用utf-8进行解码
+ string code = HttpUtility.UrlDecode(str.ToUpper(), utf8);
+ //将已经解码的字符再次进行编码.
+ string encode = HttpUtility.UrlEncode(code, utf8).ToUpper();
+ if (str == encode)
+ encoding = Encoding.UTF8;
+ else
+ encoding = Encoding.GetEncoding("gb2312");
+ }
+ return HttpUtility.UrlDecode(str, encoding);
+ }
+ }
+}
diff --git a/ButcherManageClient/ButcherManageClient.csproj b/ButcherManageClient/ButcherManageClient.csproj
index 70a2461..eba66e0 100644
--- a/ButcherManageClient/ButcherManageClient.csproj
+++ b/ButcherManageClient/ButcherManageClient.csproj
@@ -106,10 +106,6 @@
{a782b23e-be6d-4f51-b5cb-5cd259ba97cc}
BWP.WinFormControl
-
- {bfc366e2-994c-433f-9ee2-5377dba9d948}
- WeighAndGrading
-
diff --git a/TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs b/TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs
new file mode 100644
index 0000000..6fbe572
--- /dev/null
+++ b/TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs
@@ -0,0 +1,35 @@
+using System;
+using BO.BO;
+
+namespace TrunksIousOutInStore.LocalSyncBO
+{
+
+ [Serializable]
+ public class TrunksIousOutInStoreRecord: LocalSyncBase
+ {
+ public string BarCode { get; set; }
+ public long? Goods_ID { get; set; }
+ public string Goods_Name { get; set; }
+
+ private int mNumber = 1;
+ public int Number
+ {
+ get { return mNumber; }
+ set { mNumber = value; }
+ }
+
+ public decimal? Weight { get; set; }
+
+ public string CarcassStatus{ get; set; }// 胴体状态
+ }
+
+ public class CarcassStatus
+ {
+ public static readonly string 胴体称重 = "胴体称重";
+ public static readonly string 入预冷库 = "入预冷库";
+ public static readonly string 分割领用 = "分割领用";
+ public static readonly string 入销售库 = "入销售库";
+ public static readonly string 销售出库 = "销售出库";
+
+ }
+}
diff --git a/TrunksIousOutInStore/Dto/TrunksIousOutInStoreFormDto.cs b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs
similarity index 68%
rename from TrunksIousOutInStore/Dto/TrunksIousOutInStoreFormDto.cs
rename to TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs
index daa9bf5..ad876e8 100644
--- a/TrunksIousOutInStore/Dto/TrunksIousOutInStoreFormDto.cs
+++ b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs
@@ -1,15 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace TrunksIousOutInStore.Dto
+namespace TrunksIousOutInStore.Rpc
{
public class TrunksIousOutInStoreFormDto
{
public long ID { get; set; }
- public string Code { get; set; }
+ public string BarCode { get; set; }
public string Goods_Name { get; set; }
public string Goods_Spec { get; set; }
diff --git a/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs
new file mode 100644
index 0000000..5ba9dd7
--- /dev/null
+++ b/TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs
@@ -0,0 +1,62 @@
+using BO;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.JsonRpc.Client;
+using Newtonsoft.Json;
+using TrunksIousOutInStore.LocalSyncBO;
+
+namespace TrunksIousOutInStore.Rpc
+{
+ public class TrunksIousOutInStoreRecordRpc: SyncToServerBase
+ {
+ // 定义一个静态变量来保存类的实例
+ private static TrunksIousOutInStoreRecordRpc uniqueInstance;
+
+ // 定义一个标识确保线程同步
+ private static readonly object locker = new object();
+
+ // 定义私有构造函数,使外界不能创建该类实例
+ private TrunksIousOutInStoreRecordRpc()
+ {
+ }
+
+ ///
+ /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
+ ///
+ ///
+ public static TrunksIousOutInStoreRecordRpc GetInstance()
+ {
+ // 当第一个线程运行到这里时,此时会对locker对象 "加锁",
+ // 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
+ // lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
+ // 双重锁定只需要一句判断就可以了
+ if (uniqueInstance == null)
+ {
+ lock (locker)
+ {
+ // 如果类的实例不存在则创建,否则直接返回
+ if (uniqueInstance == null)
+ {
+ uniqueInstance = new TrunksIousOutInStoreRecordRpc();
+ }
+ }
+ }
+ return uniqueInstance;
+ }
+
+
+ protected override string InsertRpcUrl {
+ get { return ""; }
+ }
+
+ protected override string UpdateRpcUrl
+ {
+ get { return ""; }
+ }
+
+ protected override string DeleteRpcUrl
+ {
+ get { return ""; }
+ }
+
+ }
+}
diff --git a/TrunksIousOutInStore/TrunksIousOutInStore.csproj b/TrunksIousOutInStore/TrunksIousOutInStore.csproj
index 95b72c4..2f96e2c 100644
--- a/TrunksIousOutInStore/TrunksIousOutInStore.csproj
+++ b/TrunksIousOutInStore/TrunksIousOutInStore.csproj
@@ -33,6 +33,22 @@
false
+
+ False
+ ..\..\..\tsref\Debug\Forks.EnterpriseServices.dll
+
+
+ False
+ ..\..\..\tsref\Debug\Forks.JsonRpc.Client.dll
+
+
+ False
+ ..\..\..\tsref\Debug\Forks.Utils.dll
+
+
+ False
+ ..\..\..\tsref\Debug\Newtonsoft.Json.dll
+
@@ -44,7 +60,9 @@
-
+
+
+
diff --git a/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs b/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs
index dbbc747..5a358df 100644
--- a/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs
+++ b/TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs
@@ -28,6 +28,7 @@
///
private void InitializeComponent()
{
+ this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
@@ -40,30 +41,33 @@
this.panel2 = new System.Windows.Forms.Panel();
this.lblChengZhong = new System.Windows.Forms.Label();
this.btnWeightSet = new System.Windows.Forms.Button();
+ this.btnSycnStatus = new System.Windows.Forms.Button();
+ this.btnNetStatus = new System.Windows.Forms.Button();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
- this.uComboBox1 = new BWP.WinFormControl.UComboBox();
+ this.cbxBaiTiaoStatus = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.btnCreateBill = new System.Windows.Forms.Button();
this.btnSubmit = new System.Windows.Forms.Button();
- this.btnSyncData = new System.Windows.Forms.Button();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.gridChecked = new BWP.WinFormControl.UDataGridView();
- this.序号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.条码 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.产品名称 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.规格 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.数量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.重量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.gridUnCheck = new System.Windows.Forms.DataGridView();
+ this.flpGoods = new System.Windows.Forms.FlowLayoutPanel();
+ this.timer1 = new System.Windows.Forms.Timer(this.components);
+ this.timerChectNetStatus = new System.Windows.Forms.Timer(this.components);
+ this.timerSyncToService = new System.Windows.Forms.Timer(this.components);
+ this.timerCheckSyncSucessed = new System.Windows.Forms.Timer(this.components);
this.uncheck序号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck条码 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck产品名称 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.uncheck规格 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck数量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck重量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.timer1 = new System.Windows.Forms.Timer();
+ this.序号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.条码 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.产品名称 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.数量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.重量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -76,6 +80,7 @@
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.Panel1.SuspendLayout();
+ this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridChecked)).BeginInit();
@@ -111,6 +116,8 @@
this.panel1.Controls.Add(this.enableWeight);
this.panel1.Controls.Add(this.panel2);
this.panel1.Controls.Add(this.btnWeightSet);
+ this.panel1.Controls.Add(this.btnSycnStatus);
+ this.panel1.Controls.Add(this.btnNetStatus);
this.panel1.Location = new System.Drawing.Point(11, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1251, 100);
@@ -160,6 +167,28 @@
this.btnWeightSet.UseVisualStyleBackColor = true;
this.btnWeightSet.Click += new System.EventHandler(this.btnWeightSet_Click);
//
+ // btnSycnStatus
+ //
+ this.btnSycnStatus.Enabled = false;
+ this.btnSycnStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.btnSycnStatus.Location = new System.Drawing.Point(655, 28);
+ this.btnSycnStatus.Name = "btnSycnStatus";
+ this.btnSycnStatus.Size = new System.Drawing.Size(114, 46);
+ this.btnSycnStatus.TabIndex = 0;
+ this.btnSycnStatus.Text = "同步完成";
+ this.btnSycnStatus.UseVisualStyleBackColor = true;
+ //
+ // btnNetStatus
+ //
+ this.btnNetStatus.Enabled = false;
+ this.btnNetStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.btnNetStatus.Location = new System.Drawing.Point(450, 28);
+ this.btnNetStatus.Name = "btnNetStatus";
+ this.btnNetStatus.Size = new System.Drawing.Size(120, 46);
+ this.btnNetStatus.TabIndex = 0;
+ this.btnNetStatus.Text = "网络畅通";
+ this.btnNetStatus.UseVisualStyleBackColor = true;
+ //
// splitContainer2
//
this.splitContainer2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@@ -169,11 +198,10 @@
//
// splitContainer2.Panel1
//
- this.splitContainer2.Panel1.Controls.Add(this.uComboBox1);
+ this.splitContainer2.Panel1.Controls.Add(this.cbxBaiTiaoStatus);
this.splitContainer2.Panel1.Controls.Add(this.label2);
this.splitContainer2.Panel1.Controls.Add(this.btnCreateBill);
this.splitContainer2.Panel1.Controls.Add(this.btnSubmit);
- this.splitContainer2.Panel1.Controls.Add(this.btnSyncData);
//
// splitContainer2.Panel2
//
@@ -183,18 +211,20 @@
this.splitContainer2.SplitterWidth = 1;
this.splitContainer2.TabIndex = 0;
//
- // uComboBox1
- //
- this.uComboBox1.CodeArgs = null;
- this.uComboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
- this.uComboBox1.EnableTopItem = true;
- this.uComboBox1.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.uComboBox1.FormattingEnabled = true;
- this.uComboBox1.Location = new System.Drawing.Point(49, 144);
- this.uComboBox1.Name = "uComboBox1";
- this.uComboBox1.Range = 10;
- this.uComboBox1.Size = new System.Drawing.Size(158, 36);
- this.uComboBox1.TabIndex = 2;
+ // cbxBaiTiaoStatus
+ //
+ this.cbxBaiTiaoStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbxBaiTiaoStatus.Font = new System.Drawing.Font("宋体", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.cbxBaiTiaoStatus.FormattingEnabled = true;
+ this.cbxBaiTiaoStatus.Items.AddRange(new object[] {
+ "入预冷库",
+ "分割领用",
+ "入销售库",
+ "销售出库"});
+ this.cbxBaiTiaoStatus.Location = new System.Drawing.Point(45, 144);
+ this.cbxBaiTiaoStatus.Name = "cbxBaiTiaoStatus";
+ this.cbxBaiTiaoStatus.Size = new System.Drawing.Size(167, 35);
+ this.cbxBaiTiaoStatus.TabIndex = 34;
//
// label2
//
@@ -225,16 +255,7 @@
this.btnSubmit.TabIndex = 0;
this.btnSubmit.Text = "提交";
this.btnSubmit.UseVisualStyleBackColor = true;
- //
- // btnSyncData
- //
- this.btnSyncData.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.btnSyncData.Location = new System.Drawing.Point(45, 15);
- this.btnSyncData.Name = "btnSyncData";
- this.btnSyncData.Size = new System.Drawing.Size(156, 46);
- this.btnSyncData.TabIndex = 0;
- this.btnSyncData.Text = "同步数据";
- this.btnSyncData.UseVisualStyleBackColor = true;
+ this.btnSubmit.Visible = false;
//
// splitContainer3
//
@@ -247,6 +268,10 @@
//
this.splitContainer3.Panel1.Controls.Add(this.groupBox2);
this.splitContainer3.Panel1.Controls.Add(this.groupBox1);
+ //
+ // splitContainer3.Panel2
+ //
+ this.splitContainer3.Panel2.Controls.Add(this.flpGoods);
this.splitContainer3.Size = new System.Drawing.Size(1015, 610);
this.splitContainer3.SplitterDistance = 726;
this.splitContainer3.SplitterWidth = 1;
@@ -287,7 +312,6 @@
this.序号,
this.条码,
this.产品名称,
- this.规格,
this.数量,
this.重量});
this.gridChecked.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -304,50 +328,6 @@
this.gridChecked.Size = new System.Drawing.Size(693, 320);
this.gridChecked.TabIndex = 4;
//
- // 序号
- //
- this.序号.DataPropertyName = "ID";
- this.序号.HeaderText = "序号";
- this.序号.Name = "序号";
- this.序号.ReadOnly = true;
- //
- // 条码
- //
- this.条码.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.条码.DataPropertyName = "Code";
- this.条码.HeaderText = "条码";
- this.条码.Name = "条码";
- this.条码.ReadOnly = true;
- //
- // 产品名称
- //
- this.产品名称.DataPropertyName = "Goods_Name";
- this.产品名称.HeaderText = "产品名称";
- this.产品名称.Name = "产品名称";
- this.产品名称.ReadOnly = true;
- this.产品名称.Width = 120;
- //
- // 规格
- //
- this.规格.DataPropertyName = "Goods_Spec";
- this.规格.HeaderText = "规格";
- this.规格.Name = "规格";
- this.规格.ReadOnly = true;
- //
- // 数量
- //
- this.数量.DataPropertyName = "Number";
- this.数量.HeaderText = "数量";
- this.数量.Name = "数量";
- this.数量.ReadOnly = true;
- //
- // 重量
- //
- this.重量.DataPropertyName = "Weight";
- this.重量.HeaderText = "重量";
- this.重量.Name = "重量";
- this.重量.ReadOnly = true;
- //
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -382,7 +362,6 @@
this.uncheck序号,
this.uncheck条码,
this.uncheck产品名称,
- this.uncheck规格,
this.uncheck数量,
this.uncheck重量});
this.gridUnCheck.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -399,6 +378,38 @@
this.gridUnCheck.Size = new System.Drawing.Size(699, 200);
this.gridUnCheck.TabIndex = 3;
//
+ // flpGoods
+ //
+ this.flpGoods.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.flpGoods.Location = new System.Drawing.Point(0, 0);
+ this.flpGoods.Name = "flpGoods";
+ this.flpGoods.Size = new System.Drawing.Size(286, 608);
+ this.flpGoods.TabIndex = 0;
+ //
+ // timer1
+ //
+ this.timer1.Enabled = true;
+ this.timer1.Interval = 3000;
+ this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
+ //
+ // timerChectNetStatus
+ //
+ this.timerChectNetStatus.Enabled = true;
+ this.timerChectNetStatus.Interval = 2000;
+ this.timerChectNetStatus.Tick += new System.EventHandler(this.timerChectNetStatus_Tick);
+ //
+ // timerSyncToService
+ //
+ this.timerSyncToService.Enabled = true;
+ this.timerSyncToService.Interval = 5000;
+ this.timerSyncToService.Tick += new System.EventHandler(this.timerSyncToService_Tick);
+ //
+ // timerCheckSyncSucessed
+ //
+ this.timerCheckSyncSucessed.Enabled = true;
+ this.timerCheckSyncSucessed.Interval = 4000;
+ this.timerCheckSyncSucessed.Tick += new System.EventHandler(this.timerCheckSyncSucessed_Tick);
+ //
// uncheck序号
//
this.uncheck序号.DataPropertyName = "ID";
@@ -409,7 +420,7 @@
// uncheck条码
//
this.uncheck条码.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.uncheck条码.DataPropertyName = "Code";
+ this.uncheck条码.DataPropertyName = "BarCode";
this.uncheck条码.HeaderText = "条码";
this.uncheck条码.Name = "uncheck条码";
this.uncheck条码.ReadOnly = true;
@@ -422,13 +433,6 @@
this.uncheck产品名称.ReadOnly = true;
this.uncheck产品名称.Width = 120;
//
- // uncheck规格
- //
- this.uncheck规格.DataPropertyName = "Goods_Spec";
- this.uncheck规格.HeaderText = "规格";
- this.uncheck规格.Name = "uncheck规格";
- this.uncheck规格.ReadOnly = true;
- //
// uncheck数量
//
this.uncheck数量.DataPropertyName = "Number";
@@ -443,11 +447,42 @@
this.uncheck重量.Name = "uncheck重量";
this.uncheck重量.ReadOnly = true;
//
- // timer1
+ // 序号
//
- this.timer1.Enabled = true;
- this.timer1.Interval = 1000;
- this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
+ this.序号.DataPropertyName = "ID";
+ this.序号.HeaderText = "序号";
+ this.序号.Name = "序号";
+ this.序号.ReadOnly = true;
+ //
+ // 条码
+ //
+ this.条码.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.条码.DataPropertyName = "BarCode";
+ this.条码.HeaderText = "条码";
+ this.条码.Name = "条码";
+ this.条码.ReadOnly = true;
+ //
+ // 产品名称
+ //
+ this.产品名称.DataPropertyName = "Goods_Name";
+ this.产品名称.HeaderText = "产品名称";
+ this.产品名称.Name = "产品名称";
+ this.产品名称.ReadOnly = true;
+ this.产品名称.Width = 120;
+ //
+ // 数量
+ //
+ this.数量.DataPropertyName = "Number";
+ this.数量.HeaderText = "数量";
+ this.数量.Name = "数量";
+ this.数量.ReadOnly = true;
+ //
+ // 重量
+ //
+ this.重量.DataPropertyName = "Weight";
+ this.重量.HeaderText = "重量";
+ this.重量.Name = "重量";
+ this.重量.ReadOnly = true;
//
// TrunksIousOutInStoreForm
//
@@ -464,8 +499,6 @@
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TrunksIousOutInStoreForm_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.TrunksIousOutInStoreForm_FormClosed);
this.Load += new System.EventHandler(this.TrunksIousOutInStoreForm_Load);
- this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TrunksIousOutInStoreForm_KeyDown);
- this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TrunksIousOutInStoreForm_KeyUp);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
@@ -480,6 +513,7 @@
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.splitContainer3.Panel1.ResumeLayout(false);
+ this.splitContainer3.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
@@ -495,9 +529,8 @@
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.SplitContainer splitContainer2;
- private System.Windows.Forms.Button btnSyncData;
+ private System.Windows.Forms.Button btnNetStatus;
private System.Windows.Forms.SplitContainer splitContainer3;
- private BWP.WinFormControl.UComboBox uComboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btnCreateBill;
private System.Windows.Forms.Button btnSubmit;
@@ -507,20 +540,24 @@
private System.Windows.Forms.DataGridView gridUnCheck;
private BWP.WinFormControl.UDataGridView gridChecked;
private System.Windows.Forms.Timer timer1;
+ private System.Windows.Forms.CheckBox enableWeight;
+ private System.Windows.Forms.Panel panel2;
+ private System.Windows.Forms.Label lblChengZhong;
+ private System.Windows.Forms.ComboBox cbxBaiTiaoStatus;
+ private System.Windows.Forms.FlowLayoutPanel flpGoods;
+ private System.Windows.Forms.Timer timerChectNetStatus;
+ private System.Windows.Forms.Timer timerSyncToService;
+ private System.Windows.Forms.Timer timerCheckSyncSucessed;
+ private System.Windows.Forms.Button btnSycnStatus;
private System.Windows.Forms.DataGridViewTextBoxColumn 序号;
private System.Windows.Forms.DataGridViewTextBoxColumn 条码;
private System.Windows.Forms.DataGridViewTextBoxColumn 产品名称;
- private System.Windows.Forms.DataGridViewTextBoxColumn 规格;
private System.Windows.Forms.DataGridViewTextBoxColumn 数量;
private System.Windows.Forms.DataGridViewTextBoxColumn 重量;
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck序号;
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck条码;
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck产品名称;
- private System.Windows.Forms.DataGridViewTextBoxColumn uncheck规格;
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck数量;
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck重量;
- private System.Windows.Forms.CheckBox enableWeight;
- private System.Windows.Forms.Panel panel2;
- private System.Windows.Forms.Label lblChengZhong;
}
}
\ No newline at end of file
diff --git a/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs b/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs
index cfd8391..06bdc66 100644
--- a/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs
+++ b/TrunksIousOutInStore/TrunksIousOutInStoreForm.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
@@ -13,7 +14,8 @@ using BO;
using BO.Utils;
using BO.Utils.BillRpc;
using BWP.WinFormControl.WeightDataFormat;
-using TrunksIousOutInStore.Dto;
+using TrunksIousOutInStore.LocalSyncBO;
+using TrunksIousOutInStore.Rpc;
namespace TrunksIousOutInStore
{
@@ -67,7 +69,9 @@ namespace TrunksIousOutInStore
{
if (barCode.IsValid)
{
- doInsertUnSubmit(barCode.BarCode, null);
+ var code = UrlUtil.GetBarCode(barCode.BarCode);
+ var goodsName = UrlUtil.GetGoodsName(barCode.BarCode);
+ doInsertUnSubmit(code, goodsName, null);
}
}
}
@@ -166,7 +170,7 @@ namespace TrunksIousOutInStore
if (str != "0")
{
//AddWeightDetail(decimal.Parse(lblChengZhong.Text));
- doInsertUnSubmit("", decimal.Parse(lblChengZhong.Text));
+ doInsertUnSubmit("","", decimal.Parse(lblChengZhong.Text));
}
}));
}
@@ -189,7 +193,7 @@ namespace TrunksIousOutInStore
//lblChengZhong.Text = string.Format(format, num);
if (str != "0")
{
- doInsertUnSubmit("",decimal.Parse(string.Format(format, num)));
+ doInsertUnSubmit("","", decimal.Parse(string.Format(format, num)));
//AddWeightDetail(decimal.Parse(string.Format(format, num)));
}
}));
@@ -278,67 +282,40 @@ namespace TrunksIousOutInStore
}
#endregion
-
-
- private string barCode;
- private void TrunksIousOutInStoreForm_KeyUp(object sender, KeyEventArgs e)
- {
-
-// switch (e.KeyData)
-// {
-// case Keys.Enter:
-// barCode = "";
-// break;
-//
-// default:
-// barCode += (char)e.KeyValue;
-// barCode = barCode.Replace("\r", "").Replace("\t", "");
-// if (barCode.Length == 4)
-// {
-//
-// doInsertUnSubmit(barCode, null);
-// barCode = "";
-// }
-// break;
-// }
-
-
- }
-
+
+
static object _obj = new object();
-
- private void doInsertUnSubmit(string barCode, decimal? weight)
+ private void doInsertUnSubmit(string barCode,string goodsName, decimal? weight)
{
lock (_obj)
{
- var dto = new TrunksIousOutInStoreFormDto();
-
- dto.Goods_Name = "白条";
- dto.Goods_Name = "规格";
- dto.Number = 1;
+ var record = new TrunksIousOutInStoreRecord();
+ record.Goods_Name = goodsName;
+ record.Number = 1;
+ record.CarcassStatus = cbxBaiTiaoStatus.Text;
if (!string.IsNullOrWhiteSpace(barCode))
{//扫码
- dto.Code = barCode;
+ record.BarCode = barCode;
//找到条码为空但是重量不为空的
- var fd = unSumbitList.FirstOrDefault(x => string.IsNullOrWhiteSpace(x.Code) && x.Weight.HasValue);
+ var fd = unSumbitList.FirstOrDefault(x => string.IsNullOrWhiteSpace(x.BarCode) && x.Weight.HasValue);
if (fd == null)
{
- unSumbitList.Add(dto);
+ unSumbitList.Add(record);
}
else
{
//给条码赋值
- fd.Code = barCode;
+ fd.BarCode = barCode;
}
}
if (weight.HasValue)
{//称重
- dto.Weight = weight;
+ record.Weight = weight;
//找到称重为空条码不为空的
- var fd = unSumbitList.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.Code) && x.Weight==null);
+ var fd = unSumbitList.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.BarCode) && x.Weight == null);
if (fd == null)
{
- unSumbitList.Add(dto);
+ unSumbitList.Add(record);
}
else
{
@@ -380,32 +357,36 @@ namespace TrunksIousOutInStore
}
else
{
- e.Cancel = true;
+ e.Cancel = true;
}
}
}
- BindingList unSumbitList = new BindingList();
- BindingList sumbitedList = new BindingList();
+ BindingList unSumbitList = new BindingList();
+ BindingList sumbitedList = new BindingList();
// ConcurrentQueue barCodequeue=new ConcurrentQueue();
private void timer1_Tick(object sender, EventArgs e)
{
+ timer1.Stop();
+ if (unSumbitList == null)
+ {
+ return;
+ }
-
- var canSubmitList = unSumbitList.Where(x => !string.IsNullOrWhiteSpace(x.Code) && x.Weight != null).ToList();
- foreach (TrunksIousOutInStoreFormDto canSubmitDto in canSubmitList)
+ var canSubmitList = unSumbitList.Where(x => !string.IsNullOrWhiteSpace(x.BarCode) && x.Weight != null).ToList();
+ foreach (TrunksIousOutInStoreRecord record in canSubmitList)
{
- unSumbitList.Remove(canSubmitDto);
- //todo 插入数据库操作
- sumbitedList.Insert(0, canSubmitDto);
+ LocalDmoSession.Insert(record);
+ unSumbitList.Remove(record);
+ sumbitedList.Insert(0, record);
}
BindUnCheckGrid();
BindCheckedGrid();
-
+ timer1.Start();
}
void BindUnCheckGrid()
@@ -418,9 +399,6 @@ namespace TrunksIousOutInStore
}
-
-
-
private void btnWeightSet_Click(object sender, EventArgs e)
{
var f = new WeightSettingFrom();
@@ -436,9 +414,66 @@ namespace TrunksIousOutInStore
BarCode.Stop();
}
- private void TrunksIousOutInStoreForm_KeyDown(object sender, KeyEventArgs e)
+
+
+ #region 检查网络畅通
+ private void timerChectNetStatus_Tick(object sender, EventArgs e)
+ {
+ timerChectNetStatus.Stop();
+ ChectConnectionStatus();
+ timerChectNetStatus.Start();
+ }
+ void ChectConnectionStatus()
+ {
+ if (LoginRpcUtil.TestConnection())
+ {
+ btnNetStatus.Text = "网络畅通";
+ btnNetStatus.BackColor = Color.Green;
+ }
+ else
+ {
+ btnNetStatus.Text = "网络不通";
+ btnNetStatus.BackColor = Color.Red;
+ }
+ }
+
+ #endregion
+
+ #region 同步到中间服务器
+ //同步到
+ private void timerSyncToService_Tick(object sender, EventArgs e)
+ {
+ timerSyncToService.Stop();
+ if (LoginRpcUtil.TestConnection())
+ {
+ TrunksIousOutInStoreRecordRpc.GetInstance().SyncToServer();
+ }
+ timerSyncToService.Start();
+ }
+
+ #endregion
+
+ #region 检查是否同步完成
+
+ //检查是否同步完成
+ private void timerCheckSyncSucessed_Tick(object sender, EventArgs e)
{
- gridUnCheck.Focus();
+ timerCheckSyncSucessed.Stop();
+ if (LoginRpcUtil.TestConnection())
+ {
+ if (TrunksIousOutInStoreRecordRpc.GetInstance().IsSyncSucessed())
+ {
+ btnSycnStatus.Text = "同步完成";
+ btnSycnStatus.BackColor = Color.Green;
+ }
+ else
+ {
+ btnSycnStatus.Text = "正在同步";
+ btnSycnStatus.BackColor = Color.Red;
+ }
+ }
+ timerCheckSyncSucessed.Start();
}
+ #endregion
}
}
diff --git a/TrunksIousOutInStore/TrunksIousOutInStoreForm.resx b/TrunksIousOutInStore/TrunksIousOutInStoreForm.resx
index c59c5f9..84a5835 100644
--- a/TrunksIousOutInStore/TrunksIousOutInStoreForm.resx
+++ b/TrunksIousOutInStore/TrunksIousOutInStoreForm.resx
@@ -126,9 +126,6 @@
True
-
- True
-
True
@@ -144,9 +141,6 @@
True
-
- True
-
True
@@ -154,6 +148,15 @@
True
- 8, 19
+ 4, 19
+
+
+ 98, 19
+
+
+ 273, 19
+
+
+ 440, 19
\ No newline at end of file
diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs
index d77e242..013dbab 100644
--- a/WeighAndGrading/GradeFrom.cs
+++ b/WeighAndGrading/GradeFrom.cs
@@ -34,7 +34,7 @@ namespace WeighAndGrading
{
if (string.IsNullOrEmpty(ButcherAppContext.Context.UrlConfig.OfflineSqlConnection))
throw new Exception("请先设置离线数据库并保存");
- if (!LocalGradeAndWeightBL.ConnectionTest())
+ if (!LocalDmoSession.ConnectionTest())
throw new Exception("离线数据库连接失败");
return this;
}