Esempio n. 1
0
        public bool InsertGMULogin(MonTgt_G2H_GIM_GameIDInfo monTgt_Msg, string iPAddress, ref int?installationNo, ref int?assetNo, ref string gamePrefix)
        {
            int?status = 0;

            try
            {
                using (ExCommsSQLDataAccess DataContext = this.GetDataContext())
                {
                    DataContext.usp_InsertAndGet_GMU_Login(null,
                                                           iPAddress,
                                                           monTgt_Msg.MACAddress,
                                                           monTgt_Msg.AssetNumber,
                                                           monTgt_Msg.GMUNumber,
                                                           monTgt_Msg.SerialNumber,
                                                           monTgt_Msg.SASVersion,
                                                           monTgt_Msg.GMUVersion,
                                                           ref installationNo,
                                                           ref status,
                                                           ref assetNo,
                                                           ref gamePrefix);
                    Log.Info("InsertGMULogin: Asset No : " + assetNo.ToString() + ", Poker Game Prefix : " + gamePrefix);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                return(false);
            }
        }
        /// <summary>
        /// TO process GameIdInfo message
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private bool ProcessGameIdInfoMessage(MonMsg_G2H request)
        {
            try
            {
                MonTgt_G2H_GIM_GameIDInfo monTgtMsg = request.Targets[0] as MonTgt_G2H_GIM_GameIDInfo;
                if (monTgtMsg == null)
                {
                    return(false);
                }

                int?   installationNo = 0;
                string assetNo        = string.Empty;
                char?  gamePrefix     = '\0';

                if (GIM_DataAccess.GetInstance().InsertGMULogin(monTgtMsg, request.IpAddress, ref installationNo, ref assetNo, ref gamePrefix))
                {
                    MonMsg_H2G monH2G_Msg = new MonMsg_H2G();
                    MonTgt_H2G_GIM_GameIDInfo monH2G_GameIdInfo_Msg = new MonTgt_H2G_GIM_GameIDInfo();

                    monH2G_Msg.FaultSource    = Convert.ToInt32(FaultSource.GIM_Event);
                    monH2G_Msg.FaultType      = Convert.ToInt32(FaultType_GIM.Game_Id_Info_H2G);
                    monH2G_Msg.IpAddress      = request.IpAddress;
                    monH2G_Msg.InstallationNo = installationNo.GetValueOrDefault();

                    monH2G_GameIdInfo_Msg.SourceAddress   = new System.Net.IPAddress(Convert.ToByte(request.IpAddress));
                    monH2G_GameIdInfo_Msg.AssetNumber     = assetNo;
                    monH2G_GameIdInfo_Msg.PokerGamePrefix = gamePrefix.ToString();

                    monH2G_Msg.AddTarget(monH2G_GameIdInfo_Msg);
                    this.ProcessH2GMessage(monH2G_Msg);
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                return(false);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.Title = "ExCommsServer Testing";
            Console.SetWindowSize(80, 58);

            BMCRegistryHelper.ActiveInstallationType = BMCCategorizedInstallationTypes.Exchange;
            Log.AddAppFileLoggingSystem();
            Log.GlobalWriteToExternalLog += Log_GlobalWriteToExternalLog;

            TestPIDData();
            //MonMsg_H2G monH2G = new MonMsg_H2G();
            //MonTgt_H2G_AckNack nack = new MonTgt_H2G_AckNack();
            //nack.Nack = true;
            //monH2G.AddTarget(nack);
            //var msg2 = MonitorEntityFactory.CreateEntity(monH2G);
            //var ffBuffer = FreeformEntityFactory.CreateBuffer(msg2);

            var configStore = ExMonitorServerConfigStoreFactory.Store;
            var cat         = ErrorEventCategoryFactory.Categories;

            string       barcode = "889900027000052237";
            TicketIDInfo idInfo  = new TicketIDInfo(barcode);
            int          seqno   = idInfo.SequenceNumber;
            //byte[] packed = FreeformHelper.GetBCDToBytes(sUnpacked, sUnpacked.Length / 2);
            //string sUnpacked2 = packed.GetBCDValueString(0, 0, 9);



            //EncryptSecurity();

            //var dr = ExCommsDataContext.Current.GetMeterDeltaForPlayerSession(27, "1000012345", "IR");
            //ExecutionStepsTest();
            //return;

            //ExCommsHostingModuleTypeHelper.Current.SetAll();
            //_server = new ExCommsServerImpl(ExecutorServiceFactory.CreateExecutorService());
            //_server.Start();
            IExecutorService exec = ExecutorServiceFactory.CreateExecutorService();
            //ExecutionStepFactory.Initialize(exec, false, ExecutionStepDeviceTypes.GMU);
            //FFMsgHandlerFactory.Initialize(exec, FFTgtHandlerDeviceTypes.GMU, () =>
            //{
            //    return new FFMsgTransmitter();
            //});
            MonTgt_G2H_GIM_GameIDInfo  target = new MonTgt_G2H_GIM_GameIDInfo();
            MonTgt_G2H_GVA_TED_Request r      = new MonTgt_G2H_GVA_TED_Request();

            //TestGIM();

            //Console.ForegroundColor = ConsoleColor.Cyan;
            //GenerateKeys(SECURITY_KEY_INDEX.TICKET_KEY, IPADDR);
            //GenerateKeys(SECURITY_KEY_INDEX.EFT_KEY, IPADDR);
            //Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Start ExComms Server?");
            Console.ResetColor();
            string anser = "y";// Console.ReadLine();

            if (anser == "y")
            {
                var activators =
                    MEFHelper.GetExportedValues <IExCommsServerHostFactoryActivator>();

                ExCommsServerHostFactoryActivatorFactory factory = new ExCommsServerHostFactoryActivatorFactory(exec,
                                                                                                                ExCommsHostingModuleType.CommunicationServer |
                                                                                                                ExCommsHostingModuleType.MonitorServer4CommsServer |
                                                                                                                ExCommsHostingModuleType.MonitorServer4MonProcessor
                                                                                                                ,
                                                                                                                activators);
                factory.Start();
            }

            long ticks = DateTime.Now.Ticks;

            byte[] lohi = FFDataTypeHelper.GetInt64Bytes(ticks, FFEndianType.LittleEndian);
            //TestGIM();

            while (true)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Press any key to continue...");
                Console.ResetColor();
                string s = Console.ReadLine();
                if (s == "q")
                {
                    return;
                }

                //TestEncryptedTicketMessage();
                //InitKeyExchangeStart();
                //if (s == "k1") InitKeyExchangeStartG2H();
                //if (s == "k2") InitKeyExchangeEnd();
                //if (s == "t") GenerateKeys(SECURITY_KEY_INDEX.TICKET_KEY);
                //if (s == "e") GenerateKeys(SECURITY_KEY_INDEX.EFT_KEY);
                if (s == "g")
                {
                    ExecutionStepsTest();
                }
                if (s == "ss")
                {
                    EncryptSecurity();
                }
                if (s == "pci")
                {
                    TestPlayerCardIn();
                }
                if (s == "pco")
                {
                    TestPlayerCardOut();
                }
                if (s == "bal")
                {
                    TestECashBalanceRequest();
                }
            }
            //TestKeyExchangePartialKey();
            return;

            //short sval = 9999;
            //short ss1 = sval;
            //List<byte> ll = new List<byte>();
            //while (true)
            //{
            //    byte b1 = (byte)(ss1 % 10);
            //    ll.Add(b1);
            //    ss1 /= 10;
            //}

            byte[] b1234 = new byte[] { 0x12, 0x34, 0x56, 0x78 };
            ulong  u     = b1234.GetBytesToBCDUInt64(0, 4);
            int    v     = 99999;
            byte   b1    = (byte)(v & 0x0F);
            byte   b2    = (byte)((v >> 4) & 0x0F);

            byte[] buf = "1000500026".GetBCDToBytes(5);
            byte[] iv  = FFDataTypeHelper.GetInt32Bytes(99999, FFEndianType.LittleEndian);
            byte[] sb1 = FFDataTypeHelper.GetInt16Bytes(9999, FFEndianType.LittleEndian);
            byte[] sb2 = FFDataTypeHelper.GetInt16Bytes(9999, FFEndianType.BigEndian);
            short  s1  = FFDataTypeHelper.GetInt16(sb1, FFEndianType.LittleEndian);
            short  s2  = FFDataTypeHelper.GetInt16(sb2, FFEndianType.BigEndian);

            string cc = "1A345";

            byte[] b = cc.GetHexBytesValue(2);
            //FF_AppId_SessionIds sval = FFEnumParserFactory.GetAppId<FF_GmuId_SessionIds, FF_AppId_SessionIds>(FF_GmuId_SessionIds.ECash);
            //FF_GmuId_SessionIds ss2 = FFEnumParserFactory.GetGmuId<FF_AppId_SessionIds, FF_GmuId_SessionIds>(FF_AppId_SessionIds.GIM);

            //byte b = 23;
            //FF_AppId_SessionIds ss3 = b.GetAppId<FF_GmuId_SessionIds, FF_AppId_SessionIds>();
        }
        protected override bool OnExecuteInternal(MonitorExecutionContext context, MonitorEntity_MsgTgt target)
        {
            using (ILogMethod method = Log.LogMethod("MonitorHandler_GIM", "OnExecuteInternal"))
            {
                try
                {
                    MonMsg_G2H msgSrc = context.G2HMessage;
                    MonTgt_G2H_GIM_GameIDInfo tgtSrc = target as MonTgt_G2H_GIM_GameIDInfo;
                    method.Info("GIM (CALL): IP Address : " + msgSrc.IpAddress +
                                ", Asset No : " + tgtSrc.AssetNumber.ToStringSafe() +
                                ", GMU No : " + tgtSrc.GMUNumber.ToStringSafe() +
                                ", Serial No : " + tgtSrc.SerialNumber.ToStringSafe());

                    int?   installationNo  = 0;
                    int?   assetNo         = 0;
                    string pokerGamePrefix = string.Empty;

                    if (ExCommsDataContext.Current.InsertGMULogin(tgtSrc, msgSrc.IpAddress,
                                                                  ref installationNo, ref assetNo, ref pokerGamePrefix))
                    {
                        int       assetNoInt    = assetNo.SafeValue();
                        IPAddress hostIPAddress = null;

                        // get the ip address
                        if (_configExchange.Honeyframe_Cashmaster_Exchange_EnableDhcp == 1)
                        {
                            hostIPAddress = _configExchange.Honeyframe_Cashmaster_BMCDHCP_ServerIP.ToIPAddress();
                        }
                        else
                        {
                            hostIPAddress = _configExchange.Honeyframe_Cashmaster_Exchange_interface.ToIPAddress();
                        }
                        method.InfoV("GIM (Success): Installation no ({1:D}), Asset No : {2:D}, Game Prefix : {3} for IP : {0}, from Host : {4}",
                                     msgSrc.IpAddress, installationNo, assetNoInt,
                                     pokerGamePrefix, hostIPAddress.ToString());
                        int installationNo2 = installationNo.SafeValue();

                        if (installationNo2 > 0)
                        {
                            MonMsg_H2G msgDest = new MonMsg_H2G()
                            {
                                InstallationNo = installationNo2,
                                IpAddress      = msgSrc.IpAddress,
                            };
                            MonTgt_H2G_GIM_GameIDInfo tgtDest = new MonTgt_H2G_GIM_GameIDInfo();
                            tgtDest.SourceAddress          = hostIPAddress;
                            tgtDest.EnableNetworkMessaging = true;
                            if (_configStore.Iview3AssetNum)
                            {
                                tgtDest.AssetNumberInt  = assetNoInt;
                                tgtDest.PokerGamePrefix = pokerGamePrefix.ToString();
                            }

                            // update the installation no
                            ExMonitorServerImpl.Current
                            .UpdateCommsServerHostAddress(installationNo2, msgSrc.HostIpAddress)
                            .UpdateInstallatioIpAddress(installationNo2, msgSrc.IpAddress);

                            // add the target and process
                            msgSrc.InstallationNo = installationNo2;
                            msgDest.Targets.Add(tgtDest);
                            context.H2GMessage = msgDest;
                            return(true);
                        }
                    }
                    else
                    {
                        method.InfoV("GIM (Failure): Unable to get the installation no for IP : {0}", msgSrc.IpAddress);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
                return(false);
            }
        }