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

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

ApplicationOperator

    1: using System;
    2:  
    3: namespace Ia.Cl.Models
    4: {
    5:     ////////////////////////////////////////////////////////////////////////////
    6:  
    7:     /// <summary publish="true">
    8:     /// ApplicationOperator
    9:     /// </summary>
   10:     /// 
   11:     /// <remarks> 
   12:     /// Copyright © 2020-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   13:     ///
   14:     /// 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
   15:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   16:     ///
   17:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   18:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   19:     /// 
   20:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   21:     /// 
   22:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   23:     /// </remarks> 
   24:     public class ApplicationOperator
   25:     {
   26:         private bool processRunning;
   27:         private int secondsBetweenOperations = 10;
   28:         private DateTime createdDateTime, startedDateTime;
   29:         private ControlMode controlMode;
   30:  
   31:         public enum ControlMode { Manual, AutoStart, AutoConnectThenStart, AutoConnectThenLoginThenStart, AutoConnectThenLoginThenRegisterThenStart }
   32:  
   33:         public enum PowerUp { Connect, Login, Register, Start }
   34:         public enum PowerDown { Disconnect, Logout, Unregister, Stop }
   35:  
   36:         public bool EnableRestart { get; set; }
   37:  
   38:         ////////////////////////////////////////////////////////////////////////////
   39:  
   40:         /// <summary>
   41:         ///
   42:         /// </summary>
   43:         public ApplicationOperator()
   44:         {
   45:             this.controlMode = ControlMode.Manual;
   46:  
   47:             createdDateTime = DateTime.UtcNow.AddHours(3);
   48:  
   49:             processRunning = false;
   50:         }
   51:  
   52:         ////////////////////////////////////////////////////////////////////////////
   53:  
   54:         /// <summary>
   55:         ///
   56:         /// </summary>
   57:         public ApplicationOperator(ControlMode _controlMode)
   58:         {
   59:             this.controlMode = _controlMode;
   60:  
   61:             createdDateTime = DateTime.UtcNow.AddHours(3);
   62:  
   63:             processRunning = false;
   64:         }
   65:  
   66:         ////////////////////////////////////////////////////////////////////////////
   67:  
   68:         /// <summary>
   69:         ///
   70:         /// </summary>
   71:         public void Minute()
   72:         {
   73:         }
   74:  
   75:         ////////////////////////////////////////////////////////////////////////////
   76:  
   77:         /// <summary>
   78:         ///
   79:         /// </summary>
   80:         public bool ProcessRunning
   81:         {
   82:             get
   83:             {
   84:                 if (this.controlMode == ControlMode.Manual)
   85:                 {
   86:                     processRunning = false;
   87:                 }
   88:                 else
   89:                 {
   90:                     if (processRunning == false)
   91:                     {
   92:                         TimeSpan timeSpan = DateTime.UtcNow.AddHours(3) - createdDateTime;
   93:  
   94:                         if (timeSpan.TotalSeconds - secondsBetweenOperations > 0)
   95:                         {
   96:                             processRunning = true;
   97:                             startedDateTime = DateTime.UtcNow.AddHours(3);
   98:                         }
   99:                         else processRunning = false;
  100:                     }
  101:                     else
  102:                     {
  103:  
  104:                     }
  105:                 }
  106:  
  107:                 return processRunning;
  108:             }
  109:         }
  110:  
  111:         ////////////////////////////////////////////////////////////////////////////
  112:  
  113:         /// <summary>
  114:         ///
  115:         /// </summary>
  116:         public void Restart()
  117:         {
  118:             // Application.Restart()
  119:  
  120:             createdDateTime = DateTime.UtcNow.AddHours(3);
  121:  
  122:             processRunning = false;
  123:         }
  124:  
  125:         ////////////////////////////////////////////////////////////////////////////
  126:         ////////////////////////////////////////////////////////////////////////////
  127:     }
  128:  
  129:     ////////////////////////////////////////////////////////////////////////////
  130:     ////////////////////////////////////////////////////////////////////////////   
  131: }