private static void CompareTransactionsDataRpcObjects(RpcObject expectedRpcObject, RpcObject actualRpcObject) { var expectedKeys = expectedRpcObject.GetKeys().OrderBy(x => x).ToList(); var actualKeys = actualRpcObject.GetKeys().OrderBy(x => x); Assert.True(expectedKeys.SequenceEqual(actualKeys)); foreach (var key in expectedKeys) { var expected = expectedRpcObject.GetItem(key); var actual = actualRpcObject.GetItem(key); if (expected is RpcValue expectedRpcValue && actual is RpcValue actualRpcValue) { Assert.Equal(expectedRpcValue.ToString(), actualRpcValue.ToString()); continue; } if (expected is RpcObject expectedObj && actual is RpcObject actualObj) { CompareTransactionsDataRpcObjects(expectedObj, actualObj); continue; } throw new ArgumentException("Can't compare key values"); } }
public static string GetSignature(IWallet wallet, RpcObject properties) { var transactionHash = GetTransactionHash(properties); var signature = wallet.Sign(transactionHash); return(Base64.ToBase64String(signature)); }
public static long ProductInStoreSaveAndCheck(ClientProduceOutputBillSave dmo) { try { #region 产出单 var mainObj = "/MainSystem/B3Butchery/BO/ProductInStore"; var detailObj = "/MainSystem/B3Butchery/BO/ProductInStore_Detail"; var obj = new RpcObject(mainObj); obj.Set("ID", dmo.ID); ManyList Details = new ManyList(detailObj); foreach (var detail in dmo.Details) { var objDetail = new RpcObject(detailObj); objDetail.Set("ProductInStore_ID", detail.Bill_ID); objDetail.Set("ID", detail.ID); objDetail.Set("Goods_ID", detail.Goods_ID); objDetail.Set("Number", detail.Goods_Number); Details.Add(objDetail); } obj.Set("Details", Details); var id = RpcFacade.Call <long>("/MainSystem/B3Butchery/Rpcs/ProductInStoreRpc/ProductInStoreSaveAndCheck", obj); return(id); #endregion } catch (Exception ex) { LogUtil.Error(ex.ToString()); return(-2); } }
public static byte[] GetTransactionHash(RpcObject properties) { var serialized = Serialize(properties); var hash = Sha256(serialized); return(hash); }
public Call( RpcObject properties, Type responseType) { _properties = properties; _responseType = responseType; }
public static ClientGoods CreateClientGoods(RpcObject obj) { var goods = new ClientGoods(); goods.Goods_ID = obj.Get <long>("Goods_ID"); goods.Goods_BarCode = obj.Get <string>("Goods_Code"); goods.Goods_Name = obj.Get <string>("Goods_Name"); goods.Goods_MainUnit = obj.Get <string>("Goods_MainUnit"); goods.Goods_SecondUnit = obj.Get <string>("Goods_SecondUnit"); var d = obj.Get <NamedValue>("Goods_UnitConvertDirection"); if (d != null) { if (d.Value == 0) { goods.Goods_UnitConvertDirection = GoodsUnitConvertDirection.双向转换; } else if (d.Value == 1) { goods.Goods_UnitConvertDirection = GoodsUnitConvertDirection.由主至辅; } else if (d.Value == 2) { goods.Goods_UnitConvertDirection = GoodsUnitConvertDirection.由辅至主; } } goods.Goods_MainUnitRatio = obj.Get <decimal?>("Goods_MainUnitRatio"); goods.Goods_SecondUnitRatio = obj.Get <decimal?>("Goods_SecondUnitRatio"); return(goods); }
/// <summary> /// Serializes properties to string /// </summary> public static string Serialize(RpcObject properties) { var builder = new StringBuilder(); builder.Append("icx_sendTransaction."); SerializeObjectItems(builder, properties); return(builder.ToString()); }
private void buttonLogin_Click(object sender, EventArgs e) { var username = textBoxUsername.Text; var password = textBoxPassword.Text; try { this.Enabled = false; AppUtil.EnsureNetworkConnected(); if (string.IsNullOrEmpty(SysConfig.Current.ServerUrl)) { throw new Exception("请先设置服务器Url"); } var serverVersion = RpcFacade.Call <string>("/MainSystem/B3Butchery/Rpcs/ClientRpc/GetPdaVersion"); if (serverVersion != Util.Version) { throw new Exception(string.Format("服务器版本[{0}]与当前客户端版本[{1}]不匹配", serverVersion, Util.Version)); } RpcFacade.Login(username, password); mConfig.Username = username; mConfig.Password = password; Util.OnceLogined = true; //记录会计单位名称 和部门ID,Name mConfig.AccountingUnit_Name = RpcFacade.Call <string>("/MainSystem/B3Butchery/Rpcs/BaseInfoRpc/GetAccountUnitNameById", mConfig.AccountingUnit_ID ?? 0); RpcObject depart = RpcFacade.Call <RpcObject>("/MainSystem/B3Butchery/Rpcs/BaseInfoRpc/GetDepartmentBaseInfoDto"); mConfig.Department_ID = depart.Get <long>("ID"); mConfig.Department_Name = depart.Get <string>("Name"); mConfig.Department_Depth = depart.Get <int?>("Department_Depth"); mConfig.Save(); this.Enabled = true; new MainForm().ShowDialog(); } catch (Exception ex) { if (mConfig.Username == username && mConfig.Password == password) { this.Enabled = true; new MainForm().ShowDialog(); } else { MessageBox.Show("用户离线登录失败," + ex.Message); } } finally { this.Enabled = true; } }
private void button1_Click(object sender, EventArgs e) { List <string> ids = new List <string>(); try { foreach (ListViewItem item in listView1.Items) { if (item.Checked) { var goods = item.Tag as ClientGoods; var number = decimal.Parse(item.SubItems[2].Text); var dmo = new RpcObject("/MainSystem/B3Butchery/BO/FrozenInStore"); dmo.Set("AccountingUnit_ID", SysConfig.Current.AccountingUnit_ID); dmo.Set("Department_ID", SysConfig.Current.Department_ID); dmo.Set("Store_ID", mStoreId); dmo.Set("ProductionPlan_ID", mProductPlanId); var detail = new RpcObject("/MainSystem/B3Butchery/BO/FrozenInStore_Detail"); detail.Set("Goods_ID", goods.Goods_ID); detail.Set("Number", number); dmo.Get <ManyList>("Details").Add(detail); long id = RpcFacade.Call <long>("/MainSystem/B3Butchery/Rpcs/FrozenInStoreRpc/PdaInsertAndCheck", dmo); ids.Add(id.ToString()); } } if (ids.Any(x => x == "0")) { MessageBox.Show("没有速冻入库新建权限"); return; } if (ids.Any(x => x == "-1")) { MessageBox.Show("没有速冻入库审核权限"); return; } MessageBox.Show("生成速冻入库单:" + string.Join(",", ids.ToArray())); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { LoadGoodsFromRpc(); } }
private static TransactionData ConstructTransactionData(RpcObject @object) { return(new TransactionData { Data = @object.GetItem("data"), DataType = @object.GetItem("dataType")?.ToString(), From = new Address(@object.GetItem("from").ToString()), To = new Address(@object.GetItem("to").ToString()), Nid = @object.GetItem("nid")?.ToInteger(), Nonce = @object.GetItem("nonce")?.ToInteger(), StepLimit = @object.GetItem("stepLimit")?.ToInteger(), Timestamp = @object.GetItem("timestamp")?.ToInteger(), Value = @object.GetItem("value")?.ToInteger(), Version = @object.GetItem("version").ToInteger() }); }
private static void SerializeObjectItems(StringBuilder builder, RpcObject @object) { var firstItem = true; foreach (var key in @object.GetKeys().OrderBy(x => x)) { if (firstItem) { firstItem = false; } else { builder.Append("."); } Serialize(builder.Append(key).Append("."), @object.GetItem(key)); } }
private static object FromRpcObject <T>(RpcObject @object) { var type = typeof(T); if (type.IsAssignableFrom(typeof(RpcObject))) { return(@object); } var result = new Dictionary <string, object>(); var keys = @object.GetKeys(); foreach (var key in keys) { var v = FromRpcItem(@object.GetItem(key)); if (v != null) { result[key] = v; } } return(result); }
public ScoreApi(RpcObject properties) { _properties = properties; }
public SignedTransaction(ITransaction transaction, IWallet wallet) { _transaction = transaction; _properties = CreateProperties(transaction, wallet); }
protected SignedTransaction(ITransaction transaction, RpcObject properties) { _transaction = transaction; _properties = properties; }
/// <summary> /// Serializes the properties /// </summary> public static string Serialize(RpcObject properties) { return(TransactionSerializer.Serialize(properties)); }
public ConfirmedTransaction(RpcObject properties) { _properties = properties; }
public TransactionResult(RpcObject properties) { _properties = properties; }
public Block(RpcObject properties) { _properties = properties; }
public EventLog(RpcObject properties) { _properties = properties; }
public static void SyncProductInStore() { try { #region 成品出库 string productInStoreFoder = Path.Combine(Util.DataFolder, typeof(ClientProductInStore).Name); ClientProductInStore productInStore; if (!Directory.Exists(productInStoreFoder)) { Directory.CreateDirectory(productInStoreFoder); } string[] productInStoreFiles = Directory.GetFiles(productInStoreFoder, "*.xml"); if (productInStoreFiles.Count() != 0 && Util.OnceLogined) { foreach (var file in productInStoreFiles) { XmlSerializer serializer = new XmlSerializer(typeof(ClientProductInStore)); using (var stream = File.Open(file, FileMode.Open)) { productInStore = serializer.Deserialize(stream) as ClientProductInStore; if (productInStore.IsSend) { continue; } var mainObj = "/MainSystem/B3Butchery/BO/ProductInStore"; var detailObj = "/MainSystem/B3Butchery/BO/ProductInStore_Detail"; var obj = new RpcObject(mainObj); //obj.Set("Department_ID", productInStore.Department_ID); //obj.Set("CreateTime", productInStore.CreateTime); //obj.Set("Domain_ID", productInStore.Domain_ID); //obj.Set("CreateUser_ID", productInStore.User_ID); //obj.Set("PlanNumber_ID", productPlanGroupBy.Key); //obj.Set("ProductLinks_ID", productLink.ProductLinks_ID); ManyList Details = new ManyList(detailObj); foreach (var detail in productInStore.GoodsDetails) { var objDetail = new RpcObject(detailObj); objDetail.Set("Goods_ID", detail.Goods_ID); objDetail.Set("Number", detail.Goods_Number); Details.Add(objDetail); } obj.Set("Details", Details); RpcFacade.Call <long>("/MainSystem/B3Butchery/Rpcs/ProductInStoreRpc/InsertProductInStore", obj); } productInStore.IsSend = true; using (var stream = File.Create(file)) { serializer.Serialize(stream, productInStore); } } } #endregion } catch (Exception ex) { LogUtil.Error(ex.ToString()); } }
public Failure(RpcObject properties) { _properties = properties; }
public Param(RpcObject properties) { _properties = properties; }
/// <summary> /// Sets params /// </summary> public DeployBuilder Params(RpcObject @params) { _dataBuilder.Put("params", @params); return(this); }