CSLA - Extension
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
@@ -14,63 +13,30 @@ namespace VEPROMS.CSLA.Library
|
||||
public delegate void ROImageInfoCompressionEvent(object sender, ROImageInfoCompressionEventArgs args);
|
||||
public class ROImageInfoCompressionEventArgs
|
||||
{
|
||||
private int _Total;
|
||||
public int Total
|
||||
public int Total { get; set; }
|
||||
public int Current { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public ROImageCompressionEventType Type { get; set; }
|
||||
public ROImageInfoCompressionEventArgs(ROImageCompressionEventType type) => Type = type;
|
||||
public ROImageInfoCompressionEventArgs(int current, string fileName)
|
||||
{
|
||||
get { return _Total; }
|
||||
set { _Total = value; }
|
||||
}
|
||||
private int _Current;
|
||||
public int Current
|
||||
{
|
||||
get { return _Current; }
|
||||
set { _Current = value; }
|
||||
}
|
||||
private string _FileName;
|
||||
public string FileName
|
||||
{
|
||||
get { return _FileName; }
|
||||
set { _FileName = value; }
|
||||
}
|
||||
private ROImageCompressionEventType _Type;
|
||||
public ROImageCompressionEventType Type
|
||||
{
|
||||
get { return _Type; }
|
||||
set { _Type = value; }
|
||||
}
|
||||
public ROImageInfoCompressionEventArgs(ROImageCompressionEventType type)
|
||||
{
|
||||
_Type = type;
|
||||
}
|
||||
public ROImageInfoCompressionEventArgs(int current, string fileName)
|
||||
{
|
||||
_Current = current;
|
||||
_FileName = fileName;
|
||||
_Type = ROImageCompressionEventType.Update;
|
||||
Current = current;
|
||||
FileName = fileName;
|
||||
Type = ROImageCompressionEventType.Update;
|
||||
}
|
||||
public ROImageInfoCompressionEventArgs(int total)
|
||||
{
|
||||
_Type = ROImageCompressionEventType.Initialize;
|
||||
_Total = total;
|
||||
Type = ROImageCompressionEventType.Initialize;
|
||||
Total = total;
|
||||
}
|
||||
}
|
||||
public enum ROImageCompressionEventType:int {Initialize, Update, Complete};
|
||||
public partial class ROImageInfo
|
||||
{
|
||||
public static event ROImageInfoCompressionEvent CompressAllExistingImages;
|
||||
public static void OnCompressAllExistingImages(object sender, ROImageInfoCompressionEventArgs args)
|
||||
public static void OnCompressAllExistingImages(object sender, ROImageInfoCompressionEventArgs args) => CompressAllExistingImages?.Invoke(sender, args);
|
||||
public static ROImageInfo GetByROFstID_FileName(int rOFstID, string fileName)
|
||||
{
|
||||
if (CompressAllExistingImages != null) CompressAllExistingImages(sender, args);
|
||||
}
|
||||
// put in for debug
|
||||
//public static int CacheCountPrimaryKey
|
||||
//{ get { return _CacheByPrimaryKey.Count; } }
|
||||
//public static int CacheCountList
|
||||
//{ get { return _CacheList.Count; } }
|
||||
public static ROImageInfo GetByROFstID_FileName(int rOFstID, string fileName)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a ROImage");
|
||||
try
|
||||
{
|
||||
if (fileName.EndsWith("PCX")) fileName = fileName.Replace(".PCX", ".TIF");
|
||||
@@ -95,7 +61,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static byte[] Compress(byte[] blob)
|
||||
{
|
||||
int size = blob.Length;
|
||||
using (MemoryStream Source = new MemoryStream(blob))
|
||||
{
|
||||
using (MemoryStream Destination = new MemoryStream())
|
||||
@@ -171,9 +136,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
string nm = ro.FileName;
|
||||
OnCompressAllExistingImages(null, new ROImageInfoCompressionEventArgs(pcount++, nm));
|
||||
ROImageConfig rc = new ROImageConfig();
|
||||
rc.Image_Size = ro.Content.Length.ToString();
|
||||
ro.Content = ROImageInfo.Compress(ro.Content);
|
||||
ROImageConfig rc = new ROImageConfig
|
||||
{
|
||||
Image_Size = ro.Content.Length.ToString()
|
||||
};
|
||||
ro.Content = ROImageInfo.Compress(ro.Content);
|
||||
ro.Config = rc.ToString();
|
||||
ro.Save();
|
||||
}
|
||||
@@ -226,14 +193,11 @@ namespace VEPROMS.CSLA.Library
|
||||
[Serializable()]
|
||||
private class ROFstID_FileNameCriteria
|
||||
{
|
||||
private int _ROFstID;
|
||||
|
||||
public int ROFstID
|
||||
{ get { return _ROFstID; } }
|
||||
private string _FileName;
|
||||
public string FileName
|
||||
{ get { return _FileName; } }
|
||||
public ROFstID_FileNameCriteria(int rOFstID, string fileName)
|
||||
private readonly int _ROFstID;
|
||||
public int ROFstID => _ROFstID;
|
||||
private readonly string _FileName;
|
||||
public string FileName => _FileName;
|
||||
public ROFstID_FileNameCriteria(int rOFstID, string fileName)
|
||||
{
|
||||
_ROFstID = rOFstID;
|
||||
_FileName = fileName;
|
||||
@@ -245,7 +209,6 @@ namespace VEPROMS.CSLA.Library
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#region Fields
|
||||
private bool _IsDisposed;
|
||||
//private static string _TemporaryFolder = null;
|
||||
#endregion
|
||||
#region Properties
|
||||
private ROImageInfo _MyROImage = null;
|
||||
@@ -260,19 +223,12 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
private FileInfo _MyFile = null;
|
||||
public FileInfo MyFile
|
||||
{
|
||||
get { return _MyFile; }
|
||||
}
|
||||
private string _Extension = "TIF";
|
||||
public string Extension
|
||||
{
|
||||
get { return _Extension; }
|
||||
set { _Extension = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Private Methods
|
||||
private void TryDelete()
|
||||
public FileInfo MyFile => _MyFile;
|
||||
|
||||
public string Extension { get; set; } = "TIF";
|
||||
#endregion
|
||||
#region Private Methods
|
||||
private void TryDelete()
|
||||
{
|
||||
if (_MyROImage == null) return;
|
||||
if (_MyFile == null) return;
|
||||
@@ -356,15 +312,12 @@ namespace VEPROMS.CSLA.Library
|
||||
roImage.DTS = _MyFile.LastWriteTimeUtc;
|
||||
roImage.Save();
|
||||
}
|
||||
#endregion
|
||||
#region Constructors
|
||||
public ROImageFile(ROImageInfo myROImage)
|
||||
{
|
||||
MyROImage = myROImage;
|
||||
}
|
||||
#endregion
|
||||
#region Destructor
|
||||
~ROImageFile()
|
||||
#endregion
|
||||
#region Constructors
|
||||
public ROImageFile(ROImageInfo myROImage) => MyROImage = myROImage;
|
||||
#endregion
|
||||
#region Destructor
|
||||
~ROImageFile()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
@@ -374,7 +327,8 @@ namespace VEPROMS.CSLA.Library
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping disposing to match different signature")]
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (!_IsDisposed)
|
||||
{
|
||||
@@ -402,17 +356,10 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private class RODbIDNoDataCriteria
|
||||
{
|
||||
public RODbIDNoDataCriteria(int rODbID)
|
||||
{
|
||||
_RODbID = rODbID;
|
||||
}
|
||||
private int _RODbID;
|
||||
public int RODbID
|
||||
{
|
||||
get { return _RODbID; }
|
||||
set { _RODbID = value; }
|
||||
}
|
||||
}
|
||||
public RODbIDNoDataCriteria(int rODbID) => RODbID = rODbID;
|
||||
|
||||
public int RODbID { get; set; }
|
||||
}
|
||||
private void DataPortal_Fetch(RODbIDNoDataCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
@@ -448,7 +395,6 @@ namespace VEPROMS.CSLA.Library
|
||||
try
|
||||
{
|
||||
ROImageInfoList tmp = DataPortal.Fetch<ROImageInfoList>(new RODbIDFilenameCriteria(rODbID,filename));
|
||||
//ROImageInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
@@ -461,22 +407,13 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public RODbIDFilenameCriteria(int rODbID,string filename)
|
||||
{
|
||||
_RODbID = rODbID;
|
||||
_Filename = filename;
|
||||
RODbID = rODbID;
|
||||
Filename = filename;
|
||||
}
|
||||
private int _RODbID;
|
||||
public int RODbID
|
||||
{
|
||||
get { return _RODbID; }
|
||||
set { _RODbID = value; }
|
||||
}
|
||||
private string _Filename;
|
||||
public string Filename
|
||||
{
|
||||
get { return _Filename; }
|
||||
set { _Filename = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public int RODbID { get; set; }
|
||||
public string Filename { get; set; }
|
||||
}
|
||||
private void DataPortal_Fetch(RODbIDFilenameCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
|
||||
Reference in New Issue
Block a user