// ------------------------------------------------------------------------------
// <auto-generated>
// 這段程式碼是由工具產生的。
// 執行階段版本:4.0.30319.42000
// 
// 對這個檔案所做的變更可能會造成錯誤的行為，而且如果重新產生程式碼，
// 變更將會遺失。
// </auto-generated>
// ------------------------------------------------------------------------------


using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Web.Services;
using System.Web.Services.Protocols;
using Microsoft.VisualBasic.CompilerServices;

// 
// 原始程式碼已由 Microsoft.VSDesigner 自動產生，版本 4.0.30319.42000。
// 
namespace IEWService.wsMCloud
{

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    [DebuggerStepThrough()]
    [DesignerCategory("code")]
    [WebServiceBinding(Name = "PushServiceSoap", Namespace = "http://tempuri.org/")]
    public partial class PushService : SoapHttpClientProtocol
    {

        private System.Threading.SendOrPostCallback RegistGuestTokenOperationCompleted;

        private System.Threading.SendOrPostCallback RegistPNDeviceOperationCompleted;

        private System.Threading.SendOrPostCallback PushDevicePMGOperationCompleted;

        private System.Threading.SendOrPostCallback UpdateGProgramBgNumberOperationCompleted;

        private System.Threading.SendOrPostCallback PushMessageByTokenOperationCompleted;

        private bool useDefaultCredentialsSetExplicitly;

        /// <remarks/>
        public PushService() : base()
        {
            Url = My.MySettings.Default.MESIEW_wsMCloud_PushService;
            if (IsLocalFileSystemWebService(Url) == true)
            {
                UseDefaultCredentials = true;
                useDefaultCredentialsSetExplicitly = false;
            }
            else
            {
                useDefaultCredentialsSetExplicitly = true;
            }
        }

        public new string Url
        {
            get
            {
                return base.Url;
            }
            set
            {
                if (IsLocalFileSystemWebService(base.Url) == true && useDefaultCredentialsSetExplicitly == false && IsLocalFileSystemWebService(value) == false)

                {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }

        public new bool UseDefaultCredentials
        {
            get
            {
                return base.UseDefaultCredentials;
            }
            set
            {
                base.UseDefaultCredentials = value;
                useDefaultCredentialsSetExplicitly = true;
            }
        }

        /// <remarks/>
        public event RegistGuestTokenCompletedEventHandler RegistGuestTokenCompleted;

        /// <remarks/>
        public event RegistPNDeviceCompletedEventHandler RegistPNDeviceCompleted;

        /// <remarks/>
        public event PushDevicePMGCompletedEventHandler PushDevicePMGCompleted;

        /// <remarks/>
        public event UpdateGProgramBgNumberCompletedEventHandler UpdateGProgramBgNumberCompleted;

        /// <remarks/>
        public event PushMessageByTokenCompletedEventHandler PushMessageByTokenCompleted;

        /// <remarks/>
        [SoapDocumentMethod("http://tempuri.org/RegistGuestToken", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public string RegistGuestToken(string pKey, string pTransData)
        {
            object[] results = Invoke("RegistGuestToken", new object[] { pKey, pTransData });
            return Conversions.ToString(results[0]);
        }

        /// <remarks/>
        public void RegistGuestTokenAsync(string pKey, string pTransData)
        {
            RegistGuestTokenAsync(pKey, pTransData, null);
        }

        /// <remarks/>
        public void RegistGuestTokenAsync(string pKey, string pTransData, object userState)
        {
            if (RegistGuestTokenOperationCompleted == null)
            {
                RegistGuestTokenOperationCompleted = OnRegistGuestTokenOperationCompleted;
            }
            InvokeAsync("RegistGuestToken", new object[] { pKey, pTransData }, RegistGuestTokenOperationCompleted, userState);
        }

        private void OnRegistGuestTokenOperationCompleted(object arg)
        {
            if (RegistGuestTokenCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                RegistGuestTokenCompleted?.Invoke(this, new RegistGuestTokenCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        /// <remarks/>
        [SoapDocumentMethod("http://tempuri.org/RegistPNDevice", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public string RegistPNDevice(string pKey, string pTransData)
        {
            object[] results = Invoke("RegistPNDevice", new object[] { pKey, pTransData });
            return Conversions.ToString(results[0]);
        }

        /// <remarks/>
        public void RegistPNDeviceAsync(string pKey, string pTransData)
        {
            RegistPNDeviceAsync(pKey, pTransData, null);
        }

        /// <remarks/>
        public void RegistPNDeviceAsync(string pKey, string pTransData, object userState)
        {
            if (RegistPNDeviceOperationCompleted == null)
            {
                RegistPNDeviceOperationCompleted = OnRegistPNDeviceOperationCompleted;
            }
            InvokeAsync("RegistPNDevice", new object[] { pKey, pTransData }, RegistPNDeviceOperationCompleted, userState);
        }

        private void OnRegistPNDeviceOperationCompleted(object arg)
        {
            if (RegistPNDeviceCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                RegistPNDeviceCompleted?.Invoke(this, new RegistPNDeviceCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        /// <remarks/>
        [SoapDocumentMethod("http://tempuri.org/PushDevicePMG", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public string PushDevicePMG(string pKey, string pPushMsg)
        {
            object[] results = Invoke("PushDevicePMG", new object[] { pKey, pPushMsg });
            return Conversions.ToString(results[0]);
        }

        /// <remarks/>
        public void PushDevicePMGAsync(string pKey, string pPushMsg)
        {
            PushDevicePMGAsync(pKey, pPushMsg, null);
        }

        /// <remarks/>
        public void PushDevicePMGAsync(string pKey, string pPushMsg, object userState)
        {
            if (PushDevicePMGOperationCompleted == null)
            {
                PushDevicePMGOperationCompleted = OnPushDevicePMGOperationCompleted;
            }
            InvokeAsync("PushDevicePMG", new object[] { pKey, pPushMsg }, PushDevicePMGOperationCompleted, userState);
        }

        private void OnPushDevicePMGOperationCompleted(object arg)
        {
            if (PushDevicePMGCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                PushDevicePMGCompleted?.Invoke(this, new PushDevicePMGCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        /// <remarks/>
        [SoapDocumentMethod("http://tempuri.org/UpdateGProgramBgNumber", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public string UpdateGProgramBgNumber(string pBgP2M)
        {
            object[] results = Invoke("UpdateGProgramBgNumber", new object[] { pBgP2M });
            return Conversions.ToString(results[0]);
        }

        /// <remarks/>
        public void UpdateGProgramBgNumberAsync(string pBgP2M)
        {
            UpdateGProgramBgNumberAsync(pBgP2M, null);
        }

        /// <remarks/>
        public void UpdateGProgramBgNumberAsync(string pBgP2M, object userState)
        {
            if (UpdateGProgramBgNumberOperationCompleted == null)
            {
                UpdateGProgramBgNumberOperationCompleted = OnUpdateGProgramBgNumberOperationCompleted;
            }
            InvokeAsync("UpdateGProgramBgNumber", new object[] { pBgP2M }, UpdateGProgramBgNumberOperationCompleted, userState);
        }

        private void OnUpdateGProgramBgNumberOperationCompleted(object arg)
        {
            if (UpdateGProgramBgNumberCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                UpdateGProgramBgNumberCompleted?.Invoke(this, new UpdateGProgramBgNumberCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        /// <remarks/>
        [SoapDocumentMethod("http://tempuri.org/PushMessageByToken", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
        public string PushMessageByToken(string pKey, string pPushMsg)
        {
            object[] results = Invoke("PushMessageByToken", new object[] { pKey, pPushMsg });
            return Conversions.ToString(results[0]);
        }

        /// <remarks/>
        public void PushMessageByTokenAsync(string pKey, string pPushMsg)
        {
            PushMessageByTokenAsync(pKey, pPushMsg, null);
        }

        /// <remarks/>
        public void PushMessageByTokenAsync(string pKey, string pPushMsg, object userState)
        {
            if (PushMessageByTokenOperationCompleted == null)
            {
                PushMessageByTokenOperationCompleted = OnPushMessageByTokenOperationCompleted;
            }
            InvokeAsync("PushMessageByToken", new object[] { pKey, pPushMsg }, PushMessageByTokenOperationCompleted, userState);
        }

        private void OnPushMessageByTokenOperationCompleted(object arg)
        {
            if (PushMessageByTokenCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs)arg;
                PushMessageByTokenCompleted?.Invoke(this, new PushMessageByTokenCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        /// <remarks/>
        public new void CancelAsync(object userState)
        {
            base.CancelAsync(userState);
        }

        private bool IsLocalFileSystemWebService(string url)
        {
            if (url == null || ReferenceEquals(url, string.Empty))
            {
                return false;
            }
            var wsUri = new Uri(url);
            if (wsUri.Port >= 1024 && string.Compare(wsUri.Host, "localHost", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return true;
            }
            return false;
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    public delegate void RegistGuestTokenCompletedEventHandler(object sender, RegistGuestTokenCompletedEventArgs e);

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    [DebuggerStepThrough()]
    [DesignerCategory("code")]
    public partial class RegistGuestTokenCompletedEventArgs : AsyncCompletedEventArgs
    {

        private object[] results;

        internal RegistGuestTokenCompletedEventArgs(object[] results, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState)
        {
            this.results = results;
        }

        /// <remarks/>
        public string Result
        {
            get
            {
                RaiseExceptionIfNecessary();
                return Conversions.ToString(results[0]);
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    public delegate void RegistPNDeviceCompletedEventHandler(object sender, RegistPNDeviceCompletedEventArgs e);

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    [DebuggerStepThrough()]
    [DesignerCategory("code")]
    public partial class RegistPNDeviceCompletedEventArgs : AsyncCompletedEventArgs
    {

        private object[] results;

        internal RegistPNDeviceCompletedEventArgs(object[] results, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState)
        {
            this.results = results;
        }

        /// <remarks/>
        public string Result
        {
            get
            {
                RaiseExceptionIfNecessary();
                return Conversions.ToString(results[0]);
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    public delegate void PushDevicePMGCompletedEventHandler(object sender, PushDevicePMGCompletedEventArgs e);

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    [DebuggerStepThrough()]
    [DesignerCategory("code")]
    public partial class PushDevicePMGCompletedEventArgs : AsyncCompletedEventArgs
    {

        private object[] results;

        internal PushDevicePMGCompletedEventArgs(object[] results, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState)
        {
            this.results = results;
        }

        /// <remarks/>
        public string Result
        {
            get
            {
                RaiseExceptionIfNecessary();
                return Conversions.ToString(results[0]);
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    public delegate void UpdateGProgramBgNumberCompletedEventHandler(object sender, UpdateGProgramBgNumberCompletedEventArgs e);

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    [DebuggerStepThrough()]
    [DesignerCategory("code")]
    public partial class UpdateGProgramBgNumberCompletedEventArgs : AsyncCompletedEventArgs
    {

        private object[] results;

        internal UpdateGProgramBgNumberCompletedEventArgs(object[] results, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState)
        {
            this.results = results;
        }

        /// <remarks/>
        public string Result
        {
            get
            {
                RaiseExceptionIfNecessary();
                return Conversions.ToString(results[0]);
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    public delegate void PushMessageByTokenCompletedEventHandler(object sender, PushMessageByTokenCompletedEventArgs e);

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCode("System.Web.Services", "4.6.1055.0")]
    [DebuggerStepThrough()]
    [DesignerCategory("code")]
    public partial class PushMessageByTokenCompletedEventArgs : AsyncCompletedEventArgs
    {

        private object[] results;

        internal PushMessageByTokenCompletedEventArgs(object[] results, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState)
        {
            this.results = results;
        }

        /// <remarks/>
        public string Result
        {
            get
            {
                RaiseExceptionIfNecessary();
                return Conversions.ToString(results[0]);
            }
        }
    }
}