Exemplo n.º 1
0
        public void Update()
        {
            MSimulator simulator             = this;
            MongoDBHelper <MSimulator> mongo = new MongoDBHelper <MSimulator>();
            var query = new QueryDocument();

            query.Add("_id", simulator._id);
            var update = new UpdateDocument();

            update.Add("Mac", this.Mac);
            update.Add("Key", simulator.Key);
            update.Add("MKeyVer", simulator.MKeyVer);
            update.Add("周期", simulator.周期);
            update.Add("PriceCheck", simulator.PriceCheck);
            update.Add("ValveState", simulator.ValveState);
            update.Add("TotalAmount", simulator.TotalAmount.ToString("0.0000"));
            update.Add("MeterState", simulator.MeterState == null ? "0" : simulator.MeterState);
            update.Add("MeterType", simulator.MeterType);
            update.Add("TotalTopUp", (double)simulator.TotalTopUp);
            update.Add("hostname", simulator.hostname);
            update.Add("port", simulator.port);
            update.Add("SettlementType", simulator.SettlementType == null ? "00" : simulator.SettlementType);
            update.Add("SettlementDay", simulator.SettlementDay);
            update.Add("SettlementMonth", simulator.SettlementMonth);

            update.Add("IsUsedLadder", simulator.IsUsedLadder);
            update.Add("Ladder", simulator.Ladder);
            update.Add("Price1", (double)simulator.Price1);
            update.Add("Gas1", (double)simulator.Gas1);
            update.Add("Price2", (double)simulator.Price2);
            update.Add("Gas2", (double)simulator.Gas2);
            update.Add("Price3", (double)simulator.Price3);
            update.Add("Gas3", (double)simulator.Gas3);
            update.Add("Price4", (double)simulator.Price4);
            update.Add("Gas4", (double)simulator.Gas4);
            update.Add("Price5", (double)simulator.Price5);

            update.Add("LastSettlementAmount", (double)simulator.LastSettlementAmount);
            update.Add("LastTotal", (double)simulator.LastTotal);
            update.Add("CurrentBalance", (double)simulator.CurrentBalance);
            update.Add("出厂状态", simulator.出厂状态);

            update.Add("NextSettlementPointGas", (double)simulator.NextSettlementPointGas);//下一个结算点气量
            update.Add("CurrentLadder", simulator.CurrentLadder);
            update.Add("CurrentPrice", (double)simulator.CurrentPrice);
            update.Add("LastGasPoint", (double)simulator.LastGasPoint);
            update.Add("SettlementDateTime", simulator.SettlementDateTime);



            //if (this.PricingPlan != null)
            //{
            //    MongoDB.Bson.BsonDocument b = new MongoDB.Bson.BsonDocument();
            //    b.Add("IsUsedLadder", this.PricingPlan.IsUsedLadder);
            //    b.Add("Ladder", this.PricingPlan.Ladder);
            //    b.Add("Price1", (double)this.PricingPlan.Price1);
            //    b.Add("Gas1", (double)this.PricingPlan.Gas1);
            //    b.Add("Price2", (double)this.PricingPlan.Price2);
            //    b.Add("Gas2", (double)this.PricingPlan.Gas2);
            //    b.Add("Price3", (double)this.PricingPlan.Price3);
            //    b.Add("Gas3", (double)this.PricingPlan.Gas3);
            //    b.Add("Price4", (double)this.PricingPlan.Price4);
            //    b.Add("Gas4", (double)this.PricingPlan.Gas4);
            //    b.Add("Price5", (double)this.PricingPlan.Price5);
            //    b.Add("MeterType", this.PricingPlan.MeterType);
            //    b.Add("UseDate", this.PricingPlan.UseDate);

            //    update.Add("PricingPlan", b);
            //}

            mongo.Update(TaskCollectionName, query, update);
            if (this.OnJiliang != null)
            {
                this.OnJiliang(this);
            }
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                simulatorList = new List <MSimulator>();

                MSimulator _simulator = null;

                string hostName = System.Configuration.ConfigurationManager.AppSettings["ServerHost"];
                int    port     = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ServerPort"]);


                if (meterIdList == null)
                {
                    meterIdList = new List <string>();
                    //起始表号
                    long meterNoStart = Convert.ToInt64(this.textBox1.Text);

                    //表数目
                    int meterNum = Convert.ToInt32(this.textBox2.Text);

                    for (int i = 0; i < meterNum; i++)
                    {
                        meterIdList.Add((meterNoStart + i).ToString());
                    }
                }

                foreach (string meterNo in meterIdList)
                {
                    _simulator = Query(meterNo);
                    if (_simulator == null)
                    {
                        _simulator                    = new MSimulator();
                        _simulator.hostname           = hostName;
                        _simulator.port               = port;
                        _simulator.周期                 = Convert.ToInt32(this.textBox3.Text);
                        _simulator.Mac                = meterNo;
                        _simulator.Key                = "88888888888888";
                        _simulator.MeterType          = "00";
                        _simulator.MKeyVer            = 0;
                        _simulator.PriceCheck         = "0";
                        _simulator.SettlementDay      = 28;
                        _simulator.SettlementType     = "00";
                        _simulator.TotalAmount        = 0;
                        _simulator.TotalTopUp         = 0;
                        _simulator.ValveState         = "0";
                        _simulator.SettlementDateTime = "2015-01-01";

                        _simulator.SetNextSettlementDateTime();
                        _simulator.Insert();
                    }

                    _simulator.hourLiuLiang = Convert.ToDecimal(this.textBox4.Text);
                    _simulator.hostname     = hostName;
                    _simulator.port         = port;


                    _simulator.Start();
                    simulatorList.Add(_simulator);
                }


                MessageBox.Show("设备上线成功");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }