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

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.Models
    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:             try
   97:             {
   98:                 await Ia.Cl.Models.Http.PostAsync("https://api.ia.com.kw", "api/packets", packet);
   99:             }
  100:             catch (Exception e)
  101:             {
  102:             }
  103:         }
  104:  
  105:         ////////////////////////////////////////////////////////////////////////////
  106:  
  107:         /// <summary>
  108:         ///
  109:         /// </summary>
  110:         public static async Task PostPacketAsync(string recipientAssemblyProduct, string senderAssemblyProduct, Guid parentId, string name, string payload)
  111:         {
  112:             string hash;
  113:  
  114:             hash = Ia.Cl.Models.Cryptography.Md5.Hash(name);
  115:  
  116:             var packet = new Ia.Cl.Models.Packet()
  117:             {
  118:                 Id = Guid.NewGuid(),
  119:                 ParentId = parentId,
  120:                 RecipientAssemblyProduct = recipientAssemblyProduct,
  121:                 SenderAssemblyProduct = senderAssemblyProduct,
  122:                 Name = name,
  123:                 Payload = payload,
  124:                 Hash = hash,
  125:                 Created = DateTime.UtcNow.AddHours(3),
  126:             };
  127:  
  128:             try
  129:             {
  130:                 await Ia.Cl.Models.Http.PostAsync("https://api.ia.com.kw", "api/packets", packet);
  131:             }
  132:             catch (Exception e)
  133:             {
  134:             }
  135:         }
  136:  
  137:         ////////////////////////////////////////////////////////////////////////////
  138:  
  139:         /// <summary>
  140:         ///
  141:         /// </summary>
  142:         public static List<Ia.Cl.Models.Packet> PacketList()
  143:         {
  144:             var list = Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Packet>>("https://api.ia.com.kw", "api/packets");
  145:  
  146:             return list.Result;
  147:         }
  148:  
  149:         ////////////////////////////////////////////////////////////////////////////
  150:  
  151:         /// <summary>
  152:         ///
  153:         /// </summary>
  154:         public static async Task<List<Ia.Cl.Models.Packet>> RecipientPacketListAsync(string recipientAssemblyProduct)
  155:         {
  156:             var list = new List<Ia.Cl.Models.Packet>();
  157:  
  158:             try
  159:             {
  160:                 list = await Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Packet>>("https://api.ia.com.kw", "api/packets/recipientAssemblyProduct/" + recipientAssemblyProduct);
  161:             }
  162:             catch (Exception e)
  163:             {
  164:             }
  165:  
  166:             return list;
  167:         }
  168:  
  169:         ////////////////////////////////////////////////////////////////////////////
  170:  
  171:         /// <summary>
  172:         ///
  173:         /// </summary>
  174:         public static async Task<List<Ia.Cl.Models.Packet>> SenderPacketListAsync(string senderAssemblyProduct)
  175:         {
  176:             var list = new List<Ia.Cl.Models.Packet>();
  177:  
  178:             try
  179:             {
  180:                 list = await Ia.Cl.Models.Http.GetAsync<List<Ia.Cl.Models.Packet>>("https://api.ia.com.kw", "api/packets/senderAssemblyProduct/" + senderAssemblyProduct);
  181:             }
  182:             catch (Exception e)
  183:             {
  184:             }
  185:  
  186:             return list;
  187:         }
  188:  
  189:         ////////////////////////////////////////////////////////////////////////////
  190:         ////////////////////////////////////////////////////////////////////////////
  191:     }
  192:  
  193:     ////////////////////////////////////////////////////////////////////////////
  194:     ////////////////////////////////////////////////////////////////////////////
  195: }