working on it ...

Filters

Explore Public Snippets

Sort by

Found 5,104 snippets matching: status

    public by cghersi @ MailUp API DEV  206827  8  6  1

    MailUp REST API - How to subscribe to a particular list several contacts with the "Confirmed Optin" Procedure

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void SubcribeRecipientsWithDoubleOptin(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Subscribe recipients:
        int idList = 1;
        List<ConsoleRecipientItem> recipients = new List<ConsoleRecipientItem>();
        ConsoleRecipientItem recipient1 = new ConsoleRecipientItem()
        {
            Email = "test1@mailup.com",
            Name = "First New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3331234567",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        ConsoleRecipientItem recipient2 = new ConsoleRecipientItem()
        {
            Email = "test2@mailup.com",
            Name = "Second New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3337654321",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name2_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName2_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        recipients.Add(recipient1);
        recipients.Add(recipient2);
        int subscriptionResult = 0;
        try
        {
            subscriptionResult = client.AddRecipientsToList(idList, recipients, true);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 2.1) wait for the end of import task:
        if (subscriptionResult > 0)
        {
            Console.WriteLine("Recipients Import started; import ID:" + subscriptionResult);
    
            //optionally we can check the import status:
            bool completed = false;
            do
            {
                ConsoleImportStatus importStatus = client.CheckImportStatus(subscriptionResult);
                if (importStatus == null)
                {
                    Console.WriteLine("Cannot check the import status for import task #" + subscriptionResult);
                    return;
                }
                completed = importStatus.Completed;
            } while (!completed);
            Console.WriteLine("Recipients Added!");
        }
        else
        {
            Console.WriteLine("An error occurred while adding the recipients.");
            return;
        }
    
        // 3) Retrieve the sendingID of the confirmation email related to the previous task:
        int sendingID = -1;
        try
        {
            sendingID = client.GetSendingIDForImport(subscriptionResult);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot retrieve sending ID due to " + ex.Message);
            return;
        }
        if (sendingID <= 0)
        {
            Console.WriteLine("Cannot retrieve sending ID.");
            return;
        }
    
        // 4) Send the confirmation email:
        EmailSendingItem sendingResult = null;
        try
        {
            sendingResult = client.SendEmailMessage(sendingID);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot send email due to " + ex.Message);
            return;
        }
        if (sendingResult == null)
            Console.WriteLine("Cannot send confirmation email.");
        else
            Console.WriteLine("Confirmation email sent!");
    }
                

    public by Geometry  126451  0  4  0

    Combine: Combine will attempt to minimize the depth of InnerResults and maintain status codes

    Combine will attempt to minimize the depth of InnerResults and maintain status codes
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    /// <summary>
    /// Combine will attempt to minimize the depth of InnerResults and maintain status codes
    /// </summary>
    /// <param name="target"></param>
    public static void Combine(this IOperationResult source, IOperationResult target)
    {
    	target.Message = source.Message;
    	target.Success = source.Success;
    	target.Exception = source.Exception;
    	target.StatusCode = source.StatusCode ?? target.StatusCode;
    	target.InnerResult = source.InnerResult ?? source;
    }

    public by lbottaro  3305  1  6  0

    Bash IP PPP interface status test

    This script test IP/PPP interface status on linux
    #!/bin/sh
    
    echo "======= TEST RUNNING ========"
    sleep $((60*15))
    IF0_STATE=`ifconfig ptp_040 | grep RUNNING | wc -l`
    IF1_STATE=`ifconfig ptp_041 | grep RUNNING | wc -l`
    if [ ${IF0_STATE} -eq 1 ] && [ ${IF1_STATE} -eq 1 ] ; then
      echo "PASSED!"
      # reboot
    else
      while [ 1 ]; do
        echo "FAILED IF0_STATE : ${IF0_STATE} IF1_STATE:${IF1_STATE}"
    	sleep 10
      done
    fi

    public by cghersi  3541  3  6  1

    Check Recovery status of DB in SQL Server 2012

    This query allows you to check the status f your recovery in SQL Server. More information on http://timlaqua.com/2009/09/determining-how-long-a-database-will-be-in-recovery-sql-server-2008/
    DECLARE @DBName VARCHAR(64) = 'databasename'
     
    DECLARE @ErrorLog AS TABLE([LogDate] CHAR(24), [ProcessInfo] VARCHAR(64), [TEXT] VARCHAR(MAX))
     
    INSERT INTO @ErrorLog
    EXEC master..sp_readerrorlog 0, 1, 'Recovery of database', @DBName
     
    SELECT TOP 5
    	 [LogDate]
    	,SUBSTRING([TEXT], CHARINDEX(') is ', [TEXT]) + 4,CHARINDEX(' complete (', [TEXT]) - CHARINDEX(') is ', [TEXT]) - 4) AS PercentComplete
    	,CAST(SUBSTRING([TEXT], CHARINDEX('approximately', [TEXT]) + 13,CHARINDEX(' seconds remain', [TEXT]) - CHARINDEX('approximately', [TEXT]) - 13) AS FLOAT)/60.0 AS MinutesRemaining
    	,CAST(SUBSTRING([TEXT], CHARINDEX('approximately', [TEXT]) + 13,CHARINDEX(' seconds remain', [TEXT]) - CHARINDEX('approximately', [TEXT]) - 13) AS FLOAT)/60.0/60.0 AS HoursRemaining
    	,[TEXT]
     
    FROM @ErrorLog ORDER BY [LogDate] DESC         

    public by Geometry  1249  0  4  0

    Combine: Combine will attempt to minimize the depth of InnerResults and maintain status codes

    Combine will attempt to minimize the depth of InnerResults and maintain status codes
    C#
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    /// <summary>
    /// Combine will attempt to minimize the depth of InnerResults and maintain status codes
    /// </summary>
    /// <param name="target"></param>
    public static void Combine(this IOperationResult source, IOperationResult target)
    {
    	target.Message = source.Message;
    	target.Success = source.Success;
    	target.Exception = source.Exception;
    	target.StatusCode = source.StatusCode ?? target.StatusCode;
    	target.InnerResult = source.InnerResult ?? source;
    }

    public by cghersi @ MailUp API DEV  1349  1  5  0

    How to Retrieve the status of a recipient given the ID with MailUp .NET SDK

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void GetSubscriptionStatusByID(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Prepare the input:
        int idList = 1;
        int idRecipient = 1;
    
        // 3) Invoke the web method:
        SubscriptionStatus result = SubscriptionStatus.Unknown;
        try
        {
            result = client.GetSubscriptionStatus(idList, idRecipient);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 4) Print results:
        Console.WriteLine("Recipient status: " + result);
    }
    

    public by cghersi @ MailUp API DEV  1041  4  6  0

    How to Retrieve the status of a recipient given the email with MailUp .NET SDK

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void GetSubscriptionStatusByEmail(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Prepare the input:
        int idList = 1;
        string emailRecipient = "test@mailup.com";
    
        // 3) Invoke the web method:
        SubscriptionStatus result = SubscriptionStatus.Unknown;
        try
        {
            result = client.GetSubscriptionStatus(idList, emailRecipient);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 4) Print results:
        Console.WriteLine("Recipient status: " + result);
    }
    

    public by JKCPR  2847  4  6  1

    CUSTOM ERROR PAGE || HTTP STATUS REDIRECT

    Very useful for you to point all your error pages to the same file
    <?php
    // Very useful if you point all your error pages to the same file.
    
    // File; .htaccess
    /*# .htaccess file.
    
    ErrorDocument 404 /error-msg.php
    ErrorDocument 500 /error-msg.php
    ErrorDocument 400 /error-msg.php
    ErrorDocument 401 /error-msg.php
    ErrorDocument 403 /error-msg.php
    # End of file.
    
    // File; error-msg.php 
    */#
    ?>
    <?php
      $HttpStatus = $_SERVER["REDIRECT_STATUS"] ;
      if($HttpStatus==200) {print "Document has been processed and sent to you.";}
      if($HttpStatus==400) {print "Bad HTTP request ";}
      if($HttpStatus==401) {print "Unauthorized - Iinvalid password";}
      if($HttpStatus==403) {print "Forbidden";}
      if($HttpStatus==500) {print "Internal Server Error";}
      if($HttpStatus==418) {print "I'm a teapot! - This is a real value, defined in 1998";}
    
    ?>

    public by jlappano  3237  1  5  2

    Check Content and Status Code in PHP Unit

            $client->request('GET', ‘/create/adviseeSet’);
    
            $content = $client->getResponse()->getContent();
            $status = $client->getResponse()->getStatusCode();
    
            $this->assertEquals('shmee', $content);
            $this->assertEquals(200, $status);
    
    
    Gives a nice failure message which prints out content and status code 

    public by maholtz  1849  0  6  0

    Status der Batterie und Termperatur anzeigen (Linux)

    acpi -V
    • Public Snippets
    • Channels Snippets