Ejemplo n.º 1
0
 /// <summary>
 /// A blob created from a file uploaded by a client.
 /// </summary>
 /// <param name="file">A file uploaded by a client.</param>
 public Blob(HttpPostedFile file)
 {
     this.Name       = HString.SafeTrim(Path.GetFileName(file.FileName));
     this.BinaryData = HBinary.GetBytes(file.InputStream);
     this.Size       = HNumeric.GetSafeInteger(file.ContentLength);
     this.MimeType   = HString.SafeTrim(file.ContentType);
     this.State      = ObjectState.ToBeInserted;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Load a change log item from a data row.
 /// </summary>
 /// <param name="dr">Data row containing the data to load.</param>
 /// <remarks></remarks>
 public ChangeLogItem(DataRow dr)
     : base(dr)
 {
     this.ID            = HNumeric.GetSafeInteger(dr["change_log_master_id"]);
     this.PropertyName  = HString.SafeTrim(dr["property_name"]);
     this.PreviousValue = HString.SafeTrim(dr["prev_value"]);
     this.NewValue      = HString.SafeTrim(dr["new_value"]);
     this.State         = ObjectState.Unchanged;
 }
Ejemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            // Get the month the page should display.
            DateTime displayMonth = HDateTime.GetDateTime(HNumeric.GetSafeInteger(this.ddlYear.SelectedValue), HNumeric.GetSafeInteger(this.ddlMonth.SelectedValue), 1);

            // Set UI to indicate what month is being displayed.
            this.SetControls(displayMonth);

            // Output html to page.
            this.LoadCalendar(displayMonth);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// A blob loaded from the database.
 /// </summary>
 /// <param name="dr">The data row to populate the Blob object.</param>
 /// <param name="IncludeBinaryData">Flag that determines whether to load the binary data or not.</param>
 public Blob(DataRow dr, Boolean IncludeBinaryData)
 {
     this.ID = HNumeric.GetSafeInteger(dr["binary_id"]);
     if (IncludeBinaryData)
     {
         this.BinaryData = (Byte[])dr["binary_data"];
     }
     this.Name     = HString.SafeTrim(dr["binary_name"]);
     this.MimeType = HString.SafeTrim(dr["binary_mime_type"]);
     this.Size     = HNumeric.GetSafeInteger(dr["binary_size"]);
     this.State    = ObjectState.Unchanged;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Modify what data gets binded.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void gvUploads_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         // This is the current row being binded.
         GridViewRow gridRow = e.Row as GridViewRow;
         if (gridRow.Cells.Count >= 3)
         {
             // Modify file size value to something friendlier.
             TableCell fileSize = gridRow.Cells[2];
             fileSize.Text = HBinary.GetBytesReadable(HNumeric.GetSafeInteger(fileSize.Text));
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Get any differences between the old and new property values.
        /// </summary>
        /// <param name="prevValue">Prevous property value.</param>
        /// <param name="newValue">New property value.</param>
        /// <param name="ObjectState">The state of the object.</param>
        /// <param name="ObjectType">The type of the object.</param>
        /// <param name="propertyInfo">The property being evaluated.</param>
        /// <returns></returns>
        private ChangeLogItem GetChangeLogItem(Object prevValue, Object newValue, ObjectState ObjectState, Type ObjectType, PropertyInfo propertyInfo)
        {
            ChangeLogItem lItem = new ChangeLogItem();

            lItem.OwnerID      = this.OwnerID;
            lItem.OwnerName    = ObjectType.Name;
            lItem.PropertyName = propertyInfo.Name;
            lItem.Type         = ObjectState.ToString().Replace("ToBe", String.Empty); // Get rid of future tense from state name.

            if (Object.ReferenceEquals(propertyInfo.PropertyType, typeof(String)))
            {
                // COMPARE STRINGS

                String logPrevious = HString.SafeTrim(prevValue);
                String logNew      = HString.SafeTrim(newValue);

                if (!logNew.Equals(logPrevious))
                {
                    lItem.PreviousValue = logPrevious;
                    lItem.NewValue      = logNew;
                    return(lItem);
                }
            }
            else if (Object.ReferenceEquals(propertyInfo.PropertyType, typeof(Int32)))
            {
                // COMPARE INTEGERS

                Int32 logPrevious = HNumeric.GetSafeInteger(prevValue);
                Int32 logNew      = HNumeric.GetSafeInteger(newValue);

                if (!logNew.Equals(logPrevious))
                {
                    lItem.PreviousValue = logPrevious.ToString();
                    lItem.NewValue      = logNew.ToString();
                    return(lItem);
                }
            }
            else if (Object.ReferenceEquals(propertyInfo.PropertyType, typeof(Decimal)))
            {
                // COMPARE DECIMALS

                Decimal logPrevious = HNumeric.GetSafeDecimal(prevValue);
                Decimal logNew      = HNumeric.GetSafeDecimal(newValue);

                if (!logNew.Equals(logPrevious))
                {
                    lItem.PreviousValue = logPrevious.ToString();
                    lItem.NewValue      = logNew.ToString();
                    return(lItem);
                }
            }
            else if (Object.ReferenceEquals(propertyInfo.PropertyType, typeof(DateTime)))
            {
                // COMPARE DATETIMES

                DateTime logPrevious = HDateTime.GetDateTime(prevValue);
                DateTime logNew      = HDateTime.GetDateTime(newValue);

                if (!logNew.Equals(logPrevious))
                {
                    lItem.PreviousValue = logPrevious.ToString();
                    lItem.NewValue      = logNew.ToString();
                    return(lItem);
                }
            }
            else if (propertyInfo.PropertyType.IsEnum)
            {
                // COMPARE ENUMS

                Int32 logPrevious = Convert.ToInt32(prevValue);
                Int32 logNew      = Convert.ToInt32(newValue);

                if (!logNew.Equals(logPrevious))
                {
                    lItem.PreviousValue = logPrevious.ToString();
                    lItem.NewValue      = logNew.ToString();
                    return(lItem);
                }
            }

            return(null);
        }