internal bool Parse_configurationInfo_getGame(s2sMessage target, DLGameCollectionDto collection)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_configurationInfo_getGame");
            bool result = default(bool);

            try
            {
                configurationInfo ci = target.p_body.p_configuration.p_configurationInfo;
                if (collection != null)
                {
                    List<game> Games = new List<game>();
                    foreach (var dto in collection)
                    {
                        Games.Add(new game()
                        {
                            gameId = dto.GameID.ToStringSafe(),
                            gameName = dto.GameName,
                            gameActive = dto.IsActive,
                        });
                    }
                    ci.game = Games.ToArray();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        internal bool Parse_configurationInfo_getManufacturer(s2sMessage target, DLManufacturerCollectionDto collection)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_configurationInfo_getManufacturer");
            bool result = default(bool);

            try
            {
                configurationInfo ci = target.p_body.p_configuration.p_configurationInfo;
                if (collection != null)
                {
                    List<manufacturer> manufacturers = new List<manufacturer>();
                    foreach (var dto in collection)
                    {
                        manufacturers.Add(new manufacturer()
                        {
                            manufacturerId = dto.ManufacturerId.ToString(),
                            manufacturerName = dto.ManufacturerName,
                            manufacturerValue = dto.ManufacturerValue,
                            manufacturerActive = dto.IsActive,
                        });
                    }
                    ci.manufacturer = manufacturers.ToArray();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        internal bool Parse_configurationInfo_getSite(s2sMessage target, DLSiteCollectionDto collection)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_getConfiguration");
            bool result = default(bool);

            try
            {
                configurationInfo ci = target.p_body.p_configuration.p_configurationInfo;
                if (collection != null)
                {
                    List<casino> Casinos = new List<casino>();
                    foreach (var dto in collection)
                    {
                        Casinos.Add(new casino()
                        {
                            casinoId = dto.SiteId,
                            casinoName = dto.SiteName,
                            casinoActive = dto.IsActive
                        });
                    }
                    ci.casino = Casinos.ToArray();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        internal bool Parse_configurationInfo_getGame(s2sMessage target, XElement source)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_configurationInfo_getGame");
            bool result = default(bool);

            try
            {
                if (source != null)
                {
                    var elements = source.GetElements("Game");
                    if (elements != null)
                    {
                        foreach (var element in elements)
                        {
                            game_infoUpdate dto = new game_infoUpdate();
                            dto.gameId = element.GetElementValue("GameID");
                            result = this.AddObjectToInfoUpdateData<game_infoUpdate>(target, dto);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        internal bool Parse_configurationInfo_getDenomination(s2sMessage target, DLDenominationCollectionDto collection)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_configurationInfo_getDenomination");
            bool result = default(bool);

            try
            {
                configurationInfo ci = target.p_body.p_configuration.p_configurationInfo;
                if (collection != null)
                {
                    List<denomination> denominations = new List<denomination>();
                    foreach (var dto in collection)
                    {
                        denominations.Add(new denomination()
                        {
                            denominationId = dto.DenominationId,
                            denominationName = dto.DenominationName,
                            denominationValue = dto.DenominationValue,
                            denominationActive = dto.IsActive,
                        });
                    }
                    ci.denomination = denominations.ToArray();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        private string GetS2SMessageResponse(s2sMessage target)
        {
            // update the timestamp now and sent
            if (target.p_header != null)
                target.p_header.dateTimeSent = DateTime.Now;
            else if (target.p_ack != null)
                target.p_ack.dateTimeSent = DateTime.Now;

            string response = this.ConvertObjectToXml(target, false, false); ;
            Log.Info("[BMC->EBS] Response to be sent : " + response);
            return response;
        }
        internal bool Parse_s2sBody(s2sMessage target, object source)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_s2sBody");
            bool result = default(bool);
            s2sBody s2s = source as s2sBody;

            try
            {
                this.InvokeWork_FromEBS(target, s2s);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        internal bool Parse_s2sHeader(s2sMessage target, object source)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_s2sHeader");
            bool result = default(bool);
            s2sHeader s2s = source as s2sHeader;

            try
            {
                
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        internal bool Parse_configuration(s2sMessage target, object source)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_s2sBody");
            bool result = default(bool);
            configuration s2s = source as configuration;

            try
            {
                target.p_propertyId = s2s.propertyId;                
                this.InvokeWork_FromEBS(target, s2s);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        internal bool Parse_configurationInfo_getGame(s2sMessage target, object source)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_configurationInfo_getGame");
            bool result = default(bool);
            getConfigurationGetGame s2s = source as getConfigurationGetGame;

            try
            {
                DLGameCollectionDto collection = _di.GetGames(target.p_body.p_configuration.propertyId, s2s.gameId.s2sStringId());
                result = this.Parse_configurationInfo_getGame(target, collection);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        private s2sMessage CreateS2SErrorMessage(ref long messageId, string errorCode, string message)
        {
            // prepare the target
            s2sMessage target = new s2sMessage();
            string FromSystem = BMC.CoreLib.Extensions.GetAppSettingValue("FromSystem", "BMC");
            string ToSystem = BMC.CoreLib.Extensions.GetAppSettingValue("ToSystem", "EBS");
            s2sAck ack = new s2sAck()
            {
                fromSystem = FromSystem,
                toSystem = ToSystem,
                messageId = ++messageId,
                errorCode = errorCode,
                errorText = message,
            };
            target.p_ack = ack;
            target.Items = new object[] {
                    ack
                };

            return target;
        }
 private s2sMessage CreateS2SMessage(ref long messageId)
 {
     // prepare the target
     s2sMessage target = new s2sMessage();
     string FromSystem = BMC.CoreLib.Extensions.GetAppSettingValue("FromSystem", "BMC");
     string ToSystem = BMC.CoreLib.Extensions.GetAppSettingValue("ToSystem", "EBS");
     s2sHeader header = new s2sHeader()
     {
         
         fromSystem = FromSystem,
         toSystem = ToSystem,
         messageId = ++messageId,
     };
     s2sBody body = new s2sBody();
     target.p_header = header;
     target.p_body = body;
     target.Items = new object[] {
             header, body
         };
     return target;
 }
        internal bool Parse_configurationInfo_getMachine(s2sMessage target, DLMachineCollectionDto collection)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Parse_configurationInfo_getMachine");
            bool result = default(bool);

            try
            {
                configurationInfo ci = target.p_body.p_configuration.p_configurationInfo;
                if (collection != null)
                {
                    List<machine> Machines = new List<machine>();
                    foreach (var dto in collection)
                    {
                        Machines.Add(new machine()
                        {
                            machineId = dto.MachineID,
                            areaId = dto.Area,
                            gameId = dto.GameName,
                            machineLoc = dto.MachineLoc,
                            machineActive = dto.IsActive,
                            denominationId = dto.DenominationID,
                            manufacturerId = dto.ManufacturerName,
                            casinoId = dto.CasinoID,
                            machineType = dto.MachineType,
                            zoneId = dto.ZoneID,
                            bankId = dto.Bank
                        });
                    }
                    ci.machine = Machines.ToArray();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return result;
        }
        public BMC.EBSComms.Contracts.Messages.SMS2EBS.S2SMessagePostOperationResponse S2SMessagePostOperation(BMC.EBSComms.Contracts.Messages.SMS2EBS.S2SMessagePostOperationRequest request)
        {
            ModuleProc PROC = new ModuleProc("", "Method");

            try
            {
                Console.WriteLine("Received : " + request.Request.Request);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            s2sMessage msg = new s2sMessage();
            s2sHeader hdr = new s2sHeader()
            {
                fromSystem = "EBS",
                toSystem = "SDS",
                dateTimeSent = DateTime.Now,
            };
            s2sBody bdy = new s2sBody()
            {
                Items = new object[] { 
                    new infoUpdate() {
                        propertyId="1313",
                        Item = new infoUpdateDataAck() {}
                    },
                },
            };
            msg.Items = new object[] { hdr, bdy };
            string resp = XmlSerializerHelper.ConvertObjectToXml(msg, null, false, false);

            return new BMC.EBSComms.Contracts.Messages.SMS2EBS.S2SMessagePostOperationResponse
            {
                Response = new BMC.EBSComms.Contracts.Dto.SMS2EBS.ResponseType_13_1()
                  {
                      Response = resp,
                  }
            };
        }
 private object FillS2SMessageToResponse(object result, s2sMessage target)
 {
     if (result.GetType() == typeof(S2SMessagePostOperationSoapOut))
         return FillS2SMessageToResponse(result as S2SMessagePostOperationSoapOut, target);
     else
         return FillS2SMessageToResponse(result as S2SEndPoint_processS2SMessageResponse, target);
 }
 private S2SEndPoint_processS2SMessageResponse FillS2SMessageToResponse(S2SEndPoint_processS2SMessageResponse result, s2sMessage target)
 {
     string response = this.GetS2SMessageResponse(target);
     result.Response = new Contracts.Dto.EBS2SMS.processS2SMessageResponse()
     {
         @return = response
     };
     return result;
 }
 private S2SMessagePostOperationSoapOut FillS2SMessageToResponse(S2SMessagePostOperationSoapOut result, s2sMessage target)
 {
     string response = this.GetS2SMessageResponse(target);
     result.Response = new Contracts.Dto.EBS2SMS.ResponseType()
     {
         response = response
     };
     return result;
 }