)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Heartbeat (Ia.Cl.Models)

Public general use code classes and xml files that we've compiled and used over the years:

Heartbeat class.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Runtime.Serialization;
    4: using System.Threading.Tasks;
    5:  
    6: namespace Ia.Cl.Models
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// Heartbeat class.
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2019-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     [DataContract(IsReference = true, Namespace = "kw.com.ia.api.heartbeat", Name = "Heartbeat")]
   28:     public class Heartbeat
   29:     {
   30:         // See https://docs.opsgenie.com/docs/heartbeat-api for referece
   31:  
   32:         private static readonly object objectLock = new object();
   33:  
   34:         ////////////////////////////////////////////////////////////////////////////
   35:  
   36:         /// <summary>
   37:         ///
   38:         /// </summary>
   39:         public Heartbeat() { }
   40:  
   41:         /// <summary/>
   42:         [DataMember(Name = "name")]
   43:         public string Name { get; set; }
   44:  
   45:         /// <summary/>
   46:         [DataMember(Name = "created")]
   47:         public DateTime Created { get; set; }
   48:  
   49:         ////////////////////////////////////////////////////////////////////////////
   50:  
   51:         /// <summary>
   52:         ///
   53:         /// </summary>
   54:         public static async Task SendHeartbeatAsync(string name)
   55:         {
   56:             try
   57:             {
   58:                 await Ia.Cl.Models.Http.PostAsync<string>("https://api.ia.com.kw", "api/heartbeats/" + name, string.Empty);
   59:             }
   60:             catch (Exception e)
   61:             {
   62:             }
   63:         }
   64:  
   65:         ////////////////////////////////////////////////////////////////////////////
   66:  
   67:         /// <summary>
   68:         ///
   69:         /// </summary>
   70:         public static async Task<List<Ia.Cl.Models.Heartbeat>> HeartbeatListAsync()
   71:         {
   72:             var list = new List<Ia.Cl.Models.Heartbeat>();
   73:  
   74:             try
   75:             {
   76:                 list = await Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Heartbeat>>("https://api.ia.com.kw", "api/heartbeats");
   77:             }
   78:             catch (Exception e)
   79:             {
   80:             }
   81:  
   82:             return list;
   83:         }
   84:  
   85:         ////////////////////////////////////////////////////////////////////////////
   86:  
   87:         /// <summary>
   88:         ///
   89:         /// </summary>
   90:         public static List<Heartbeat> HeartbeatList()
   91:         {
   92:             var list = Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Heartbeat>>("https://api.ia.com.kw", "api/heartbeats");
   93:  
   94:             return list.Result;
   95:         }
   96:  
   97:         ////////////////////////////////////////////////////////////////////////////
   98:         ////////////////////////////////////////////////////////////////////////////
   99:     }
  100:  
  101:     ////////////////////////////////////////////////////////////////////////////
  102:     ////////////////////////////////////////////////////////////////////////////
  103: }