Пример #1
0
 /// <summary>
 /// 获得售气控件方法对象
 /// </summary>
 /// <param name="EventName"></param>
 /// <returns></returns>
 public dynamic GetSellEvent(string EventName)
 {
     AutomationFactory.GetEvent(sellobj, EventName);
     return(obj);
 }
Пример #2
0
 public dynamic GetEvent(string EventName)
 {
     AutomationFactory.GetEvent(pos, EventName);
     return(pos);
 }
Пример #3
0
 /// <summary>
 /// 表类型转换
 /// </summary>
 /// <param name="factoryid"></param>
 /// <returns></returns>
 private string FactoryTypeConver(long factoryid)
 {
     if (factoryid == 0 || factoryid == 1 || factoryid == 2)
     {
         //再判断是否是化解加密
         AutomationFactory.GetEvent(obj, "GetCardType");
         var huajie = obj.GetCardType();
         if (huajie == 4)
         {
             return("华捷普通");
         }
         return("华捷加密");
     }
     else if (factoryid == 3)
     {
         return("秦港");
     }
     else if (factoryid == 4)
     {
         return("秦川");
     }
     else if (factoryid == 5)
     {
         return("天庆");
     }
     else if (factoryid == 6)
     {
         return("致力老表");
     }
     else if (factoryid == 7)
     {
         return("致力新表");
     }
     else if (factoryid == 8)
     {
         return("赛福");
     }
     else if (factoryid == 13)
     {
         return("天然气无线");
     }
     else if (factoryid == 14)
     {
         return("工业无线");
     }
     else if (factoryid == 15)
     {
         return("秦港民用无线");
     }
     else if (factoryid == 16)
     {
         return("秦刚工业无线");
     }
     else if (factoryid == -1)
     {
         return("新卡");
     }
     else
     {
         return("未知卡");
     }
 }
Пример #4
0
 /// <summary>
 /// 获得cpu控件方法对象
 /// </summary>
 /// <param name="EventName">方法名</param>
 /// <returns></returns>
 public dynamic GetCpuEvent(string EventName)
 {
     AutomationFactory.GetEvent(cpuobj, EventName);
     return(obj);
 }
Пример #5
0
        //格式化卡
        public void MakeNewCard()
        {
            IsBusy = true;
            Error  = "";
            State  = State.Start;
            //执行写卡线程
            Thread thread = new Thread(() =>
            {
                dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
                AutomationFactory.GetEvent(ocx, "ReadGasCard");
                int openRen = ocx.ReadGasCard();
                //读卡失败
                if (openRen != 0)
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        Error = "擦卡不成功!错误代码" + openRen;
                        State = State.Error;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            Error = "擦卡不成功!错误代码" + openRen;
                            State = State.Error;
                        });
                    }
                }
                else
                {
                    //获取擦卡所需数据
                    AutomationFactory.GetEvent(ocx, "GetCardId");
                    string _cardId = ocx.GetCardId();
                    AutomationFactory.GetEvent(ocx, "GetFactory");
                    string _factory = ocx.GetFactory();
                    AutomationFactory.GetEvent(ocx, "GetKlx");
                    int _klx = ocx.GetKlx();
                    AutomationFactory.GetEvent(ocx, "GetDqdm");
                    string _dqdm = ocx.GetDqdm();
                    //擦卡
                    AutomationFactory.GetEvent(ocx, "FormatGasCard");
                    int sellRen = ocx.FormatGasCard(_factory, Kmm, _klx, _cardId, _dqdm);
                    //售气成功返回true,失败false;
                    if (sellRen == 0)
                    {
                        if (this.Dispatcher.CheckAccess())
                        {
                            State = State.End;
                        }
                        else
                        {
                            this.Dispatcher.BeginInvoke(() =>
                            {
                                State = State.End;
                            });
                        }
                    }
                    else
                    {
                        if (this.Dispatcher.CheckAccess())
                        {
                            Error = "擦卡不成功!错误代码" + sellRen;
                            State = State.Error;
                        }
                        else
                        {
                            this.Dispatcher.BeginInvoke(() =>
                            {
                                Error = "擦卡不成功!错误代码" + sellRen;
                                State = State.Error;
                            });
                        }
                    }
                }
                //IsBusy=false;
                if (this.Dispatcher.CheckAccess())
                {
                    IsBusy = false;
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        IsBusy = false;
                    });
                }
                if (this.Dispatcher.CheckAccess())
                {
                    OnCompleted(null);
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        OnCompleted(null);
                    });
                }
            });

            thread.Start();
        }
Пример #6
0
        //格式化卡
        public void ReWriteCard()
        {
            IsBusy = true;
            Error  = "";
            State  = State.Start;
            //执行写卡线程
            Thread thread = new Thread(() =>
            {
                dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
                AutomationFactory.GetEvent(ocx, "ReadGasCard");
                int openRen = ocx.ReadGasCard();
                //读卡失败
                if (openRen != 0)
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        Error = "擦卡不成功!错误代码" + openRen;
                        State = State.Error;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            Error = "擦卡不成功!错误代码" + openRen;
                            State = State.Error;
                        });
                    }
                }
                else
                {
                    //获取擦卡所需数据
                    AutomationFactory.GetEvent(ocx, "GetCardId");
                    string _cardId = ocx.GetCardId();
                    AutomationFactory.GetEvent(ocx, "GetFactory");
                    string _factory = ocx.GetFactory();
                    AutomationFactory.GetEvent(ocx, "GetKlx");
                    int _klx = ocx.GetKlx();
                    AutomationFactory.GetEvent(ocx, "GetDqdm");
                    string _dqdm = ocx.GetDqdm();
                    //擦卡
                    AutomationFactory.GetEvent(ocx, "FormatGasCard");
                    int sellRen = ocx.FormatGasCard(_factory, Kmm, _klx, _cardId, _dqdm);
                    //擦卡后,写初始化卡
                    if (sellRen == 0)
                    {
                        //写初始化卡
                        AutomationFactory.GetEvent(ocx, "WriteGasCard");
                        sellRen = ocx.WriteNewCard(Factory, Kmm, Klx, Kzt, CardId, Dqdm, Yhh, Tm, Gas, BuyTimes, Ljgql, Bkcs, Bjql, Czsx, Tzed, Sqrq, OldPrice, NewPrice, Sxrq, Sxbj);
                        //售气成功返回true,失败false;
                        AutomationFactory.GetEvent(ocx, "GetKmm");
                        kmm = ocx.GetKmm();
                        if (sellRen == 0)
                        {
                            if (this.Dispatcher.CheckAccess())
                            {
                                State = State.End;
                            }
                            else
                            {
                                this.Dispatcher.BeginInvoke(() =>
                                {
                                    State = State.End;
                                });
                            }
                        }
                        else
                        {
                            if (this.Dispatcher.CheckAccess())
                            {
                                Error = "发卡不成功!错误代码" + sellRen;
                                State = State.Error;
                            }
                            else
                            {
                                this.Dispatcher.BeginInvoke(() =>
                                {
                                    Error = "发卡不成功!错误代码" + sellRen;
                                    State = State.Error;
                                });
                            }
                        }
                    }
                    else
                    {
                        if (this.Dispatcher.CheckAccess())
                        {
                            Error = "擦卡不成功!错误代码" + sellRen;
                            State = State.Error;
                        }
                        else
                        {
                            this.Dispatcher.BeginInvoke(() =>
                            {
                                Error = "擦卡不成功!错误代码" + sellRen;
                                State = State.Error;
                            });
                        }
                    }
                }
                //IsBusy=false;
                if (this.Dispatcher.CheckAccess())
                {
                    IsBusy = false;
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        IsBusy = false;
                    });
                }
                if (this.Dispatcher.CheckAccess())
                {
                    OnCompleted(null);
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        OnCompleted(null);
                    });
                }
            });

            thread.Start();
        }
Пример #7
0
        //发初始化卡,或补卡 0:开户卡状态,1:用户卡状态。 卡状态
        public void ReInitCard()
        {
            IsBusy = true;
            Error  = "";
            State  = State.Start;
            State  = State.End;
            return;

            //执行写卡线程
            Thread thread = new Thread(() =>
            {
                dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
                AutomationFactory.GetEvent(ocx, "WriteGasCard");
                //  int sellRen = ocx.WriteNewCard(Factory, Kmm, Klx, Kzt, CardId, Dqdm, Yhh, Tm, Gas, BuyTimes, Ljgql, Bkcs, Bjql, Czsx, Tzed, Sqrq, OldPrice, NewPrice, Sxrq, Sxbj);
                int sellRen = ocx.WriteNewCard(Factory, Kmm, Klx, Kzt, CardId, Dqdm, Yhh, Tm, Gas, BuyTimes, Ljgql, Bkcs, Bjql, Czsx, Tzed, Sqrq, OldPrice, NewPrice, Sxrq, Sxbj);
                //IsBusy=false;
                AutomationFactory.GetEvent(ocx, "GetKmm");
                kmm = ocx.GetKmm();
                if (this.Dispatcher.CheckAccess())
                {
                    IsBusy = false;
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        IsBusy = false;
                    });
                }
                //售气成功返回true,失败false;
                if (sellRen == 0)
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        State = State.End;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            State = State.End;
                        });
                    }
                }
                else
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        Error = "发卡不成功!错误代码" + sellRen;
                        State = State.Error;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            Error = "发卡不成功!错误代码" + sellRen;
                            State = State.Error;
                        });
                    }
                }
                if (this.Dispatcher.CheckAccess())
                {
                    OnCompleted(null);
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        OnCompleted(null);
                    });
                }
            });

            thread.Start();
        }
Пример #8
0
        /// <summary>
        /// 读卡
        /// </summary>
        public void ReadCard()
        {
            IsBusy = true;
            Error  = "";
            State  = State.StartLoad;
            //卡上信息初始化
            CardId   = "";
            Factory  = "";
            Gas      = 0;
            BuyTimes = 0;
            Klx      = -1;
            Kzt      = -1;
            Dqdm     = "";
            Yhh      = "";
            Tm       = "";
            Ljgql    = 0;
            Bkcs     = 0;
            Ljyql    = 0;
            Syql     = 0;
            Bjql     = 0;
            Czsx     = 0;
            Tzed     = 0;
            Sqrq     = "";
            OldPrice = 0;
            NewPrice = 0;
            // Sxrq = "";
            Sxbj = "";
            //读卡
            Thread thread = new Thread(() =>
            {
                dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
                AutomationFactory.GetEvent(ocx, "ReadGasCard");
                int openRen = ocx.ReadGasCard();
                //IsBusy=false;
                if (this.Dispatcher.CheckAccess())
                {
                    IsBusy = false;
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        IsBusy = false;
                    });
                }
                if (openRen == 0)
                {
                    //获取卡上内容
                    AutomationFactory.GetEvent(ocx, "GetCardId");
                    string cardId = ocx.GetCardId();
                    AutomationFactory.GetEvent(ocx, "GetFactory");
                    string factory = ocx.GetFactory();
                    AutomationFactory.GetEvent(ocx, "GetGas");
                    double gas = ocx.GetGas();
                    AutomationFactory.GetEvent(ocx, "GetTimes");
                    int buyTimes = ocx.GetTimes();
                    AutomationFactory.GetEvent(ocx, "GetKlx");
                    int klx = ocx.GetKlx();
                    AutomationFactory.GetEvent(ocx, "GetKzt");
                    int kzt = ocx.GetKzt();
                    AutomationFactory.GetEvent(ocx, "GetDqdm");
                    string dqdm = ocx.GetDqdm();
                    AutomationFactory.GetEvent(ocx, "GetYhh");
                    string yhh = ocx.GetYhh();
                    AutomationFactory.GetEvent(ocx, "GetTm");
                    string tm = ocx.GetTm();
                    AutomationFactory.GetEvent(ocx, "GetLjgql");
                    double ljgql = ocx.GetLjgql();
                    AutomationFactory.GetEvent(ocx, "GetBkcs");
                    int bkcs = ocx.GetBkcs();
                    AutomationFactory.GetEvent(ocx, "GetLjyql");
                    double ljyql = ocx.GetLjyql();
                    AutomationFactory.GetEvent(ocx, "GetSyql");
                    double syql = ocx.GetSyql();
                    AutomationFactory.GetEvent(ocx, "GetBjql");
                    int bjql = ocx.GetBjql();
                    AutomationFactory.GetEvent(ocx, "GetCzsx");
                    int czsx = ocx.GetCzsx();
                    AutomationFactory.GetEvent(ocx, "GetTzed");
                    int tzed = ocx.GetTzed();
                    AutomationFactory.GetEvent(ocx, "GetSqrq");
                    string sqrq = ocx.GetSqrq();
                    AutomationFactory.GetEvent(ocx, "GetOldPrice");
                    int oldprice = ocx.GetOldPrice();
                    AutomationFactory.GetEvent(ocx, "GetNewPrice");
                    int newprice = ocx.GetNewPrice();
                    AutomationFactory.GetEvent(ocx, "GetSxrq");
                    string sxrq = ocx.GetSxrq();
                    AutomationFactory.GetEvent(ocx, "GetSxbj");
                    string sxbj = ocx.GetSxbj();
                    //直接赋值
                    if (this.Dispatcher.CheckAccess())
                    {
                        CardId   = cardId;
                        Factory  = factory;
                        Gas      = gas;
                        BuyTimes = buyTimes;
                        Klx      = klx;
                        Kzt      = kzt;
                        Dqdm     = dqdm;
                        Yhh      = yhh;
                        Tm       = tm;
                        Ljgql    = ljgql;
                        Bkcs     = bkcs;
                        Ljyql    = ljyql;
                        Syql     = syql;
                        Bjql     = bjql;
                        Czsx     = czsx;
                        Tzed     = tzed;
                        Sqrq     = sqrq;
                        OldPrice = oldprice;
                        NewPrice = newprice;
                        //Sxrq = sxrq;
                        Sxbj  = sxbj;
                        State = State.Loaded;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            CardId   = cardId;
                            Factory  = factory;
                            Gas      = gas;
                            BuyTimes = buyTimes;
                            Klx      = klx;
                            Kzt      = kzt;
                            Dqdm     = dqdm;
                            Yhh      = yhh;
                            Tm       = tm;
                            Ljgql    = ljgql;
                            Bkcs     = bkcs;
                            Ljyql    = ljyql;
                            Syql     = syql;
                            Bjql     = bjql;
                            Czsx     = czsx;
                            Tzed     = tzed;
                            Sqrq     = sqrq;
                            OldPrice = oldprice;
                            NewPrice = newprice;
                            // Sxrq = sxrq;
                            Sxbj  = sxbj;
                            State = State.Loaded;
                        });
                    }
                }
                else
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        Error = "读卡错误!错误代码" + openRen;
                        State = State.LoadError;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            Error = "读卡错误!错误代码" + openRen;
                            State = State.LoadError;
                        });
                    }
                }
                if (this.Dispatcher.CheckAccess())
                {
                    OnReadCompleted(null);
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        OnReadCompleted(null);
                    });
                }
            });

            thread.Start();
        }
Пример #9
0
        //气量大于0代表购气,气量等于0代表退气
        public void SellGas()
        {
            IsBusy = true;
            Error  = "";
            State  = State.Start;
            //执行写卡线程
            Thread thread = new Thread(() =>
            {
                dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
                AutomationFactory.GetEvent(ocx, "WriteGasCard");
                string kmm1 = Kmm.Replace("\\", "/");
                kmm1        = kmm1.Replace("/", "\\");

                int sellRen = ocx.WriteGasCard(Factory, kmm1, Klx, CardId, Dqdm, Gas, BuyTimes, Ljgql, Bjql, Czsx, Tzed, Sqrq);
                //IsBusy=false;
                AutomationFactory.GetEvent(ocx, "GetKmm");
                string mm = ocx.GetKmm();
                if (this.Dispatcher.CheckAccess())
                {
                    Kmm    = mm;
                    IsBusy = false;
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        Kmm    = mm;
                        IsBusy = false;
                    });
                }
                //售气成功返回true,失败false;
                if (sellRen == 0)
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        State = State.End;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            State = State.End;
                        });
                    }
                }
                else
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        Error = "售气不成功!错误代码" + sellRen;
                        State = State.Error;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            Error = "售气不成功!错误代码" + sellRen;
                            State = State.Error;
                        });
                    }
                }
                if (this.Dispatcher.CheckAccess())
                {
                    OnCompleted(null);
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        OnCompleted(null);
                    });
                }
            });

            thread.Start();
        }