示例#1
0
 public static void LookupDevice(ExtendedForm parentForm, Device device)
 {
     if (device != null)
     {
         if (!FormIsOpenByGuid(typeof(ViewDeviceForm), device.Guid))
         {
             new ViewDeviceForm(parentForm, device);
         }
     }
     else
     {
         OtherFunctions.Message("Device not found.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Error", parentForm);
     }
 }
示例#2
0
 private static bool handleNullReferenceException(Exception ex, MethodBase Method)
 {
     Logging.Logger("ERROR:  MethodName=" + Method.Name + "  Type: " + ex.GetType().Name + "  #:" + ex.HResult + "  Message:" + ex.Message);
     if (ServerInfo.ServerPinging)
     {
         PromptUser("ERROR:  MethodName=" + Method.Name + "  Type: " + ex.GetType().Name + "  #:" + ex.HResult + "  Message:" + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "ERROR");
         OtherFunctions.EndProgram(true);
         return(false);
     }
     else
     {
         return(true);
     }
 }
示例#3
0
 private static void UnHandledError(Exception ex, int ErrorCode, MethodBase Method)
 {
     Logging.Logger("UNHANDLED ERROR:  MethodName=" + Method.Name + "  Type: " + ex.GetType().Name + "  #:" + ErrorCode + "  Message:" + ex.Message);
     PromptUser("UNHANDLED ERROR:  MethodName=" + Method.Name + "  Type: " + ex.GetType().Name + "  #:" + ErrorCode + "  Message:" + ex.Message + Environment.NewLine + Environment.NewLine + "file://" + Paths.LogPath, MessageBoxButtons.OK, MessageBoxIcon.Error, "ERROR");
     OtherFunctions.EndProgram(true);
 }
        private static DataTable BuildDataSource(DataTable data, List <GridColumnAttrib> columns, bool forceRawData)
        {
            var needsRebuilt = ColumnsRequireRebuild(columns);

            if (needsRebuilt & !forceRawData)
            {
                DataTable newTable = new DataTable();

                // Add columns to the new table.
                foreach (GridColumnAttrib col in columns)
                {
                    if (col.ColumnType != null)
                    {
                        newTable.Columns.Add(col.ColumnName, col.ColumnType);
                    }
                    else
                    {
                        if (data.Columns.Contains(col.ColumnName))
                        {
                            newTable.Columns.Add(col.ColumnName, data.Columns[col.ColumnName].DataType);
                        }
                    }
                }

                foreach (DataRow row in data.Rows)
                {
                    DataRow newRow = newTable.NewRow();

                    foreach (GridColumnAttrib col in columns)
                    {
                        if (!data.Columns.Contains(col.ColumnName))
                        {
                            continue;
                        }

                        switch (col.ColumnFormatType)
                        {
                        case ColumnFormatType.DefaultFormat:
                        case ColumnFormatType.AttributeCombo:
                            newRow[col.ColumnName] = row[col.ColumnName];

                            break;

                        case ColumnFormatType.AttributeDisplayMemberOnly:
                            newRow[col.ColumnName] = col.Attributes[row[col.ColumnName].ToString()].DisplayValue;

                            break;

                        case ColumnFormatType.NotePreview:
                            var noteText = OtherFunctions.RTFToPlainText(row[col.ColumnName].ToString());
                            newRow[col.ColumnName] = OtherFunctions.NotePreview(noteText);

                            break;

                        case ColumnFormatType.FileSize:
                            newRow[col.ColumnName] = Math.Round((Convert.ToInt32(row[col.ColumnName]) / 1024d), 1);

                            break;

                        case ColumnFormatType.Image:
                            newRow[col.ColumnName] = FileIcon.GetFileIcon(row[col.ColumnName].ToString());

                            break;
                        }
                    }
                    newTable.Rows.Add(newRow);
                }
                return(newTable);
            }
            else
            {
                return(data);
            }
        }