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

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

Packet model

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Runtime.Serialization;
    4: using System.Threading.Tasks;
    5:  
    6: namespace Ia.Cl.Model
    7: {
    8:     ////////////////////////////////////////////////////////////////////////////
    9:  
   10:     /// <summary publish="true">
   11:     /// Packet model
   12:     /// </summary>
   13:     /// 
   14:     /// <remarks> 
   15:     /// Copyright © 2006-2020 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.packet", Name = "packet")]
   28:     public class Packet
   29:     {
   30:         /// <summary/>
   31:         public Packet() { }
   32:  
   33:         /// <summary/>
   34:         [DataMember(Name = "id")]
   35:         public System.Guid Id { get; set; }
   36:  
   37:         /// <summary/>
   38:         [DataMember(Name = "parentId")]
   39:         public System.Guid ParentId { get; set; }
   40:  
   41:         /// <summary/>
   42:         [DataMember(Name = "recipientAssemblyGuid")]
   43:         public System.Guid RecipientAssemblyGuid { get; set; }
   44:  
   45:         /// <summary/>
   46:         [DataMember(Name = "recipientAssemblyProduct")]
   47:         public string RecipientAssemblyProduct { get; set; }
   48:  
   49:         /// <summary/>
   50:         [DataMember(Name = "senderAssemblyGuid")]
   51:         public System.Guid SenderAssemblyGuid { get; set; }
   52:  
   53:         /// <summary/>
   54:         [DataMember(Name = "senderAssemblyProduct")]
   55:         public string SenderAssemblyProduct { get; set; }
   56:  
   57:         /// <summary/>
   58:         [DataMember(Name = "name")]
   59:         public string Name { get; set; }
   60:  
   61:         /// <summary/>
   62:         [DataMember(Name = "payload")]
   63:         public string Payload { get; set; }
   64:  
   65:         /// <summary/>
   66:         [DataMember(Name = "hash")]
   67:         public string Hash { get; set; }
   68:  
   69:         /// <summary/>
   70:         [DataMember(Name = "created")]
   71:         public DateTime Created { get; set; }
   72:  
   73:         ////////////////////////////////////////////////////////////////////////////
   74:  
   75:         /// <summary>
   76:         ///
   77:         /// </summary>
   78:         public static async Task PostPacketAsync(Guid recipientAssemblyGuid, Guid senderAssemblyGuid, Guid parentId, string name, string payload)
   79:         {
   80:             string hash;
   81:  
   82:             hash = Ia.Cl.Models.Cryptography.Md5.Hash(name);
   83:  
   84:             var packet = new Ia.Cl.Models.Packet()
   85:             {
   86:                 Id = Guid.NewGuid(),
   87:                 ParentId = parentId,
   88:                 RecipientAssemblyGuid = recipientAssemblyGuid,
   89:                 SenderAssemblyGuid = senderAssemblyGuid,
   90:                 Name = name,
   91:                 Payload = payload,
   92:                 Hash = hash,
   93:                 Created = DateTime.UtcNow.AddHours(3),
   94:             };
   95:  
   96:             await Ia.Cl.Models.Http.PostAsync("https://api.ia.com.kw", "api/packets", packet);
   97:         }
   98:  
   99:         ////////////////////////////////////////////////////////////////////////////
  100:  
  101:         /// <summary>
  102:         ///
  103:         /// </summary>
  104:         public static async Task PostPacketAsync(string recipientAssemblyProduct, string senderAssemblyProduct, Guid parentId, string name, string payload)
  105:         {
  106:             string hash;
  107:  
  108:             hash = Ia.Cl.Models.Cryptography.Md5.Hash(name);
  109:  
  110:             var packet = new Ia.Cl.Models.Packet()
  111:             {
  112:                 Id = Guid.NewGuid(),
  113:                 ParentId = parentId,
  114:                 RecipientAssemblyProduct = recipientAssemblyProduct,
  115:                 SenderAssemblyProduct = senderAssemblyProduct,
  116:                 Name = name,
  117:                 Payload = payload,
  118:                 Hash = hash,
  119:                 Created = DateTime.UtcNow.AddHours(3),
  120:             };
  121:  
  122:             await Ia.Cl.Models.Http.PostAsync("https://api.ia.com.kw", "api/packets", packet);
  123:         }
  124:  
  125:         ////////////////////////////////////////////////////////////////////////////
  126:  
  127:         /// <summary>
  128:         ///
  129:         /// </summary>
  130:         public static List<Ia.Cl.Models.Packet> PacketList()
  131:         {
  132:             var list = Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Packet>>("https://api.ia.com.kw", "api/packets");
  133:  
  134:             return list.Result;
  135:         }
  136:  
  137:         ////////////////////////////////////////////////////////////////////////////
  138:  
  139:         /// <summary>
  140:         ///
  141:         /// </summary>
  142:         public static async Task<List<Ia.Cl.Models.Packet>> RecipientPacketListAsync(string recipientAssemblyProduct)
  143:         {
  144:             var list = await Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Packet>>("https://api.ia.com.kw", "api/packets/recipientAssemblyProduct/" + recipientAssemblyProduct);
  145:  
  146:             return list;
  147:         }
  148:  
  149:         ////////////////////////////////////////////////////////////////////////////
  150:  
  151:         /// <summary>
  152:         ///
  153:         /// </summary>
  154:         public static async Task<List<Ia.Cl.Models.Packet>> SenderPacketListAsync(string senderAssemblyProduct)
  155:         {
  156:             var list = await Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Packet>>("https://api.ia.com.kw", "api/packets/senderAssemblyProduct/" + senderAssemblyProduct);
  157:  
  158:             return list;
  159:         }
  160:  
  161:         ////////////////////////////////////////////////////////////////////////////
  162:         ////////////////////////////////////////////////////////////////////////////
  163:     }
  164:  
  165:     ////////////////////////////////////////////////////////////////////////////
  166:     ////////////////////////////////////////////////////////////////////////////
  167: }