示例#1
0
        }//END LogAction method

        // =====================================================================================
        /// <summary>
        /// This method adds EvApplicationEvent data object in the database.
        /// </summary>
        /// <param name="Category">String: Event Category</param>
        /// <param name="Description">String: Description</param>
        /// <param name="EventId">EvEventCodes: Object Evado.Model.EvEventCodes </param>
        /// <param name="Url">String: Page Url</param>
        /// <param name="UserName">String: Username of a person </param>
        /// <returns> A boolean value </returns>
        ///<remarks>
        /// This method consists of following steps.
        ///
        /// 1. Initialise a string Error to the Category if Category is empty.
        ///
        /// 2. Write to the event log.
        ///
        /// 3. Return a boolean value.
        ///
        /// </remarks>

        // -------------------------------------------------------------------------------------
        public static bool LogError(
            Evado.Model.EvEventCodes EventId, string Category, string Description, string Url, string UserName)
        {
            //
            // Initialise a string Error to the Category if Category is empty.
            //
            if (Category == String.Empty)
            {
                Category = "Error";
            }

            string sEventContent = "EventId: " + EventId.ToString( )
                                   + "\r\nEvent Category: " + Category
                                   + "\r\nPageUrl: " + Url
                                   + "\r\nUserId:  " + UserName
                                   + "\r\n\r\nDescription:\r\n" + Description;

            //
            // Write to the event log
            //
            WriteLog(sEventContent, EventLogEntryType.Error);
            //
            // Return a boolean value
            //
            return(true);
        }//END LogError method
示例#2
0
        }//END encryptString method

        //  =================================================================================
        /// <summary>
        /// This method decrypts a string of encrypted text.
        ///
        /// </summary>
        /// <param name="EncryptedString"></param>
        /// <returns>Unencrypted string</returns>
        //  ---------------------------------------------------------------------------------
        public string decryptString(String EncryptedString)
        {
            this.LogMethod("decryptString method. ");
            //
            // Define the reader and writer.
            //
            string clearText = String.Empty;
            TripleDESCryptoServiceProvider tripleDes = new TripleDESCryptoServiceProvider( );

            //
            // If the key is empty return empty string.
            //
            if (this._Key [0] == 0)
            {
                return(String.Empty);
            }

            try
            {
                //
                // Convert the string to a byte array.
                //
                byte [] buffer = Convert.FromBase64String(EncryptedString);

                //
                // Set the encryption keys.
                //
                tripleDes.Key = this._Key;
                tripleDes.IV  = this._IV;

                //
                // Encrypt the clear data.
                //
                ICryptoTransform ITransform = tripleDes.CreateDecryptor( );
                clearText = Encoding.Unicode.GetString(ITransform.TransformFinalBlock(buffer, 0, buffer.Length));

                this.LogMethodEnd("decryptString");

                //
                // Return the clear data.
                //
                return(clearText);
            }
            catch (CryptographicException Ex)
            {
                this.LogException(Ex);

                this._eventId = Evado.Model.EvEventCodes.Encryption_Decryption_Bad_Data_Error;

                throw;
            }
        }//END decryptString method
示例#3
0
 //====================================================================================
 /// <summary>
 /// Default constructor and initlaise the object.
 /// </summary>
 /// <param name="Type">EventType enumerated value</param>
 /// <param name="EventId">EvEventCodes enumerated value</param>
 /// <param name="Category">String: the category of the event</param>
 /// <param name="Description">String: the description of the event.</param>
 /// <param name="UserId">String: name of the user that created the event.</param>
 // ----------------------------------------------------------------------------------
 public EvApplicationEvent(
     EventType Type,
     Evado.Model.EvEventCodes EventId,
     String Category,
     String Description,
     String UserId)
 {
     this.EventId     = (int)EventId;
     this.Type        = Type;
     this.Category    = Category;
     this.Description = Description;
     this.UserId      = UserId;
 }
示例#4
0
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region Add Evado.Model.EvEventCodes methods

        // =====================================================================================
        /// <summary>
        /// This method adds EvApplicationEvent data object in the database.
        /// </summary>
        /// <param name="Category">String: Event category</param>
        /// <param name="Description">String: Description</param>
        /// <param name="EventId">EvEventCodes: Object Evado.Model.EvEventCodes </param>
        /// <param name="UserName">String: UserName of a person</param>
        /// <returns>A boolean value</returns>
        /// <remarks>
        /// This method consists of following steps.
        ///
        /// 1. Write to the event log.
        ///
        /// 2. Return a boolean value.
        ///
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public static bool LogInformation(
            string Description, Evado.Model.EvEventCodes EventId, string Category, string UserName)
        {
            //
            // Create the event comment content
            //
            string sEventContent = "EventId: " + EventId.ToString( )
                                   + "\r\nEvent Category: " + Category
                                   + "\r\nUserId:  " + UserName
                                   + "\r\n\r\nDescription:\r\n" + Description;

            //
            // Write the event comment to the event log.
            //
            WriteLog(sEventContent, EventLogEntryType.Information);

            //
            // Return a boolean value
            //
            return(true);
        } //END LogInformation method
示例#5
0
        }//END decryptString method

        //  =================================================================================
        /// <summary>
        /// This method decrypts a string of encrypted text.
        ///
        /// </summary>
        /// <param name="Guid_1">a Guid identifier used as part of the encryption key </param>
        /// <param name="Guid_2">a Guid identifier used as part of the encryption key </param>
        //  ---------------------------------------------------------------------------------
        private void encodeKeyFromGuid(Guid Guid_1, Guid Guid_2)
        {
            this.LogMethod("encodeKeyFromGuid method. ");
            this.LogDebug("Guid_1: " + Guid_1 + ", Guid_2: " + Guid_2);

            //
            // Initialise the method variables and objects.
            //
            this._eventId = Evado.Model.EvEventCodes.Ok;

            byte [] byteGuid_1 = Guid_1.ToByteArray( );
            byte [] byteGuid_2 = Guid_2.ToByteArray( );
            byte [] byteGuids  = new byte [32];

            for (int index = 0; index < 16; index++)
            {
                byteGuids [index]        = byteGuid_1 [index];
                byteGuids [(index + 16)] = byteGuid_2 [index];
            }
            this.LogDebug("byteGuids length: " + byteGuids.Length + " value: " + Convert.ToBase64String(byteGuids));

            for (int index = 0; index < 24; index++)
            {
                this._Key [index] = byteGuids [index];
            }

            for (int index = 24; index < 32; index++)
            {
                this._IV [(index - 24)] = byteGuids [index];
            }
            this.LogDebug("Key length: " + this._Key.Length);
            this.LogDebug("Key value: " + Convert.ToBase64String(this._Key));
            this.LogDebug("IV length: " + this._IV.Length);
            this.LogDebug("IV value: " + Convert.ToBase64String(this._IV));

            this.LogMethodEnd("encodeKeyFromGuid");
        }//END encodeKeyFromGuid method