3 Commits

5 changed files with 126 additions and 249 deletions
+5
View File
@@ -637,6 +637,11 @@ namespace Lskj.Control
}
_gridResourcesDisposed = true;
if (cellHelper != null)
{
cellHelper.Dispose();
cellHelper = null;
}
StopColumnSourceTimer();
if (mTimer != null)
{
@@ -12,10 +12,15 @@ using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
// Token: 0x02000003 RID: 3
public class AmountCellRender
public class AmountCellRender : IDisposable
{
public AmountCellRender(GridView gridView_0)
{
if (gridView_0 == null)
{
throw new ArgumentNullException("gridView_0");
}
Class5.gBkiB4AzUqwkh();
this.colorGray = Color.FromArgb(189, 185, 185);
this.colorGreen = Color.Green;
@@ -25,23 +30,58 @@ public class AmountCellRender
this.dictionary_0 = new Dictionary<string, Class2>();
this.list_0 = new List<GridColumn>();
this.object_0 = gridView_0;
this.gridControl_0 = this.object_0.GridControl;
this.object_0.CustomDrawCell += this.object_0_CustomDrawCell;
this.object_0.CustomDrawColumnHeader += this.object_0_CustomDrawColumnHeader;
this.object_0.CustomDrawFooterCell += this.object_0_CustomDrawFooterCell;
this.object_0.GridControl.Paint += this.method_0;
if (this.gridControl_0 != null)
{
this.gridControl_0.Paint += this.method_0;
}
}
private void method_0(object sender, PaintEventArgs e)
{
BaseViewInfo viewInfo = ((sender as GridControl).FocusedView as GridView).GetViewInfo();
if (this.disposed || this.list_0.Count == 0)
{
return;
}
GridControl gridControl = sender as GridControl;
if (gridControl == null || gridControl.IsDisposed || gridControl.Disposing)
{
return;
}
GridView gridView = gridControl.FocusedView as GridView;
if (gridView == null)
{
return;
}
GridViewInfo gridViewInfo = gridView.GetViewInfo() as GridViewInfo;
if (gridViewInfo == null || gridViewInfo.ColumnsInfo == null)
{
return;
}
foreach (GridColumn gridColumn in this.list_0)
{
Class2 @class = this.dictionary_0[gridColumn.Name];
Class2 @class;
if (gridColumn == null ||
!this.dictionary_0.TryGetValue(gridColumn.Name, out @class) ||
@class == null)
{
continue;
}
if (@class.IsCountinuousCell())
{
GridViewInfo gridViewInfo = viewInfo as GridViewInfo;
GridColumnInfoArgs gridColumnInfoArgs = gridViewInfo.ColumnsInfo[gridColumn];
if (gridColumnInfoArgs == null) return;
if (gridColumnInfoArgs == null)
{
continue;
}
int num = 0;
int int_;
if (@class.method_4())
@@ -82,10 +122,16 @@ public class AmountCellRender
private void object_0_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (this.dictionary_0.ContainsKey(e.Column.Name))
if (this.disposed || e.Column == null)
{
return;
}
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
e.DisplayText = "";
Class2 @class = this.dictionary_0[e.Column.Name];
Rectangle bounds = e.Bounds;
Rectangle rectangle_ = bounds;
Graphics graphics = e.Graphics;
@@ -98,14 +144,20 @@ public class AmountCellRender
private void object_0_CustomDrawFooterCell(object sender, FooterCellCustomDrawEventArgs e)
{
if (this.dictionary_0.ContainsKey(e.Column.Name))
if (this.disposed || e.Column == null)
{
return;
}
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
Class2 @class = this.dictionary_0[e.Column.Name];
if (@class.method_8())
{
e.Info.DisplayText = "";
Rectangle bounds = e.Bounds;
@class.method_17(bounds, e.Graphics, e.Appearance.Font, e.Info.Value.ToString());
@class.method_17(bounds, e.Graphics, e.Appearance.Font, Convert.ToString(e.Info.Value));
e.Handled = true;
}
}
@@ -113,13 +165,15 @@ public class AmountCellRender
private void object_0_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
{
if (e.Column == null)
if (this.disposed || e.Column == null)
{
return;
}
if (this.dictionary_0.ContainsKey(e.Column.Name))
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
Class2 @class = this.dictionary_0[e.Column.Name];
if (@class.method_6())
{
e.Column.Caption = "";
@@ -204,14 +258,44 @@ public class AmountCellRender
public void RemoveAmountColumn(GridColumn gridColumn_0)
{
if (this.dictionary_0.ContainsKey(gridColumn_0.Name))
if (gridColumn_0 != null && this.dictionary_0.ContainsKey(gridColumn_0.Name))
{
this.dictionary_0.Remove(gridColumn_0.Name);
this.list_0.Remove(gridColumn_0);
}
}
public void Dispose()
{
if (this.disposed)
{
return;
}
this.disposed = true;
GridView gridView = this.object_0;
GridControl gridControl = this.gridControl_0;
this.object_0 = null;
this.gridControl_0 = null;
if (gridView != null)
{
gridView.CustomDrawCell -= this.object_0_CustomDrawCell;
gridView.CustomDrawColumnHeader -= this.object_0_CustomDrawColumnHeader;
gridView.CustomDrawFooterCell -= this.object_0_CustomDrawFooterCell;
}
if (gridControl != null)
{
gridControl.Paint -= this.method_0;
}
this.dictionary_0.Clear();
this.list_0.Clear();
}
private GridView object_0;
private GridControl gridControl_0;
private bool disposed;
private Color colorGray;
private Color colorGreen;
+9 -3
View File
@@ -255,7 +255,10 @@ public class Class2
if (color != Color.Empty)
{
Rectangle rect = new Rectangle(rectangle_0.Left + i - 2, int_2, int_1, int_3);
graphics_0.FillRectangle(new SolidBrush(color), rect);
using (SolidBrush solidBrush = new SolidBrush(color))
{
graphics_0.FillRectangle(solidBrush, rect);
}
}
}
else
@@ -265,9 +268,12 @@ public class Class2
num++;
}
Rectangle rect2 = new Rectangle(rectangle_0.Left - 1, int_2, int_1 + 1, int_3);
graphics_0.FillRectangle(new SolidBrush(Color.FromArgb(161, 157, 157)), rect2);
Rectangle rect3 = new Rectangle(rectangle_0.Left + rectangle_0.Width - 1, int_2, int_1 + 1, int_3);
graphics_0.FillRectangle(new SolidBrush(Color.FromArgb(161, 157, 157)), rect3);
using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(161, 157, 157)))
{
graphics_0.FillRectangle(solidBrush, rect2);
graphics_0.FillRectangle(solidBrush, rect3);
}
}
// Token: 0x06000028 RID: 40 RVA: 0x00002CC8 File Offset: 0x00000EC8
+11 -1
View File
@@ -13,10 +13,20 @@
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
if (disposing)
{
if (cellHelper != null)
{
cellHelper.Dispose();
cellHelper = null;
}
class2_0 = null;
class2_1 = null;
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
-228
View File
@@ -13,7 +13,6 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lskj.Control;
using Lskj.Model;
@@ -24,7 +23,6 @@ using Lskj.Business.Impl;
using Lskj.Business;
using System.Threading.Tasks;
using System.Collections;
using System.IO;
using System.Reflection;
namespace Lskj.Report
@@ -42,8 +40,6 @@ namespace Lskj.Report
mReportGridLocalizerViews =
new HashSet<DevExpress.XtraGrid.Views.Base.BaseView>();
private bool mReportGridResourcesReleased;
private int mDisposedReportGridViewCount;
private int mRemovedGridLocalizerHandlerCount;
public FrmMain()
{
@@ -99,19 +95,12 @@ namespace Lskj.Report
private void OnClose(object sender, FormClosingEventArgs e)
{
WriteReportLifecycleDiagnostics("closing-before-close-module");
this.mControl.CloseModule();
WriteReportLifecycleDiagnostics("closing-after-close-module");
}
private void OnFrmMainDisposed(object sender, EventArgs e)
{
DisposeReportGridViews();
WriteReportLifecycleDiagnostics(
"disposed-event;disposedGridViews=" +
mDisposedReportGridViewCount +
";gridLocalizerRemoved=" +
mRemovedGridLocalizerHandlerCount);
mReportGridLocalizerViews.Clear();
mPreexistingGridLocalizerViews.Clear();
this.FormClosing -= OnClose;
@@ -142,7 +131,6 @@ namespace Lskj.Report
}
mReportGridResourcesReleased = true;
WriteReportLifecycleDiagnostics("dispose-before-gridviews");
CaptureReportGridLocalizerViews();
if (this.mControl != null)
{
@@ -151,8 +139,6 @@ namespace Lskj.Report
HashSet<DevExpress.XtraGrid.Views.Base.BaseView> disposedViews =
new HashSet<DevExpress.XtraGrid.Views.Base.BaseView>();
int disposeErrorCount = 0;
int detachedDataSourceCount = 0;
foreach (System.Windows.Forms.Control control in
EnumerateControls(this.mControl))
{
@@ -165,12 +151,10 @@ namespace Lskj.Report
if (gridControl.DataSource != null)
{
gridControl.DataSource = null;
detachedDataSourceCount++;
}
}
catch (Exception ex)
{
disposeErrorCount++;
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseReport);
}
@@ -191,7 +175,6 @@ namespace Lskj.Report
}
catch (Exception ex)
{
disposeErrorCount++;
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseReport);
}
}
@@ -216,33 +199,16 @@ namespace Lskj.Report
dataSourceProperty.GetValue(control, null) != null)
{
dataSourceProperty.SetValue(control, null, null);
detachedDataSourceCount++;
}
}
catch (Exception ex)
{
disposeErrorCount++;
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseReport);
}
}
}
int trackedGridViews = mReportGridLocalizerViews.Count;
int removedGridLocalizerHandlers =
ReleaseTrackedGridLocalizerViews(disposedViews);
mDisposedReportGridViewCount = disposedViews.Count;
mRemovedGridLocalizerHandlerCount = removedGridLocalizerHandlers;
WriteReportLifecycleDiagnostics(
"dispose-after-gridviews;dispose-attempts=" +
disposedViews.Count +
";dispose-errors=" +
disposeErrorCount +
";detachedDataSources=" +
detachedDataSourceCount +
";trackedGridViews=" +
trackedGridViews +
";gridLocalizerRemoved=" +
removedGridLocalizerHandlers);
}
private void CaptureReportGridLocalizerViews()
@@ -454,200 +420,6 @@ namespace Lskj.Report
handler.Target is DevExpress.XtraGrid.Views.Base.BaseView;
}
private void WriteReportLifecycleDiagnostics(string phase)
{
if (!IsReportDiagnosticsEnabled())
{
return;
}
try
{
LogHelper.Instance.WriteLog(
"REPORT_DIAGNOSTIC phase=" +
(phase ?? string.Empty) +
" " +
GetReportGridDiagnostics(),
"ResourceDiagnostics.Report");
}
catch
{
// Diagnostics must never interfere with module close/dispose.
}
}
private string GetReportGridDiagnostics()
{
int controlCount = 0;
int gridControlCount = 0;
int viewCount = 0;
HashSet<DevExpress.XtraGrid.Views.Base.BaseView> views =
new HashSet<DevExpress.XtraGrid.Views.Base.BaseView>();
StringBuilder viewDetails = new StringBuilder();
try
{
if (this.mControl != null)
{
foreach (System.Windows.Forms.Control control in EnumerateControls(this.mControl))
{
controlCount++;
DevExpress.XtraGrid.GridControl gridControl =
control as DevExpress.XtraGrid.GridControl;
if (gridControl == null)
{
continue;
}
gridControlCount++;
foreach (DevExpress.XtraGrid.Views.Base.BaseView view in
gridControl.ViewCollection.Cast<DevExpress.XtraGrid.Views.Base.BaseView>())
{
if (view == null || !views.Add(view))
{
continue;
}
viewCount++;
if (viewDetails.Length < 1800)
{
if (viewDetails.Length > 0)
{
viewDetails.Append(",");
}
viewDetails.Append(SafeViewDescription(view));
}
}
}
}
}
catch (Exception exception)
{
viewDetails.Append(",enumeration-error=");
viewDetails.Append(exception.GetType().Name);
}
return "formDisposed=" +
this.IsDisposed +
";controlCount=" +
controlCount +
";gridControlCount=" +
gridControlCount +
";viewCount=" +
viewCount +
";views=" +
viewDetails +
";gridLocalizer=" +
DescribeGridLocalizer();
}
private static string SafeViewDescription(
DevExpress.XtraGrid.Views.Base.BaseView view)
{
try
{
return view.GetType().FullName +
":" +
(view.Name ?? string.Empty).Replace(";", ",");
}
catch
{
return "<view-description-error>";
}
}
private static string DescribeGridLocalizer()
{
try
{
var active =
DevExpress.XtraGrid.Localization.GridLocalizer.Active;
if (active == null)
{
return "active=null";
}
StringBuilder handlers = new StringBuilder();
int handlerCount = 0;
Type currentType = active.GetType();
while (currentType != null && currentType != typeof(object))
{
FieldInfo[] fields = currentType.GetFields(
BindingFlags.Instance |
BindingFlags.Static |
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.DeclaredOnly);
foreach (FieldInfo field in fields)
{
if (!typeof(Delegate).IsAssignableFrom(field.FieldType))
{
continue;
}
object owner = field.IsStatic ? null : (object)active;
Delegate value = field.GetValue(owner) as Delegate;
if (value == null)
{
continue;
}
foreach (Delegate handler in value.GetInvocationList())
{
handlerCount++;
if (handlers.Length < 1800)
{
if (handlers.Length > 0)
{
handlers.Append(",");
}
string targetType = handler.Target == null
? "static"
: handler.Target.GetType().FullName;
handlers.Append(field.Name.Replace(";", ","));
handlers.Append("->");
handlers.Append(targetType.Replace(";", ","));
handlers.Append(".");
handlers.Append(handler.Method.Name.Replace(";", ","));
}
}
}
currentType = currentType.BaseType;
}
return "activeType=" +
active.GetType().FullName.Replace(";", ",") +
";handlerCount=" +
handlerCount +
";handlers=" +
handlers;
}
catch (Exception exception)
{
return "localizer-error=" + exception.GetType().Name;
}
}
private static bool IsReportDiagnosticsEnabled()
{
try
{
return File.Exists(
Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"Logs",
"ResourceDiagnostics",
"resource-diagnostics.enabled"));
}
catch
{
return false;
}
}
private static IEnumerable<System.Windows.Forms.Control> EnumerateControls(
System.Windows.Forms.Control root)
{