This commit is contained in:
2018-06-29 19:47:36 +00:00
commit be7f501333
3769 changed files with 1425961 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("AyaNova BLL")]
[assembly: AssemblyDescription("AyaNova business object library")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ground Zero Tech-Works Inc.")]
[assembly: AssemblyProduct("AyaNova")]
[assembly: AssemblyCopyright("Copyright 1999-2018 Ground Zero Tech-Works Inc. All rights reserved.")]
[assembly: AssemblyTrademark("AyaNova® is either a registered trademark or trademark of Ground Zero Tech-Works Inc. in the United States and/or other countries.")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("7.5.0.0")]
// Test commnet for subversion testing
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto WorkorderService
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following Processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("..\\..\\..\\..\\..\\keys\\AyaNova.snk")]
//[assembly: AssemblyKeyName("")]
//[assembly:System.CLSCompliant(true)]
// Configure log4net using the .config file
//[assembly: log4net.Config.XmlConfigurator(ConfigFile="Log4Net.config",Watch=true)]
//[assembly: log4net.Config.XmlConfigurator( ConfigFile="Log4Net.config",Watch=true )]
[assembly: AssemblyFileVersionAttribute("7.5.8.0")]

View File

@@ -0,0 +1,278 @@
///////////////////////////////////////////////////////////
// Document.cs
// Implementation of the Class Document
// Generated by Enterprise Architect
// Created on: 28-May-2004 1:21:49 PM
// Original author: Joyce
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using CSLA;//using CSLA;
namespace GZTW.AyaNova.BLL {
[Serializable]
public class Document : BusinessBase {
private Guid mID;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
/// <summary>
/// Calculated checksum of the data contained in the business object to handle mult-
/// user concurrency
/// </summary>
private long mOriginalCheckSum;
private string mNotes;
/// <summary>
/// Binary array of bytes stored in the database as an image field
/// </summary>
private byte mDocumentData;
/// <summary>
/// original file name and extension
/// </summary>
private string mFileName;
/// <summary>
/// if null than is a actual document stored within the database
/// if not null, is a redirect to a document at a specific location outside the
/// database (i.e webpage, file on server, local directory)
/// </summary>
private string mURL;
/// <summary>
/// User friendly name of document
/// </summary>
private string mName;
~Document(){
}
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private Document()
{
mID=Guid.NewGuid();
mCreated=new SmartDate();
mModified=new SmartDate();
}
/// <summary>
/// original file name and extension
/// </summary>
public string FileName {
get{
return mFileName;
}
set{
mFileName = value;
}
}
/// <summary>
/// user friendly name
/// </summary>
public string Name
{
get
{
return mName;
}
set
{
mName = value;
}
}
public string Notes {
get{
return mNotes;
}
set{
mNotes = value;
}
}
/// <summary>
/// Binary array of bytes stored in the database as an image field
/// </summary>
public byte DocumentData {
get{
return mDocumentData;
}
set{
mDocumentData = value;
}
}
/// <summary>
/// if null than is a actual document stored within the database
/// if not null, is a redirect to a document at a specific location outside the
/// database (i.e webpage, file on server, local directory)
/// </summary>
public string URL {
get{
return mURL;
}
set{
mURL = value;
}
}
public override string ToString(){
return "Document:" + mName + mID.ToString();
}
///
/// <param name="obj"></param>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
Document c=(Document)obj;
return mID==c.mID;
}
public override int GetHashCode()
{
return mID.GetHashCode();
}
public static Document NewItem(){
return (Document)DataPortal.Create(new Criteria(Guid.Empty));
}
///
/// <param name="_ID">Client Guid</param>
public static Document GetItem(Guid _ID){
return (Document)DataPortal.Fetch(new Criteria(_ID));
}
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID=_ID;
}
}
#endregion
/// <summary>
/// Delete Document
/// Rules:
/// - can't delete if used anywhere in database
/// </summary>
/// <param name="_ID">Client GUID</param>
public static void DeleteItem(Guid _ID)
{
}
/// <summary>
/// Called by DataPortal so that we can set defaults as needed Would probably do a
/// lookup from the db for default values in a more complete version
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Create(object Criteria){
}
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria){
}
/// <summary>
/// Called by DataPortal to delete/add/update data into the database
/// </summary>
protected override void DataPortal_Update(){
}
/// <summary>
/// Remove a Document record from the database but only if you are an
/// administrator
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Delete(object Criteria){
}
/// <summary>
/// Get internal id number Read only property because it's set internally, not
/// externally
/// </summary>
public Guid ID {
get{
return mID;
}
}
/// <summary>
/// Get created date
/// Rules:
/// - read-only
/// </summary>
public string Created {
get{
return mCreated.Text;
}
}
/// <summary>
/// Get modified date
/// Rules:
/// - read-only
/// </summary>
public string Modified {
get{
return mModified.Text;
}
}
/// <summary>
/// Get user record ID of person who created this record
/// Rules:
/// - read-only
/// </summary>
public Guid Creator {
get{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
/// Rules:
/// - read-only
/// </summary>
public Guid Modifier {
get{
return mModifier;
}
}
}//end Document
}//end namespace GZTW.AyaNova.BLL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastOpenVersion>7.10.3077</LastOpenVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>
</ReferencePath>
<CopyProjectDestinationFolder>
</CopyProjectDestinationFolder>
<CopyProjectUncPath>
</CopyProjectUncPath>
<CopyProjectOption>0</CopyProjectOption>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
<PublishUrlHistory />
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<EnableASPDebugging>false</EnableASPDebugging>
<EnableASPXDebugging>false</EnableASPXDebugging>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
<RemoteDebugEnabled>false</RemoteDebugEnabled>
<RemoteDebugMachine>
</RemoteDebugMachine>
<StartAction>Project</StartAction>
<StartArguments>
</StartArguments>
<StartPage>
</StartPage>
<StartProgram>
</StartProgram>
<StartURL>
</StartURL>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWithIE>true</StartWithIE>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<EnableASPDebugging>false</EnableASPDebugging>
<EnableASPXDebugging>false</EnableASPXDebugging>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
<RemoteDebugEnabled>false</RemoteDebugEnabled>
<RemoteDebugMachine>
</RemoteDebugMachine>
<StartAction>Project</StartAction>
<StartArguments>
</StartArguments>
<StartPage>
</StartPage>
<StartProgram>
</StartProgram>
<StartURL>
</StartURL>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWithIE>true</StartWithIE>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'RELEASE AND DEPLOY BUILD|AnyCPU' ">
<StartWithIE>true</StartWithIE>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,187 @@
///////////////////////////////////////////////////////////
// AddressFieldPickList.cs
// Implementation of Class AddressFieldPickList
// CSLA type: Read only collection
// Created on: 15-Dec-2008
// Object design: John
// Coded: 15-Dec-2008
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
//case 486
/// <summary>
/// List of distinct address fields previously entered
/// for autocomplete selection in address editing
///
/// </summary>
[Serializable]
public class AddressFieldPickList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct AddressFieldPickListInfo
{
internal string mName;
public string Name {get{return mName;}}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(AddressFieldPickListInfo obj)
{
return this.mName.Equals(obj.mName);
}
}//end AddressFieldPickListInfo
#endregion
#region Constructor
protected AddressFieldPickList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public AddressFieldPickListInfo this[int Item]
{
get
{
return (AddressFieldPickListInfo) List[Item];
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(AddressFieldPickListInfo obj)
{
foreach (AddressFieldPickListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
public static AddressFieldPickList GetList(AddressField fld)
{
return (AddressFieldPickList) DataPortal.Fetch(new Criteria(fld));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
switch (crit.fld)
{
case AddressField.City:
dr = DBUtil.GetReaderFromSQLString("SELECT DISTINCT ACITY AS AFLD FROM AADDRESS ORDER BY ACITY ASC");
break;
case AddressField.Country:
dr = DBUtil.GetReaderFromSQLString("SELECT DISTINCT ACOUNTRY AS AFLD FROM AADDRESS ORDER BY ACOUNTRY ASC");
break;
case AddressField.Postal:
dr = DBUtil.GetReaderFromSQLString("SELECT DISTINCT APOSTAL AS AFLD FROM AADDRESS ORDER BY APOSTAL ASC");
break;
case AddressField.State:
dr = DBUtil.GetReaderFromSQLString("SELECT DISTINCT ASTATEPROV AS AFLD FROM AADDRESS ORDER BY ASTATEPROV ASC");
break;
}
while(dr.Read())
{
//*******************************************
AddressFieldPickListInfo info=new AddressFieldPickListInfo();
info.mName=dr.GetString("AFLD");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public AddressField fld;
public Criteria(AddressField _fld )
{
fld = _fld;
}
}
#endregion
public enum AddressField
{
City, Postal, State, Country
}
}//end AddressFieldPickList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,34 @@
///////////////////////////////////////////////////////////
// AddressTypes.cs
// Implementation of Class AddressTypes
//
// Created on: 30-Jun-2004 12:37:00 PM
// Object design: John
// Coded: John 30-Jun-2004
///////////////////////////////////////////////////////////
using System;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Types of addresses used in AyaNova
/// </summary>
public enum AddressTypes : int
{
/// <summary>
/// Used as illegal default to ensure
/// that parent object sets this correctly
/// </summary>
Unset=0,
/// <summary>
/// Mailing Address
/// </summary>
Postal = 1,
/// <summary>
/// Physical street delivery address
/// </summary>
Physical = 2
}//end AddressTypes
}

View File

@@ -0,0 +1,693 @@
///////////////////////////////////////////////////////////
// AppointmentList.cs
// Implementation of Class AppointmentList
// CSLA type: Read only collection
// Created on: 06-Jan-2005
// Object design: John
// Coded: 06-Jan-2005
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Text.RegularExpressions;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// A list of appointments for scheduleable users in AyaNova
/// This list is what populates the schedule calendar
///
/// (Read only collection )
/// </summary>
[Serializable]
public class AppointmentList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct AppointmentListInfo
{
//used to indicate there is nothing in this
//struct
internal bool mIsEmpty;
internal Guid mWorkorderID;
internal Guid mWorkorderItemID;
internal int mServiceNumber;
internal RootObjectTypes mAppliesToObjectType;
internal Guid mAppliesToObjectID;
internal RootObjectTypes mSourceObjectType;
//This is the workorderitemscheduleduser record ID
internal Guid mSourceObjectID;
internal string mSubject;
internal string mDetails;
internal DateTime mStartDateTime;
internal DateTime mEndDateTime;
internal bool mAllDay;
//If
internal bool mShowPriorityFlag;
internal int mPriorityARGB;
internal int mBackColorARGB;
#pragma warning disable 1591
/// <summary>
/// true if there is nothing in this record
/// false if this record contains a valid appointment
/// </summary>
public bool IsEmpty {get{return mIsEmpty;}set{mIsEmpty=value;}}
/// <summary>
/// What object type this appointment applies to, can be single user
/// or another object type that represents a group of users
/// such as: region, sched user group etc etc
/// </summary>
public RootObjectTypes AppliesToObjectType{get{return mAppliesToObjectType;}}
/// <summary>
/// Object ID appointment applies to
/// </summary>
public Guid AppliesToObjectID{get{return mAppliesToObjectID;}}
/// <summary>
/// Type of appointment
/// either ScheduleMarker or WorkorderItemScheduledUser
/// </summary>
public RootObjectTypes SourceObjectType{get{return mSourceObjectType;}}
/// <summary>
/// The ID of the schedulemarker or workorderitemscheduleduser object
/// </summary>
public Guid SourceObjectID {get{return mSourceObjectID;}}
/// <summary>
/// ID of workorder if this appointment is a scheduled workorder user
/// </summary>
public Guid WorkorderID {get{return mWorkorderID;}}
/// <summary>
/// ID of workorder item if this appointment is a scheduled workorder user
/// </summary>
public Guid WorkorderItemID {get{return mWorkorderItemID;}}
/// <summary>
/// Visible sequential workorder number of workorder
/// if this appointment is a scheduled workorder user
/// </summary>
public int ServiceNumber {get{return mServiceNumber;}}
/// <summary>
/// Description of appointment, either a schedulemarker
/// description or a summary of the workorder
/// formatted according to the workorder
/// </summary>
public string Subject {get{return mSubject;}}
public string Details {get{return mDetails;}}
public DateTime StartDateTime {get{return mStartDateTime;}}
public DateTime EndDateTime {get{return mEndDateTime;}}
public bool AllDay {get{return mAllDay;}}
public int PriorityARGB {get{return mPriorityARGB;}}
public bool ShowPriorityFlag {get{return mShowPriorityFlag;}}
/// <summary>
/// Back color of appointment
/// could be workorder status or schedmarker colour
/// </summary>
public int BackColorARGB {get{return mBackColorARGB;} }
#pragma warning restore 1591
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(AppointmentListInfo obj)
{
return this.mSourceObjectID.Equals(obj.mSourceObjectID);
}
}//end AppointmentListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected AppointmentList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public AppointmentListInfo this[int Item]
{
get
{
return (AppointmentListInfo) List[Item];
}
}
/// <summary>
/// Returns AppointmentListInfo item that matches passed in itemid value
/// </summary>
/// <param name="o"></param>
public AppointmentListInfo this[Guid o]
{
get
{
foreach (AppointmentListInfo child in List)
{
if(child.mSourceObjectID==o) return child;
}
throw new ArgumentException("AppointmentList: SourceObjectID not found\r\n");
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(AppointmentListInfo obj)
{
foreach (AppointmentListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get list of <see cref="AppointmentListInfo"/> objects.
/// If UserID==Guid.Empty then all appointments for all
/// active scheduleable users are returned.
///
/// If UserID set to an Active *and* scheduleable specific user id then all workorders
/// for that specific user only are returned as well as
/// all <see cref="ScheduleMarker"/> for all users (since the UI has to
/// determine if they are applicable or not as some are not
/// for any specific user at all).
///
/// Closed work orders are *not* returned by default, use GetListWithClosed for that
/// behaviour.
///
/// </summary>
/// <param name="Start">Start date and time</param>
/// <param name="End">End date and time</param>
/// <param name="UserID">A <see cref="User"/> ID for a specific user's appointments
/// or Guid.Empty for all user's appointments</param>
/// <returns>A read only collection of <see cref="AppointmentListInfo"/> objects (ScheduleMarkers and WorkorderItemScheduledUser data)</returns>
public static AppointmentList GetList(DateTime Start, DateTime End, Guid UserID)
{
if (Start == DateTime.MinValue || End == DateTime.MinValue)
return new AppointmentList();
return (AppointmentList) DataPortal.Fetch(new Criteria(Start,End, UserID, false));
}
/// <summary>
/// Same as GetList, but includes closed work orders as well.
/// </summary>
/// <param name="Start"></param>
/// <param name="End"></param>
/// <param name="UserID"></param>
/// <returns></returns>
public static AppointmentList GetListWithClosed(DateTime Start, DateTime End, Guid UserID)
{
if (Start == DateTime.MinValue || End == DateTime.MinValue)
return new AppointmentList();
return (AppointmentList)DataPortal.Fetch(new Criteria(Start, End, UserID, true));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
string strTemplate="";
//case 1705
System.Collections.Generic.List<string> ListOfAppointmentSubjects = new System.Collections.Generic.List<string>();
//We set global settings during login, but
//a 3rd party user of this lib might not, so if the global object is not set then
//we'll retrieve it here, this provides some insurance
if(AyaBizUtils.GlobalSettings!=null)
strTemplate=AyaBizUtils.GlobalSettings.WorkorderSummaryTemplate;
else
strTemplate=Global.GetItem().WorkorderSummaryTemplate;
if(strTemplate==null || strTemplate=="")
{
strTemplate="WO#: [WorkorderService.Label.ServiceNumber]\r\n (You can customize the information displayed here\r\n in Global Settings workorder summary template)";
}
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
UserListScheduleable ulist=UserListScheduleable.GetList();
try
{
#region appointments
string q = "SELECT aWorkorderItemScheduledUser.aStartDate, aWorkorderItemScheduledUser.aStopDate, " +
" aWorkorderItemScheduledUser.aUserID, " +
" aWorkorderService.aServiceNumber, " +
" aWorkorderItem.aWorkorderID, aWorkorderItemScheduledUser.aWorkorderItemID, " +
" aWorkorderItem.aTechNotes, " +
" aWorkorderStatus.AARGB AS aStatusARGB, aWorkorderItem.aWorkorderStatusID, " +
" aWorkorderItem.aPriorityID, " +
" aPriority.AARGB AS aPriorityARGB, aWorkorderItemScheduledUser.aID " +
"AS aSCHEDITEMID, aClient.aName " +
"AS aCLIENTNAME, aWorkorder.aCustomerContactName, " +
" aWorkorder.aCustomerReferenceNumber, aWorkorder.aInternalReferenceNumber, aWorkorder.aOnsite, " +//case 987
" aProject.aName AS aPROJECTNAME, " +
" aWorkorder.aSummary AS aWORKORDERSUMMARY, " +
" aWorkorderCategory.aName AS aWORKORDERCATEGORYNAME, " +
" aWorkorderService.aInvoiceNumber, aWorkorderItem.aRequestDate, " +
" aWorkorderItem.aSummary AS aWORKORDERITEMSUMMARY, " +
" aUnit.aSerial, aUnitModel.aName " +
"AS aUNITMODELNAME, aUnitModelCategory.aName AS aUNITMODELCATEGORYNAME, " +
" aWorkorderStatus.aName AS aWORKORDERITEMSTATUSNAME, " +
" aDispatchZone.aName AS aDISPATCHZONENAME, " +
" aVendor.aName AS aUNITMODELVENDORNAME, " +
" aWorkorder.aWorkorderType FROM aWorkorderItemScheduledUser " +
"inner JOIN ( aWorkorder INNER JOIN aWorkorderService " +
"ON aWorkorder.aID = aWorkorderService.aWorkorderID " +
"INNER JOIN aWorkorderItem ON aWorkorder.aID " +
"= aWorkorderItem.aWorkorderID LEFT JOIN " +
"aUnit ON aWorkorderItem.aUnitID = aUnit.aID LEFT JOIN " +
"aUnitModel ON aUnit.aUnitModelID = aUnitModel.aID " +
"LEFT JOIN aVendor ON aUnitModel.aVendorID = aVendor.aID " +
"LEFT JOIN aUnitModelCategory ON aUnitModel.aUnitModelCategoryID " +
"= aUnitModelCategory.aID LEFT " +
"JOIN aWorkorderCategory ON aWorkorder.aWorkorderCategoryID " +
"= aWorkorderCategory.aID LEFT JOIN aProject " +
"ON aWorkorder.aProjectID = aProject.aID LEFT " +
"JOIN aClient ON aWorkorder.aClientID = aClient.aID " +
"LEFT JOIN aDispatchZone ON aClient.aDispatchZoneID " +
"= aDispatchZone.aID LEFT JOIN aPriority ON aWorkorderItem.aPriorityID " +
"= aPriority.aID LEFT JOIN " +
"aWorkorderStatus ON aWorkorderItem.aWorkorderStatusID " +
"= aWorkorderStatus.aID ) ON aWorkorderItem.aID " +
"= aWorkorderItemScheduledUser.aWorkorderItemID " +
"WHERE (aWorkorder.aWorkorderType=1) AND " +
"(NOT((aWorkorderItemScheduledUser.aStopDate < @StartDateTime) or (aWorkorderItemScheduledUser.aStartDate > @EndDateTime)))"; //case 1075
//"(aWorkorderItemScheduledUser.aStartDate > @StartDateTime) AND (aWorkorderItemScheduledUser.aStartDate < @EndDateTime) ";
if (crit.UserID != Guid.Empty)
q = q + "AND (aWorkorderItemScheduledUser.aUserID=@UserID) ";
//case 540
if (crit.IncludeClosed == false)
q = q + "AND (aWorkorder.aClosed=@False) ";
//Case 58
if (User.CurrentUserRegionID != Region.DefaultRegionID)
{
//wrong, what about clients in all regions?
// q = q + " AND (aClient.aRegionID = '{" + User.CurrentUserRegionID.ToString().ToUpperInvariant() + "}') ";
q = q + DBUtil.RegionAClientClause;//case 1117
}
DBCommandWrapper cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
//Add parameters
if (crit.UserID != Guid.Empty)
cm.AddInParameter("@UserID", DbType.Guid, crit.UserID);
if (crit.IncludeClosed == false)
cm.AddInParameter("@False", DbType.Boolean, false);
cm.AddInParameter("@StartDateTime", DbType.DateTime, DBUtil.ToUTC(crit.Start));
cm.AddInParameter("@EndDateTime", DbType.DateTime, DBUtil.ToUTC(crit.End));
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
//First result: Workorder item scheduled users
while (dr.Read())
{
//screen the user to make sure they are scheduleable and active
//If not, skip 'em
if(dr.GetGuid("aUserID")!=Guid.Empty)//is it a user?
{
if(!ulist.ContainsActiveUser(dr.GetGuid("aUserID")))
continue;
}
AppointmentListInfo info=new AppointmentListInfo();
info.mAllDay=false;
info.mIsEmpty=false;
info.mAppliesToObjectType=RootObjectTypes.User;
info.mAppliesToObjectID=dr.GetGuid("aUserID");
info.mSourceObjectType=RootObjectTypes.WorkorderItemScheduledUser;
info.mSourceObjectID=dr.GetGuid("aSCHEDITEMID");
info.mWorkorderID=dr.GetGuid("aWorkorderID");
info.mWorkorderItemID=dr.GetGuid("aWorkorderItemID");
info.mServiceNumber=dr.GetInt32("aServiceNumber");
//Not used currently, all data goes into subject
info.mDetails="";
//Copy template to subject
info.mSubject=strTemplate;
//case 1705
//need unique subject guaranteed for case 1705
string UniqueSubject = info.mSubject;
int n = 0;
while (ListOfAppointmentSubjects.Contains(UniqueSubject))
{
n++;
UniqueSubject = info.mSubject + " (" + n.ToString() + ")";
}
if (info.mSubject != UniqueSubject)
{
info.mSubject = UniqueSubject;
}
//Match all keywords and substitute queried data for them
MatchCollection matches=Regex.Matches(strTemplate,@"\[(.|\n)*?\]",RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled);
foreach(Match KeyMatch in matches)
{
switch(KeyMatch.Value)
{
case "[O.Client]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aCLIENTNAME"));
break;
case "[Workorder.Label.CustomerContactName]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aCustomerContactName"));
break;
case "[Workorder.Label.CustomerReferenceNumber]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aCustomerReferenceNumber"));
break;
case "[Workorder.Label.InternalReferenceNumber]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aInternalReferenceNumber"));
break;
//case 987
case "[Workorder.Label.Onsite]":
info.mSubject = info.mSubject.Replace(KeyMatch.Value, dr.GetBoolean("aOnsite").ToString());
break;
case "[O.Project]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aPROJECTNAME"));
break;
case "[Workorder.Label.Summary]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aWORKORDERSUMMARY"));
break;
case "[O.WorkorderCategory]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aWORKORDERCATEGORYNAME"));
break;
case "[WorkorderService.Label.InvoiceNumber]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aInvoiceNumber"));
break;
case "[WorkorderService.Label.ServiceNumber]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetInt32("aServiceNumber").ToString());
break;
case "[WorkorderItem.Label.RequestDate]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,DBUtil.ToLocal(dr.GetSmartDate("aRequestDate")).ToString());
break;
case "[WorkorderItem.Label.Summary]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aWORKORDERITEMSUMMARY"));
break;
case "[WorkorderItem.Label.TechNotes]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aTechNotes"));
break;
case "[O.Unit]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aSerial"));
break;
case "[O.UnitModel]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aUNITMODELNAME"));
break;
case "[O.UnitModelCategory]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aUNITMODELCATEGORYNAME"));
break;
case "[O.Vendor]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aUNITMODELVENDORNAME"));
break;
case "[O.WorkorderStatus]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aWORKORDERITEMSTATUSNAME"));
break;
case "[O.DispatchZone]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,dr.GetString("aDISPATCHZONENAME"));
break;
case "[WorkorderItemScheduledUser.Label.StartDate]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,DBUtil.ToLocal(dr.GetSmartDate("aStartDate")).ToString());
break;
case "[WorkorderItemScheduledUser.Label.StopDate]":
info.mSubject=info.mSubject.Replace(KeyMatch.Value,DBUtil.ToLocal(dr.GetSmartDate("aStopDate")).ToString());
break;
case "[O.WorkorderItemScheduledUser]":
if(dr.GetGuid("aUserID")!=Guid.Empty)
info.mSubject=info.mSubject.Replace(KeyMatch.Value,ulist[dr.GetGuid("aUserID")].Name(AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat));
else
info.mSubject=info.mSubject.Replace(KeyMatch.Value,"-?-");
break;
}
}
info.mEndDateTime=DBUtil.ToLocal(dr.GetDateTime("aStopDate"));
info.mStartDateTime=DBUtil.ToLocal(dr.GetDateTime("aStartDate"));
//Added:30-Oct-2006 for wbi infra schedule seems to ignore times exactly
//at midnight
//if (info.mEndDateTime.Hour == 12 && info.mEndDateTime.Minute == 0 && info.mEndDateTime.Second == 0)
// info.mEndDateTime.AddSeconds(-59);
//if (info.mStartDateTime.Hour == 0 && info.mStartDateTime.Minute == 0 && info.mStartDateTime.Second == 0)
// info.mStartDateTime.AddSeconds(59);
if(dr.GetGuid("aPriorityID")!=Guid.Empty)
{
info.mPriorityARGB=dr.GetInt32("aPriorityARGB");
info.mShowPriorityFlag=true;
}
else
{
info.mPriorityARGB=0;
info.mShowPriorityFlag=false;
}
//Workorder status color
info.mBackColorARGB=dr.GetInt32("aStatusARGB");
// info.mBold=dr.GetBoolean("aBold");
// info.mUnderline=dr.GetBoolean("aUnderline");
InnerList.Add(info);
}
if(dr!=null) dr.Close();
#endregion appointments
#region Schedule markers
//Not filtered by user if specific user is specified which is what we want
//next query
DBCommandWrapper cmSM = DBUtil.DB.GetSqlStringCommandWrapper(
"SELECT aScheduleMarkerSourceType, aSourceID,aID,aNotes,aName, " +
"aStopDate,aStartDate, AARGB FROM aScheduleMarker " +
"WHERE (NOT((aStopDate < @StartDateTime) or (aStartDate > @EndDateTime)))" //case 1075
//"WHERE aScheduleMarker.aStartDate BETWEEN @StartDateTime AND @EndDateTime"
);
//Add parameters
cmSM.AddInParameter("@StartDateTime",DbType.DateTime,DBUtil.ToUTC(crit.Start));
cmSM.AddInParameter("@EndDateTime",DbType.DateTime,DBUtil.ToUTC(crit.End));
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cmSM));
while (dr.Read())
{
AppointmentListInfo info=new AppointmentListInfo();
info.mAllDay=false;
info.mIsEmpty=false;
ScheduleMarkerSourceTypes smt=(ScheduleMarkerSourceTypes)dr.GetInt16("aScheduleMarkerSourceType");
info.mAppliesToObjectID = dr.GetGuid("aSourceID");
switch(smt)
{
case ScheduleMarkerSourceTypes.User:
info.mAppliesToObjectType=RootObjectTypes.User;
//screen the user to make sure they are scheduleable and active
//If not, skip 'em
if(dr.GetGuid("aSourceID")!=Guid.Empty &&
dr.GetGuid("aSourceID")!=ScheduleMarker.ScheduleMarkerGlobalSourceID)//is it a user?
{
if(!ulist.ContainsActiveUser(dr.GetGuid("aSourceID")))
continue;
}
break;
case ScheduleMarkerSourceTypes.Regional:
//Case 58
//If it applies to a specific region besides default and the current user is not default region and the applies to region id is not
//the current users then don't show it
if ((info.mAppliesToObjectID!=Region.DefaultRegionID) && (User.CurrentUserRegionID != Region.DefaultRegionID) && info.mAppliesToObjectID != User.CurrentUserRegionID)
continue;
info.mAppliesToObjectType=RootObjectTypes.Region;
break;
case ScheduleMarkerSourceTypes.Global:
info.mAppliesToObjectType=RootObjectTypes.Global;
break;
case ScheduleMarkerSourceTypes.DispatchZone:
info.mAppliesToObjectType=RootObjectTypes.DispatchZone;
break;
case ScheduleMarkerSourceTypes.ScheduleableUserGroup:
info.mAppliesToObjectType=RootObjectTypes.ScheduleableUserGroup;
break;
}
info.mSourceObjectType=RootObjectTypes.ScheduleMarker;
info.mSourceObjectID=dr.GetGuid("aID");
info.mDetails=dr.GetString("aNotes");
info.mSubject=dr.GetString("aName");
info.mEndDateTime=DBUtil.ToLocal(dr.GetDateTime("aStopDate"));
info.mStartDateTime=DBUtil.ToLocal(dr.GetDateTime("aStartDate"));
//priority doesn't apply here, but don't
//leave it dangling
info.mShowPriorityFlag=false;
info.mPriorityARGB=0;
info.mBackColorARGB=dr.GetInt32("AARGB");
InnerList.Add(info);
}
#endregion schedulemarkers
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public DateTime Start;
public DateTime End;
public Guid UserID;
public bool IncludeClosed;//Added case 540
public Criteria(DateTime _Start, DateTime _End, Guid _UserID, bool _IncludeClosed)
{
Start = _Start;
End = _End;
UserID = _UserID;
IncludeClosed = _IncludeClosed;
}
}
#endregion
}//end AppointmentList
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,624 @@
///////////////////////////////////////////////////////////
// AssignedDoc.cs
// Implementation of Class AssignedDoc
// CSLA type: Editable Child
// Created on: 07-Jun-2004 8:41:13 AM
// Object design: Joyce
// Coded: John July 9 2004
// Re-coded: as editable child by John Nov 11 2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// AssignedDoc class
/// This is the original method of attaching documents to various objects in AyaNova and is used to link a file location on disk to a business object.
/// If you want to actually store the document itself in the AyaNova database (making it accessible from WBI and location independant)
/// you should use the <see cref="WikiPage"/> object instead to store documents in the database.
///
/// </summary>
[Serializable]
public class AssignedDoc : BusinessBase {
#region Attributes
private bool bReadOnly;
private Guid mID;
private Guid mRootObjectID;
private RootObjectTypes mRootObjectType;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
private string mDescription="";
private string mURL=null;
//case 1584
private RootObjectTypes mExactObjectType;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private AssignedDoc()
{
MarkAsChild();
//Set to read / write initially so that properties
//can be set
bReadOnly=false;
mID=Guid.NewGuid();
//pre-break the rule
this.URL="";
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified=new SmartDate();
mCreator=User.CurrentThreadUserID;
mModifier=User.CurrentThreadUserID;
//case 1584
mExactObjectType = RootObjectTypes.Nothing;
}
#endregion
#region Business properties
/// <summary>
/// ID of assigneddoc entry
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// RootObject Type
/// </summary>
public RootObjectTypes RootObjectType
{
get
{
return mRootObjectType;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mRootObjectType!=value)
{
mRootObjectType = value;
MarkDirty();
}
}
}
}
/// <summary>
/// RootObjectID
/// </summary>
public Guid RootObjectID
{
get
{
return mRootObjectID;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mRootObjectID!=value)
{
mRootObjectID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// AssignedDocs associated with any workorder type are saved attributed to rootobject type Workorder.
/// Since version 7 that has been deprecated but to maintain backward compatibility wikipages are still
/// associated with Workorder.
///
/// This properly shows the actual exact workorder type that retrieved this assigneddoc object.
///
/// It is not stored in the database but used on the fly internally by AyaNova to check exact rights.
/// </summary>
public RootObjectTypes ExactRootObjectType //case 1584
{
get
{
return mExactObjectType;
}
set
{
mExactObjectType = value;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// Set/get Description of item
///
/// </summary>
public string Description
{
get
{
return mDescription;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mDescription!=value)
{
mDescription = value;
BrokenRules.Assert("DescriptionLength",
"Error.Object.FieldLengthExceeded255,AssignedDoc.Label.Description","Description",value.Length>255);
MarkDirty();
}
}
}
}
/// <summary>
///URL for document
///This could be an internet URL, a UNC path and file name or a
///drive letter path filename to the file in question
///
///Basically this is anything that is understood by the Windows Shell
///Maximum of 4000 characters
/// </summary>
public string URL
{
get
{
return mURL;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mURL!=value)
{
mURL = value;
BrokenRules.Assert("URLRequired",
"Error.Object.RequiredFieldEmpty,AssignedDoc.Label.URL","URL",value.Length==0);
BrokenRules.Assert("URLLength",
"Error.Object.FieldLengthExceeded,AssignedDoc.Label.URL,3500","URL",value.Length>3500);
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.AssignedDoc")
)
);
}
#endregion
#region System.Object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "AssignedDoc"+ mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
AssignedDoc c=(AssignedDoc)obj;
return (mID==c.mID);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("AssignedDoc"+ mID.ToString()).GetHashCode();
}
#endregion
#region Searching
/// <summary>
/// Returns a search result object based on search terms
/// for the ID specified
/// </summary>
/// <param name="ID"></param>
/// <param name="searchTerms"></param>
/// <returns></returns>
public static SearchResult GetSearchResult(Guid ID, string[]searchTerms)
{
SearchResult sr=new SearchResult();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString(
"SELECT aCreated, aModified, aCreator, aModifier, aRootObjectID, " +
"aRootObjectType, aURL, aDescription FROM AASSIGNEDDOC " +
"WHERE (aID = @ID)",ID);
if(!dr.Read())
return new SearchResult();//DBUtil.ThrowFetchError("SearchResult for AssignedDoc: " + ID.ToString());
//Get description for later adding to description string
sr.Description=dr.GetString("aDescription");
sb.Append(dr.GetString("aURL"));
sb.Append(" ");
sb.Append(sr.Description);
sr.AncestorRootObjectID=dr.GetGuid("aRootObjectID");
sr.AncestorRootObjectType=(RootObjectTypes)dr.GetInt16("aRootObjectType");
sr.Created=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
sr.Modified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
sr.Creator=dr.GetGuid("aCreator");
sr.Modifier=dr.GetGuid("aModifier");
}
finally
{
if(dr!=null) dr.Close();
}
//Case 58
//Is the document's ancestor within their region?
if (
!AyaBizUtils.InYourRegion(
ObjectRegionIDFetcher.ObjectRegion(
new TypeAndID(
sr.AncestorRootObjectType,sr.AncestorRootObjectID
)
)
)
) return new SearchResult();//case 58
//Security check..do they have rights to the ancestor object?
if(AyaBizUtils.Right("Object." + sr.AncestorRootObjectType.ToString())<(int)SecurityLevelTypes.ReadOnly)
return new SearchResult();
//Formulate results
ExtractAndRank er = new ExtractAndRank();
er.Process(sb.ToString().Trim(),searchTerms);
sr.Extract=er.Extract;
sr.Rank=er.Ranking;
return sr;
}
#endregion
#region Static methods
/// <summary>
/// Get new object
/// Parent is responsible for RootObjectID, RootObjectType and DocumentID
/// </summary>
/// <returns></returns>
internal static AssignedDoc NewItem(RootObjectTypes ObjectType, RootObjectTypes ExactObjectType) //case 1584
{
if(AyaBizUtils.Right(ExactObjectType)>(int)SecurityLevelTypes.ReadOnly)
return new AssignedDoc();
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("O.AssignedDoc")));
}
internal static AssignedDoc GetItem(SafeDataReader dr, RootObjectTypes ObjectType, RootObjectTypes ExactObjectType) //case 1584
{
if (AyaBizUtils.Right(ExactObjectType) > (int)SecurityLevelTypes.NoAccess)
{
AssignedDoc child = new AssignedDoc();
child.Fetch(dr,ExactObjectType);
return child;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("O.AssignedDoc")));
}
#endregion
#region DAL Data access
/// <summary>
/// Populate this object from the values in the datareader passed to it
/// </summary>
/// <param name="dr"></param>
/// <param name="ExactObjectType"></param>
private void Fetch(SafeDataReader dr, RootObjectTypes ExactObjectType)
{
//Standard fields
mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator=dr.GetGuid("aCreator");
mModifier=dr.GetGuid("aModifier");
//AssignedDoc fields
mID=dr.GetGuid("aID");
mRootObjectID=dr.GetGuid("aRootObjectID");
mRootObjectType=(RootObjectTypes)dr.GetInt16("aRootObjectType");
mExactObjectType = ExactObjectType;//case 1584
mDescription=dr.GetString("aDescription");
URL=dr.GetString("aURL");
//Get access rights level
bReadOnly=AyaBizUtils.Right(ExactObjectType)<(int)SecurityLevelTypes.ReadWrite;//case 1584
MarkOld();
}
/// <summary>
///
/// </summary>
/// <param name="tr"></param>
internal void Update(IDbTransaction tr)
{
//No need to update if there is nothing changed
if(!this.IsDirty) return;
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
// If not a new record, check if record was modified
//by another user since original retrieval:
if(!IsNew)
DBUtil.CheckSafeToUpdateInsideTransaction(this.mModified.Date, this.mID, "AASSIGNEDDOC", tr);//case 1960
#region Delete
if(IsDeleted)
{
if(!IsNew)
{
//Delete user and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM AASSIGNEDDOC WHERE aID = @ID;");
cmDelete.AddInParameter("@ID",DbType.Guid,this.mID);
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
DBUtil.RemoveKeywords(tr,RootObjectTypes.AssignedDocument,this.ID);
}
MarkNew();
return;
}
#endregion
#region Add / Update
DBCommandWrapper cm = null;
if(IsNew)//Add or update?
cm=DBUtil.GetCommandFromSQL(
"INSERT INTO AASSIGNEDDOC (aRootObjectID,aRootObjectType, aID, aURL, aDescription, aCreated,aModified,aCreator,aModifier) " +
"VALUES (@RootObjectID,@RootObjectType, @ID, @URL,@Description, @Created, @Modified, @CurrentUserID,@CurrentUserID)"
);
else
cm=DBUtil.GetCommandFromSQL(
"UPDATE AASSIGNEDDOC SET aRootObjectID=@RootObjectID, " +
"aRootObjectType=@RootObjectType, aID=@ID, aURL=@URL, " +
"aDescription=@Description,aModified=@Modified, aModifier=@CurrentUserID " +
"WHERE aID=@ID"
);
cm.AddInParameter("@ID",DbType.Guid,mID);
cm.AddInParameter("@RootObjectID",DbType.Guid, mRootObjectID);
cm.AddInParameter("@RootObjectType",DbType.Int16, mRootObjectType);
cm.AddInParameter("@Description",DbType.String, mDescription);
cm.AddInParameter("@URL",DbType.String, mURL);
cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified));
DBUtil.DB.ExecuteNonQuery(cm, tr);
//Process keywords
DBUtil.ProcessKeywords(tr,this.mID,RootObjectTypes.AssignedDocument,IsNew,AyaBizUtils.Break(false,mDescription,mURL));
MarkOld();//db is now synched with object
//Successful update so
//change modification time to match
this.mModified.Date=dtModified;
#endregion
}
#endregion
#region Override IsValid / IsDirty
//Override base class version if there are child objects
/*
public override bool IsValid
{
get
{
return base.IsValid && ChildItem.IsValid;
}
}
public override bool IsDirty
{
get
{
return base.IsDirty || ChildItem.IsDirty;
}
}
*/
#endregion
#region criteria
// /// <summary>
// /// Criteria for identifying existing object
// /// </summary>
// [Serializable]
// private class Criteria
// {
// public Guid RootObjectID;
// public Guid DocumentID;
// public RootObjectTypes RootObjectType;
// public Criteria(Guid _RootObjectID, Guid _DocumentID, RootObjectTypes _RootObjectType )
// {
// RootObjectID=_RootObjectID;
// DocumentID=_DocumentID;
// RootObjectType=_RootObjectType;
//
// }
//
// }
#endregion
}//end AssignedDoc
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,245 @@
///////////////////////////////////////////////////////////
// AssignedDocs.cs
// Implementation of Class AssignedDocs
// CSLA type: Editable child collection
// Created on: 15-April-2005
// Object design: John
// Coded: John 15-April-2005
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Collection of <see cref="AssignedDoc"/> items
/// </summary>
[Serializable]
public class AssignedDocs : BusinessCollectionBase
{
#region Constructor
//Private constructor prevents direction instantiation
private AssignedDocs()
{
//Child
MarkAsChild();
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
/// <summary>
/// Retrieve AssignedDoc by index
/// </summary>
/// <param name="Item">Index</param>
public AssignedDoc this[int Item]
{
get
{
return (AssignedDoc) List[Item];
}
}
/// <summary>
/// Retrieve AssignedDoc by string containing Guid value
/// </summary>
public AssignedDoc this[string AssignedDocID]
{
get
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in List)
{
if(child.ID==sid)
return child;
}
return null;
}
}
/// <summary>
/// Remove AssignedDoc by passing it in
/// </summary>
/// <param name="obj"></param>
public void Remove(AssignedDoc obj)
{
List.Remove(obj);
}
/// <summary>
/// Remove AssignedDoc by string of id value
/// </summary>
/// <param name="AssignedDocID"></param>
public void Remove(string AssignedDocID)
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in List)
{
if(child.ID==sid)
List.Remove(child);
}
}
/// <summary>
/// Remove by Guid value of ID
/// </summary>
/// <param name="AssignedDocID"></param>
public void Remove(Guid AssignedDocID)
{
foreach (AssignedDoc child in List)
{
if(child.ID==AssignedDocID)
List.Remove(child);
}
}
/// <summary>
/// Add a new AssignedDoc to the collection
/// </summary>
/// <param name="type"></param>
/// <param name="ID"></param>
/// <param name="ExactObjectType"></param>
public AssignedDoc Add(RootObjectTypes type, Guid ID, RootObjectTypes ExactObjectType) //case 1584
{
AssignedDoc child=AssignedDoc.NewItem(type, ExactObjectType);
child.RootObjectID=ID;
child.RootObjectType=type;
List.Add(child);
return child;
}
#endregion
#region Contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(AssignedDoc obj)
{
foreach (AssignedDoc child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in collection by string of ID value
/// </summary>
/// <param name="AssignedDocID"></param>
public bool Contains(string AssignedDocID)
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in List)
{
if(child.ID==sid) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection
/// </summary>
/// <param name="obj"></param>
public bool ContainsDeleted(AssignedDoc obj)
{
foreach (AssignedDoc child in deletedList)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection by string of ID value
/// </summary>
/// <param name="AssignedDocID"></param>
public bool ContainsDeleted(string AssignedDocID)
{
System.Guid sid = new System.Guid(AssignedDocID);
foreach (AssignedDoc child in deletedList)
{
if(child.ID==sid) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// NewItems
/// </summary>
/// <returns></returns>
internal static AssignedDocs NewItems()
{
return new AssignedDocs();
}
/// <summary>
/// GetItems
/// </summary>
internal static AssignedDocs GetItems(SafeDataReader dr, RootObjectTypes type, RootObjectTypes ExactObjectType)//case 1584
{
AssignedDocs col = new AssignedDocs();
col.Fetch(dr, type, ExactObjectType);
return col;
}
#endregion
#region DAL DATA ACCESS
/// <summary>
/// Fetch children
/// </summary>
private void Fetch(SafeDataReader dr, RootObjectTypes type, RootObjectTypes ExactObjectType)//case 1584
{
while(dr.Read())
{
List.Add(AssignedDoc.GetItem(dr,type, ExactObjectType));
}
}
/// <summary>
/// Update children
/// </summary>
/// <param name="tr"></param>
internal void Update(IDbTransaction tr)
{
//update (thus deleting) any deleted child objects
foreach (AssignedDoc child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (AssignedDoc child in List)
{
child.Update(tr);
}
}
#endregion
}//end Tasks
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,206 @@
using System;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
///// <summary>
/////Custom attribute used to indicate the underlying
/////sql column name for a business object property.
/////
/////Used internally for sorting and filtering in grids.
/////
/////A value of "grid" indicates that the grid should
/////handle sorting for grid columns that are calculated
/////and not provided directly from the data
///// </summary>
//[AttributeUsage(AttributeTargets.Property)]
//public class SqlColumnNameAttribute:Attribute
//{
// private string _SqlColumnName;
// public SqlColumnNameAttribute(string sqlColumnName)
// {
// _SqlColumnName = sqlColumnName;
// }
// public string SqlColumnName
// {
// get
// {
// return _SqlColumnName;
// }
// }
//}
/// <summary>
///Custom attribute used to indicate the underlying
///sql column name for a business object property.
///
///Used internally for sorting and filtering in grids.
///
///A value of "grid" indicates that the grid should
///handle sorting for grid columns that are calculated
///and not provided directly from the data
///
/// SqlColumnName represents the "display" or text based column
/// SqlValueColumnName represents the underlying value column
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class SqlColumnNameAttribute : Attribute
{
private string _SqlColumnName;
private string _SqlValueColumnName;
public SqlColumnNameAttribute(string sqlColumnName)
{
_SqlColumnName = sqlColumnName;
_SqlValueColumnName = "";
}
public SqlColumnNameAttribute(string sqlColumnName, string sqlValueColumnName)
{
_SqlColumnName = sqlColumnName;
_SqlValueColumnName = sqlValueColumnName;
}
public string SqlColumnName
{
get
{
return _SqlColumnName;
}
}
public string SqlValueColumnName
{
get
{
return _SqlValueColumnName;
}
}
}
/// <summary>
/// DisplayAttribute, used to provide more detailed information to
/// the ui layer about properties in a business object collection
/// in order to simplify display process through reflection
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple=false)]
public class DisplayAttribute : Attribute
{
public DisplayAttribute(DisplayType DisplayAsControl)
{
displayAs = DisplayAsControl;
}
private DisplayType displayAs = DisplayType.Text;
public DisplayType DisplayAs
{
get { return displayAs; }
}
private bool color=false;
public bool Color
{
get { return color; }
set { color = value; }
}
private string colorField="";
public string ColorField
{
get { return colorField; }
set { colorField = value; }
}
private RootObjectTypes rootObjectType=RootObjectTypes.Nothing;
public RootObjectTypes RootObjectType
{
get { return rootObjectType; }
set { rootObjectType = value; }
}
private CompareType compareAs = CompareType.Default;
public CompareType CompareAs
{
get { return compareAs; }
set { compareAs = value; }
}
private bool showInLite = true;
public bool ShowInLite
{
get { return showInLite; }
set { showInLite = value; }
}
}
public enum CompareType : int
{
Default=0,
StringToDate=1,
StringToInt32=2
}
public enum DisplayType : int
{
Hidden = 0,
DateTime = 1,
DateOnly = 2,
TimeOnly = 3,
Text = 4,
WholeNumber = 5,
TrueFalse = 6,
Currency = 7,
URL_Email = 8,
Button = 9,
GeoCoordinate = 10,
DecimalNumber=11,
Percentage=12,
URL_Web =13,
URL_Document=14,
ListAyaDayOfWeek=15,
ListAyaUnitsOfTime=16,
ListPurchaseOrderStatus=17,
ListVendorTypes=18,
ListUsers = 19,
ListUserTypes = 20,
MultiLineText = 21,
ListClientServiceRequestStatus=22,
ListClientServiceRequestPriority=23,
ListQuoteStatusTypes=24,//Case 353
ListLoanItemRates=25,//Case 420
SpecialControl = 99//A special control field is handled by the form based on the exact circumstance, i.e. the replied checkbox on a memo form
}
#pragma warning restore 1591
}

View File

@@ -0,0 +1,366 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using CSLA;
using System.IO;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// AyaNova captures and stores signatures as vector data,
/// this class is used to parse the captured signature data
/// for various admin info stored with it as well as generate
/// an image for use in reporting or displaying in UI.
/// </summary>
[Serializable]
public class AySignature
{
private string mSignatureCode = "";
/// <summary>
/// Raw signature code stored by client software as captured
/// </summary>
public string SignatureCode {
get
{
return mSignatureCode;
}
set
{
if (mSignatureCode != value)
{
mSignatureCode = value;
Parse();
}
}
}
/// <summary>
/// Signature polyline stroke line paths in x,y coordinate pairs.
/// </summary>
public string StrokePath { get; set; }
/// <summary>
/// Width of signature pade area in pixels
/// Defined because different devices may require different
/// sized signature areas
/// </summary>
public int Width { get; set; }
/// <summary>
/// Height of signature pade area in pixels
/// Defined because different devices may require different
/// sized signature areas
/// </summary>
public int Height { get; set; }
/// <summary>
/// Date time at client device at moment captured signature was started drawing by end user
/// </summary>
public DateTime ClientCapturedDateTime { get; set; }
/// <summary>
/// Date time at server at moment captured signature was saved
/// </summary>
public SmartDate HostCapturedDateTime { get; set; }
/// <summary>
/// Version of signature code schema in case new features or SignatureCode changes are required in future and
/// </summary>
public string Version { get; set; }
/// <summary>
/// Strokepath is not empty and contains at least two sets of points
/// </summary>
public bool HasSignature
{
get
{
if (string.IsNullOrWhiteSpace(StrokePath)) return false;
int nOccurs = AyaBizUtils.StringOccurrences(StrokePath, ",");
return (nOccurs > 1);
}
}
/// <summary>
/// Strokepath is not empty
/// (This is obviously not definitive, but a strong indication the user drew more than a dot or a short line,
/// Of course nothing can certify it's a valid legal signature other than a signature expert or witnesses. :) )
/// </summary>
public bool IsALikelySignature
{
get
{
if (string.IsNullOrWhiteSpace(StrokePath)) return false;
int nOccurs = AyaBizUtils.StringOccurrences(StrokePath, ",");
return (nOccurs > 1);
}
}
Bitmap bmSig = null;
/// <summary>
/// Converts strokepath to bitmap object
/// same size as signature box used to sign
/// in first place.
/// </summary>
public Bitmap SignatureBitmap
{
get
{
//case 1704
if (bmSig == null && HasSignature)
GenerateBitmap();
return bmSig;
}
}
/// <summary>
/// SignatureBitmap converted to byte array which is
/// a more friendly format for some uses
/// </summary>
public byte[] SignatureBitmapAsByteArray
{
get
{
//case 1704
if (!HasSignature) return null;
MemoryStream ms = new MemoryStream();
SignatureBitmap.Save(ms, ImageFormat.Bmp);
return ms.ToArray();
}
}
/// <summary>
/// Constructor takes the signature code
/// containing the dimensions, client datetime captured,
/// version and signature poly line strokes
/// and parses it out.
/// </summary>
/// <param name="signatureCode"></param>
public AySignature(string signatureCode)
{
Clear();
SignatureCode = signatureCode;
if(SignatureCode!=null && !string.IsNullOrWhiteSpace(SignatureCode))
Parse();
}
/// <summary>
/// Constructor
/// </summary>
public AySignature()
{
Clear();
}
/// <summary>
/// Reset signature object to empty
/// </summary>
public void Clear()
{
//defaults in case signature blank as it often will be for most people
SignatureCode = "";
Version = "1";
Width = 300;
Height = 100;
ClientCapturedDateTime = DateTime.MinValue;
StrokePath = "";
HostCapturedDateTime = new SmartDate();
//case 1626
if (bmSig != null)
{
bmSig.Dispose();
bmSig = null;
}
}
private void Parse()
{
Parse2();
return;
//Match m = AyaBizUtils.rxSignatureParser.Match(SignatureCode);
//if (m.Groups.Count < 10) return;
//Version = m.Groups["version"].Value;
//Height = int.Parse(m.Groups["height"].Value);
//Width = int.Parse(m.Groups["width"].Value);
//ClientCapturedDateTime = new DateTime(
// int.Parse(m.Groups["year"].Value),
// int.Parse(m.Groups["month"].Value),
// int.Parse(m.Groups["day"].Value),
// int.Parse(m.Groups["hour"].Value),
// int.Parse(m.Groups["minute"].Value),
// int.Parse(m.Groups["second"].Value)
// );
//StrokePath = m.Groups["strokes"].Value.TrimStart('X').Trim();
////case 1978
//StrokePath = StrokePath.Replace("NaN", "0");
}
//case
private void Parse2()
{
if (String.IsNullOrWhiteSpace(SignatureCode)) return;
Version = "1";//it's always 1
int nWidthStart = SignatureCode.LastIndexOf("width=");
int nHeightStart = SignatureCode.LastIndexOf("height=");
int nCapturedStart = SignatureCode.LastIndexOf("captured=");
int nCloseBracketStart = SignatureCode.LastIndexOf("}");
string sWidthValue = SignatureCode.Substring(nWidthStart + 6, nHeightStart - (nWidthStart + 6));
string sHeightValue = SignatureCode.Substring(nHeightStart + 7, nCapturedStart - (nHeightStart + 7));
string sCapturedValue = SignatureCode.Substring(nCapturedStart + 9, nCloseBracketStart - (nCapturedStart + 9));
string sStrokes = SignatureCode.Substring(nCloseBracketStart + 1).TrimStart('X').Trim().Replace("NaN", "0");
//in case there are commas in the decimal separator
sHeightValue=sHeightValue.Replace(',', '.');
sWidthValue = sWidthValue.Replace(',', '.');
Height = ParseInt(sHeightValue);
Width = ParseInt(sWidthValue);
StrokePath = sStrokes;
string[] cap = sCapturedValue.Split(':');
ClientCapturedDateTime = new DateTime(
int.Parse(cap[0]),//year
int.Parse(cap[1]),//month
int.Parse(cap[2]),//day
int.Parse(cap[3]),//hr
int.Parse(cap[4]),//min
int.Parse(cap[5])//sec
);
//{version=1 width=300.4 height=100.4 captured=2017:2:1:12:27:37}X 62,43 62,45 62,46 63,47 64,49 66,50 66,50 68,50 70,51 75,51 83,51 95,49 110,43 144,26 151,22 156,19 158,18 160,17 160,18 160,22 160,29 162,34 162,39 163,43 166,47 167,51 168,53 171,54 174,57 176,57 179,58 183,59 188,59 194,59 202,59 207,58 214,58 218,58 220,58 222,58 223,59 226,59 232,58 240,57 246,53 252,49 258,45 260,41 262,37 263,37 263,35 263,37 263,38 263,39 263,41 263,42 263,43 263,45 263,45
}
private int ParseInt(string s, bool alwaysRoundDown = false)
{
//converts null/empty strings to zero
if (string.IsNullOrEmpty(s)) return 0;
if (!s.Contains(".")) return int.Parse(s);
string[] parts = s.Split('.');
int i = int.Parse(parts[0]);
if (alwaysRoundDown || parts.Length == 1) return i;
String afterPoint = parts[1];
if (afterPoint.Length > 1)
afterPoint = afterPoint.Substring(0, 1);
int digitAfterPoint = int.Parse(afterPoint);
return (digitAfterPoint < 5) ? i : i + 1;
}
/// <summary>
/// convert stroke path to bitmap
/// </summary>
private void GenerateBitmap()
{
//case 1704
if (!HasSignature) return;
bmSig = new Bitmap(Width, Height);
Graphics g = Graphics.FromImage(bmSig);
//Make the bitmap all white before drawing the signature on it
Brush bWhite = new SolidBrush(Color.White);
g.FillRectangle(bWhite, 0, 0, Width, Height);
//Pen for drawing sample
Pen penDraw = new Pen(Color.Black, 3);
// GraphicsPath pth = new GraphicsPath();
List<Point> lPoints = new List<Point>();
string[] sLines = StrokePath.Split('X');
foreach (string sLine in sLines)
{
string[] sPoints = sLine.Trim().Split(' ');
if (sPoints.Length > 0)
{
lPoints.Clear();
GraphicsPath pth = new GraphicsPath();
foreach (string s in sPoints)
{
lPoints.Add(StringToPoint(s));
}
pth.AddLines(lPoints.ToArray());
g.DrawPath(penDraw, pth);
pth.Dispose();
pth = null;
}
}
if (g != null)
g.Dispose();
}
private static Point StringToPoint(string s)
{
if (string.IsNullOrWhiteSpace(s))
return new Point(0, 0);
if (!s.Contains(','))
return new Point(0, 0);
string[] spoint = s.Split(',');
//case 1939 - can't treat the input in the parse as integers as they can apparently contain decimals now
//I suspect that the conversion with decimal is likely slower than checking to see if it has a decimal first so
//I'm breaking this out into two separate streams for performance
if (s.Contains('.'))
{
// if it contains a decimal then convert differently
return new Point(
Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[0]))),
Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[1])))
);
}
else
{
//if it doesn't contain a decimal then use the original method
//case 1978 wrap this in a try catch block due to one customer having NaN values
//in their signature stroke path string.
try
{
return new Point(int.Parse(spoint[0]), int.Parse(spoint[1]));
}
catch (System.FormatException )
{
return new Point(0, 0);
}
}
}
}//End of class
}//End of namespace

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////
// AyaDayOfWeek.cs
// Implementation of Class AyaDayOfWeek
// CSLA type: enumeration
// Created on: 07-Jun-2004 8:41:23 AM
// Object design: Joyce
// Coded: John July 19 2004
///////////////////////////////////////////////////////////
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
[TypeConverter(typeof(EnumDescConverter))]
public enum AyaDayOfWeek : int {
[Description("LT:UI.Label.Day.Saturday")]
Saturday = 1,
[Description("LT:UI.Label.Day.Sunday")]
Sunday = 2,
[Description("LT:UI.Label.Day.Monday")]
Monday = 3,
[Description("LT:UI.Label.Day.Tuesday")]
Tuesday = 4,
[Description("LT:UI.Label.Day.Wednesday")]
Wednesday = 5,
[Description("LT:UI.Label.Day.Thursday")]
Thursday = 6,
[Description("LT:UI.Label.Day.Friday")]
Friday = 7,
[Description("LT:UI.Label.Day.Any")]
AnyDayOfWeek = 8
}//end AyaDayOfWeek
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,196 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// This class converts localized text keys used to display
/// enum values in AyaNova UI to integer enum values
/// suitable for using in queries in database
///
/// This is required because the Infragistics grid component
/// only gives us the text selected in a filter based on an enum value
/// not the underlying enum or it's value
///
/// This method is used in conjunction with the GetLocalizedTextKey method
/// in the LocalizedTextTable object by the UI (due to caching)
/// </summary>
public sealed class AyaEnumConverter
{
/// <summary>
/// Convert localized text key to enum value
/// </summary>
/// <param name="LocalizedTextKey">key of enum value </param>
/// <returns>Int of enum or -1 on fail to match</returns>
public static int Convert(string LocalizedTextKey)
{
switch (LocalizedTextKey)
{
//Purchase order status
case "PurchaseOrder.Label.PurchaseOrderStatus.ClosedFullReceived":
return (int)PurchaseOrderStatus.ClosedFullReceived;
case "PurchaseOrder.Label.PurchaseOrderStatus.ClosedNoneReceived":
return (int)PurchaseOrderStatus.ClosedNoneReceived;
case "PurchaseOrder.Label.PurchaseOrderStatus.ClosedPartialReceived":
return (int)PurchaseOrderStatus.ClosedPartialReceived;
case "PurchaseOrder.Label.PurchaseOrderStatus.OpenNotYetOrdered":
return (int)PurchaseOrderStatus.OpenNotYetOrdered;
case "PurchaseOrder.Label.PurchaseOrderStatus.OpenOrdered":
return (int)PurchaseOrderStatus.OpenOrdered;
case "PurchaseOrder.Label.PurchaseOrderStatus.OpenPartialReceived":
return (int)PurchaseOrderStatus.OpenPartialReceived;
//AyaDayOfWeek
case "UI.Label.Day.Any":
return (int)AyaDayOfWeek.AnyDayOfWeek;
case "UI.Label.Day.Monday":
return (int)AyaDayOfWeek.Monday;
case "UI.Label.Day.Tuesday":
return (int)AyaDayOfWeek.Tuesday;
case "UI.Label.Day.Wednesday":
return (int)AyaDayOfWeek.Wednesday;
case "UI.Label.Day.Thursday":
return (int)AyaDayOfWeek.Thursday;
case "UI.Label.Day.Friday":
return (int)AyaDayOfWeek.Friday;
case "UI.Label.Day.Saturday":
return (int)AyaDayOfWeek.Saturday;
case "UI.Label.Day.Sunday":
return (int)AyaDayOfWeek.Sunday;
//AyaUnitsOfTime
case "UI.Label.TimeSpan.Minutes":
return (int)AyaUnitsOfTime.Minutes;
case "UI.Label.TimeSpan.Hours":
return (int)AyaUnitsOfTime.Hours;
case "UI.Label.TimeSpan.Days":
return (int)AyaUnitsOfTime.Days;
case "UI.Label.TimeSpan.Months":
return (int)AyaUnitsOfTime.Months;
case "UI.Label.TimeSpan.Years":
return (int)AyaUnitsOfTime.Years;
//Vendortypes
case "Vendor.Label.VendorType.Manufacturer":
case "Part.Label.ManufacturerID":
return (int)VendorTypes.Manufacturer;
case "Vendor.Label.VendorType.Shipper":
return (int)VendorTypes.Shipper;
case "Vendor.Label.VendorType.SubContractor":
return (int)VendorTypes.SubContractor;
case "Vendor.Label.VendorType.ThirdPartyRepair":
return (int)VendorTypes.ThirdPartyRepair;
case "Vendor.Label.VendorType.Wholesaler":
return (int)VendorTypes.Wholesaler;
//Added: 10-Nov-2006: Client service request stuff
case "ClientServiceRequestStatus.Accepted":
return (int)ClientServiceRequestStatus.Accepted;
case "ClientServiceRequestStatus.Declined":
return (int)ClientServiceRequestStatus.Declined;
case "ClientServiceRequestStatus.Open":
return (int)ClientServiceRequestStatus.Open;
case "ClientServiceRequestStatus.Closed":
return (int)ClientServiceRequestStatus.Closed;
case "ClientServiceRequestPriority.ASAP":
return (int)ClientServiceRequestPriority.ASAP;
case "ClientServiceRequestPriority.Emergency":
return (int)ClientServiceRequestPriority.Emergency;
case "ClientServiceRequestPriority.NotUrgent":
return (int)ClientServiceRequestPriority.NotUrgent;
//Case 184
case "UserTypes.Label.Administrator":
return (int)UserTypes.Administrator;
case "UserTypes.Label.Schedulable":
return (int)UserTypes.Schedulable;
case "UserTypes.Label.NonSchedulable":
return (int)UserTypes.NonSchedulable;
case "UserTypes.Label.Client":
return (int)UserTypes.Client;
case "UserTypes.Label.HeadOffice":
return (int)UserTypes.HeadOffice;
case "UserTypes.Label.UTILITY":
return (int)UserTypes.Utility;
//Case 353
case "WorkorderQuoteStatusTypes.Label.Awarded":
return (int)WorkorderQuoteStatusTypes.Awarded;
case "WorkorderQuoteStatusTypes.Label.InProgress":
return (int)WorkorderQuoteStatusTypes.InProgress;
case "WorkorderQuoteStatusTypes.Label.NotAwarded":
return (int)WorkorderQuoteStatusTypes.NotAwarded;
case "WorkorderQuoteStatusTypes.Label.Submitted":
return (int)WorkorderQuoteStatusTypes.Submitted;
//case 1556
case "WorkorderQuoteStatusTypes.Label.New":
return (int)WorkorderQuoteStatusTypes.New;
case "WorkorderQuoteStatusTypes.Label.NotAwarded2":
return (int)WorkorderQuoteStatusTypes.NotAwarded2;
//case 420
case "LoanItem.Label.RateNone":
return (int)LoanItemRates.None;
case "LoanItem.Label.RateHour":
return (int)LoanItemRates.Hours;
case "LoanItem.Label.RateHalfDay":
return (int)LoanItemRates.HalfDays;
case "LoanItem.Label.RateDay":
return (int)LoanItemRates.Days;
case "LoanItem.Label.RateWeek":
return (int)LoanItemRates.Weeks;
case "LoanItem.Label.RateMonth":
return (int)LoanItemRates.Months;
case "LoanItem.Label.RateYear":
return (int)LoanItemRates.Years;
default:
return -1;
}
}
}
}

View File

@@ -0,0 +1,867 @@
///////////////////////////////////////////////////////////
// AyaFile.cs
// Implementation of Class AyaFile
// CSLA type: Editable Root
// Created on: 30-Rocktober-2008
// Object design: John
// Coded: 30-Rocktober-2008
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Collections.Generic;
//case 73
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// AyaFile object
/// Storage, retrieval and deletion of files inside
/// the AyaNova database.
///
/// Automatic compression / decompression.
///
/// NOTE: There is a 50MB source file size limit
/// </summary>
[Serializable]
public class AyaFile : BusinessBase
{
#region Attributes
private Guid mID;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
private Guid mRootObjectID = Guid.Empty;
private RootObjectTypes mRootObjectType;
private AyaFileType mFileType;
private string mName = null;
private byte[] mContent=null;
private bool bReadOnly = false;
private int mFileSize;
private int mFileSizeStored;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private AyaFile()
{
//New ID
mID = Guid.NewGuid();
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified = new SmartDate();
mCreator = Guid.Empty;
mModifier = Guid.Empty;
//pre-break various rules
Name = "";
RootObjectID = Guid.Empty;
RootObjectType = RootObjectTypes.Nothing;
mFileType = AyaFileType.WikiFile;
mFileSize = 0;
}
#endregion
#region Business properties
/// <summary>
/// Internal Unique GUID value of AyaFile record in database
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// AyaNova object ID
/// </summary>
public Guid RootObjectID
{
get
{
return mRootObjectID;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mRootObjectID != value)
{
mRootObjectID = value;
BrokenRules.Assert("RootObjectID", "Error.Object.RequiredFieldEmpty,AyaFile.Label.RootObjectID", "RootObjectID", value == Guid.Empty);
MarkDirty();
}
}
}
}
/// <summary>
/// AyaNova object type
/// </summary>
public RootObjectTypes RootObjectType
{
get
{
return mRootObjectType;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mRootObjectType != value)
{
mRootObjectType = value;
BrokenRules.Assert("RootObjectType", "Error.Object.RequiredFieldEmpty,AyaFile.Label.RootObjectType", "RootObjectType", value == RootObjectTypes.Nothing);
MarkDirty();
}
}
}
}
/// <summary>
/// AyaNova file type
/// </summary>
public AyaFileType FileType
{
get
{
return mFileType;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mFileType != value)
{
mFileType = value;
//BrokenRules.Assert("FileType", "Error.Object.RequiredFieldEmpty,AyaFile.Label.FileType", "FileType", value == RootObjectTypes.Nothing);
MarkDirty();
}
}
}
}
/// <summary>
/// File name displayed on wiki page and potentially in pick lists
/// combo boxes
///
/// This is a required field 1-255 Unicode characters and must be a legal file name
/// </summary>
public string Name
{
get
{
return mName;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mName != value)
{
mName = value;
BrokenRules.Assert("NameRequired",
"Error.Object.RequiredFieldEmpty,AyaFile.Label.Name",
"Name", value.Length == 0);
BrokenRules.Assert("NameLength",
"Error.Object.FieldLengthExceeded255,AyaFile.Label.Name",
"Name", value.Length > 255);
MarkDirty();
}
}
}
}
/// <summary>
/// Size of file in bytes
/// (Note: *file* size, not the amount of bytes actually
/// stored in the database which is compressed)
/// </summary>
public int FileSize
{
get
{
return this.mFileSize;
}
}
/// <summary>
/// Size of stored file in bytes
/// (Note: *file* size stored in database after compression)
/// </summary>
public int FileSizeStored
{
get
{
return this.mFileSize;
}
}
/// <summary>
/// Returns content of AyaFile as a <see cref="System.IO.MemoryStream"/>
/// </summary>
/// <returns></returns>
public System.IO.MemoryStream GetContent()
{
if (mContent.Length == mFileSize)//it's not compressed so just return it
return new System.IO.MemoryStream(mContent);
else//it *is* compressed so decompress and return
return new System.IO.MemoryStream(AyaBizUtils.Decompress(mContent));
}
/// <summary>
/// Set the content from a <see cref="System.IO.Stream"/>
/// Must be less bytes than limit set in <see cref="Global.MaxFileSizeMB"/>
/// or 50mb (hard coded limit) whichever is smaller
/// </summary>
/// <param name="mStream"></param>
public void SetContent(System.IO.Stream mStream)
{
//is file size larger than admin set value or default 50mb limit?
long limit=AyaBizUtils.GlobalSettings.MaxFileSizeMB * 1048576;
if(limit > 52428800) limit = 52428800;
if (mStream.Length > limit)
{
throw new AyAyaFileTooLargeException(string.Format(LocalizedTextTable.GetLocalizedTextDirect("AyaFile.Error.FileTooLarge"),
AyaBizUtils.FileSizeDisplay(limit)));
}
mFileSize = (int)mStream.Length;
mStream.Position = 0;
byte[] bData = new byte[mStream.Length];
mStream.Read(bData, 0, (int)mStream.Length);
mContent = AyaBizUtils.Compress(bData);
//did it compress smaller?
//don't want to store uncompressible files that are actually larger after compression
if (mContent.Length >= mFileSize)
{
//yup, it's bigger compressed, so store the uncompressed version instead
mContent = bData;
}
MarkDirty();
}
/// <summary>
/// Byte array set content
/// </summary>
/// <param name="bData"></param>
public void SetContent(byte[] bData)
{
//is file size larger than admin set value or default 50mb limit?
long limit = AyaBizUtils.GlobalSettings.MaxFileSizeMB * 1048576;
if (limit > 52428800) limit = 52428800;
if (bData.LongLength > limit)
{
throw new AyAyaFileTooLargeException(string.Format(LocalizedTextTable.GetLocalizedTextDirect("AyaFile.Error.FileTooLarge"),
AyaBizUtils.FileSizeDisplay(limit)));
}
mFileSize = (int)bData.LongLength;
//mStream.Position = 0;
//byte[] bData = new byte[mStream.Length];
//mStream.Read(bData, 0, (int)mStream.Length);
mContent = AyaBizUtils.Compress(bData);
//did it compress smaller?
//don't want to store uncompressible files that are actually larger after compression
if (mContent.Length >= mFileSize)
{
//yup, it's bigger compressed, so store the uncompressed version instead
mContent = bData;
}
MarkDirty();
}
/// <summary>
/// Write file to disk
/// </summary>
/// <param name="sPath">Path to save to</param>
/// <param name="sName">Optionally force file name or use original if not specified</param>
public string WriteToDisk(string sPath, string sName)
{
System.IO.FileStream fileStream = null;
sPath = sPath.Trim();
if (sPath[sPath.Length-1] != Path.DirectorySeparatorChar)
sPath += Path.DirectorySeparatorChar;
if (string.IsNullOrEmpty(sName))
{
sPath += mName;
}
else
sPath += sName;
try
{
fileStream = System.IO.File.Create(sPath);
//TESTING ONLY
//mFileSize = mContent.Length;
if (mContent.Length == mFileSize)//not compressed?
{
fileStream.Write(mContent, 0, mContent.Length);
fileStream.Close();
}
else
{
byte[] b = AyaBizUtils.Decompress(mContent);
fileStream.Write(b, 0, b.Length);
fileStream.Close();
}
}
finally
{
fileStream.Dispose();
}
return sPath;
}
/// <summary>
/// Get the MIME type for this file based on extension
/// </summary>
public string mimeType
{
get {
return AyaMimeTypeMap.GetMimeType(System.IO.Path.GetExtension(mName));
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.AyaFile")
)
);
}
#endregion
#region System.object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "AyaFile" + mID.ToString();
}
///
/// <param name="obj"></param>
public override bool Equals(Object obj)
{
if (obj == null || GetType() != obj.GetType()) return false;
AyaFile c = (AyaFile)obj;
return mID == c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("AyaFile" + mID).GetHashCode();
}
#endregion
#region Static methods
/// <summary>
/// Create new AyaFile
/// </summary>
/// <returns>Empty AyaFile object</returns>
public static AyaFile NewItem()
{
AyaFile c;
if (AyaBizUtils.Right("Object.AyaFile") > (int)SecurityLevelTypes.ReadOnly)
{
c = new AyaFile();
return c;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("O.AyaFile")));
}
/// <summary>
/// Fetch existing AyaFile
/// </summary>
/// <returns>AyaFile</returns>
/// <param name="ID">AyaFile Guid</param>
public static AyaFile GetItem(Guid ID)
{
return (AyaFile)DataPortal.Fetch(new Criteria(ID,Guid.Empty));
}
/// <summary>
/// Delete AyaFile
/// </summary>
/// <param name="ID">AyaFile applicationID</param>
public static void DeleteItem(Guid ID)
{
DataPortal.Delete(new Criteria(ID, Guid.Empty));
}
/// <summary>
/// Delete all files that are embedded images in wiki page
/// </summary>
/// <param name="WikiPageID">WikiPage ID</param>
public static void DeleteAllEmbeddedImagesInWikiPage(Guid WikiPageID)
{
DataPortal.Delete(new Criteria(Guid.Empty, WikiPageID));
}
/// <summary>
/// Same as WriteFileToDisk but fetches AyaFile first
/// returns the full path and name it was actually saved to
/// </summary>
/// <param name="ID"></param>
/// <param name="sPath"></param>
/// <param name="sName"></param>
public static string GetAndWriteFileToDisk(Guid ID, string sPath, string sName)
{
AyaFile af = AyaFile.GetItem(ID);
return af.WriteToDisk(sPath, sName);
}
/// <summary>
/// User can read AyaFiles?
/// </summary>
public static bool CanRead
{
get
{
return (AyaBizUtils.Right("Object.AyaFile") > (int)SecurityLevelTypes.NoAccess);
}
}
/// <summary>
/// User can write AyaFiles?
/// (anything above read only is considered full rights to edit, upload and delete files)
/// </summary>
public static bool CanWrite
{
get
{
return (AyaBizUtils.Right("Object.AyaFile") > (int)SecurityLevelTypes.ReadOnly);
}
}
/// <summary>
/// Retrieve internal ID from name.
///
/// </summary>
/// <param name="Name">Text value</param>
/// <returns>Guid ID value or Guid.Empty if no match</returns>
public static Guid GetIDFromName(string Name)
{
return GuidFetcher.GetItem("AFILE", "ANAME", Name);
}
#endregion
#region DAL DATA ACCESS
#region Fetch
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aFile WHERE aID=@ID;", crit.ID);
if (!dr.Read())
DBUtil.ThrowFetchError("AyaFile ID: " + crit.ID.ToString());
//Standard fields
mID = dr.GetGuid("aID");
mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified = DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator = dr.GetGuid("aCreator");
mModifier = dr.GetGuid("aModifier");
//AyaFile fields
Name = dr.GetString("aName");
mFileSize = dr.GetInt32("AFileSize");
RootObjectID = dr.GetGuid("aRootObjectID");
RootObjectType = (RootObjectTypes)dr.GetInt16("aRootObjectType");
FileType = (AyaFileType)dr.GetInt16("aFileType");
//Get the FObject
//Get the data's size
mFileSizeStored = dr.GetInt32("aFObjectSize");
//allocate a place to store it
mContent = new Byte[mFileSizeStored];
//retrieve the (compressed) bytes
dr.GetBytes("aFObject", 0, mContent, 0, mContent.Length);
if(dr!=null) dr.Close();
}
finally
{
if (dr != null) dr.Close();
}
MarkOld();
//Get access rights level
bReadOnly = AyaBizUtils.Right("Object.AyaFile") < (int)SecurityLevelTypes.ReadWrite;
}
#endregion fetch
#region Update
/// <summary>
/// Called by DataPortal to delete/add/update data into the database
/// </summary>
protected override void DataPortal_Update()
{
// If not a new record, check if record was modified
//by another user since original retrieval:
if (!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date, this.mID, "aFile");
#region Delete
if (IsDeleted)
{
throw new System.NotSupportedException("AyaFile->Update->Delete: not supported for this object, call the static/shared AyaFile.DeleteItem() method instead");
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if (IsNew)//Add or update?
cm = DBUtil.GetCommandFromSQL(
"INSERT INTO aFile (aID, aCreated,aModified,aCreator,aModifier, " +
"aRootObjectID, aRootObjectType, aFileType, aName, aFileSize, aFObject,aFObjectSize) " +
"VALUES (@ID,@Created,@Modified,@CurrentUserID,@CurrentUserID, " +
"@RootObjectID,@RootObjectType, @FileType, @Name,@FileSize,@FObject,@FObjectSize)"
);
else
cm = DBUtil.GetCommandFromSQL(
"UPDATE aFile SET aID=@ID, " +
"aModified=@Modified,aModifier=@CurrentUserID, " +
"aRootObjectID=@RootObjectID,aRootObjectType=@RootObjectType, aFileType=@FileType, aName=@Name, " +
"aFileSize=@FileSize, aFObject=@FObject,aFObjectSize=@FObjectSize " +
"WHERE aID=@ID"
);
//AyaFile fields
cm.AddInParameter("@ID", DbType.Guid, mID);
cm.AddInParameter("@Name", DbType.String, mName);
cm.AddInParameter("@RootObjectID", DbType.Guid, mRootObjectID);
cm.AddInParameter("@RootObjectType", DbType.Int16, (int)mRootObjectType);
cm.AddInParameter("@Filetype", DbType.Int16, (int)mFileType);
cm.AddInParameter("@FileSize", DbType.Int32, mFileSize);
//Standard fields
cm.AddInParameter("@CurrentUserID", DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created", DbType.DateTime, DBUtil.ToUTC(mCreated).DBValue);
cm.AddInParameter("@Modified", DbType.DateTime, DBUtil.ToUTC(dtModified));
cm.AddInParameter("@FObject", DbType.Object, mContent);
cm.AddInParameter("@FObjectSize", DbType.Int32, mContent.GetLength(0));
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cm, transaction);
MarkOld();//db is now synched with object
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
//Successful update so
//change modification time to match
this.mModified.Date = dtModified;
}
#endregion
}
#endregion update
#region Delete
/// <summary>
/// Remove a AyaFile record
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Delete(object Criteria)
{
Criteria crit = (Criteria)Criteria;
DBCommandWrapper cmDelete = null;
//Delete *all* embedded images from a wiki page?
if (crit.WikiPageID != Guid.Empty)
{
cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aFile WHERE aRootObjectID = @ID AND aFileType=1");
cmDelete.AddInParameter("@ID", DbType.Guid, crit.WikiPageID);
}
else
{
//Delete object
cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aFile WHERE aID = @ID;");
cmDelete.AddInParameter("@ID", DbType.Guid, crit.ID);
}
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cmDelete, transaction);
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
}
}
#endregion delete
#endregion
#region Override IsValid / IsDirty
/// <summary>
///
/// </summary>
public override bool IsValid
{
get
{
return base.IsValid ;
}
}
/// <summary>
///
/// </summary>
public override bool IsDirty
{
get
{
return base.IsDirty ;
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Guid WikiPageID;
public Criteria(Guid _ID, Guid _WikiPageID)
{
ID = _ID;
WikiPageID = _WikiPageID;
}
}
#endregion
}//end AyaFile
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,569 @@
///////////////////////////////////////////////////////////
// AyaFileList.cs
// Implementation of Class AyaFileList
// CSLA type: Read only collection
// Created on: 31-Rocktober-2008
// Object design: John
// Coded: 31-Rocktober-2008
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Used to fetch a read only list of <see cref="AyaFileList.AyaFileListInfo"/> objects
/// representing <see cref="AyaFile"/> files stored inside the database.
///
/// Used for Wiki feature and for general file management by admin
///
/// </summary>
[Serializable]
public class AyaFileList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct AyaFileListInfo
{
internal GridNameValueCellItem mFile;
/// <summary>
/// File name an internal ID
/// </summary>
[SqlColumnNameAttribute("aFile.aName",
"aFile.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.AyaFile)]
public GridNameValueCellItem LT_O_AyaFile
{ get { return mFile; } }
internal GridNameValueCellItem mSource;
/// <summary>
/// Source of the file (which AyaNova object it's associated with)
/// </summary>
[SqlColumnNameAttribute("grid"), Display(DisplayType.Button, RootObjectType = RootObjectTypes.AyaFile)]
public GridNameValueCellItem LT_AyaFile_Label_Source
{
get
{
return mSource;
}
}
// Object to open to view this search results original record
// If this object is not a child or grandchild, then this is the same as RootObjectID
internal Guid mRootObjectID;
internal RootObjectTypes mRootObjectType;
/// <summary>
/// Files associated object ID
/// </summary>
[Display(DisplayType.Hidden)]
public Guid RootObjectID { get { return mRootObjectID; } }
/// <summary>
/// Files associated object type
/// </summary>
[Display(DisplayType.Hidden)]
public RootObjectTypes RootObjectType { get { return mRootObjectType; } }
/// <summary>
/// The <see cref="AyaFileType"/> of this file
/// </summary>
// [SqlColumnNameAttribute("aFile.aFileType"), Display(DisplayType.Text)]
[SqlColumnNameAttribute("grid"), Display(DisplayType.Text)]
public AyaFileType FileType { get { return mFileType; } }
internal AyaFileType mFileType;
internal string mFileSize;
/// <summary>
/// File size converted to largest whole display unit and unit type appended (i.e. 10MB) see
/// <see cref="AyaBizUtils.FileSizeDisplay"/> for more.
/// </summary>
[SqlColumnNameAttribute("aFile.aFileSize"), Display(DisplayType.Text)]
public string LT_AyaFile_Label_FileSize { get { return mFileSize; } }
internal int mFileSizeBytes;
/// <summary>
/// File size in bytes (actual file size when uncompressed, stored in DB compressed where possible)
/// </summary>
[Display(DisplayType.Hidden)]
public int FileSizeBytes { get { return mFileSizeBytes; } }
internal string mFileSizeStored;
/// <summary>
/// Actual size as stored in Database in human readable format (<see cref="AyaBizUtils.FileSizeDisplay"/>)
/// </summary>
[SqlColumnNameAttribute("aFile.aFObjectSize"), Display(DisplayType.Text)]
public string LT_AyaFile_Label_FileSizeStored { get { return mFileSizeStored; } }
internal SmartDate mCreated;
/// <summary>
/// DateTime the record was created
/// </summary>
[SqlColumnNameAttribute("aFile.aCreated"), Display(DisplayType.DateTime)]
public object LT_Common_Label_Created { get { return mCreated.DBValue; } }
internal SmartDate mModified;
/// <summary>
/// Date and time this record was last modified
/// </summary>
[SqlColumnNameAttribute("aFile.aModified"), Display(DisplayType.DateTime)]
public object LT_Common_Label_Modified { get { return mModified.DBValue; } }
internal GridNameValueCellItem mCreator;
/// <summary>
/// Creator of record
/// </summary>
[SqlColumnNameAttribute("aFile.aCreator",
"aFile.aCreator"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.User)]
public GridNameValueCellItem LT_Common_Label_Creator { get { return mCreator; } }
internal GridNameValueCellItem mModifier;
/// <summary>
/// User who last modified this record
/// </summary>
[SqlColumnNameAttribute("aFile.aModifier",
"aFile.aModifier"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.User)]
public GridNameValueCellItem LT_Common_Label_Modifier { get { return mModifier; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(AyaFileListInfo obj)
{
return this.mFile.Value.Equals(obj.mFile.Value);
}
}//end AyaFileListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected AyaFileList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public AyaFileListInfo this[int Item]
{
get
{
return (AyaFileListInfo) List[Item];
}
}
/// <summary>
/// Returns AyaFileListInfo object that matches passed in File Name value
/// </summary>
/// <param name="FileName"></param>
public AyaFileListInfo? this[string FileName]
{
get
{
foreach (AyaFileListInfo child in List)
{
if (child.LT_O_AyaFile.Display == FileName) return child;
}
return null;
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (AyaFileListInfo child in List)
{
if(child.mFile.Value==ItemID) return child.ToString();
}
return "Missing: "+ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(AyaFileListInfo obj)
{
foreach (AyaFileListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in collection by file name
/// </summary>
/// <param name="FileName"></param>
/// <returns></returns>
public bool Contains(string FileName)
{
foreach (AyaFileListInfo child in List)
{
if (child.LT_O_AyaFile.Display==FileName) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "AyaFileList";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return "";
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
return RootObjectTypes.AyaFile;
}
}
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "AyaFile.Label.List";
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(AyaFileListInfo);
}
}
/// <summary>
/// Field that contains the ID of the objects
/// that are the basis of this list.
///
/// Used for compiling an ID list for reporting from user
/// selections in a grid.
/// </summary>
public static string IDField
{
get
{
return "LT_O_AyaFile";
}
}
/// <summary>
/// Same as IDField but for detailed reports
/// </summary>
public static string IDFieldDetailed
{
get
{
return IDField;
}
}
#endregion
#region Static methods
/// <summary>
/// Get all for given RootObjectID
/// (typically the ID of a WikiPage
/// </summary>
/// <param name="RootObjectID"></param>
/// <returns>List of <see cref="AyaFileList.AyaFileListInfo"/> objects</returns>
public static AyaFileList GetList(Guid RootObjectID)
{
return (AyaFileList) DataPortal.Fetch(new Criteria("",null,-1,RootObjectID));
}
/// <summary>
/// Internal method used by list factory
/// </summary>
internal static AyaFileList Get(string Filter, int MaxRecords, List<Guid> IDList)
{
return (AyaFileList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords, Guid.Empty));
}
/// <summary>
/// Get all (filtered by crit)
/// </summary>
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
/// <returns>List of <see cref="AyaFileList.AyaFileListInfo"/> objects</returns>
public static AyaFileList GetList(string xmlCriteria)
{
return (AyaFileList) DataPortal.Fetch(new Criteria(xmlCriteria,null,-1, Guid.Empty));
}
/// <summary>
/// Get list by items indicated in IDList
/// </summary>
/// <param name="IDList">Generic list of Guid's</param>
/// <returns>List of <see cref="AyaFileList.AyaFileListInfo"/> objects</returns>
public static AyaFileList GetListFromIDList(List<Guid> IDList)
{
//case 556
//Handle empty list
if (IDList.Count == 0)
return new AyaFileList();
return (AyaFileList)DataPortal.Fetch(new Criteria("", IDList, -1, Guid.Empty));
}
/// <summary>
/// Used internally to fetch info for a single specific file
/// </summary>
/// <param name="AyaFileID"></param>
/// <returns>List of <see cref="AyaFileList.AyaFileListInfo"/> one object</returns>
public static AyaFileList GetListOfOne(Guid AyaFileID)
{
List<Guid> l = new List<Guid>();
l.Add(AyaFileID);
return GetListFromIDList(l);
}
/// <summary>
/// Return an empty list
/// used for initializing grid
/// </summary>
/// <returns>Empty List of zero <see cref="AyaFileList.AyaFileListInfo"/> objects</returns>
public static AyaFileList GetEmptyList()
{
return new AyaFileList();
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
//cached user list
UserPickList users = UserPickList.GetList(false);
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q = "";
//************************************************************
if (crit.RootObjectID != Guid.Empty)
{ //Standard case for wikipages
dr=DBUtil.GetReaderFromSQLString("SELECT aID, aCreated,aModified,aCreator,aModifier, " +
"aRootObjectID, aRootObjectType, aFileType, aName, aFileSize, aFObjectSize " +
"FROM aFile WHERE aRootObjectID=@ID ", crit.RootObjectID);
}
else if (crit.IDList != null)
{
//Case 556
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" WHERE aFile.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(") ");
q = "SELECT aID, aCreated,aModified,aCreator,aModifier, " +
"aRootObjectID, aRootObjectType, aFileType, aName, aFileSize, aFObjectSize " +
"FROM aFile " +
sbIN.ToString() + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
dr = DBUtil.GetReaderFromSQLString(q);
}
else
{
q = "SELECT ~MAXRECS~ aID, aCreated,aModified,aCreator,aModifier, " +
"aRootObjectID, aRootObjectType, aFileType, aName, aFileSize, aFObjectSize " +
"FROM aFile " + //Case 58;
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML, true) + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
dr = DBUtil.GetReaderFromSQLString(q);
}
//************************************************************
while(dr.Read())
{
//*******************************************
AyaFileListInfo info=new AyaFileListInfo();
info.mFileType = (AyaFileType)dr.GetInt16("aFileType");
////Don't load image files into list when in a wikipage
////as they are handled internally, no need to show to user and confuse them
//if (crit.RootObjectID != Guid.Empty)//it's a wikipage
// if (info.mFileType == AyaFileType.EmbeddedWikiImage)
// continue;
info.mFile=new GridNameValueCellItem(
dr.GetGuid("aID"),
dr.GetString("aName"),
RootObjectTypes.AyaFile);
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
info.mCreator = new GridNameValueCellItem(
dr.GetGuid("aCreator"),
users[dr.GetGuid("aCreator")],
RootObjectTypes.User);
info.mModifier = new GridNameValueCellItem(
dr.GetGuid("aModifier"),
users[dr.GetGuid("aModifier")],
RootObjectTypes.User);
info.mModified = DBUtil.ToLocal(dr.GetSmartDate("aModified"));
info.mFileSize = AyaBizUtils.FileSizeDisplay(System.Convert.ToDecimal(dr.GetInt32("aFileSize")));
info.mFileSizeStored = AyaBizUtils.FileSizeDisplay(System.Convert.ToDecimal(dr.GetInt32("aFObjectSize")));
info.mFileSizeBytes = dr.GetInt32("aFileSize");
info.mRootObjectID = dr.GetGuid("aRootObjectID");
info.mRootObjectType = (RootObjectTypes)dr.GetInt16("aRootObjectType");
info.mSource = new GridNameValueCellItem(
info.mRootObjectID,
EnumDescConverter.GetEnumDescription(info.mRootObjectType),
info.mRootObjectType);
InnerList.Add(info);
//*******************************************
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public List<Guid> IDList;
public string CriteriaXML;
public int MaxRecords;
public Guid RootObjectID;
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords,Guid _RootObjectID)
{
CriteriaXML = _CriteriaXML;
IDList = _IDList;
MaxRecords = _MaxRecords;
RootObjectID=_RootObjectID;
}
}
#endregion
}//end AyaFileList
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,141 @@
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
//case 73
/// <summary>
///Retrieves stats about files stored
///in the AyaNova database for diagnosis and administrative purposes
/// </summary>
[Serializable]
public class AyaFileStats : ReadOnlyBase
{
#region Attributes
private decimal mFileCount;
private decimal mTotalStoredFileData;
private decimal mTotalFileSize;
/// <summary>
/// Number of files stored in database
/// </summary>
public decimal FileCount
{ get { return mFileCount; } }
/// <summary>
/// Total bytes actually stored in database for files
/// </summary>
public decimal TotalStoredFileData
{ get { return mTotalStoredFileData; } }
/// <summary>
/// Total size of all files stored in the database if they were uncompressed
/// </summary>
public decimal TotalFileSize
{ get { return mTotalFileSize; } }
/// <summary>
/// Stats formatted in one UI friendly string for direct display
/// </summary>
public string Stats
{
//All stats formatted into one neat string
get
{
return "AyaFile stats - Files: " + mFileCount.ToString() + " Total stored file data: " + AyaBizUtils.FileSizeDisplay(mTotalStoredFileData);
}
}
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private AyaFileStats()
{
}
#endregion
#region Static methods
/// <summary>
/// Fetch
/// </summary>
/// <returns></returns>
public static AyaFileStats GetStats()
{
return (AyaFileStats)DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
//case 963 improved null handling
//case 1980 - arithmetic overflow bug
if (DBUtil.DB.DBType == DataBaseType.FireBird)
{
mTotalStoredFileData = DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT SUM(AFOBJECTSIZE) FROM AFILE"));
mTotalFileSize = DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT SUM(AFILESIZE) FROM AFILE"));
mFileCount = DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT COUNT(*) FROM AFILE"));
}
else
{
mTotalStoredFileData = DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT SUM(CAST(AFOBJECTSIZE AS BIGINT)) FROM AFILE"));
mTotalFileSize = DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT SUM(CAST(AFILESIZE AS BIGINT)) FROM AFILE"));
mFileCount = DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT COUNT(*) FROM AFILE"));
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
// public Guid ID;
// public string Name;
public Criteria(/*Guid _ID, string _Name*/)
{
//ID = _ID;
// Name = _Name;
}
}
#endregion
}//end class
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,24 @@
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Used to identify file types for display and internal processing purposes
/// </summary>
public enum AyaFileType : int
{
/// <summary>
/// A file of unknown attachement
/// </summary>
Unknown = 0,
/// <summary>
/// An image that is embedded in a wiki page
/// </summary>
EmbeddedWikiImage = 1,
/// <summary>
/// A file attached to a wiki entry
/// </summary>
WikiFile=2
}//end AyaFileType
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,609 @@
using System;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Extension to MIME type
/// </summary>
public static class AyaMimeTypeMap
{
//From https://github.com/samuelneff/MimeTypeMap
private static readonly IDictionary<string, string> _mappings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) {
#region Big freaking list of mime types
// combination of values from Windows 7 Registry and
// from C:\Windows\System32\inetsrv\config\applicationHost.config
// some added, including .7z and .dat
{".323", "text/h323"},
{".3g2", "video/3gpp2"},
{".3gp", "video/3gpp"},
{".3gp2", "video/3gpp2"},
{".3gpp", "video/3gpp"},
{".7z", "application/x-7z-compressed"},
{".aa", "audio/audible"},
{".AAC", "audio/aac"},
{".aaf", "application/octet-stream"},
{".aax", "audio/vnd.audible.aax"},
{".ac3", "audio/ac3"},
{".aca", "application/octet-stream"},
{".accda", "application/msaccess.addin"},
{".accdb", "application/msaccess"},
{".accdc", "application/msaccess.cab"},
{".accde", "application/msaccess"},
{".accdr", "application/msaccess.runtime"},
{".accdt", "application/msaccess"},
{".accdw", "application/msaccess.webapplication"},
{".accft", "application/msaccess.ftemplate"},
{".acx", "application/internet-property-stream"},
{".AddIn", "text/xml"},
{".ade", "application/msaccess"},
{".adobebridge", "application/x-bridge-url"},
{".adp", "application/msaccess"},
{".ADT", "audio/vnd.dlna.adts"},
{".ADTS", "audio/aac"},
{".afm", "application/octet-stream"},
{".ai", "application/postscript"},
{".aif", "audio/x-aiff"},
{".aifc", "audio/aiff"},
{".aiff", "audio/aiff"},
{".air", "application/vnd.adobe.air-application-installer-package+zip"},
{".amc", "application/x-mpeg"},
{".application", "application/x-ms-application"},
{".art", "image/x-jg"},
{".asa", "application/xml"},
{".asax", "application/xml"},
{".ascx", "application/xml"},
{".asd", "application/octet-stream"},
{".asf", "video/x-ms-asf"},
{".ashx", "application/xml"},
{".asi", "application/octet-stream"},
{".asm", "text/plain"},
{".asmx", "application/xml"},
{".aspx", "application/xml"},
{".asr", "video/x-ms-asf"},
{".asx", "video/x-ms-asf"},
{".atom", "application/atom+xml"},
{".au", "audio/basic"},
{".avi", "video/x-msvideo"},
{".axs", "application/olescript"},
{".bas", "text/plain"},
{".bcpio", "application/x-bcpio"},
{".bin", "application/octet-stream"},
{".bmp", "image/bmp"},
{".c", "text/plain"},
{".cab", "application/octet-stream"},
{".caf", "audio/x-caf"},
{".calx", "application/vnd.ms-office.calx"},
{".cat", "application/vnd.ms-pki.seccat"},
{".cc", "text/plain"},
{".cd", "text/plain"},
{".cdda", "audio/aiff"},
{".cdf", "application/x-cdf"},
{".cer", "application/x-x509-ca-cert"},
{".chm", "application/octet-stream"},
{".class", "application/x-java-applet"},
{".clp", "application/x-msclip"},
{".cmx", "image/x-cmx"},
{".cnf", "text/plain"},
{".cod", "image/cis-cod"},
{".config", "application/xml"},
{".contact", "text/x-ms-contact"},
{".coverage", "application/xml"},
{".cpio", "application/x-cpio"},
{".cpp", "text/plain"},
{".crd", "application/x-mscardfile"},
{".crl", "application/pkix-crl"},
{".crt", "application/x-x509-ca-cert"},
{".cs", "text/plain"},
{".csdproj", "text/plain"},
{".csh", "application/x-csh"},
{".csproj", "text/plain"},
{".css", "text/css"},
{".csv", "text/csv"},
{".cur", "application/octet-stream"},
{".cxx", "text/plain"},
{".dat", "application/octet-stream"},
{".datasource", "application/xml"},
{".dbproj", "text/plain"},
{".dcr", "application/x-director"},
{".def", "text/plain"},
{".deploy", "application/octet-stream"},
{".der", "application/x-x509-ca-cert"},
{".dgml", "application/xml"},
{".dib", "image/bmp"},
{".dif", "video/x-dv"},
{".dir", "application/x-director"},
{".disco", "text/xml"},
{".dll", "application/x-msdownload"},
{".dll.config", "text/xml"},
{".dlm", "text/dlm"},
{".doc", "application/msword"},
{".docm", "application/vnd.ms-word.document.macroEnabled.12"},
{".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
{".dot", "application/msword"},
{".dotm", "application/vnd.ms-word.template.macroEnabled.12"},
{".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"},
{".dsp", "application/octet-stream"},
{".dsw", "text/plain"},
{".dtd", "text/xml"},
{".dtsConfig", "text/xml"},
{".dv", "video/x-dv"},
{".dvi", "application/x-dvi"},
{".dwf", "drawing/x-dwf"},
{".dwp", "application/octet-stream"},
{".dxr", "application/x-director"},
{".eml", "message/rfc822"},
{".emz", "application/octet-stream"},
{".eot", "application/octet-stream"},
{".eps", "application/postscript"},
{".etl", "application/etl"},
{".etx", "text/x-setext"},
{".evy", "application/envoy"},
{".exe", "application/octet-stream"},
{".exe.config", "text/xml"},
{".fdf", "application/vnd.fdf"},
{".fif", "application/fractals"},
{".filters", "Application/xml"},
{".fla", "application/octet-stream"},
{".flr", "x-world/x-vrml"},
{".flv", "video/x-flv"},
{".fsscript", "application/fsharp-script"},
{".fsx", "application/fsharp-script"},
{".generictest", "application/xml"},
{".gif", "image/gif"},
{".group", "text/x-ms-group"},
{".gsm", "audio/x-gsm"},
{".gtar", "application/x-gtar"},
{".gz", "application/x-gzip"},
{".h", "text/plain"},
{".hdf", "application/x-hdf"},
{".hdml", "text/x-hdml"},
{".hhc", "application/x-oleobject"},
{".hhk", "application/octet-stream"},
{".hhp", "application/octet-stream"},
{".hlp", "application/winhlp"},
{".hpp", "text/plain"},
{".hqx", "application/mac-binhex40"},
{".hta", "application/hta"},
{".htc", "text/x-component"},
{".htm", "text/html"},
{".html", "text/html"},
{".htt", "text/webviewhtml"},
{".hxa", "application/xml"},
{".hxc", "application/xml"},
{".hxd", "application/octet-stream"},
{".hxe", "application/xml"},
{".hxf", "application/xml"},
{".hxh", "application/octet-stream"},
{".hxi", "application/octet-stream"},
{".hxk", "application/xml"},
{".hxq", "application/octet-stream"},
{".hxr", "application/octet-stream"},
{".hxs", "application/octet-stream"},
{".hxt", "text/html"},
{".hxv", "application/xml"},
{".hxw", "application/octet-stream"},
{".hxx", "text/plain"},
{".i", "text/plain"},
{".ico", "image/x-icon"},
{".ics", "application/octet-stream"},
{".idl", "text/plain"},
{".ief", "image/ief"},
{".iii", "application/x-iphone"},
{".inc", "text/plain"},
{".inf", "application/octet-stream"},
{".inl", "text/plain"},
{".ins", "application/x-internet-signup"},
{".ipa", "application/x-itunes-ipa"},
{".ipg", "application/x-itunes-ipg"},
{".ipproj", "text/plain"},
{".ipsw", "application/x-itunes-ipsw"},
{".iqy", "text/x-ms-iqy"},
{".isp", "application/x-internet-signup"},
{".ite", "application/x-itunes-ite"},
{".itlp", "application/x-itunes-itlp"},
{".itms", "application/x-itunes-itms"},
{".itpc", "application/x-itunes-itpc"},
{".IVF", "video/x-ivf"},
{".jar", "application/java-archive"},
{".java", "application/octet-stream"},
{".jck", "application/liquidmotion"},
{".jcz", "application/liquidmotion"},
{".jfif", "image/pjpeg"},
{".jnlp", "application/x-java-jnlp-file"},
{".jpb", "application/octet-stream"},
{".jpe", "image/jpeg"},
{".jpeg", "image/jpeg"},
{".jpg", "image/jpeg"},
{".js", "application/x-javascript"},
{".json", "application/json"},
{".jsx", "text/jscript"},
{".jsxbin", "text/plain"},
{".latex", "application/x-latex"},
{".library-ms", "application/windows-library+xml"},
{".lit", "application/x-ms-reader"},
{".loadtest", "application/xml"},
{".lpk", "application/octet-stream"},
{".lsf", "video/x-la-asf"},
{".lst", "text/plain"},
{".lsx", "video/x-la-asf"},
{".lzh", "application/octet-stream"},
{".m13", "application/x-msmediaview"},
{".m14", "application/x-msmediaview"},
{".m1v", "video/mpeg"},
{".m2t", "video/vnd.dlna.mpeg-tts"},
{".m2ts", "video/vnd.dlna.mpeg-tts"},
{".m2v", "video/mpeg"},
{".m3u", "audio/x-mpegurl"},
{".m3u8", "audio/x-mpegurl"},
{".m4a", "audio/m4a"},
{".m4b", "audio/m4b"},
{".m4p", "audio/m4p"},
{".m4r", "audio/x-m4r"},
{".m4v", "video/x-m4v"},
{".mac", "image/x-macpaint"},
{".mak", "text/plain"},
{".man", "application/x-troff-man"},
{".manifest", "application/x-ms-manifest"},
{".map", "text/plain"},
{".master", "application/xml"},
{".mda", "application/msaccess"},
{".mdb", "application/x-msaccess"},
{".mde", "application/msaccess"},
{".mdp", "application/octet-stream"},
{".me", "application/x-troff-me"},
{".mfp", "application/x-shockwave-flash"},
{".mht", "message/rfc822"},
{".mhtml", "message/rfc822"},
{".mid", "audio/mid"},
{".midi", "audio/mid"},
{".mix", "application/octet-stream"},
{".mk", "text/plain"},
{".mmf", "application/x-smaf"},
{".mno", "text/xml"},
{".mny", "application/x-msmoney"},
{".mod", "video/mpeg"},
{".mov", "video/quicktime"},
{".movie", "video/x-sgi-movie"},
{".mp2", "video/mpeg"},
{".mp2v", "video/mpeg"},
{".mp3", "audio/mpeg"},
{".mp4", "video/mp4"},
{".mp4v", "video/mp4"},
{".mpa", "video/mpeg"},
{".mpe", "video/mpeg"},
{".mpeg", "video/mpeg"},
{".mpf", "application/vnd.ms-mediapackage"},
{".mpg", "video/mpeg"},
{".mpp", "application/vnd.ms-project"},
{".mpv2", "video/mpeg"},
{".mqv", "video/quicktime"},
{".ms", "application/x-troff-ms"},
{".msi", "application/octet-stream"},
{".mso", "application/octet-stream"},
{".mts", "video/vnd.dlna.mpeg-tts"},
{".mtx", "application/xml"},
{".mvb", "application/x-msmediaview"},
{".mvc", "application/x-miva-compiled"},
{".mxp", "application/x-mmxp"},
{".nc", "application/x-netcdf"},
{".nsc", "video/x-ms-asf"},
{".nws", "message/rfc822"},
{".ocx", "application/octet-stream"},
{".oda", "application/oda"},
{".odc", "text/x-ms-odc"},
{".odh", "text/plain"},
{".odl", "text/plain"},
{".odp", "application/vnd.oasis.opendocument.presentation"},
{".ods", "application/oleobject"},
{".odt", "application/vnd.oasis.opendocument.text"},
{".one", "application/onenote"},
{".onea", "application/onenote"},
{".onepkg", "application/onenote"},
{".onetmp", "application/onenote"},
{".onetoc", "application/onenote"},
{".onetoc2", "application/onenote"},
{".orderedtest", "application/xml"},
{".osdx", "application/opensearchdescription+xml"},
{".p10", "application/pkcs10"},
{".p12", "application/x-pkcs12"},
{".p7b", "application/x-pkcs7-certificates"},
{".p7c", "application/pkcs7-mime"},
{".p7m", "application/pkcs7-mime"},
{".p7r", "application/x-pkcs7-certreqresp"},
{".p7s", "application/pkcs7-signature"},
{".pbm", "image/x-portable-bitmap"},
{".pcast", "application/x-podcast"},
{".pct", "image/pict"},
{".pcx", "application/octet-stream"},
{".pcz", "application/octet-stream"},
{".pdf", "application/pdf"},
{".pfb", "application/octet-stream"},
{".pfm", "application/octet-stream"},
{".pfx", "application/x-pkcs12"},
{".pgm", "image/x-portable-graymap"},
{".pic", "image/pict"},
{".pict", "image/pict"},
{".pkgdef", "text/plain"},
{".pkgundef", "text/plain"},
{".pko", "application/vnd.ms-pki.pko"},
{".pls", "audio/scpls"},
{".pma", "application/x-perfmon"},
{".pmc", "application/x-perfmon"},
{".pml", "application/x-perfmon"},
{".pmr", "application/x-perfmon"},
{".pmw", "application/x-perfmon"},
{".png", "image/png"},
{".pnm", "image/x-portable-anymap"},
{".pnt", "image/x-macpaint"},
{".pntg", "image/x-macpaint"},
{".pnz", "image/png"},
{".pot", "application/vnd.ms-powerpoint"},
{".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12"},
{".potx", "application/vnd.openxmlformats-officedocument.presentationml.template"},
{".ppa", "application/vnd.ms-powerpoint"},
{".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12"},
{".ppm", "image/x-portable-pixmap"},
{".pps", "application/vnd.ms-powerpoint"},
{".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12"},
{".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"},
{".ppt", "application/vnd.ms-powerpoint"},
{".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12"},
{".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"},
{".prf", "application/pics-rules"},
{".prm", "application/octet-stream"},
{".prx", "application/octet-stream"},
{".ps", "application/postscript"},
{".psc1", "application/PowerShell"},
{".psd", "application/octet-stream"},
{".psess", "application/xml"},
{".psm", "application/octet-stream"},
{".psp", "application/octet-stream"},
{".pub", "application/x-mspublisher"},
{".pwz", "application/vnd.ms-powerpoint"},
{".qht", "text/x-html-insertion"},
{".qhtm", "text/x-html-insertion"},
{".qt", "video/quicktime"},
{".qti", "image/x-quicktime"},
{".qtif", "image/x-quicktime"},
{".qtl", "application/x-quicktimeplayer"},
{".qxd", "application/octet-stream"},
{".ra", "audio/x-pn-realaudio"},
{".ram", "audio/x-pn-realaudio"},
{".rar", "application/octet-stream"},
{".ras", "image/x-cmu-raster"},
{".rat", "application/rat-file"},
{".rc", "text/plain"},
{".rc2", "text/plain"},
{".rct", "text/plain"},
{".rdlc", "application/xml"},
{".resx", "application/xml"},
{".rf", "image/vnd.rn-realflash"},
{".rgb", "image/x-rgb"},
{".rgs", "text/plain"},
{".rm", "application/vnd.rn-realmedia"},
{".rmi", "audio/mid"},
{".rmp", "application/vnd.rn-rn_music_package"},
{".roff", "application/x-troff"},
{".rpm", "audio/x-pn-realaudio-plugin"},
{".rqy", "text/x-ms-rqy"},
{".rtf", "application/rtf"},
{".rtx", "text/richtext"},
{".ruleset", "application/xml"},
{".s", "text/plain"},
{".safariextz", "application/x-safari-safariextz"},
{".scd", "application/x-msschedule"},
{".sct", "text/scriptlet"},
{".sd2", "audio/x-sd2"},
{".sdp", "application/sdp"},
{".sea", "application/octet-stream"},
{".searchConnector-ms", "application/windows-search-connector+xml"},
{".setpay", "application/set-payment-initiation"},
{".setreg", "application/set-registration-initiation"},
{".settings", "application/xml"},
{".sgimb", "application/x-sgimb"},
{".sgml", "text/sgml"},
{".sh", "application/x-sh"},
{".shar", "application/x-shar"},
{".shtml", "text/html"},
{".sit", "application/x-stuffit"},
{".sitemap", "application/xml"},
{".skin", "application/xml"},
{".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12"},
{".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide"},
{".slk", "application/vnd.ms-excel"},
{".sln", "text/plain"},
{".slupkg-ms", "application/x-ms-license"},
{".smd", "audio/x-smd"},
{".smi", "application/octet-stream"},
{".smx", "audio/x-smd"},
{".smz", "audio/x-smd"},
{".snd", "audio/basic"},
{".snippet", "application/xml"},
{".snp", "application/octet-stream"},
{".sol", "text/plain"},
{".sor", "text/plain"},
{".spc", "application/x-pkcs7-certificates"},
{".spl", "application/futuresplash"},
{".src", "application/x-wais-source"},
{".srf", "text/plain"},
{".SSISDeploymentManifest", "text/xml"},
{".ssm", "application/streamingmedia"},
{".sst", "application/vnd.ms-pki.certstore"},
{".stl", "application/vnd.ms-pki.stl"},
{".sv4cpio", "application/x-sv4cpio"},
{".sv4crc", "application/x-sv4crc"},
{".svc", "application/xml"},
{".swf", "application/x-shockwave-flash"},
{".t", "application/x-troff"},
{".tar", "application/x-tar"},
{".tcl", "application/x-tcl"},
{".testrunconfig", "application/xml"},
{".testsettings", "application/xml"},
{".tex", "application/x-tex"},
{".texi", "application/x-texinfo"},
{".texinfo", "application/x-texinfo"},
{".tgz", "application/x-compressed"},
{".thmx", "application/vnd.ms-officetheme"},
{".thn", "application/octet-stream"},
{".tif", "image/tiff"},
{".tiff", "image/tiff"},
{".tlh", "text/plain"},
{".tli", "text/plain"},
{".toc", "application/octet-stream"},
{".tr", "application/x-troff"},
{".trm", "application/x-msterminal"},
{".trx", "application/xml"},
{".ts", "video/vnd.dlna.mpeg-tts"},
{".tsv", "text/tab-separated-values"},
{".ttf", "application/octet-stream"},
{".tts", "video/vnd.dlna.mpeg-tts"},
{".txt", "text/plain"},
{".u32", "application/octet-stream"},
{".uls", "text/iuls"},
{".user", "text/plain"},
{".ustar", "application/x-ustar"},
{".vb", "text/plain"},
{".vbdproj", "text/plain"},
{".vbk", "video/mpeg"},
{".vbproj", "text/plain"},
{".vbs", "text/vbscript"},
{".vcf", "text/x-vcard"},
{".vcproj", "Application/xml"},
{".vcs", "text/plain"},
{".vcxproj", "Application/xml"},
{".vddproj", "text/plain"},
{".vdp", "text/plain"},
{".vdproj", "text/plain"},
{".vdx", "application/vnd.ms-visio.viewer"},
{".vml", "text/xml"},
{".vscontent", "application/xml"},
{".vsct", "text/xml"},
{".vsd", "application/vnd.visio"},
{".vsi", "application/ms-vsi"},
{".vsix", "application/vsix"},
{".vsixlangpack", "text/xml"},
{".vsixmanifest", "text/xml"},
{".vsmdi", "application/xml"},
{".vspscc", "text/plain"},
{".vss", "application/vnd.visio"},
{".vsscc", "text/plain"},
{".vssettings", "text/xml"},
{".vssscc", "text/plain"},
{".vst", "application/vnd.visio"},
{".vstemplate", "text/xml"},
{".vsto", "application/x-ms-vsto"},
{".vsw", "application/vnd.visio"},
{".vsx", "application/vnd.visio"},
{".vtx", "application/vnd.visio"},
{".wav", "audio/wav"},
{".wave", "audio/wav"},
{".wax", "audio/x-ms-wax"},
{".wbk", "application/msword"},
{".wbmp", "image/vnd.wap.wbmp"},
{".wcm", "application/vnd.ms-works"},
{".wdb", "application/vnd.ms-works"},
{".wdp", "image/vnd.ms-photo"},
{".webarchive", "application/x-safari-webarchive"},
{".webtest", "application/xml"},
{".wiq", "application/xml"},
{".wiz", "application/msword"},
{".wks", "application/vnd.ms-works"},
{".WLMP", "application/wlmoviemaker"},
{".wlpginstall", "application/x-wlpg-detect"},
{".wlpginstall3", "application/x-wlpg3-detect"},
{".wm", "video/x-ms-wm"},
{".wma", "audio/x-ms-wma"},
{".wmd", "application/x-ms-wmd"},
{".wmf", "application/x-msmetafile"},
{".wml", "text/vnd.wap.wml"},
{".wmlc", "application/vnd.wap.wmlc"},
{".wmls", "text/vnd.wap.wmlscript"},
{".wmlsc", "application/vnd.wap.wmlscriptc"},
{".wmp", "video/x-ms-wmp"},
{".wmv", "video/x-ms-wmv"},
{".wmx", "video/x-ms-wmx"},
{".wmz", "application/x-ms-wmz"},
{".wpl", "application/vnd.ms-wpl"},
{".wps", "application/vnd.ms-works"},
{".wri", "application/x-mswrite"},
{".wrl", "x-world/x-vrml"},
{".wrz", "x-world/x-vrml"},
{".wsc", "text/scriptlet"},
{".wsdl", "text/xml"},
{".wvx", "video/x-ms-wvx"},
{".x", "application/directx"},
{".xaf", "x-world/x-vrml"},
{".xaml", "application/xaml+xml"},
{".xap", "application/x-silverlight-app"},
{".xbap", "application/x-ms-xbap"},
{".xbm", "image/x-xbitmap"},
{".xdr", "text/plain"},
{".xht", "application/xhtml+xml"},
{".xhtml", "application/xhtml+xml"},
{".xla", "application/vnd.ms-excel"},
{".xlam", "application/vnd.ms-excel.addin.macroEnabled.12"},
{".xlc", "application/vnd.ms-excel"},
{".xld", "application/vnd.ms-excel"},
{".xlk", "application/vnd.ms-excel"},
{".xll", "application/vnd.ms-excel"},
{".xlm", "application/vnd.ms-excel"},
{".xls", "application/vnd.ms-excel"},
{".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12"},
{".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12"},
{".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
{".xlt", "application/vnd.ms-excel"},
{".xltm", "application/vnd.ms-excel.template.macroEnabled.12"},
{".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"},
{".xlw", "application/vnd.ms-excel"},
{".xml", "text/xml"},
{".xmta", "application/xml"},
{".xof", "x-world/x-vrml"},
{".XOML", "text/plain"},
{".xpm", "image/x-xpixmap"},
{".xps", "application/vnd.ms-xpsdocument"},
{".xrm-ms", "text/xml"},
{".xsc", "application/xml"},
{".xsd", "text/xml"},
{".xsf", "text/xml"},
{".xsl", "text/xml"},
{".xslt", "text/xml"},
{".xsn", "application/octet-stream"},
{".xss", "application/xml"},
{".xtp", "application/octet-stream"},
{".xwd", "image/x-xwindowdump"},
{".z", "application/x-compress"},
{".zip", "application/x-zip-compressed"},
#endregion
};
/// <summary>
/// Get mime type from extension
/// </summary>
/// <param name="extension"></param>
/// <returns></returns>
public static string GetMimeType(string extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
if (!extension.StartsWith("."))
{
extension = "." + extension;
}
string mime;
return _mappings.TryGetValue(extension, out mime) ? mime : "application/octet-stream";
}
}
//ens
}

View File

@@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////
// AyaTimeSpan.cs
// Implementation of Class AyaTimeSpan
// CSLA type: enumeration
// Created on: 06-Oct-2005
// Object design: John
// Coded: John 06-Oct-2005
///////////////////////////////////////////////////////////
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Used throughout AyaNova wherever a unit of time needs to be selected or acted upon
/// </summary>
[TypeConverter(typeof(EnumDescConverter))]
public enum AyaUnitsOfTime : int
{
#pragma warning disable 1591
[Description("LT:UI.Label.TimeSpan.Seconds")]
Seconds = 1,
[Description("LT:UI.Label.TimeSpan.Minutes")]
Minutes = 2,
[Description("LT:UI.Label.TimeSpan.Hours")]
Hours = 3,
[Description("LT:UI.Label.TimeSpan.Days")]
Days = 4,
[Description("LT:UI.Label.TimeSpan.Weeks")]
Weeks = 5,
[Description("LT:UI.Label.TimeSpan.Months")]
Months = 6,
[Description("LT:UI.Label.TimeSpan.Years")]
Years = 7
#pragma warning restore 1591
}//end AyaTimeSpan
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,161 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class BoolFetcher
// CSLA type: Read-only object
// Created on: 06-Dec-2004
// Object design: John
// Coded: John Aug 4 2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Used to quickly fetch a single Bool record from the db
/// </summary>
[Serializable]
public class BoolFetcher : ReadOnlyBase
{
#region Attributes
private bool mBoolValue;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private BoolFetcher()
{
}
#endregion
#region Business properties
public bool BoolValue
{
get
{
return mBoolValue;
}
}
#endregion
#region System.Object overrides
public override string ToString()
{
return mBoolValue.ToString();
}
///
/// <param Bool="obj"></param>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
BoolFetcher c=(BoolFetcher)obj;
return mBoolValue==c.mBoolValue;
}
public override int GetHashCode()
{
return ("Bool" + mBoolValue.ToString()).GetHashCode();
}
#endregion
#region Static methods
/// <summary>
///
/// </summary>
/// <param Bool="Table"></param>
/// <param Bool="FieldBool"></param>
/// <param Bool="RecordID"></param>
/// <returns></returns>
public static BoolFetcher GetItem(string Table, string FieldName, Guid RecordID)
{
return (BoolFetcher)DataPortal.Fetch(new Criteria( Table, FieldName, RecordID));
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
try
{
//FireBird will return an int16 0 or 1 value
//mssql will return a bool value
//because this isn't using the datareader which converts automatically
//but it's still faster to check here and use executescalar than
//to convert this to use a data reader
object o=DBUtil.GetScalarFromSQLString("SELECT " + AyaBizUtils.ToDBName(crit.FieldName) + " FROM "+ AyaBizUtils.ToDBName(crit.Table) +" WHERE aID=@ID",crit.RecordID);
mBoolValue=System.Convert.ToBoolean(o);
}
catch(Exception ex)
{
throw new System.ArgumentException(
string.Format(LocalizedTextTable.GetLocalizedTextDirect("Error.Object.NameFetcherNotFound")/*Name/bool Fetcher: Field {0} in table {1} with record ID {2} not found!*/,
crit.FieldName,crit.Table,crit.RecordID.ToString()) +
"\r\n(" + ex.Message + ")");
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public string Table;
public string FieldName;
public Guid RecordID;
public Criteria(string _Table, string _FieldName, Guid _RecordID)
{
if(_Table=="User")
_Table="aUser";
Table=_Table;
FieldName=_FieldName;
RecordID=_RecordID;
}
}
#endregion
}//end Bool
#pragma warning restore 1591
}//end Boolspace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Data;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Class used to check for updates
/// </summary>
[Serializable]
public class CheckForUpdate
{
/// <summary>
/// Checks the AyaNova web server for available
/// updates to the product indicated
/// </summary>
/// <param name="sProductName">Name of product i.e. "AyaNovaFull", "AyaNovaLite"</param>
/// <param name="sVersion">Version to check (current version)</param>
/// <returns>url to update page or empty string if no update available</returns>
static public string UpdateUrl(string sProductName, string sVersion)
{
try
{
//download the update xml
WebClient wc = new WebClient();
Stream strm = wc.OpenRead("http://www.ayanova.com/updates/updates.xml");
DataSet ds = new DataSet();
ds.ReadXml(strm);
strm.Close();
//find matching product and version
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["Product"].ToString() == sProductName && dr["Version"].ToString() == sVersion)
return dr["UpgradeInfoUrl"].ToString();
}
return "";
}
catch (System.Net.WebException e)
{
return e.Message;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,522 @@
///////////////////////////////////////////////////////////
// ClientClientServiceRequestList.cs
// Implementation of Class ClientClientServiceRequestList
// CSLA type: Read only collection
// Created on: 9-Feb-2009
// Coded: John 9-Feb-2009
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of <see cref="ClientClientServiceRequestList.ClientClientServiceRequestListInfo"/> objects
///
/// </summary>
[Serializable]
public class ClientClientServiceRequestList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientClientServiceRequestListInfo
{
internal DateTime mCreated;
internal string mCreator;
internal string mTitle;
internal string mClient;
internal string mHeadOffice;
internal string mUnit;
internal int mWorkorder;
internal string mClientRef;
internal string mStatus;
internal string mPriority;
internal Guid mID;
internal Guid mWorkorderID;
internal string mRegion;
internal string mRequestedBy;
public DateTime LT_Common_Label_Created
{ get { return mCreated; } }
public string LT_Common_Label_Creator
{ get { return mCreator; } }
public string LT_O_ClientServiceRequest
{ get { return mTitle; } }
public string LT_O_Client { get { return mClient; } }
public string LT_O_HeadOffice { get { return mHeadOffice; } }
public string LT_Unit_Label_Serial { get { return mUnit; } }
public int LT_O_Workorder { get { return mWorkorder; } }
public string LT_ClientServiceRequest_Label_CustomerReferenceNumber
{ get { return this.mClientRef; } }
public string LT_ClientServiceRequest_Label_Status
{ get { return mStatus; } }
public string LT_ClientServiceRequest_Label_Priority
{ get { return mPriority; } }
public string LT_O_Region
{
get
{
return mRegion;
}
}
public Guid ID { get { return mID; } }
public Guid WorkorderID { get { return mWorkorderID; } }
public string LT_ClientServiceRequest_Label_RequestedBy
{ get { return this.mRequestedBy; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientClientServiceRequestListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end ClientServiceRequestListInfo
#endregion
#region Constructor
protected ClientClientServiceRequestList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientClientServiceRequestListInfo this[int Item]
{
get
{
return (ClientClientServiceRequestListInfo)List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (ClientClientServiceRequestListInfo child in List)
{
if (child.mID == ItemID) return child.ToString();
}
return "Missing: " + ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientClientServiceRequestListInfo obj)
{
foreach (ClientClientServiceRequestListInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Internal method used by list factory
/// </summary>
internal static ClientClientServiceRequestList Get(string Filter, int MaxRecords, List<Guid> IDList)
{
return (ClientClientServiceRequestList)DataPortal.Fetch(new Criteria(Filter,IDList, MaxRecords, Guid.Empty, Guid.Empty));
}
/// <summary>
/// Get all ClientServiceRequest (filtered by crit)
/// </summary>
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
/// <returns></returns>
public static ClientClientServiceRequestList GetList(string xmlCriteria)
{
return (ClientClientServiceRequestList)DataPortal.Fetch(new Criteria(xmlCriteria,null, -1, Guid.Empty, Guid.Empty));
}
/// <summary>
/// Get all ClientServiceRequest for a specified head office
/// (returns all requests for all clients under headOfficeID)
/// </summary>
/// <param name="headOfficeID"></param>
/// <returns></returns>
public static ClientClientServiceRequestList GetListForHeadOffice(Guid headOfficeID)
{
return (ClientClientServiceRequestList)DataPortal.Fetch(new Criteria("",null, -1, headOfficeID, Guid.Empty));
}
/// <summary>
/// Get all ClientServiceRequest for a specified client
/// </summary>
/// <param name="clientID"></param>
/// <returns></returns>
public static ClientClientServiceRequestList GetListForClient(Guid clientID)
{
return (ClientClientServiceRequestList)DataPortal.Fetch(new Criteria("",null, -1, Guid.Empty, clientID));
}
/// <summary>
/// Get list by items indicated in IDList
/// </summary>
/// <param name="IDList">Generic list of Guid's</param>
/// <returns></returns>
public static ClientClientServiceRequestList GetListFromIDList(List<Guid> IDList)
{
//case 556
//Handle empty list
if (IDList.Count == 0)
return new ClientClientServiceRequestList();
return (ClientClientServiceRequestList)DataPortal.Fetch(new Criteria("", IDList, -1, Guid.Empty, Guid.Empty));
}
/// <summary>
/// Return an empty list
/// used for initializing grid
/// </summary>
/// <returns></returns>
public static ClientClientServiceRequestList GetEmptyList()
{
return new ClientClientServiceRequestList();
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q = "";
if (crit.IDList != null)
{
//Case 556
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" WHERE ACLIENTSERVICEREQUEST.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(") ");
// By list of ID's, not regionalized
q = "SELECT " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION, " +//case 3182
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case 9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
sbIN.ToString() +
"ORDER BY ACLIENTSERVICEREQUEST.ACREATED DESC ";
dr = DBUtil.GetReaderFromSQLString(q);
}
else if (crit.ClientID != Guid.Empty)
{
//by specific client not regionalized.
q = "SELECT " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION, " + //case 3182
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case 9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
"WHERE ACLIENTSERVICEREQUEST.ACLIENTID=@ID " +
"ORDER BY ACLIENTSERVICEREQUEST.ACREATED DESC ";
dr = DBUtil.GetReaderFromSQLString(q, crit.ClientID);
}
else if (crit.HeadOfficeID != Guid.Empty)
{
//by specific head office not regionalized
q = "SELECT " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION, " + //case 3182
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case 9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
"WHERE ACLIENT.AHEADOFFICEID=@ID " +
"ORDER BY ACLIENT.ANAME, ACLIENTSERVICEREQUEST.ACREATED DESC ";
dr = DBUtil.GetReaderFromSQLString(q, crit.HeadOfficeID);
}
else
{
//Generic full list fetch (regionalized)
//************************************************************
q = "SELECT ~MAXRECS~ " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION, " +
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML, true) + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
q = DBUtil.AddRegionFilter(q, "aClient", "");//case 58
dr = DBUtil.GetReaderFromSQLString(q);
}
//************************************************************
string accepted = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Accepted");
string declined = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Declined");
string open = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Open");
string closed = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Closed");
string noturgent = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.NotUrgent");
string asap = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.ASAP");
string emergency = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.Emergency");
while (dr.Read())
{
//*******************************************
ClientClientServiceRequestListInfo info = new ClientClientServiceRequestListInfo();
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("ACREATED")).Date;
info.mCreator = dr.GetString("AINITIALS");
info.mID = dr.GetGuid("AID");
info.mTitle = dr.GetString("ATITLE");
info.mClient = dr.GetString("ACLIENTNAME");
//Case 58
info.mRegion = dr.GetString("aRegionName");
info.mHeadOffice = dr.GetString("AHEADOFFICENAME");
info.mUnit = Unit.UnitNameFormatter(dr.GetString("aModelNumber"), dr.GetString("AUNITMODELNAME"), dr.GetString("AUNITVENDORNAME"), dr.GetString("ASERIAL"),
dr.GetString("ADESCRIPTION"), AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat);
info.mWorkorderID = dr.GetGuid("AWORKORDERID");
info.mWorkorder = dr.GetInt32("ASERVICENUMBER");
info.mClientRef = dr.GetString("ACLIENTREF");
info.mRequestedBy = dr.GetString("AREQUESTEDBY");
ClientServiceRequestStatus csrstat=(ClientServiceRequestStatus)dr.GetInt16("ASTATUS");
switch (csrstat)
{
case ClientServiceRequestStatus.Accepted:
info.mStatus = accepted;
break;
case ClientServiceRequestStatus.Declined:
info.mStatus = declined;
break;
case ClientServiceRequestStatus.Open:
info.mStatus = open;
break;
case ClientServiceRequestStatus.Closed:
info.mStatus = closed;
break;
}
ClientServiceRequestPriority prior = (ClientServiceRequestPriority)dr.GetInt16("APRIORITY");
switch (prior)
{
case ClientServiceRequestPriority.ASAP:
info.mPriority = asap;
break;
case ClientServiceRequestPriority.Emergency:
info.mPriority = emergency;
break;
case ClientServiceRequestPriority.NotUrgent:
info.mPriority = noturgent;
break;
}
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public List<Guid> IDList;
public string CriteriaXML;
public int MaxRecords;
public Guid HeadOfficeID;
public Guid ClientID;
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords, Guid _HeadOfficeID, Guid _ClientID)
{
CriteriaXML = _CriteriaXML;
MaxRecords = _MaxRecords;
HeadOfficeID = _HeadOfficeID;
ClientID = _ClientID;
IDList = _IDList;
}
}
#endregion
}//end ClientClientServiceRequestList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class ClientExistanceChecker
// CSLA type: Read-only object
// Created on: 24-Sept-2007
// Object design: John
// Coded: 24-Sept-2007
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
//case 496
/// <summary>
///Confirms the presence of an Client
///in the AyaNova database
/// </summary>
[Serializable, EditorBrowsable(EditorBrowsableState.Never)]
internal class ClientExistanceChecker : ReadOnlyBase
{
#region Attributes
private bool mExists;
//case 1404 added for usefulness
internal Guid mClientID;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientExistanceChecker()
{
}
#endregion
#region Static methods
internal static ClientExistanceChecker ClientExists(string Name)
{
return (ClientExistanceChecker)DataPortal.Fetch(new Criteria(Guid.Empty, Name));
}
internal static bool ClientExists(Guid ID, string Name)
{
return ((ClientExistanceChecker)DataPortal.Fetch(new Criteria(ID, Name))).mExists;
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
if (!string.IsNullOrEmpty(crit.Name))
{
//case 1890
string CaseInsensitiveQueryString = string.Empty;
if(DBUtil.DB.DBType == DataBaseType.FireBird)
{
CaseInsensitiveQueryString = "SELECT AID FROM ACLIENT WHERE (Upper(ANAME) = Upper(@ANAME))";
}
else
{
//SQL server so for performance let SQL do the collating since it's easily set unlike firebird
CaseInsensitiveQueryString = "SELECT AID FROM ACLIENT WHERE (ANAME = @ANAME)";
}
DBCommandWrapper dbCommandWrapper = DBUtil.DB.GetSqlStringCommandWrapper(CaseInsensitiveQueryString);
dbCommandWrapper.AddInParameter("@ANAME", DbType.String, crit.Name);
//case 1404
mClientID=DBUtil.ToGuid(DBUtil.DB.ExecuteScalar(dbCommandWrapper));
if (mClientID == Guid.Empty)
this.mExists = false;
else
this.mExists = true;
}
else
{
if (DBUtil.ToGuid(DBUtil.GetScalarFromSQLString(
"SELECT aID FROM aClient WHERE " +
"(aID = @ID)", crit.ID
)) == Guid.Empty)
this.mExists = false;
else
this.mExists = true;
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public string Name;
public Criteria(Guid _ID, string _Name)
{
ID = _ID;
Name = _Name;
}
}
#endregion
}//end class
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,532 @@
///////////////////////////////////////////////////////////
// ClientGroup.cs
// Implementation of Class ClientGroup
// CSLA type: Editable Child
// Created on: 07-Jun-2004 8:41:14 AM
// Object design: Joyce
// Coded: John 07-Jul-2004
//reCoded as child 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Client group - for grouping clients for filtering, sorting and reporting purposes
/// </summary>
[Serializable]
public class ClientGroup : BusinessBase
{
#region Attributes
private bool bReadOnly;
private Guid mID;
private string mName=null;
private SmartDate mCreated;
private SmartDate mModified;
private bool mActive;
private Guid mCreator;
private Guid mModifier;
private string mDescription="";
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientGroup()
{
MarkAsChild();
//Set to read / write initially so that properties
//can be set
bReadOnly=false;
//New ID
mID = Guid.NewGuid();
//prebreak the rule
Name="";
Active=true;
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified=new SmartDate();
mCreator=Guid.Empty;
mModifier=Guid.Empty;
}
#endregion
#region Business properties
/// <summary>
///
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// Set/get client group name
/// </summary>
public string Name
{
get
{
return mName;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mName!=value)
{
mName = value;
BrokenRules.Assert("NameRequired",
"Error.Object.RequiredFieldEmpty,ClientGroup.Label.Name",
"Name",value.Length==0);
BrokenRules.Assert("NameLength",
"Error.Object.FieldLengthExceeded255,ClientGroup.Label.Name",
"Name",value.Length>255);
MarkDirty();
}
}
}
}
/// <summary>
/// Get /set active status of client group
/// If active = true then clientgroup is selectable for workorders etc
/// If active = false then clientgroup in not selectable, but history can be
/// viewed
/// </summary>
public bool Active
{
get
{
return mActive;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mActive!=value)
{
mActive = value;
MarkDirty();
}
}
}
}
/// <summary>
///
/// </summary>
public string Description
{
get
{
return mDescription;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mDescription!=value)
{
mDescription = value;
BrokenRules.Assert("DescriptionLength",
"Error.Object.FieldLengthExceeded255,ClientGroup.Label.Description","Description",value.Length>255);
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientGroup")
)
);
}
#endregion
#region System.Object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "ClientGroup" + mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
ClientGroup c=(ClientGroup)obj;
return mID==c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("ClientGroup"+mID).GetHashCode();
}
#endregion
#region Searching
/// <summary>
/// Returns a search result object based on search terms
/// for the ID specified
/// </summary>
/// <param name="ID"></param>
/// <param name="searchTerms"></param>
/// <returns></returns>
public static SearchResult GetSearchResult(Guid ID, string[]searchTerms)
{
if(AyaBizUtils.Right("Object.ClientGroup")<(int)SecurityLevelTypes.ReadOnly)
return new SearchResult();
SearchResult sr=new SearchResult();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString(
"SELECT aCreated, aModified, aCreator, aModifier, aName, " +
" aDescription FROM aClientGroup WHERE (aID = @ID)",ID);
if(!dr.Read())
return new SearchResult();//DBUtil.ThrowFetchError("SearchResult for ClientGroupID: " + ID.ToString());
sr.Description=dr.GetString("aName");
sb.Append(sr.Description);
sb.Append(" ");
sb.Append(dr.GetString("aDescription"));
sr.Created=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
sr.Modified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
sr.Creator=dr.GetGuid("aCreator");
sr.Modifier=dr.GetGuid("aModifier");
}
finally
{
if(dr!=null) dr.Close();
}
//Formulate results
ExtractAndRank er = new ExtractAndRank();
er.Process(sb.ToString().Trim(),searchTerms);
sr.Extract=er.Extract;
sr.Rank=er.Ranking;
sr.AncestorRootObjectID=ID;
sr.AncestorRootObjectType=RootObjectTypes.ClientGroup;
return sr;
}
#endregion
#region Static methods
/// <summary>
/// Create new ClientGroup
/// </summary>
internal static ClientGroup NewItem()
{
if(AyaBizUtils.Right("Object.ClientGroup")>(int)SecurityLevelTypes.ReadOnly)
{
ClientGroup c = new ClientGroup();
return c;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientGroup")));
}
/// <summary>
/// Fetch existing ClientGroup
/// </summary>
/// <param name="dr">Datareader</param>
internal static ClientGroup GetItem(SafeDataReader dr)
{
if(AyaBizUtils.Right("Object.ClientGroup")>(int)SecurityLevelTypes.NoAccess)
{
ClientGroup child = new ClientGroup();
child.Fetch(dr);
return child;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientGroup")));
}
/// <summary>
/// Retrieve internal ID from name.
///
/// </summary>
/// <param name="Name">Text value</param>
/// <returns>Guid ID value or Guid.Empty if no match</returns>
public static Guid GetIDFromName(string Name)
{
return GuidFetcher.GetItem("ACLIENTGROUP", "ANAME", Name);
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Populate this object from the values in the datareader passed to it
/// </summary>
/// <param name="dr"></param>
private void Fetch(SafeDataReader dr)
{
//Standard fields
mID=dr.GetGuid("aID");
mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator=dr.GetGuid("aCreator");
mModifier=dr.GetGuid("aModifier");
//ClientGroup fields
mActive=dr.GetBoolean("AACTIVE");
//Important: use property not internal field
//so that initial broken rule is unbroken on fetch
Name=dr.GetString("aName");
mDescription=dr.GetString("aDescription");
MarkOld();
//Get access rights level
bReadOnly=AyaBizUtils.Right("Object.ClientGroup")<(int)SecurityLevelTypes.ReadWrite;
}
#endregion fetch
#region Add / Update
internal void Update(IDbTransaction tr)
{
//No need to update if there is nothing changed
if(!this.IsDirty) return;
// If not a new record, check if record was modified
//by another user since original retrieval:
if(!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"aClientGroup");
#region Delete
if(IsDeleted)
{
if(!IsNew)
{
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aClientGroup WHERE aID = @ID;");
cmDelete.AddInParameter("@ID",DbType.Guid,this.mID);
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
DBUtil.RemoveKeywords(tr,RootObjectTypes.ClientGroup,this.mID);
//-----------------------------
}
MarkNew();
return;
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if(IsNew)//Add or update?
cm=DBUtil.GetCommandFromSQL(
"INSERT INTO aClientGroup (aID, AACTIVE, aName, aDescription, " +
"aCreated,aModified,aCreator,aModifier) VALUES (@ID,@Active, " +
"@Name,@Description,@Created,@Modified,@CurrentUserID,@CurrentUserID)"
);
else
cm=DBUtil.GetCommandFromSQL(
"UPDATE aClientGroup SET aID=@ID, AACTIVE=@Active, " +
"aName=@Name, aDescription=@Description, aModifier=@CurrentUserID, " +
"aModified=@Modified WHERE aID=@ID"
);
//ClientGroup fields
cm.AddInParameter("@Active",DbType.Boolean,mActive);
cm.AddLargeStringInParameter("@Description",mDescription);
cm.AddInParameter("@Name",DbType.String,mName);
//Standard fields
cm.AddInParameter("@ID",DbType.Guid,this.mID);
cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified));
DBUtil.DB.ExecuteNonQuery(cm, tr);
//Process keywords
DBUtil.ProcessKeywords(tr,this.mID,RootObjectTypes.ClientGroup,IsNew,AyaBizUtils.Break(false,
mName,mDescription
));
MarkOld();//db is now synched with object
//Successful update so
//change modification time to match
this.mModified.Date=dtModified;
#endregion
}
#endregion add/update
#endregion
#region Override IsValid / IsDirty
//Override base class version if there are child objects
/*
public override bool IsValid
{
get
{
return base.IsValid && ChildItem.IsValid;
}
}
public override bool IsDirty
{
get
{
return base.IsDirty || ChildItem.IsDirty;
}
}
*/
#endregion
}//end ClientGroup
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,303 @@
///////////////////////////////////////////////////////////
// ClientGroups.cs
// Implementation of Class ClientGroups
// CSLA type: Editable root collection
// Created on: 04-Nov-2004
// Object design: John
// Coded: John 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Editable root collection of <see cref="ClientGroup"/> objects
/// </summary>
[Serializable]
public class ClientGroups : BusinessCollectionBase
{
#region Constructor
//Private constructor prevents direction instantiation
private ClientGroups()
{
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "ClientGroup.Label.List";
}
}
/// <summary>
/// Retrieve ClientGroup by index
/// </summary>
/// <param name="Item">Index</param>
public ClientGroup this[int Item]
{
get
{
return (ClientGroup) List[Item];
}
}
//case 2072
/// <summary>
/// Retrieve ClientGroup by Id
/// </summary>
/// <param name="Id">ID of item</param>
public ClientGroup this[Guid Id]
{
get
{
foreach (ClientGroup child in List)
{
if (child.ID.Equals(Id)) return child;
}
return null;
}
}
/// <summary>
/// Remove ClientGroup by passing it in
/// </summary>
/// <param name="obj"></param>
public void Remove(ClientGroup obj)
{
List.Remove(obj);
}
/// <summary>
/// Remove by Guid value of ID
/// </summary>
/// <param name="ID"></param>
public void Remove(Guid ID)
{
ClientGroup delete = null;
foreach (ClientGroup child in List)
{
if (child.ID == ID)
{
delete = child;
break;
}
}
if (delete != null)
Remove(delete);
}
/// <summary>
/// Add a new ClientGroup to the collection
/// </summary>
public ClientGroup Add()
{
ClientGroup child=ClientGroup.NewItem();
List.Add(child);
return child;
}
/// <summary>
/// Add ClientGroup by passing it in
/// </summary>
/// <param name="obj"></param>
public void Add(ClientGroup obj)
{
List.Add(obj);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
protected override object OnAddNew()
{
ClientGroup child=ClientGroup.NewItem();
List.Add(child);
return child;
}
#endregion
#region Contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientGroup obj)
{
foreach (ClientGroup child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
//case 2072
/// <summary>
/// Check if item in collection by Id
/// </summary>
/// <param name="Id"></param>
public bool Contains(Guid Id)
{
foreach (ClientGroup child in List)
{
if (child.ID.Equals(Id)) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection
/// </summary>
/// <param name="obj"></param>
public bool ContainsDeleted(ClientGroup obj)
{
foreach (ClientGroup child in deletedList)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get item collection
/// </summary>
///
/// <returns></returns>
public static ClientGroups GetItems()
{
//in future specify criteria if filtering (e.g. filter by region)
ClientGroups col = new ClientGroups();
return (ClientGroups)DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Fetch children
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString("SELECT * FROM aClientGroup ORDER BY ANAME;");
while(dr.Read())
{
List.Add(ClientGroup.GetItem(dr));
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region Update
/// <summary>
/// Editable Root Collection Update
/// </summary>
protected override void DataPortal_Update()
{
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction tr = connection.BeginTransaction();
try
{
//update (thus deleting) any deleted child objects
foreach (ClientGroup child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (ClientGroup child in List)
{
child.Update(tr);
}
tr.Commit();
}
catch
{
tr.Rollback();
throw;//WAS: throw(ex);
}
}
}
#endregion update
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
//public string ObjectName;
public Criteria(/*string _ObjectName*/)
{
//ObjectName=_ObjectName;
}
}
#endregion
}//end ClientGroups
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,917 @@
///////////////////////////////////////////////////////////
// ClientList.cs
// Implementation of Class ClientList
// CSLA type: Read only collection
// Created on: 07-Jun-2004 8:41:14 AM
// Object design: Joyce
// Coded: Sept. 23rd 2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of <see cref="ClientList.ClientListInfo"/> objects representing <see cref="Client"/> objects.
///
/// </summary>
[Serializable]
public class ClientList : ReadOnlyCollectionBase {
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientListInfo
{
internal GridNameValueCellItem mClient;
internal GridNameValueCellItem mHeadOffice;
internal GridNameValueCellItem mClientGroup;
internal GridNameValueCellItem mDispatchZone;
internal GridNameValueCellItem mRegion;
//CONTACT FIELDS
internal string mContact;
internal string mEmail;
internal string mPhone1;
internal string mPhone2;
internal string mPhone3;
internal string mPhone4;
internal string mPhone5;
internal string mAccountNumber;
internal string mDeliveryAddress;
internal string mCity;
internal string mStateProv;
internal string mCountry;
internal string mPostal;
internal bool mActive;
internal string mWebAddress;
internal GridNameValueCellItem mWorkorder;
internal SmartDate mServiceDate;
internal bool mBillHeadOffice;
internal bool mUsesBanking;
//case 53 used internally and useful on grid display as well
internal bool mSendNotifications;
internal GridNameValueCellItem mContract;
internal SmartDate mContractExpires;
internal string mLatitude;
internal string mLongitude;
internal string mCountryCode;
internal decimal mHoursBalance;
internal decimal mIncidentsBalance;
internal decimal mCurrencyBalance;
[SqlColumnNameAttribute("aClient.aName", "aClient.aID"),
Display(DisplayType.Button,RootObjectType=RootObjectTypes.Client)]
public GridNameValueCellItem LT_O_Client
{
get
{
return mClient;
}
}
[SqlColumnNameAttribute("aHeadOffice.aName","aHeadOffice.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.HeadOffice, ShowInLite = false)]
public GridNameValueCellItem LT_O_HeadOffice
{
get
{
return mHeadOffice;
}
}
[SqlColumnNameAttribute("aRegion.aName","aRegion.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Region, ShowInLite = false)]
public GridNameValueCellItem LT_O_Region
{
get
{
return mRegion;
}
}
//CONTACT FIELDS
[Display(DisplayType.Text)]
public string LT_Client_Label_Contact
{get{return mContact;}}
[Display(DisplayType.URL_Email)]
public string LT_Client_Label_Email
{ get { return mEmail; } }
[Display(DisplayType.Text)]
public string LT_Client_Label_Phone1
{ get { return mPhone1; } }
[Display(DisplayType.Text)]
public string LT_Client_Label_Phone2
{ get { return mPhone2; } }
[Display(DisplayType.Text)]
public string LT_Client_Label_Phone3
{ get { return mPhone3; } }
[Display(DisplayType.Text)]
public string LT_Client_Label_Phone4
{ get { return mPhone4; } }
[Display(DisplayType.Text)]
public string LT_Client_Label_Phone5
{ get { return mPhone5; } }
[Display(DisplayType.Text)]
public string LT_Client_Label_AccountNumber
{
get
{
return mAccountNumber;
}
}
[SqlColumnNameAttribute("aClientGroup.aName","aClientGroup.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.ClientGroup, ShowInLite = false)]
public GridNameValueCellItem LT_O_ClientGroup
{
get
{
return mClientGroup;
}
}
[SqlColumnNameAttribute("aDispatchZone.aName","aDispatchZone.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.DispatchZone, ShowInLite = false)]
public GridNameValueCellItem LT_O_DispatchZone
{
get
{
return mDispatchZone;
}
}
[Display(DisplayType.Text)]
public string LT_Address_Label_DeliveryAddress
{
get
{
return mDeliveryAddress;
}
}
[Display(DisplayType.Text)]
public string LT_Address_Label_City
{
get
{
return mCity;
}
}
[Display(DisplayType.Text)]
public string LT_Address_Label_StateProv
{
get
{
return mStateProv;
}
}
[Display(DisplayType.Text)]
public string LT_Address_Label_Country
{
get
{
return mCountry;
}
}
[Display(DisplayType.Text)]
public string LT_Address_Label_Postal
{
get
{
return mPostal;
}
}
[Display(DisplayType.TrueFalse)]
public bool LT_Client_Label_Active
{
get
{
return mActive;
}
}
[Display(DisplayType.URL_Web)]
public string LT_Client_Label_WebAddress
{
get
{
return mWebAddress;
}
}
[SqlColumnNameAttribute("aWorkorderService.aServiceNumber","aClient.aLastWorkorderID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Workorder, CompareAs=CompareType.StringToInt32)]
public GridNameValueCellItem LT_UI_Label_LastWorkorder
{
get
{
return mWorkorder;
}
}
[SqlColumnNameAttribute("aClient.aLastServiceDate"), Display(DisplayType.DateTime)]
public object LT_UI_Label_LastServiceDate
{
get
{
return mServiceDate.DBValue;
}
}
[Display(DisplayType.TrueFalse, ShowInLite = false)]
public bool LT_Client_Label_UsesBanking
{
get
{
return mUsesBanking;
}
}
//case 53
[SqlColumnNameAttribute("aClient.aSendNotifications"), Display(DisplayType.TrueFalse, ShowInLite = false)]
public bool LT_Client_Label_Notification
{
get
{
return mSendNotifications;
}
}
[Display(DisplayType.TrueFalse, ShowInLite = false)]
public bool LT_Client_Label_BillHeadOffice
{
get
{
return this.mBillHeadOffice;
}
}
[SqlColumnNameAttribute("aContract.aName","aClient.aContractID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Contract, ShowInLite = false)]
public GridNameValueCellItem LT_O_Contract
{
get
{
return mContract;
}
}
[SqlColumnNameAttribute("aClient.aContractExpires"), Display(DisplayType.DateTime, ShowInLite = false)]
public object LT_Client_Label_ContractExpires
{
get
{
return mContractExpires.DBValue;
}
}
[Display(DisplayType.GeoCoordinate)]
public string LT_Address_Label_Latitude
{
get
{
return mLatitude;
}
}
[Display(DisplayType.GeoCoordinate)]
public string LT_Address_Label_Longitude
{
get
{
return mLongitude;
}
}
[Display(DisplayType.Text)]
public string LT_Address_Label_CountryCode
{
get
{
return mCountryCode;
}
}
[SqlColumnNameAttribute("HOURSBAL"), Display(DisplayType.DecimalNumber, ShowInLite = false)]
public decimal LT_ServiceBank_Label_HoursBalance
{
get
{
return mHoursBalance;
}
}
[SqlColumnNameAttribute("INCIDENTSBAL"), Display(DisplayType.DecimalNumber, ShowInLite = false)]
public decimal LT_ServiceBank_Label_IncidentsBalance
{
get
{
return mIncidentsBalance;
}
}
[SqlColumnNameAttribute("CURRENCYBAL"), Display(DisplayType.Currency, ShowInLite = false)]
public decimal LT_ServiceBank_Label_CurrencyBalance
{
get
{
return mCurrencyBalance;
}
}
//=======================================================================
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientListInfo obj)
{
return this.mClient.Value.Equals(obj.mClient.Value);
}
}//end ClientListInfo
#endregion
#region Constructor
protected ClientList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientListInfo this[int Item]
{
get
{
return (ClientListInfo) List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]{
get
{
foreach (ClientListInfo child in List)
{
if(child.mClient.Value==ItemID) return child.ToString();
}
return "Missing: "+ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientListInfo obj)
{
foreach (ClientListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ClientList";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return ClientListDetailed.ReportKey;
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
return RootObjectTypes.Client;
}
}
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "Client.Label.List";
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(ClientListInfo);
}
}
/// <summary>
/// Field that contains the ID of the objects
/// that are the basis of this list.
///
/// Used for compiling an ID list for reporting from user
/// selections in a grid.
/// </summary>
public static string IDField
{
get
{
return "LT_O_Client";
}
}
/// <summary>
/// Same as IDField but for detailed reports
/// </summary>
public static string IDFieldDetailed
{
get
{
return IDField;
}
}
#endregion
#region Static methods
/// <summary>
/// Internal method used by list factory
/// </summary>
/// <param name="Filter"></param>
/// <param name="MaxRecords"></param>
/// <param name="IDList"></param>
/// <returns></returns>
internal static ClientList Get(string Filter, int MaxRecords, List<Guid> IDList)
{
return (ClientList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
}
/// <summary>
/// Takes an xml column list and where criteria
/// and returns a list filtered and sorted accordingly
/// </summary>
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
/// <returns>list of <see cref="ClientList.ClientListInfo"/> objects</returns>
public static ClientList GetListByCriteria(string xmlCriteria)
{
return (ClientList) DataPortal.Fetch(new Criteria(xmlCriteria,null,-1));
}
/// <summary>
/// Takes a single ID and returns a "list" of one object
/// </summary>
/// <param name="ClientID">ID of Client object</param>
/// <returns>list of <see cref="ClientList.ClientListInfo"/> one object</returns>
public static ClientList GetListForSingleItem(Guid ClientID)
{
//Case 556
List<Guid> l = new List<Guid>();
l.Add(ClientID);
return GetListFromIDList(l);
}
/// <summary>
/// Get list by items indicated in IDList
/// </summary>
/// <param name="IDList">Generic list of Guid's</param>
/// <returns>list of <see cref="ClientList.ClientListInfo"/> objects</returns>
public static ClientList GetListFromIDList(List<Guid> IDList)
{
//case 556
//Handle empty list
if (IDList.Count == 0)
return new ClientList();
return (ClientList)DataPortal.Fetch(new Criteria("", IDList, -1));
}
/// <summary>
/// Return an empty list
/// used for initializing grid
/// </summary>
/// <returns></returns>
public static ClientList GetEmptyList()
{
return new ClientList();
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
//case 1748
//IDbTransaction tr = connection.BeginTransaction();
try
{
DBCommandWrapper cm = null;
if(crit.IDList!=null)
{
//Case 556
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" AND (aClient.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(")) ");
cm = DBUtil.DB.GetSqlStringCommandWrapper(
"SELECT ACLIENT.aID, ACLIENT.aName, ACLIENT.aModified, " +
" ACLIENT.AACTIVE, ACLIENT.aUsesBanking, ACLIENT.aSendNotifications, " +
" ACLIENT.aBillHeadOffice, ACLIENT.aWebAddress, " +
" ACLIENT.aDispatchZoneID, ACLIENT.aClientGroupID, " +
" ACLIENT.aLastWorkorderID, " +
" ACLIENT.ACONTACT, ACLIENT.AEMAIL, ACLIENT.APHONE1, ACLIENT.APHONE2, ACLIENT.APHONE3, ACLIENT.APHONE4, ACLIENT.APHONE5, " +
" ACLIENT.aLastServiceDate, (SELECT TOP 1 aSBANK.aHoursBalance " +
"FROM aServiceBank aSBANK WHERE aSBANK.AAPPLIESTOROOTOBJECTID " +
"= ACLIENT.aID ORDER " +
"BY aSBANK.aCreated DESC) AS HOURSBAL, (SELECT TOP 1 aSBANK.aIncidentsBalance " +
"FROM aServiceBank aSBANK WHERE " +
"aSBANK.AAPPLIESTOROOTOBJECTID = ACLIENT.aID ORDER " +
"BY aSBANK.aCreated DESC) AS INCIDENTSBAL, (SELECT " +
"TOP 1 aSBANK.aCurrencyBalance FROM aServiceBank aSBANK " +
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = ACLIENT.aID " +
"ORDER BY aSBANK.aCreated DESC) AS CURRENCYBAL, " +
" ACLIENT.AACCOUNTNUMBER, " +
" aHeadOffice.aName AS aHeadOfficeName, " +
" aHeadOffice.aID AS aHeadOfficeID, " +
" aDispatchZone.aName AS aDispatchZoneName, ACLIENT.aRegionID, " +
" aRegion.aName AS aRegionName, " +
" aClientGroup.aName AS aClientGroupName, AADDRESS.aDeliveryAddress, " +
" AADDRESS.aCity, AADDRESS.aStateProv, " +
" AADDRESS.aCountry, AADDRESS.aPostal, " +
" AADDRESS.AADDRESSTYPE, AADDRESS.aLongitude, " +
" AADDRESS.aLatitude, aWorkorderService.aServiceNumber, " +
" ACLIENT.aContractID, " +
" aContract.aName AS aContractName, ACLIENT.aContractExpires, " +
" AADDRESS.aCountryCode " +
"FROM aClient ACLIENT LEFT OUTER JOIN aContract " +
"ON ACLIENT.aContractID = aContract.aID " +
"LEFT OUTER JOIN aHeadOffice ON aHeadOffice.aID " +
"= ACLIENT.aHeadOfficeID LEFT OUTER " +
"JOIN aWorkorderService ON ACLIENT.aLastWorkorderID " +
"= aWorkorderService.aWorkorderID LEFT " +
"OUTER JOIN AADDRESS ON AADDRESS.aRootObjectID " +
"= ACLIENT.aID LEFT OUTER JOIN aRegion " +
"ON ACLIENT.aRegionID = aRegion.aID LEFT " +
"OUTER JOIN aClientGroup ON ACLIENT.aClientGroupID " +
"= aClientGroup.aID LEFT OUTER JOIN aDispatchZone " +
"ON ACLIENT.aDispatchZoneID = aDispatchZone.aID " +
"WHERE (AADDRESS.AADDRESSTYPE IS NULL OR AADDRESS.AADDRESSTYPE = 2) "
+ sbIN.ToString() + " ORDER BY ACLIENT.ANAME ");
}
else
{
string sCurrencySelect=
" (SELECT TOP 1 aSBANK.aCurrencyBalance FROM aServiceBank aSBANK " +
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = ACLIENT.aID " +
"ORDER BY aSBANK.aCreated DESC) ";
string sIncidentsSelect=
" (SELECT TOP 1 aSBANK.aIncidentsBalance FROM aServiceBank aSBANK " +
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = ACLIENT.aID " +
"ORDER BY aSBANK.aCreated DESC) ";
string sHoursSelect=
" (SELECT TOP 1 aSBANK.aHoursBalance FROM aServiceBank aSBANK " +
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = ACLIENT.aID " +
"ORDER BY aSBANK.aCreated DESC) ";
string where=AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,false);
where = where.Replace("CURRENCYBAL", sCurrencySelect);
where = where.Replace("INCIDENTSBAL", sIncidentsSelect);
where = where.Replace("HOURSBAL", sHoursSelect);
string order=AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
//case 1184
//this was *hammering* performance and turns out to be unnecessary
//as both MSSQL and Firebird will accept the aliases in the ORDER BY clause instead
//of the full subquery.
//NOTE that neither accepts the alias in the WHERE clause though
//order=order.Replace("CURRENCYBAL",sCurrencySelect);
//order=order.Replace("INCIDENTSBAL",sIncidentsSelect);
//order=order.Replace("HOURSBAL",sHoursSelect);
order=order.Replace("aClient.","ACLIENT.");
string q = "SELECT ~MAXRECS~ ACLIENT.aID, ACLIENT.aName, ACLIENT.aModified, " +
" ACLIENT.AACTIVE, ACLIENT.aUsesBanking, ACLIENT.aSendNotifications, " +
" ACLIENT.aBillHeadOffice, ACLIENT.aWebAddress, " +
" ACLIENT.aDispatchZoneID, ACLIENT.aClientGroupID, " +
" ACLIENT.aLastWorkorderID, " +
" ACLIENT.ACONTACT, ACLIENT.AEMAIL, ACLIENT.APHONE1, ACLIENT.APHONE2, ACLIENT.APHONE3, ACLIENT.APHONE4, ACLIENT.APHONE5, " +
" ACLIENT.aLastServiceDate, (SELECT TOP 1 aSBANK.aHoursBalance " +
"FROM aServiceBank aSBANK WHERE aSBANK.AAPPLIESTOROOTOBJECTID " +
"= ACLIENT.aID ORDER " +
"BY aSBANK.aCreated DESC) AS HOURSBAL, (SELECT TOP 1 aSBANK.aIncidentsBalance " +
"FROM aServiceBank aSBANK WHERE " +
"aSBANK.AAPPLIESTOROOTOBJECTID = ACLIENT.aID ORDER " +
"BY aSBANK.aCreated DESC) AS INCIDENTSBAL, (SELECT " +
"TOP 1 aSBANK.aCurrencyBalance FROM aServiceBank aSBANK " +
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = ACLIENT.aID " +
"ORDER BY aSBANK.aCreated DESC) AS CURRENCYBAL, " +
" ACLIENT.AACCOUNTNUMBER, " +
" aHeadOffice.aName AS aHeadOfficeName, " +
" aHeadOffice.aID AS aHeadOfficeID, " +
" aDispatchZone.aName AS aDispatchZoneName, ACLIENT.aRegionID, " +
" aRegion.aName AS aRegionName, " +
" aClientGroup.aName AS aClientGroupName, AADDRESS.aDeliveryAddress, " +
" AADDRESS.aCity, AADDRESS.aStateProv, " +
" AADDRESS.aCountry, AADDRESS.aPostal, " +
" AADDRESS.AADDRESSTYPE, AADDRESS.aLongitude, " +
" AADDRESS.aLatitude, aWorkorderService.aServiceNumber, " +
" ACLIENT.aContractID, " +
" aContract.aName AS aContractName, ACLIENT.aContractExpires, " +
" AADDRESS.aCountryCode " +
"FROM aClient LEFT OUTER JOIN aContract " +
"ON ACLIENT.aContractID = aContract.aID " +
"LEFT OUTER JOIN aHeadOffice ON aHeadOffice.aID " +
"= ACLIENT.aHeadOfficeID LEFT OUTER " +
"JOIN aWorkorderService ON ACLIENT.aLastWorkorderID " +
"= aWorkorderService.aWorkorderID LEFT " +
"OUTER JOIN AADDRESS ON AADDRESS.aRootObjectID " +
"= ACLIENT.aID LEFT OUTER JOIN aRegion " +
"ON ACLIENT.aRegionID = aRegion.aID LEFT " +
"OUTER JOIN aClientGroup ON ACLIENT.aClientGroupID " +
"= aClientGroup.aID LEFT OUTER JOIN aDispatchZone " +
"ON ACLIENT.aDispatchZoneID = aDispatchZone.aID " +
"WHERE (AADDRESS.AADDRESSTYPE IS NULL OR AADDRESS.AADDRESSTYPE = 2) \r\n ";
//Can't use regular addregion because of subqueries so just insert it here
q = q+DBUtil.RegionAClientClause;//case 58
q = q + where + " \r\n ";
q=q+order;
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
}
cm.AddInParameter("@TRUE",DbType.Boolean,true);
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm/*case 1748,tr*/));
while (dr.Read())
{
ClientListInfo info=new ClientListInfo();
info.mClient=new GridNameValueCellItem(
dr.GetGuid("aID"),
dr.GetString("aName"),
RootObjectTypes.Client);
info.mHeadOffice=new GridNameValueCellItem(
dr.GetGuid("aHeadOfficeID"),
dr.GetString("aHeadOfficeName"),
RootObjectTypes.HeadOffice);
info.mDispatchZone = new GridNameValueCellItem(
dr.GetGuid("aDispatchZoneID"),
dr.GetString("aDispatchZoneName"),
RootObjectTypes.DispatchZone);
info.mClientGroup = new GridNameValueCellItem(
dr.GetGuid("aClientGroupID"),
dr.GetString("aClientGroupName"),
RootObjectTypes.ClientGroup);
info.mRegion = new GridNameValueCellItem(
dr.GetGuid("aRegionID"),
dr.GetString("aRegionName"),
RootObjectTypes.Region);
info.mWorkorder=new GridNameValueCellItem(
dr.GetGuid("aLastWorkorderID"),
dr.GetInt32("aServiceNumber")==0?"":dr.GetInt32("aServiceNumber").ToString(),
RootObjectTypes.Workorder);
info.mServiceDate=DBUtil.ToLocal(dr.GetSmartDate("aLastServiceDate"));
info.mContact = dr.GetString("ACONTACT");
info.mEmail = dr.GetString("AEMAIL");
info.mPhone1 = dr.GetString("APHONE1");//.Replace('\t','~');
info.mPhone2 = dr.GetString("APHONE2");
info.mPhone3 = dr.GetString("APHONE3");
info.mPhone4 = dr.GetString("APHONE4");
info.mPhone5 = dr.GetString("APHONE5");
info.mAccountNumber=dr.GetString("AACCOUNTNUMBER");
info.mDeliveryAddress=dr.GetString("aDeliveryAddress");
info.mCity=dr.GetString("aCity");
info.mStateProv=dr.GetString("aStateProv");
info.mCountry=dr.GetString("aCountry");
info.mPostal=dr.GetString("aPostal");
info.mActive=dr.GetBoolean("AACTIVE");
info.mWebAddress=dr.GetString("aWebAddress");
info.mUsesBanking=dr.GetBoolean("aUsesBanking");
info.mSendNotifications = dr.GetBoolean("aSendNotifications");
info.mBillHeadOffice=dr.GetBoolean("aBillHeadOffice");
info.mContract = new GridNameValueCellItem(
dr.GetGuid("aContractID"),
dr.GetString("aContractName"),
RootObjectTypes.Contract);
info.mContractExpires=DBUtil.ToLocal(dr.GetSmartDate("aContractExpires"));
//no need to call if lat/lon = 0 which is likely very often
decimal dLat = dr.GetDecimal("aLatitude");
info.mLatitude=dLat!=0?Address.LatitudeToString(dLat):"";
decimal dLon = dr.GetDecimal("aLongitude");
info.mLongitude=dLon!=0?Address.LongitudeToString(dLon):"";
info.mCountryCode=dr.GetString("aCountryCode");
info.mHoursBalance=dr.GetDecimal("HOURSBAL");
info.mIncidentsBalance=dr.GetDecimal("INCIDENTSBAL");
info.mCurrencyBalance=dr.GetDecimal("CURRENCYBAL");
InnerList.Add(info);
}
}
finally
{
if(dr!=null) dr.Close();
//tr.Rollback();
}
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public List<Guid> IDList;
public string CriteriaXML;
public int MaxRecords;
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords)
{
CriteriaXML = _CriteriaXML;
IDList = _IDList;
MaxRecords = _MaxRecords;
}
}
#endregion
}//end ClientList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,576 @@
///////////////////////////////////////////////////////////
// ClientNote.cs
// Implementation of Class ClientNote
// CSLA type: Editable Child
// Created on: 07-Jun-2004 8:41:15 AM
// Object design: Joyce
// Coded: John July 9 2004
// Re-coded: as editable child by John Nov 11 2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Note for a <see cref="Client"/> object stored in the Client's <see cref="ClientNotes"/> collection
/// </summary>
[Serializable]
public class ClientNote : BusinessBase {
#region Attributes
private bool bReadOnly;
private Guid mID;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
private SmartDate mNoteDate;
private string mNotes="";
private Guid mClientNoteTypeID=Guid.Empty;
private Guid mClientID;
private Guid mRootObjectID;
private RootObjectTypes mRootObjectType;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientNote()
{
MarkAsChild();
//Set to read / write initially so that properties
//can be set
bReadOnly=false;
//New ID
mID = Guid.NewGuid();
mNoteDate = new SmartDate(DBUtil.CurrentWorkingDateTime);
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified = new SmartDate();
//Case 30
//mCreator = Guid.Empty;
mCreator = User.CurrentThreadUserID;
mModifier = Guid.Empty;
}
#endregion
#region Business properties
/// <summary>
/// Get internal id number Read only property because it's set internally, not
/// externally
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
///
/// </summary>
public string Notes
{
get
{
return mNotes;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mNotes!=value)
{
mNotes = value;
MarkDirty();
}
}
}
}
/// <summary>
/// User selectable data and time of note
/// </summary>
public object NoteDate
{
get
{
return mNoteDate.DBValue;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if (!AyaBizUtils.SmartDateEquals(mNoteDate, value)) //Case 298
{
mNoteDate.DBValue = value;
MarkDirty();
}
}
}
}
/// <summary>
/// <see cref="Client"/> ID
/// </summary>
public Guid ClientID
{
get
{
return mClientID;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mClientID!=value)
{
mClientID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// DEPRECATED: DO NOT USE
/// </summary>
public RootObjectTypes RootObjectType
{
get
{
return mRootObjectType;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mRootObjectType!=value)
{
mRootObjectType = value;
MarkDirty();
}
}
}
}
/// <summary>
/// DEPRECATED: DO NOT USE
/// </summary>
public Guid RootObjectID //NOTE: 2/19/2015 THIS IS NOT ACTUALLY USED, flagging as deprecated
{
get
{
return mRootObjectID;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mRootObjectID!=value)
{
mRootObjectID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// <see cref="ClientNoteType"/> ID
/// </summary>
public Guid ClientNoteTypeID
{
get
{
return mClientNoteTypeID;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mClientNoteTypeID!=value)
{
mClientNoteTypeID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("ClientNote.Label.List")
)
);
}
#endregion
#region System.Object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "ClientNote" + mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
ClientNote c=(ClientNote)obj;
return mID==c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("ClientNote" + mID).GetHashCode();
}
#endregion
#region Searching
/// <summary>
/// Returns a search result object based on search terms
/// for the ID specified
/// </summary>
/// <param name="ID"></param>
/// <param name="searchTerms"></param>
/// <returns></returns>
public static SearchResult GetSearchResult(Guid ID, string[]searchTerms)
{
if(AyaBizUtils.Right("Object.Client")<(int)SecurityLevelTypes.ReadOnly)
return new SearchResult();
SearchResult sr=new SearchResult();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
//=================================================================
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString(
"SELECT aClientNote.aCreated, aClientNote.aModified, " +
" aClientNote.aCreator, aClientNote.aModifier, " +
" aClientNote.aNotes, aClient.aID AS aClientID, aClient.aRegionID, " +
" aClient.aName FROM aClientNote LEFT JOIN " +
"aClient ON aClientNote.aClientID = aClient.aID " +
"WHERE (aClientNote.aID = @ID)",ID);
if(!dr.Read())
return new SearchResult();//DBUtil.ThrowFetchError("SearchResult for ClientNoteID: " + ID.ToString());
if (!AyaBizUtils.InYourRegion(dr.GetGuid("aRegionID"))) return new SearchResult();//case 58
sr.Description=dr.GetString("aName");
sb.Append(dr.GetString("aNotes"));
sr.AncestorRootObjectID=dr.GetGuid("aClientID");
sr.AncestorRootObjectType=RootObjectTypes.Client;
sr.Created=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
sr.Modified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
sr.Creator=dr.GetGuid("aCreator");
sr.Modifier=dr.GetGuid("aModifier");
}
finally
{
if(dr!=null) dr.Close();
}
//=================================================================
//Formulate results
ExtractAndRank er = new ExtractAndRank();
er.Process(sb.ToString().Trim(),searchTerms);
sr.Extract=er.Extract;
sr.Rank=er.Ranking;
return sr;
}
#endregion
#region Static methods
/// <summary>
/// Get new object
/// </summary>
/// <returns></returns>
internal static ClientNote NewItem()
{
if(AyaBizUtils.Right("Object.Client")>(int)SecurityLevelTypes.ReadOnly)
return new ClientNote();
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("ClientNote.Label.List")));
}
/// <summary>
///
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
public static ClientNote GetItem(SafeDataReader dr)
{
if(AyaBizUtils.Right("Object.Client")>(int)SecurityLevelTypes.NoAccess)
{
ClientNote child = new ClientNote();
child.Fetch(dr);
return child;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("ClientNote.Label.List")));
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Populate this object from the values in the datareader passed to it
/// </summary>
/// <param name="dr"></param>
private void Fetch(SafeDataReader dr)
{
//Standard fields
mID=dr.GetGuid("aID");
mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator=dr.GetGuid("aCreator");
mModifier=dr.GetGuid("aModifier");
//ClientNote fields
mClientID=dr.GetGuid("aClientID");
mClientNoteTypeID=dr.GetGuid("aClientNoteTypeID");
mNoteDate=DBUtil.ToLocal(dr.GetSmartDate("aNoteDate"));
mNotes=dr.GetString("aNotes");
mRootObjectID=dr.GetGuid("aRootObjectID");
mRootObjectType=(RootObjectTypes)dr.GetInt16("aRootObjectType");
//Get access rights level
bReadOnly=AyaBizUtils.Right("Object.Client")<(int)SecurityLevelTypes.ReadWrite;
MarkOld();
}
#endregion fetch
#region Update
/// <summary>
///
/// </summary>
/// <param name="tr"></param>
internal void Update(IDbTransaction tr)
{
//No need to update if there is nothing changed
if(!this.IsDirty) return;
// If not a new record, check if record was modified
//by another user since original retrieval:
if(!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"aClientNote");
#region Delete
if(IsDeleted)
{
if(!IsNew)
{
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aClientNote WHERE aID = @ID;");
cmDelete.AddInParameter("@ID",DbType.Guid,this.mID);
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
DBUtil.RemoveKeywords(tr,RootObjectTypes.ClientNote,this.mID);
//-----------------------------
}
MarkNew();
return;
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if(IsNew)//Add or update?
cm=DBUtil.GetCommandFromSQL(
"INSERT INTO aClientNote (aID, aNoteDate, aNotes, aClientNoteTypeID, " +
"aClientID, aRootObjectID,aRootObjectType, " +
"aCreated,aModified,aCreator,aModifier) VALUES (@ID,@NoteDate, " +
"@Notes,@ClientNoteTypeID,@ClientID,@RootObjectID, " +
"@RootObjectType,@Created,@Modified,@CurrentUserID,@CurrentUserID)"
);
else
cm=DBUtil.GetCommandFromSQL(
"UPDATE aClientNote SET aID=@ID, aNoteDate=@NoteDate, " +
"aNotes=@Notes, aClientNoteTypeID=@ClientNoteTypeID, " +
"aClientID=@ClientID, aRootObjectID=@RootObjectID, " +
" aRootObjectType=@RootObjectType, aModifier=@CurrentUserID, " +
" aModified=@Modified WHERE aID=@ID"
);
//ClientNote fields
cm.AddInParameter("@NoteDate",DbType.DateTime,DBUtil.ToUTC(mNoteDate).DBValue);
cm.AddLargeStringInParameter("@Notes",mNotes);
cm.AddInParameter("@ClientNoteTypeID",DbType.Guid,mClientNoteTypeID);
cm.AddInParameter("@ClientID",DbType.Guid,mClientID);
cm.AddInParameter("@RootObjectID",DbType.Guid,mRootObjectID);
cm.AddInParameter("@RootObjectType",DbType.Int16,(int)mRootObjectType);
//Standard fields
cm.AddInParameter("@ID",DbType.Guid,this.mID);
cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified));
DBUtil.DB.ExecuteNonQuery(cm, tr);
//Process keywords
DBUtil.ProcessKeywords(tr,this.mID,RootObjectTypes.ClientNote,IsNew,AyaBizUtils.Break(false,
mNotes
));
MarkOld();//db is now synched with object
//Successful update so
//change modification time to match
this.mModified.Date=dtModified;
#endregion
}
#endregion update
#endregion
}//end ClientNote
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,647 @@
///////////////////////////////////////////////////////////
// ClientNoteEr.cs
// Implementation of Class ClientNoteEr
// CSLA type: Editable Root
// Created on: Feb 24 2015
// Object design: John
// Coded: John Feb 24 2015
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Note for a <see cref="Client"/> editable root version
/// </summary>
[Serializable]
public class ClientNoteEr : BusinessBase
{
#region Attributes
private bool bReadOnly;
private Guid mID;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
private SmartDate mNoteDate;
private string mNotes = string.Empty;
private Guid mClientNoteTypeID = Guid.Empty;
private Guid mClientID;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientNoteEr()
{
//Set to read / write initially so that properties
//can be set
bReadOnly = false;
//New ID
mID = Guid.NewGuid();
mNoteDate = new SmartDate(DBUtil.CurrentWorkingDateTime);
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified = new SmartDate();
//Case 30
//mCreator = Guid.Empty;
mCreator = User.CurrentThreadUserID;
mModifier = Guid.Empty;
}
#endregion
#region Business properties
/// <summary>
/// Get internal id number Read only property because it's set internally, not
/// externally
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
///
/// </summary>
public string Notes
{
get
{
return mNotes;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mNotes != value)
{
mNotes = value;
MarkDirty();
}
}
}
}
/// <summary>
/// User selectable data and time of note
/// </summary>
public object NoteDate
{
get
{
return mNoteDate.DBValue;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (!AyaBizUtils.SmartDateEquals(mNoteDate, value)) //Case 298
{
mNoteDate.DBValue = value;
MarkDirty();
}
}
}
}
/// <summary>
/// <see cref="Client"/> ID
/// </summary>
public Guid ClientID
{
get
{
return mClientID;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mClientID != value)
{
mClientID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// <see cref="ClientNoteType"/> ID
/// </summary>
public Guid ClientNoteTypeID
{
get
{
return mClientNoteTypeID;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mClientNoteTypeID != value)
{
mClientNoteTypeID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// Object is editable if current user is not read only
/// </summary>
public bool IsEditable
{
get
{
if (bReadOnly) return false;
return true;
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNote")
)
);
}
#endregion
#region System.Object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "ClientNoteEr" + mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if (obj == null || GetType() != obj.GetType()) return false;
ClientNoteEr c = (ClientNoteEr)obj;
return mID == c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("ClientNoteEr" + mID).GetHashCode();
}
#endregion
#region Searching
/// <summary>
/// Returns a search result object based on search terms
/// for the ID specified
/// </summary>
/// <param name="ID"></param>
/// <param name="searchTerms"></param>
/// <returns></returns>
public static SearchResult GetSearchResult(Guid ID, string[] searchTerms)
{
if (AyaBizUtils.Right("Object.Client") < (int)SecurityLevelTypes.ReadOnly)
return new SearchResult();
SearchResult sr = new SearchResult();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
//=================================================================
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString(
"SELECT aClientNote.aCreated, aClientNote.aModified, " +
" aClientNote.aCreator, aClientNote.aModifier, " +
" aClientNote.aNotes, aClient.aID AS aClientID, aClient.aRegionID, " +
" aClient.aName FROM aClientNote LEFT JOIN " +
"aClient ON aClientNote.aClientID = aClient.aID " +
"WHERE (aClientNote.aID = @ID)", ID);
if (!dr.Read())
return new SearchResult();//DBUtil.ThrowFetchError("SearchResult for ClientNoteID: " + ID.ToString());
if (!AyaBizUtils.InYourRegion(dr.GetGuid("aRegionID"))) return new SearchResult();//case 58
sr.Description = dr.GetString("aName");
sb.Append(dr.GetString("aNotes"));
sr.AncestorRootObjectID = dr.GetGuid("aClientID");
sr.AncestorRootObjectType = RootObjectTypes.Client;
sr.Created = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
sr.Modified = DBUtil.ToLocal(dr.GetSmartDate("aModified"));
sr.Creator = dr.GetGuid("aCreator");
sr.Modifier = dr.GetGuid("aModifier");
}
finally
{
if (dr != null) dr.Close();
}
//=================================================================
//Formulate results
ExtractAndRank er = new ExtractAndRank();
er.Process(sb.ToString().Trim(), searchTerms);
sr.Extract = er.Extract;
sr.Rank = er.Ranking;
return sr;
}
#endregion
#region Static methods
/// <summary>
///
/// </summary>
/// <param name="clientID"></param>
/// <returns></returns>
public static ClientNoteEr NewItem(Guid clientID)
{
if (clientID == Guid.Empty)
throw new System.ApplicationException("CLIENT ID NOT VALID");
ClientNoteEr c;
if (AyaBizUtils.Right("Object.Client") > (int)SecurityLevelTypes.ReadOnly)
{
c = new ClientNoteEr();
c.mClientID = clientID;
return c;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNote")));
}
/// <summary>
///
/// </summary>
/// <param name="_ID"></param>
/// <returns></returns>
public static ClientNoteEr GetItem(Guid _ID)
{
if (AyaBizUtils.Right("Object.Client") > (int)SecurityLevelTypes.NoAccess)
return (ClientNoteEr)DataPortal.Fetch(new Criteria(_ID));
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNote")));
}
/// <summary>
///
/// </summary>
/// <param name="_ID"></param>
public static void DeleteItem(Guid _ID)
{
if (AyaBizUtils.Right("Object.Client") > (int)SecurityLevelTypes.ReadWrite)
DataPortal.Delete(new Criteria(_ID));
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToDelete"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNote")));
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
///
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
//set to false to load items initially
bReadOnly = false;
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString("SELECT * FROM ACLIENTNOTE WHERE AID=@ID;", crit.ID);
if (!dr.Read())
DBUtil.ThrowFetchError("ClientNote ID: " + crit.ID.ToString());
//Standard fields
mID = dr.GetGuid("aID");
mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified = DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator = dr.GetGuid("aCreator");
mModifier = dr.GetGuid("aModifier");
//ClientNote fields
mClientID = dr.GetGuid("aClientID");
mClientNoteTypeID = dr.GetGuid("aClientNoteTypeID");
mNoteDate = DBUtil.ToLocal(dr.GetSmartDate("aNoteDate"));
mNotes = dr.GetString("aNotes");
}
finally
{
if (dr != null) dr.Close();
}
MarkOld();
//Get access rights level
bReadOnly = AyaBizUtils.Right("Object.Client") < (int)SecurityLevelTypes.ReadWrite;
}
#endregion fetch
#region Update
/// <summary>
///
/// </summary>
protected override void DataPortal_Update()
{
// If not a new record, check if record was modified
//by another user since original retrieval:
if (!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date, this.mID, "aClientNote");
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if (IsNew)//Add or update?
cm = DBUtil.GetCommandFromSQL(
"INSERT INTO aClientNote (aID, aNoteDate, aNotes, aClientNoteTypeID, " +
"aClientID, " +
"aCreated,aModified,aCreator,aModifier) VALUES (@ID,@NoteDate, " +
"@Notes,@ClientNoteTypeID,@ClientID, " +
"@Created,@Modified,@CurrentUserID,@CurrentUserID)"
);
else
cm = DBUtil.GetCommandFromSQL(
"UPDATE aClientNote SET aID=@ID, aNoteDate=@NoteDate, " +
"aNotes=@Notes, aClientNoteTypeID=@ClientNoteTypeID, " +
"aClientID=@ClientID, aModifier=@CurrentUserID, " +
" aModified=@Modified WHERE aID=@ID"
);
//ClientNote fields
cm.AddInParameter("@NoteDate", DbType.DateTime, DBUtil.ToUTC(mNoteDate).DBValue);
cm.AddLargeStringInParameter("@Notes", mNotes);
cm.AddInParameter("@ClientNoteTypeID", DbType.Guid, mClientNoteTypeID);
cm.AddInParameter("@ClientID", DbType.Guid, mClientID);
//Standard fields
cm.AddInParameter("@ID", DbType.Guid, this.mID);
cm.AddInParameter("@CurrentUserID", DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created", DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified", DbType.DateTime, DBUtil.ToUTC(dtModified));
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cm, transaction);
//Process keywords
DBUtil.ProcessKeywords(transaction, this.mID, RootObjectTypes.ClientNote, IsNew,
AyaBizUtils.Break(false, mNotes)
);
MarkOld();//db is now synched with object
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
//Successful update so
//change modification time to match
this.mModified.Date = dtModified;
}
#endregion
}
#endregion update
#region Delete
/// <summary>
/// Remove a ClientServiceRequest record .
/// </summary>
/// <param Title="Criteria"></param>
protected override void DataPortal_Delete(object Criteria)
{
Criteria crit = (Criteria)Criteria;
ClientNoteEr rq = ClientNoteEr.GetItem(crit.ID);
if (!rq.IsEditable)
throw new System.ApplicationException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Object.NotDeleteable"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNote")
)
);
rq = null;
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM ACLIENTNOTE WHERE AID = @ID;");
cmDelete.AddInParameter("@ID", DbType.Guid, crit.ID);
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cmDelete, transaction);
DBUtil.RemoveKeywords(transaction, RootObjectTypes.ClientNote, crit.ID);
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
}
}
#endregion delete
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID = _ID;
}
}
#endregion
}//end ClientNoteEr
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,191 @@
///////////////////////////////////////////////////////////
// ClientNoteList.cs
// Implementation of Class ClientNoteList
// CSLA type: Read only collection
// Created on: 18-FEB-2015
// Object design: John
// Coded: 18-FEB-2015
///////////////////////////////////////////////////////////
//created for case 1975
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of <see cref="ClientNoteList.ClientNoteListInfo"/> objects representing <see cref="ClientNote"/> objects.
/// Used for display in responsive interface (AyaNova RI)
/// </summary>
[Serializable]
public class ClientNoteList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientNoteListInfo
{
internal string mCreator;
internal string mNoteDate;
internal string mNotes;
internal string mClientNoteType;
internal decimal mTotal;
internal Guid mId;
public string Creator
{ get { return mCreator; } }
public string NoteDate
{ get { return mNoteDate; } }
public string Notes
{ get { return mNotes; } }
public string ClientNoteType
{ get { return mClientNoteType; } }
public decimal Total
{ get { return mTotal; } }
public Guid Id
{ get { return mId; } }
}//end ClientNoteListInfo
#endregion
#region Constructor
protected ClientNoteList()
{
}
#endregion
#region Business properties and methods
///// <summary>
///// Get item by index
///// </summary>
///// <param name="Item"></param>
//public ClientNoteListInfo this[int Item]
//{
// get
// {
// return (ClientNoteListInfo)List[Item];
// }
//}
#endregion
#region Static methods
//case 1975
/// <summary>
/// Get MaxRecords Client notes for specified client (-1 for all)
/// </summary>
public static ClientNoteList GetList(Guid ClientID, int MaxRecords)
{
return (ClientNoteList)DataPortal.Fetch(new Criteria(ClientID, MaxRecords));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
decimal dTotal=DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT COUNT(AID) FROM ACLIENTNOTE WHERE ACLIENTNOTE.ACLIENTID=@ID", crit.ClientID));
string q = "SELECT ~MAXRECS~ ACLIENTNOTE.AID AS ACLIENTNOTEID, ACLIENTNOTE.ANOTEDATE, ACLIENTNOTE.ANOTES, " +
" AUSER.AFIRSTNAME, AUSER.ALASTNAME, " +
" AUSER.AINITIALS, AUSER.AEMPLOYEENUMBER, " +
" ACLIENTNOTETYPE.ANAME AS ACLIENTNOTETYPENAME " +
" FROM ACLIENTNOTE " +
" INNER JOIN AUSER ON (ACLIENTNOTE.ACREATOR = AUSER.AID)" +
" LEFT OUTER JOIN ACLIENTNOTETYPE ON (ACLIENTNOTE.ACLIENTNOTETYPEID=ACLIENTNOTETYPE.AID) " +
" WHERE ACLIENTNOTE.ACLIENTID=@ID " +
" ORDER BY ANOTEDATE DESC";
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
dr = DBUtil.GetReaderFromSQLString(q, crit.ClientID);
//************************************************************
bool bFirst = true;
while (dr.Read())
{
//*******************************************
ClientNoteListInfo info = new ClientNoteListInfo();
info.mId = dr.GetGuid("ACLIENTNOTEID");
info.mCreator = User.NameFormatter(dr.GetString("aFirstName"), dr.GetString("aLastName"),
dr.GetString("aInitials"), dr.GetString("aEmployeeNumber"), "",
AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat);
info.mClientNoteType = dr.GetString("ACLIENTNOTETYPENAME");
info.mNoteDate = DBUtil.ToLocal(dr.GetSmartDate("ANOTEDATE")).ToString();
info.mNotes = dr.GetString("ANOTES");
if (bFirst)
{
info.mTotal = dTotal;
bFirst = false;
}
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ClientID;
public int MaxRecords;
public Criteria(Guid _ClientID, int _MaxRecords)
{
ClientID = _ClientID;
MaxRecords = _MaxRecords;
}
}
#endregion
}//end ClientNoteList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,373 @@
///////////////////////////////////////////////////////////
// ClientNoteType.cs
// Implementation of Class ClientNoteType
// CSLA type: Editable Child
// Created on: 07-Jun-2004 8:41:15 AM
// Object design: Joyce
// Coded: John 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// i.e phone, fax, followup etc
/// </summary>
[Serializable]
public class ClientNoteType : BusinessBase
{
#region Attributes
private bool bReadOnly;
private Guid mID;
private string mName=null;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientNoteType()
{
//Set as child object
MarkAsChild();
//Set to read / write initially so that properties
//can be set
bReadOnly=false;
//New ID
mID = Guid.NewGuid();
//prebreak the rule
Name="";
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified=new SmartDate();
mCreator=Guid.Empty;
mModifier=Guid.Empty;
}
#endregion
#region Business properties
/// <summary>
/// Get internal id number Read only property because it's set internally, not
/// externally
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// Set/get Name of item
///
/// </summary>
public string Name
{
get
{
return mName;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mName!=value)
{
mName = value;
BrokenRules.Assert("NameRequired",
"Error.Object.RequiredFieldEmpty,ClientNoteType.Label.Name","Name",value.Length==0);
BrokenRules.Assert("NameLength",
"Error.Object.FieldLengthExceeded255,ClientNoteType.Label.Name","Name",value.Length>255);
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNoteType")
)
);
}
#endregion
#region System.Object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "ClientNoteType" + mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
ClientNoteType c=(ClientNoteType)obj;
return mID==c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("ClientNoteType" + mID).GetHashCode();
}
#endregion
#region Static methods
/// <summary>
/// Get new object
/// </summary>
/// <returns></returns>
internal static ClientNoteType NewItem()
{
if(AyaBizUtils.Right("Object.Client")>(int)SecurityLevelTypes.ReadOnly)
{
ClientNoteType c = new ClientNoteType();
return c;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNoteType")));
}
/// <summary>
///
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
public static ClientNoteType GetItem(SafeDataReader dr)
{
if(AyaBizUtils.Right("Object.Client")>(int)SecurityLevelTypes.NoAccess)
{
ClientNoteType child = new ClientNoteType();
child.Fetch(dr);
return child;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNoteType")));
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Populate this object from the values in the datareader passed to it
/// </summary>
/// <param name="dr"></param>
private void Fetch(SafeDataReader dr)
{
//Standard fields
mID=dr.GetGuid("aID");
mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator=dr.GetGuid("aCreator");
mModifier=dr.GetGuid("aModifier");
//ClientNoteType fields
//Important: use property not internal field
//so that initial broken rule is unbroken on fetch
Name=dr.GetString("aName");
MarkOld();
//Get access rights level
bReadOnly=AyaBizUtils.Right("Object.Client")<(int)SecurityLevelTypes.ReadWrite;
}
#endregion fetch
#region Update
/// <summary>
///
/// </summary>
/// <param name="tr"></param>
internal void Update(IDbTransaction tr)
{
//No need to update if there is nothing changed
if(!this.IsDirty) return;
// If not a new record, check if record was modified
//by another user since original retrieval:
if(!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"aClientNoteType");
#region Delete
if(IsDeleted)
{
if(!IsNew)
{
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aClientNoteType WHERE aID = @ID;");
cmDelete.AddInParameter("@ID",DbType.Guid,this.mID);
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
//-----------------------------
}
MarkNew();
return;
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if(IsNew)//Add or update?
cm=DBUtil.GetCommandFromSQL(
"INSERT INTO aClientNoteType (aID, aName, aCreated,aModified,aCreator,aModifier) " +
"VALUES (@ID,@Name,@Created,@Modified,@CurrentUserID,@CurrentUserID)"
);
else
cm=DBUtil.GetCommandFromSQL(
"UPDATE aClientNoteType SET aID=@ID, aName=@Name, aModifier=@CurrentUserID, " +
"aModified=@Modified WHERE " +
"aID=@ID"
);
//ClientNoteType fields
cm.AddInParameter("@Name",DbType.String,mName);
//Standard fields
cm.AddInParameter("@ID",DbType.Guid,this.mID);
cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified));
DBUtil.DB.ExecuteNonQuery(cm, tr);
MarkOld();//db is now synched with object
//Successful update so
//change modification time to match
this.mModified.Date=dtModified;
#endregion
}
#endregion update
#endregion
}//end ClientNoteType
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,253 @@
///////////////////////////////////////////////////////////
// ClientNoteTypes.cs
// Implementation of Class ClientNoteTypes
// CSLA type: Editable root collection
// Created on: 04-Nov-2004
// Object design: John
// Coded: John 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Editable Root collection of <see cref="ClientNoteType"/> objects
/// </summary>
[Serializable]
public class ClientNoteTypes : BusinessCollectionBase
{
#region Constructor
//Private constructor prevents direction instantiation
private ClientNoteTypes()
{
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "ClientNoteType.Label.List";
}
}
/// <summary>
/// Retrieve ClientNoteType by index
/// </summary>
/// <param name="Item">Index</param>
public ClientNoteType this[int Item]
{
get
{
return (ClientNoteType) List[Item];
}
}
/// <summary>
/// Remove ClientNoteType by passing it in
/// </summary>
/// <param name="obj"></param>
public void Remove(ClientNoteType obj)
{
List.Remove(obj);
}
/// <summary>
/// Add a new ClientNoteType to the collection
/// </summary>
public ClientNoteType Add()
{
ClientNoteType child=ClientNoteType.NewItem();
List.Add(child);
return child;
}
/// <summary>
/// Add ClientNoteType by passing it in
/// </summary>
/// <param name="obj"></param>
public void Add(ClientNoteType obj)
{
List.Add(obj);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
protected override object OnAddNew()
{
ClientNoteType child=ClientNoteType.NewItem();
List.Add(child);
return child;
}
#endregion
#region Contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientNoteType obj)
{
foreach (ClientNoteType child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection
/// </summary>
/// <param name="obj"></param>
public bool ContainsDeleted(ClientNoteType obj)
{
foreach (ClientNoteType child in deletedList)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get item collection
/// </summary>
///
/// <returns></returns>
public static ClientNoteTypes GetItems()
{
//in future specify criteria if filtering (e.g. filter by region)
ClientNoteTypes col = new ClientNoteTypes();
return (ClientNoteTypes)DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Fetch children
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString("SELECT * FROM aClientNoteType ORDER BY ANAME;");
while(dr.Read())
{
List.Add(ClientNoteType.GetItem(dr));
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion fetch
#region Update
/// <summary>
/// Editable Root Collection Update
/// </summary>
protected override void DataPortal_Update()
{
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction tr = connection.BeginTransaction();
try
{
//update (thus deleting) any deleted child objects
foreach (ClientNoteType child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (ClientNoteType child in List)
{
child.Update(tr);
}
tr.Commit();
}
catch
{
tr.Rollback();
throw;//WAS: throw(ex);
}
}
}
#endregion update
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
//public string ObjectName;
public Criteria(/*string _ObjectName*/)
{
//ObjectName=_ObjectName;
}
}
#endregion
}//end ClientNoteTypes
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,425 @@
///////////////////////////////////////////////////////////
// ClientNotes.cs
// Implementation of Class ClientNotes
// CSLA type: Editable root collection
// Created on: 11-Nov-2004
// Object design: John
// Coded: John 11-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Collection of <see cref="ClientNote"/> objects attached to a <see cref="Client"/>
/// </summary>
[Serializable]
public class ClientNotes : BusinessCollectionBase
{
#region Constructor
//Private constructor prevents direction instantiation
private ClientNotes()
{
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "ClientNote.Label.List";
}
}
/// <summary>
/// Reference <see cref="ClientNote"/> by index
/// </summary>
/// <param name="Item">Index</param>
public ClientNote this[int Item]
{
get
{
return (ClientNote) List[Item];
}
}
/// <summary>
/// Reference <see cref="ClientNote"/> from collection by ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ClientNote this[Guid id]
{
get
{
foreach (ClientNote child in List)
{
if (child.ID == id)
return child;
}
return null;
}
}
/// <summary>
/// Reference <see cref="ClientNote"/> in collection based on a string representation of it's Guid value
/// </summary>
/// <param name="sid"></param>
/// <returns></returns>
public ClientNote this[string sid]
{
get{
return this[new Guid(sid)];
}
}
/// <summary>
/// Remove <see cref="ClientNote"/> by passing it in
/// </summary>
/// <param name="obj"></param>
public void Remove(ClientNote obj)
{
List.Remove(obj);
}
/// <summary>
/// Remove <see cref="ClientNote"/> from collection by ID value
/// </summary>
/// <param name="ID"></param>
public void Remove(Guid ID)
{
ClientNote delete = null;
foreach (ClientNote child in List)
{
if (child.ID == ID)
{
delete = child;
break;
}
}
if (delete != null)
Remove(delete);
}
/// <summary>
/// Remove <see cref="ClientNote"/> from collection based on a string representation of it's ID
/// </summary>
/// <param name="sID"></param>
public void Remove(string sID)
{
Remove(new Guid(sID));
}
/// <summary>
/// Add a new ClientNote to the collection
/// </summary>
public ClientNote Add()
{
ClientNote child=ClientNote.NewItem();
List.Add(child);
return child;
}
/// <summary>
/// Add ClientNote by passing it in
/// </summary>
/// <param name="obj"></param>
public void Add(ClientNote obj)
{
List.Add(obj);
}
// protected override object OnAddNew()
// {
// ClientNote child=ClientNote.NewItem();
// List.Add(child);
// return child;
// }
#endregion
#region Contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientNote obj)
{
foreach (ClientNote child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection
/// </summary>
/// <param name="obj"></param>
public bool ContainsDeleted(ClientNote obj)
{
foreach (ClientNote child in deletedList)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ClientNoteList";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return "";
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
return RootObjectTypes.ClientNote;
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(ClientNote);
}
}
/// <summary>
/// Field that contains the ID of the objects
/// that are the basis of this list.
///
/// Used for compiling an ID list for reporting from user
/// selections in a grid.
/// </summary>
public static string IDField
{
get
{
return "ID";
}
}
/// <summary>
/// Same as IDField but for detailed reports
/// </summary>
public static string IDFieldDetailed
{
get
{
return IDField;
}
}
#endregion
#region Static methods
/// <summary>
/// Get item collection
/// </summary>
///
/// <returns></returns>
public static ClientNotes GetItems(Guid ClientID)
{
ClientNotes col = new ClientNotes();
return (ClientNotes)DataPortal.Fetch(new Criteria(ClientID, null));
}
/// <summary>
/// Get list by items indicated in IDList
/// </summary>
/// <param name="IDList">Generic list of Guid's</param>
/// <returns></returns>
public static ClientNotes GetListFromIDList(List<Guid> IDList)
{
//case 274
//Handle empty list
if (IDList.Count == 0)
return new ClientNotes();
return (ClientNotes)DataPortal.Fetch(new Criteria(Guid.Empty, IDList));
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Fetch children
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
if (crit.IDList != null)
{
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append("SELECT * FROM ACLIENTNOTE WHERE aClientNote.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(") order by anotedate desc");
dr = DBUtil.GetReaderFromSQLString(sbIN.ToString());
}
else
{
dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aClientNote WHERE aClientID=@ID order by anotedate desc", crit.ClientID);
}
while (dr.Read())
{
List.Add(ClientNote.GetItem(dr));
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion fetch
#region Update
/// <summary>
/// Editable Root Collection Update
/// </summary>
protected override void DataPortal_Update()
{
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction tr = connection.BeginTransaction();
try
{
//update (thus deleting) any deleted child objects
foreach (ClientNote child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (ClientNote child in List)
{
child.Update(tr);
}
tr.Commit();
}
catch
{
tr.Rollback();
throw;//WAS: throw(ex);
}
}
}
#endregion update
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ClientID;
public List<Guid> IDList;
public Criteria(Guid _ClientID, List<Guid> _IDList)
{
ClientID=_ClientID;
IDList = _IDList;
}
}
#endregion
}//end ClientNotes
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,321 @@
///////////////////////////////////////////////////////////
// ClientNotesReportList.cs
// Implementation of Class ClientNotesReportList case 274
// CSLA type: Read only collection
// Created on: 3-Nov-2009
// Object design: John
// Coded: 3-Nov-2009
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of <see cref="ClientNotesReportList.ClientNotesReportListInfo"/> objects representing ClientNotes used for reporting (printing) client notes
///
///
/// </summary>
[Serializable]
public class ClientNotesReportList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientNotesReportListInfo
{
internal Guid mID;
internal string mCreator;
internal SmartDate mCreated;
internal SmartDate mNoteDate;
internal string mNotes;
internal string mClientNoteType;
internal string mClient;
public Guid ID
{
get
{
return mID;
}
}
public object LT_Common_Label_Created
{
get
{
return mCreated.DBValue;
}
}
public string LT_Common_Label_Creator
{
get
{
return mCreator;
}
}
public object LT_ClientNote_Label_NoteDate
{
get
{
return mNoteDate.DBValue;
}
}
public string LT_ClientNote_Label_Notes
{
get
{
return mNotes;
}
}
public string LT_ClientNoteType_Label_Name
{
get
{
return mClientNoteType;
}
}
public string LT_O_Client
{
get
{
return mClient;
}
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientNotesReportListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end ClientNotesReportListInfo
#endregion
#region Constructor
protected ClientNotesReportList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientNotesReportListInfo this[int Item]
{
get
{
return (ClientNotesReportListInfo) List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (ClientNotesReportListInfo child in List)
{
if(child.mID==ItemID) return child.ToString();
}
return "Missing: "+ItemID.ToString();
}
}
#endregion
#region Reporting
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ClientNote";
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientNotesReportListInfo obj)
{
foreach (ClientNotesReportListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get list of notes for client id passed in
/// </summary>
/// <param name="ClientID"></param>
/// <returns>list of <see cref="ClientNotesReportList.ClientNotesReportListInfo"/> objects</returns>
public static ClientNotesReportList GetList(Guid ClientID)
{
return (ClientNotesReportList) DataPortal.Fetch(new Criteria(ClientID,null));
}
/// <summary>
/// Get list of notes by items indicated in IDList
/// </summary>
/// <param name="IDList">Generic list of ClientNote.ID Guid's</param>
/// <returns>list of <see cref="ClientNotesReportList.ClientNotesReportListInfo"/> objects</returns>
public static ClientNotesReportList GetListFromIDList(List<Guid> IDList)
{
//case 274
//Handle empty list
if (IDList.Count == 0)
return new ClientNotesReportList();
return (ClientNotesReportList)DataPortal.Fetch(new Criteria(Guid.Empty, IDList));
}
#endregion
#region DAL DATA ACCESS
/// <summary>
/// Fetch children
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
//cached user name list
UserPickList users = UserPickList.GetList(false);
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q = "SELECT ACLIENTNOTE.*, ACLIENT.ANAME AS ACLIENTNAME, " +
"ACLIENTNOTETYPE.ANAME AS ACLIENTNOTETYPENAME " +
"FROM ACLIENTNOTE " +
"LEFT OUTER JOIN ACLIENT ON (ACLIENT.AID = ACLIENTNOTE.ACLIENTID) " +
"LEFT OUTER JOIN ACLIENTNOTETYPE ON (ACLIENTNOTETYPE.AID = ACLIENTNOTE.ACLIENTNOTETYPEID) ";
if (crit.IDList != null)
{
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" WHERE aClientNote.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(") ");
dr = DBUtil.GetReaderFromSQLString(q + sbIN.ToString() + " ORDER BY ANOTEDATE DESC");
}
else
{
dr = DBUtil.GetReaderFromSQLString(q + " WHERE aClientID=@ID ORDER BY ANOTEDATE DESC", crit.ClientID);
}
while (dr.Read())
{
ClientNotesReportListInfo info = new ClientNotesReportListInfo();
info.mID = dr.GetGuid("AID");
info.mCreator = users[dr.GetGuid("ACREATOR")];
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("ACREATED"));
info.mNoteDate = DBUtil.ToLocal(dr.GetSmartDate("ANOTEDATE"));
info.mNotes = dr.GetString("ANOTES");
info.mClientNoteType = dr.GetString("ACLIENTNOTETYPENAME");
info.mClient = dr.GetString("ACLIENTNAME");
InnerList.Add(info);
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ClientID;
public List<Guid> IDList;
public Criteria(Guid _ClientID, List<Guid> _IDList)
{
ClientID = _ClientID;
IDList = _IDList;
}
}
#endregion
}//end ClientNotesReportList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,194 @@
///////////////////////////////////////////////////////////
// ClientNotificationList.cs
// Implementation of Class ClientNotificationList
// CSLA type: Read only collection
// Created on: 11-Dec-2008
// Object design: John
// Coded: 11-Dec-2008
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// List of ClientNotifications for processing by GenProcessClientNotifications
///
/// </summary>
[Serializable]
internal class ClientNotificationList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct ClientNotificationListInfo
{
internal Guid mID;
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientNotificationListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end ClientNotificationListInfo
#endregion
#region Constructor
protected ClientNotificationList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientNotificationListInfo this[int Item]
{
get
{
return (ClientNotificationListInfo) List[Item];
}
}
/// <summary>
/// Returns ClientNotificationListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public ClientNotificationListInfo this[Guid ItemID]
{
get
{
foreach (ClientNotificationListInfo child in List)
{
if(child.mID==ItemID) return child;
}
throw new ArgumentException("ClientNotificationList: ID not found:\r\n"+ItemID.ToString());
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientNotificationListInfo obj)
{
foreach (ClientNotificationListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all
/// </summary>
/// <returns></returns>
public static ClientNotificationList GetList()
{
return (ClientNotificationList) DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
//case 1163
//SmartDate rightnow=new SmartDate(DateTime.Now);
DateTime dtNowUTC = DateTime.Now.ToUniversalTime();
dr=DBUtil.GetReaderFromSQLString(
//************************************************************
"SELECT AID, ADELIVERAFTER FROM ACLIENTNOTIFYEVENT ORDER BY ACREATED"
//************************************************************
)
;
while(dr.Read())
{
//*******************************************
ClientNotificationListInfo info=new ClientNotificationListInfo();
info.mID=dr.GetGuid("aID");
//case 1163 - this kind of stuff should go exclusively by utc no local involved at all
//if(DBUtil.ToLocal(dr.GetSmartDate("ADELIVERAFTER")).Date > rightnow.Date) continue;
if (dr.GetSmartDate("ADELIVERAFTER").Date > dtNowUTC) continue;
InnerList.Add(info);
//*******************************************
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
// public bool Regional;
public Criteria(/*bool _Regional*/ )
{
//Regional = _Regional;
}
}
#endregion
}//end ClientNotificationList
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,875 @@
///////////////////////////////////////////////////////////
// ClientNotifyEvent.cs
// Implementation of Class ClientNotifyEvent
// CSLA type: Editable Root
// Created on: 10-December-2008
// Object design: John
// Coded: 10-December-2008
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Collections.Generic;
//using Chilkat;
using System.Text;
using System.Text.RegularExpressions;
//case 53
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// ClientNotifyEvent object
/// Insert and manage client notification events
///
/// </summary>
[Serializable]
public class ClientNotifyEvent : BusinessBase
{
#pragma warning disable 1591
#region Attributes
private Guid mID;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
private Guid mClientID = Guid.Empty;
private SmartDate mDeliverAfter;
private byte[] mContent=null;
private int mObjectSize;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientNotifyEvent()
{
//New ID
mID = Guid.NewGuid();
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified = new SmartDate();
mCreator = Guid.Empty;
mModifier = Guid.Empty;
//case 1163
mDeliverAfter = new SmartDate(DBUtil.CurrentWorkingDateTime - TimeSpan.FromSeconds(30));//deliver after 30 seconds ago just in case
ClientID = Guid.Empty;
mObjectSize = 0;
}
#endregion
#region Business properties
/// <summary>
/// Internal Unique GUID value of ClientNotifyEvent record in database
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// AyaNova object ID
/// </summary>
public Guid ClientID
{
get
{
return mClientID;
}
set
{
if (mClientID != value)
{
mClientID = value;
BrokenRules.Assert("ClientID", "Error.Object.RequiredFieldEmpty,ClientNotifyEvent.Label.ClientID", "ClientID", value == Guid.Empty);
MarkDirty();
}
}
}
/// <summary>
/// Deliver after date, used only
/// for follow up client notifications
/// </summary>
public DateTime DeliverAfter
{
get
{
return mDeliverAfter.Date;
}
set
{
mDeliverAfter.Date = value;
}
}
/// <summary>
/// Get the MIME content
///
/// </summary>
public string GetContentAsString
{
get
{
return Encoding.Unicode.GetString(mContent);
}
}
public System.IO.MemoryStream GetContent()
{
//if (mContent.Length == mObjectSize)//it's not compressed so just return it
return new System.IO.MemoryStream(mContent);
// else//it *is* compressed so decompress and return
// return new System.IO.MemoryStream(AyaBizUtils.Decompress(mContent));
}
/// <summary>
/// Set the content based on string
/// </summary>
/// <param name="sContent"></param>
public void SetContent(string sContent)
{
using (MemoryStream ms = new MemoryStream(System.Text.Encoding.Unicode.GetBytes(sContent)))
{
SetContent(ms);
}
}
public void SetContent(System.IO.Stream mStream)
{
mObjectSize = (int)mStream.Length;
mStream.Position = 0;
byte[] bData = new byte[mStream.Length];
mStream.Read(bData, 0, (int)mStream.Length);
mContent = bData;//just store, compression not needed here
//mContent = AyaBizUtils.Compress(bData);
////did it compress smaller?
////don't want to store uncompressible files that are actually larger after compression
//if (mContent.Length >= mObjectSize)
//{
// //yup, it's bigger compressed, so store the uncompressed version instead
// mContent = bData;
//}
MarkDirty();
}
/// <summary>
/// Byte array set content
/// </summary>
/// <param name="bData"></param>
public void SetContent(byte[] bData)
{
mObjectSize = (int)bData.LongLength;
//mStream.Position = 0;
//byte[] bData = new byte[mStream.Length];
//mStream.Read(bData, 0, (int)mStream.Length);
// mContent = AyaBizUtils.Compress(bData);
//did it compress smaller?
//don't want to store uncompressible files that are actually larger after compression
//if (mContent.Length >= mObjectSize)
//{
//yup, it's bigger compressed, so store the uncompressed version instead
mContent = bData;
//}
MarkDirty();
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.ClientNotifyEvent")
)
);
}
#endregion
#region System.object overrides
public override string ToString()
{
return "ClientNotifyEvent" + mID.ToString();
}
///
/// <param name="obj"></param>
public override bool Equals(Object obj)
{
if (obj == null || GetType() != obj.GetType()) return false;
ClientNotifyEvent c = (ClientNotifyEvent)obj;
return mID == c.mID;
}
public override int GetHashCode()
{
return ("ClientNotifyEvent" + mID).GetHashCode();
}
#endregion
#region Static methods
/// <summary>
/// Overload
/// </summary>
/// <param name="type"></param>
/// <param name="ClientID"></param>
/// <param name="WorkorderStatusID"></param>
/// <param name="wonumber"></param>
/// <param name="contact"></param>
/// <param name="cref"></param>
/// <param name="csrdetails"></param>
/// <param name="WorkorderID"></param>
/// <param name="wosummary"></param>
/// <param name="csrtitle"></param>
internal static void ProcessEvent(ClientNotifyEventType type, Guid ClientID, Guid WorkorderStatusID,
string wonumber, string contact, string cref, string csrdetails, Guid WorkorderID, string wosummary, string csrtitle)
{
ProcessEvent(type, ClientID, WorkorderStatusID, wonumber, contact, cref, csrdetails, WorkorderID, wosummary, csrtitle, WorkorderQuoteStatusTypes.NotSet);
}
/// <summary>
/// Generate a new client notification if appropriate
/// </summary>
/// <param name="type"></param>
/// <param name="ClientID"></param>
/// <param name="WorkorderStatusID"></param>
/// <param name="wonumber"></param>
/// <param name="contact"></param>
/// <param name="cref"></param>
/// <param name="csrdetails"></param>
/// <param name="WorkorderID"></param>
/// <param name="wosummary"></param>
/// <param name="csrtitle"></param>
/// <param name="quoteStatus"></param>
internal static void ProcessEvent(ClientNotifyEventType type, Guid ClientID, Guid WorkorderStatusID,
string wonumber, string contact, string cref, string csrdetails, Guid WorkorderID,string wosummary, string csrtitle, WorkorderQuoteStatusTypes quoteStatus)
{
ClientList cl = ClientList.GetListForSingleItem(ClientID);
if (cl.Count < 1) return;
if (!cl[0].LT_Client_Label_Notification) return;
if (string.IsNullOrEmpty(cl[0].LT_Client_Label_Email)) return;
Region r = Region.GetItem(cl[0].LT_O_Region.Value);
if (!r.ClientNotification) return;
string sTemplate = "";
//case 1151
Guid gAttachReportID = Guid.Empty;
switch (type)
{
case ClientNotifyEventType.CSRAccepted:
{
if (!r.NotifyCSRAccepted) return;
sTemplate = r.NotifyCSRMSG;
}
break;
case ClientNotifyEventType.CSRRejected:
{
if (!r.NotifyCSRRejected) return;
sTemplate = r.NotifyCSRRejectMSG;
}
break;
case ClientNotifyEventType.NewWorkorder:
{
if (!r.NotifyNewWO) return;
sTemplate = r.NotifyNewWOMSG;
}
break;
case ClientNotifyEventType.WorkorderClosed:
{
if (!r.NotifyWOClosed) return;
sTemplate = r.NotifyWOClosedMSG;
//added for case 1151
if (r.NotifyWOClosedAttachWO)
gAttachReportID = r.NotifyWOClosedRPT;
}
break;
case ClientNotifyEventType.WorkorderFollowUp:
{
if (!r.NotifyWOFollowUp) return;
sTemplate = r.NotifyWOFollowUpMSG;
}
break;
case ClientNotifyEventType.WorkorderStatusSet:
{
//if (!r.NotifyWOStatus) return;
//if (WorkorderStatusID == Guid.Empty || WorkorderStatusID != r.NotifyWOStatusID) return;
//sTemplate = r.NotifyWOStatMSG;
//case 1151
if (WorkorderStatusID == Guid.Empty) return;
System.Text.StringBuilder stb = new StringBuilder();
foreach (RegionWoStatusNotifyItem rwsni in r.WoStatusNotifyItems)
{
if (rwsni.Active && rwsni.NotifyWOStatusID == WorkorderStatusID)
{
sTemplate=rwsni.NotifyWOStatMSG;
gAttachReportID = rwsni.WoReportID;
break;
}
}
}
break;
//case 1499
case ClientNotifyEventType.QuoteStatusSet:
{
if (!r.NotifyQuoteStatus) return;
if (r.NotifyQuoteStatusType != quoteStatus) return;
sTemplate = r.NotifyQuoteStatMSG;
if (r.NotifyQuoteStatusRPT!=Guid.Empty)
gAttachReportID = r.NotifyQuoteStatusRPT;
}
break;
}
if(string.IsNullOrEmpty(sTemplate)) return;
#region Template processing
WorkorderStatusPickList statpick = WorkorderStatusPickList.GetList();
//fill in template
//Match all keywords and substitute queried data for them
MatchCollection matches = Regex.Matches(sTemplate, @"\[(.|\n)*?\]", RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled);
foreach (Match KeyMatch in matches)
{
switch (KeyMatch.Value)
{
case "[WorkorderService.Label.ServiceNumber]":
sTemplate=sTemplate.Replace(KeyMatch.Value, wonumber);
break;
case "[O.WorkorderStatus]":
if (statpick.Contains(WorkorderStatusID))
sTemplate = sTemplate.Replace(KeyMatch.Value, statpick[WorkorderStatusID].Name);
else
sTemplate = sTemplate.Replace(KeyMatch.Value, "");
break;
case "[Workorder.Label.CustomerContactName]":
sTemplate = sTemplate.Replace(KeyMatch.Value, contact);
break;
case "[Workorder.Label.CustomerReferenceNumber]":
sTemplate = sTemplate.Replace(KeyMatch.Value, cref);
break;
case "[Region.Label.WBIUrl]":
sTemplate = sTemplate.Replace(KeyMatch.Value, r.WBIUrl);
break;
case "[Client.Label.Name]":
sTemplate = sTemplate.Replace(KeyMatch.Value, cl[0].LT_O_Client.Display);
break;
case "[ClientServiceRequest.Label.Details]":
sTemplate = sTemplate.Replace(KeyMatch.Value, csrdetails);
break;
case "[Workorder.Label.Summary]":
sTemplate = sTemplate.Replace(KeyMatch.Value, wosummary);
break;
case "[ClientServiceRequest.Label.Title]":
sTemplate = sTemplate.Replace(KeyMatch.Value, csrtitle);
break;
//case 1499
case "[WorkorderQuote.Label.QuoteNumber]":
sTemplate = sTemplate.Replace(KeyMatch.Value, wonumber);
break;
}
}
#endregion template
if(string.IsNullOrEmpty(sTemplate)) return;
//subject line first line or first 100 characters of template
string sSubject="";
//Let's get the default 100 characters or less first
if (sTemplate.Length < 101)
sSubject = sTemplate;
else
sSubject = sTemplate.Substring(0, 100);
//fine tune if there is a return or linefeed within the bounds of reason
int n = sTemplate.IndexOfAny(new char[] { '\n', '\r' });
if (n != -1 && n<102 && n > 2)
{
sSubject = sTemplate.Substring(0, n);//case 1984 was n-1
}
//generate email
System.Text.StringBuilder sb = new StringBuilder();
sb.Append("CLIENTNOTIFYEVENT|");
//Email email = new Email();
// email.UnlockComponent("SAyanovaMAILQ_46WCmUg3lQ1i");
// email.Mailer = "AyaNova service management software licensed to " + AyaBizUtils.REGTO;
//email.Body = sTemplate;
sb.Append(sTemplate);
sb.Append("|");
//email.Subject = sSubject;
sb.Append(sSubject);
sb.Append("|");
//email.AddTo("", cl[0].LT_Client_Label_Email);
sb.Append(cl[0].LT_Client_Label_Email);
sb.Append("|");
//email.From = r.ReplyToEmail;
sb.Append(r.ReplyToEmail);
//ATTACH REPORT?
//case 1151 modified to add status change, b4 was only on closed
//indicate which wo to attach and which report to use
//(saves looking it up later)
if (gAttachReportID!=Guid.Empty)
{
//put in delimiter for previous item
sb.Append("|");
//email.AddHeaderField("WorkorderID", WorkorderID.ToString());
sb.Append(WorkorderID.ToString());
sb.Append("|");
//email.AddHeaderField("ReportID", r.NotifyWOClosedRPT.ToString());
sb.Append(gAttachReportID.ToString());
}
ClientNotifyEvent cn = ClientNotifyEvent.NewItem();
cn.ClientID = ClientID;
if (type == ClientNotifyEventType.WorkorderFollowUp)
cn.DeliverAfter += TimeSpan.FromDays(r.NotifyWOFollowUpDays);
cn.SetContent(sb.ToString());
cn.Save();
}
/// <summary>
/// Create new ClientNotifyEvent
/// </summary>
/// <returns>Empty ClientNotifyEvent object</returns>
public static ClientNotifyEvent NewItem()
{
ClientNotifyEvent c;
//if (AyaBizUtils.Right("Object.ClientNotifyEvent") > (int)SecurityLevelTypes.ReadOnly)
//{
c = new ClientNotifyEvent();
return c;
//}
//else
// throw new System.Security.SecurityException(
// string.Format(
// LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
// LocalizedTextTable.GetLocalizedTextDirect("O.ClientNotifyEvent")));
}
/// <summary>
/// Fetch existing ClientNotifyEvent
/// </summary>
/// <returns>ClientNotifyEvent</returns>
/// <param name="ID">ClientNotifyEvent Guid</param>
public static ClientNotifyEvent GetItem(Guid ID)
{
return (ClientNotifyEvent)DataPortal.Fetch(new Criteria(ID,Guid.Empty));
}
/// <summary>
/// Delete ClientNotifyEvent
/// </summary>
/// <param name="ID">ClientNotifyEvent applicationID</param>
public static void DeleteItem(Guid ID)
{
DataPortal.Delete(new Criteria(ID, Guid.Empty));
}
/// <summary>
/// Delete all events for a specified client
/// used when saving a client record that has it's send notifications
/// unchecked and when deleting a client
/// </summary>
/// <param name="ClientID">Client ID</param>
public static void DeleteAllNotifyEventsForClient(Guid ClientID)
{
DataPortal.Delete(new Criteria(Guid.Empty, ClientID));
}
#endregion
#region DAL DATA ACCESS
#region Fetch
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString("SELECT * FROM aClientNotifyEvent WHERE aID=@ID;", crit.ID);
if (!dr.Read())
DBUtil.ThrowFetchError("ClientNotifyEvent ID: " + crit.ID.ToString());
//Standard fields
mID = dr.GetGuid("aID");
mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified = DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mDeliverAfter = DBUtil.ToLocal(dr.GetSmartDate("ADELIVERAFTER"));
mCreator = dr.GetGuid("aCreator");
mModifier = dr.GetGuid("aModifier");
//ClientNotifyEvent fields
mObjectSize = dr.GetInt32("AOBJECTSIZE");
ClientID = dr.GetGuid("aClientID");
//allocate a place to store it
mContent = new Byte[mObjectSize];
//retrieve the (compressed) bytes
dr.GetBytes("AOBJECT", 0, mContent, 0, mContent.Length);
if(dr!=null) dr.Close();
}
finally
{
if (dr != null) dr.Close();
}
MarkOld();
}
#endregion fetch
#region Update
/// <summary>
/// Called by DataPortal to delete/add/update data into the database
/// </summary>
protected override void DataPortal_Update()
{
// If not a new record, check if record was modified
//by another user since original retrieval:
if (!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date, this.mID, "aClientNotifyEvent");
#region Delete
if (IsDeleted)
{
throw new System.NotSupportedException("ClientNotifyEvent->Update->Delete: not supported for this object, call the static/shared ClientNotifyEvent.DeleteItem() method instead");
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if (IsNew)//Add or update?
cm = DBUtil.GetCommandFromSQL(
"INSERT INTO aClientNotifyEvent (aID, aCreated,aModified,aCreator,aModifier, " +
"aClientID, aDeliverAfter, AOBJECT,AOBJECTSIZE) " +
"VALUES (@ID,@Created,@Modified,@CurrentUserID,@CurrentUserID, " +
"@ClientID, @DeliverAfter, @OBJECT,@OBJECTSIZE)"
);
else
cm = DBUtil.GetCommandFromSQL(
"UPDATE aClientNotifyEvent SET aID=@ID, " +
"aModified=@Modified,aModifier=@CurrentUserID, " +
"aClientID=@ClientID, " +
"aDeliverAfter=@DeliverAfter, " +
"AOBJECT=@OBJECT, AOBJECTSIZE=@OBJECTSIZE " +
"WHERE aID=@ID"
);
//ClientNotifyEvent fields
cm.AddInParameter("@ID", DbType.Guid, mID);
cm.AddInParameter("@ClientID", DbType.Guid, mClientID);
cm.AddInParameter("@DeliverAfter", DbType.DateTime, DBUtil.ToUTC(mDeliverAfter.Date));
cm.AddInParameter("@OBJECT", DbType.Object, mContent);
cm.AddInParameter("@OBJECTSIZE", DbType.Int32, mContent.GetLength(0));
//Standard fields
cm.AddInParameter("@CurrentUserID", DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created", DbType.DateTime, DBUtil.ToUTC(mCreated).DBValue);
cm.AddInParameter("@Modified", DbType.DateTime, DBUtil.ToUTC(dtModified));
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cm, transaction);
MarkOld();//db is now synched with object
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
//Successful update so
//change modification time to match
this.mModified.Date = dtModified;
}
#endregion
}
#endregion update
#region Delete
/// <summary>
/// Remove a ClientNotifyEvent record
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Delete(object Criteria)
{
Criteria crit = (Criteria)Criteria;
DBCommandWrapper cmDelete = null;
//Delete *all* events for a client
if (crit.ClientID != Guid.Empty)
{
cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aClientNotifyEvent WHERE aClientID = @ID");
cmDelete.AddInParameter("@ID", DbType.Guid, crit.ClientID);
}
else
{
//Delete object
cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aClientNotifyEvent WHERE aID = @ID;");
cmDelete.AddInParameter("@ID", DbType.Guid, crit.ID);
}
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cmDelete, transaction);
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
}
}
#endregion delete
#endregion
#region Override IsValid / IsDirty
public override bool IsValid
{
get
{
return base.IsValid ;
}
}
public override bool IsDirty
{
get
{
return base.IsDirty ;
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Guid ClientID;
public Criteria(Guid _ID, Guid _ClientID)
{
ID = _ID;
ClientID = _ClientID;
}
}
#endregion
}//end ClientNotifyEvent
#region Notification events
public enum ClientNotifyEventType : int
{
CSRAccepted=1,
CSRRejected=2,
NewWorkorder=3,
WorkorderStatusSet=4,
WorkorderClosed=5,
WorkorderFollowUp=6,
QuoteStatusSet=7//case 1499
}
#endregion
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,359 @@
///////////////////////////////////////////////////////////
// ClientPickList.cs
// Implementation of Class ClientPickList
// CSLA type: Read only collection
// Created on: 16-Feb-2006
// Object design: John
// Coded: 16-Feb-2006
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Lightweight list of <see cref="ClientPickList.ClientPickListInfo"/> objects used for quickly fetching a list of clients.
/// Used for user selection and internal API useage by other business objects.
///
/// NOTE: this is used mostly internally so the default GetList() method is not regionalized
///
/// </summary>
[Serializable]
public class ClientPickList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct ClientPickListInfo
{
internal Guid mID;
internal string mName;
internal bool mActive;
//internal string mNotes;
internal Guid mRegionID;//case 981
//Public properties
/// <summary>
/// ID of <see cref="Client"/>
/// </summary>
public Guid ID {get{return mID;}}
/// <summary>
/// Name of <see cref="Client"/>
/// </summary>
public string Name {get{return mName;}}
/// <summary>
/// Active status of <see cref="Client"/>
/// </summary>
public bool Active {get{return mActive;}}
//public string Notes {get{return mNotes;}}
/// <summary>
/// <see cref="Region"/> ID of <see cref="Client"/>
/// </summary>
public Guid RegionID { get { return mRegionID; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientPickListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end ClientPickListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected ClientPickList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientPickListInfo this[int Item]
{
get
{
return (ClientPickListInfo) List[Item];
}
}
/// <summary>
/// Returns ClientPickListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public ClientPickListInfo this[Guid ItemID]
{
get
{
foreach (ClientPickListInfo child in List)
{
if(child.mID==ItemID) return child;
}
throw new ArgumentException("ClientPickList: ID not found:\r\n"+ItemID.ToString());
}
}
/// <summary>
/// Get a list of all duplicate names in this list
/// </summary>
public System.Collections.Generic.List<string> DuplicateNames
{
get
{
System.Collections.Generic.List<string> dupes = new System.Collections.Generic.List<string>();
System.Collections.Generic.List<string> all = new System.Collections.Generic.List<string>();
foreach (ClientPickListInfo i in List)
{
if (all.Contains(i.Name))
{
dupes.Add(i.Name);
}
else
{
all.Add(i.Name);
}
}
return dupes;
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientPickListInfo obj)
{
foreach (ClientPickListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in collection
/// </summary>
///<param name="ClientID">Id of client object</param>
public bool Contains(Guid ClientID)
{
foreach (ClientPickListInfo child in List)
{
if(child.ID.Equals(ClientID)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all clients
/// </summary>
/// <returns>list of <see cref="ClientPickList.ClientPickListInfo"/> objects</returns>
public static ClientPickList GetList()
{
return (ClientPickList) DataPortal.Fetch(new Criteria(Guid.Empty,null,false));
}
/// <summary>
/// Get all clients in users current region
/// </summary>
/// <param name="Regionalized"></param>
/// <returns>list of <see cref="ClientPickList.ClientPickListInfo"/> objects</returns>
public static ClientPickList GetList(bool Regionalized)
{
return (ClientPickList)DataPortal.Fetch(new Criteria(Guid.Empty, null,Regionalized));
}
//Added: 10-Nov-2006 list for head office only for wbi client service request support
/// <summary>
/// Get a list of all active clients that share the indicated head office
/// </summary>
/// <param name="headOfficeID"></param>
/// <returns>list of <see cref="ClientPickList.ClientPickListInfo"/> objects</returns>
public static ClientPickList GetListForHeadOffice(Guid headOfficeID)
{
return (ClientPickList)DataPortal.Fetch(new Criteria(headOfficeID,null,false));
}
/// <summary>
/// Get a list of all active clients regionalized
/// that are in the id list provided
/// </summary>
/// <param name="IDList">Guid's in a generic list</param>
/// <param name="Regionalized">Check and enforce region rules</param>
/// <returns>list of <see cref="ClientPickList.ClientPickListInfo"/> objects</returns>
public static ClientPickList GetList(List<Guid> IDList, bool Regionalized)
{
return (ClientPickList)DataPortal.Fetch(new Criteria(Guid.Empty, IDList, Regionalized));
}
/// <summary>
/// Check all items for duplicate names
/// </summary>
/// <returns>List of duplicate names</returns>
public static System.Collections.Generic.List<string> DuplicateNameCheck()
{
return GetList().DuplicateNames;
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
if (crit.HeadOfficeID != Guid.Empty)
{
dr = DBUtil.GetReaderFromSQLString(
//************************************************************
"SELECT aID, AACTIVE, aName, aRegionID FROM aClient WHERE aHeadOfficeID=@ID " +
"ORDER BY aName",crit.HeadOfficeID
//************************************************************
);
}
else
{
if (crit.IDList == null)
{//case 1019 changes
string q="SELECT aID, AACTIVE, aName, aRegionID FROM aClient ORDER BY ANAME ";
if(crit.Regionalized)
q=DBUtil.AddRegionFilter(q);
dr = DBUtil.GetReaderFromSQLString(q);
}
else
{
if (crit.IDList.Count > 0)
{
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" (aClient.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(")) ");
dr = DBUtil.GetReaderFromSQLString(
//************************************************************
"SELECT aID, AACTIVE, aName, aRegionID FROM aClient WHERE " +
sbIN.ToString() + (string)(crit.Regionalized ? DBUtil.RegionAClientClause : "") + " ORDER BY ACLIENT.ANAME "
//************************************************************
);
}
else
return;
}
}
//case 1298
int AID = dr.GetOrdinal("AID");
int AACTIVE = dr.GetOrdinal("AACTIVE");
int ANAME = dr.GetOrdinal("ANAME");
int AREGIONID = dr.GetOrdinal("AREGIONID");
//int XXX = dr.GetOrdinal("XXX");
while(dr.Read())
{
//*******************************************
ClientPickListInfo info=new ClientPickListInfo();
info.mID=dr.GetGuid(AID);
info.mActive=dr.GetBoolean(AACTIVE);
info.mName=dr.GetString(ANAME);
info.mRegionID = dr.GetGuid(AREGIONID);
InnerList.Add(info);
//*******************************************
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid HeadOfficeID;
public List<Guid> IDList;
public bool Regionalized;
public Criteria(Guid _HeadOfficeID, List<Guid> _IDList, bool _Regionalized)
{
HeadOfficeID = _HeadOfficeID;
IDList=_IDList;
Regionalized = _Regionalized;
}
}
#endregion
}//end ClientPickList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,113 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class ClientPopUpNotesFetcher
// CSLA type: Read-only object
// Created on: 1-Nov-2007
// Object design: John
// Coded: 1-Nov-2007
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
///Lightweight method for quickly fetching a <see cref="Client"/> object's PopupNotes if present
///Used by UI when opening workorders
/// </summary>
[Serializable, EditorBrowsable(EditorBrowsableState.Never)]
public class ClientPopUpNotesFetcher : ReadOnlyBase
{
#region Attributes
private string mNotes;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientPopUpNotesFetcher()
{
mNotes="";
}
#endregion
#region Static methods
/// <summary>
/// Fetch the notes for the specified <see cref="Client"/>
/// </summary>
/// <param name="ID"></param>
/// <returns><see cref="Client"/> Popup notes</returns>
public static string GetNotes(Guid ID)
{
return ((ClientPopUpNotesFetcher)DataPortal.Fetch(new Criteria(ID))).mNotes;
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString(
"SELECT ACLIENT.APOPUPNOTES " +
"FROM ACLIENT " +
"WHERE ACLIENT.AID= @ID", crit.ID);
if (dr.Read())
{
mNotes = dr.GetString("APOPUPNOTES");
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID = _ID;
}
}
#endregion
}//end class
}//end namespace GZTW.AyaNova.BLL

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,657 @@
///////////////////////////////////////////////////////////
// ClientServiceRequestList.cs
// Implementation of Class ClientServiceRequestList
// CSLA type: Read only collection
// Created on: 07-Jun-2004 8:41:30 AM
// Object design: Joyce & John Nov 8th 2006
// Coded: John 8-Nov-2006
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of <see cref="ClientServiceRequestList.ClientServiceRequestListInfo"/> objects representing <see cref="ClientServiceRequest"/> objects
///
/// </summary>
[Serializable]
public class ClientServiceRequestList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientServiceRequestListInfo
{
internal SmartDate mCreated;
internal string mCreator;
internal GridNameValueCellItem mTitle;
internal string mClient;
internal string mHeadOffice;
//case 1976
//internal string mUnit;
internal GridNameValueCellItem mSerial;
internal GridNameValueCellItem mWorkorder;
internal string mClientRef;
internal ClientServiceRequestStatus mStatus;
internal ClientServiceRequestPriority mPriority;
internal string mRequestedBy;
[SqlColumnNameAttribute("aClientServiceRequest.aCreated"), Display(DisplayType.DateTime)]
public object LT_Common_Label_Created
{ get { return mCreated.DBValue; } }
[SqlColumnNameAttribute("aUser.aInitials"), Display(DisplayType.Text)]
public string LT_Common_Label_Creator
{ get { return mCreator; } }
[SqlColumnNameAttribute("aClientServiceRequest.aTitle", "aClientServiceRequest.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.ClientServiceRequest)]
public GridNameValueCellItem LT_O_ClientServiceRequest
{ get { return mTitle; } }
[SqlColumnNameAttribute("aClient.aName"), Display(DisplayType.Text)]
public string LT_O_Client { get { return mClient; } }
[SqlColumnNameAttribute("aHeadOffice.aName"), Display(DisplayType.Text)]
public string LT_O_HeadOffice { get { return mHeadOffice; } }
//case 1976
//[SqlColumnNameAttribute("aUnit.aSerial"), Display(DisplayType.Text)]
//public string LT_Unit_Label_Serial { get { return mUnit; } }
[SqlColumnNameAttribute("AUNIT.ASERIAL", "ACLIENTSERVICEREQUEST.AUNITID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Unit)]
public GridNameValueCellItem LT_Unit_Label_Serial { get { return mSerial; } }
[SqlColumnNameAttribute("aWorkorderService.aServiceNumber", "aWorkorder.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderItem, CompareAs = CompareType.StringToInt32)]
public GridNameValueCellItem LT_O_Workorder { get { return mWorkorder; } }
[SqlColumnNameAttribute("aClientServiceRequest.ACLIENTREF"), Display(DisplayType.Text)]
public string LT_ClientServiceRequest_Label_CustomerReferenceNumber
{ get { return this.mClientRef; } }
[Display(DisplayType.ListClientServiceRequestStatus)]
public ClientServiceRequestStatus LT_ClientServiceRequest_Label_Status
{ get { return mStatus; } }
[Display(DisplayType.ListClientServiceRequestPriority, Color = true, ColorField = "FIXED")]
public ClientServiceRequestPriority LT_ClientServiceRequest_Label_Priority
{ get { return mPriority; } }
//Case 58
internal GridNameValueCellItem mRegion;
[SqlColumnNameAttribute("aRegion.aName", "aRegion.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Region)]
public GridNameValueCellItem LT_O_Region
{
get
{
return mRegion;
}
}
[SqlColumnNameAttribute("aClientServiceRequest.AREQUESTEDBY"), Display(DisplayType.Text)]
public string LT_ClientServiceRequest_Label_RequestedBy
{ get { return this.mRequestedBy; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientServiceRequestListInfo obj)
{
return this.mTitle.Value.Equals(obj.mTitle.Value);
}
}//end ClientServiceRequestListInfo
#endregion
#region Constructor
protected ClientServiceRequestList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientServiceRequestListInfo this[int Item]
{
get
{
return (ClientServiceRequestListInfo)List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (ClientServiceRequestListInfo child in List)
{
if (child.mTitle.Value == ItemID) return child.ToString();
}
return "Missing: " + ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientServiceRequestListInfo obj)
{
foreach (ClientServiceRequestListInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ClientServiceRequestList";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return "";
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
return RootObjectTypes.ClientServiceRequest;
}
}
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "ClientServiceRequest.Label.List";
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(ClientServiceRequestListInfo);
}
}
/// <summary>
/// Field that contains the ID of the objects
/// that are the basis of this list.
///
/// Used for compiling an ID list for reporting from user
/// selections in a grid.
/// </summary>
public static string IDField
{
get
{
return "LT_O_ClientServiceRequest";
}
}
/// <summary>
/// Same as IDField but for detailed reports
/// </summary>
public static string IDFieldDetailed
{
get
{
return IDField;
}
}
#endregion
#region Static methods
/// <summary>
/// Internal method used by list factory
/// </summary>
internal static ClientServiceRequestList Get(string Filter, int MaxRecords, List<Guid> IDList)
{
return (ClientServiceRequestList)DataPortal.Fetch(new Criteria(Filter,IDList, MaxRecords, Guid.Empty, Guid.Empty));
}
/// <summary>
/// Get all ClientServiceRequest (filtered by crit)
/// </summary>
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
/// <returns>list of <see cref="ClientServiceRequestList.ClientServiceRequestListInfo"/> objects</returns>
public static ClientServiceRequestList GetList(string xmlCriteria)
{
return (ClientServiceRequestList)DataPortal.Fetch(new Criteria(xmlCriteria,null, -1, Guid.Empty, Guid.Empty));
}
//added for case 1975 RI
/// <summary>
/// Get MaxRecord Quotes filtered by criteria
/// </summary>
/// <param name="xmlCriteria"></param>
/// <param name="MaxRecords"></param>
/// <param name="clientID"></param>
/// <returns></returns>
public static ClientServiceRequestList GetList(string xmlCriteria, int MaxRecords, Guid clientID)
{
return (ClientServiceRequestList)DataPortal.Fetch(new Criteria(xmlCriteria, null, MaxRecords, Guid.Empty, clientID));
}
//added for case 1975 RI
/// <summary>
/// Get MaxRecord Quotes filtered by criteria
/// </summary>
/// <param name="xmlCriteria"></param>
/// <param name="MaxRecords"></param>
/// <returns></returns>
public static ClientServiceRequestList GetList(string xmlCriteria, int MaxRecords)
{
return (ClientServiceRequestList)DataPortal.Fetch(new Criteria(xmlCriteria, null, MaxRecords, Guid.Empty, Guid.Empty));
}
/// <summary>
/// Get all ClientServiceRequest for a specified head office
/// (returns all requests for all clients under headOfficeID)
/// </summary>
/// <param name="headOfficeID"></param>
/// <returns>list of <see cref="ClientServiceRequestList.ClientServiceRequestListInfo"/> objects</returns>
public static ClientServiceRequestList GetListForHeadOffice(Guid headOfficeID)
{
return (ClientServiceRequestList)DataPortal.Fetch(new Criteria("",null, -1, headOfficeID, Guid.Empty));
}
/// <summary>
/// Get all ClientServiceRequest for a specified client
/// </summary>
/// <param name="clientID"></param>
/// <returns>list of <see cref="ClientServiceRequestList.ClientServiceRequestListInfo"/> objects</returns>
public static ClientServiceRequestList GetListForClient(Guid clientID)
{
return (ClientServiceRequestList)DataPortal.Fetch(new Criteria("",null, -1, Guid.Empty, clientID));
}
/// <summary>
/// Get list by items indicated in IDList
/// </summary>
/// <param name="IDList">Generic list of Guid's</param>
/// <returns>list of <see cref="ClientServiceRequestList.ClientServiceRequestListInfo"/> objects</returns>
public static ClientServiceRequestList GetListFromIDList(List<Guid> IDList)
{
//case 556
//Handle empty list
if (IDList.Count == 0)
return new ClientServiceRequestList();
return (ClientServiceRequestList)DataPortal.Fetch(new Criteria("", IDList, -1, Guid.Empty, Guid.Empty));
}
/// <summary>
/// Return an empty list
/// used for initializing grid
/// </summary>
/// <returns></returns>
public static ClientServiceRequestList GetEmptyList()
{
return new ClientServiceRequestList();
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q = "";
if (crit.IDList != null)
{
//Case 556
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" WHERE ACLIENTSERVICEREQUEST.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(") ");
// By list of ID's, not regionalized
q = "SELECT " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION AS AUNITDESCRIPTION, " + //case 3150
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case 9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
sbIN.ToString() +
"ORDER BY ACLIENTSERVICEREQUEST.ACREATED DESC ";
dr = DBUtil.GetReaderFromSQLString(q);
}
else if (crit.ClientID != Guid.Empty)
{
//by specific client not regionalized.
q = "SELECT " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION AS AUNITDESCRIPTION, " + //case 3150
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case 9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
"WHERE ACLIENTSERVICEREQUEST.ACLIENTID=@ID " +
"ORDER BY ACLIENTSERVICEREQUEST.ACREATED DESC ";
dr = DBUtil.GetReaderFromSQLString(q, crit.ClientID);
}
else if (crit.HeadOfficeID != Guid.Empty)
{
//by specific head office not regionalized
q = "SELECT " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION AS AUNITDESCRIPTION, " + //case 3150
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case 9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
"WHERE ACLIENT.AHEADOFFICEID=@ID " +
"ORDER BY ACLIENT.ANAME, ACLIENTSERVICEREQUEST.ACREATED DESC ";
dr = DBUtil.GetReaderFromSQLString(q, crit.HeadOfficeID);
}
else
{
//Generic full list fetch (regionalized)
//************************************************************
q = "SELECT ~MAXRECS~ " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION AS AUNITDESCRIPTION, " + //case 3150
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
"FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML, true) + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
q = DBUtil.AddRegionFilter(q, "aClient", "");//case 58
dr = DBUtil.GetReaderFromSQLString(q);
}
//************************************************************
string accepted = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Accepted");
string declined = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Declined");
string open = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Open");
string closed = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Closed");
string noturgent = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.NotUrgent");
string asap = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.ASAP");
string emergency = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.Emergency");
while (dr.Read())
{
//*******************************************
ClientServiceRequestListInfo info = new ClientServiceRequestListInfo();
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("ACREATED"));
info.mCreator = dr.GetString("AINITIALS");
info.mTitle = new GridNameValueCellItem(
dr.GetGuid("AID"),
dr.GetString("ATITLE"),
RootObjectTypes.ClientServiceRequest);
info.mClient = dr.GetString("ACLIENTNAME");
//Case 58
info.mRegion = new GridNameValueCellItem(
dr.GetGuid("aRegionID"),
dr.GetString("aRegionName"),
RootObjectTypes.Region);
info.mHeadOffice = dr.GetString("AHEADOFFICENAME");
//case 1976
//info.mUnit = Unit.UnitNameFormatter(dr.GetString("aModelNumber"), dr.GetString("AUNITMODELNAME"), dr.GetString("AUNITVENDORNAME"), dr.GetString("ASERIAL"), AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat);
info.mSerial = new GridNameValueCellItem(
dr.GetGuid("AUNITID"),
Unit.UnitNameFormatter(
dr.GetString("AMODELNUMBER"),
dr.GetString("AUNITMODELNAME"),
dr.GetString("AUNITVENDORNAME"),
dr.GetString("ASERIAL"),
dr.GetString("AUNITDESCRIPTION"),
AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat),
RootObjectTypes.Unit);
info.mWorkorder = new GridNameValueCellItem(
dr.GetGuid("AWORKORDERID"),
dr.GetInt32("ASERVICENUMBER") == 0 ? "" : dr.GetInt32("ASERVICENUMBER").ToString(),
RootObjectTypes.Workorder);
info.mClientRef = dr.GetString("ACLIENTREF");
info.mRequestedBy = dr.GetString("AREQUESTEDBY");
info.mStatus=(ClientServiceRequestStatus)dr.GetInt16("ASTATUS");
info.mPriority=(ClientServiceRequestPriority)dr.GetInt16("APRIORITY");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public List<Guid> IDList;
public string CriteriaXML;
public int MaxRecords;
public Guid HeadOfficeID;
public Guid ClientID;
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords, Guid _HeadOfficeID, Guid _ClientID)
{
CriteriaXML = _CriteriaXML;
MaxRecords = _MaxRecords;
HeadOfficeID = _HeadOfficeID;
ClientID = _ClientID;
IDList = _IDList;
}
}
#endregion
}//end ClientServiceRequestList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,539 @@
///////////////////////////////////////////////////////////
// ClientServiceRequestListRI.cs
// Implementation of Class ClientServiceRequestListRI
// CSLA type: Read only collection
// Created on: 16-Feb-2016
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects representing <see cref="ClientServiceRequest"/> objects
/// Used by AyaNova RI interface
/// </summary>
[Serializable]
public class ClientServiceRequestListRI : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientServiceRequestListRIInfo
{
internal SmartDate mCreated;
internal string mCreator;
internal GridNameValueCellItem mTitle;
internal string mClient;
internal GridNameValueCellItem mHeadOffice;
//case 1976
//internal string mUnit;
internal GridNameValueCellItem mSerial;
internal GridNameValueCellItem mWorkorder;
internal string mClientRef;
internal ClientServiceRequestStatus mStatus;
internal ClientServiceRequestPriority mPriority;
internal string mRequestedBy;
[SqlColumnNameAttribute("aClientServiceRequest.aCreated"), Display(DisplayType.DateTime)]
public object LT_Common_Label_Created
{ get { return mCreated.DBValue; } }
[SqlColumnNameAttribute("aUser.aInitials"), Display(DisplayType.Text)]
public string LT_Common_Label_Creator
{ get { return mCreator; } }
[SqlColumnNameAttribute("aClientServiceRequest.aTitle", "aClientServiceRequest.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.ClientServiceRequest)]
public GridNameValueCellItem LT_O_ClientServiceRequest
{ get { return mTitle; } }
[SqlColumnNameAttribute("aClient.aName"), Display(DisplayType.Text)]
public string LT_O_Client { get { return mClient; } }
[SqlColumnNameAttribute("aHeadOffice.aName", "aClient.aHeadOfficeID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.HeadOffice)]
public GridNameValueCellItem LT_O_HeadOffice { get { return mHeadOffice; } }
//case 1976
//[SqlColumnNameAttribute("aUnit.aSerial"), Display(DisplayType.Text)]
//public string LT_Unit_Label_Serial { get { return mUnit; } }
[SqlColumnNameAttribute("AUNIT.ASERIAL", "ACLIENTSERVICEREQUEST.AUNITID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Unit)]
public GridNameValueCellItem LT_Unit_Label_Serial { get { return mSerial; } }
[SqlColumnNameAttribute("aWorkorderService.aServiceNumber", "aWorkorder.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderItem, CompareAs = CompareType.StringToInt32)]
public GridNameValueCellItem LT_O_Workorder { get { return mWorkorder; } }
[SqlColumnNameAttribute("aClientServiceRequest.ACLIENTREF"), Display(DisplayType.Text)]
public string LT_ClientServiceRequest_Label_CustomerReferenceNumber
{ get { return this.mClientRef; } }
[Display(DisplayType.ListClientServiceRequestStatus)]
public ClientServiceRequestStatus LT_ClientServiceRequest_Label_Status
{ get { return mStatus; } }
[Display(DisplayType.ListClientServiceRequestPriority, Color = true, ColorField = "FIXED")]
public ClientServiceRequestPriority LT_ClientServiceRequest_Label_Priority
{ get { return mPriority; } }
//Case 58
internal GridNameValueCellItem mRegion;
[SqlColumnNameAttribute("aRegion.aName", "aRegion.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Region)]
public GridNameValueCellItem LT_O_Region
{
get
{
return mRegion;
}
}
[SqlColumnNameAttribute("aClientServiceRequest.AREQUESTEDBY"), Display(DisplayType.Text)]
public string LT_ClientServiceRequest_Label_RequestedBy
{ get { return this.mRequestedBy; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientServiceRequestListRIInfo obj)
{
return this.mTitle.Value.Equals(obj.mTitle.Value);
}
}//end ClientServiceRequestListRIInfo
#endregion
#region Constructor
protected ClientServiceRequestListRI()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientServiceRequestListRIInfo this[int Item]
{
get
{
return (ClientServiceRequestListRIInfo)List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (ClientServiceRequestListRIInfo child in List)
{
if (child.mTitle.Value == ItemID) return child.ToString();
}
return "Missing: " + ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientServiceRequestListRIInfo obj)
{
foreach (ClientServiceRequestListRIInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ClientServiceRequestListRI";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return "";
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
return RootObjectTypes.ClientServiceRequest;
}
}
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "ClientServiceRequest.Label.List";
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(ClientServiceRequestListRIInfo);
}
}
/// <summary>
/// Field that contains the ID of the objects
/// that are the basis of this list.
///
/// Used for compiling an ID list for reporting from user
/// selections in a grid.
/// </summary>
public static string IDField
{
get
{
return "LT_O_ClientServiceRequest";
}
}
/// <summary>
/// Same as IDField but for detailed reports
/// </summary>
public static string IDFieldDetailed
{
get
{
return IDField;
}
}
#endregion
#region Static methods
///// <summary>
///// Internal method used by list factory
///// </summary>
//internal static ClientServiceRequestListRI Get(string Filter, int MaxRecords, List<Guid> IDList)
//{
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(Filter,IDList, MaxRecords, Guid.Empty, Guid.Empty));
//}
///// <summary>
///// Get all ClientServiceRequest (filtered by crit)
///// </summary>
///// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
//public static ClientServiceRequestListRI GetList(string xmlCriteria)
//{
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(xmlCriteria,null, -1, Guid.Empty, Guid.Empty));
//}
////added for case 1975 RI
///// <summary>
///// Get MaxRecord Quotes filtered by criteria
///// </summary>
///// <param name="xmlCriteria"></param>
///// <param name="MaxRecords"></param>
///// <param name="clientID"></param>
///// <returns></returns>
//public static ClientServiceRequestListRI GetList(string xmlCriteria, int MaxRecords, Guid clientID)
//{
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(xmlCriteria, null, MaxRecords, Guid.Empty, clientID));
//}
//added for case 1975 RI
/// <summary>
/// Get MaxRecord Quotes filtered by criteria
/// </summary>
/// <param name="xmlCriteria"></param>
/// <param name="MaxRecords"></param>
/// <returns></returns>
public static ClientServiceRequestListRI GetList(string xmlCriteria, int MaxRecords)
{
return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(xmlCriteria, null, MaxRecords, Guid.Empty, Guid.Empty));
}
///// <summary>
///// Get all ClientServiceRequest for a specified head office
///// (returns all requests for all clients under headOfficeID)
///// </summary>
///// <param name="headOfficeID"></param>
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
//public static ClientServiceRequestListRI GetListForHeadOffice(Guid headOfficeID)
//{
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria("",null, -1, headOfficeID, Guid.Empty));
//}
///// <summary>
///// Get all ClientServiceRequest for a specified client
///// </summary>
///// <param name="clientID"></param>
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
//public static ClientServiceRequestListRI GetListForClient(Guid clientID)
//{
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria("",null, -1, Guid.Empty, clientID));
//}
///// <summary>
///// Get list by items indicated in IDList
///// </summary>
///// <param name="IDList">Generic list of Guid's</param>
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
//public static ClientServiceRequestListRI GetListFromIDList(List<Guid> IDList)
//{
// //case 556
// //Handle empty list
// if (IDList.Count == 0)
// return new ClientServiceRequestListRI();
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria("", IDList, -1, Guid.Empty, Guid.Empty));
//}
///// <summary>
///// Return an empty list
///// used for initializing grid
///// </summary>
///// <returns></returns>
//public static ClientServiceRequestListRI GetEmptyList()
//{
// return new ClientServiceRequestListRI();
//}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q = "";
//Generic full list fetch (regionalized)
//************************************************************
q = "SELECT ~MAXRECS~ " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION, " +//case 3150
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.aRegionID, ACLIENT.AHEADOFFICEID, aRegion.aName AS aRegionName, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
" FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML, true) + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
q = DBUtil.AddRegionFilter(q, "aClient", "");//case 58
dr = DBUtil.GetReaderFromSQLString(q);
//************************************************************
string accepted = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Accepted");
string declined = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Declined");
string open = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Open");
string closed = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Closed");
string noturgent = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.NotUrgent");
string asap = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.ASAP");
string emergency = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.Emergency");
while (dr.Read())
{
//*******************************************
ClientServiceRequestListRIInfo info = new ClientServiceRequestListRIInfo();
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("ACREATED"));
info.mCreator = dr.GetString("AINITIALS");
info.mTitle = new GridNameValueCellItem(
dr.GetGuid("AID"),
dr.GetString("ATITLE"),
RootObjectTypes.ClientServiceRequest);
info.mClient = dr.GetString("ACLIENTNAME");
//Case 58
info.mRegion = new GridNameValueCellItem(
dr.GetGuid("aRegionID"),
dr.GetString("aRegionName"),
RootObjectTypes.Region);
info.mHeadOffice = new GridNameValueCellItem(
dr.GetGuid("AHEADOFFICEID"),
dr.GetString("AHEADOFFICENAME"),
RootObjectTypes.HeadOffice);
//case 1976
//info.mUnit = Unit.UnitNameFormatter(dr.GetString("aModelNumber"), dr.GetString("AUNITMODELNAME"), dr.GetString("AUNITVENDORNAME"), dr.GetString("ASERIAL"), AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat);
info.mSerial = new GridNameValueCellItem(
dr.GetGuid("AUNITID"),
Unit.UnitNameFormatter(
dr.GetString("AMODELNUMBER"),
dr.GetString("AUNITMODELNAME"),
dr.GetString("AUNITVENDORNAME"),
dr.GetString("ASERIAL"),
dr.GetString("ADESCRIPTION"),
AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat),
RootObjectTypes.Unit);
info.mWorkorder = new GridNameValueCellItem(
dr.GetGuid("AWORKORDERID"),
dr.GetInt32("ASERVICENUMBER") == 0 ? "" : dr.GetInt32("ASERVICENUMBER").ToString(),
RootObjectTypes.Workorder);
info.mClientRef = dr.GetString("ACLIENTREF");
info.mRequestedBy = dr.GetString("AREQUESTEDBY");
info.mStatus=(ClientServiceRequestStatus)dr.GetInt16("ASTATUS");
info.mPriority=(ClientServiceRequestPriority)dr.GetInt16("APRIORITY");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public List<Guid> IDList;
public string CriteriaXML;
public int MaxRecords;
public Guid HeadOfficeID;
public Guid ClientID;
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords, Guid _HeadOfficeID, Guid _ClientID)
{
CriteriaXML = _CriteriaXML;
MaxRecords = _MaxRecords;
HeadOfficeID = _HeadOfficeID;
ClientID = _ClientID;
IDList = _IDList;
}
}
#endregion
}//end ClientServiceRequestListRI
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,115 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class ClientServiceRequestNameFetcher
// CSLA type: Read-only object
// Created on: 2-Nov-2007
// Object design: John
// Coded: 2-Nov-2007
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
///Returns service bankable object most responsible
/// for banking based on client
/// </summary>
[Serializable, EditorBrowsable(EditorBrowsableState.Never)]
internal class ClientServiceRequestNameFetcher : ReadOnlyBase
{
#region Attributes
private string description;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ClientServiceRequestNameFetcher()
{
description = "";
}
#endregion
#region Static methods
/// <summary>
/// Get a description for a CSR to display in lists in UI
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
internal static string Description(Guid ID)
{
return ((ClientServiceRequestNameFetcher)DataPortal.Fetch(new Criteria(ID))).description;
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString(
"SELECT ACLIENTSERVICEREQUEST.ATITLE, ACLIENT.ANAME FROM " +
"ACLIENTSERVICEREQUEST " +
"LEFT JOIN ACLIENT " +
"ON ( ACLIENT.AID = ACLIENTSERVICEREQUEST.ACLIENTID ) " +
"WHERE ACLIENTSERVICEREQUEST.AID= @ID", crit.ID);
if (dr.Read())
{
description = dr.GetString("ANAME") + " \"" + dr.GetString("ATITLE") + "\"";
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID = _ID;
}
}
#endregion
}//end class
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////
// ClientServiceRequestPriority.cs
// Implementation of ClientServiceRequestPriority
//
// Created on: 07-Jun-2004 8:41:30 AM
// Object design: Joyce & John Nov 8th 2006
// Coded: John 8-Nov-2006
///////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// User chosen priority for their service request
/// </summary>
[TypeConverter(typeof(EnumDescConverter))]
public enum ClientServiceRequestPriority : int
{
/// <summary>
/// Not urgent, service at time of choosing of service company
/// </summary>
[Description("LT:ClientServiceRequestPriority.NotUrgent")]
NotUrgent = 0,
/// <summary>
/// Not an emergency but quite urgent, service as soon as possible
/// </summary>
[Description("LT:ClientServiceRequestPriority.ASAP")]
ASAP = 1,
/// <summary>
/// Issue is an emergency, client expects service company to make it their first priority
/// </summary>
[Description("LT:ClientServiceRequestPriority.Emergency")]
Emergency = 2
}//end ClientServiceRequestPriority
}

View File

@@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////
// ClientServiceRequestStatus.cs
// Implementation of ClientServiceRequestStatus
//
// Created on: 07-Jun-2004 8:41:30 AM
// Object design: Joyce & John Nov 8th 2006
// Coded: John 8-Nov-2006
///////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// The current status of a customers service request as it progresses through the system
/// </summary>
[TypeConverter(typeof(EnumDescConverter))]
public enum ClientServiceRequestStatus : int
{
/// <summary>
/// No status set
/// (editable)
/// </summary>
[Description("LT:ClientServiceRequestStatus.Open")]
Open = 0,
/// <summary>
/// Accepted for service
/// (Not editable / locked and closed)
/// </summary>
[Description("LT:ClientServiceRequestStatus.Accepted")]
Accepted = 1,
/// <summary>
/// Declined for service
/// (editable)
/// </summary>
[Description("LT:ClientServiceRequestStatus.Declined")]
Declined = 2,
/// <summary>
/// Closed (service completed)
/// </summary>
[Description("LT:ClientServiceRequestStatus.Closed")]
Closed = 3
}//end ClientServiceRequestStatus
}

View File

@@ -0,0 +1,384 @@
///////////////////////////////////////////////////////////
// ClientWorkorderList.cs
// Implementation of Class ClientWorkorderList
// CSLA type: Read only collection
// Created on: 11-Nov-2006
// Object design: Joyce & John Nov 11th 2006
// Coded: John 11-Nov-2006
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of client work orders
/// Displayed in AyaNova WBI for client logins
///
/// </summary>
[Serializable]
public class ClientWorkorderList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientWorkorderListInfo
{
internal GridNameValueCellItem mWorkorder;
internal string mInvoice;
internal SmartDate mServiceDate;
internal bool mClosed;
internal string mClientRef;
internal string mClientContact;
internal string mClient;
internal string mHeadOffice;
//Case 228
internal string mSummary;
[SqlColumnNameAttribute("aWorkorderService.aServiceNumber", "aWorkorder.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderItem, CompareAs = CompareType.StringToInt32)]
public GridNameValueCellItem LT_O_Workorder { get { return mWorkorder; } }
[Display(DisplayType.Text)]
public string LT_WorkorderService_Label_InvoiceNumber { get { return mInvoice; } }
[SqlColumnNameAttribute("AWORKORDERSERVICE.ASERVICEDATE"), Display(DisplayType.DateTime)]
public object LT_WorkorderService_Label_ServiceDate
{ get { return mServiceDate.DBValue; } }
[Display(DisplayType.TrueFalse)]
public bool LT_Workorder_Label_Closed { get { return mClosed; } }
[SqlColumnNameAttribute("aWorkorder.ACLIENTREF"), Display(DisplayType.Text)]
public string LT_Workorder_Label_CustomerReferenceNumber
{ get { return this.mClientRef; } }
[Display(DisplayType.Text)]
public string LT_Workorder_Label_CustomerContactName { get { return mClientContact; } }
[SqlColumnNameAttribute("aClient.aName"), Display(DisplayType.Text)]
public string LT_O_Client { get { return mClient; } }
[SqlColumnNameAttribute("aHeadOffice.aName"), Display(DisplayType.Text)]
public string LT_O_HeadOffice { get { return mHeadOffice; } }
//Case 228
[Display(DisplayType.Text)]
public string LT_Workorder_Label_Summary { get { return mSummary; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientWorkorderListInfo obj)
{
return this.mWorkorder.Value.Equals(obj.mWorkorder.Value);
}
}//end ClientWorkorderListInfo
#endregion
#region Constructor
protected ClientWorkorderList()
{
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientWorkorderListInfo this[int Item]
{
get
{
return (ClientWorkorderListInfo)List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (ClientWorkorderListInfo child in List)
{
if (child.mWorkorder.Value == ItemID) return child.ToString();
}
return "Missing: " + ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientWorkorderListInfo obj)
{
foreach (ClientWorkorderListInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ClientWorkorderList";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return "";
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
//Nothing so that no accidental possibility of
//client creating a workorder
return RootObjectTypes.Nothing;
}
}
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "WorkorderService.Label.List";
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(ClientWorkorderListInfo);
}
}
#endregion
#region Static methods
/// <summary>
/// Get all Workorders for a specified head office
/// (returns all workorders for all clients under headOfficeID)
/// </summary>
/// <param name="headOfficeID"></param>
/// <returns></returns>
public static ClientWorkorderList GetListForHeadOffice(Guid headOfficeID)
{
return (ClientWorkorderList)DataPortal.Fetch(new Criteria(headOfficeID, Guid.Empty));
}
/// <summary>
/// Get all Workorders for a specified client
/// </summary>
/// <param name="clientID">ID of client object</param>
/// <returns></returns>
public static ClientWorkorderList GetListForClient(Guid clientID)
{
return (ClientWorkorderList)DataPortal.Fetch(new Criteria(Guid.Empty, clientID));
}
///// <summary>
///// Return an empty list
///// used for initializing grid
///// </summary>
///// <returns></returns>
//public static ClientWorkorderList GetEmptyList()
//{
// return new ClientWorkorderList();
//}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q = "";
if (crit.ClientID != Guid.Empty)
{
q = "SELECT " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERSERVICE.AINVOICENUMBER, " +
" AWORKORDERSERVICE.ASERVICEDATE, " +
" AWORKORDER.ACLOSED, " +
" AWORKORDER.ACUSTOMERREFERENCENUMBER, " +
" AWORKORDER.ACUSTOMERCONTACTNAME, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDER.AID, AWORKORDER.ASUMMARY " +//case 228 added summary column
"FROM " +
" AWORKORDERSERVICE " +
" INNER JOIN AWORKORDER ON (AWORKORDERSERVICE.AWORKORDERID = AWORKORDER.AID) " +
" INNER JOIN ACLIENT ON (AWORKORDER.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
"WHERE " +
" (AWORKORDER.AWORKORDERTYPE = 1) AND AWORKORDER.ACLIENTID=@ID " +
" ORDER BY AWORKORDERSERVICE.ASERVICENUMBER DESC ";
dr = DBUtil.GetReaderFromSQLString(q, crit.ClientID);
}
else
{
q = "SELECT " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERSERVICE.AINVOICENUMBER, " +
" AWORKORDERSERVICE.ASERVICEDATE, " +
" AWORKORDER.ACLOSED, " +
" AWORKORDER.ACUSTOMERREFERENCENUMBER, " +
" AWORKORDER.ACUSTOMERCONTACTNAME, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDER.AID, AWORKORDER.ASUMMARY " +//case 228 added summary column
"FROM " +
" AWORKORDERSERVICE " +
" INNER JOIN AWORKORDER ON (AWORKORDERSERVICE.AWORKORDERID = AWORKORDER.AID) " +
" INNER JOIN ACLIENT ON (AWORKORDER.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
"WHERE " +
" (AWORKORDER.AWORKORDERTYPE = 1) AND ACLIENT.AHEADOFFICEID=@ID " +
" ORDER BY AWORKORDERSERVICE.ASERVICENUMBER DESC ";
dr = DBUtil.GetReaderFromSQLString(q, crit.HeadOfficeID);
}
//************************************************************
while (dr.Read())
{
//*******************************************
ClientWorkorderListInfo info = new ClientWorkorderListInfo();
info.mWorkorder = new GridNameValueCellItem(
dr.GetGuid("AID"),
dr.GetInt32("ASERVICENUMBER") == 0 ? "" : dr.GetInt32("ASERVICENUMBER").ToString(),
RootObjectTypes.Workorder);
info.mInvoice = dr.GetString("AINVOICENUMBER");
info.mServiceDate = DBUtil.ToLocal(dr.GetSmartDate("ASERVICEDATE"));
info.mClosed = dr.GetBoolean("ACLOSED");
info.mClientRef = dr.GetString("ACUSTOMERREFERENCENUMBER");
info.mClientContact = dr.GetString("ACUSTOMERCONTACTNAME");
info.mClient = dr.GetString("ACLIENTNAME");
info.mHeadOffice = dr.GetString("AHEADOFFICENAME");
//Case 228
info.mSummary = dr.GetString("ASUMMARY");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid HeadOfficeID;
public Guid ClientID;
public Criteria(Guid _HeadOfficeID, Guid _ClientID)
{
HeadOfficeID = _HeadOfficeID;
ClientID = _ClientID;
}
}
#endregion
}//end ClientWorkorderList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,433 @@
///////////////////////////////////////////////////////////
// ClientWorkorderListEx.cs
// Implementation of Class ClientWorkorderListEx
// CSLA type: Read only collection
// Created on: 9-Feb-2009
// Coded: John 9-Feb-2009
///////////////////////////////////////////////////////////
//case 922
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of client work orders
/// Displayed in AyaNova WBI for client logins
///
/// New version for v5 modified to enable built in sorting
/// </summary>
[Serializable]
public class ClientWorkorderListEx : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ClientWorkorderListExInfo
{
internal int mWorkorder;
internal string mInvoice;
internal DateTime mServiceDate;
internal bool mClosed;
internal string mClientRef;
internal string mClientContact;
internal string mClient;
internal string mHeadOffice;
//Case 228
internal string mSummary;
internal Guid mID;
public int LT_O_Workorder { get { return mWorkorder; } }
public string LT_WorkorderService_Label_InvoiceNumber { get { return mInvoice; } }
public DateTime LT_WorkorderService_Label_ServiceDate
{ get { return mServiceDate; } }
public bool LT_Workorder_Label_Closed { get { return mClosed; } }
public string LT_Workorder_Label_CustomerReferenceNumber
{ get { return this.mClientRef; } }
public string LT_Workorder_Label_CustomerContactName { get { return mClientContact; } }
public string LT_O_Client { get { return mClient; } }
public string LT_O_HeadOffice { get { return mHeadOffice; } }
public string LT_Workorder_Label_Summary { get { return mSummary; } }
public Guid ID { get { return mID; } }
//case 1169
internal bool mHasWikiPage;
public bool HasWikiPage { get { return mHasWikiPage; } }
//case 1175
internal string mUnits;
public string LT_O_Unit { get { return mUnits; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ClientWorkorderListExInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end ClientWorkorderListExInfo
#endregion
#region Constructor
protected ClientWorkorderListEx()
{
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ClientWorkorderListExInfo this[int Item]
{
get
{
return (ClientWorkorderListExInfo)List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (ClientWorkorderListExInfo child in List)
{
if (child.mID == ItemID) return child.ToString();
}
return "Missing: " + ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ClientWorkorderListExInfo obj)
{
foreach (ClientWorkorderListExInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ClientWorkorderListEx";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return "";
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
//Nothing so that no accidental possibility of
//client creating a workorder
return RootObjectTypes.Nothing;
}
}
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "WorkorderService.Label.List";
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(ClientWorkorderListExInfo);
}
}
#endregion
#region Static methods
/// <summary>
/// Get all Workorders for a specified head office
/// (returns all workorders for all clients under headOfficeID)
/// </summary>
/// <param name="headOfficeID"></param>
/// <param name="includeClosed">true= all workorders, false=open only</param>
/// <returns></returns>
public static ClientWorkorderListEx GetListForHeadOffice(Guid headOfficeID, bool includeClosed)
{
return (ClientWorkorderListEx)DataPortal.Fetch(new Criteria(headOfficeID, Guid.Empty,includeClosed));
}
/// <summary>
/// Get all Workorders for a specified client
/// </summary>
/// <param name="clientID">ID of client object</param>
/// <param name="includeClosed">true= all workorders, false=open only</param>
/// <returns></returns>
public static ClientWorkorderListEx GetListForClient(Guid clientID, bool includeClosed)
{
return (ClientWorkorderListEx)DataPortal.Fetch(new Criteria(Guid.Empty, clientID,includeClosed));
}
///// <summary>
///// Return an empty list
///// used for initializing grid
///// </summary>
///// <returns></returns>
//public static ClientWorkorderListEx GetEmptyList()
//{
// return new ClientWorkorderListEx();
//}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
//case 1262
string sClosed = "";
if (crit.IncludeClosed == false)
sClosed = " AND (AWORKORDER.ACLOSED=@False) ";
SafeDataReader dr = null;
try
{
string q = "";
if (crit.ClientID != Guid.Empty)
{
q = "SELECT " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERSERVICE.AINVOICENUMBER, " +
" AWORKORDERSERVICE.ASERVICEDATE, " +
" AWORKORDER.ACLOSED, " +
" AWORKORDER.ACUSTOMERREFERENCENUMBER, " +
" AWORKORDER.ACUSTOMERCONTACTNAME, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDER.AID, AWORKORDER.ASUMMARY, " +//case 228 added summary column
" AWIKIPAGE.AID AS AWIKIID " + //case 1169
"FROM " +
" AWORKORDERSERVICE " +
" INNER JOIN AWORKORDER ON (AWORKORDERSERVICE.AWORKORDERID = AWORKORDER.AID) " +
" INNER JOIN ACLIENT ON (AWORKORDER.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AWIKIPAGE ON (AWIKIPAGE.AROOTOBJECTID = AWORKORDER.AID) " + //case 1169
"WHERE " +
" (AWORKORDER.AWORKORDERTYPE = 1) AND AWORKORDER.ACLIENTID=@ID " +
sClosed + //case 1262
" ORDER BY AWORKORDERSERVICE.ASERVICENUMBER DESC ";
//case 1262
//dr = DBUtil.GetReaderFromSQLString(q, crit.ClientID);
}
else
{
q = "SELECT " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERSERVICE.AINVOICENUMBER, " +
" AWORKORDERSERVICE.ASERVICEDATE, " +
" AWORKORDER.ACLOSED, " +
" AWORKORDER.ACUSTOMERREFERENCENUMBER, " +
" AWORKORDER.ACUSTOMERCONTACTNAME, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDER.AID, AWORKORDER.ASUMMARY, " +//case 228 added summary column
" AWIKIPAGE.AID AS AWIKIID " + //case 1169
"FROM " +
" AWORKORDERSERVICE " +
" INNER JOIN AWORKORDER ON (AWORKORDERSERVICE.AWORKORDERID = AWORKORDER.AID) " +
" INNER JOIN ACLIENT ON (AWORKORDER.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AWIKIPAGE ON (AWIKIPAGE.AROOTOBJECTID = AWORKORDER.AID) " + //case 1169
"WHERE " +
" (AWORKORDER.AWORKORDERTYPE = 1) AND ACLIENT.AHEADOFFICEID=@ID " +
sClosed + //case 1262
" ORDER BY AWORKORDERSERVICE.ASERVICENUMBER DESC ";
//case 1262
//dr = DBUtil.GetReaderFromSQLString(q, crit.HeadOfficeID);
}
//case 1262
DBCommandWrapper cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
if (crit.ClientID != Guid.Empty)
cm.AddInParameter("@ID", DbType.Guid, crit.ClientID);
else
cm.AddInParameter("@ID", DbType.Guid, crit.HeadOfficeID);
if (crit.IncludeClosed == false)
cm.AddInParameter("@False", DbType.Boolean, false);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
//************************************************************
while (dr.Read())
{
//*******************************************
ClientWorkorderListExInfo info = new ClientWorkorderListExInfo();
info.mWorkorder = dr.GetInt32("ASERVICENUMBER");
info.mInvoice = dr.GetString("AINVOICENUMBER");
info.mServiceDate = DBUtil.ToLocal(dr.GetSmartDate("ASERVICEDATE")).Date;
info.mClosed = dr.GetBoolean("ACLOSED");
info.mClientRef = dr.GetString("ACUSTOMERREFERENCENUMBER");
info.mClientContact = dr.GetString("ACUSTOMERCONTACTNAME");
info.mClient = dr.GetString("ACLIENTNAME");
info.mHeadOffice = dr.GetString("AHEADOFFICENAME");
//Case 228
info.mSummary = dr.GetString("ASUMMARY");
info.mID = dr.GetGuid("AID");
info.mHasWikiPage = (dr.GetGuid("AWIKIID") != Guid.Empty);//case 1169
//case 1175
info.mUnits = "";
UnitPickList upl = UnitPickList.GetListByWorkorder(info.mID);
if (upl.Count > 0)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (UnitPickList.UnitPickListInfo i in upl)
{
string sName = i.UnitName();
if (!string.IsNullOrWhiteSpace(sName))
{
sb.Append(i.UnitName());
sb.Append("<br/>");
}
}
//chop off the trailing return
if(sb.Length>5)
sb.Length = sb.Length - 5;
info.mUnits = sb.ToString();
}
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public bool IncludeClosed;
public Guid HeadOfficeID;
public Guid ClientID;
public Criteria(Guid _HeadOfficeID, Guid _ClientID, bool _IncludeClosed)
{
HeadOfficeID = _HeadOfficeID;
ClientID = _ClientID;
IncludeClosed = _IncludeClosed;
}
}
#endregion
}//end ClientWorkorderListEx
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////
// ContactPhoneTypes.cs
// Implementation of Class ContactPhoneTypes
//
// Created on: 30-Jun-2004 12:37:00 PM
// Object design: John
// Coded: John 30-Jun-2004
///////////////////////////////////////////////////////////
using System;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// DEPRECATED v4.0
/// </summary>
public enum ContactPhoneTypes : int
{
/// <summary>
/// Used as illegal default to ensure
/// that parent object sets this correctly
/// </summary>
Unset=0,
/// <summary>
/// Business phone
/// </summary>
Business = 1,
/// <summary>
/// Cell phone
/// </summary>
Mobile = 4,
/// <summary>
/// Fax
/// </summary>
Fax = 5,
/// <summary>
/// Pager
/// </summary>
Pager = 6,
/// <summary>
/// Home phone
/// </summary>
Home = 8
}//end ContactPhoneTypes
}

View File

@@ -0,0 +1,371 @@
///////////////////////////////////////////////////////////
// ContactTitle.cs
// Implementation of Class ContactTitle
// CSLA type: Editable Child
// Created on: 07-Jun-2004 8:41:19 AM
// Object design: Joyce
// Coded: John 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL {
/// <summary>
/// Contact's title, i.e. "Mr.", "Mrs.", "Doctor", "Professor" etc
/// </summary>
[Serializable]
public class ContactTitle : BusinessBase {
#region Attributes
private bool bReadOnly;
private Guid mID;
private string mName=null;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ContactTitle()
{
MarkAsChild();
//Set to read / write initially so that properties
//can be set
bReadOnly=false;
//New ID
mID = Guid.NewGuid();
//pre-break the rule
Name="";
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified=new SmartDate();
mCreator=Guid.Empty;
mModifier=Guid.Empty;
}
#endregion
#region Business properties
/// <summary>
/// Get internal id number Read only property because it's set internally, not
/// externally
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// Set/get Name of item
///
/// </summary>
public string Name
{
get
{
return mName;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mName!=value)
{
mName = value;
BrokenRules.Assert("NameRequired","Error.Object.RequiredFieldEmpty,ContactTitle.Label.Name","Name",value.Length==0);
BrokenRules.Assert("NameLength",
"Error.Object.FieldLengthExceeded255,ContactTitle.Label.Name","Name",value.Length>255);
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.ContactTitle")
)
);
}
#endregion
#region System.Object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "ContactTitle" + mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
ContactTitle c=(ContactTitle)obj;
return mID==c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("ContactTitle" + mID).GetHashCode();
}
#endregion
#region Static methods
/// <summary>
/// Get new object
/// </summary>
/// <returns></returns>
internal static ContactTitle NewItem()
{
// if(AyaBizUtils.Right(RootObject)>(int)SecurityLevelTypes.ReadOnly)
// {
ContactTitle c=new ContactTitle();
return c;
// }
// else
// throw new System.Security.SecurityException(
// string.Format(
// LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
// LocalizedTextTable.GetLocalizedTextDirect("O.ContactTitle")));
}
/// <summary>
///
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
internal static ContactTitle GetItem(SafeDataReader dr)
{
// if(AyaBizUtils.Right(RootObject)>(int)SecurityLevelTypes.NoAccess)
// {
ContactTitle child = new ContactTitle();
child.Fetch(dr);
return child;
// }
// else
// throw new System.Security.SecurityException(
// string.Format(
// LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
// LocalizedTextTable.GetLocalizedTextDirect("O.ContactTitle")));
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Populate this object from the values in the datareader passed to it
/// </summary>
/// <param name="dr"></param>
private void Fetch(SafeDataReader dr)
{
//Standard fields
mID=dr.GetGuid("aID");
mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator=dr.GetGuid("aCreator");
mModifier=dr.GetGuid("aModifier");
//ContactTitle fields
//Important: use property not internal field
//so that initial broken rule is unbroken on fetch
Name=dr.GetString("aName");
MarkOld();
//Get access rights level
bReadOnly=false;//AyaBizUtils.Right(RootObject)<(int)SecurityLevelTypes.ReadWrite;
}
#endregion fetch
#region Update
/// <summary>
///
/// </summary>
/// <param name="tr"></param>
internal void Update(IDbTransaction tr)
{
//No need to update if there is nothing changed
if(!this.IsDirty) return;
// If not a new record, check if record was modified
//by another user since original retrieval:
if(!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"aContactTitle");
#region Delete
if(IsDeleted)
{
if(!IsNew)
{
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aContactTitle WHERE aID = @ID;");
cmDelete.AddInParameter("@ID",DbType.Guid,this.mID);
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
//-----------------------------
}
MarkNew();
return;
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if(IsNew)//Add or update?
cm=DBUtil.GetCommandFromSQL(
"INSERT INTO aContactTitle (aID, aName, aCreated,aModified,aCreator,aModifier) " +
"VALUES (@ID,@Name,@Created,@Modified,@CurrentUserID,@CurrentUserID)"
);
else
cm=DBUtil.GetCommandFromSQL(
"UPDATE aContactTitle SET aID=@ID, aName=@Name, aModifier=@CurrentUserID, " +
"aModified=@Modified WHERE " +
"aID=@ID"
);
//ContactTitle fields
cm.AddInParameter("@Name",DbType.String,mName);
//Standard fields
cm.AddInParameter("@ID",DbType.Guid,this.mID);
cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified));
DBUtil.DB.ExecuteNonQuery(cm, tr);
MarkOld();//db is now synched with object
//Successful update so
//change modification time to match
this.mModified.Date=dtModified;
#endregion
}
#endregion Update
#endregion
}//end ContactTitle
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,283 @@
///////////////////////////////////////////////////////////
// ContactTitles.cs
// Implementation of Class ContactTitles
// CSLA type: Editable root collection
// Created on: 04-Nov-2004
// Object design: John
// Coded: John 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// DEPRECATED v4.0
/// </summary>
[Serializable]
public class ContactTitles : BusinessCollectionBase
{
#region Constructor
//Private constructor prevents direction instantiation
private ContactTitles()
{
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "ContactTitle.Label.List";
}
}
/// <summary>
/// Retrieve ContactTitle by index
/// </summary>
/// <param name="Item">Index</param>
public ContactTitle this[int Item]
{
get
{
return (ContactTitle) List[Item];
}
}
/// <summary>
/// Retrieve ContactTitle by ID
/// </summary>
/// <param name="ID">ID</param>
public string TitleFromID(Guid ID)
{
foreach (ContactTitle child in List)
{
if (child.ID == ID)
{
return child.Name + " ";
}
}
return "";
}
/// <summary>
/// Remove ContactTitle by passing it in
/// </summary>
/// <param name="obj"></param>
public void Remove(ContactTitle obj)
{
List.Remove(obj);
}
/// <summary>
/// Remove by Guid value of ID
/// </summary>
/// <param name="ID"></param>
public void Remove(Guid ID)
{
ContactTitle delete = null;
foreach (ContactTitle child in List)
{
if (child.ID == ID)
{
delete = child;
break;
}
}
if (delete != null)
Remove(delete);
}
/// <summary>
/// Add a new ContactTitle to the collection
/// </summary>
public ContactTitle Add()
{
ContactTitle child=ContactTitle.NewItem();
List.Add(child);
return child;
}
/// <summary>
/// Add ContactTitle by passing it in
/// </summary>
/// <param name="obj"></param>
public void Add(ContactTitle obj)
{
List.Add(obj);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
protected override object OnAddNew()
{
ContactTitle child=ContactTitle.NewItem();
List.Add(child);
return child;
}
#endregion
#region Contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ContactTitle obj)
{
foreach (ContactTitle child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection
/// </summary>
/// <param name="obj"></param>
public bool ContainsDeleted(ContactTitle obj)
{
foreach (ContactTitle child in deletedList)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get item collection
/// </summary>
///
/// <returns></returns>
public static ContactTitles GetItems()
{
//in future specify criteria if filtering (e.g. filter by region)
ContactTitles col = new ContactTitles();
return (ContactTitles)DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
/// <summary>
/// Fetch children
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString("SELECT * FROM aContactTitle ORDER BY ANAME;");
while(dr.Read())
{
List.Add(ContactTitle.GetItem(dr));
}
}
finally
{
if(dr!=null) dr.Close();
}
}
/// <summary>
/// Editable Root Collection Update
/// </summary>
protected override void DataPortal_Update()
{
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction tr = connection.BeginTransaction();
try
{
//update (thus deleting) any deleted child objects
foreach (ContactTitle child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (ContactTitle child in List)
{
child.Update(tr);
}
tr.Commit();
}
catch
{
tr.Rollback();
throw;//WAS: throw(ex);
}
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
//public string ObjectName;
public Criteria(/*string _ObjectName*/)
{
//ObjectName=_ObjectName;
}
}
#endregion
}//end ContactTitles
}//end namespace GZTW.AyaNova.BLL

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,496 @@
///////////////////////////////////////////////////////////
// ContractList.cs
// Implementation of Class ContractList
// CSLA type: Read only collection
// Created on: 26-Jan-2005
// Object design: John
// Coded: 26-Jan-2005
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Lightweight list of <see cref="ContractList.ContractListInfo"/> objects representing <see cref="Contract"/> objects
///
/// </summary>
[Serializable]
public class ContractList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct ContractListInfo
{
internal GridNameValueCellItem mName; //and ID
internal bool mActive;
[SqlColumnNameAttribute("aContract.aName", "aContract.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Contract)]
public GridNameValueCellItem LT_O_Contract //changed 12-June-2006 was LT_Contract_Label_ID
{
get
{
return mName;
}
}
[Display(DisplayType.TrueFalse)]
public bool LT_Contract_Label_Active
{
get
{
return mActive;
}
}
internal decimal mDiscountParts;
[Display(DisplayType.Percentage)]
public decimal LT_Contract_Label_DiscountParts
{ get { return mDiscountParts; } }
internal bool mContractRatesOnly;
internal string mNotes;
[Display(DisplayType.TrueFalse)]
public bool LT_Contract_Label_ContractRatesOnly
{ get { return mContractRatesOnly; } }
[SqlColumnNameAttribute("grid"),Display(DisplayType.Text)]
public string LT_Contract_Label_Notes
{ get { return mNotes; } }
//Case 58
internal GridNameValueCellItem mRegion;
[SqlColumnNameAttribute("aRegion.aName", "aRegion.aID"),
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Region)]
public GridNameValueCellItem LT_O_Region
{
get
{
return mRegion;
}
}
internal string mCustom1;
internal string mCustom2;
internal string mCustom3;
internal string mCustom4;
internal string mCustom5;
internal string mCustom6;
internal string mCustom7;
internal string mCustom8;
internal string mCustom9;
internal string mCustom0;
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom1{get{return mCustom1;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom2{get{return mCustom2;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom3{get{return mCustom3;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom4{get{return mCustom4;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom5{get{return mCustom5;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom6{get{return mCustom6;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom7{get{return mCustom7;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom8{get{return mCustom8;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom9{get{return mCustom9;}}
[Display(DisplayType.Text)]
public string LT_Contract_Label_Custom0{get{return mCustom0;}}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ContractListInfo obj)
{
return this.mName.Value.Equals(obj.mName.Value);
}
}//end ContractListInfo
#endregion
#region Constructor
protected ContractList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public ContractListInfo this[int Item]
{
get
{
return (ContractListInfo) List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (ContractListInfo child in List)
{
if(child.mName.Value==ItemID) return child.ToString();
}
return "Missing: "+ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ContractListInfo obj)
{
foreach (ContractListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Reporting and shared UI editor helpers
/// <summary>
/// Returns the report key which is a property of
/// reports used to link all reports that can be used
/// with a particular data source.
/// </summary>
public static string ReportKey
{
get
{
return "ContractList";
}
}
/// <summary>
/// Returns the Detailed report key
/// which is used to determine which reports and objects
/// will be used for detailed reports
///
/// If empty string then indicates there is no detailed report object or reports
/// </summary>
public static string DetailedReportKey
{
get
{
return "";
}
}
/// <summary>
/// Base object that this list is reporting on
/// used by shared UI editor to instantiate new objects
/// when user selects new in UI elements that display this list
///
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
/// </summary>
public static RootObjectTypes BaseObjectType
{
get
{
return RootObjectTypes.Contract;
}
}
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "Contract.Label.List";
}
}
/// <summary>
/// The Type of the struct used to store list records
/// Used to fetch the custom display attributes of the fields
/// contained within the record to modify the grid display accordingly
/// <see cref="DisplayAttribute"/>
/// </summary>
public static Type ListRecordType
{
get
{
return typeof(ContractListInfo);
}
}
/// <summary>
/// Field that contains the ID of the objects
/// that are the basis of this list.
///
/// Used for compiling an ID list for reporting from user
/// selections in a grid.
/// </summary>
public static string IDField
{
get
{
return "LT_O_Contract";
}
}
/// <summary>
/// Same as IDField but for detailed reports
/// </summary>
public static string IDFieldDetailed
{
get
{
return IDField;
}
}
#endregion
#region Static methods
/// <summary>
/// Internal method used by list factory
/// </summary>
internal static ContractList Get(string Filter, int MaxRecords, List<Guid> IDList)
{
return (ContractList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
}
/// <summary>
/// Get all Contract (filtered by crit)
/// </summary>
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
/// <returns>list of <see cref="ContractList.ContractListInfo"/> objects</returns>
public static ContractList GetList(string xmlCriteria)
{
return (ContractList) DataPortal.Fetch(new Criteria(xmlCriteria,null,-1));
}
/// <summary>
/// Get list by items indicated in IDList
/// </summary>
/// <param name="IDList">Generic list of Guid's</param>
/// <returns>list of <see cref="ContractList.ContractListInfo"/> objects</returns>
public static ContractList GetListFromIDList(List<Guid> IDList)
{
//case 556
//Handle empty list
if (IDList.Count == 0)
return new ContractList();
return (ContractList)DataPortal.Fetch(new Criteria("", IDList, -1));
}
/// <summary>
/// Return an empty list
/// used for initializing grid
/// </summary>
/// <returns></returns>
public static ContractList GetEmptyList()
{
return new ContractList();
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q="";
if (crit.IDList != null)
{
//Case 556
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
sbIN.Append(" WHERE aContract.aID in (");
foreach (Guid gItem in crit.IDList)
{
sbIN.Append("'");
sbIN.Append("{");
sbIN.Append(gItem.ToString().ToUpperInvariant());
sbIN.Append("}");
sbIN.Append("',");
}
sbIN.Length = sbIN.Length - 1;
sbIN.Append(") ");
q = "SELECT aContract.aID AS aContractID, aContract.aName AS aContractName, " +
"aContract.AACTIVE, " +
" aContract.aRegionID, aRegion.aName AS aRegionName, " + //case 58
" aContract.aCustom1, " +
" aContract.aCustom2, aContract.aCustom3, " +
" aContract.aCustom4, " +
" aContract.aCustom5, aContract.aCustom6, " +
" aContract.aCustom7, aContract.aCustom8, " +
" aContract.aCustom9, " +
" aContract.aCustom0, aDiscountParts, aContractRatesOnly,aNotes " +
"FROM aContract " +
"LEFT OUTER JOIN aRegion ON aContract.aRegionID = aRegion.aID " + //Case 58
sbIN.ToString() +
" " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
}
else
{
//************************************************************
q = "SELECT ~MAXRECS~ aContract.aID AS aContractID, aContract.aName AS aContractName, " +
"aContract.AACTIVE, " +
" aContract.aRegionID, aRegion.aName AS aRegionName, " +
" aContract.aCustom1, " +
" aContract.aCustom2, aContract.aCustom3, " +
" aContract.aCustom4, " +
" aContract.aCustom5, aContract.aCustom6, " +
" aContract.aCustom7, aContract.aCustom8, " +
" aContract.aCustom9, " +
" aContract.aCustom0, aDiscountParts, aContractRatesOnly,aNotes " +
"FROM aContract " +
"LEFT OUTER JOIN aRegion ON aContract.aRegionID = aRegion.aID " + //Case 58
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML, true) + " " +
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
//************************************************************
}
dr=DBUtil.GetReaderFromSQLString(DBUtil.AddRegionFilter(q,"aContract",""));//case 58
while(dr.Read())
{
//*******************************************
ContractListInfo info=new ContractListInfo();
info.mName=new GridNameValueCellItem(
dr.GetGuid("aContractID"),
dr.GetString("aContractName"),
RootObjectTypes.Contract);
//Case 58
info.mRegion = new GridNameValueCellItem(
dr.GetGuid("aRegionID"),
dr.GetString("aRegionName"),
RootObjectTypes.Region);
info.mActive=dr.GetBoolean("AACTIVE");
info.mCustom0=dr.GetString("aCustom0");
info.mCustom1=dr.GetString("aCustom1");
info.mCustom2=dr.GetString("aCustom2");
info.mCustom3=dr.GetString("aCustom3");
info.mCustom4=dr.GetString("aCustom4");
info.mCustom5=dr.GetString("aCustom5");
info.mCustom6=dr.GetString("aCustom6");
info.mCustom7=dr.GetString("aCustom7");
info.mCustom8=dr.GetString("aCustom8");
info.mCustom9=dr.GetString("aCustom9");
info.mDiscountParts=dr.GetDecimal("aDiscountParts");
info.mContractRatesOnly=dr.GetBoolean("aContractRatesOnly");
info.mNotes=dr.GetString("aNotes");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public List<Guid> IDList;
public string CriteriaXML;
public int MaxRecords;
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords)
{
CriteriaXML = _CriteriaXML;
IDList = _IDList;
MaxRecords = _MaxRecords;
}
}
#endregion
}//end ContractList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,379 @@
///////////////////////////////////////////////////////////
// ContractRate.cs
// Implementation of Class ContractRate
// CSLA type: Editable Child
// Created on: 07-Jun-2004 8:41:22 AM
// Object design: Joyce
// Coded: John 14-July-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL {
/// <summary>
/// Rate applicable to <see cref="Contract"/> only
/// </summary>
[Serializable]
public class ContractRate : BusinessBase {
#region Attributes
private bool bReadOnly;
private Guid mID;
private Guid mCreator;
private Guid mModifier;
private SmartDate mCreated;
private SmartDate mModified;
/// <summary>
/// Guid ID of root object (contract)
/// </summary>
private Guid mContractID;
/// <summary>
/// ID of rate (this brings over the name, account number, etc check with john if
/// need more
/// </summary>
private Guid mRateID;
#endregion
#region Constructor
private ContractRate()
{
//Set to read / write initially so that properties
//can be set
bReadOnly=false;
//Child object
MarkAsChild();
//New ID
mID = Guid.NewGuid();
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified=new SmartDate();
mCreator=Guid.Empty;
mModifier=Guid.Empty;
}
#endregion
#region Business Properties
//---Common properties
/// <summary>
/// Initial created date of this object
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// User ID of who initially created this object
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Last modified date of this object
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// User ID of who last modified this object
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// Unique ID of this object
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
//---ContractRate specific properties
/// <summary>
/// Guid ID of root object (contract)
/// </summary>
public Guid ContractID
{
get
{
return mContractID;
}
}
/// <summary>
/// ID of rate (this brings over the name, account number, etc check with john if
/// need more
/// </summary>
public Guid RateID
{
get
{
return mRateID;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mRateID!=value)
{
mRateID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.ContractRate")
)
);
}
#endregion
#region System.object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "ContractRate" + mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
ContractRate c=(ContractRate)obj;
return mID==c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("ContractRate" + mID).GetHashCode();
}
#endregion
#region Static methods
/// <summary>
/// Create item
/// </summary>
/// <param name="obj">Parent ID</param>
/// <returns>New Item</returns>
internal static ContractRate NewItem(Contract obj)
{
if(AyaBizUtils.Right("Object.ContractRate")>(int)SecurityLevelTypes.ReadOnly)
{
ContractRate child=new ContractRate();
child.mContractID=obj.ID;
return child;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("O.ContractRate")));
}
/// <summary>
/// Retrieve item
/// </summary>
/// <param name="dr">Data reader</param>
/// <returns>item from database</returns>
internal static ContractRate GetItem(SafeDataReader dr)
{
if(AyaBizUtils.Right("Object.ContractRate")>(int)SecurityLevelTypes.NoAccess)
{
ContractRate child = new ContractRate();
child.Fetch(dr);
return child;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("O.ContractRate")));
}
#endregion
#region DAL DATA ACCESS
/// <summary>
/// Fetch from db
/// </summary>
/// <param name="dr"></param>
private void Fetch(SafeDataReader dr)
{
//Standard items
mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mCreator=dr.GetGuid("aCreator");
mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mModifier=dr.GetGuid("aModifier");
//ContractRate specific parameters
mID=dr.GetGuid("aID");
mContractID=dr.GetGuid("aContractID");
mRateID=dr.GetGuid("aRateID");
//Get access rights level
bReadOnly=AyaBizUtils.Right("Object.ContractRate")<(int)SecurityLevelTypes.ReadWrite;
MarkOld();
}
/// <summary>
/// Persist object to database
/// </summary>
/// <param name="obj">Parent object</param>
/// <param name="tr">Parents transaction object</param>
internal void Update(Contract obj,IDbTransaction tr)
{
//No need to update if there is nothing changed
if(!this.IsDirty) return;
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
// If not a new record, check if record was modified
//by another user since original retrieval:
if(!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"aContractRate");
#region Delete
if(IsDeleted)
{
if(!IsNew)
{
//Delete
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aContractRate WHERE aID = @ID;");
cmDelete.AddInParameter("@ID",DbType.Guid,this.mID);
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
}
MarkNew();
return;
}
#endregion
#region Add / Update
DBCommandWrapper cm = null;
if(IsNew)//Add or update?
cm=DBUtil.GetCommandFromSQL(
"INSERT INTO aContractRate (aRateID, aContractID, aID, aCreated, aModified, aCreator,aModifier) " +
"VALUES (@RateID,@ContractID,@ID, @Created, @Modified, @CurrentUserID,@CurrentUserID)"
);
else
cm=DBUtil.GetCommandFromSQL(
"UPDATE aContractRate SET aRateID=@RateID, aContractID=@ContractID, " +
"aID=@ID, aModifier=@CurrentUserID, " +
"aModified=@Modified WHERE aID=@ID"
);
//ContractRate fields
cm.AddInParameter("@ID",DbType.Guid,mID);
cm.AddInParameter("@ContractID",DbType.Guid,mContractID);
cm.AddInParameter("@RateID",DbType.Guid,mRateID);
//Standard fields
cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified));
DBUtil.DB.ExecuteNonQuery(cm, tr);
MarkOld();//db is now synched with object
//Successful update so
//change modification time to match
this.mModified.Date=dtModified;
#endregion
}
#endregion
}//end ContractRate
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,244 @@
///////////////////////////////////////////////////////////
// ContractRates.cs
// Implementation of Class ContractRates
// CSLA type: Editable child collection
// Created on: 07-Jun-2004 8:41:22 AM
// Object design: Joyce
// Coded: John 28-July-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Editable child collection of <see cref="ContractRate"/> objects
/// </summary>
[Serializable]
public class ContractRates : BusinessCollectionBase {
#region Constructor
//Private constructor prevents direction instantiation
private ContractRates()
{
//Child
MarkAsChild();
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
/// <summary>
/// Retrieve ContractRate by index
/// </summary>
/// <param name="Item">Index</param>
public ContractRate this[int Item]
{
get
{
return (ContractRate) List[Item];
}
}
/// <summary>
/// Retrieve ContractRate by string containing Guid value
/// </summary>
public ContractRate this[string ContractRateID]
{
get
{
System.Guid sid = new System.Guid(ContractRateID);
foreach (ContractRate child in List)
{
if(child.ID==sid)
return child;
}
return null;
}
}
/// <summary>
/// Remove ContractRate by passing it in
/// </summary>
/// <param name="obj"></param>
public void Remove(ContractRate obj)
{
List.Remove(obj);
}
/// <summary>
/// Remove ContractRate by string of id value
/// </summary>
/// <param name="ContractRateID"></param>
public void Remove(string ContractRateID)
{
System.Guid sid = new System.Guid(ContractRateID);
foreach (ContractRate child in List)
{
if(child.ID==sid)
List.Remove(child);
}
}
/// <summary>
/// Remove by Guid value of ID
/// </summary>
/// <param name="ContractRateID"></param>
public void Remove(Guid ContractRateID)
{
foreach (ContractRate child in List)
{
if(child.ID==ContractRateID)
List.Remove(child);
}
}
/// <summary>
/// Add a new ContractRate to the collection
/// </summary>
/// <param name="obj"></param>
public ContractRate Add(Contract obj)
{
ContractRate child=ContractRate.NewItem(obj);
List.Add(child);
return child;
}
#endregion
#region Contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ContractRate obj)
{
foreach (ContractRate child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in collection by string of ID value
/// </summary>
/// <param name="ContractRateID"></param>
public bool Contains(string ContractRateID)
{
System.Guid sid = new System.Guid(ContractRateID);
foreach (ContractRate child in List)
{
if(child.ID==sid) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection
/// </summary>
/// <param name="obj"></param>
public bool ContainsDeleted(ContractRate obj)
{
foreach (ContractRate child in deletedList)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection by string of ID value
/// </summary>
/// <param name="ContractRateID"></param>
public bool ContainsDeleted(string ContractRateID)
{
System.Guid sid = new System.Guid(ContractRateID);
foreach (ContractRate child in deletedList)
{
if(child.ID==sid) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// NewItems
/// </summary>
/// <returns></returns>
internal static ContractRates NewItems()
{
return new ContractRates();
}
/// <summary>
/// GetItems
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
internal static ContractRates GetItems(SafeDataReader dr)
{
ContractRates col = new ContractRates();
col.Fetch(dr);
return col;
}
#endregion
#region DAL DATA ACCESS
/// <summary>
/// Fetch children
/// </summary>
/// <param name="dr">Populated data reader</param>
private void Fetch(SafeDataReader dr)
{
while(dr.Read())
{
List.Add(ContractRate.GetItem(dr));
}
}
/// <summary>
/// Update children
/// </summary>
/// <param name="obj"></param>
/// <param name="tr"></param>
internal void Update(Contract obj,IDbTransaction tr)
{
//update (thus deleting) any deleted child objects
foreach (ContractRate child in deletedList)
{
child.Update(obj,tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (ContractRate child in List)
{
child.Update(obj,tr);
}
}
#endregion
}//end ContractRates
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,129 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class ContractResolver
// CSLA type: Read-only object
// Created on: 1-Nov-2007
// Object design: John
// Coded: 1-Nov-2007
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
//case 496
/// <summary>
///Returns service bankable object most responsible
/// for banking based on client
/// </summary>
[Serializable, EditorBrowsable(EditorBrowsableState.Never)]
internal class ContractResolver : ReadOnlyBase
{
#region Attributes
private Contract mContract;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private ContractResolver()
{
mContract = null;
}
#endregion
#region Static methods
/// <summary>
/// Resolve the contract reponsible for client id specified
/// if no contract then resolves to null
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
internal static Contract ResolvedContract(Guid ID)
{
if (AyaBizUtils.Lite) return null;
return ((ContractResolver)DataPortal.Fetch(new Criteria(ID))).mContract;
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString(
"SELECT ACLIENT.ACONTRACTID AS CCID, AHEADOFFICE.ACONTRACTID AS HOCID, " +
"ACLIENT.ACONTRACTEXPIRES AS CCEXPIRES, AHEADOFFICE.ACONTRACTEXPIRES AS HOEXPIRES " +
"FROM ACLIENT " +
"LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID=AHEADOFFICE.AID) " +
"WHERE ACLIENT.AID= @ID", crit.ID);
if (dr.Read())
{
Guid cg = dr.GetGuid("CCID");
SmartDate cd = DBUtil.ToLocal(dr.GetSmartDate("CCEXPIRES"));
Guid hg = dr.GetGuid("HOCID");
SmartDate hd = DBUtil.ToLocal(dr.GetSmartDate("HOEXPIRES"));
//Mirrors code in Client.ContractInEffect and head office same
if ((cg != Guid.Empty) && (!cd.IsEmpty) && (cd.Date > DBUtil.CurrentWorkingDateTime))
mContract=Contract.GetItemNoMRU(cg);
else if ((hg != Guid.Empty) && (!hd.IsEmpty) && (hd.Date > DBUtil.CurrentWorkingDateTime))
mContract=Contract.GetItemNoMRU(hg);
//default is null contract
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID = _ID;
}
}
#endregion
}//end class
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////
// CoordinateTypes.cs
// Implementation of Class CoordinateTypes
//
// Created on: 29-Jun-2004 12:06:00 PM
// Object design: John
// Coded: John 30-Jun-2004
///////////////////////////////////////////////////////////
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Geographical co-ordinate nomenclature to use
/// </summary>
[TypeConverter(typeof(EnumDescConverter))]
public enum CoordinateTypes : int
{
/// <summary>
/// Decimal degrees (DDD.ddd°)
/// </summary>
[Description("LT:CoordinateTypes.Label.DecimalDegrees")] DecimalDegrees = 1,
/// <summary>
/// Degrees minutes (DDD° MM.mmm)
/// </summary>
[Description("LT:CoordinateTypes.Label.DegreesDecimalMinutes")] DegreesDecimalMinutes = 2,
/// <summary>
/// Degrees Minutes Seconds (DDD° MM' SS.sss')
/// </summary>
[Description("LT:CoordinateTypes.Label.DegreesMinutesSeconds")] DegreesMinutesSeconds = 3
}//end CoordinateTypes
}

View File

@@ -0,0 +1,121 @@
///////////////////////////////////////////////////////////
// CustomerDashBoardClientServiceRequestCountRI.cs
// Implementation of Class CustomerDashBoardClientServiceRequestCountRI
// CSLA type: Read only collection
// Created on: 9-Feb-2016
// Coded: John 8-Feb-2016
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
[Serializable]
public class CustomerDashBoardClientServiceRequestCountRI : ReadOnlyBase
{
public long _Count = 0;
#region Constructor
protected CustomerDashBoardClientServiceRequestCountRI()
{
}
#endregion
#region Static methods
public static long Get()
{
return ((CustomerDashBoardClientServiceRequestCountRI)DataPortal.Fetch(new Criteria()))._Count;
}
#endregion
#region DAL DATA ACCESS
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
UserTypes currentUserType = User.CurrentUserType;
if (currentUserType != UserTypes.HeadOffice && currentUserType != UserTypes.Client)
throw new System.NotSupportedException("CustomerDashBoardList::Get-> Can only be called by a head office or client user type");
bool isHeadOffice = User.CurrentUserType == UserTypes.HeadOffice;
Guid custID=Guid.Empty;
if(isHeadOffice)
custID=User.GetItem(User.CurrentThreadUserID).HeadOfficeID;
else
custID = User.GetItem(User.CurrentThreadUserID).ClientID;
if (custID == Guid.Empty)
throw new System.ArgumentException("CustomerDashBoardClientServiceRequestCountRI->custID is empty, current user does not have a valid client or headoffice ID.\r\nThis method can only be called by a head office or client user type");
SafeDataReader dr = null;
try
{
DBCommandWrapper cm = null;
string q = string.Empty;
if (isHeadOffice)
{
q =
"SELECT COUNT(*) FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" WHERE ACLIENTSERVICEREQUEST.ASTATUS=0 AND ACLIENT.AHEADOFFICEID=@ID";
}
else
{
q =
"SELECT COUNT(*) FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" WHERE ACLIENTSERVICEREQUEST.ASTATUS=0 AND ACLIENTSERVICEREQUEST.ACLIENTID=@ID";
}
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@ID", DbType.Guid, custID);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
while (dr.Read())
{
object o = dr.GetValue(0);
_Count = long.Parse(o.ToString());
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Criteria()
{
}
}
#endregion
}//end CustomerDashBoardClientServiceRequestCountRI
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,120 @@
///////////////////////////////////////////////////////////
// CustomerDashBoardOpenServiceWOCountRI.cs
// Implementation of Class CustomerDashBoardOpenServiceWOCountRI
// CSLA type: Read only collection
// Created on: 9-Feb-2016
// Coded: John 8-Feb-2016
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
[Serializable]
public class CustomerDashBoardOpenServiceWOCountRI : ReadOnlyBase
{
public long _Count = 0;
#region Constructor
protected CustomerDashBoardOpenServiceWOCountRI()
{
}
#endregion
#region Static methods
public static long Get()
{
return ((CustomerDashBoardOpenServiceWOCountRI)DataPortal.Fetch(new Criteria()))._Count;
}
#endregion
#region DAL DATA ACCESS
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
UserTypes currentUserType = User.CurrentUserType;
if (currentUserType != UserTypes.HeadOffice && currentUserType != UserTypes.Client)
throw new System.NotSupportedException("CustomerDashBoardList::Get-> Can only be called by a head office or client user type");
bool isHeadOffice = User.CurrentUserType == UserTypes.HeadOffice;
Guid custID=Guid.Empty;
if(isHeadOffice)
custID=User.GetItem(User.CurrentThreadUserID).HeadOfficeID;
else
custID = User.GetItem(User.CurrentThreadUserID).ClientID;
if (custID == Guid.Empty)
throw new System.ArgumentException("CustomerDashBoardOpenServiceWOCountRI->custID is empty, current user does not have a valid client or headoffice ID.\r\nThis method can only be called by a head office or client user type");
SafeDataReader dr = null;
try
{
DBCommandWrapper cm = null;
string q = string.Empty;
if (isHeadOffice)
{
q =
"SELECT COUNT(*) FROM AWORKORDER " +
"INNER JOIN ACLIENT ON (ACLIENT.AID=AWORKORDER.ACLIENTID) " +
"WHERE AWORKORDER.AWORKORDERTYPE = 1 AND AWORKORDER.ACLOSED = 0 " +
"AND ACLIENT.AHEADOFFICEID = @ID";
}
else
{
q =
"SELECT COUNT(*) FROM AWORKORDER " +
"WHERE AWORKORDER.AWORKORDERTYPE = 1 AND AWORKORDER.ACLOSED = 0 " +
"AND AWORKORDER.ACLIENTID = @ID";
}
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@ID", DbType.Guid, custID);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
while (dr.Read())
{
object o = dr.GetValue(0);
_Count = long.Parse(o.ToString());
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Criteria()
{
}
}
#endregion
}//end CustomerDashBoardOpenServiceWOCountRI
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////
// CustomerDashboardInfoRI.cs
// Implementation of Class CustomerDashboardInfoRI
// CSLA type: Read-only object
// Created on: 10-Feb-2016
// Object design: John
// Coded: John 10-Feb-2016
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Fetches header and user information for RI Customer portal dashboard form / page
/// </summary>
[Serializable]
public class CustomerDashboardInfoRI : ReadOnlyBase
{
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private CustomerDashboardInfoRI()
{
}
public long OpenServiceWOCount { get; private set; }
public long OpenCSRCount { get; private set; }
public static CustomerDashboardInfoRI Get()
{
CustomerDashboardInfoRI di = new CustomerDashboardInfoRI();
UserTypes currentUserType=User.CurrentUserType;
if (currentUserType != UserTypes.HeadOffice && currentUserType != UserTypes.Client)
throw new System.NotSupportedException("CustomerDashBoardList::Get-> Can only be called by a head office or client user type");
bool isHeadOffice = User.CurrentUserType == UserTypes.HeadOffice;
di.OpenCSRCount = CustomerDashBoardClientServiceRequestCountRI.Get();
di.OpenServiceWOCount = CustomerDashBoardOpenServiceWOCountRI.Get();
return di;
}
}//eoc
#pragma warning restore 1591
}//ens

View File

@@ -0,0 +1,225 @@
///////////////////////////////////////////////////////////
// CustomizableObjectList.cs
// Implementation of Class CustomizableObjectList
// CSLA type: Read only collection
// Created on: 14-Jan-2006
// Object design: John
// Coded: 14-Jan-2006
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of CustomizableObjects
///
/// </summary>
[Serializable]
public class CustomizableObjectList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct CustomizableObjectListInfo
{
internal string mName;
internal string mKey;
public string LT_ObjectCustomField_Label_ObjectName
{
get
{
return mName;
}
}
public string Key
{
get
{
return mKey;
}
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(CustomizableObjectListInfo obj)
{
return this.Key.Equals(obj.Key);
}
}//end CustomizableObjectListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected CustomizableObjectList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public CustomizableObjectListInfo this[int Item]
{
get
{
return (CustomizableObjectListInfo) List[Item];
}
}
// /// <summary>
// /// Returns display text that matches passed in itemid value
// /// </summary>
// /// <param name="ItemID"></param>
// public string this[Guid ItemID]
// {
//
// get
// {
// foreach (CustomizableObjectListInfo child in List)
// {
// if(child.ID==ItemID) return child.ToString();
// }
// return "Missing: "+ItemID.ToString();
// }
// }
#endregion
#region contains
// /// <summary>
// /// Check if item in collection
// /// </summary>
//
// /// <param name="obj"></param>
// public bool Contains(CustomizableObjectListInfo obj)
// {
// foreach (CustomizableObjectListInfo child in List)
// {
// if(child.Equals(obj)) return true;
// }
// return false;
//
// }
#endregion
#region Static methods
/// <summary>
/// Get list
/// </summary>
/// <returns></returns>
public static CustomizableObjectList GetList()
{
return (CustomizableObjectList) DataPortal.Fetch(new Criteria());
}
/// <summary>
/// Return an empty list
/// used for initializing grid
/// </summary>
/// <returns></returns>
public static CustomizableObjectList GetEmptyList()
{
return new CustomizableObjectList();
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
SafeDataReader dr = null;
try
{
DBCommandWrapper cm = DBUtil.DB.GetSqlStringCommandWrapper(
"SELECT DISTINCT aKey FROM aLocalizedText WHERE aKey " +
"LIKE @aCUSTOMCRIT"
);
cm.AddInParameter("@aCUSTOMCRIT",DbType.String, "%.Label.Custom1");
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
while(dr.Read())
{
//*******************************************
CustomizableObjectListInfo info=new CustomizableObjectListInfo();
info.mKey=dr.GetString("aKey").Replace(".Label.Custom1","");
info.mName=LocalizedTextTable.GetLocalizedTextDirect("O."+info.mKey);
InnerList.Add(info);
//*******************************************
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
//public string CriteriaXML;
public Criteria( /*string _CriteriaXML*/)
{
//CriteriaXML=_CriteriaXML;
}
}
#endregion
}//end CustomizableObjectList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,121 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class DBDtPfc
// CSLA type: Read-only object
// Created on: 26-April-2016
// Object design: John
// Coded: 26-April-2016
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
//case 2094
/// <summary>
/// Preflight check to ensure date is accurate on server
/// </summary>
[Serializable, EditorBrowsable(EditorBrowsableState.Never)]
internal class DBDtPfc : ReadOnlyBase
{
#region Attributes
bool _Ok = false;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private DBDtPfc()
{
}
#endregion
#region Static methods
internal static bool CheckIt()
{
return ((DBDtPfc)DataPortal.Fetch(new Criteria()))._Ok;
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
//No record in the db should have a modified date that is more than 26 hours newer than the current system date and time
//(26 hours due to international date line time zone diffs)
DateTime dtMaxDbDateAllowed = DateTime.UtcNow.AddHours(26);
DateTime dtDbItem = DateTime.MinValue;
//do not check users because simply logging in and out with the wrong date would fuck up the db
//dates which we do not want to happen accidentally
////SELECT MAX(AMODIFIED) FROM AUSER
//dtDbItem = DBUtil.ScalarToDate(DBUtil.DB.ExecuteScalar(DBUtil.GetCommandFromSQL(AyaBizUtils.Ec("5$ 6&2A!2=N !<!/'%6!OA*!*+A-&6#3", "false"))));
//if (dtDbItem > dtMaxDbDateAllowed) return;
//SELECT MAX(AMODIFIED) FROM AWORKORDER
dtDbItem = DBUtil.ScalarToDate(DBUtil.DB.ExecuteScalar(DBUtil.GetCommandFromSQL(AyaBizUtils.Ec("5$ 6&2A!2=N !<!/'%6!OA*!*+A-$*4*#!!#3", "false"))));
if (dtDbItem > dtMaxDbDateAllowed) return;
//SELECT MAX(AMODIFIED) FROM AVENDOR
dtDbItem = DBUtil.ScalarToDate(DBUtil.DB.ExecuteScalar(DBUtil.GetCommandFromSQL(AyaBizUtils.Ec("5$ 6&2A!2=N !<!/'%6!OA*!*+A-% (%#!", "false"))));
if (dtDbItem > dtMaxDbDateAllowed) return;
//SELECT MAX(AMODIFIED) FROM ACLIENT
dtDbItem = DBUtil.ScalarToDate(DBUtil.DB.ExecuteScalar(DBUtil.GetCommandFromSQL(AyaBizUtils.Ec("5$ 6&2A!2=N !<!/'%6!OA*!*+A-0)/$\"'", "false"))));
if (dtDbItem > dtMaxDbDateAllowed) return;
//SELECT MAX(AMODIFIED) FROM APART
dtDbItem = DBUtil.ScalarToDate(DBUtil.DB.ExecuteScalar(DBUtil.GetCommandFromSQL(AyaBizUtils.Ec("5$ 6&2A!2=N !<!/'%6!OA*!*+A-#$45", "false"))));
if (dtDbItem > dtMaxDbDateAllowed) return;
//SELECT MAX(AMODIFIED) FROM APARTSERIAL
dtDbItem = DBUtil.ScalarToDate(DBUtil.DB.ExecuteScalar(DBUtil.GetCommandFromSQL(AyaBizUtils.Ec("5$ 6&2A!2=N !<!/'%6!OA*!*+A-#$45?67/ ", "false"))));
if (dtDbItem > dtMaxDbDateAllowed) return;
//SELECT MAX(AMODIFIED) FROM AUNIT
dtDbItem = DBUtil.ScalarToDate(DBUtil.DB.ExecuteScalar(DBUtil.GetCommandFromSQL(AyaBizUtils.Ec("5$ 6&2A!2=N !<!/'%6!OA*!*+A-&+/5", "false"))));
if (dtDbItem > dtMaxDbDateAllowed) return;
//Made it here, all ok
_Ok = true;
return;
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
}
#endregion
}//end class
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,207 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class DBInfo
// CSLA type: Read-only object
// Created on: 26-Dec-2008
// Object design: John
// Coded: John 26-Dec-2008
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Retrieves useful info about the database server
/// </summary>
[Serializable]
public class DBInfo : ReadOnlyBase //case 570
{
#pragma warning disable 1591
#region Attributes
private string mVersion;
/// <summary>
/// Database server version
/// </summary>
public string Version
{
get { return mVersion; }
}
private string mDBServerType;
/// <summary>
/// Database server type
/// </summary>
public string DBServerType
{
get { return mDBServerType; }
}
private string _FingerPrint;
/// <summary>
/// Fingerprint of database schema
/// used to determine schema corruption
/// or 3rd party changes to the schema
/// </summary>
public string FingerPrint
{
get { return _FingerPrint; }
set { _FingerPrint = value; }
}
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private DBInfo()
{
}
#endregion
#region Static methods
public static DBInfo GetInfo()
{
return (DBInfo)DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
string q = "";
try
{
#region server type and version
DataBaseType currentdbtype = DBUtil.DB.DBType;
if (currentdbtype == DataBaseType.MSSQL)
{
q = "select SERVERPROPERTY('PRODUCTVERSION')";
mDBServerType = "MSSQL";
mVersion = System.Convert.ToString(DBUtil.GetScalarFromSQLString(q));
}
else if (currentdbtype == DataBaseType.FireBird)
{
q = "SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database";
mDBServerType = "FireBird";
//case 1082, apparently the above doesnt' query the server itself, it checks variables stored in the database
//so unless the db was created with FB 2.x tools it will barf when the query is run which is trouble for AyaNova
//3.x people updating.
//since this is buggy, I'm removing it for now entirely as there is no consistent safe way to check the db server
//version, the thrust of this was more aimed at SQL server anyway.
mVersion = "Unknown";
//try
//{
// mVersion = System.Convert.ToString(DBUtil.GetScalarFromSQLString(q));
//}
//catch (Exception ex)
//{
// mVersion = "unknown";
//}
}
#endregion server type and version
#region fingerprint
_FingerPrint = DBUtil.DB.SchemaFingerPrint;
//if (currentdbtype == DataBaseType.FireBird)
//{
// using (IDbConnection cn = DBUtil.DB.GetConnection())
// {
// cn.Open();
// }
// try
// {
// }
// catch (Exception ex)
// {
// FingerPrint = "Error: " + ex.Message;
// throw;
// }
// finally
// {
// if (cn != null)
// cn.Close();
// }
//}
//else if (currentdbtype == DataBaseType.MSSQL)
//{
// //q = "select SERVERPROPERTY('PRODUCTVERSION')";
// _FingerPrint = "blah";
//}
#endregion
}
catch (Exception ex)
{
mVersion = "Error: Can't retrieve database server version, likely an old unsupported version, error was:\r\n " + ex.Message;
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
//public Guid ReportID;
public Criteria( /*Guid _ReportID*/)
{
//ReportID=_ReportID;
}
}
#endregion
#pragma warning restore 1591
}//end class
}//end namespace GZTW.AyaNova.BLL

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,938 @@
using System;
using CSLA.Data;
using CSLA;
using GZTW.Profile;
using GZTW.Data;
using System.Data;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Various DB helpers to save duplication
/// in individual business objects
/// </summary>
public class DBUtil
{
#region construction and initialization
static DBUtil()
{
}
#endregion
#region DataBase
private static GZTWDatabase _DB = null;
//private static AyaNovaConnectionSettings _ConnectionSettings=null;
internal static GZTWDatabase DB
{
get
{
//if(_ConnectionSettings==null)
//{
// _ConnectionSettings=new AyaNovaConnectionSettings();
// _ConnectionSettings.GetConnectionData();
//}
if(_DB==null)
_DB=GZTWDatabaseFactory.CreateDatabase(AyaBizUtils.AyaNovaConnectionSetting);
return _DB;
}
}
#endregion
#region Fetch data helpers
/// <summary>
/// Return a reader based on query with no parameters
/// </summary>
/// <param name="SqlCommandString">SQL query</param>
/// <returns></returns>
internal static SafeDataReader GetReaderFromSQLString(string SqlCommandString)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
return new SafeDataReader(DB.ExecuteReader(dbCommandWrapper));
}
/// <summary>
/// Return a reader based on query with no parameters
/// </summary>
/// <param name="SqlCommandString">SQL query</param>
/// <param name="tr">Database transaction</param>
/// <returns></returns>
internal static SafeDataReader GetReaderFromSQLString(string SqlCommandString, IDbTransaction tr)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
return new SafeDataReader(DB.ExecuteReader(dbCommandWrapper, tr));
}
/// <summary>
/// Return a reader based on query and ID parameter
/// </summary>
/// <param name="SqlCommandString">SQL with single ID paramter</param>
/// <param name="ID">ID of record desired</param>
/// <returns></returns>
internal static SafeDataReader GetReaderFromSQLString(string SqlCommandString, Guid ID)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
dbCommandWrapper.AddInParameter("@ID",DbType.Guid,ID);
return new SafeDataReader(DB.ExecuteReader(dbCommandWrapper));
}
/// <summary>
/// Return a reader based on query and ID parameter
/// without using parameters for performance in a tight loop
/// </summary>
/// <param name="SqlCommandString">SQL with single ID paramter</param>
/// <param name="ID">ID of record desired</param>
/// <returns></returns>
internal static SafeDataReader GetReaderFromSQLStringParameterlessly(string SqlCommandString, Guid ID)
{
//if empty (null) then let normal method handle
//because it can't be done dynamically propery
if(ID==Guid.Empty)
return GetReaderFromSQLString(SqlCommandString,ID);
string strParameter="'{"+ID.ToString().ToUpper()+"}'";
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString.Replace("@ID",strParameter));
return new SafeDataReader(DB.ExecuteReader(dbCommandWrapper));
}
/// <summary>
/// Return a reader based on query and ID parameter
/// and database transaction
/// </summary>
/// <param name="SqlCommandString">SQL with single ID paramter</param>
/// <param name="ID">ID of record desired</param>
/// <param name="tr">Database transaction</param>
/// <returns></returns>
internal static SafeDataReader GetReaderFromSQLString(string SqlCommandString, Guid ID, IDbTransaction tr)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
dbCommandWrapper.AddInParameter("@ID",DbType.Guid,ID);
return new SafeDataReader(DB.ExecuteReader(dbCommandWrapper,tr));
}
/// <summary>
/// Return a single object value based on query and ID parameter
/// (returns first column of first row as Object)
/// </summary>
/// <param name="SqlCommandString">SQL with single ID paramter</param>
/// <param name="ID">ID of record desired</param>
/// <returns></returns>
internal static object GetScalarFromSQLString(string SqlCommandString, Guid ID)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
dbCommandWrapper.AddInParameter("@ID",DbType.Guid,ID);
return DB.ExecuteScalar(dbCommandWrapper);
}
/// <summary>
/// Return a single object value based on query and ID parameter
/// (returns first column of first row as Object)
/// Within the specified transaction
/// </summary>
/// <param name="SqlCommandString">SQL with single ID paramter</param>
/// <param name="ID">ID of record desired</param>
/// <param name="tr">Database transaction</param>
/// <returns></returns>
internal static object GetScalarFromSQLString(string SqlCommandString, Guid ID, IDbTransaction tr)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
dbCommandWrapper.AddInParameter("@ID",DbType.Guid,ID);
return DB.ExecuteScalar(dbCommandWrapper,tr);
}
/// <summary>
/// Return a single object value based on query
/// (returns first column of first row as Object)
/// </summary>
/// <param name="SqlCommandString">SQL</param>
/// <returns></returns>
internal static object GetScalarFromSQLString(string SqlCommandString)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
return DB.ExecuteScalar(dbCommandWrapper);
}
/// <summary>
/// Return a single object value based on query
/// within transaction
/// (returns first column of first row as Object)
/// </summary>
internal static object GetScalarFromSQLString(string SqlCommandString, IDbTransaction tr)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
return DB.ExecuteScalar(dbCommandWrapper,tr);
}
/// <summary>
/// Return a DB generated sequential identity number
/// </summary>
/// <param name="field">Field containing ID value</param>
/// <param name="table">Table name</param>
/// <param name="ID">Guid of record desired</param>
/// <param name="tr"></param>
/// <returns>32bit sequential integer identity value</returns>
internal static int GetIdentity(string field, string table, Guid ID, IDbTransaction tr)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper("SELECT " + field + " FROM " + table + " WHERE aID=@ID;");
dbCommandWrapper.AddInParameter("@ID",DbType.Guid,ID);
SafeDataReader dr = null;
if(tr==null)
dr=new SafeDataReader(DB.ExecuteReader(dbCommandWrapper));
else
dr=new SafeDataReader(DB.ExecuteReader(dbCommandWrapper,tr));
if(!dr.Read())
ThrowFetchError("DBUtil:GetIdentity for "+table+"."+field+ " ID=" + ID.ToString());
int i=dr.GetInt32(field);
dr.Close();
if(i==0)
throw new System.ApplicationException("ERROR - DBUtil:GetIdentity for "+table+"."+field+ " ID=" + ID.ToString() + " RETURNED 0");
return i;
}
/// <summary>
/// Return a reader based on query, RootObjectType and ID parameter
/// </summary>
/// <param name="SqlCommandString">A SQL string containing two parameters @RootObjectID and @RootObjectType</param>
/// <param name="objectType">@RootObjectType parameter</param>
/// <param name="RootObjectID">@RootObjectID parameter</param>
/// <returns></returns>
internal static SafeDataReader GetReaderFromSQLString(string SqlCommandString, Guid RootObjectID, RootObjectTypes objectType)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
dbCommandWrapper.AddInParameter("@RootObjectID", DbType.Guid, RootObjectID);
dbCommandWrapper.AddInParameter("@RootObjectType", DbType.Int16, (int)objectType);
return new SafeDataReader(DB.ExecuteReader(dbCommandWrapper));
}
/// <summary>
/// Return a single object value based on query, ID parameter and RootObjectType
/// (returns first column of first row as Object)
/// </summary>
/// <param name="SqlCommandString">A SQL string containing two parameters @RootObjectID and @RootObjectType</param>
/// <param name="RootObjectID">RootObjectID parameter</param>
/// <param name="objectType">@RootObjectType parameter</param>
/// <returns></returns>
internal static object GetScalarFromSQLString(string SqlCommandString, Guid RootObjectID, RootObjectTypes objectType)
{
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper(SqlCommandString);
dbCommandWrapper.AddInParameter("@RootObjectID", DbType.Guid, RootObjectID);
dbCommandWrapper.AddInParameter("@RootObjectType", DbType.Int16, (int)objectType);
return DB.ExecuteScalar(dbCommandWrapper);
}
#region Region query modifiers
/// <summary>
/// Returns a fragment of a where clause for aClient.aRegion prefixed with AND
/// for queries with existing where clauses
/// for filtering queries that are regionalized and contain the aclient table
/// Used in all selected queries that have subqueries
/// </summary>
internal static string RegionAClientClause
{
get
{
return (User.CurrentUserRegionID != Region.DefaultRegionID) ?
" AND (aClient.aRegionID IN ('{8236E8D1-CAB1-4797-9C34-93861954AE6A}','{" + User.CurrentUserRegionID.ToString().ToUpperInvariant() + "}')) "
: "";
}
}
///// <summary>
///// Returns a fragment of a where clause for any table name passed in prefixed with WHERE
///// for queries without existing where clauses
///// for filtering queries that are regionalized
///// </summary>
///// <param name="sTable"></param>
///// <returns></returns>
//internal static string RegionGenericWithWhereClause(string sTable)
//{
// return (User.CurrentUserRegionID != Region.DefaultRegionID) ?
// " WHERE ("+ sTable +".aRegionID IN ('{8236E8D1-CAB1-4797-9C34-93861954AE6A}','{" + User.CurrentUserRegionID.ToString().ToUpperInvariant() + "}')) "
// : "";
//}
///// <summary>
///// Returns a fragment of a where clause for any table name passed in prefixed with AND
///// for queries with existing where clauses
///// for filtering queries that are regionalized
///// </summary>
///// <param name="sTable"></param>
///// <returns></returns>
//internal static string RegionGenericClause(string sTable)
//{
// return (User.CurrentUserRegionID != Region.DefaultRegionID) ?
// " AND (" + sTable + ".aRegionID IN ('{8236E8D1-CAB1-4797-9C34-93861954AE6A}','{" + User.CurrentUserRegionID.ToString().ToUpperInvariant() + "}')) "
// : "";
//}
///// <summary>
///// Returns a fragment of a where clause for any column name passed in prefixed with AND
///// for queries with existing where clauses
///// for filtering queries that are regionalized
///// </summary>
///// <param name="sColumn"></param>
///// <returns></returns>
//internal static string RegionGenericColumnClause(string sColumn)
//{
// return (User.CurrentUserRegionID != Region.DefaultRegionID) ?
// " AND (" + sColumn + " IN ('{8236E8D1-CAB1-4797-9C34-93861954AE6A}','{" + User.CurrentUserRegionID.ToString().ToUpperInvariant() + "}')) "
// : "";
//}
///// <summary>
///// Returns a fragment of a where clause for aClient.aRegion prefixed without AND
///// for queries with no existing where clauses like client pick list
///// </summary>
//internal static string RegionAClientWithWhereClause
//{
// get
// {
// return (User.CurrentUserRegionID != Region.DefaultRegionID) ?
// " WHERE (aClient.aRegionID IN ('{8236E8D1-CAB1-4797-9C34-93861954AE6A}','{" + User.CurrentUserRegionID.ToString().ToUpperInvariant() + "}')) "
// : "";
// }
//}
/// <summary>
/// Add region for queries that filter on client region
/// </summary>
/// <param name="q"></param>
/// <returns></returns>
internal static string AddRegionFilter(string q)
{
return AddRegionFilter(q, "", "");
}
/// <summary>
/// Same as regular AddRegionFilter but with bool parameter for
/// queries that may or may not use regions
/// </summary>
/// <param name="q"></param>
/// <param name="sTable"></param>
/// <param name="sColumn"></param>
/// <param name="Regional"></param>
/// <returns></returns>
internal static string AddRegionFilter(string q, string sTable, string sColumn, bool Regional)
{
if(!Regional) return q;
return AddRegionFilter(q,sTable,sColumn);
}
/// <summary>
/// Modifies input string to include region fragment
/// checks to see if where clause needs to be added
/// and inserts before Order by clause
/// </summary>
/// <param name="q">Ref query string</param>
/// <param name="sTable">table name if not "aClient" (default)</param>
/// <param name="sColumn">column name if not "aRegionID" (default)</param>
internal static string AddRegionFilter(string q, string sTable, string sColumn)
{
//Short circuit, none of the below may be necessary:
//If user is in the default region, no need to do any mods to query
if (User.CurrentUserRegionID == Region.DefaultRegionID) return q;
//case 2033 - regions shouldn't affect client user queries because they are irrelevant
if (User.CurrentUserType == UserTypes.Client || User.CurrentUserType == UserTypes.HeadOffice) return q;
//default to aClient because the majority of queries filter by client
if (string.IsNullOrEmpty(sTable))
sTable = "aClient";
if (string.IsNullOrEmpty(sColumn))
sColumn = "aRegionID";
//build fragment
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int nOrderByStart = -1;
int nWhereStart = -1;
//last index because queries could contain sub queries
nOrderByStart = q.LastIndexOf("ORDER BY", StringComparison.InvariantCultureIgnoreCase);
nWhereStart = q.LastIndexOf(" WHERE ", StringComparison.InvariantCultureIgnoreCase);
//special case for embedded sub queries where the order by may come before the final where clause
if (nOrderByStart < nWhereStart)
nOrderByStart = -1;
if (nWhereStart == -1)
sb.Append(" WHERE (");
else
sb.Append(" AND (");
sb.Append(sTable);
sb.Append(".");
sb.Append(sColumn);
sb.Append(" IN ('{8236E8D1-CAB1-4797-9C34-93861954AE6A}','{");
sb.Append(User.CurrentUserRegionID.ToString().ToUpperInvariant());
sb.Append("}')) ");
//If no order by then can just append and done
if (nOrderByStart == -1)
{
q = q + sb.ToString();
return q;
}
//There is an order by clause so we need to insert our filter before it
string s1 = q.Substring(0, nOrderByStart - 1);
string s2 = q.Substring(nOrderByStart);
q = q.Substring(0, nOrderByStart - 1) + sb.ToString() + q.Substring(nOrderByStart);
return q;
}
#endregion region query modifiers
#endregion
#region Insert Keywords
/// <summary>
/// Insert keywords into search tables
/// </summary>
/// <param name="transaction"></param>
/// <param name="RootObjectID"></param>
/// <param name="RootObjectType"></param>
/// <param name="NewRecord">if false then clears any existing keywords out of dictionary first</param>
/// <param name="Keywords"></param>
internal static void ProcessKeywords(IDbTransaction transaction,Guid RootObjectID, RootObjectTypes RootObjectType, bool NewRecord,string Keywords)
{
//Clear index if necessary:
if(!NewRecord)
{
DBCommandWrapper cm = GetCommandFromSQL("DELETE FROM aSearchKey WHERE (aSourceObjectID=@RootObjectID AND aSourceObjectType=@RootObjectType);");
cm.AddInParameter("@RootObjectID",DbType.Guid,RootObjectID);
cm.AddInParameter("@RootObjectType",DbType.Int16,RootObjectType);
DB.ExecuteNonQuery(cm, transaction);
}
//bail early if there is nothing to index
if(Keywords==null || Keywords=="") return;
//Using an in memory data table get all the relevant word id's
//and insert the non-existing ones
//Build a DataTable of all words and their id's
//set to Guid.empty any word that isn't in the database already
DataTable dtWords = new DataTable("WORDDATA");
dtWords.Columns.Add("WORD",typeof(System.String));
dtWords.Columns.Add("WORDID",typeof(System.Guid));
DBCommandWrapper dbWords = DB.GetSqlStringCommandWrapper("SELECT aID FROM aSearchDictionary WHERE aWord = @Word;");
string[] kw=Keywords.Split(',');
foreach(string s in kw)
{
DataRow dr=dtWords.NewRow();
dr["WORD"]=s;
dbWords.Command.Parameters.Clear();
dbWords.AddInParameter("@Word",DbType.String,s);
SafeDataReader r = new SafeDataReader(DB.ExecuteReader(dbWords,transaction));
if(r.Read())
dr["WORDID"]=r.GetGuid("aID");
else
dr["WORDID"]=Guid.Empty;
r.Close();
dtWords.Rows.Add(dr);
}
//Loop through word table and insert in dictionary words not already there
DBCommandWrapper cmDict = GetCommandFromSQL("INSERT INTO aSearchDictionary (aWord, aID) VALUES (@Word, @WordID);");
foreach(DataRow dr in dtWords.Rows)
{
Guid g=(Guid)dr["WORDID"];
if(g==Guid.Empty)
{
g=Guid.NewGuid();
cmDict.Command.Parameters.Clear();
cmDict.AddInParameter("@Word",DbType.String,(string)dr["WORD"]);
cmDict.AddInParameter("@WordID",DbType.Guid,g);
DB.ExecuteNonQuery(cmDict,transaction);
dr["WORDID"]=g;
}
}
//Now insert searchkey records
DBCommandWrapper cmKey = GetCommandFromSQL(
"INSERT INTO aSearchKey (aWordID, aSourceObjectID, aSourceObjectType) " +
"VALUES (@WordID, @RootObjectID, @RootObjectType)");
foreach(DataRow dr in dtWords.Rows)
{
cmKey.Command.Parameters.Clear();
cmKey.AddInParameter("@WordID",DbType.Guid,(Guid)dr["WORDID"]);
cmKey.AddInParameter("@RootObjectID",DbType.Guid,RootObjectID);
cmKey.AddInParameter("@RootObjectType",DbType.Int16,RootObjectType);
DB.ExecuteNonQuery(cmKey,transaction);
}
}
#endregion
#region Getcommandfromsql
internal static DBCommandWrapper GetCommandFromSQL(string SqlCommandString)
{
return DB.GetSqlStringCommandWrapper(SqlCommandString);
}
#endregion
#region Remove keywords / Documents
/// <summary>
///Used by every object indexed with keywords
///to delete that objects keywords from the search dictionary
///when that object is deleted under the same transaction
/// </summary>
/// <param name="transaction"></param>
/// <param name="RootObjectType"></param>
/// <param name="RootObjectID"></param>
internal static void RemoveKeywords(IDbTransaction transaction, RootObjectTypes RootObjectType, Guid RootObjectID)
{
DBCommandWrapper cm = GetCommandFromSQL("DELETE FROM aSearchKey WHERE (aSourceObjectID=@RootObjectID AND aSourceObjectType=@RootObjectType);");
cm.AddInParameter("@RootObjectID",DbType.Guid,RootObjectID);
cm.AddInParameter("@RootObjectType",DbType.Int16,RootObjectType);
DB.ExecuteNonQuery(cm, transaction);
}
/// <summary>
///Used by every object with Assigned documents and wikipages
///to delete that objects documents and wikipages
///when that object is deleted under the same transaction
/// </summary>
/// <param name="transaction"></param>
/// <param name="RootObjectType"></param>
/// <param name="RootObjectID"></param>
internal static void RemoveDocs(IDbTransaction transaction, RootObjectTypes RootObjectType, Guid RootObjectID)
{
//AssignedDoc Keywords
SafeDataReader dr = null;
System.Collections.ArrayList al = new System.Collections.ArrayList();
try
{
dr=GetReaderFromSQLString("SELECT aID " +
"FROM AASSIGNEDDOC " +
"WHERE aRootObjectID=@ID",RootObjectID,transaction);
while(dr.Read())
{
al.Add(dr.GetGuid("aID"));
}
dr.Close();
foreach(object o in al)
RemoveKeywords(transaction,RootObjectTypes.AssignedDocument,(Guid)o);
}
finally
{
if(dr!=null) dr.Close();
}
//Delete AssignedDocs
DBCommandWrapper cmDeleteDocs = GetCommandFromSQL(
"DELETE FROM AASSIGNEDDOC WHERE (aRootObjectID=@RootObjectID and aRootObjectType=@RootObjectType)");
cmDeleteDocs.AddInParameter("@RootObjectID",DbType.Guid,RootObjectID);
cmDeleteDocs.AddInParameter("@RootObjectType",DbType.Int16,RootObjectType);
//Execute
//DB.ExecuteNonQuery(cmDeleteDocKeywords, transaction);
DB.ExecuteNonQuery(cmDeleteDocs, transaction);
//Delete WikiPages linked to this rootobject case 73
//Collect id's of all wikipages that are linked to object being deleted
System.Collections.ArrayList alWikiPages = new System.Collections.ArrayList();
try
{
dr = GetReaderFromSQLString("SELECT aID " +
"FROM AWIKIPAGE " +
"WHERE aRootObjectID=@ID", RootObjectID, transaction);
while (dr.Read())
{
alWikiPages.Add(dr.GetGuid("aID"));
}
dr.Close();
//Delete them. WikiPage.Delete will look after keywords and child wikipages of itself
foreach (object o in alWikiPages)
WikiPage.DeleteItem((Guid)o, transaction);
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region Concurrency checking
/// <summary>
/// Compares two dates and determines if they are equal down to seconds.
/// (Portions smaller than seconds are ignored)
/// </summary>
/// <param name="dt1"></param>
/// <param name="dt2"></param>
/// <returns></returns>
public static bool DatesAreEqualish(System.DateTime dt1, System.DateTime dt2)
{
System.DateTime dtFirst=new DateTime(dt1.Year,dt1.Month,dt1.Day,dt1.Hour,dt1.Minute,dt1.Second,0);
System.DateTime dtSecond=new DateTime(dt2.Year,dt2.Month,dt2.Day,dt2.Hour,dt2.Minute,dt2.Second,0);
return dtFirst.Equals(dtSecond);
}
/// <summary>
/// Check for record being changed by another user while they were editing it separately
/// </summary>
/// <param name="LastUpdated"></param>
/// <param name="ID"></param>
/// <param name="table"></param>
internal static void CheckSafeToUpdate(System.DateTime LastUpdated, Guid ID, string table)
{
//case 624
if (AyaBizUtils.AyaNovaConnectionSetting.SingleUserConnection) return;
CheckSafeToUpdateInsideTransaction(LastUpdated,ID,table,null);
}
/// <summary>
/// Transaction version, called by objects in collections to avoid timeout on conflict
/// </summary>
/// <param name="LastUpdated"></param>
/// <param name="ID"></param>
/// <param name="table"></param>
/// <param name="tr"></param>
internal static void CheckSafeToUpdateInsideTransaction(System.DateTime LastUpdated, Guid ID, string table,IDbTransaction tr)
{
//case 624
if (AyaBizUtils.AyaNovaConnectionSetting.SingleUserConnection) return;
DBCommandWrapper dbCommandWrapper = DB.GetSqlStringCommandWrapper("SELECT aModified, aModifier FROM " + table + " WHERE aID = @ID;");
dbCommandWrapper.AddInParameter("@ID",DbType.Guid,ID);
SafeDataReader r = null;
//changed: 20-June-2006 Noticed this isn't explicitly closing the data reader
//added the try and catch block so could put that in the finally block
try
{
if (tr != null)
r = new SafeDataReader(DBUtil.DB.ExecuteReader(dbCommandWrapper, tr));
else
r = new SafeDataReader(DBUtil.DB.ExecuteReader(dbCommandWrapper));
if (r.Read())
{
if (!DatesAreEqualish(DBUtil.ToUTC(LastUpdated), r.GetSmartDate("aModified").Date))
{
Guid gModifier = r.GetGuid("aModifier");
r.Close();
dbCommandWrapper.Command.Parameters.Clear();
dbCommandWrapper.AddInParameter("@ID", DbType.Guid, gModifier);
dbCommandWrapper.Command.CommandText = "SELECT aFirstName, aLastName FROM aUser WHERE aID = @ID";
//changed: 20-June-2006 so that transaction is used here if one was passed
//if this is not done then this code will throw an exception on a transaction
//type check
if (tr != null)
r = new SafeDataReader(DBUtil.DB.ExecuteReader(dbCommandWrapper, tr));
else
r = new SafeDataReader(DBUtil.DB.ExecuteReader(dbCommandWrapper));
//r = new SafeDataReader(DBUtil.DB.ExecuteReader(dbCommandWrapper));
if (r.Read())
{
string sUser = r.GetString("aFirstName") + " " + r.GetString("aLastName");
r.Close();
throw new AyConcurrencyException(string.Format(LocalizedTextTable.GetLocalizedTextDirect("Error.DB.RecordModifiedExternally"), table, sUser));
}
}
//else
//{
// //de nada
// r.Close();
// return;
//}
}
}
catch
{
throw;
}
finally
{
if(r!=null) r.Close();
}
}
#endregion
#region DB related error handling
internal static void ThrowFetchError(string ExtraInfo)
{
throw new FetchException(string.Format(LocalizedTextTable.GetLocalizedTextDirect("Error.DB.FetchError"),ExtraInfo));
}
#endregion
#region Convert dates to / from UTC offsetting if required
//case 1163 changes to accomodate timezone offset feature
/// <summary>
/// Convert SmartDate object to universal time
/// If a user time zone offset is not null
/// that value is used for conversion, otherwise local machine
/// timezone is used
/// </summary>
/// <param name="sd"></param>
/// <returns></returns>
public static SmartDate ToUTC(SmartDate sd)
{
if (sd.IsEmpty)
return sd;
else
{
if (!AyaBizUtils.OverrideTimeZone)
return new SmartDate(sd.Date.ToUniversalTime());
else
return new SmartDate(sd.Date.AddHours(AyaBizUtils.TimeZoneOffset*-1));//*-1 to flip the sign since there is no SubtractHours method in datetime
}
}
/// <summary>
/// Convert SmartDate object to local time
/// If a user time zone offset is not null
/// that value is used for conversion, otherwise local machine
/// timezone is used
/// </summary>
/// <param name="sd"></param>
/// <returns></returns>
public static SmartDate ToLocal(SmartDate sd)
{
if(sd.IsEmpty)
return sd;
else
if (!AyaBizUtils.OverrideTimeZone)
return new SmartDate(sd.Date.ToLocalTime());
else
return new SmartDate(sd.Date.AddHours(AyaBizUtils.TimeZoneOffset));
}
/// <summary>
/// Convert DateTime object to universal time
/// If a user time zone offset is not null
/// that value is used for conversion, otherwise local machine
/// timezone is used
/// </summary>
/// <param name="sd"></param>
/// <returns></returns>
public static DateTime ToUTC(DateTime sd)
{
if (!AyaBizUtils.OverrideTimeZone)
return sd.ToUniversalTime();
else
return sd.AddHours(AyaBizUtils.TimeZoneOffset * -1);//*-1 to flip the sign since there is no SubtractHours method in datetime
}
/// <summary>
/// Convert DateTime object to local time
/// If a user time zone offset is not null
/// that value is used for conversion, otherwise local machine
/// timezone is used
/// </summary>
/// <param name="sd"></param>
/// <returns></returns>
public static DateTime ToLocal(DateTime sd)
{
if (!AyaBizUtils.OverrideTimeZone)
return sd.ToLocalTime();
else
return sd.AddHours(AyaBizUtils.TimeZoneOffset);
}
/// <summary>
/// Returns current date time adjusted by user TimeZoneOffset
/// if applicable
/// </summary>
public static DateTime CurrentWorkingDateTime
{
get
{
DateTime dtNow = DateTime.Now;
if (!AyaBizUtils.OverrideTimeZone)
return dtNow;
else
return dtNow.ToUniversalTime().AddHours(AyaBizUtils.TimeZoneOffset);
}
}
/// <summary>
/// Returns current date time adjusted by user TimeZoneOffset
/// if applicable as a SmartDate
/// </summary>
public static SmartDate CurrentWorkingDateTimeAsSmartDate
{
get
{
DateTime dtNow = DateTime.Now;
if (!AyaBizUtils.OverrideTimeZone)
return new SmartDate(dtNow);
else
return new SmartDate(dtNow.ToUniversalTime().AddHours(AyaBizUtils.TimeZoneOffset));
}
}
#endregion
#region Convert scalar object to Guid from FireBird / MSSql
internal static Guid ToGuid(object o)
{
if(o is Guid) return (Guid)o;
if(o==null || o==System.DBNull.Value) return Guid.Empty;
if(o is String) return new Guid((string)o);
throw new ApplicationException("DBUtil.ToGuid - Cannot convert type " + o.GetType().ToString() + " to Guid value.");
}
internal static string ScalarToString(object o)
{
if(o is string) return (string)o;
if(o==null || o==System.DBNull.Value) return "";
throw new ApplicationException("DBUtil.ToString - Cannot convert type " + o.GetType().ToString() + " to Guid value.");
}
internal static long ScalarToLong(object o)
{
if(o is long) return (long)o;
if(o==null || o==System.DBNull.Value) return 0;
return System.Convert.ToInt64(o);
//throw new ApplicationException("DBUtil.ToString - Cannot convert type " + o.GetType().ToString() + " to Guid value.");
}
//case 963
internal static decimal ScalarToDecimal(object o)
{
if (o is decimal) return (decimal)o;
if (o == null || o == System.DBNull.Value) return 0;
return System.Convert.ToDecimal(o);
}
internal static bool ScalarToBool(object o)
{
if (o is bool) return (bool)o;
if (o == null || o == System.DBNull.Value) return false;
return System.Convert.ToBoolean(o);
//throw new ApplicationException("DBUtil.ToString - Cannot convert type " + o.GetType().ToString() + " to Guid value.");
}
//case 1283
internal static int ScalarToInt(object o)
{
if (o is int) return (int)o;
if (o == null || o == System.DBNull.Value) return 0;
return System.Convert.ToInt32(o);
//throw new ApplicationException("DBUtil.ToString - Cannot convert type " + o.GetType().ToString() + " to Guid value.");
}
//case 2094
/// <summary>
/// Scalar to date
/// </summary>
/// <param name="o"></param>
/// <returns>DateTime.MinValue if null or unparseable</returns>
internal static DateTime ScalarToDate(object o)
{
if (o is DateTime) return (DateTime)o;
if (o == null || o == System.DBNull.Value) return DateTime.MinValue;
return System.Convert.ToDateTime(o);
}
#endregion
#region Identity field import utils
internal static void AllowIdentityInsert()
{
throw new ApplicationException("DBUtil:AllowIdentityInsert: STUB");
}
#endregion
}
}

View File

@@ -0,0 +1,238 @@
///////////////////////////////////////////////////////////
// DashBoardClientServiceRequestList.cs
// Implementation of Class DashBoardClientServiceRequestList
// CSLA type: Read only collection
// Created on: 9-Feb-2009
// Coded: John 9-Feb-2009
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Read only list of <see cref="DashBoardClientServiceRequestList.DashBoardClientServiceRequestListInfo"/> objects
///
/// </summary>
[Serializable]
public class DashBoardClientServiceRequestList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct DashBoardClientServiceRequestListInfo
{
internal DateTime mCreated;
// internal string mCreator;
internal string mTitle;
internal string mClient;
//internal string mHeadOffice;
//internal string mUnit;
//internal int mWorkorder;
//internal string mClientRef;
//internal string mStatus;
//internal string mPriority;
internal Guid mID;
//internal Guid mWorkorderID;
//internal string mRegion;
internal string mRequestedBy;
public DateTime LT_Common_Label_Created
{ get { return mCreated; } }
public string LT_O_ClientServiceRequest
{ get { return mTitle; } }
public string LT_O_Client { get { return mClient; } }
public Guid ID { get { return mID; } }
public string LT_ClientServiceRequest_Label_RequestedBy
{ get { return this.mRequestedBy; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(DashBoardClientServiceRequestListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end DashBoardClientServiceRequestListInfo
#endregion
#region Constructor
protected DashBoardClientServiceRequestList()
{
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public DashBoardClientServiceRequestListInfo this[int Item]
{
get
{
return (DashBoardClientServiceRequestListInfo)List[Item];
}
}
/// <summary>
/// Returns display text that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public string this[Guid ItemID]
{
get
{
foreach (DashBoardClientServiceRequestListInfo child in List)
{
if (child.mID == ItemID) return child.ToString();
}
return "Missing: " + ItemID.ToString();
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(DashBoardClientServiceRequestListInfo obj)
{
foreach (DashBoardClientServiceRequestListInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all ClientServiceRequest for dashboard
/// </summary>
/// <returns></returns>
public static DashBoardClientServiceRequestList GetList()
{
return (DashBoardClientServiceRequestList)DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q = "";
//Generic full list fetch (regionalized)
//************************************************************
q = "SELECT " +
" ACLIENTSERVICEREQUEST.*, " +
" AUNIT.ASERIAL, " +
" AUNITMODEL.ANAME AS AUNITMODELNAME, AUNITMODEL.AMODELNUMBER, " +//Case9
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
" AUSER.AFIRSTNAME, " +
" AUSER.ALASTNAME, " +
" AUSER.AINITIALS, " +
" AUSER.AEMPLOYEENUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" ACLIENT.AREGIONID, AREGION.ANAME AS AREGIONNAME, " + //case 58
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
" AWORKORDERSERVICE.ASERVICENUMBER, " +
" AWORKORDERITEM.AWORKORDERID " +
" FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" LEFT OUTER JOIN AREGION ON ACLIENT.AREGIONID = AREGION.AID " + //Case 58
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
" WHERE ACLIENTSERVICEREQUEST.ASTATUS=0 ";
q = DBUtil.AddRegionFilter(q, "ACLIENT", "");//case 58
q = q + " ORDER BY ACLIENTSERVICEREQUEST.ACREATED ASC";
dr = DBUtil.GetReaderFromSQLString(q);
//************************************************************
while (dr.Read())
{
//*******************************************
DashBoardClientServiceRequestListInfo info = new DashBoardClientServiceRequestListInfo();
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("ACREATED")).Date;
info.mID = dr.GetGuid("AID");
info.mTitle = dr.GetString("ATITLE");
info.mClient = dr.GetString("ACLIENTNAME");
info.mRequestedBy = dr.GetString("AREQUESTEDBY");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Criteria()
{
}
}
#endregion
}//end DashBoardClientServiceRequestList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,137 @@
///////////////////////////////////////////////////////////
// DashBoardClientServiceRequestListRI.cs
// Implementation of Class DashBoardClientServiceRequestListRI
// CSLA type: Read only collection
// Created on: 25-Sept-2014
// Coded: John 25-Sept-2014
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
[Serializable]
public class DashBoardClientServiceRequestListRI : ReadOnlyBase
{
public long _Count = 0;
public Dictionary<Guid, string> list = null;
#region Constructor
protected DashBoardClientServiceRequestListRI()
{
}
#endregion
#region Static methods
public static Dictionary<Guid, string> GetList(int MaxRecords = 3)
{
return ((DashBoardClientServiceRequestListRI)DataPortal.Fetch(new Criteria(false, MaxRecords))).list;
}
public static long GetCount()
{
return ((DashBoardClientServiceRequestListRI)DataPortal.Fetch(new Criteria(true, 0)))._Count;
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
DBCommandWrapper cm = null;
string qFields = "";
if (crit.Count)
qFields = "SELECT COUNT(*) ";
else
qFields = "SELECT ~MAXRECS~ " +
" ACLIENTSERVICEREQUEST.AID, ACLIENTSERVICEREQUEST.ATITLE, ACLIENTSERVICEREQUEST.ACREATED, ACLIENTSERVICEREQUEST.AREQUESTEDBY," +
" ACLIENT.ANAME AS ACLIENTNAME ";
string q = qFields + " FROM " +
" ACLIENTSERVICEREQUEST " +
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
" WHERE ACLIENTSERVICEREQUEST.ASTATUS=0 ";
if (!crit.Count)
q = q + " ORDER BY ACLIENTSERVICEREQUEST.ACREATED ASC";
if (!crit.Count)
{
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
}
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@ID", DbType.Guid, User.CurrentThreadUserID);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
if (!crit.Count)
list = new Dictionary<Guid, string>(crit.MaxRecords);
while (dr.Read())
{
if (crit.Count)
{
object o = dr.GetValue(0);
_Count = long.Parse(o.ToString());
}
else
{
//id = new TypeAndID(RootObjectTypes.ClientServiceRequest, i.ID);
//item = i.LT_Common_Label_Created.ToString() + " " + i.LT_O_Client + " " + i.LT_O_ClientServiceRequest + " " + i.LT_ClientServiceRequest_Label_RequestedBy;
list.Add(dr.GetGuid("AID"),
DBUtil.ToLocal(dr.GetSmartDate("ACREATED")).ToString() + " " +
dr.GetString("ACLIENTNAME") + " " +
dr.GetString("ATITLE") + " " +
dr.GetString("AREQUESTEDBY")
);
_Count++;
}
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public bool Count;
public int MaxRecords;
public Criteria(bool count, int maxRecords)
{
MaxRecords = maxRecords;
Count = count;
}
}
#endregion
}//end DashBoardClientServiceRequestListRI
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,619 @@
///////////////////////////////////////////////////////////
// DashBoardInfo.cs
// Implementation of Class DashBoardInfo
// CSLA type: Read-only object
// Created on: 09-Jan-2012
// Object design: John / Joyce
// Coded: John 09-Jan-2012
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Fetches all information for Dashboard form / page
/// </summary>
[Serializable]
public class DashBoardInfo : ReadOnlyBase
{
private const int DASHBOARDMAXLISTITEMS = 3;//List items plus one more for the More... item
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private DashBoardInfo()
{
ListCriteria = new Dictionary<string, string>(10);
myOverdueList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
myNewMemosList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
myRemindersList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
myServiceRateSummaryList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
myScheduledList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
compOverdueList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
compNotAssignedList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
compServiceRequestsList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
compServiceRateSummaryList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
compScheduledList = new List<DashBoardInfoItem>(DASHBOARDMAXLISTITEMS + 1);
}
#region props
public string CurrentUserNameFormatted { get; private set; }
public string CurrentCompanyOrRegionName { get; private set; }
public Dictionary<string,string> ListCriteria { get; private set; }
#region "My" properties
public bool HasMyOverdueList { get { return myOverdueList.Count > 0; } }
public bool HasMyNewMemoList { get { return myNewMemosList.Count > 0; } }
public bool HasMyReminderList { get { return myRemindersList.Count > 0; } }
public bool HasMyServiceRateSummaryList { get { return myServiceRateSummaryList.Count > 0; } }
public bool HasMyScheduledList { get { return myScheduledList.Count > 0; } }
/// <summary>
/// Should the "my" panel be shown
/// </summary>
public bool MyPanelVisible
{
get
{
return (HasMyOverdueList || HasMyNewMemoList || HasMyReminderList || HasMyScheduledList || HasMyServiceRateSummaryList);
}
}
public List<DashBoardInfoItem> myOverdueList { get; private set; }
public List<DashBoardInfoItem> myNewMemosList { get; private set; }
public List<DashBoardInfoItem> myRemindersList { get; private set; }
public List<DashBoardInfoItem> myServiceRateSummaryList { get; private set; }
public List<DashBoardInfoItem> myScheduledList { get; private set; }
#endregion "my" props
#region "Comp" properties
public bool HasCompOverdueList { get { return compOverdueList.Count > 0; } }
public bool HasCompNotAssignedList { get { return compNotAssignedList.Count > 0; } }
public bool HasCompServiceRequestList { get { return compServiceRequestsList.Count > 0; } }
public bool HasCompServiceRateSummaryList { get { return compServiceRateSummaryList.Count > 0; } }
public bool HasCompScheduledList { get { return compScheduledList.Count > 0; } }
/// <summary>
/// Should the "Company / Region" panel be shown
/// </summary>
public bool CompPanelVisible
{
get
{
return (HasCompOverdueList || HasCompNotAssignedList || HasCompServiceRequestList || HasCompScheduledList || HasCompServiceRateSummaryList);
}
}
public List<DashBoardInfoItem> compOverdueList { get; private set; }
public List<DashBoardInfoItem> compNotAssignedList { get; private set; }
public List<DashBoardInfoItem> compServiceRequestsList { get; private set; }
public List<DashBoardInfoItem> compServiceRateSummaryList { get; private set; }
public List<DashBoardInfoItem> compScheduledList { get; private set; }
#endregion "comp" props
#endregion props
public static DashBoardInfo Get(string More)
{
bool FetchScheduleableUserInfo = true;
if (User.IsAdmin) FetchScheduleableUserInfo = false;
if (User.CurrentUserType != UserTypes.Schedulable)
FetchScheduleableUserInfo = false;
DashBoardInfo di = new DashBoardInfo();
DashBoardInfoItem MoreItem = new DashBoardInfoItem(RootObjectTypes.Nothing, Guid.Empty, More);
di.CurrentUserNameFormatted = UserPickList.GetListOfOneSpecificUser(User.CurrentThreadUserID)[0].Name;
di.CurrentCompanyOrRegionName = AyaBizUtils.REGTO;
if (!User.CurrentUserIsInDefaultRegion)
di.CurrentCompanyOrRegionName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Region, User.CurrentUserRegionID)).RecordName;
#region "My" lists
if (FetchScheduleableUserInfo)
{
if (AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.NoAccess)
{
#region My overdue
{
string crit = "<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" PIN=\"0\" WIDTH=\"210\" SORT=\"ASC\" /> \r\n" +
" <COLUMNITEM CM=\"aUser.aLastName\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\" PIN=\"0\" WIDTH=\"242\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceNumber\" UI=\"LT_O_Workorder\" PIN=\"0\" WIDTH=\"100\" /> \r\n" +
" <COLUMNITEM CM=\"aPriority.aName\" UI=\"LT_WorkorderItem_Label_PriorityID\" PIN=\"0\" WIDTH=\"148\" /> \r\n" +
" <COLUMNITEM CM=\"aDispatchZone.aName\" UI=\"LT_O_DispatchZone\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
" <COLUMNITEM CM=\"aUnit.aSerial\" UI=\"LT_Unit_Label_Serial\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aOnsite\" UI=\"LT_Workorder_Label_Onsite\" PIN=\"0\" WIDTH=\"80\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemStatus.aName\" UI=\"LT_WorkorderItem_Label_WorkorderStatusID\" PIN=\"0\" WIDTH=\"158\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceDate\" UI=\"LT_WorkorderService_Label_ServiceDate\" PIN=\"0\" WIDTH=\"112\" /> \r\n" +
" <COLUMNITEM CM=\"aClient.aName\" UI=\"LT_O_Client\" PIN=\"0\" WIDTH=\"76\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStopDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StopDate\" PIN=\"0\" WIDTH=\"136\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItem.aSummary\" UI=\"LT_WorkorderItem_Label_Summary\" PIN=\"0\" WIDTH=\"121\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aClosed\" UI=\"LT_Workorder_Label_Closed\" PIN=\"0\" WIDTH=\"82\" /> \r\n" +
" <COLUMNITEM CM=\"aUnitModel.aName\" UI=\"LT_O_UnitModel\" PIN=\"0\" WIDTH=\"101\" /> \r\n" +
" <COLUMNITEM CM=\"aRate.aName\" UI=\"LT_WorkorderItemScheduledUser_Label_ServiceRateID\" PIN=\"0\" WIDTH=\"124\" /> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItemScheduledUser.aUserID\" UICOMPAREVALUE=\"" + di.CurrentUserNameFormatted + "\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + User.CurrentThreadUserID.ToString().ToUpper() + "}\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"NotEquals\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"\" /> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"LessThanOrEqualTo\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
"</GRIDCRITERIA> ";
string critSub = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItemScheduledUser.aUserID\" UICOMPAREVALUE=\"" + di.CurrentUserNameFormatted + "\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + User.CurrentThreadUserID.ToString().ToUpper() + "}\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"NotEquals\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"\" /> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"LessThanOrEqualTo\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n";
di.ListCriteria.Add("MyOverdue", critSub);//used to filter grid list in UI when user clicks More... list item
WorkorderServiceScheduledUserList l = WorkorderServiceScheduledUserList.Get(crit, DASHBOARDMAXLISTITEMS, null);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.myOverdueList.Add(new DashBoardInfoItem(l[x]));
}
if (l.Count == DASHBOARDMAXLISTITEMS)
di.myOverdueList.Add(MoreItem);
}
}
#endregion my overdue
#region My Scheduled items list
{
string crit = "<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" PIN=\"0\" WIDTH=\"210\" SORT=\"ASC\" /> \r\n" +
" <COLUMNITEM CM=\"aUser.aLastName\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\" PIN=\"0\" WIDTH=\"242\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceNumber\" UI=\"LT_O_Workorder\" PIN=\"0\" WIDTH=\"100\" /> \r\n" +
" <COLUMNITEM CM=\"aPriority.aName\" UI=\"LT_WorkorderItem_Label_PriorityID\" PIN=\"0\" WIDTH=\"148\" /> \r\n" +
" <COLUMNITEM CM=\"aDispatchZone.aName\" UI=\"LT_O_DispatchZone\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
" <COLUMNITEM CM=\"aUnit.aSerial\" UI=\"LT_Unit_Label_Serial\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aOnsite\" UI=\"LT_Workorder_Label_Onsite\" PIN=\"0\" WIDTH=\"80\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemStatus.aName\" UI=\"LT_WorkorderItem_Label_WorkorderStatusID\" PIN=\"0\" WIDTH=\"158\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceDate\" UI=\"LT_WorkorderService_Label_ServiceDate\" PIN=\"0\" WIDTH=\"112\" /> \r\n" +
" <COLUMNITEM CM=\"aClient.aName\" UI=\"LT_O_Client\" PIN=\"0\" WIDTH=\"76\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStopDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StopDate\" PIN=\"0\" WIDTH=\"136\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItem.aSummary\" UI=\"LT_WorkorderItem_Label_Summary\" PIN=\"0\" WIDTH=\"121\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aClosed\" UI=\"LT_Workorder_Label_Closed\" PIN=\"0\" WIDTH=\"82\" /> \r\n" +
" <COLUMNITEM CM=\"aUnitModel.aName\" UI=\"LT_O_UnitModel\" PIN=\"0\" WIDTH=\"101\" /> \r\n" +
" <COLUMNITEM CM=\"aRate.aName\" UI=\"LT_WorkorderItemScheduledUser_Label_ServiceRateID\" PIN=\"0\" WIDTH=\"124\" /> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItemScheduledUser.aUserID\" UICOMPAREVALUE=\"" + di.CurrentUserNameFormatted + "\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + User.CurrentThreadUserID.ToString().ToUpper() + "}\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"GreaterThan\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
"</GRIDCRITERIA> ";
string critSub = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItemScheduledUser.aUserID\" UICOMPAREVALUE=\"" + di.CurrentUserNameFormatted + "\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + User.CurrentThreadUserID.ToString().ToUpper() + "}\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"GreaterThan\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n";
di.ListCriteria.Add("MyScheduled", critSub);//used to filter grid list in UI when user clicks More... list item
WorkorderServiceScheduledUserList l = WorkorderServiceScheduledUserList.Get(crit, DASHBOARDMAXLISTITEMS, null);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.myScheduledList.Add(new DashBoardInfoItem(l[x]));
}
if (l.Count == DASHBOARDMAXLISTITEMS)
di.myScheduledList.Add(MoreItem);
}
}
#endregion my scheduled
}
#region My Service rate summary
{
DashboardServiceRateBalanceFetcher l = DashboardServiceRateBalanceFetcher.GetItem(User.CurrentThreadUserID, true);
di.myServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.Today") + " = " + l.Today.ToString()));
di.myServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.Yesterday") + " = " + l.Yesterday.ToString()));
di.myServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.ThisWeek") + " = " + l.ThisWeek.ToString()));
di.myServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.ThisMonth") + " = " + l.ThisMonth.ToString()));
di.myServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.ThisYear") + " = " + l.ThisYear.ToString()));
}
#endregion my service rate summary
if (AyaBizUtils.Right("Object.Memo") > (int)SecurityLevelTypes.NoAccess)
{
#region My newest memos
{
string crit = "<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aMemo.aCreated\" UI=\"LT_Memo_Label_Sent\" PIN=\"0\" WIDTH=\"158\" SORT=\"DESC\" /> \r\n" +
" <COLUMNITEM CM=\"aMemo.aReplied\" UI=\"LT_Memo_Label_Replied\" PIN=\"0\" WIDTH=\"86\" /> \r\n" +
" <COLUMNITEM CM=\"aUser.aLastName\" UI=\"LT_Memo_Label_FromID\" PIN=\"0\" WIDTH=\"274\" /> \r\n" +
" <COLUMNITEM CM=\"aMemo.aSubject\" UI=\"LT_Memo_Label_Subject\" PIN=\"0\" WIDTH=\"85\" /> \r\n" +
" <COLUMNITEM CM=\"grid\" UI=\"LT_Memo_Label_Sent_Relative\" PIN=\"0\" WIDTH=\"158\" /> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Memo_Label_Viewed\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aMemo.aViewed\" UI=\"\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
"</GRIDCRITERIA> ";
string critSub = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Memo_Label_Viewed\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aMemo.aViewed\" UI=\"\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n";
di.ListCriteria.Add("MyNewMemos", critSub);//used to filter grid list in UI when user clicks More... list item
MemoList l = MemoList.Get(crit, DASHBOARDMAXLISTITEMS, null);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.myNewMemosList.Add(new DashBoardInfoItem(l[x]));
}
if (l.Count == DASHBOARDMAXLISTITEMS)
di.myNewMemosList.Add(MoreItem);
}
}
#endregion
}
if (AyaBizUtils.Right("Object.ScheduleMarker") > (int)SecurityLevelTypes.NoAccess)
{
#region My reminders
{
DashboardReminderList l = DashboardReminderList.GetList(DASHBOARDMAXLISTITEMS);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.myRemindersList.Add(new DashBoardInfoItem(l[x]));
}
//Nowhere really to send them as it's not based on a grid so
//unless we send them to the schedule screen then this shouldn't be here
//if(l.Count==DASHBOARDMAXLISTITEMS)
// di.myRemindersList.Add(MoreItem);
}
}
#endregion my reminders
}
}//end of if FetchScheduleableUserInfo
#endregion my lists
#region "Company" lists
{
if (!AyaBizUtils.Lite)
{
if (AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.NoAccess)
{
#region Company - Not Assigned
{
string crit = "<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" PIN=\"0\" WIDTH=\"210\" SORT=\"DESC\" /> \r\n" +
" <COLUMNITEM CM=\"aUser.aLastName\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\" PIN=\"0\" WIDTH=\"242\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceNumber\" UI=\"LT_O_Workorder\" PIN=\"0\" WIDTH=\"100\" /> \r\n" +
" <COLUMNITEM CM=\"aPriority.aName\" UI=\"LT_WorkorderItem_Label_PriorityID\" PIN=\"0\" WIDTH=\"148\" /> \r\n" +
" <COLUMNITEM CM=\"aDispatchZone.aName\" UI=\"LT_O_DispatchZone\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
" <COLUMNITEM CM=\"aUnit.aSerial\" UI=\"LT_Unit_Label_Serial\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aOnsite\" UI=\"LT_Workorder_Label_Onsite\" PIN=\"0\" WIDTH=\"80\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemStatus.aName\" UI=\"LT_WorkorderItem_Label_WorkorderStatusID\" PIN=\"0\" WIDTH=\"158\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceDate\" UI=\"LT_WorkorderService_Label_ServiceDate\" PIN=\"0\" WIDTH=\"112\" /> \r\n" +
" <COLUMNITEM CM=\"aClient.aName\" UI=\"LT_O_Client\" PIN=\"0\" WIDTH=\"76\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStopDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StopDate\" PIN=\"0\" WIDTH=\"136\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItem.aSummary\" UI=\"LT_WorkorderItem_Label_Summary\" PIN=\"0\" WIDTH=\"121\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aClosed\" UI=\"LT_Workorder_Label_Closed\" PIN=\"0\" WIDTH=\"82\" /> \r\n" +
" <COLUMNITEM CM=\"aUnitModel.aName\" UI=\"LT_O_UnitModel\" PIN=\"0\" WIDTH=\"101\" /> \r\n" +
" <COLUMNITEM CM=\"aRate.aName\" UI=\"LT_WorkorderItemScheduledUser_Label_ServiceRateID\" PIN=\"0\" WIDTH=\"124\" /> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"Or\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"Or\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aUser.aLastName\" UICOMPAREVALUE=\"\" TYPE=\"System.String\" COMPAREVALUE=\"\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
"</GRIDCRITERIA> ";
string critSub =
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"Or\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"Or\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aUser.aLastName\" UICOMPAREVALUE=\"\" TYPE=\"System.String\" COMPAREVALUE=\"\" /> \r\n" +
" </WHEREITEMGROUP> \r\n";
di.ListCriteria.Add("CompanyNotAssigned", critSub);//used to filter grid list in UI when user clicks More... list item
WorkorderServiceScheduledUserList l = WorkorderServiceScheduledUserList.Get(crit, DASHBOARDMAXLISTITEMS, null);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.compNotAssignedList.Add(new DashBoardInfoItem(l[x]));
}
if (l.Count == DASHBOARDMAXLISTITEMS)
di.compNotAssignedList.Add(MoreItem);
}
}
#endregion Company not assigned
#region Company overdue
{
string crit = "<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" PIN=\"0\" WIDTH=\"210\" SORT=\"ASC\" /> \r\n" +
" <COLUMNITEM CM=\"aUser.aLastName\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\" PIN=\"0\" WIDTH=\"242\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceNumber\" UI=\"LT_O_Workorder\" PIN=\"0\" WIDTH=\"100\" /> \r\n" +
" <COLUMNITEM CM=\"aPriority.aName\" UI=\"LT_WorkorderItem_Label_PriorityID\" PIN=\"0\" WIDTH=\"148\" /> \r\n" +
" <COLUMNITEM CM=\"aDispatchZone.aName\" UI=\"LT_O_DispatchZone\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
" <COLUMNITEM CM=\"aUnit.aSerial\" UI=\"LT_Unit_Label_Serial\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aOnsite\" UI=\"LT_Workorder_Label_Onsite\" PIN=\"0\" WIDTH=\"80\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemStatus.aName\" UI=\"LT_WorkorderItem_Label_WorkorderStatusID\" PIN=\"0\" WIDTH=\"158\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceDate\" UI=\"LT_WorkorderService_Label_ServiceDate\" PIN=\"0\" WIDTH=\"112\" /> \r\n" +
" <COLUMNITEM CM=\"aClient.aName\" UI=\"LT_O_Client\" PIN=\"0\" WIDTH=\"76\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStopDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StopDate\" PIN=\"0\" WIDTH=\"136\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItem.aSummary\" UI=\"LT_WorkorderItem_Label_Summary\" PIN=\"0\" WIDTH=\"121\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aClosed\" UI=\"LT_Workorder_Label_Closed\" PIN=\"0\" WIDTH=\"82\" /> \r\n" +
" <COLUMNITEM CM=\"aUnitModel.aName\" UI=\"LT_O_UnitModel\" PIN=\"0\" WIDTH=\"101\" /> \r\n" +
" <COLUMNITEM CM=\"aRate.aName\" UI=\"LT_WorkorderItemScheduledUser_Label_ServiceRateID\" PIN=\"0\" WIDTH=\"124\" /> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"NotEquals\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"\" /> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"LessThanOrEqualTo\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
"</GRIDCRITERIA> ";
string critSub = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"NotEquals\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"\" /> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"LessThanOrEqualTo\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n";
di.ListCriteria.Add("CompanyOverdue", critSub);//used to filter grid list in UI when user clicks More... list item
WorkorderServiceScheduledUserList l = WorkorderServiceScheduledUserList.Get(crit, DASHBOARDMAXLISTITEMS, null);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.compOverdueList.Add(new DashBoardInfoItem(l[x]));
}
if (l.Count == DASHBOARDMAXLISTITEMS)
di.compOverdueList.Add(MoreItem);
}
}
#endregion my overdue
#region Company Scheduled / next items list
{
string crit = "<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" PIN=\"0\" WIDTH=\"210\" SORT=\"ASC\" /> \r\n" +
" <COLUMNITEM CM=\"aUser.aLastName\" UI=\"LT_WorkorderItemScheduledUser_Label_UserID\" PIN=\"0\" WIDTH=\"242\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceNumber\" UI=\"LT_O_Workorder\" PIN=\"0\" WIDTH=\"100\" /> \r\n" +
" <COLUMNITEM CM=\"aPriority.aName\" UI=\"LT_WorkorderItem_Label_PriorityID\" PIN=\"0\" WIDTH=\"148\" /> \r\n" +
" <COLUMNITEM CM=\"aDispatchZone.aName\" UI=\"LT_O_DispatchZone\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
" <COLUMNITEM CM=\"aUnit.aSerial\" UI=\"LT_Unit_Label_Serial\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aOnsite\" UI=\"LT_Workorder_Label_Onsite\" PIN=\"0\" WIDTH=\"80\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemStatus.aName\" UI=\"LT_WorkorderItem_Label_WorkorderStatusID\" PIN=\"0\" WIDTH=\"158\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceDate\" UI=\"LT_WorkorderService_Label_ServiceDate\" PIN=\"0\" WIDTH=\"112\" /> \r\n" +
" <COLUMNITEM CM=\"aClient.aName\" UI=\"LT_O_Client\" PIN=\"0\" WIDTH=\"76\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItemScheduledUser.aStopDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StopDate\" PIN=\"0\" WIDTH=\"136\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderItem.aSummary\" UI=\"LT_WorkorderItem_Label_Summary\" PIN=\"0\" WIDTH=\"121\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorder.aClosed\" UI=\"LT_Workorder_Label_Closed\" PIN=\"0\" WIDTH=\"82\" /> \r\n" +
" <COLUMNITEM CM=\"aUnitModel.aName\" UI=\"LT_O_UnitModel\" PIN=\"0\" WIDTH=\"101\" /> \r\n" +
" <COLUMNITEM CM=\"aRate.aName\" UI=\"LT_WorkorderItemScheduledUser_Label_ServiceRateID\" PIN=\"0\" WIDTH=\"124\" /> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"GreaterThan\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
"</GRIDCRITERIA> ";
string critSub = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Workorder_Label_ServiceCompleted\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" TYPE=\"System.Boolean\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"False\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"GreaterThan\" CM=\"aWorkorderItemScheduledUser.aStartDate\" UI=\"LT_WorkorderItemScheduledUser_Label_StartDate\" TYPE=\"System.Object\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"" + DBUtil.CurrentWorkingDateTime.ToString() + "\" /> \r\n" +
" </WHEREITEMGROUP> \r\n";
di.ListCriteria.Add("CompanyNext", critSub);//used to filter grid list in UI when user clicks More... list item
WorkorderServiceScheduledUserList l = WorkorderServiceScheduledUserList.Get(crit, DASHBOARDMAXLISTITEMS, null);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.compScheduledList.Add(new DashBoardInfoItem(l[x]));
}
if (l.Count == DASHBOARDMAXLISTITEMS)
di.compScheduledList.Add(MoreItem);
}
}
#endregion my scheduled
}
#region Company / region Service rate summary
{
DashboardServiceRateBalanceFetcher l = DashboardServiceRateBalanceFetcher.GetItem(User.CurrentThreadUserID, false);
di.compServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.Today") + " = " + l.Today.ToString()));
di.compServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.Yesterday") + " = " + l.Yesterday.ToString()));
di.compServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.ThisWeek") + " = " + l.ThisWeek.ToString()));
di.compServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.ThisMonth") + " = " + l.ThisMonth.ToString()));
di.compServiceRateSummaryList.Add(new DashBoardInfoItem(LocalizedTextTable.GetLocalizedTextDirect("UI.Label.DateRange.ThisYear") + " = " + l.ThisYear.ToString()));
}
#endregion my service rate summary
if (AyaBizUtils.Right("Object.ClientServiceRequest") > (int)SecurityLevelTypes.NoAccess)
{
#region Company open client service requests
{
string crit = "<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aClientServiceRequest.aCreated\" UI=\"LT_Common_Label_Created\" PIN=\"0\" WIDTH=\"226\" SORT=\"ASC\" /> \r\n" +
" <COLUMNITEM CM=\"aClientServiceRequest.aStatus\" UI=\"LT_ClientServiceRequest_Label_Status\" PIN=\"0\" WIDTH=\"153\" /> \r\n" +
" <COLUMNITEM CM=\"aClientServiceRequest.aPriority\" UI=\"LT_ClientServiceRequest_Label_Priority\" PIN=\"0\" WIDTH=\"141\" /> \r\n" +
" <COLUMNITEM CM=\"aClientServiceRequest.aTitle\" UI=\"LT_O_ClientServiceRequest\" PIN=\"0\" WIDTH=\"156\" /> \r\n" +
" <COLUMNITEM CM=\"aClient.aName\" UI=\"LT_O_Client\" PIN=\"0\" WIDTH=\"98\" /> \r\n" +
" <COLUMNITEM CM=\"aWorkorderService.aServiceNumber\" UI=\"LT_O_Workorder\" PIN=\"0\" WIDTH=\"100\" /> \r\n" +
" <COLUMNITEM CM=\"aClientServiceRequest.ACLIENTREF\" UI=\"LT_ClientServiceRequest_Label_CustomerReferenceNumber\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
" <COLUMNITEM CM=\"aUser.aInitials\" UI=\"LT_Common_Label_Creator\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
" <COLUMNITEM CM=\"aUnit.aSerial\" UI=\"LT_Unit_Label_Serial\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
" <COLUMNITEM CM=\"aHeadOffice.aName\" UI=\"LT_O_HeadOffice\" PIN=\"0\" WIDTH=\"107\" /> \r\n" +
" <COLUMNITEM CM=\"aRegion.aName\" UI=\"LT_O_Region\" PIN=\"0\" WIDTH=\"83\" /> \r\n" +
" <COLUMNITEM CM=\"aClientServiceRequest.AREQUESTEDBY\" UI=\"LT_ClientServiceRequest_Label_RequestedBy\" PIN=\"0\" WIDTH=\"122\" /> \r\n" +
" <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_ClientServiceRequest_Label_Status\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aClientServiceRequest.aStatus\" UI=\"LT_ClientServiceRequest_Label_Status\" TYPE=\"System.Int32\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"0\" /> \r\n" +
" </WHEREITEMGROUP> \r\n" +
"</GRIDCRITERIA> ";
string critSub = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_ClientServiceRequest_Label_Status\"> \r\n" +
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aClientServiceRequest.aStatus\" UI=\"LT_ClientServiceRequest_Label_Status\" TYPE=\"System.Int32\" UICOMPAREVALUE=\"\" COMPAREVALUE=\"0\" /> \r\n" +
" </WHEREITEMGROUP> \r\n";
di.ListCriteria.Add("CompanyNewServiceRequests", critSub);//used to filter grid list in UI when user clicks More... list item
ClientClientServiceRequestList l = ClientClientServiceRequestList.Get(crit, DASHBOARDMAXLISTITEMS, null);
if (l.Count > 0)
{
int max = Max(l.Count);
for (int x = 0; x < max; x++)
{
di.compServiceRequestsList.Add(new DashBoardInfoItem(l[x]));
}
if (l.Count == DASHBOARDMAXLISTITEMS)
di.compServiceRequestsList.Add(MoreItem);
}
}
#endregion my overdue
}
//?? contracts about to expire ??
//?? Maybe this: active banked service at zero or negative ??
//?? Average response time ??
}
}
#endregion company lists
return di;
}
private static int Max(int listCount)
{
if (listCount < DASHBOARDMAXLISTITEMS)
return listCount;
else
return DASHBOARDMAXLISTITEMS;
}
}//eoc
/// <summary>
/// Used internally to populate dashboard lists
/// </summary>
public class DashBoardInfoItem
{
public TypeAndID id { get; set; }
public string item { get; set; }
public DashBoardInfoItem(string itemDescription)
{
id = new TypeAndID(RootObjectTypes.Nothing, Guid.Empty);
item = itemDescription;
}
public DashBoardInfoItem(RootObjectTypes objectType, Guid objectId, string itemDescription)
{
id = new TypeAndID(objectType, objectId);
item = itemDescription;
}
public DashBoardInfoItem(object listInfoObject)
{
if (listInfoObject is WorkorderServiceScheduledUserList.WorkorderServiceScheduledUserListInfo)
{
WorkorderServiceScheduledUserList.WorkorderServiceScheduledUserListInfo i = (WorkorderServiceScheduledUserList.WorkorderServiceScheduledUserListInfo)listInfoObject;
id = new TypeAndID(RootObjectTypes.WorkorderItemScheduledUser, i.LT_WorkorderItemScheduledUser_Label_ID);
item = i.LT_WorkorderItemScheduledUser_Label_StartDate.ToString() + " " + i.LT_O_Workorder.Display + " " + i.LT_O_Client.Display + " " + i.LT_WorkorderItem_Label_Summary.Replace('\r', ' ').Replace("\n", "");
}
else if (listInfoObject is MemoList.MemoListInfo)
{
MemoList.MemoListInfo i = (MemoList.MemoListInfo)listInfoObject;
id = new TypeAndID(RootObjectTypes.Memo, i.ID);
item = i.LT_Memo_Label_Sent.ToString() + " " + i.LT_Memo_Label_FromID.Display + " " + i.LT_Memo_Label_Subject;
}
else if (listInfoObject is DashboardReminderList.DashboardReminderListInfo)
{
DashboardReminderList.DashboardReminderListInfo i = (DashboardReminderList.DashboardReminderListInfo)listInfoObject;
id = new TypeAndID(RootObjectTypes.ScheduleMarker, i.SourceObjectID);
item = i.StartDateTime.ToString() + " " + i.Subject;
}
else if (listInfoObject is ClientClientServiceRequestList.ClientClientServiceRequestListInfo)
{
ClientClientServiceRequestList.ClientClientServiceRequestListInfo i = (ClientClientServiceRequestList.ClientClientServiceRequestListInfo)listInfoObject;
id = new TypeAndID(RootObjectTypes.ClientServiceRequest, i.ID);
item = i.LT_Common_Label_Created.ToString() + " " + i.LT_O_Client + " " + i.LT_O_ClientServiceRequest + " " + i.LT_ClientServiceRequest_Label_RequestedBy;
}
}
}
#pragma warning restore 1591
}//ens

View File

@@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////
// DashBoardInfoRI.cs
// Implementation of Class DashBoardInfoRI
// CSLA type: Read-only object
// Created on: 09-Jan-2012
// Object design: John / Joyce
// Coded: John 09-Jan-2012
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Fetches header and user information for Dashboard form / page
/// </summary>
[Serializable]
public class DashBoardInfoRI : ReadOnlyBase
{
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private DashBoardInfoRI()
{
}
public long defaultListCount { get { return 3L; } }
public string CurrentUserNameFormatted { get; private set; }
public string CurrentCompanyOrRegionName { get; private set; }
public string More { get; private set; }
public bool FetchScheduleableUserInfo { get; private set; }
public long myOverdueTotal { get; private set; }
public long myScheduledTotal { get; private set; }
public long compNotAssignedTotal { get; private set; }
public long compOverdueTotal { get; private set; }
public long compScheduledTotal { get; private set; }
public long myMemoTotal { get; private set; }
public long myReminderTotal { get; private set; }
public long compCSRTotal { get; private set; }
public static DashBoardInfoRI Get(string sMore)
{
DashBoardInfoRI di = new DashBoardInfoRI();
di.More = sMore;
di.FetchScheduleableUserInfo = true;
if (User.IsAdmin) di.FetchScheduleableUserInfo = false;
if (User.CurrentUserType != UserTypes.Schedulable)
di.FetchScheduleableUserInfo = false;
di.CurrentUserNameFormatted = UserPickList.GetListOfOneSpecificUser(User.CurrentThreadUserID)[0].Name;
di.CurrentCompanyOrRegionName = AyaBizUtils.REGTO;
if (!User.CurrentUserIsInDefaultRegion)
di.CurrentCompanyOrRegionName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Region, User.CurrentUserRegionID)).RecordName;
di.myOverdueTotal = DashBoardScheduledUserListRI.GetCount("myOverdue");
di.myScheduledTotal = DashBoardScheduledUserListRI.GetCount("myScheduled");
di.myMemoTotal = DashBoardMemoListRI.GetCount();
di.myReminderTotal = DashboardReminderListRI.GetCount();
di.compNotAssignedTotal = DashBoardScheduledUserListRI.GetCount("compNotAssigned");
di.compOverdueTotal = DashBoardScheduledUserListRI.GetCount("compOverdue");
di.compScheduledTotal = DashBoardScheduledUserListRI.GetCount("compScheduled");
di.compCSRTotal = DashBoardClientServiceRequestListRI.GetCount();
return di;
}
}//eoc
#pragma warning restore 1591
}//ens

View File

@@ -0,0 +1,143 @@
///////////////////////////////////////////////////////////
// DashBoardMemoListRI.cs
// Implementation of Class DashBoardMemoListRI
// CSLA type: Read only collection
// Created on: 25-Sept-2014
// Object design: John
// Coded: 25-Sept-2014
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Lightweight read only list of objects representing <see cref="Memo"/> object
/// used internally for Web dashboard
///
/// </summary>
[Serializable]
public class DashBoardMemoListRI : ReadOnlyBase
{
public long _Count = 0;
public Dictionary<Guid, string> list = null;
#region Constructor
protected DashBoardMemoListRI()
{
}
#endregion
#region Static methods
public static Dictionary<Guid, string> GetList(int MaxRecords = 3)
{
return ((DashBoardMemoListRI)DataPortal.Fetch(new Criteria(false, MaxRecords))).list;
}
public static long GetCount()
{
return ((DashBoardMemoListRI)DataPortal.Fetch(new Criteria(true, 0)))._Count;
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
DateTime dtNow = DBUtil.CurrentWorkingDateTime;
try
{
DBCommandWrapper cm = null;
string qFields = "";
if (crit.Count)
qFields = "SELECT COUNT(*) ";
else
qFields = "SELECT ~MAXRECS~ AMEMO.AID AS AMEMOID, AMEMO.ACREATED, " +
"AMEMO.AVIEWED, AMEMO.ASUBJECT, " +
"AMEMO.AFROMID, AUSER.AFIRSTNAME, AUSER.ALASTNAME, AUSER.AINITIALS, AREGION.ANAME AS AREGIONNAME, " +
"AUSER.AEMPLOYEENUMBER ";
string q = qFields + " FROM AMEMO " +
" LEFT OUTER JOIN AUSER ON AMEMO.AFROMID = AUSER.AID " +
" LEFT OUTER JOIN AREGION ON (AUSER.AREGIONID=AREGION.AID) " +
" WHERE (AMEMO.ATOID = @ID) " ;
if (!crit.Count)
q = q + "ORDER BY AMEMO.ACREATED ";
if (!crit.Count)
{
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
}
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@ID",DbType.Guid,User.CurrentThreadUserID);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
if (!crit.Count)
list = new Dictionary<Guid, string>(crit.MaxRecords);
while (dr.Read())
{
if (crit.Count)
{
object o = dr.GetValue(0);
_Count = long.Parse(o.ToString());
}
else
{
//id = new TypeAndID(RootObjectTypes.Memo, i.ID);
//item = i.LT_Memo_Label_Sent.ToString() + " " + i.LT_Memo_Label_FromID.Display + " " + i.LT_Memo_Label_Subject;
//created + " " + from uyser " " subject
list.Add(dr.GetGuid("AMEMOID"),
DBUtil.ToLocal(dr.GetSmartDate("ACREATED")).ToString() + " " +
User.NameFormatter(dr.GetString("AFIRSTNAME"), dr.GetString("ALASTNAME"), dr.GetString("AINITIALS"),
dr.GetString("AEMPLOYEENUMBER"), dr.GetString("AREGIONNAME"), AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat) + " " +
dr.GetString("ASUBJECT")
);
_Count++;
}
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public bool Count;
public int MaxRecords;
public Criteria(bool count, int maxRecords)
{
MaxRecords = maxRecords;
Count = count;
}
}
#endregion
}//end DashBoardMemoListRI
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,216 @@
///////////////////////////////////////////////////////////
// DashBoardScheduledUserList.cs
// Implementation of Class DashBoardScheduledUserList
// CSLA type: Read only
// Created on: 09-Sept-2014
// Object design: John
// Coded: 09-Sept-2014
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
[Serializable]
public class DashBoardScheduledUserListRI : ReadOnlyBase
{
public long _Count = 0;
public Dictionary<Guid, string> list=null;
#region Constructor
protected DashBoardScheduledUserListRI()
{
}
#endregion
#region Static methods
public static Dictionary<Guid, string> GetList(string List, int MaxRecords = 3)
{
return ((DashBoardScheduledUserListRI)DataPortal.Fetch(new Criteria(List, false, MaxRecords))).list;
}
public static long GetCount(string List)
{
return ((DashBoardScheduledUserListRI) DataPortal.Fetch(new Criteria(List, true, 0)))._Count;
}
#endregion
#region DAL DATA ACCESS
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SmartDate dtNow = new SmartDate(DBUtil.CurrentWorkingDateTime);
Guid currentUserId = User.CurrentThreadUserID;
SafeDataReader dr = null;
try
{
DBCommandWrapper cm = null;
//Base query
string qFields = "";
if (crit.Count)
qFields = "SELECT COUNT(*) ";
else
qFields = "SELECT ~MAXRECS~ AWORKORDERSERVICE.ASERVICENUMBER AS AWORKORDERNUMBER, " +
" ACLIENT.ANAME AS ACLIENTNAME, " +
" AWORKORDERITEM.ASUMMARY AS AWORKORDERITEMSUMMARY, " +
" AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE, " +
" AWORKORDERITEMSCHEDULEDUSER.AID AS AWORKORDERITEMSCHEDULEDUSERID ";
string q =
//***********************************************************************************************************
qFields +
" FROM " +
" AWORKORDER " +
" LEFT OUTER JOIN AWORKORDERITEM ON (AWORKORDER.AID=AWORKORDERITEM.AWORKORDERID) " +
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDER.AID=AWORKORDERSERVICE.AWORKORDERID) " +
" LEFT OUTER JOIN ACLIENT ON (AWORKORDER.ACLIENTID=ACLIENT.AID) " +
" LEFT OUTER JOIN AWORKORDERITEMSCHEDULEDUSER ON (AWORKORDERITEM.AID=AWORKORDERITEMSCHEDULEDUSER.AWORKORDERITEMID) " +
" WHERE (AWORKORDER.AWORKORDERTYPE = 1) AND (AWORKORDER.ASERVICECOMPLETED = 0) AND (AWORKORDERITEMSCHEDULEDUSER.AID IS NOT NULL) "
//***********************************************************************************************************
;
if (!crit.Count)
{
if (crit.MaxRecords > 0)
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
else
q = q.Replace("~MAXRECS~", "");
}
switch (crit.List)
{
case "myOverdue":
//current user only and before or equal to right now
q = q + " AND (AWORKORDERITEMSCHEDULEDUSER.AUSERID=@USERID)";
q = q + " AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE IS NOT NULL) AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE <= @RIGHTNOW)";
q=DBUtil.AddRegionFilter(q);
if(!crit.Count)
q = q + " ORDER BY AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE ASC";
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@RIGHTNOW", DbType.DateTime, DBUtil.ToUTC(dtNow).DBValue);
cm.AddInParameter("@USERID", DbType.Guid, currentUserId);
break;
case "myScheduled":
//current user only and after right now
q = q + " AND (AWORKORDERITEMSCHEDULEDUSER.AUSERID=@USERID)";
q = q + " AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE IS NOT NULL) AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE > @RIGHTNOW)";
q=DBUtil.AddRegionFilter(q);
if (!crit.Count)
q = q + " ORDER BY AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE ASC";
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@RIGHTNOW", DbType.DateTime, DBUtil.ToUTC(dtNow).DBValue);
cm.AddInParameter("@USERID", DbType.Guid, currentUserId);
break;
case "compNotAssigned":
//empty user
q = q + " AND (AWORKORDERITEMSCHEDULEDUSER.AUSERID IS NULL)";
q=DBUtil.AddRegionFilter(q);
if (!crit.Count)
q = q + " ORDER BY AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE DESC";
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
//cm.AddInParameter("@USERID", DbType.Guid, Guid.Empty);
break;
case "compOverdue":
//Any user and before or equal to right now
q = q + " AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE IS NOT NULL) AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE <= @RIGHTNOW)";
q = DBUtil.AddRegionFilter(q);
if (!crit.Count)
q = q + " ORDER BY AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE ASC";
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@RIGHTNOW", DbType.DateTime, DBUtil.ToUTC(dtNow).DBValue);
break;
case "compScheduled":
//current user only and after right now
q = q + " AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE IS NOT NULL) AND (AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE > @RIGHTNOW)";
q = DBUtil.AddRegionFilter(q);
if (!crit.Count)
q = q + " ORDER BY AWORKORDERITEMSCHEDULEDUSER.ASTARTDATE ASC";
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@RIGHTNOW", DbType.DateTime, DBUtil.ToUTC(dtNow).DBValue);
break;
default:
throw new System.ArgumentOutOfRangeException("The list type of: \"" + crit.List + "\" was not recognized");
}
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
if(!crit.Count)
list = new Dictionary<Guid, string>(crit.MaxRecords);
while (dr.Read())
{
if (crit.Count)
{
object o=dr.GetValue(0);
_Count = long.Parse(o.ToString());
}
else
{
//*******************************************
list.Add(dr.GetGuid("AWORKORDERITEMSCHEDULEDUSERID"),
//"<mark>" + DBUtil.ToLocal(dr.GetSmartDate("ASTARTDATE")).ToString() + "</mark> " +
DBUtil.ToLocal(dr.GetSmartDate("ASTARTDATE")).ToString() + " " +
dr.GetInt32("AWORKORDERNUMBER").ToString() + " " +
dr.GetString("ACLIENTNAME") + " " +
dr.GetString("AWORKORDERITEMSUMMARY").Replace('\r', ' ').Replace("\n", ""));
_Count++;
//*******************************************
}
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for list
/// </summary>
[Serializable]
private class Criteria
{
public bool Count;
public string List;
public int MaxRecords;
public Criteria(string list, bool count, int maxRecords)
{
MaxRecords = maxRecords;
Count = count;
List = list;
}
}
#endregion
}//end DashBoardScheduledUserList
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,381 @@
///////////////////////////////////////////////////////////
// DashboardReminderList.cs
// Implementation of Class DashboardReminderList
// CSLA type: Read only collection
// Created on: 10-Jan-2012
// Object design: John
// Coded: 10-Jan-2012
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Text.RegularExpressions;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// A list of reminders (schedule markers) for populating the dashboard in AyaNova
/// (Read only collection )
/// </summary>
[Serializable]
public class DashboardReminderList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct DashboardReminderListInfo
{
//used to indicate there is nothing in this
//struct
internal bool mIsEmpty;
//internal Guid mWorkorderID;
//internal Guid mWorkorderItemID;
//internal int mServiceNumber;
internal RootObjectTypes mAppliesToObjectType;
internal Guid mAppliesToObjectID;
internal RootObjectTypes mSourceObjectType;
//This is the workorderitemscheduleduser record ID
internal Guid mSourceObjectID;
internal string mSubject;
internal string mDetails;
internal DateTime mStartDateTime;
internal DateTime mEndDateTime;
internal bool mAllDay;
//If
internal bool mShowPriorityFlag;
internal int mPriorityARGB;
internal int mBackColorARGB;
#pragma warning disable 1591
/// <summary>
/// true if there is nothing in this record
/// false if this record contains a valid appointment
/// </summary>
public bool IsEmpty {get{return mIsEmpty;}set{mIsEmpty=value;}}
/// <summary>
/// What object type this appointment applies to, can be single user
/// or another object type that represents a group of users
/// such as: region, sched user group etc etc
/// </summary>
public RootObjectTypes AppliesToObjectType{get{return mAppliesToObjectType;}}
/// <summary>
/// Object ID appointment applies to
/// </summary>
public Guid AppliesToObjectID{get{return mAppliesToObjectID;}}
/// <summary>
/// Type of appointment
/// either ScheduleMarker or WorkorderItemScheduledUser
/// </summary>
public RootObjectTypes SourceObjectType{get{return mSourceObjectType;}}
/// <summary>
/// The ID of the schedulemarker or workorderitemscheduleduser object
/// </summary>
public Guid SourceObjectID {get{return mSourceObjectID;}}
///// <summary>
///// ID of workorder if this appointment is a scheduled workorder user
///// </summary>
//public Guid WorkorderID {get{return mWorkorderID;}}
///// <summary>
///// ID of workorder item if this appointment is a scheduled workorder user
///// </summary>
//public Guid WorkorderItemID {get{return mWorkorderItemID;}}
///// <summary>
///// Visible sequential workorder number of workorder
///// if this appointment is a scheduled workorder user
///// </summary>
//public int ServiceNumber {get{return mServiceNumber;}}
/// <summary>
/// Description of appointment, either a schedulemarker
/// description or a summary of the workorder
/// formatted according to the workorder
/// </summary>
public string Subject {get{return mSubject;}}
public string Details {get{return mDetails;}}
public DateTime StartDateTime {get{return mStartDateTime;}}
public DateTime EndDateTime {get{return mEndDateTime;}}
public bool AllDay {get{return mAllDay;}}
public int PriorityARGB {get{return mPriorityARGB;}}
public bool ShowPriorityFlag {get{return mShowPriorityFlag;}}
/// <summary>
/// Back color of appointment
/// could be workorder status or schedmarker colour
/// </summary>
public int BackColorARGB {get{return mBackColorARGB;} }
#pragma warning restore 1591
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(DashboardReminderListInfo obj)
{
return this.mSourceObjectID.Equals(obj.mSourceObjectID);
}
}//end DashboardReminderListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected DashboardReminderList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public DashboardReminderListInfo this[int Item]
{
get
{
return (DashboardReminderListInfo) List[Item];
}
}
/// <summary>
/// Returns DashboardReminderListInfo item that matches passed in itemid value
/// </summary>
/// <param name="o"></param>
public DashboardReminderListInfo this[Guid o]
{
get
{
foreach (DashboardReminderListInfo child in List)
{
if(child.mSourceObjectID==o) return child;
}
throw new ArgumentException("DashboardReminderList: SourceObjectID not found\r\n");
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(DashboardReminderListInfo obj)
{
foreach (DashboardReminderListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get list of <see cref="DashboardReminderListInfo"/> objects.
/// Returns list of closest upcoming reminders for currently logged in user
///
/// </summary>
/// <param name="MaximumItemsToRetrieve">What it says</param>
/// <returns>A read only collection of <see cref="DashboardReminderListInfo"/> objects (ScheduleMarkers)</returns>
public static DashboardReminderList GetList(int MaximumItemsToRetrieve)
{
return (DashboardReminderList)DataPortal.Fetch(new Criteria(MaximumItemsToRetrieve));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
System.Collections.Generic.List<string> ListOfAppointmentSubjects = new System.Collections.Generic.List<string>();
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
UserListScheduleable ulist = UserListScheduleable.GetList();
try
{
#region Schedule markers
//Not filtered by user if specific user is specified which is what we want
//next query
DBCommandWrapper cmSM = DBUtil.DB.GetSqlStringCommandWrapper(
"SELECT aScheduleMarkerSourceType, aSourceID,aID,aNotes,aName, " +
"aStopDate,aStartDate, AARGB FROM aScheduleMarker " +
"WHERE (aStartDate > @CurrentDateTime) ORDER BY ASTARTDATE "
);
//Add parameters
cmSM.AddInParameter("@CurrentDateTime", DbType.DateTime, DBUtil.ToUTC(DBUtil.CurrentWorkingDateTime));
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cmSM));
while (dr.Read())
{
DashboardReminderListInfo info=new DashboardReminderListInfo();
info.mAllDay=false;
info.mIsEmpty=false;
ScheduleMarkerSourceTypes smt=(ScheduleMarkerSourceTypes)dr.GetInt16("aScheduleMarkerSourceType");
info.mAppliesToObjectID = dr.GetGuid("aSourceID");
switch(smt)
{
case ScheduleMarkerSourceTypes.User:
info.mAppliesToObjectType=RootObjectTypes.User;
//screen the user to make sure they are scheduleable and active && are the current logged in user //case 1963
//If not, skip 'em
if (info.mAppliesToObjectID != Guid.Empty &&
info.mAppliesToObjectID != ScheduleMarker.ScheduleMarkerGlobalSourceID)//is it a user?
{
//case 1963 changed following, not sure why it was done that way, completely wrong
//if(!ulist.ContainsActiveUser(dr.GetGuid("aSourceID")))
if(info.mAppliesToObjectID!= User.CurrentThreadUserID)
continue;
}
break;
case ScheduleMarkerSourceTypes.Regional:
//Case 58
//If it applies to a specific region besides default and the current user is not default region and the applies to region id is not
//the current users then don't show it
if ((info.mAppliesToObjectID!=Region.DefaultRegionID) && (User.CurrentUserRegionID != Region.DefaultRegionID) && info.mAppliesToObjectID != User.CurrentUserRegionID)
continue;
info.mAppliesToObjectType=RootObjectTypes.Region;
break;
case ScheduleMarkerSourceTypes.Global:
info.mAppliesToObjectType=RootObjectTypes.Global;
break;
case ScheduleMarkerSourceTypes.DispatchZone:
info.mAppliesToObjectType=RootObjectTypes.DispatchZone;
break;
case ScheduleMarkerSourceTypes.ScheduleableUserGroup:
info.mAppliesToObjectType=RootObjectTypes.ScheduleableUserGroup;
break;
}
info.mSourceObjectType=RootObjectTypes.ScheduleMarker;
info.mSourceObjectID=dr.GetGuid("aID");
info.mDetails=dr.GetString("aNotes");
info.mSubject=dr.GetString("aName");
info.mEndDateTime=DBUtil.ToLocal(dr.GetDateTime("aStopDate"));
info.mStartDateTime=DBUtil.ToLocal(dr.GetDateTime("aStartDate"));
//priority doesn't apply here, but don't
//leave it dangling
info.mShowPriorityFlag=false;
info.mPriorityARGB=0;
info.mBackColorARGB=dr.GetInt32("AARGB");
InnerList.Add(info);
}
#endregion schedulemarkers
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public int MaximumItemsToRetrieve;
public Criteria(int _MaximumItemsToRetrieve)
{
MaximumItemsToRetrieve = _MaximumItemsToRetrieve;
}
}
#endregion
}//end DashboardReminderList
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,172 @@
///////////////////////////////////////////////////////////
// DashboardReminderListRI.cs
// Implementation of Class DashboardReminderListRI
// CSLA type: Read only collection
// Created on: 25-Sept-2014
// Object design: John
// Coded: 25-Sept-2014
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
using System.Collections.Generic;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// A list of reminders (schedule markers) for populating the web dashboard in AyaNova RI
/// (Read only collection )
/// </summary>
[Serializable]
public class DashboardReminderListRI : ReadOnlyBase
{
public long _Count = 0;
public Dictionary<Guid, string> list = null;
#region Constructor
/// <summary>
///
/// </summary>
protected DashboardReminderListRI()
{
}
#endregion
#region Static methods
public static Dictionary<Guid, string> GetList(int MaxRecords = 3)
{
return ((DashboardReminderListRI)DataPortal.Fetch(new Criteria(false, MaxRecords))).list;
}
public static long GetCount()
{
return ((DashboardReminderListRI)DataPortal.Fetch(new Criteria(true, 0)))._Count;
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
UserListScheduleable uls = UserListScheduleable.GetList();
Guid activeUserId = User.CurrentThreadUserID;
try
{
DBCommandWrapper cm = null;
string qFields = "";
qFields = "SELECT ~MAXRECS~ AID, ANAME, ASTARTDATE, ASOURCEID, ASCHEDULEMARKERSOURCETYPE ";
string q = qFields + "FROM ASCHEDULEMARKER WHERE (ASTARTDATE > @RIGHTNOW) ORDER BY ASTARTDATE ";
//bugbug: because it's fetching all types then seeing which apply you can't restrict it this way
//if (crit.MaxRecords > 0)
// q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
//else
q = q.Replace("~MAXRECS~", "");
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
cm.AddInParameter("@RIGHTNOW", DbType.DateTime, DBUtil.ToUTC(DBUtil.CurrentWorkingDateTime));
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
if (!crit.Count)
list = new Dictionary<Guid, string>(crit.MaxRecords);
while (dr.Read())
{
if (relevantScheduleMarker(activeUserId, (ScheduleMarkerSourceTypes)dr.GetInt16("aScheduleMarkerSourceType"), dr.GetGuid("ASOURCEID"), uls))
{
_Count++;
if (!crit.Count)
{
list.Add(dr.GetGuid("AID"), DBUtil.ToLocal(dr.GetSmartDate("ASTARTDATE")).ToString() + " " + dr.GetString("ANAME"));
if (_Count >= crit.MaxRecords)
break;
}
}
}
}
finally
{
if (dr != null) dr.Close();
}
}
private static bool relevantScheduleMarker(Guid activeUserId, ScheduleMarkerSourceTypes appliesToObjectType, Guid appliesToObjectId, UserListScheduleable uls)
{
//appliesToObjectId==aSourceId
//ScheduleMarkerSourceTypes smt=(ScheduleMarkerSourceTypes)dr.GetInt16("aScheduleMarkerSourceType");
//Don't process for unassigned user
if (activeUserId == Guid.Empty) return false;
//Could be a bunch by region , global , dispatchzone, schedusergroup
//or could be a single by one user ID
switch (appliesToObjectType)
{
case ScheduleMarkerSourceTypes.User:
{
if (appliesToObjectId == activeUserId)
return true;
}
break;
case ScheduleMarkerSourceTypes.Regional:
{
if (uls[activeUserId].RegionID == appliesToObjectId)
return true;
}
break;
case ScheduleMarkerSourceTypes.DispatchZone:
{
if (uls[activeUserId].DispatchZoneID == appliesToObjectId)
return true;
}
break;
case ScheduleMarkerSourceTypes.ScheduleableUserGroup:
{
ScheduleableUserGroupUsersList ScheduleMarkerGroup = ScheduleableUserGroupUsersList.GetList(appliesToObjectId);
if (ScheduleMarkerGroup.Contains(activeUserId))//Case 835
return true;
}
break;
case ScheduleMarkerSourceTypes.Global:
{
return true;
}
}
return false;
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public bool Count;
public int MaxRecords;
public Criteria(bool count, int maxRecords)
{
MaxRecords = maxRecords;
Count = count;
}
}
#endregion
}//end DashboardReminderListRI
#pragma warning restore 1591
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,216 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class DashboardServiceRateBalanceFetcher
// CSLA type: Read-only object
// Created on: 11-Jan-2012
// Object design: John
// Coded: John 11-Jan-2012
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Fetch service hours balance for dashboard display
/// </summary>
[Serializable]
public class DashboardServiceRateBalanceFetcher : ReadOnlyBase
{
private decimal mToday=0;
private decimal mYesterday=0;
private decimal mThisWeek=0;
private decimal mThisMonth = 0;
private decimal mThisYear = 0;
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private DashboardServiceRateBalanceFetcher()
{
}
#endregion
#region Business properties
public decimal Today {get{return mToday;}}
public decimal Yesterday {get{return mYesterday;}}
public decimal ThisWeek {get{return mThisWeek;}}
public decimal ThisMonth { get { return mThisMonth; } }
public decimal ThisYear { get { return mThisYear; } }
#endregion
#region Static methods
/// <summary>
/// Get service rate balances
/// </summary>
/// <param name="UserId"></param>
/// <param name="PersonalOnly">true - get for user, false - get for entire company or region only if user is regional</param>
/// <returns></returns>
public static DashboardServiceRateBalanceFetcher GetItem(Guid UserId, bool PersonalOnly)
{
return (DashboardServiceRateBalanceFetcher)DataPortal.Fetch(new Criteria(UserId, PersonalOnly));
}
#endregion
#region DAL DATA ACCESS
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
#region Pre-calculate dates
//************* Today
//Between yesterday at midnight and tommorow at midnight
DateTime dTodayAfter = DBUtil.ToUTC(System.DateTime.Today.AddSeconds(-1));
DateTime dTodayBefore = DBUtil.ToUTC(System.DateTime.Today.AddDays(1));
//************* Yesterday
//Between Day before yesterday at midnight and yesterday at midnight
DateTime dYesterdayAfter = DBUtil.ToUTC(System.DateTime.Today.AddDays(-1).AddSeconds(-1));
DateTime dYesterdayBefore = DBUtil.ToUTC(System.DateTime.Today);
//************* ThisWeek
//Between Sunday at midnight and Next sunday at midnight
DateTime dThisWeekAfter = System.DateTime.Today;
//go backwards to monday
while (dThisWeekAfter.DayOfWeek != DayOfWeek.Monday)
dThisWeekAfter = dThisWeekAfter.AddDays(-1);
//Now go back to sunday last second
dThisWeekAfter = dThisWeekAfter.AddSeconds(-1);
DateTime dThisWeekBefore = System.DateTime.Today;
//go forwards to monday
if (System.DateTime.Today.DayOfWeek == DayOfWeek.Monday)
{
//Monday today? then go to next monday
dThisWeekBefore = dThisWeekBefore.AddDays(7);
}
else
{
while (dThisWeekBefore.DayOfWeek != DayOfWeek.Monday)
dThisWeekBefore = dThisWeekBefore.AddDays(1);
}
dThisWeekAfter = DBUtil.ToUTC(dThisWeekAfter);
dThisWeekBefore = DBUtil.ToUTC(dThisWeekBefore);
//************* This Month
//start with the first day of this month minus one second
DateTime dThisMonthAfter = DBUtil.ToUTC(new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddSeconds(-1));
//add a month plus one second
DateTime dThisMonthBefore = DBUtil.ToUTC(dThisMonthAfter.AddMonths(1).AddSeconds(1));
//************* This Year
//start with the first day of this year minus one second
DateTime dThisYearAfter = DBUtil.ToUTC(new DateTime(DateTime.Today.Year, 1, 1, 00, 00, 00).AddSeconds(-1));
//add a year plus one second
DateTime dThisYearBefore = DBUtil.ToUTC(dThisYearAfter.AddYears(1).AddSeconds(1));
#endregion
DBCommandWrapper cm = null;
if (crit.PersonalOnly)
{
//Personal only
cm = DBUtil.DB.GetSqlStringCommandWrapper("SELECT SUM(ASERVICERATEQUANTITY) AS QUANTSUM " +
"FROM AWORKORDERITEMLABOR " +
"WHERE AUSERID=@USERID AND " +
"ASERVICESTARTDATE BETWEEN @STARTDATE AND @ENDDATE ");
cm.AddInParameter("@USERID", DbType.Guid, crit.UserId);
}
else
{
if (User.IsAdmin || User.CurrentUserIsInDefaultRegion)
{
//Entire company
cm = DBUtil.DB.GetSqlStringCommandWrapper("SELECT SUM(ASERVICERATEQUANTITY) AS QUANTSUM " +
"FROM AWORKORDERITEMLABOR " +
"WHERE ASERVICESTARTDATE BETWEEN @STARTDATE AND @ENDDATE ");
}
else
{
//Regional
cm = DBUtil.DB.GetSqlStringCommandWrapper("SELECT SUM(ASERVICERATEQUANTITY) AS QUANTSUM " +
"FROM AWORKORDERITEMLABOR LEFT OUTER JOIN " +
"AWORKORDERITEM LEFT OUTER JOIN " +
"AWORKORDER LEFT OUTER JOIN " +
"ACLIENT ON AWORKORDER.ACLIENTID = ACLIENT.AID ON AWORKORDERITEM.AWORKORDERID = AWORKORDER.AID ON " +
"AWORKORDERITEMLABOR.AWORKORDERITEMID = AWORKORDERITEM.AID " +
"WHERE ACLIENT.AREGIONID=@REGIONID AND " +
"ASERVICESTARTDATE BETWEEN @STARTDATE AND @ENDDATE ");
cm.AddInParameter("@REGIONID", DbType.Guid, User.CurrentUserRegionID);
}
}
//Add parameters initially so they can be modified later for each run
//of the query
cm.AddInParameter("@STARTDATE", DbType.DateTime, dTodayAfter);
cm.AddInParameter("@ENDDATE", DbType.DateTime, dTodayBefore);
//Get the values
mToday = GetValue(dTodayAfter, dTodayBefore, cm);
mYesterday = GetValue(dYesterdayAfter, dYesterdayBefore, cm);
mThisWeek = GetValue(dThisWeekAfter, dThisWeekBefore, cm);
mThisMonth = GetValue(dThisMonthAfter, dThisMonthBefore, cm);
mThisYear = GetValue(dThisYearAfter, dThisYearBefore, cm);
}
private decimal GetValue(DateTime dAfter, DateTime dBefore, DBCommandWrapper cm)
{
decimal retValue = 0;
cm.SetParameterValue("@STARTDATE", dAfter);
cm.SetParameterValue("@ENDDATE", dBefore);
SafeDataReader dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
if (dr.Read())
retValue = dr.GetDecimal("QUANTSUM");
dr.Close();
return decimal.Round(retValue, 2, MidpointRounding.AwayFromZero);
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid UserId;
public bool PersonalOnly;
public Criteria(Guid _UserId, bool _PersonalOnly)
{
UserId = _UserId;
PersonalOnly = _PersonalOnly;
}
}
#endregion
}//end Bool
#pragma warning restore 1591
}//end Boolspace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,161 @@
///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class DataPortalInfo
// CSLA type: Read-only object
// Created on: 06-Dec-2004
// Object design: John
// Coded: John Aug 4 2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.Text;
using System.Diagnostics;
using System.Reflection;
using System.Configuration;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Used to quickly fetch a single Bool record from the db
/// </summary>
[Serializable]
public class DataPortalInfo : ReadOnlyBase
{
#region Attributes
private string mInfo;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private DataPortalInfo()
{
}
#endregion
#region Business properties
#endregion
#region Static methods
/// <summary>
/// Fetch support info off the remote data portal
/// </summary>
/// <returns></returns>
public static string GetItem()
{
return ((DataPortalInfo)DataPortal.Fetch(new Criteria( ))).mInfo;
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
try
{
StringBuilder sb = new StringBuilder();
sb.Append(
"\tPORTAL: Machine name: " + System.Environment.MachineName + "\r\n" +
//"\tAyaNova Connection: " + DiagnosticConnectionInfo + "\r\n" +
//"\tGenerate PM and Notify from this connection: " + IAmAGenerator.ToString()+ "\r\n" +
"\tPORTAL: OS user name: " + System.Environment.UserName + "\r\n" +
//"\tNetworked: " + SystemInformation.Network.ToString() + "\r\n" +
"\tPORTAL: OS user domain name: " + System.Environment.UserDomainName + "\r\n" +
//"\tPORTAL: OS version: " + System.Environment.OSVersion.ToString() + "\r\n" +
OSVersionInfo.FullOperatingSystemInformationForDisplay + "\r\n" +
"\tPORTAL: System folder: " + System.Environment.SystemDirectory + "\r\n" +
"\tPORTAL: CLR version: " + System.Environment.Version.ToString() + "\r\n" +
"\tPORTAL: Current directory: " + System.Environment.CurrentDirectory + "\r\n" +
"\tPORTAL: Logical drives: ");
foreach(string s in System.Environment.GetLogicalDrives())
sb.Append(s+" ");
sb.Append( "\r\n");
sb.Append(
"\tPORTAL: Working set: " + System.Environment.WorkingSet.ToString() + "\r\n" +
//"\tPrimary monitor size: " + SystemInformation.PrimaryMonitorSize.ToString() + "\r\n" +
"\tPORTAL: Locale current culture: " + System.Threading.Thread.CurrentThread.CurrentCulture.EnglishName + "\r\n" +
"\tPORTAL: Locale currency symbol: " + System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol + "\r\n" +
"\tPORTAL: Locale short date pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern + "\r\n" +
"\tPORTAL: Locale short time pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern + "\r\n" );
Assembly a=Assembly.GetExecutingAssembly();
AssemblyName an=a.GetName();
sb.Append("\tPORTAL: Primary assembly: "+an.Name + " " + AyaBizUtils.DisplayVersion(an.Version)+"\r\n");
////Sub release version if any
sb.Append(AyaBizUtils.SubVersion);
sb.Append("\tPORTAL: Primary assembly location: "+an.CodeBase +"\r\n");
sb.Append("\t\tPORTAL: References:\r\n");
foreach(AssemblyName arn in a.GetReferencedAssemblies())
{
sb.Append("\t\tPORTAL: " + arn.Name + " " + AyaBizUtils.DisplayVersion(arn.Version)+"\r\n");
}
mInfo=sb.ToString();
}
catch(Exception ex)
{
this.mInfo="PORTAL: Error retrieving diagnostic info:\r\n" + ex.Message;
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Criteria()
{
}
}
#endregion
}//end Bool
}//end Boolspace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,600 @@
///////////////////////////////////////////////////////////
// DispatchZone.cs
// Implementation of Class DispatchZone
// CSLA type: Editable Child
// Created on: 07-Jun-2004 8:41:23 AM
// Object design: Joyce
// Coded: John 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Dispatch zones, used to group scheduleable users for filtering in Schedule calendar
/// as well as filtering and sorting in grids and reporting purposes
/// </summary>
[Serializable]
public class DispatchZone : BusinessBase {
#region Attributes
private bool bReadOnly;
private Guid mID;
private SmartDate mCreated;
private SmartDate mModified;
private bool mActive;
private Guid mCreator;
private Guid mModifier;
private string mDescription="";
private string mName=null;
//case 58
private Guid mRegionID;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private DispatchZone()
{
//Set as child object
MarkAsChild();
//Set to read / write initially so that properties
//can be set
bReadOnly=false;
//New ID
mID = Guid.NewGuid();
//pre-break the rule
Name="";
Active=true;
//Set record history to defaults
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified=new SmartDate();
mCreator=Guid.Empty;
mModifier=Guid.Empty;
//Built-in "Default" region
mRegionID = Region.DefaultRegionID;//case 58
}
#endregion
#region Business properties
/// <summary>
/// Get internal id number Read only property because it's set internally, not
/// externally
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// Get /set active status of DispatchZone
/// If active = true then DispatchZone is selectable for workorders etc
/// If active = false then DispatchZone in not selectable, but history can be viewed
/// </summary>
public bool Active
{
get
{
return mActive;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mActive!=value)
{
mActive = value;
MarkDirty();
}
}
}
}
/// <summary>
/// Description about DispatchZone
/// </summary>
public string Description
{
get
{
return mDescription;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mDescription!=value)
{
mDescription = value;
MarkDirty();
}
}
}
}
/// <summary>
/// Original sales Name number
/// </summary>
public string Name
{
get
{
return mName;
}
set
{
if(bReadOnly)
ThrowSetError();
else
{
if(mName!=value)
{
mName = value;
BrokenRules.Assert("NameRequired",
"Error.Object.RequiredFieldEmpty,DispatchZone.Label.Name","Name",value.Length==0);
BrokenRules.Assert("NameLength",
"Error.Object.FieldLengthExceeded255,DispatchZone.Label.Name","Name",value.Length>255);
MarkDirty();
}
}
}
}
/// <summary>
/// Limit to specific region or available to all regions using Region.DefaultRegionID
/// </summary>
public Guid RegionID
{
get
{
return mRegionID;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mRegionID != value)
{
mRegionID = value;
BrokenRules.Assert("RegionIDRequired",
"Error.Object.RequiredFieldEmpty,O.Region",
"RegionID", value == Guid.Empty);
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.DispatchZone")
)
);
}
#endregion
#region System.object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "DispatchZone" + mID.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
DispatchZone c=(DispatchZone)obj;
return mID==c.mID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("DispatchZone"+mID).GetHashCode();
}
#endregion
#region Searching
/// <summary>
/// Returns a search result object based on search terms
/// for the ID specified
/// </summary>
/// <param name="ID"></param>
/// <param name="searchTerms"></param>
/// <returns></returns>
public static SearchResult GetSearchResult(Guid ID, string[]searchTerms)
{
if(AyaBizUtils.Right("Object.DispatchZone")<(int)SecurityLevelTypes.ReadOnly)
return new SearchResult();
SearchResult sr=new SearchResult();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString(
"SELECT aRegionID, aCreated, aModified, aCreator, aModifier, aName, " +
" aDescription FROM aDispatchZone WHERE (aID = @ID)"
,ID);
if(!dr.Read())
return new SearchResult();//DBUtil.ThrowFetchError("SearchResult for DispatchZoneID: " + ID.ToString());
if (!AyaBizUtils.InYourRegion(dr.GetGuid("aRegionID"))) return new SearchResult();//case 58
sr.Description=dr.GetString("aName");
sb.Append(sr.Description);
sb.Append(" ");
sb.Append(dr.GetString("aDescription"));
sr.Created=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
sr.Modified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
sr.Creator=dr.GetGuid("aCreator");
sr.Modifier=dr.GetGuid("aModifier");
}
finally
{
if(dr!=null) dr.Close();
}
//Formulate results
ExtractAndRank er = new ExtractAndRank();
er.Process(sb.ToString().Trim(),searchTerms);
sr.Extract=er.Extract;
sr.Rank=er.Ranking;
sr.AncestorRootObjectID=ID;
sr.AncestorRootObjectType=RootObjectTypes.DispatchZone;
return sr;
}
#endregion
#region Static methods
/// <summary>
/// Create new DispatchZone
/// </summary>
/// <returns>DispatchZone</returns>
internal static DispatchZone NewItem()
{
if(AyaBizUtils.Right("Object.DispatchZone")>(int)SecurityLevelTypes.ReadOnly)
{
DispatchZone c = new DispatchZone();
return c;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToCreate"),
LocalizedTextTable.GetLocalizedTextDirect("O.DispatchZone")));
}
/// <summary>
/// Fetch existing DispatchZone
/// </summary>
/// <returns>DispatchZone</returns>
/// <param name="dr">Datareader</param>
internal static DispatchZone GetItem(SafeDataReader dr)
{
if(AyaBizUtils.Right("Object.DispatchZone")>(int)SecurityLevelTypes.NoAccess)
{
DispatchZone child = new DispatchZone();
child.Fetch(dr);
return child;
}
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("O.DispatchZone")));
}
/// <summary>
/// Retrieve internal ID from name.
///
/// </summary>
/// <param name="Name">Text value</param>
/// <returns>Guid ID value or Guid.Empty if no match</returns>
public static Guid GetIDFromName(string Name)
{
return GuidFetcher.GetItem("ADISPATCHZONE", "ANAME", Name);
}
#endregion
#region DAL DATA ACCESS
#region Fetch
/// <summary>
/// Populate this object from the values in the datareader passed to it
/// </summary>
/// <param name="dr"></param>
private void Fetch(SafeDataReader dr)
{
//Standard fields
mID=dr.GetGuid("aID");
mCreated=DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified=DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator=dr.GetGuid("aCreator");
mModifier=dr.GetGuid("aModifier");
//DispatchZone fields
mActive=dr.GetBoolean("AACTIVE");
mDescription=dr.GetString("aDescription");
//Important: use property not internal field
//so that initial broken rule is unbroken on fetch
Name=dr.GetString("aName");
//case 58
mRegionID = dr.GetGuid("aRegionID");
//Get access rights level
bReadOnly=AyaBizUtils.Right("Object.DispatchZone")<(int)SecurityLevelTypes.ReadWrite;
MarkOld();
}
#endregion fetch
#region Update
/// <summary>
///
/// </summary>
/// <param name="tr"></param>
internal void Update(IDbTransaction tr)
{
//No need to update if there is nothing changed
if(!this.IsDirty) return;
// If not a new record, check if record was modified
//by another user since original retrieval:
if(!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"aDispatchZone");
#region Delete
if(IsDeleted)
{
if(!IsNew)
{
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aDispatchZone WHERE aID = @ID;");
cmDelete.AddInParameter("@ID",DbType.Guid,this.mID);
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
DBUtil.RemoveKeywords(tr,RootObjectTypes.DispatchZone,this.mID);
//-----------------------------
}
MarkNew();
return;
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if(IsNew)//Add or update?
cm=DBUtil.GetCommandFromSQL(
"INSERT INTO aDispatchZone (aID, AACTIVE, aName, aDescription, " +
"aCreated,aModified,aCreator,aModifier, aRegionID) VALUES (@ID,@Active, " +
"@Name,@Description,@Created,@Modified,@CurrentUserID,@CurrentUserID,@RegionID)"
);
else
cm=DBUtil.GetCommandFromSQL(
"UPDATE aDispatchZone SET aID=@ID, AACTIVE=@Active, " +
"aName=@Name, aDescription=@Description, aModifier=@CurrentUserID, " +
"aModified=@Modified, aRegionID=@RegionID WHERE aID=@ID"
);
//DispatchZone fields
cm.AddInParameter("@Active",DbType.Boolean,mActive);
cm.AddLargeStringInParameter("@Description",mDescription);
cm.AddInParameter("@Name",DbType.String,mName);
cm.AddInParameter("@RegionID", DbType.Guid, mRegionID);//case 58
//Standard fields
cm.AddInParameter("@ID",DbType.Guid,this.mID);
cm.AddInParameter("@CurrentUserID",DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created",DbType.DateTime, DBUtil.ToUTC(mCreated.Date));
cm.AddInParameter("@Modified",DbType.DateTime, DBUtil.ToUTC(dtModified));
DBUtil.DB.ExecuteNonQuery(cm, tr);
//Process keywords
DBUtil.ProcessKeywords(tr,this.mID,RootObjectTypes.DispatchZone,IsNew,AyaBizUtils.Break(false,
mName,mDescription
));
MarkOld();//db is now synched with object
//Successful update so
//change modification time to match
this.mModified.Date=dtModified;
#endregion
}
#endregion update
#endregion
#region Override IsValid / IsDirty
// //Override base class version if there are child objects
//
// public override bool IsValid
// {
// get
// {
// return base.IsValid && mGoToAddress.IsValid ;
// }
// }
// public override bool IsDirty
// {
// get
// {
// return base.IsDirty || mGoToAddress.IsDirty ;
// }
// }
//
#endregion
}//end DispatchZone
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,211 @@
///////////////////////////////////////////////////////////
// DispatchZonePickList.cs
// Implementation of Class DispatchZonePickList
// CSLA type: Read only collection
// Created on: 09-Sept-2005
// Object design: John
// Coded: 09-Sept-2005
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Lightweight list of <see cref="DispatchZonePickList.DispatchZonePickListInfo"/> objects representing <see cref="DispatchZone"/> objects
///
/// Includes inactive so that they can be shown on old records
/// in a consistent format
///
/// </summary>
[Serializable]
public class DispatchZonePickList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct DispatchZonePickListInfo
{
internal Guid mID;
internal string mName;
internal bool mActive;
//internal string mNotes;
#pragma warning disable 1591
//Public properties
public Guid ID {get{return mID;}}
public string Name {get{return mName;}}
public bool Active {get{return mActive;}}
//public string Notes {get{return mNotes;}}
#pragma warning restore 1591
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(DispatchZonePickListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end DispatchZonePickListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected DispatchZonePickList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public DispatchZonePickListInfo this[int Item]
{
get
{
return (DispatchZonePickListInfo) List[Item];
}
}
/// <summary>
/// Returns DispatchZonePickListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public DispatchZonePickListInfo this[Guid ItemID]
{
get
{
foreach (DispatchZonePickListInfo child in List)
{
if(child.mID==ItemID) return child;
}
throw new ArgumentException("DispatchZonePickList: ID not found:\r\n"+ItemID.ToString());
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(DispatchZonePickListInfo obj)
{
foreach (DispatchZonePickListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all scheduleable users
/// </summary>
/// <returns>list of <see cref="DispatchZonePickList.DispatchZonePickListInfo"/> objects</returns>
public static DispatchZonePickList GetList(bool Regional)
{
return (DispatchZonePickList) DataPortal.Fetch(new Criteria(Regional));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString(DBUtil.AddRegionFilter(
//************************************************************
"SELECT aID, AACTIVE, aName FROM aDispatchZone",
"aDispatchZone",
"",
crit.Regional
//************************************************************
))
;
while(dr.Read())
{
//*******************************************
DispatchZonePickListInfo info=new DispatchZonePickListInfo();
info.mID=dr.GetGuid("aID");
info.mActive=dr.GetBoolean("AACTIVE");
info.mName=dr.GetString("aName");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if(dr!=null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public bool Regional;
public Criteria(bool _Regional )
{
Regional = _Regional;
}
}
#endregion
}//end DispatchZonePickList
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,276 @@
///////////////////////////////////////////////////////////
// DispatchZones.cs
// Implementation of Class DispatchZones
// CSLA type: Editable root collection
// Created on: 04-Nov-2004
// Object design: John
// Coded: John 04-Nov-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Editable root collection of <see cref="DispatchZone"/> objects
/// </summary>
[Serializable]
public class DispatchZones : BusinessCollectionBase
{
#region Constructor
//Private constructor prevents direction instantiation
private DispatchZones()
{
AllowSort=false;
AllowFind=true;
AllowEdit=true;
AllowNew=true;
AllowRemove=true;
}
#endregion
#region Business properties and methods
/// <summary>
/// Locale key so that generic list editor
/// UI code knows what title to give the list in a
/// grid
/// </summary>
public string LocaleKey
{
get
{
return "DispatchZone.Label.List";
}
}
/// <summary>
/// Retrieve DispatchZone by index
/// </summary>
/// <param name="Item">Index</param>
public DispatchZone this[int Item]
{
get
{
return (DispatchZone) List[Item];
}
}
/// <summary>
/// Remove DispatchZone by passing it in
/// </summary>
/// <param name="obj"></param>
public void Remove(DispatchZone obj)
{
List.Remove(obj);
}
/// <summary>
/// Remove by Guid value of ID
/// </summary>
/// <param name="ID"></param>
public void Remove(Guid ID)
{
DispatchZone delete = null;
foreach (DispatchZone child in List)
{
if (child.ID == ID)
{
delete = child;
break;
}
}
if (delete != null)
Remove(delete);
}
/// <summary>
/// Add a new DispatchZone to the collection
/// </summary>
public DispatchZone Add()
{
DispatchZone child=DispatchZone.NewItem();
List.Add(child);
return child;
}
/// <summary>
/// Add DispatchZone by passing it in
/// </summary>
/// <param name="obj"></param>
public void Add(DispatchZone obj)
{
List.Add(obj);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
protected override object OnAddNew()
{
DispatchZone child=DispatchZone.NewItem();
List.Add(child);
return child;
}
#endregion
#region Contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(DispatchZone obj)
{
foreach (DispatchZone child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in deleted collection
/// </summary>
/// <param name="obj"></param>
public bool ContainsDeleted(DispatchZone obj)
{
foreach (DispatchZone child in deletedList)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get item collection
/// </summary>
///
/// <returns></returns>
public static DispatchZones GetItems(bool Regional)
{
//in future specify criteria if filtering (e.g. filter by region)
DispatchZones col = new DispatchZones();
return (DispatchZones)DataPortal.Fetch(new Criteria(Regional));
}
#endregion
#region DAL DATA ACCESS
/// <summary>
/// Fetch children
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
//case 58
dr=DBUtil.GetReaderFromSQLString(DBUtil.AddRegionFilter(//case 58
"SELECT * FROM aDispatchZone ORDER BY ANAME ",
"aDispatchZone",
"",
crit.Regional
)
);
while(dr.Read())
{
List.Add(DispatchZone.GetItem(dr));
}
}
finally
{
if(dr!=null) dr.Close();
}
}
/// <summary>
/// Editable Root Collection Update
/// </summary>
protected override void DataPortal_Update()
{
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction tr = connection.BeginTransaction();
try
{
//update (thus deleting) any deleted child objects
foreach (DispatchZone child in deletedList)
{
child.Update(tr);
}
//Now that they are deleted remove them from memory
deletedList.Clear();
foreach (DispatchZone child in List)
{
child.Update(tr);
}
tr.Commit();
}
catch
{
tr.Rollback();
throw;//WAS: throw(ex);
}
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
//public string ObjectName;
public bool Regional;
public Criteria(bool _Regional)
{
Regional = _Regional;
}
}
#endregion
}//end DispatchZones
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Factory class for returning editable
/// root object collections by name
/// </summary>
public sealed class EditableCollectionFactory
{
/// <summary>
/// Fetch an editable collection
/// </summary>
/// <param name="Key">LocaleKey of Collection or
/// most significant portion of localeKey property of collection
/// i.e. "Priority.Label.List" LocaleKey is accepted
/// as is "Priority"
/// </param>
public static object Get(string Key)
{
if (Key.LastIndexOf(".") != -1)
{
string [] s=Key.Split('.');
Key=s[0];
}
switch (Key)
{
case "ContactTitle":
return ContactTitles.GetItems();
case "DispatchZone":
return DispatchZones.GetItems(true);
case "ClientGroup":
return ClientGroups.GetItems();
case "ClientNoteType":
return ClientNoteTypes.GetItems();
case "WorkorderItemType":
return WorkorderItemTypes.GetItems();
case "WorkorderCategory":
return WorkorderCategories.GetItems();
case "WorkorderStatus":
return WorkorderStatuses.GetItems();
case "Priority":
return Priorities.GetItems();
case "UnitOfMeasure":
return UnitOfMeasures.GetItems();
case "PartCategory":
return PartCategories.GetItems();
case "PartAssembly":
return PartAssemblies.GetItems();
case "UserSkill":
return UserSkills.GetItems();
case "UserCertification":
return UserCertifications.GetItems();
case "UnitServiceType":
return UnitServiceTypes.GetItems();
case "PartWarehouse":
return PartWarehouses.GetItems(true);
case "UnitModelCategory":
return UnitModelCategories.GetItems();
case "RateUnitChargeDescription":
return RateUnitChargeDescriptions.GetItems();
case "Task":
return Tasks.GetItems();
default:
throw new ApplicationException("EditableCollectionFactory - list: " + Key + " Not recognized");
}
}
}
}

View File

@@ -0,0 +1,194 @@
///////////////////////////////////////////////////////////
// EventWindowSet.cs
// Implementation of Class EventWindowSet
// Class type: Utility (biz object layer)
// Created on: 07-Oct-2005
// Object design: John
// Coded: John 07-Oct-2005
///////////////////////////////////////////////////////////
using System;
using System.Collections;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Manages a set of event windows for a week
/// Serializable for easy saving to database / file etc
/// Easily confirms if a given date/time is within an allowable
/// window or not
/// </summary>
[Serializable]
public class EventWindowSet
{
//Any time or day is allowed
//this allows a quicker short circuit
//comparison
private bool _AnyTime;
private bool _IsDirty;
//An array for each day of the week's events
private EventWindow[] _Events;
/// <summary>
/// An event window structure
/// this is added to an array of structures to cover a week
/// of day windows
/// </summary>
[Serializable]
public struct EventWindow
{
internal bool _AnyTimeOfDay;
internal bool _Active;
//Only time portion is used
internal DateTime _StartTime;
internal DateTime _EndTime;
public bool AnyTimeOfDay{get{return _AnyTimeOfDay;}}
public bool Active{get{return _Active;}}
public DateTime StartTime{get{return _StartTime;}}
public DateTime EndTime{get{return _EndTime;}}
}
public EventWindowSet()
{
_Events=new EventWindow[7];
System.DateTime dtStartDefault=new DateTime(1968,3,12,9,0,0);
System.DateTime dtEndDefault=new DateTime(1968,3,12,17,0,0);
//Initialize
//0==sunday 6==Saturday
for(int x=0;x<7;x++)
{
_Events[x]._StartTime=dtStartDefault;
_Events[x]._EndTime=dtEndDefault;
_Events[x]._AnyTimeOfDay=false;
_Events[x]._Active=true;
}
_AnyTime=true;
_IsDirty=false;
}
public bool IsValid
{
get
{
return true;
}
}
public bool IsDirty
{
get
{
return _IsDirty;
}
}
public bool AnyTime
{
get
{
return _AnyTime;
}
set
{
_AnyTime=value;
_IsDirty=true;
}
}
public EventWindow[] Events
{
get
{
return _Events;
}
}
/// <summary>
/// Sets an event for day indicated.
/// </summary>
/// <param name="Day">int value of DayOfWeek enum (0=Sunday...6=Saturday)</param>
/// <param name="AnyTimeOfDay">true=deliver any time of day if active</param>
/// <param name="Active">True=day is enabled for deliver, false=no delivery on this day</param>
/// <param name="StartTime">Starting time window for delivery (time only is used date is irrelevant)</param>
/// <param name="EndTime">Ending time window for delivery (time only is used date is irrelevant)</param>
public void SetEvent(int Day,
bool AnyTimeOfDay,
bool Active,
DateTime StartTime,
DateTime EndTime)
{
_IsDirty=true;
_Events[Day]._AnyTimeOfDay=AnyTimeOfDay;
_Events[Day]._Active=Active;
_Events[Day]._StartTime=StartTime;
_Events[Day]._EndTime=EndTime;
}
/// <summary>
/// Returns true if a given date/time is within
/// an event window.
///
/// False if not.
/// </summary>
/// <param name="dtValue"></param>
/// <returns></returns>
public bool InEventWindow(System.DateTime dtValue)
{
//Short circuit tests...
if(this._AnyTime) return true;
int nDay=(int)dtValue.DayOfWeek;
//Not an active day anyway?
if(!_Events[nDay]._Active) return false;
//Any time of day ok?
if(_Events[nDay]._AnyTimeOfDay) return true;
//ok, it's not a simple one, so let's compare times...
double dbCompareValue=dtValue.TimeOfDay.TotalMinutes;
//Is it in the window?
if(dbCompareValue >= _Events[nDay]._StartTime.TimeOfDay.TotalMinutes &&
dbCompareValue <= _Events[nDay]._EndTime.TimeOfDay.TotalMinutes)
return true;
//Guess not
return false;
}
//------------------------------------------------------
}// End of class
#pragma warning restore 1591
}//End of namespace

View File

@@ -0,0 +1,212 @@
///////////////////////////////////////////////////////////
// FollowUpList.cs
// Implementation of Class FollowUpList
// CSLA type: Read only collection
// Created on: 5-Mar-2015
// Object design: John
// Coded: 5-Mar-2015
///////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// List of <see cref="FollowUpList.FollowUpListInfo"/> objects representing <see cref="ScheduleMarker"/> objects
/// that are linked to a root object. A more detailed version of <see cref="FollowUpPickList"/>
/// however this object only retrieves current items, not old ones past their end date.
/// </summary>
[Serializable]
public class FollowUpList : ReadOnlyCollectionBase
{
#pragma warning disable 1591
#region Data structure
[Serializable]
public struct FollowUpListInfo
{
internal Guid mID;
internal string mName;
internal string mNotes;
internal string mTechName;
internal string mFollowObjectName;
internal TypeAndID mFollowObject;
internal int mARGB;
internal DateTime mStartDateTime;
internal DateTime mEndDateTime;
internal bool mOutDated;
public Guid ID { get { return mID; } }
public string Name { get { return mName; } }
public string Notes { get { return mNotes; } }
public string TechName { get { return mTechName; } }
public string FollowObjectName { get { return mFollowObjectName; } }
public TypeAndID FollowObject { get { return mFollowObject; } }
public int ARGB { get { return mARGB; } }
public DateTime StartDateTime { get { return mStartDateTime; } }
public DateTime EndDateTime { get { return mEndDateTime; } }
public bool OutDated { get { return mOutDated; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(FollowUpListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end FollowUpListInfo
#endregion
#region Constructor
protected FollowUpList()
{
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public FollowUpListInfo this[int Item]
{
get
{
return (FollowUpListInfo)List[Item];
}
}
/// <summary>
/// Returns FollowUpListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public FollowUpListInfo this[Guid ItemID]
{
get
{
foreach (FollowUpListInfo child in List)
{
if (child.mID == ItemID) return child;
}
throw new ArgumentException("FollowUpList: ID not found:\r\n" + ItemID.ToString());
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(FollowUpListInfo obj)
{
foreach (FollowUpListInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get current and future follow ups for id
/// </summary>
/// <returns>list of <see cref="FollowUpList.FollowUpListInfo"/> objects</returns>
public static FollowUpList GetList(Guid rootObjectID)
{
if (rootObjectID == Guid.Empty)
throw new System.ApplicationException("FollowUpList->GetList: Error rootObjectID is empty");
return (FollowUpList)DataPortal.Fetch(new Criteria(rootObjectID));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
UserPickList ulist = UserPickList.GetList(false);
DateTime dtNow = DateTime.Now;
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q =
"SELECT * FROM ASCHEDULEMARKER " +
"WHERE (AFOLLOWID = @FID) AND (ASTOPDATE > @ANOW) ORDER BY ASTARTDATE";
DBCommandWrapper cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
DateTime earliestEndDateToInclude = DBUtil.CurrentWorkingDateTime.AddDays(-15);
cm.AddInParameter("@ANOW", DbType.DateTime, DBUtil.ToUTC(earliestEndDateToInclude));
cm.AddInParameter("@FID", DbType.Guid, crit.rootObjectID);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
while (dr.Read())
{
//*******************************************
FollowUpListInfo info = new FollowUpListInfo();
info.mID = dr.GetGuid("AID");
info.mName = dr.GetString("ANAME");
info.mARGB = dr.GetInt32("AARGB");
info.mEndDateTime = DBUtil.ToLocal(dr.GetDateTime("ASTOPDATE"));
info.mOutDated = (info.mEndDateTime < dtNow);
info.mStartDateTime = DBUtil.ToLocal(dr.GetDateTime("ASTARTDATE"));
info.mFollowObject = new TypeAndID((RootObjectTypes)dr.GetInt16("AFOLLOWTYPE"), dr.GetGuid("AFOLLOWID"));
info.mFollowObjectName = NameFetcher.GetItem(info.mFollowObject).RecordName;
info.mNotes = dr.GetString("ANOTES");
Guid gTech = dr.GetGuid("ASOURCEID");
if (gTech != Guid.Empty)
info.mTechName = ulist[gTech];
else
info.mTechName = string.Empty;
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid rootObjectID;
public Criteria(Guid _rootObjectID)
{
rootObjectID = _rootObjectID;
}
}
#endregion
#pragma warning restore 1591
}//end FollowUpList
}

View File

@@ -0,0 +1,252 @@
///////////////////////////////////////////////////////////
// FollowUpListForUser.cs
// Implementation of Class FollowUpListForUser
// CSLA type: Read only collection
// Created on: 24-Sept-2015
// Object design: John
// Coded: 24-Sept-2015
///////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Internal utility class used to send a list of outstanding follow ups
/// for a user to the manager account via memo
/// </summary>
[Serializable(), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never), System.ComponentModel.Browsable(false)]
public class FollowUpListForUser : ReadOnlyCollectionBase
{
#pragma warning disable 1591
#region Data structure
[Serializable]
public struct FollowUpListForUserInfo
{
internal Guid mID;
internal string mName;
internal string mNotes;
internal string mTechName;
internal string mFollowObjectName;
internal TypeAndID mFollowObject;
internal int mARGB;
internal DateTime mStartDateTime;
internal DateTime mEndDateTime;
public Guid ID { get { return mID; } }
public string Name { get { return mName; } }
public string Notes { get { return mNotes; } }
public string TechName { get { return mTechName; } }
public string FollowObjectName { get { return mFollowObjectName; } }
public TypeAndID FollowObject { get { return mFollowObject; } }
public int ARGB { get { return mARGB; } }
public DateTime StartDateTime { get { return mStartDateTime; } }
public DateTime EndDateTime { get { return mEndDateTime; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(FollowUpListForUserInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end FollowUpListForUserInfo
#endregion
#region Constructor
protected FollowUpListForUser()
{
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public FollowUpListForUserInfo this[int Item]
{
get
{
return (FollowUpListForUserInfo)List[Item];
}
}
/// <summary>
/// Returns FollowUpListForUserInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public FollowUpListForUserInfo this[Guid ItemID]
{
get
{
foreach (FollowUpListForUserInfo child in List)
{
if (child.mID == ItemID) return child;
}
throw new ArgumentException("FollowUpListForUser: ID not found:\r\n" + ItemID.ToString());
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(FollowUpListForUserInfo obj)
{
foreach (FollowUpListForUserInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all follow ups for user specified that have a stop date and time
/// which is in the future and send them to the Manager account via memo
///
/// </summary>
/// <returns>list of <see cref="FollowUpListForUser.FollowUpListForUserInfo"/> objects</returns>
[ System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never), System.ComponentModel.Browsable(false)]
public static void SendListViaMemoToManager(Guid userID)
{
System.Text.StringBuilder sb = new StringBuilder();
if (userID == Guid.Empty)
throw new System.ApplicationException("FollowUpListForUser->GetList: Error userID is empty");
string sUserName=UserPickList.GetListOfOneSpecificUser(userID)[0].Name;
FollowUpListForUser l= (FollowUpListForUser)DataPortal.Fetch(new Criteria(userID));
if (l.Count > 0)
{
sb.AppendLine("User " + sUserName + " was set inactive and has these upcoming follow up items:");
foreach (FollowUpListForUser.FollowUpListForUserInfo i in l)
{
sb.Append(i.StartDateTime.ToString());
sb.Append(" - ");
sb.Append(i.EndDateTime.ToString());
sb.Append(": ");
sb.Append(i.FollowObjectName);
sb.Append(" \"");
sb.Append(i.Name);
sb.AppendLine("\"");
}
Memo m = Memo.NewItem();
m.FromID = User.CurrentThreadUserID;
m.ToID = User.AdministratorID;
m.Subject = "Deactivated user " + sUserName + " list of active follow ups";
m.Message = sb.ToString();
m.Save();
}
return;
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
UserPickList ulist = UserPickList.GetList(false);
//DateTime dtNow = DateTime.Now;
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
string q =
"SELECT * FROM ASCHEDULEMARKER " +
"WHERE " +
"(ASOURCEID = @FID) " +
"AND " +
"ASTOPDATE > @ANOW " +
"AND " +
"AFOLLOWID IS NOT NULL ORDER BY ASTARTDATE";
DBCommandWrapper cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
DateTime earliestEndDateToInclude = DBUtil.CurrentWorkingDateTime.AddDays(-1);
cm.AddInParameter("@ANOW", DbType.DateTime, DBUtil.ToUTC(earliestEndDateToInclude));
cm.AddInParameter("@FID", DbType.Guid, crit.userID);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
while (dr.Read())
{
//*******************************************
FollowUpListForUserInfo info = new FollowUpListForUserInfo();
info.mID = dr.GetGuid("AID");
info.mName = dr.GetString("ANAME");
info.mARGB = dr.GetInt32("AARGB");
info.mEndDateTime = DBUtil.ToLocal(dr.GetDateTime("ASTOPDATE"));
info.mStartDateTime = DBUtil.ToLocal(dr.GetDateTime("ASTARTDATE"));
info.mFollowObject = new TypeAndID((RootObjectTypes)dr.GetInt16("AFOLLOWTYPE"), dr.GetGuid("AFOLLOWID"));
info.mFollowObjectName = NameFetcher.GetItem(info.mFollowObject).RecordName;
info.mNotes = dr.GetString("ANOTES");
Guid gTech = dr.GetGuid("ASOURCEID");
if (gTech != Guid.Empty)
info.mTechName = ulist[gTech];
else
info.mTechName = string.Empty;
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid userID;
public Criteria(Guid _userID)
{
userID = _userID;
}
}
#endregion
#pragma warning restore 1591
}//end FollowUpListForUser
}

View File

@@ -0,0 +1,198 @@
///////////////////////////////////////////////////////////
// FollowUpPickList.cs
// Implementation of Class FollowUpPickList
// CSLA type: Read only collection
// Created on: 19-Nov-2007
// Object design: John
// Coded: 19-Nov-2007
///////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Lightweight list of <see cref="FollowUpPickList.FollowUpPickListInfo"/> objects representing <see cref="ScheduleMarker"/> objects
/// that are linked to a root object.
/// </summary>
[Serializable]
public class FollowUpPickList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct FollowUpPickListInfo
{
internal Guid mID;
internal string mName;
//Public properties
/// <summary>
///
/// </summary>
public Guid ID { get { return mID; } }
/// <summary>
///
/// </summary>
public string Name { get { return mName; } }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(FollowUpPickListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end FollowUpPickListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected FollowUpPickList()
{
// AllowSort=false;
// AllowFind=true;
// AllowEdit=false;
// AllowNew=false;
// AllowRemove=false;
}
#endregion
#region Business properties and methods
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public FollowUpPickListInfo this[int Item]
{
get
{
return (FollowUpPickListInfo)List[Item];
}
}
/// <summary>
/// Returns FollowUpPickListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public FollowUpPickListInfo this[Guid ItemID]
{
get
{
foreach (FollowUpPickListInfo child in List)
{
if (child.mID == ItemID) return child;
}
throw new ArgumentException("FollowUpPickList: ID not found:\r\n" + ItemID.ToString());
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(FollowUpPickListInfo obj)
{
foreach (FollowUpPickListInfo child in List)
{
if (child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all follow ups for id
/// </summary>
/// <returns>list of <see cref="FollowUpPickList.FollowUpPickListInfo"/> objects</returns>
public static FollowUpPickList GetList(Guid rootObjectID)
{
if (rootObjectID == Guid.Empty)
throw new System.ApplicationException("FollowUpPickList->GetList: Error rootObjectID is empty");
return (FollowUpPickList)DataPortal.Fetch(new Criteria(rootObjectID));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
dr = DBUtil.GetReaderFromSQLString(
//************************************************************
"SELECT AID, ANAME FROM aschedulemarker " +
"WHERE AFOLLOWID = @ID ORDER BY ANAME", crit.rootObjectID
//************************************************************
);
while (dr.Read())
{
//*******************************************
FollowUpPickListInfo info = new FollowUpPickListInfo();
info.mID = dr.GetGuid("aID");
info.mName = dr.GetString("aName");
InnerList.Add(info);
//*******************************************
}
}
finally
{
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid rootObjectID;
public Criteria(Guid _rootObjectID)
{
rootObjectID=_rootObjectID;
}
}
#endregion
}//end FollowUpPickList
}

View File

@@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////
// FormFieldDataTypes.cs
// Implementation of Class FormFieldDataTypes
// CSLA type: enumeration
// Created on: 07-Jun-2004 8:41:24 AM
// Object design: Joyce Class Incomplete
///////////////////////////////////////////////////////////
namespace GZTW.AyaNova.BLL {
/// <summary>
/// Used by <see cref="ObjectCustomField"/>.
/// When a user customizes the custom fields these are the types of
/// display and input they can select from
/// </summary>
public enum FormFieldDataTypes : int {
/// <summary>
/// A date and time entry field
/// </summary>
DateTime = 1,
/// <summary>
/// A date only entry field, time will always be 12:00:00am
/// </summary>
DateOnly = 2,
/// <summary>
/// A time only entry field, date will always be DateTime.MinValue
/// </summary>
TimeOnly = 3,
/// <summary>
/// Text entry field (text meaning anything you can type on a keyboard including numbers)
/// </summary>
Text = 4,
/// <summary>
/// Only numbers accepted
/// </summary>
Number = 5,
/// <summary>
/// Boolean checkbox field
/// </summary>
TrueFalse = 6,
/// <summary>
/// Displayed with currency symbol and treated as currency for entry purposes
/// </summary>
Currency = 7,
}//end FormFieldDataTypes
}//end namespace GZTW.AyaNova.BLL

View File

@@ -0,0 +1,64 @@
using System;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// Memo message delivery
/// </summary>
public class GenMemoMessageDelivery : GenMessageDelivery
{
public GenMemoMessageDelivery():base()
{
//
// TODO: Add constructor logic here
//
}
public override bool Deliver()
{
if(IsValid)
{
try
{
Memo m = Memo.NewItem();
m.FromID=this.AyaNovaRecipientUserID;
m.ToID=this.AyaNovaRecipientUserID;
m.Message=this.Message;
m.Subject=this.Subject;
m.Save();
this.mFailedDelivery=false;
}
catch(Exception ex)
{
this.mFailedDelivery=true;
this.mError=ex.Message;
return false;
}
}
return false;
}
public override bool IsValid
{
get
{
if(this.AyaNovaRecipientUserID==Guid.Empty || (this.Message=="" && this.Subject==""))
{
this.mFailedDelivery=true;
this.mError="Memo delivery error: One or more required fields empty, undeliverable";
return false;
}
return true;
}
}
}
#pragma warning restore 1591
}

View File

@@ -0,0 +1,60 @@
using System;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Abstract class for physically delivering
/// notification messages.
/// </summary>
public abstract class GenMessageDelivery
{
#pragma warning disable 1591
private string _toAddress="";
private string _fromAddress="";
private string _subject="";
private string _message="";
protected string mError="";
private string _host="";
private int _port = 25;//Case 515
private string _login="";
private string _password="";
private Guid _AyaNovaRecipientUserID=Guid.Empty;
private Guid _RootObjectID;
private RootObjectTypes _RootObjectType;
protected bool mFailedDelivery;
protected GenMessageDelivery()
{}
public string Host{get{return _host;}set{_host=value;}}
public int Port { get { return _port; } set { _port = value; } }//Case 515
public string ToAddress{get{return _toAddress;}set{_toAddress=value;}}
public string FromAddress{get{return _fromAddress;}set{_fromAddress=value;}}
public string Subject{get{return _subject;}set{_subject=value;}}
public string Message{get{return _message;}set{_message=value;}}
public string Error{get{return mError;}}
public string Login{get{return _login;}set{_login=value;}}
public string Password{get{return _password;}set{_password=value;}}
public Guid AyaNovaRecipientUserID{get{return _AyaNovaRecipientUserID;}set{_AyaNovaRecipientUserID=value;}}
public bool FailedDelivery{get{return mFailedDelivery;}}
public Guid RootObjectID{get{return _RootObjectID;}set{_RootObjectID=value;}}
public RootObjectTypes RootObjectType{get{return _RootObjectType;}set{_RootObjectType=value;}}
/// <summary>
/// Performs delivery,
/// returns true on sucess or false on failure
/// </summary>
/// <returns></returns>
public abstract bool Deliver();
/// <summary>
/// Indicates message contains enough
/// info for delivery and/or address
/// is in the correct format for delivery
/// </summary>
public abstract bool IsValid{get; }
#pragma warning restore 1591
}
}

View File

@@ -0,0 +1,55 @@
using System;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// PopUp message delivery
/// </summary>
public class GenPopUpMessageDelivery : GenMessageDelivery
{
#pragma warning disable 1591
public GenPopUpMessageDelivery():base()
{
//
// TODO: Add constructor logic here
//
}
public override bool Deliver()
{
if(IsValid)
{
try
{
NotifyPopUp.SendPopUp(this.RootObjectType, this.RootObjectID, this.AyaNovaRecipientUserID, AyaBizUtils.SS("", this.Subject, " ") + this.Message);
this.mFailedDelivery=false;
}
catch(Exception ex)
{
this.mFailedDelivery=true;
this.mError=ex.Message;
return false;
}
}
return false;
}
public override bool IsValid
{
get
{
if(AyaNovaRecipientUserID==Guid.Empty || (this.Message=="" && this.Subject==""))
{
this.mFailedDelivery=true;
this.mError="PopUp delivery error: One or more required fields empty, undeliverable";
return false;
}
return true;
}
}
#pragma warning restore 1591
}
}

View File

@@ -0,0 +1,71 @@
using System;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
///Triggers processing of pending notifications and preventive maintenance items
/// </summary>
public class GenProcess
{
private GenProcess()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// One stop call to process all Generator items without having to call them individually.
/// For example this will call GenProcessPM.GeneratePMWorkorders() followed by GenProcessDeliveries.DeliverNotifications()
/// etc etc.
///
/// This is the preferred method to call Generator processing in your code.
///
///
/// </summary>
/// <param name="UserName"></param>
/// <param name="Password"></param>
public static void GO(string UserName, string Password)
{
if(!Thread.CurrentPrincipal.Identity.IsAuthenticated)
AyaBizUtils.Login(UserName,Password);
if(Thread.CurrentPrincipal.Identity.IsAuthenticated)
{
GZTW.AyaNova.BLL.AyaBizUtils.mGlobalSettings=Global.GetItem();
}
else
throw new ApplicationException("Generator - Authentication error");
//Changed 02-June-2006 swapped order of these
//so that if notifications are crashing out generator
//the pm's will process when the user re-runs it while diagnosing the problem
//The thinking behind this is that pm's are less likely to crash than notifications
//and we've gone over ways of handling any crash and decided it's best to just hard
//crash without handling the exception if it get's this far so that the end user
//sees the exception dialog right away and we find out before too much time goes by
GenProcessPM.GeneratePMWorkorders();
GenProcessDeliveries.DeliverNotifications();
//case 53
GenProcessClientNotifications.DeliverNotifications();
//case 1325
//TODO: Code this
//GenProcessEmailToCSR.GenerateEMI();
//case 1448
//todo: code this
//GenProcessRequestToWorkorder.GenerateWorkorders();
}
}
}

View File

@@ -0,0 +1,157 @@
using System;
using System.Threading;
using CSLA.Security;
using Chilkat;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Process client notification list and
/// deliver appropriately
/// </summary>
public class GenProcessClientNotifications
{
private GenProcessClientNotifications()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Compile a list of all pending Client notifications and deliver them
/// </summary>
public static void DeliverNotifications()
{
//case 1904
if (!AyaBizUtils.GlobalSettings.UseNotification) return;
//case 1904 moved up here for early exit if nothing to process to avoid
//probing possibly not set up smtp server
ClientNotificationList nl = ClientNotificationList.GetList();
if (nl.Count == 0) return;
// Create a mailman object for sending email.
MailMan mailman = new MailMan();
mailman.UnlockComponent("SAyanovaMAILQ_46WCmUg3lQ1i");
// Set the SMTP variables
mailman.SmtpHost = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPHostPortionOnly;
mailman.SmtpPort = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPort;
//case 1136
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseSSL)
mailman.SmtpSsl = true;
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseTLS)
mailman.StartTLS = true;
mailman.SmtpUsername = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPAccount;
mailman.SmtpPassword = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPassword;
//case 1382
//if can't use smtp server then log and conditionally abort
if (!mailman.SmtpNoop())
{
//case 1608
NotifyDeliveryLog.LogSMTPConnectFailure("Code:" + mailman.LastSmtpStatus.ToString() + "\r\n" + mailman.LastErrorText);
//If retry then don't proceed or notifications will be deleted
if(AyaBizUtils.GlobalSettings.SMTPRetry)
return;
}
foreach (ClientNotificationList.ClientNotificationListInfo info in nl)
{
try
{
//reload email from stored mime
ClientNotifyEvent n = ClientNotifyEvent.GetItem(info.mID);
string[] sMessageFields = n.GetContentAsString.Split('|');
int nFieldCount = sMessageFields.GetLength(0);
if (nFieldCount < 5 || sMessageFields[0] != "CLIENTNOTIFYEVENT")
{
NotifyDeliveryLog.LogClientDelivery(n.ClientID, false, "Invalid event data: " + n.GetContentAsString);
ClientNotifyEvent.DeleteItem(n.ID);
continue;
}
Chilkat.Email email = new Chilkat.Email();
//email.SetFromMimeText(n.GetContentAsString);
email.Mailer = "AyaNova service management software licensed to " + AyaBizUtils.REGTO;
email.Body = sMessageFields[1];
email.Subject = sMessageFields[2];
//case 1601
string ToAddress = sMessageFields[3];
if (ToAddress.Contains(";")) ToAddress = ToAddress.Replace(";", ",");
if (ToAddress.Contains(","))
email.AddMultipleTo(ToAddress);
else
email.AddTo("", ToAddress);
email.From = sMessageFields[4];
if (nFieldCount > 5)
{
string sWOID = sMessageFields[5];
if (!string.IsNullOrEmpty(sWOID))
{
Guid woid = new Guid(sWOID);
//attach a workorder
Report r = Report.GetItem(new Guid(sMessageFields[6]));
object o = null;
if (r.ReportKey == "WorkorderServiceList")
o = WorkorderServiceList.GetListForSingleItem(woid);
else if (r.ReportKey == "WorkorderServiceDetailed")
o = WorkorderServiceDetailedReportData.GetItem(woid);
else if (r.ReportKey == "WorkorderQuoteList")
o = WorkorderQuoteList.GetListForSingleItem(woid);
else if (r.ReportKey == "WorkorderQuoteDetailed")
o = WorkorderQuoteDetailedReportData.GetItem(woid);
//ms.toarray = byte array from memory stream
email.AddDataAttachment(DateTime.Now.ToString("yyyy_MM_dd_HH_mm") + ".pdf", ReportGenerator.GetReportAsPDF(r, o).ToArray());
}
}
// Send mail.
bool success;
success = mailman.SendEmail(email);
if (success)
{
NotifyDeliveryLog.LogClientDelivery(n.ClientID,true,"");
ClientNotifyEvent.DeleteItem(n.ID);
}
else
{
NotifyDeliveryLog.LogClientDelivery(n.ClientID,false, mailman.LastErrorText);
//Added this late, I'm thinking if it fails they will get the log and
//be able to fix the problem easily but if it stays in the queue there will be no way
//for them to delete it
//A better way would be to delete after x failed deliveries
ClientNotifyEvent.DeleteItem(n.ID);
}
}
catch
{
}
}
}
//=================================
}
}

View File

@@ -0,0 +1,190 @@
using System;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Process a notification list and
/// deliver appropriately
/// </summary>
public class GenProcessDeliveries
{
private GenProcessDeliveries()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Retrieve verifies and delivers all active user notifications
/// </summary>
public static void DeliverNotifications()
{
//case 1904
if (!AyaBizUtils.GlobalSettings.UseNotification) return;
NotificationList nl=NotificationList.GetList();
//case 1904 - early exit, why not?
if (nl.Count == 0) return;
#region case 1382 smtp probing
bool bSMTPCanDeliver = false;
bool bHasSMTPDeliveriesToMake = false;
//check if any smtp style deliveries
//if so do a noop on the smtp server
//if fails then skip all smtp style items
foreach (NotificationList.NotificationListInfo info in nl)
{
if (info.DeliveryMethod == NotifyDeliveryMethods.SMS || info.DeliveryMethod == NotifyDeliveryMethods.SMTP)
{
bHasSMTPDeliveriesToMake = true;
break;
}
}
if (bHasSMTPDeliveriesToMake)
{
//probe the mail server
bSMTPCanDeliver = GenSMTPMessageDelivery.ProbeSMTPServer;
if (!bSMTPCanDeliver)
{
//If retry is false then allow the delivery attempt and subsequent removal
//as that's the users choice
if (!AyaBizUtils.GlobalSettings.SMTPRetry)
bSMTPCanDeliver = true;
}
}
#endregion case 1382
foreach (NotificationList.NotificationListInfo info in nl)
{
switch(info.DeliveryMethod)
{
case NotifyDeliveryMethods.SMS:
{
//case 1382
if (!bSMTPCanDeliver) continue;
GenSMSMessageDelivery sms=new GenSMSMessageDelivery();
sms.FromAddress=GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPFrom;
//Case 515
sms.Host = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPHostPortionOnly;
sms.Port = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPort;
sms.Login=GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPAccount;
sms.Password=GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPassword;
sms.Message=info.Message;
sms.Subject="";//info.Subject;
sms.ToAddress=info.Address;
sms.Deliver();
LogAndRemoveEvent(info,sms.FailedDelivery,sms.Error);
break;
}
case NotifyDeliveryMethods.SMTP:
{
//case 1382
if (!bSMTPCanDeliver) continue;
GenSMTPMessageDelivery smtp=new GenSMTPMessageDelivery();
smtp.FromAddress=GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPFrom;
//Case 515
smtp.Host = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPHostPortionOnly;
smtp.Port = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPort;
smtp.Login=GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPAccount;
smtp.Password=GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPassword;
smtp.Message=info.Message;
smtp.Subject=info.Subject;
smtp.ToAddress=info.Address;
smtp.RootObjectID=info.RootObjectID;
smtp.RootObjectType=info.RootObjectType;
smtp.Deliver();
LogAndRemoveEvent(info,smtp.FailedDelivery,smtp.Error);
break;
}
case NotifyDeliveryMethods.Memo:
{
GenMemoMessageDelivery m = new GenMemoMessageDelivery();
m.AyaNovaRecipientUserID=info.DeliverToUserID;
m.Message=info.Message;
m.Subject=info.Subject;
m.RootObjectID=info.RootObjectID;
m.RootObjectType=info.RootObjectType;
m.Deliver();
LogAndRemoveEvent(info,m.FailedDelivery,m.Error);
break;
}
case NotifyDeliveryMethods.PopUp:
{
GenPopUpMessageDelivery p = new GenPopUpMessageDelivery();
p.AyaNovaRecipientUserID=info.DeliverToUserID;
p.Message=info.Message;
p.Subject="";//info.Subject;
p.RootObjectID=info.RootObjectID;
p.RootObjectType=info.RootObjectType;
p.Deliver();
LogAndRemoveEvent(info,p.FailedDelivery,p.Error);
break;
}
}//End of switch
//do nothing if not one of the above delivery formats
}
}
/// <summary>
/// Log and remove
/// </summary>
/// <param name="info"></param>
/// <param name="failed"></param>
/// <param name="error"></param>
private static void LogAndRemoveEvent(NotificationList.NotificationListInfo info, bool failed, string error)
{
if(!failed)
{
//Remove the event
NotifyEvent.RemoveDeliveredEvent(info.NotifyEventID);
}
//Log the delivery
NotifyDeliveryLog.LogDelivery(info.RootObjectType, info.RootObjectID, info.EventType, info.DeliverToUserID, !failed, info.GuidValue, info.DeliveryMethod, error, DBUtil.CurrentWorkingDateTime);
//case 1096
//Remove the event
NotifyEvent.RemoveDeliveredEvent(info.NotifyEventID);
}
//=================================
}
}

View File

@@ -0,0 +1,31 @@
using System;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Summary description for GenProcessPM.
/// </summary>
public class GenProcessPM
{
private GenProcessPM()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Loop through PM workorders ready for generation and
/// Process them / advance dates
/// </summary>
public static void GeneratePMWorkorders()
{
WorkorderPMReadyForServiceList l=WorkorderPMReadyForServiceList.GetList();
foreach(WorkorderPMReadyForServiceList.WorkorderPMReadyForServiceListInfo i in l)
{
Workorder.NewServiceWorkorderFromPM(i.PMWorkorderID);
}
}
}
}

View File

@@ -0,0 +1,96 @@
using System;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// SMS message delivery
/// </summary>
public class GenSMSMessageDelivery : GenMessageDelivery
{
public GenSMSMessageDelivery():base()
{
//
// TODO: Add constructor logic here
//
}
public override bool Deliver()
{
if(IsValid)
{
//attempt delivery
// Create a mailman object for sending email.
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("SAyanovaMAILQ_46WCmUg3lQ1i");
// Set the SMTP server hostname.
mailman.SmtpHost = Host;//"mail.ayanova.com";
//Case 515
mailman.SmtpPort = Port;
//case 1136
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseSSL)
mailman.SmtpSsl = true;
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseTLS)
mailman.StartTLS = true;
mailman.SmtpUsername=Login;
mailman.SmtpPassword=Password;
// Create a simple email.
Chilkat.Email email = new Chilkat.Email();
email.Body = Message;
email.Subject = Subject;
//case 1601
if (ToAddress.Contains(";")) ToAddress = ToAddress.Replace(";", ",");
if (ToAddress.Contains(","))
email.AddMultipleTo(ToAddress);
else
email.AddTo("",ToAddress);
email.From = FromAddress;//Case 452
// Send mail.
bool success;
success = mailman.SendEmail(email);
if (success)
{
this.mFailedDelivery=false;
return true;
}
else
{
this.mFailedDelivery=true;
this.mError=mailman.LastErrorText;
return false;
}
}
return false;
}
public override bool IsValid
{
get
{
if(this.Login=="" || this.Password=="" || this.Host=="" || this.ToAddress=="" || this.FromAddress=="" || (this.Message=="" && this.Subject==""))
{
this.mFailedDelivery=true;
this.mError="SMS delivery error: One or more required fields empty, undeliverable";
return false;
}
return true;
}
}
}
#pragma warning restore 1591
}

View File

@@ -0,0 +1,131 @@
using System;
namespace GZTW.AyaNova.BLL
{
#pragma warning disable 1591
/// <summary>
/// SMTP message delivery
/// </summary>
public class GenSMTPMessageDelivery : GenMessageDelivery
{
public GenSMTPMessageDelivery():base()
{
//
// TODO: Add constructor logic here
//
}
public override bool Deliver()
{
if(IsValid)
{
//attempt delivery
// Create a mailman object for sending email.
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("SAyanovaMAILQ_46WCmUg3lQ1i");
// Set the SMTP server hostname.
mailman.SmtpHost = Host;//"mail.ayanova.com";
//Case 515
mailman.SmtpPort = Port;
//case 1136
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseSSL)
mailman.SmtpSsl = true;
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseTLS)
mailman.StartTLS = true;
mailman.SmtpUsername=Login;
mailman.SmtpPassword=Password;
// Create a simple email.
Chilkat.Email email = new Chilkat.Email();
email.Body = Message;
email.Subject = Subject;
//case 1601
if (ToAddress.Contains(";")) ToAddress = ToAddress.Replace(";", ",");
if (ToAddress.Contains(","))
email.AddMultipleTo(ToAddress);
else
email.AddTo("",ToAddress);
email.From = FromAddress;
// Send mail.
bool success;
success = mailman.SendEmail(email);
if (success)
{
this.mFailedDelivery=false;
return true;
}
else
{
this.mFailedDelivery=true;
this.mError=mailman.LastErrorText;
return false;
}
}
return false;
}
public override bool IsValid
{
get
{
if(this.Login=="" || this.Password=="" || this.Host=="" || this.ToAddress=="" || this.FromAddress=="" || (this.Message=="" && this.Subject==""))
{
this.mFailedDelivery=true;
this.mError="SMTP delivery error: One or more required fields empty, undeliverable";
return false;
}
return true;
}
}
/// <summary>
/// Confirm SMTP server can be connected to as per
/// global settings for notification
/// </summary>
/// <returns></returns>
public static bool ProbeSMTPServer
{
get
{
//case 1382
// Create a mailman object for sending email.
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("SAyanovaMAILQ_46WCmUg3lQ1i");
// Set the SMTP server hostname.
mailman.SmtpHost = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPHostPortionOnly;
//Case 515
mailman.SmtpPort = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPort;
//case 1136
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseSSL)
mailman.SmtpSsl = true;
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseTLS)
mailman.StartTLS = true;
mailman.SmtpUsername = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPAccount;
mailman.SmtpPassword = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPassword;
//case 1608
bool bCanDeliver = mailman.SmtpNoop();
if (!bCanDeliver)
{
NotifyDeliveryLog.LogSMTPConnectFailure("Code:" + mailman.LastSmtpStatus.ToString() + "\r\n" + mailman.LastErrorText);
}
return bCanDeliver;
}
}
}
#pragma warning restore 1591
}

View File

@@ -0,0 +1,225 @@
///////////////////////////////////////////////////////////
// GenericNVList.cs
// Implementation of Class GenericNVList
// CSLA type: Name-Value Lists
// Created on: 19 August 2004
// Object design: John
// Coded: John 19 August 2004
///////////////////////////////////////////////////////////
using System;
using CSLA.Data;
using System.Runtime.Serialization;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Generic name / value list
/// </summary>
[Serializable, Browsable(false)]
public class GenericNVList : NameValueList
{//NVCHANGED
#region Constructors
//Prevent direct creation
private GenericNVList() {}
//Required because the base class (NameObjectCollectionBase) implements ISerializable
private GenericNVList(SerializationInfo info, StreamingContext context) : base(info, context) {}
#endregion
#region Static methods
/// <summary>
/// Get GenericNVList object
/// Retrieves a name value list from db
/// </summary>
/// <example>
/// This code shows a typical usage of the generic name value list
/// <code>
/// GenericNVList ls=GenericNVList.GetList("aWorkorderStatus","aID","aName",true,false);
/// foreach(DictionaryEntry d in ls.BindableList)
/// {
/// Guid gWorkorderStatusID=new Guid(d.Key.ToString());
/// string sWorkorderStatusName=d.Value.ToString();
/// //... populate a list box or other processing
/// }
/// </code>
/// </example>
public static GenericNVList GetList(string ObjectName,string IDColumn,
string ValueColumn, bool ValueIsGuid, bool ActiveOnly, bool Regional)//case 58
{
string sTempObjectName=ObjectName;
switch(ObjectName)
{
case "aVendor:Manufacturer":
sTempObjectName="Vendor";
break;
case "aVendor:Shipper":
sTempObjectName="Vendor";
break;
case "aVendor:SubContractor":
sTempObjectName="Vendor";
break;
case "aVendor:ThirdPartyRepair":
sTempObjectName="Vendor";
break;
case "aVendor:Wholesaler":
sTempObjectName="Vendor";
break;
}
//if(AyaBizUtils.Right("Object."+AyaBizUtils.ToObjectName(sTempObjectName))>(int)SecurityLevelTypes.NoAccess)
return (GenericNVList) DataPortal.Fetch(new Criteria(ObjectName,IDColumn, ValueColumn,ValueIsGuid,ActiveOnly, Regional));
// else
// throw new System.Security.SecurityException(
// string.Format(
// LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
// LocalizedTextTable.GetLocalizedTextDirect("O." + AyaBizUtils.ToObjectName(sTempObjectName))));
//
}
private static string RegionAndActiveClause(bool ActiveOnly, string sTable, bool bRegional)
{
string q = "";
if(ActiveOnly)
q = " WHERE AACTIVE=1";
if (bRegional)
q = DBUtil.AddRegionFilter(q, sTable, "");
return q;
}
#endregion
#region DAL DATA ACCESS
/// <summary>
/// Fetch name value list
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
Criteria crit = (Criteria)Criteria;
switch(crit.TableName)
{
case "aVendor:Manufacturer":
this.SQLFetchG(DBUtil.DB,"SELECT aID, aName FROM aVendor WHERE aVendorType=" + ((int)VendorTypes.Manufacturer).ToString()+ " AND AACTIVE=1");
break;
case "aVendor:Shipper":
this.SQLFetchG(DBUtil.DB,"SELECT aID, aName FROM aVendor WHERE aVendorType=" + ((int)VendorTypes.Shipper).ToString()+ " AND AACTIVE=1");
break;
case "aVendor:SubContractor":
this.SQLFetchG(DBUtil.DB,"SELECT aID, aName FROM aVendor WHERE aVendorType=" + ((int)VendorTypes.SubContractor).ToString()+ " AND AACTIVE=1");
break;
case "aVendor:ThirdPartyRepair":
this.SQLFetchG(DBUtil.DB,"SELECT aID, aName FROM aVendor WHERE aVendorType=" + ((int)VendorTypes.ThirdPartyRepair).ToString()+ " AND AACTIVE=1");
break;
case "aVendor:Wholesaler":
this.SQLFetchG(DBUtil.DB,"SELECT aID, aName FROM aVendor WHERE aVendorType=" + ((int)VendorTypes.Wholesaler).ToString()+ " AND AACTIVE=1");
break;
case "aClient":
SQLFetchG(DBUtil.DB, "SELECT aID, aName FROM aClient " + RegionAndActiveClause(crit.ActiveOnly,"aClient", crit.Regional) );
break;
case "aUser":
SQLFetchG(DBUtil.DB, "SELECT aID, aName FROM aUser " + RegionAndActiveClause(crit.ActiveOnly, "aUser", crit.Regional));
break;
case "aHeadOffice":
SQLFetchG(DBUtil.DB, "SELECT aID, aName FROM aHeadOffice " + RegionAndActiveClause(crit.ActiveOnly, "aHeadOffice", crit.Regional));
break;
case "aContract":
SQLFetchG(DBUtil.DB, "SELECT aID, aName FROM aContract " + RegionAndActiveClause(crit.ActiveOnly, "aContract", crit.Regional));
break;
case "aRegion":
string q = "";
if (crit.Regional)
{
q=q+ (string)(
(User.CurrentUserRegionID != Region.DefaultRegionID) ?
" WHERE (aID IN ('{8236E8D1-CAB1-4797-9C34-93861954AE6A}','{" + User.CurrentUserRegionID.ToString().ToUpperInvariant() + "}')) "
: ""
);
}
if (crit.ActiveOnly)
{
if (q == "")
q = " WHERE AACTIVE=1";
else
q = q + " AND AACTIVE=1";
}
SQLFetchG(DBUtil.DB,"SELECT aID, aName FROM aRegion " + q );
break;
/*
* *Dispatch Zones
*Loan Items
*Projects
*Rates
*Report Templates
*Templates - workorders / quotes / pm
*Warehouses
* */
default:
{
//REgional ones:
if(crit.ValueIsGuid)
{
if(crit.ActiveOnly)
this.SimpleFetchGActiveOnly(DBUtil.DB,crit.TableName,crit.ValueColumn,crit.NameColumn);
else
this.SimpleFetchG(DBUtil.DB,crit.TableName,crit.ValueColumn ,crit.NameColumn);
}
else
this.SimpleFetch(DBUtil.DB,crit.TableName,crit.ValueColumn ,crit.NameColumn);
break;
}
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public string TableName;
public string NameColumn;
public string ValueColumn;
public bool ValueIsGuid;
public bool ActiveOnly;
public bool Regional;//case 58
public Criteria( string _TableName, string _NameColumn, string _ValueColumn, bool _ValueIsGuid, bool _ActiveOnly, bool _Regional)
{
if(_TableName=="User")
_TableName="aUser";
TableName=AyaBizUtils.ToDBName(_TableName);
NameColumn=AyaBizUtils.ToDBName(_NameColumn);
ValueColumn=AyaBizUtils.ToDBName(_ValueColumn);
ValueIsGuid=_ValueIsGuid;
ActiveOnly=_ActiveOnly;
Regional = _Regional;
}
}
#endregion
}//end GenericNVList
}//end namespace GZTW.AyaNova.BLL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
//using System;
//namespace GZTW.AyaNova.BLL
//{
// /// <summary>
// /// Object item representing a cell of data
// /// that is not directly read from a corresponding database
// /// record column.
// ///
// /// Used to redirect sorting and filtering in the grid
// /// to another sql field
// ///
// /// </summary>
// [Serializable]
// public class GridCalculatedCellItem
// {
// private object mValue;
// private string mSQLValueFieldName;
// public GridCalculatedCellItem(object Value)
// {
// mValue=Value;
// mSQLValueFieldName=null;
// }
// public GridCalculatedCellItem(object Value,string SQLValueFieldName)
// {
// mValue=Value;
// mSQLValueFieldName=SQLValueFieldName;
// }
// public override int GetHashCode()
// {
// return this.mValue.GetHashCode();
// }
//// public override bool Equals(object obj)
//// {
//// GridCalculatedCellItem i=(GridCalculatedCellItem)obj;
//// return(i.Value.Equals(this.mValue));
//// }
//// //necessary to give the grid something to display
//// public override string ToString()
//// {
//// return mValue.ToString();
//// }
// public bool bValue
// {
// get
// {
// return (bool)mValue;
// }
// }
// public object Value
// {
// get
// {
// return mValue;
// }
// }
// //The sql name of the value column to filter/sort on
// public string SQLValueFieldName
// {
// get
// {
// return mSQLValueFieldName;
// }
// }
// }
//}

View File

@@ -0,0 +1,702 @@
///////////////////////////////////////////////////////////
// GridFilter.cs
// Implementation of Class GridFilter
// CSLA type: Editable Root
// Created on: 25-may-2006
// Object design: John
// Coded: John 25-may-2006
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
namespace GZTW.AyaNova.BLL
{
/// <summary>
///Filter for restricting results in main grid lists
///Created by user and shared amongst all users
/// </summary>
[Serializable]
public class GridFilter : BusinessBase
{
#region Attributes
private bool bReadOnly;
private Guid mID;
private SmartDate mCreated;
private SmartDate mModified;
private Guid mCreator;
private Guid mModifier;
private string mName = "";
private string mGridKey = null;
private string mFilterXML = null;
//Security
private Guid mOnlyUserID = Guid.Empty;
private Guid mOnlySecurityGroupID = Guid.Empty;
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private GridFilter()
{
//New ID
mID = Guid.NewGuid();
mCreated = new SmartDate(DBUtil.CurrentWorkingDateTime);
mModified = new SmartDate();
mCreator = Guid.Empty;
mModifier = Guid.Empty;
//pre-break the rules
this.GridKey = "";
Name = "";
FilterXML = "";
}
#endregion
#region Business properties
/// <summary>
/// Get internal id number Read only property because it's set internally, not
/// externally
/// </summary>
public Guid ID
{
get
{
return mID;
}
}
/// <summary>
/// Get created date
///
///
/// </summary>
public string Created
{
get
{
return mCreated.ToString();
}
}
/// <summary>
/// Get modified date
///
///
/// </summary>
public string Modified
{
get
{
return mModified.ToString();
}
}
/// <summary>
/// Get user record ID of person who created this record
///
///
/// </summary>
public Guid Creator
{
get
{
return mCreator;
}
}
/// <summary>
/// Get user ID of person who modified this record
///
///
/// </summary>
public Guid Modifier
{
get
{
return mModifier;
}
}
/// <summary>
/// Set/get Name of item
///
/// </summary>
public string Name
{
get
{
return mName;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mName != value)
{
mName = value;
BrokenRules.Assert("NameRequired", "Error.Object.RequiredFieldEmpty,GridFilter.Label.Name", "Name", value.Length == 0);
BrokenRules.Assert("NameLength",
"Error.Object.FieldLengthExceeded255,GridFilter.Label.Name", "Name", value.Length > 255);
MarkDirty();
}
}
}
}
/// <summary>
/// Set/get GridKey filter applies to
/// This is the equivalent of the ReportKey specified
/// in the report key property of the read only collections
///
/// </summary>
public string GridKey
{
get
{
return mGridKey;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mGridKey != value)
{
mGridKey = value;
BrokenRules.Assert("GridKeyRequired", "Error.Object.RequiredFieldEmpty,GridFilter.Label.GridKey", "GridKey", value.Length == 0);
BrokenRules.Assert("GridKeyLength",
"Error.Object.FieldLengthExceeded255,GridFilter.Label.GridKey", "GridKey", value.Length > 255);
MarkDirty();
}
}
}
}
/// <summary>
/// Set/get FilterXML of filter
///
/// This is generated at the UI level and is not settable manually
///
/// </summary>
public string FilterXML
{
get
{
return mFilterXML;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mFilterXML != value)
{
mFilterXML = UIUserGridLastView.ScrubOutContactFieldsFromViewXML(value, mGridKey);
BrokenRules.Assert("FilterXMLRequired", "Error.Object.RequiredFieldEmpty,GridFilter.Label.FilterXML", "FilterXML", value.Length == 0);
MarkDirty();
}
}
}
}
/// <summary>
/// If not empty restricts displaying this
/// filter to the matching user id
///
/// This value overrides the security group ID property
///
/// </summary>
public Guid OnlyUserID
{
get
{
return mOnlyUserID;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mOnlyUserID != value)
{
mOnlyUserID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// If not empty restricts displaying this
/// filter to users who are members of the
/// matching security group
///
/// This value is ignored if the OnlyUserID
/// property is set to non empty
///
/// </summary>
public Guid OnlySecurityGroupID
{
get
{
return mOnlySecurityGroupID;
}
set
{
if (bReadOnly)
ThrowSetError();
else
{
if (mOnlySecurityGroupID != value)
{
mOnlySecurityGroupID = value;
MarkDirty();
}
}
}
}
/// <summary>
/// Throw an error when a read only user
/// tries to set a property
/// (this should normally never be called unless someone is using the developer api since the UI
/// should prevent it from happening initially)
/// </summary>
private void ThrowSetError()
{
throw new System.Security.SecurityException
(
string.Format
(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToChange"),
LocalizedTextTable.GetLocalizedTextDirect("O.GridFilter")
)
);
}
#endregion
#region System.Object overrides
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return "GridFilter" + mID + " - " + mName;
}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(Object obj)
{
if (obj == null || GetType() != obj.GetType()) return false;
GridFilter c = (GridFilter)obj;
return (c.ID.Equals(this.ID));
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return ("GridFilter" + mID.ToString()).GetHashCode();
}
#endregion
#region Static methods
/// <summary>
/// Used to identify an item in the ui combo box list of filters
/// that represents that no filter has been selected and
/// no filtering is applied. Also allows user to select to defilter
/// grid quickly and easily
/// </summary>
public static Guid NoFilterID
{
get
{
return new Guid("{096EDE37-4651-4d0a-97FD-65FA9EE26476}");
}
}
/// <summary>
/// Used to identify an item in the UI combo box list of filters
/// that represents that a filter is unsaved due to user modification
/// </summary>
public static Guid UnsavedFilterID
{
get
{
return new Guid("{8B32724D-F024-4648-998B-357A8A0B43DC}");
}
}
/// <summary>
/// Get new object
/// </summary>
/// <returns></returns>
public static GridFilter NewItem()
{
return new GridFilter();
}
/// <summary>
/// Fetch Grid filter requested
///
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public static GridFilter GetItem(Guid ID)
{
if (AyaBizUtils.Right("Object.GridFilter") > (int)SecurityLevelTypes.NoAccess)
return (GridFilter)DataPortal.Fetch(new Criteria(ID));
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToRetrieve"),
LocalizedTextTable.GetLocalizedTextDirect("O.GridFilter")));
}
/// <summary>
/// Delete Filter
/// </summary>
/// <param name="_ID">Region GUID</param>
public static void DeleteItem(Guid _ID)
{
if (AyaBizUtils.Right("Object.GridFilter") > (int)SecurityLevelTypes.ReadWrite)
DataPortal.Delete(new Criteria(_ID));
else
throw new System.Security.SecurityException(
string.Format(
LocalizedTextTable.GetLocalizedTextDirect("Error.Security.NotAuthorizedToDelete"),
LocalizedTextTable.GetLocalizedTextDirect("O.GridFilter")));
}
#endregion
#region DAL DATA ACCESS
#region Fetch
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
//set to false to load items initially
bReadOnly = false;
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
try
{
DBCommandWrapper dbCommandWrapper = DBUtil.DB.GetSqlStringCommandWrapper(
"SELECT * from aGridFilter WHERE " +
"(aGridFilter.aID=@ID)"
);
dbCommandWrapper.AddInParameter("@ID", DbType.Guid, crit.ID);
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(dbCommandWrapper));
if (dr.Read())
{
//Standard fields
mID = crit.ID;
mCreated = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
mModified = DBUtil.ToLocal(dr.GetSmartDate("aModified"));
mCreator = dr.GetGuid("aCreator");
mModifier = dr.GetGuid("aModifier");
//GridFilter fields
//use props to unbreak rules
Name = dr.GetString("aName");
GridKey = dr.GetString("aGridKey");
FilterXML = dr.GetString("aFilterXML");
mOnlyUserID = dr.GetGuid("aOnlyUserID");
mOnlySecurityGroupID = dr.GetGuid("aOnlySecurityGroupID");
}
}
finally
{
if (dr != null) dr.Close();
}
MarkOld();
//Get access rights level
bReadOnly = AyaBizUtils.Right("Object.GridFilter") < (int)SecurityLevelTypes.ReadWrite;
}
#endregion fetch
#region Update
/// <summary>
/// Called by DataPortal to delete/add/update data into the database
/// </summary>
protected override void DataPortal_Update()
{
// If not a new record, check if record was modified
//by another user since original retrieval:
if (!IsNew)
DBUtil.CheckSafeToUpdate(this.mModified.Date, this.mID, "aGridFilter");
#region Delete
if (IsDeleted)
{
if (!IsNew)
{
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL(
"DELETE FROM aGridFilter WHERE aID=@ID");
cmDelete.AddInParameter("@ID", DbType.Guid, this.mID);
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cmDelete, transaction);
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
}
//-----------------------------
}
MarkNew();
return;
}
#endregion
#region Add / Update
//get modification time temporarily, if update succeeds then
//set to this time
System.DateTime dtModified = DBUtil.CurrentWorkingDateTime;
DBCommandWrapper cm = null;
if (IsNew)//Add or update?
cm = DBUtil.GetCommandFromSQL(
"INSERT INTO aGridFilter (aID, aGridKey, aName, " +
"aFilterXML, aOnlyUserID, aOnlySecurityGroupID, " +
"aCreated,aModified,aCreator,aModifier) VALUES (@ID,@GridKey,@Name, " +
"@FilterXML,@OnlyUserID,@OnlySecurityGroupID, " +
"@Created,@Modified,@CurrentUserID, " +
"@CurrentUserID)"
);
else
cm = DBUtil.GetCommandFromSQL(
"UPDATE aGridFilter SET aGridKey=@GridKey, " +
"aName=@Name, aFilterXML=@FilterXML, aOnlyUserID=@OnlyUserID, " +
"aOnlySecurityGroupID=@OnlySecurityGroupID, " +
"aModifier=@CurrentUserID, " +
"aModified=@Modified WHERE aGridFilter.aID=@ID "
);
cm.AddInParameter("@ID", DbType.Guid, this.mID);
cm.AddInParameter("@GridKey", DbType.String, this.mGridKey);
cm.AddInParameter("@Name", DbType.String, this.mName);
cm.AddInParameter("@FilterXML", DbType.String, mFilterXML);
cm.AddInParameter("@OnlyUserID", DbType.Guid, mOnlyUserID);
cm.AddInParameter("@OnlySecurityGroupID", DbType.Guid, mOnlySecurityGroupID);
//Standard fields
cm.AddInParameter("@CurrentUserID", DbType.Guid, CurrentUserID);
cm.AddInParameter("@Created", DbType.DateTime, DBUtil.ToUTC(mCreated).DBValue);
cm.AddInParameter("@Modified", DbType.DateTime, DBUtil.ToUTC(dtModified));
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cm, transaction);
MarkOld();//db is now synched with object
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
//Successful update so
//change modification time to match
this.mModified.Date = dtModified;
}
#endregion
}
#endregion update
#region Delete
/// <summary>
/// Remove a filter record from the database
/// </summary>
/// <param name="Criteria"></param>
protected override void DataPortal_Delete(object Criteria)
{
Criteria crit = (Criteria)Criteria;
//Delete object and child objects
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aGridFilter WHERE aID = @ID;");
cmDelete.AddInParameter("@ID", DbType.Guid, crit.ID);
using (IDbConnection connection = DBUtil.DB.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try
{
DBUtil.DB.ExecuteNonQuery(cmDelete, transaction);
// Commit the transaction
transaction.Commit();
}
catch
{
// Rollback transaction
transaction.Rollback();
throw;
}
finally
{
connection.Close();
}
}
}
#endregion delete
#endregion
#region Override IsValid / IsDirty
//Override base class version if there are child objects
/*
public override bool IsValid
{
get
{
return base.IsValid && ChildItem.IsValid;
}
}
public override bool IsDirty
{
get
{
return base.IsDirty || ChildItem.IsDirty;
}
}
*/
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID = _ID;
}
}
#endregion
}//end GridFilter
}//end namespace GZTW.AyaNova.BLL

Some files were not shown because too many files have changed in this diff Show More