Browse Source

增加 同步的基类

@易波 可以参考一下 好省事
master
wugang 8 years ago
parent
commit
4afb09b221
16 changed files with 966 additions and 220 deletions
  1. +10
    -0
      BO/BO.csproj
  2. +68
    -0
      BO/BO/LocalSyncBase.cs
  3. +276
    -0
      BO/LocalDmoSession.cs
  4. +23
    -0
      BO/LocalForSyncList.cs
  5. +85
    -0
      BO/SyncToServerBase.cs
  6. +15
    -38
      BO/Utils/BillRpc/GradeAndWeightRpc.cs
  7. +127
    -0
      BO/Utils/UrlUtil.cs
  8. +0
    -4
      ButcherManageClient/ButcherManageClient.csproj
  9. +35
    -0
      TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs
  10. +2
    -8
      TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs
  11. +62
    -0
      TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs
  12. +19
    -1
      TrunksIousOutInStore/TrunksIousOutInStore.csproj
  13. +138
    -101
      TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs
  14. +95
    -60
      TrunksIousOutInStore/TrunksIousOutInStoreForm.cs
  15. +10
    -7
      TrunksIousOutInStore/TrunksIousOutInStoreForm.resx
  16. +1
    -1
      WeighAndGrading/GradeFrom.cs

+ 10
- 0
BO/BO.csproj View File

@ -46,8 +46,13 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.Utils.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
@ -78,8 +83,12 @@
<Compile Include="BO\Bill\WeightBill\WeightBillList.cs" />
<Compile Include="BO\Bill\WeightBill\WeightDetail.cs" />
<Compile Include="BO\Dtos\ClientGoodsSetDto.cs" />
<Compile Include="BO\LocalSyncBase.cs" />
<Compile Include="BO\SyncBase.cs" />
<Compile Include="CTuple.cs" />
<Compile Include="LocalDmoSession.cs" />
<Compile Include="LocalForSyncList.cs" />
<Compile Include="SyncToServerBase.cs" />
<Compile Include="Utils\AfterLoginUtil.cs" />
<Compile Include="Utils\BillRpc\ClientGoodsSetRpc.cs" />
<Compile Include="Utils\BillRpc\GradeAndWeightRpc.cs" />
@ -100,6 +109,7 @@
<Compile Include="Utils\LoginRpcUtil.cs" />
<Compile Include="Utils\LoginUserInfo.cs" />
<Compile Include="Utils\ServerUrlConfig.cs" />
<Compile Include="Utils\UrlUtil.cs" />
<Compile Include="Utils\XmlUtil.cs" />
</ItemGroup>
<ItemGroup>


+ 68
- 0
BO/BO/LocalSyncBase.cs View File

@ -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
{
/// <summary>
/// 本地自增ID
/// </summary>
public long ID { get; set; }
/// <summary>
/// 是否同步到中间服务器上
/// </summary>
public bool IsSynced { get; set; }
/// <summary>
/// 中间服务器ID
/// </summary>
public long? Service_ID { get; set; }
/// <summary>
/// 上传中间服务器时间
/// </summary>
public DateTime? SyncTime { get; set; }
/// <summary>
/// 是否要在服务器上删除 此字段为了删除服务器上的数据用的
/// </summary>
public bool WillBeDeleted{ get; set; }
/// <summary>
/// 是否要在服务器上修改 此字段为了修改服务器上的数据用的
/// </summary>
public bool WillBeUpdated { get; set; }
//已经删除的记录 相当于作废的记录 查询的时候要过滤 为了保存原始的记录 用删除标记
public bool IsDeleted { get; set; }
/// <summary>
/// 设置删除的时间
/// </summary>
public DateTime? DeleteTime { get; set; }
protected DateTime mCreateTime=DateTime.Now;
/// <summary>
/// 每条记录都要记录创建时间
/// </summary>
public DateTime CreateTime
{ get { return mCreateTime; }
set { mCreateTime = value; }
}
/// <summary>
/// 每条记录都要记录创建人 将来可可以记录标识用
/// </summary>
public string CreateUserName { get; set; }
}
}

+ 276
- 0
BO/LocalDmoSession.cs View File

@ -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;
}
}
}
/// <summary>
/// 新增
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="detail"></param>
public static void Insert<T>(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();
}
}
/// <summary>
/// 同步修改到服务器之后调用
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
/// <param name="serviceid"></param>
public static void UpdateAfterInsertSynced<T>(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();
}
}
/// <summary>
/// 同步更改到服务器之后调用
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
public static void UpdateAfterUpdateSynced<T>(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();
}
}
/// <summary>
/// 同步删除到服务器之后调用
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="id"></param>
public static void UpdateAfterDeleteSynced<T>(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();
}
}
/// <summary>
/// 置删除标记 不是真正的删除
/// </summary>
/// <param name="id"></param>
public static void SaveDelete<T>(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>(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();
}
}
/// <summary>
/// 根据条件获取获取没有被删除的集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static BindingList<T> GetNotDeleteListByDate<T>(DateTime date) where T : LocalSyncBase
{
List<T> 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<T>().ToList();
}
var bindingList = new BindingList<T>();
foreach (T t in list)
{
bindingList.Add(t);
}
return bindingList;
}
/// <summary>
/// 根据条件获取获取没有被删除的集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static BindingList<T> GetNotDeleteList<T>(Dictionary<string, string> eqdic, int? top) where T : LocalSyncBase
{
List<T> 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<string, string> 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<T>().ToList();
}
var bindingList = new BindingList<T>();
foreach (T t in list)
{
bindingList.Add(t);
}
return bindingList;
}
/// <summary>
/// 获取需要同步的数据 默认一次50条
/// </summary>
/// <typeparam name="T"></typeparam>
public static LocalForSyncList<T> GetNeedSyncList<T>(int top = 50) where T : LocalSyncBase
{
var result = new LocalForSyncList<T>();
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<T> list;
using (var session = LocalDmoSession.New())
{
list = session.ExecuteList(query).Cast<T>().ToList();
}
var willInsertList = new List<T>();
var willUpdateList = new List<T>();
var willDeleteList = new List<T>();
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;
}
}
}

+ 23
- 0
BO/LocalForSyncList.cs View File

@ -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<T> where T:LocalSyncBase
{
public LocalForSyncList()
{
WillInsertList=new List<T>();
WillUpdateList = new List<T>();
WillDeleteList = new List<T>();
}
public List<T> WillInsertList { get; set; }
public List<T> WillUpdateList { get; set; }
public List<T> WillDeleteList { get; set; }
}
}

+ 85
- 0
BO/SyncToServerBase.cs View File

@ -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<T> 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; }
/// <summary>
/// 是否同步完成
/// </summary>
/// <returns></returns>
public bool IsSyncSucessed()
{
lock (lockSucessedObj)
{
var forList = LocalDmoSession.GetNeedSyncList<T>();
//所有集合长度为0时
return forList.WillInsertList.Count == 0 && forList.WillUpdateList.Count == 0 &&forList.WillDeleteList.Count == 0;
}
}
public void SyncToServer()
{
lock (lockObj)
{
var forList = LocalDmoSession.GetNeedSyncList<T>();
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<long>(InsertRpcUrl, json);
LocalDmoSession.UpdateAfterInsertSynced<T>(record.ID, serviceid);
return serviceid;
}
private void Update(T record)
{
var json = JsonConvert.SerializeObject(record);
RpcFacade.Call<int>(UpdateRpcUrl, json);
LocalDmoSession.UpdateAfterUpdateSynced<T>(record.ID);
}
private void Delete(T record)
{
var serviceId = record.Service_ID;
if (serviceId == null)
{
return;
}
RpcFacade.Call<int>(DeleteRpcUrl, serviceId.Value);
LocalDmoSession.UpdateAfterDeleteSynced<T>(record.ID);
}
}
}

+ 15
- 38
BO/Utils/BillRpc/GradeAndWeightRpc.cs View File

@ -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<GradeAndWeight_Detail>().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<GradeAndWeight_Detail>().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<GradeAndWeight_Detail> 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));
}


+ 127
- 0
BO/Utils/UrlUtil.cs View File

@ -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);
}
}
}

+ 0
- 4
ButcherManageClient/ButcherManageClient.csproj View File

@ -106,10 +106,6 @@
<Project>{a782b23e-be6d-4f51-b5cb-5cd259ba97cc}</Project>
<Name>BWP.WinFormControl</Name>
</ProjectReference>
<ProjectReference Include="..\WeighAndGrading\WeighAndGrading.csproj">
<Project>{bfc366e2-994c-433f-9ee2-5377dba9d948}</Project>
<Name>WeighAndGrading</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="pig [128x128].ico" />


+ 35
- 0
TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs View File

@ -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 = "销售出库";
}
}

TrunksIousOutInStore/Dto/TrunksIousOutInStoreFormDto.cs → TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs View File

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

+ 62
- 0
TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs View File

@ -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<TrunksIousOutInStoreRecord>
{
// 定义一个静态变量来保存类的实例
private static TrunksIousOutInStoreRecordRpc uniqueInstance;
// 定义一个标识确保线程同步
private static readonly object locker = new object();
// 定义私有构造函数,使外界不能创建该类实例
private TrunksIousOutInStoreRecordRpc()
{
}
/// <summary>
/// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
/// </summary>
/// <returns></returns>
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 ""; }
}
}
}

+ 19
- 1
TrunksIousOutInStore/TrunksIousOutInStore.csproj View File

@ -33,6 +33,22 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Forks.EnterpriseServices, Version=3.1.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.EnterpriseServices.dll</HintPath>
</Reference>
<Reference Include="Forks.JsonRpc.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.JsonRpc.Client.dll</HintPath>
</Reference>
<Reference Include="Forks.Utils, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.Utils.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
@ -44,7 +60,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Dto\TrunksIousOutInStoreFormDto.cs" />
<Compile Include="Rpc\TrunksIousOutInStoreRecordRpc.cs" />
<Compile Include="LocalSyncBO\TrunksIousOutInStoreRecord.cs" />
<Compile Include="Rpc\TrunksIousOutInStoreFormDto.cs" />
<Compile Include="TrunksIousOutInStoreContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Test.cs">


+ 138
- 101
TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs View File

@ -28,6 +28,7 @@
/// </summary>
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;
}
}

+ 95
- 60
TrunksIousOutInStore/TrunksIousOutInStoreForm.cs View File

@ -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<TrunksIousOutInStoreFormDto> unSumbitList = new BindingList<TrunksIousOutInStoreFormDto>();
BindingList<TrunksIousOutInStoreFormDto> sumbitedList = new BindingList<TrunksIousOutInStoreFormDto>();
BindingList<TrunksIousOutInStoreRecord> unSumbitList = new BindingList<TrunksIousOutInStoreRecord>();
BindingList<TrunksIousOutInStoreRecord> sumbitedList = new BindingList<TrunksIousOutInStoreRecord>();
// ConcurrentQueue<string> barCodequeue=new ConcurrentQueue<string>();
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
}
}

+ 10
- 7
TrunksIousOutInStore/TrunksIousOutInStoreForm.resx View File

@ -126,9 +126,6 @@
<metadata name="产品名称.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="规格.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="数量.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -144,9 +141,6 @@
<metadata name="uncheck产品名称.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="uncheck规格.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="uncheck数量.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -154,6 +148,15 @@
<value>True</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>8, 19</value>
<value>4, 19</value>
</metadata>
<metadata name="timerChectNetStatus.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>98, 19</value>
</metadata>
<metadata name="timerSyncToService.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>273, 19</value>
</metadata>
<metadata name="timerCheckSyncSucessed.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>440, 19</value>
</metadata>
</root>

+ 1
- 1
WeighAndGrading/GradeFrom.cs View File

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


Loading…
Cancel
Save