/// <summary>
        /// What's this?<br />
        /// This will load a CgiScriptServiceInfo object and attempt to serialise it into a JSON string.
        /// </summary>
        /// <param name="serviceInformation"></param>
        /// <returns>Serialised CgiScriptServiceInfo JSON string</returns>
        public static string SaveScript(CgiScriptServiceInfo serviceInformation)
        {
            try
            {
                //validation
                if (serviceInformation != null)
                {
                    //attempt json serialisation
                    var jsonString =
                        JsonConvert.SerializeObject(serviceInformation, Formatting.Indented, GenericJsonSettings.Settings);

                    //validation
                    if (!string.IsNullOrWhiteSpace(jsonString))
                    {
                        return(jsonString);
                    }
                }
            }
            catch (Exception ex)
            {
                UiMessages.Error(ex.ToString());
            }

            //default
            return(@"");
        }
Exemple #2
0
        /// <summary>
        /// What's this?<br />
        /// This will load a CgiScriptServiceInfo object, attempt to serialise it into a JSON string and then write that string to the file specified.
        /// </summary>
        /// <param name="serviceInformation"></param>
        /// <param name="filePath"></param>
        /// <returns>True on success</returns>
        public static bool SaveScript(CgiScriptServiceInfo serviceInformation, string filePath)
        {
            try
            {
                //validation
                if (serviceInformation != null && !string.IsNullOrWhiteSpace(filePath))
                {
                    //if the file exists, delete it
                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }

                    //attempt serialisation
                    var jsonString = SaveScript(serviceInformation);

                    //validation
                    if (!string.IsNullOrWhiteSpace(jsonString))
                    {
                        //write the string to a file
                        File.WriteAllText(filePath, jsonString);

                        //report success
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                UiMessages.Error(ex.ToString());
            }

            //default
            return(false);
        }
Exemple #3
0
 public CgiScriptFileService(CgiScriptServiceInfo serviceInformation)
 {
     //validation
     if (serviceInformation != null)
     {
         ServiceAuthInfo = serviceInformation;
     }
 }
Exemple #4
0
        public CgiStationsScript()
        {
            //parameters needed for communication
            const string serviceMessage     = @"Retrieving modem station info...";
            var          serviceEndpoint    = $@"{Endpoints.Origin}/cgi/cgi_toplogy_info.js";
            var          serviceTokeniser   = Endpoints.DevicesHtm;
            var          serviceInformation = new CgiScriptServiceInfo(serviceTokeniser, serviceEndpoint, serviceMessage)
            {
                ServiceName = @"CgiStationsScript"
            };

            //set the global service parameters
            ServiceAuthInfo = serviceInformation;
        }
Exemple #5
0
        public CgiLoginScript()
        {
            //parameters needed for communication
            const string serviceMessage     = @"Retrieving modem login initialisation information...";
            var          serviceEndpoint    = $@"{Endpoints.Origin}/cgi/cgi_login.js";
            var          serviceTokeniser   = Endpoints.HomeHtm;
            var          serviceInformation = new CgiScriptServiceInfo(serviceTokeniser, serviceEndpoint, serviceMessage)
            {
                ServiceName = @"CgiLoginScript"
            };

            //set the global service parameters
            ServiceAuthInfo = serviceInformation;
        }
        public CgiBackupScript()
        {
            //parameters needed for communication
            const string serviceMessage     = @"Retrieving config file...";
            var          serviceEndpoint    = $@"{Endpoints.Origin}/cgi/cgi_backup.js";
            var          serviceTokeniser   = Endpoints.BackupHtm;
            var          serviceInformation = new CgiScriptServiceInfo(serviceTokeniser, serviceEndpoint, serviceMessage)
            {
                ServiceName = @"CgiBackupScript"
            };

            //set the global service parameters
            ServiceAuthInfo = serviceInformation;
        }
        public CgiCallLogScript()
        {
            //parameters needed for communication
            const string serviceMessage     = @"Retrieving call log..";
            var          serviceEndpoint    = $@"{Endpoints.Origin}/cgi/cgi_tel_call_list.js";
            var          serviceTokeniser   = Endpoints.CallLogHtm;
            var          serviceInformation = new CgiScriptServiceInfo(serviceTokeniser, serviceEndpoint, serviceMessage)
            {
                ServiceName = @"CgiCallLogScript"
            };

            //set the global service parameters
            ServiceAuthInfo = serviceInformation;
        }
        public CgiSystemLogScript(LogType log)
        {
            //global log type for endpoint construction
            Log = log;

            //parameters needed for communication
            const string serviceMessage     = @"Retrieving log...";
            var          serviceEndpoint    = EndpointFromLogType();
            var          serviceTokeniser   = Endpoints.SystemLogHtm;
            var          serviceInformation = new CgiScriptServiceInfo(serviceTokeniser, serviceEndpoint, serviceMessage)
            {
                ServiceName = @"CgiSystemLogScript"
            };

            //set the global service parameters
            ServiceAuthInfo = serviceInformation;
        }
        private void FillValues(CgiScriptServiceInfo serviceInformation)
        {
            //validation
            if (serviceInformation != null)
            {
                //Script Service Name
                txtServiceName.Text =
                    string.IsNullOrWhiteSpace(serviceInformation.ServiceName)
                        ? @"<ServiceName>"
                        : serviceInformation.ServiceName;

                //Script Service Endpoint
                txtServiceEndpoint.Text =
                    string.IsNullOrWhiteSpace(serviceInformation.ServiceEndpoint)
                        ? @"<ServiceEndpoint>"
                        : serviceInformation.ServiceEndpoint;

                //Script Token Endpoint
                txtTokeniserEndpoint.Text =
                    string.IsNullOrWhiteSpace(serviceInformation.TokeniserPage)
                        ? @"<TokenEndpoint>"
                        : serviceInformation.TokeniserPage;

                //Script Service Referrer
                txtReferrer.Text =
                    string.IsNullOrWhiteSpace(serviceInformation.ReferrerPage)
                        ? @"<Referrer>"
                        : serviceInformation.ReferrerPage;

                //Wait Window Message
                txtServiceMessage.Text =
                    string.IsNullOrWhiteSpace(serviceInformation.ServiceMessage)
                        ? @"<Message>"
                        : serviceInformation.ServiceMessage;
            }
        }