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");
            }
        }
Exemplo n.º 2
0
        public static string GetSignature(IWallet wallet, RpcObject properties)
        {
            var transactionHash = GetTransactionHash(properties);
            var signature       = wallet.Sign(transactionHash);

            return(Base64.ToBase64String(signature));
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        public static byte[] GetTransactionHash(RpcObject properties)
        {
            var serialized = Serialize(properties);
            var hash       = Sha256(serialized);

            return(hash);
        }
Exemplo n.º 5
0
 public Call(
     RpcObject properties,
     Type responseType)
 {
     _properties   = properties;
     _responseType = responseType;
 }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 8
0
        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;
            }
        }
Exemplo n.º 9
0
        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));
            }
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
 public ScoreApi(RpcObject properties)
 {
     _properties = properties;
 }
Exemplo n.º 14
0
 public SignedTransaction(ITransaction transaction, IWallet wallet)
 {
     _transaction = transaction;
     _properties  = CreateProperties(transaction, wallet);
 }
Exemplo n.º 15
0
 protected SignedTransaction(ITransaction transaction, RpcObject properties)
 {
     _transaction = transaction;
     _properties  = properties;
 }
Exemplo n.º 16
0
 /// <summary>
 ///     Serializes the properties
 /// </summary>
 public static string Serialize(RpcObject properties)
 {
     return(TransactionSerializer.Serialize(properties));
 }
Exemplo n.º 17
0
 public ConfirmedTransaction(RpcObject properties)
 {
     _properties = properties;
 }
Exemplo n.º 18
0
 public TransactionResult(RpcObject properties)
 {
     _properties = properties;
 }
Exemplo n.º 19
0
 public Block(RpcObject properties)
 {
     _properties = properties;
 }
Exemplo n.º 20
0
 public EventLog(RpcObject properties)
 {
     _properties = properties;
 }
Exemplo n.º 21
0
        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());
            }
        }
Exemplo n.º 22
0
 public Failure(RpcObject properties)
 {
     _properties = properties;
 }
Exemplo n.º 23
0
 public Param(RpcObject properties)
 {
     _properties = properties;
 }
Exemplo n.º 24
0
 /// <summary>
 ///    Sets params
 /// </summary>
 public DeployBuilder Params(RpcObject @params)
 {
     _dataBuilder.Put("params", @params);
     return(this);
 }