3893 lines
149 KiB
C#
3893 lines
149 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.HtmlControls;
|
|
using GZTW.AyaNova.BLL;
|
|
using CSLA.Security;
|
|
using System.Threading;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using System.Collections.Generic;
|
|
using Telerik.Web.UI;
|
|
using FirebirdSql.Data.FirebirdClient;
|
|
using System.Globalization;
|
|
|
|
|
|
/// <summary>
|
|
/// Summary description for Util
|
|
/// </summary>
|
|
public class Util
|
|
{
|
|
public Util()
|
|
{
|
|
//
|
|
// TODO: Add constructor logic here
|
|
//
|
|
|
|
}
|
|
|
|
public static string Version { get { return "7.5.0"; } }
|
|
public static int HotfixVersion { get { return 3; } }
|
|
public static Guid WBIIntegrationID { get { return new Guid("{6946040C-1B50-4eab-BE08-A0E93DB7449F}"); } }
|
|
|
|
#region "global" vars
|
|
/// <summary>
|
|
/// Get the current user record
|
|
/// </summary>
|
|
public static User CurrentUser
|
|
{
|
|
get
|
|
{
|
|
|
|
return User.GetItem((((BusinessPrincipal)Thread.CurrentPrincipal).ID));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the current user record
|
|
/// </summary>
|
|
public static Guid CurrentUserID
|
|
{
|
|
get
|
|
{
|
|
|
|
return (((BusinessPrincipal)Thread.CurrentPrincipal).ID);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Global settings (cached)
|
|
/// </summary>
|
|
public static Global GlobalSettings
|
|
{
|
|
get
|
|
{
|
|
if (mglobal != null)
|
|
return mglobal;
|
|
|
|
if (HttpContext.Current.Cache["GlobalSettings"] == null)
|
|
{
|
|
HttpContext.Current.Cache.Insert("GlobalSettings", Global.GetItem(),
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
|
|
}
|
|
|
|
mglobal = (Global)HttpContext.Current.Cache["GlobalSettings"];
|
|
return mglobal;
|
|
}
|
|
}
|
|
private static Global mglobal = null;
|
|
|
|
|
|
public static WBIIntegrationData IntegrationData
|
|
{
|
|
get
|
|
{
|
|
return (WBIIntegrationData)WBIIntegration.AIObject;
|
|
}
|
|
|
|
}
|
|
|
|
public static void SaveIntegrationData()
|
|
{
|
|
//trigger is dirty
|
|
WBIIntegration.SyncCheckPoint = DBUtil.CurrentWorkingDateTime.ToString();//case 1163
|
|
mWBIIntegration = (Integration) WBIIntegration.Save();
|
|
|
|
// HttpContext.Current.Cache.Remove("IntegrationData");
|
|
|
|
}
|
|
|
|
public static Integration WBIIntegration
|
|
{
|
|
get
|
|
{
|
|
|
|
//It's in memory?
|
|
if (mWBIIntegration != null)
|
|
return mWBIIntegration;
|
|
|
|
////It's in the cache?
|
|
//if (HttpContext.Current.Cache["IntegrationData"] != null)
|
|
//{
|
|
// mWBIIntegration = (Integration)HttpContext.Current.Cache["IntegrationData"];
|
|
// return mWBIIntegration;
|
|
//}
|
|
|
|
//check if there is an integration for wbi already
|
|
if (!Integration.IntegrationExists(WBIIntegrationID))
|
|
{
|
|
Integration i = Integration.NewItem(WBIIntegrationID);
|
|
i.AppVersion = Version;
|
|
i.Name = "AyaNova WBI";
|
|
i.AIObject = new WBIIntegrationData();
|
|
mWBIIntegration = (Integration)i.Save();
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
mWBIIntegration = Integration.GetItem(WBIIntegrationID);
|
|
}
|
|
catch
|
|
{
|
|
//Added as insurance code, on my dev station but no where else getting a serialization exception
|
|
//claiming that it can't find wbi v4.0.0.0 when we've been beyond that for some time without error and deployed
|
|
//4.0.2 doesn't get this error
|
|
Integration.DeleteItem(WBIIntegrationID);
|
|
Integration i = Integration.NewItem(WBIIntegrationID);
|
|
i.AppVersion = Version;
|
|
i.Name = "AyaNova WBI";
|
|
i.AIObject = new WBIIntegrationData();
|
|
mWBIIntegration = (Integration)i.Save();
|
|
}
|
|
}
|
|
|
|
//Convert for case 613
|
|
if (!(mWBIIntegration.AIObject is WBIIntegrationData))
|
|
{
|
|
//convert to new (v4 case 613 integrationdata object from old
|
|
//single guid that stored workorder report id
|
|
Guid mWorkorderReportID = (Guid)mWBIIntegration.AIObject;
|
|
mWBIIntegration.AIObject = new WBIIntegrationData();
|
|
((WBIIntegrationData)mWBIIntegration.AIObject).ClientWorkorderReportID = mWorkorderReportID;
|
|
mWBIIntegration = (Integration)mWBIIntegration.Save();
|
|
}
|
|
|
|
//We have a current integration object so put it in the cache...
|
|
|
|
//HttpContext.Current.Cache.Insert("IntegrationData", mWBIIntegration,
|
|
// null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
|
|
|
|
//...and return it
|
|
return mWBIIntegration;
|
|
}
|
|
|
|
}
|
|
private static Integration mWBIIntegration;
|
|
|
|
|
|
/// <summary>
|
|
/// GridLastView cached
|
|
/// </summary>
|
|
public static UIUserGridLastViews gGridLastViews
|
|
{
|
|
get
|
|
{
|
|
if (HttpContext.Current.Cache[Util.CurrentUserID.ToString() + "GridLastViews"] == null)
|
|
{
|
|
HttpContext.Current.Cache.Insert(Util.CurrentUserID.ToString() + "GridLastViews",
|
|
UIUserGridLastViews.GetItems(User.CurrentThreadUserID),
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20));
|
|
}
|
|
|
|
return (UIUserGridLastViews)HttpContext.Current.Cache[Util.CurrentUserID.ToString() + "GridLastViews"];
|
|
}
|
|
}
|
|
|
|
#region deprecated workorder report id prior to case 613
|
|
///// <summary>
|
|
///// the report id of the workorder report selected for
|
|
///// clients to print / preview
|
|
///// </summary>
|
|
//public static Guid ClientWorkorderReportID
|
|
//{
|
|
// get
|
|
// {
|
|
// if (HttpContext.Current.Cache["ClientWorkorderReportID"] == null)
|
|
// {
|
|
// Integration i = WBIIntegration;
|
|
// if (i.AIObject == null)
|
|
// {
|
|
// i.AIObject = Guid.Empty;
|
|
// i.Save();
|
|
// }
|
|
|
|
// HttpContext.Current.Cache.Insert("ClientWorkorderReportID",
|
|
// i.AIObject,
|
|
// null,
|
|
// System.Web.Caching.Cache.NoAbsoluteExpiration,
|
|
// TimeSpan.FromMinutes(20));
|
|
|
|
|
|
// }
|
|
|
|
// return (Guid)HttpContext.Current.Cache["ClientWorkorderReportID"];
|
|
|
|
// }
|
|
|
|
// set
|
|
// {
|
|
// //When setting we will have always retrieved at least once first in order
|
|
// //to prime the drop down list box selected value for reports so just need to update
|
|
// //and remove the cache and bob's your uncle.
|
|
// Integration i = WBIIntegration;
|
|
// i.AIObject = value;
|
|
// i.Save();
|
|
// HttpContext.Current.Cache.Remove("ClientWorkorderReportID");
|
|
|
|
|
|
// }
|
|
//}
|
|
#endregion deprecated
|
|
#endregion
|
|
|
|
#region Localization
|
|
|
|
public static void SetUserLocale()
|
|
{
|
|
//for more info see here: http://www.w3.org/International/questions/qa-lang-priorities
|
|
HttpRequest Request = HttpContext.Current.Request;
|
|
if (Request.UserLanguages == null)
|
|
return;
|
|
string Lang = Request.UserLanguages[0];
|
|
if (Lang != null)
|
|
{
|
|
if (Lang.Length < 3)
|
|
Lang = Lang + "-" + Lang.ToUpper();
|
|
try
|
|
{
|
|
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Lang);
|
|
}
|
|
catch
|
|
{
|
|
;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#region Get localized text strings from cache
|
|
|
|
/// <summary>
|
|
/// Get the localized text from a passed in localizedTextTable fetched
|
|
/// earlier (for performance when doing multiple items at once)
|
|
/// </summary>
|
|
/// <param name="Key"></param>
|
|
/// <param name="ltt"></param>
|
|
/// <returns></returns>
|
|
static public string LocaleText(string Key, LocalizedTextTable ltt)//case 1543 logpoint
|
|
{
|
|
if (string.IsNullOrEmpty(Key)) return "";
|
|
return ltt.GetLocalizedText(Key).Replace("&", "");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the localized text based on the current users language
|
|
/// from the web app cache
|
|
///
|
|
/// If the cache doesn't contain a localizedtexttable object for the language
|
|
/// requested, populate it first
|
|
///
|
|
/// (caches for 30 minutes from last access)
|
|
/// </summary>
|
|
/// <param name="Key"></param>
|
|
/// <returns></returns>
|
|
static public string LocaleText(string Key)//case 1543 logpoint
|
|
{
|
|
if (string.IsNullOrEmpty(Key)) return "";
|
|
return LocaleTextTable.GetLocalizedText(Key).Replace("&", "");
|
|
}
|
|
|
|
//private static LocalizedTextTable mlt = null;
|
|
static public LocalizedTextTable LocaleTextTable
|
|
{
|
|
get
|
|
{
|
|
|
|
//If it's in the private member then use that
|
|
|
|
//BUGBUG: this will cause a problem if WBI is used for multiple locales
|
|
//because the static localizedtexttable will be populated once
|
|
//at app startup and first login, then remain forever afterward until wbi is restarted
|
|
//However this does perform much better
|
|
//What to do...?
|
|
//Probably should add a switch for multilingual sites
|
|
//if (mlt != null)
|
|
// return mlt;
|
|
|
|
//try and get it from the cache first
|
|
|
|
if (string.IsNullOrEmpty(((BusinessPrincipal)Thread.CurrentPrincipal).Language)) return null;
|
|
string language=((BusinessPrincipal)Thread.CurrentPrincipal).Language;
|
|
|
|
LocalizedTextTable l = (LocalizedTextTable)HttpContext.Current.Cache["LT_" + language];
|
|
|
|
if (l == null)
|
|
{
|
|
//Not in cache so load it into cache
|
|
|
|
l = LocalizedTextTable.Load(language);
|
|
HttpContext.Current.Cache.Insert("LT_" + language, l,
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
|
|
|
|
}
|
|
|
|
//mlt = l;
|
|
return l;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Localize control and children
|
|
|
|
//Override added after initial design to take the place
|
|
//of the new localize method that takes a localizedtexttable as a parameter
|
|
//for performance
|
|
static public void Localize(System.Web.UI.Control TheControl)
|
|
{
|
|
//prefetch the localized text table
|
|
LocalizedTextTable ltt = LocaleTextTable;
|
|
Localize(TheControl, ltt);
|
|
}
|
|
/// <summary>
|
|
/// iterate through the controls on the passed in control and localize them
|
|
/// and it as necessary
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
static public void Localize(System.Web.UI.Control TheControl, LocalizedTextTable ltt)
|
|
{
|
|
switch (TheControl.GetType().ToString())
|
|
{
|
|
//Ignore these:
|
|
case "System.Web.UI.LiteralControl":
|
|
case "Telerik.Web.UI.GridTableCell":
|
|
case "System.Web.UI.WebControls.ImageButton":
|
|
case "System.Web.UI.WebControls.Image":
|
|
|
|
break;
|
|
case "System.Web.UI.WebControls.Label":
|
|
{
|
|
Label c = (Label)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""),ltt);
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.CheckBox":
|
|
{
|
|
CheckBox c = (CheckBox)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.Button":
|
|
{
|
|
Button c = (Button)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.LinkButton":
|
|
{
|
|
LinkButton c = (LinkButton)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
case "Telerik.Web.UI.RadMenuItem":
|
|
{
|
|
Telerik.Web.UI.RadMenuItem mi = (Telerik.Web.UI.RadMenuItem)TheControl;
|
|
if (!string.IsNullOrEmpty(mi.Text))
|
|
if (mi.Text.StartsWith("LT:"))
|
|
mi.Text = LocaleText(mi.Text.Replace("LT:", ""), ltt);
|
|
|
|
if (!string.IsNullOrEmpty(mi.ToolTip))
|
|
if (mi.ToolTip.StartsWith("LT:"))
|
|
mi.ToolTip = LocaleText(mi.ToolTip.Replace("LT:", ""), ltt);
|
|
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.HyperLink":
|
|
{
|
|
HyperLink c = (HyperLink)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
case "Telerik.Web.UI.RadPanelBar":
|
|
{
|
|
LocalizeRadPanelItems(((Telerik.Web.UI.RadPanelBar)TheControl).Items,ltt);
|
|
|
|
}
|
|
break;
|
|
|
|
case "Telerik.Web.UI.RadTabStrip":
|
|
{
|
|
Telerik.Web.UI.RadTabStrip strip = (Telerik.Web.UI.RadTabStrip)TheControl;
|
|
foreach (Telerik.Web.UI.RadTab t in strip.Tabs)
|
|
{
|
|
if (!string.IsNullOrEmpty(t.Text))
|
|
t.Text = LocaleText(t.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
|
|
|
|
case "System.Web.UI.Page":
|
|
//case "ASP.masterpage_master":
|
|
{
|
|
//Localize the page title if required
|
|
Page p = (Page)TheControl;
|
|
if (p.Title.StartsWith("LT:"))
|
|
p.Title = LocaleText(p.Title.Replace("LT:", ""), ltt);
|
|
|
|
}
|
|
break;
|
|
|
|
case "Telerik.Web.UI.RadDateTimePicker":
|
|
{
|
|
Telerik.Web.UI.RadDateTimePicker r = (Telerik.Web.UI.RadDateTimePicker)TheControl;
|
|
r.MaxDate = DateTime.MaxValue;
|
|
r.MinDate = DateTime.MinValue;
|
|
r.TimeView.StartTime = new TimeSpan(8, 0, 0);
|
|
r.TimeView.EndTime = new TimeSpan(21, 15, 0);
|
|
r.TimeView.Interval = new TimeSpan(0, 15, 0);
|
|
r.TimeView.HeaderText = "";
|
|
r.TimeView.Columns = 4;
|
|
}
|
|
break;
|
|
case "Telerik.Web.UI.RadTimeView":
|
|
{
|
|
Telerik.Web.UI.RadTimeView r = (Telerik.Web.UI.RadTimeView)TheControl;
|
|
r.StartTime = new TimeSpan(8, 0, 0);
|
|
r.EndTime = new TimeSpan(21, 15, 0);
|
|
r.Interval = new TimeSpan(0, 15, 0);
|
|
r.HeaderText = "";
|
|
r.Columns = 4;
|
|
}
|
|
break;
|
|
case "Telerik.Web.UI.RadButton"://added for case 1805
|
|
{
|
|
Telerik.Web.UI.RadButton c = (Telerik.Web.UI.RadButton)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
;
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
//Now localize any child controls if contained in it
|
|
foreach (Control c in TheControl.Controls)
|
|
{
|
|
Localize(c, ltt);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion page
|
|
|
|
#region Localize Radpanel
|
|
static public void LocalizeRadPanelItems(Telerik.Web.UI.RadPanelItemCollection items, LocalizedTextTable ltt)
|
|
{
|
|
|
|
foreach (Telerik.Web.UI.RadPanelItem pi in items)
|
|
{
|
|
if (pi.Items.Count > 0)
|
|
{
|
|
//Recurse me baby one more time...
|
|
LocalizeRadPanelItems(pi.Items,ltt);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(pi.Text))
|
|
pi.Text = LocaleText(pi.Text.Replace("LT:", ""),ltt);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Localize grid
|
|
|
|
|
|
/// <summary>
|
|
/// Localizes an editable grid by transmorphing the current column names found
|
|
/// by including the object name passed in to make a localized text key
|
|
/// then setting the column to the key in question
|
|
/// </summary>
|
|
/// <param name="Grid"></param>
|
|
static public void LocalizeEditableGrid(string ObjectName, Telerik.Web.UI.RadGrid Grid)
|
|
{
|
|
|
|
if (Grid.Columns.Count == 0) return;
|
|
|
|
//Grid.MasterTableView.EditFormSettings.FormTemplate
|
|
|
|
foreach (Telerik.Web.UI.GridColumn c in Grid.Columns)
|
|
{
|
|
if (c.Display && !string.IsNullOrEmpty(c.HeaderText))
|
|
{
|
|
//Keep track of original value just in case
|
|
string sOld = c.HeaderText;
|
|
|
|
//attempt to localize, works for non-editable grid as well
|
|
//because first checks if column name already contains a localized text key...
|
|
if (c.HeaderText.StartsWith("LT_"))//Yes then must be a read only grid
|
|
c.HeaderText = LocaleText(c.HeaderText.Replace("LT_", "").Replace("_", "."));
|
|
else
|
|
c.HeaderText = LocaleText(ObjectName + ".Label." + c.HeaderText);
|
|
|
|
//If the header text still contains part of the locale key
|
|
//then it wasn't found in the localized text table and should
|
|
//probably not have been changed as it was likely
|
|
//pre-localized for some reason already (i.e. COLORCOLUMN)
|
|
if (c.HeaderText.Contains(".Label."))
|
|
c.HeaderText = sOld;
|
|
}
|
|
if (c is GridButtonColumn)
|
|
{
|
|
GridButtonColumn bc = c as GridButtonColumn;
|
|
if (bc.CommandName == "Delete")
|
|
bc.ConfirmText = LocaleText("UI.Label.DeletePrompt");
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(bc.ConfirmText))
|
|
{
|
|
bc.ConfirmText = StringJavaScriptify(LocaleText(bc.ConfirmText));
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Localizes existing columns header text in grid
|
|
/// (generally a read only one)
|
|
/// </summary>
|
|
/// <param name="Grid"></param>
|
|
static public void LocalizeGrid( Telerik.Web.UI.RadGrid Grid)
|
|
{
|
|
|
|
LocalizeEditableGrid("", Grid);
|
|
|
|
}
|
|
#endregion localize grid
|
|
|
|
#endregion localization
|
|
|
|
#region Form Rights and security
|
|
|
|
/// <summary>
|
|
/// Use reflection to find the locale key for a biz object
|
|
/// (if the biz object doesn't have a LocaleKey property it returns
|
|
/// the name of the biz object instead)
|
|
/// </summary>
|
|
/// <param name="BizObject"></param>
|
|
public static string GetBizObjectLocaleKey(object BizObject)
|
|
{
|
|
//case 1039 //log.Debug("GetBizObjectLocaleKey("+BizObject.ToString()+")");
|
|
try
|
|
{
|
|
|
|
PropertyInfo pi = BizObject.GetType().GetProperty("LocaleKey");
|
|
if (pi == null) return BizObject.ToString();
|
|
|
|
object propvalue = pi.GetValue(BizObject, null).ToString();
|
|
if (propvalue != null)
|
|
return propvalue.ToString();
|
|
else
|
|
return BizObject.ToString();
|
|
|
|
}
|
|
catch
|
|
{
|
|
//log.Error("GetBizObjectLocaleKey", e);
|
|
//MessageBox.Show("GetBizObjectLocaleKey:" + e.Message);
|
|
return "";
|
|
}
|
|
|
|
|
|
//return BizObject.ToString();
|
|
|
|
}
|
|
|
|
|
|
public static void Denied(HttpContext c)
|
|
{
|
|
c.Response.Clear();
|
|
c.Response.StatusCode = 403;
|
|
c.Response.StatusDescription = "Access Denied";
|
|
c.Response.Write("<h2>Access Denied</h2>");
|
|
c.Response.End();
|
|
}
|
|
|
|
|
|
public static void SetAccess(System.Web.UI.Page p, int rights)
|
|
{
|
|
if (rights < (int)SecurityLevelTypes.ReadWrite)
|
|
{
|
|
SetReadOnly(p);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the passed in control and all it's children as read only
|
|
/// </summary>
|
|
/// <param name="TheControl"></param>
|
|
public static void SetReadOnly(System.Web.UI.Control TheControl)
|
|
{
|
|
switch (TheControl.GetType().ToString())
|
|
{
|
|
|
|
case "Telerik.Web.UI.RadComboBox":
|
|
{
|
|
((Telerik.Web.UI.RadComboBox)TheControl).Enabled=false;
|
|
}
|
|
break;
|
|
case "Telerik.Web.UI.RadDateTimePicker":
|
|
{
|
|
((Telerik.Web.UI.RadDateTimePicker)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
case "Telerik.Web.UI.RadDatePicker":
|
|
{
|
|
((Telerik.Web.UI.RadDatePicker)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.TextBox":
|
|
{
|
|
((TextBox)TheControl).Enabled=false;
|
|
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.CheckBox":
|
|
{
|
|
((CheckBox)TheControl).Enabled=false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.Button":
|
|
{
|
|
((Button)TheControl).Enabled=false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.LinkButton":
|
|
{
|
|
LinkButton lb = ((LinkButton)TheControl);
|
|
lb.Enabled = false;
|
|
if (lb.ID == "btnNew" || lb.ID == "btnNew2")
|
|
lb.Visible = false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.ImageButton":
|
|
{
|
|
ImageButton lb = ((ImageButton)TheControl);
|
|
lb.Enabled = false;
|
|
if (lb.ID == "btnNew" || lb.ID == "btnNew2")
|
|
lb.Visible = false;
|
|
}
|
|
break;
|
|
|
|
case "Telerik.Web.UI.RadGrid":
|
|
{
|
|
GridSetReadOnly(((RadGrid)TheControl));
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.RadioButtonList":
|
|
{
|
|
((RadioButtonList)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
|
|
case "GZTW.CustomWebControls.AyColorPicker":
|
|
{
|
|
((GZTW.CustomWebControls.AyColorPicker)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
|
|
|
|
case "Telerik.Web.UI.RadMenuItem":
|
|
{
|
|
Telerik.Web.UI.RadMenuItem mi = (Telerik.Web.UI.RadMenuItem)TheControl;
|
|
switch (mi.Value)
|
|
{
|
|
case "LT:UI.Command.Delete":
|
|
mi.Visible = false;
|
|
break;
|
|
case "LT:UI.Command.Save":
|
|
mi.Visible = false;
|
|
break;
|
|
case "LT:UI.Command.SaveClose":
|
|
mi.Visible = false;
|
|
break;
|
|
case "Delete":
|
|
mi.Visible = false;
|
|
break;
|
|
case "Save":
|
|
mi.Visible = false;
|
|
break;
|
|
case "SaveClose":
|
|
mi.Visible = false;
|
|
break;
|
|
case "AcceptToNew":
|
|
mi.Visible = false;
|
|
break;
|
|
case "AcceptToExisting":
|
|
mi.Visible = false;
|
|
break;
|
|
case "Reject":
|
|
mi.Visible = false;
|
|
break;
|
|
//case 1052
|
|
case "REPLY":
|
|
mi.Visible = false;
|
|
break;
|
|
case "FORWARD":
|
|
mi.Visible = false;
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
break;
|
|
}
|
|
|
|
//Now localize any child controls if contained in it
|
|
foreach (Control c in TheControl.Controls)
|
|
{
|
|
SetReadOnly(c);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//case 1972
|
|
public static void SetDeletable(System.Web.UI.Page p, RootObjectTypes rot)
|
|
{
|
|
if (AyaBizUtils.Right(rot) < (int)SecurityLevelTypes.ReadWriteDelete)
|
|
{
|
|
Control c = p.Master.FindControl("RadMenu1");//this is the name of the delete menu item id
|
|
if (c != null)
|
|
{
|
|
Telerik.Web.UI.RadMenu rm = (Telerik.Web.UI.RadMenu)c;
|
|
rm.Items.FindItemByValue("LT:UI.Command.Delete").Visible = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region broken rule localizing and cracking
|
|
/// <summary>
|
|
/// Takes a broken rule text and xforms it into the localized version
|
|
/// applying all formatting as required
|
|
/// </summary>
|
|
/// <param name="BrokenRuleString"></param>
|
|
/// <returns></returns>
|
|
private static string BrokenRuleLocalizer(string BrokenRuleString)
|
|
{
|
|
if (BrokenRuleString == null) return null;
|
|
if (BrokenRuleString == "") return "";
|
|
|
|
|
|
//Localize and format the string
|
|
//this string comes to us as a set of comma delimited localized text key strings
|
|
//i.e. "Error.Object.RequiredFieldEmpty,Client.Label.Name"
|
|
//the first key translates often to a string with format characters in it such as
|
|
//"{0} is not a valid value for the {1} field
|
|
//The second and following keys are the values to be inserted in those format positions
|
|
|
|
//This code makes an object array of all the second and following localized text strings
|
|
//and then passes that to the string.format function along with the first string
|
|
string[] sarray = BrokenRuleString.Split(',');
|
|
object[] sitems = new object[sarray.GetLength(0) - 1];
|
|
for (int x = 1; x < sarray.GetLength(0); x++)
|
|
{
|
|
sitems[x - 1] = LocaleText(sarray[x]);
|
|
}
|
|
|
|
return string.Format(LocaleText(sarray[0]), sitems);
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// cracks a broken rule collection into separate errors
|
|
/// then processes them
|
|
///
|
|
/// A brokenrulestext property of a biz object contains one or more
|
|
/// broken rules as in the brokenrulelocalizer method above, but
|
|
/// separated by pipe characters |
|
|
/// </summary>
|
|
/// <param name="BrokenRuleCollection"></param>
|
|
/// <returns></returns>
|
|
public static string BrokenRuleCollectionLocalizer(string BrokenRuleCollection)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
string[] sarray = BrokenRuleCollection.Split('|');
|
|
foreach (string s in sarray)
|
|
{
|
|
sb.Append(BrokenRuleLocalizer(s));
|
|
sb.Append("\r\n");
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region Reporting
|
|
|
|
/// <summary>
|
|
/// Fill an Telerik RadMenuItem panel item
|
|
/// with all reports for given key
|
|
/// </summary>
|
|
/// <param name="ReportKey"></param>
|
|
static public void ReportFillList(Telerik.Web.UI.RadMenuItem topmenuitem, string ReportKeySummary, string ReportKeyDetailed)
|
|
{
|
|
topmenuitem.Items.Clear();
|
|
topmenuitem.PostBack = false;
|
|
ReportPickList rpl = ReportPickList.GetList(ReportKeySummary, ReportKeyDetailed,true);
|
|
foreach (ReportPickList.ReportPickListInfo i in rpl)
|
|
{
|
|
if (i.Active)
|
|
{
|
|
Telerik.Web.UI.RadMenuItem li = new Telerik.Web.UI.RadMenuItem();
|
|
li.Text = i.Name;
|
|
if (i.IsSummary)
|
|
li.Value = "PRINTSUMMARY," + i.ID.ToString();
|
|
else
|
|
li.Value = "PRINTDETAILED," + i.ID.ToString();
|
|
topmenuitem.Items.Add(li);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Put report data in a 2 minute cache under
|
|
/// current user id and report key
|
|
/// and return url to report page
|
|
/// for redirection from caller
|
|
/// </summary>
|
|
/// <param name="Key">Key to retrieve data from cache</param>
|
|
/// <param name="Data">data to go in cache or null if it's already there</param>
|
|
static public void Report(Page p, string ReportID, string Key, object Data, string SignableWoID)
|
|
{
|
|
|
|
if (Data != null)
|
|
p.Cache.Insert(CurrentUserID.ToString() + Key,
|
|
Data,
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(2));
|
|
|
|
string toUrl = "ReportView.aspx?rpt=" + ReportID + "&src=" + CurrentUserID.ToString() + Key + (!string.IsNullOrEmpty(SignableWoID)?"&sigwo="+SignableWoID:"");
|
|
|
|
//TODO: Likely this is going to cause problems for some with popup blockers
|
|
//It's possible we might need to add an alternative choice to a regular response redirect
|
|
p.Response.Write("<script>\r\n");
|
|
p.Response.Write("window.open('" + toUrl + "');");
|
|
p.Response.Write("\r\n</script>");
|
|
|
|
}
|
|
/// <summary>
|
|
/// Overload for non signable workorder reports
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
/// <param name="ReportID"></param>
|
|
/// <param name="Key"></param>
|
|
/// <param name="Data"></param>
|
|
static public void Report(Page p, string ReportID, string Key, object Data)
|
|
{
|
|
Report(p, ReportID, Key, Data, "");
|
|
}
|
|
|
|
#endregion reporting
|
|
|
|
#region List retrievers for combo boxes and value lists in grid
|
|
|
|
|
|
#region NonBizLists
|
|
|
|
/// <summary>
|
|
/// Since there is a limited set of these types of items there is no populate and init separately,
|
|
/// instead it fills with all available items and selects automatically
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <param name="EnumListName"></param>
|
|
/// <param name="oSelected"></param>
|
|
static public void ComboInitializeNonBiz(Telerik.Web.UI.RadComboBox cb, string EnumListName, object oSelected)
|
|
{
|
|
|
|
cb.DataSource = GetDataNonBiz(EnumListName);
|
|
cb.DataValueField = "Value";
|
|
cb.DataTextField = "Display";
|
|
cb.DataBind();
|
|
if (oSelected != null)
|
|
cb.SelectedValue = oSelected.ToString();
|
|
}
|
|
|
|
public static string GetNonBizName(string EnumListName, int i)
|
|
{
|
|
DataTable dt = GetDataNonBiz(EnumListName);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (int.Parse(dr["Value"].ToString()) == i)
|
|
return dr["Display"].ToString();
|
|
}
|
|
return " ";
|
|
}
|
|
public static DataTable GetDataNonBiz(string EnumListName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("Display");
|
|
dt.Columns.Add("Value");
|
|
|
|
|
|
switch (EnumListName)
|
|
{
|
|
case "QuoteStatus":
|
|
{
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.Awarded, LocaleText("WorkorderQuoteStatusTypes.Label.Awarded"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.InProgress, LocaleText("WorkorderQuoteStatusTypes.Label.InProgress"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.NotAwarded, LocaleText("WorkorderQuoteStatusTypes.Label.NotAwarded"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.Submitted, LocaleText("WorkorderQuoteStatusTypes.Label.Submitted"));
|
|
//case 1556
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.New, LocaleText("WorkorderQuoteStatusTypes.Label.New"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.NotAwarded2, LocaleText("WorkorderQuoteStatusTypes.Label.NotAwarded2"));
|
|
|
|
}
|
|
break;
|
|
case "ClientServiceRequestStatus":
|
|
{
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Accepted, LocaleText("ClientServiceRequestStatus.Accepted"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Declined, LocaleText("ClientServiceRequestStatus.Declined"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Open, LocaleText("ClientServiceRequestStatus.Open"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Closed, LocaleText("ClientServiceRequestStatus.Closed"));
|
|
}
|
|
break;
|
|
case "ClientServiceRequestPriority":
|
|
{
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.NotUrgent, LocaleText("ClientServiceRequestPriority.NotUrgent"));
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.ASAP, LocaleText("ClientServiceRequestPriority.ASAP"));
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.Emergency, LocaleText("ClientServiceRequestPriority.Emergency"));
|
|
|
|
}
|
|
break;
|
|
case "UnitsOfTime":
|
|
{
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Minutes, Util.LocaleText("UI.Label.TimeSpan.Minutes"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Hours, Util.LocaleText("UI.Label.TimeSpan.Hours"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Days, Util.LocaleText("UI.Label.TimeSpan.Days"));
|
|
//Weeks are not supported because the concept of Week is very "weak" globally :)
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Months, Util.LocaleText("UI.Label.TimeSpan.Months"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Years, Util.LocaleText("UI.Label.TimeSpan.Years"));
|
|
|
|
}
|
|
break;
|
|
case "DaysOfWeek":
|
|
{
|
|
AddNVRow(dt, (int)AyaDayOfWeek.AnyDayOfWeek, Util.LocaleText("UI.Label.Day.Any"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Monday, Util.LocaleText("UI.Label.Day.Monday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Tuesday, Util.LocaleText("UI.Label.Day.Tuesday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Wednesday, Util.LocaleText("UI.Label.Day.Wednesday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Thursday, Util.LocaleText("UI.Label.Day.Thursday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Friday, Util.LocaleText("UI.Label.Day.Friday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Saturday, Util.LocaleText("UI.Label.Day.Saturday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Sunday, Util.LocaleText("UI.Label.Day.Sunday"));
|
|
|
|
}
|
|
break;
|
|
case "VendorTypes":
|
|
{
|
|
AddNVRow(dt, -1, "-");//Case 344
|
|
AddNVRow(dt, (int)VendorTypes.Manufacturer, Util.LocaleText("Vendor.Label.VendorType.Manufacturer"));
|
|
AddNVRow(dt, (int)VendorTypes.Shipper, Util.LocaleText("Vendor.Label.VendorType.Shipper"));
|
|
AddNVRow(dt, (int)VendorTypes.SubContractor, Util.LocaleText("Vendor.Label.VendorType.SubContractor"));
|
|
AddNVRow(dt, (int)VendorTypes.ThirdPartyRepair, Util.LocaleText("Vendor.Label.VendorType.ThirdPartyRepair"));
|
|
AddNVRow(dt, (int)VendorTypes.Wholesaler, Util.LocaleText("Vendor.Label.VendorType.Wholesaler"));
|
|
|
|
}
|
|
break;
|
|
case "PurchaseOrderStatus":
|
|
{
|
|
AddNVRow(dt, -1, "-");//Case 344
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedFullReceived, Util.LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedFullReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedNoneReceived, Util.LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedNoneReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedPartialReceived, Util.LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedPartialReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenNotYetOrdered, Util.LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.OpenNotYetOrdered"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenOrdered, Util.LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.OpenOrdered"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenPartialReceived, Util.LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.OpenPartialReceived"));
|
|
|
|
|
|
}
|
|
break;
|
|
case "WorkorderItemTaskCompletionType":
|
|
{
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.Complete, LocaleText("WorkorderItemTask.Label.CompletionType.Complete"));
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.Incomplete, LocaleText("WorkorderItemTask.Label.CompletionType.Incomplete"));
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.NotApplicable, LocaleText("WorkorderItemTask.Label.CompletionType.NotApplicable"));
|
|
|
|
}
|
|
break;
|
|
|
|
case "ContactPhoneTypes":
|
|
{
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Unset, "-");//Case 344
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Business, LocaleText("ContactPhone.Label.ContactPhoneType.Business"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Mobile, LocaleText("ContactPhone.Label.ContactPhoneType.Mobile"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Fax, LocaleText("ContactPhone.Label.ContactPhoneType.Fax"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Pager, LocaleText("ContactPhone.Label.ContactPhoneType.Pager"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Home, LocaleText("ContactPhone.Label.ContactPhoneType.Home"));
|
|
}
|
|
break;
|
|
|
|
case "UserTypes":
|
|
{
|
|
AddNVRow(dt, (int)UserTypes.Administrator, LocaleText("UserTypes.Label.Administrator"));
|
|
AddNVRow(dt, (int)UserTypes.Schedulable, LocaleText("UserTypes.Label.Schedulable"));
|
|
AddNVRow(dt, (int)UserTypes.NonSchedulable, LocaleText("UserTypes.Label.NonSchedulable"));
|
|
AddNVRow(dt, (int)UserTypes.Client, LocaleText("UserTypes.Label.Client"));
|
|
AddNVRow(dt, (int)UserTypes.HeadOffice, LocaleText("UserTypes.Label.HeadOffice"));
|
|
AddNVRow(dt, (int)UserTypes.Utility, LocaleText("UserTypes.Label.UTILITY"));
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
//Case 513
|
|
case "LoanItemRates":
|
|
{
|
|
AddNVRow(dt, (int)LoanItemRates.None, LocaleText("LoanItem.Label.RateNone"));
|
|
AddNVRow(dt, (int)LoanItemRates.Hours, LocaleText("LoanItem.Label.RateHour"));
|
|
AddNVRow(dt, (int)LoanItemRates.HalfDays, LocaleText("LoanItem.Label.RateHalfDay"));
|
|
AddNVRow(dt, (int)LoanItemRates.Days, LocaleText("LoanItem.Label.RateDay"));
|
|
AddNVRow(dt, (int)LoanItemRates.Weeks, LocaleText("LoanItem.Label.RateWeek"));
|
|
AddNVRow(dt, (int)LoanItemRates.Months, LocaleText("LoanItem.Label.RateMonth"));
|
|
AddNVRow(dt, (int)LoanItemRates.Years, LocaleText("LoanItem.Label.RateYear"));
|
|
}
|
|
break;
|
|
|
|
}
|
|
return dt;
|
|
}
|
|
#endregion nonbizlists
|
|
|
|
|
|
#region BizList
|
|
|
|
|
|
|
|
#region Telerik combo populate and retrieve wrappers
|
|
/// <summary>
|
|
/// Get Guid from selected item in combo passed in
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <returns></returns>
|
|
static public Guid ComboValue(Telerik.Web.UI.RadComboBox cb)
|
|
{
|
|
if (cb == null) return Guid.Empty;
|
|
if (string.IsNullOrEmpty(cb.SelectedValue)) return Guid.Empty;
|
|
return new Guid(cb.SelectedValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Guid from selected item in dropdownlist passed in
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <returns></returns>
|
|
static public Guid ComboValue(DropDownList cb)
|
|
{
|
|
if (cb == null) return Guid.Empty;
|
|
if (string.IsNullOrEmpty(cb.SelectedValue)) return Guid.Empty;
|
|
return new Guid(cb.SelectedValue);
|
|
}
|
|
|
|
|
|
//static public ComboValue<T>(RadComboBox cb)
|
|
//{
|
|
// if (cb == null) return Guid.Empty;
|
|
// if (string.IsNullOrEmpty(cb.Value)) return Guid.Empty;
|
|
// return new Guid(cb.Value);
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Populate a combo box either with an initial value only or
|
|
/// all active items plus selected initial value (active or inactive)
|
|
/// from a business object collection list
|
|
///
|
|
/// Uses a generic fetch from db for object names and for defined picklists
|
|
/// uses the pick list collection object instead
|
|
/// </summary>
|
|
/// <param name="PickList">Either a defined pick list name or an object name</param>
|
|
/// <param name="cb"></param>
|
|
/// <param name="InitialValueOnly"></param>
|
|
/// <param name="SelectedID"></param>
|
|
static public void ComboPopulateBizList(string PickList, Telerik.Web.UI.RadComboBox cb,
|
|
bool ActiveOnly, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e, bool Region)
|
|
{
|
|
ComboPopulateBizList(PickList, cb, ActiveOnly, Guid.Empty, null, e, Region);
|
|
}
|
|
|
|
//Added for Case 307
|
|
/// <summary>
|
|
/// Kind of an overload for above that includes selection of selected ID
|
|
/// to save typing
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <param name="ObjectName"></param>
|
|
/// <param name="SelectedID"></param>
|
|
static public void ComboPopulateAndInitializeBizList(Telerik.Web.UI.RadComboBox cb, string PickList, Guid SelectedID, bool Region)
|
|
{
|
|
ComboPopulateBizList(PickList, cb, false, null,Region);
|
|
cb.SelectedValue = SelectedID.ToString();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Populate a combo with one item that is initially selected
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <param name="ObjectName"></param>
|
|
/// <param name="SelectedID"></param>
|
|
static public void ComboInitialize(Telerik.Web.UI.RadComboBox cb, string ObjectName, Guid SelectedID)
|
|
{
|
|
|
|
cb.Items.Add(new Telerik.Web.UI.RadComboBoxItem(GetBizObjectName(ObjectName, SelectedID), SelectedID.ToString()));
|
|
cb.SelectedValue = SelectedID.ToString();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Used for combo box initialization
|
|
/// and for label intialization in grid
|
|
/// columns that contain a combo but are
|
|
/// not in edit mode
|
|
///
|
|
/// </summary>
|
|
/// <param name="ObjectName"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <returns></returns>
|
|
static public string GetBizObjectName(string ObjectName, Guid SelectedID)
|
|
{
|
|
if (SelectedID == Guid.Empty)
|
|
return "-";//Case 344
|
|
switch (ObjectName)
|
|
{
|
|
case "UserPickList":
|
|
case "User":
|
|
{
|
|
UserPickList upl = UserPickList.GetListOfOneSpecificUser(SelectedID);
|
|
if (upl.Count == 0)
|
|
return "";
|
|
return upl[0].Name;
|
|
}
|
|
case "Part":
|
|
{
|
|
PartPickList pl = PartPickList.GetOnePart(SelectedID);
|
|
if (pl.Count == 0)
|
|
return "";
|
|
return pl[0].DisplayName(GlobalSettings.DefaultPartDisplayFormat);
|
|
}
|
|
case "PartSerial":
|
|
{
|
|
NameFetcher nf = NameFetcher.GetItem(ObjectName, "SerialNumber", SelectedID);
|
|
return nf.RecordName;
|
|
}
|
|
case "LoanItem":
|
|
{
|
|
LoanItemPickList pl = LoanItemPickList.GetOneLoanItem(SelectedID);
|
|
if (pl.Count == 0)
|
|
return "";
|
|
return pl[0].Name + " " + pl[0].Serial;
|
|
}
|
|
case "Unit":
|
|
{
|
|
return UnitNameFetcher.GetUnitNameFromUnitID(SelectedID);
|
|
|
|
}
|
|
case "UnitModel":
|
|
{
|
|
UnitModelPickList pl = UnitModelPickList.GetListOfOneSpecificUnitModel(SelectedID);
|
|
if (pl.Count == 0)
|
|
return "";
|
|
return pl[0].Name;
|
|
}
|
|
|
|
default:
|
|
{
|
|
NameFetcher nf = NameFetcher.GetItem(ObjectName, "Name", SelectedID);
|
|
return nf.RecordName;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Convenience overload
|
|
/// </summary>
|
|
/// <param name="ObjectName"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <returns></returns>
|
|
static public string GetBizObjectName(string ObjectName, string SelectedID)
|
|
{
|
|
return GetBizObjectName(ObjectName, new Guid(SelectedID));
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Override for backward compatibility before ID2 was added
|
|
/// </summary>
|
|
/// <param name="PickList"></param>
|
|
/// <param name="cb"></param>
|
|
/// <param name="ActiveOnly"></param>
|
|
/// <param name="ID1"></param>
|
|
/// <param name="SelectedIDList"></param>
|
|
/// <param name="e"></param>
|
|
static public void ComboPopulateBizList(string PickList, Telerik.Web.UI.RadComboBox cb,
|
|
bool ActiveOnly, Guid ID1, List<Guid> SelectedIDList, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e, bool Regional)
|
|
{
|
|
ComboPopulateBizList(PickList, cb, ActiveOnly, ID1, Guid.Empty, SelectedIDList, e, Regional);
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="PickList"></param>
|
|
/// <param name="cb"></param>
|
|
/// <param name="ActiveOnly"></param>
|
|
/// <param name="ID1"></param>
|
|
/// <param name="SelectedIDList"></param>
|
|
/// <param name="e"></param>
|
|
static public void ComboPopulateBizList(string PickList, Telerik.Web.UI.RadComboBox cb,
|
|
bool ActiveOnly, Guid ID1, Guid ID2, List<Guid> SelectedIDList, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e, bool Regional)
|
|
{
|
|
//add a list of stuff
|
|
DataTable dt = GetDataBiz(PickList, Guid.Empty, ActiveOnly, ID1, ID2, SelectedIDList, Regional);
|
|
|
|
//check if the requested event args are null
|
|
//if they are null then it means this is being called to load everything initially
|
|
//if they are not null then it means this is being called to add to an existing list
|
|
//so do the following...
|
|
if (e != null)
|
|
{
|
|
if (e.NumberOfItems >= dt.Rows.Count) return;
|
|
DataRow RemoveRow = null;
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (dr["Value"].ToString() == e.Value)
|
|
{
|
|
RemoveRow = dr;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (RemoveRow != null)
|
|
dt.Rows.Remove(RemoveRow);
|
|
}
|
|
|
|
DataView dv = dt.DefaultView;
|
|
dv.Sort = "Display";
|
|
cb.DataSource = dv;
|
|
cb.DataValueField = "Value";
|
|
cb.DataTextField = "Display";
|
|
cb.DataBind();
|
|
|
|
}
|
|
|
|
|
|
#endregion Telerik combo wrappers
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// overload for original method without ID2
|
|
/// </summary>
|
|
/// <param name="PickList"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <param name="ActiveOnly"></param>
|
|
/// <param name="ID1"></param>
|
|
/// <param name="SelectedIDList"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetDataBiz(string PickList, Guid SelectedID, bool ActiveOnly, Guid ID1, List<Guid> SelectedIDList, bool Regional)
|
|
{
|
|
return GetDataBiz(PickList, SelectedID, ActiveOnly, ID1, Guid.Empty, SelectedIDList, Regional);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="PickList"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <param name="ActiveOnly"></param>
|
|
/// <param name="ID1"></param>
|
|
/// <param name="SelectedIDList"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetDataBiz(string PickList, Guid SelectedID, bool ActiveOnly, Guid ID1, Guid ID2, List<Guid> SelectedIDList, bool Regional)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("Display");
|
|
dt.Columns.Add("Value", typeof(Guid));
|
|
dt.Columns.Add("Color", typeof(int));
|
|
//add an initial blank row for Guid.empty
|
|
DataRow drBlank = dt.NewRow();
|
|
drBlank["Display"] = "-";//Case 344
|
|
drBlank["Value"] = Guid.Empty;
|
|
dt.Rows.Add(drBlank);
|
|
|
|
switch (PickList)
|
|
{
|
|
|
|
case "UserPickListScheduleable":
|
|
{
|
|
#region
|
|
ScheduleableUserNameDisplayFormats fmt = GlobalSettings.DefaultScheduleableUserNameDisplayFormat;
|
|
UserListScheduleable UList = UserListScheduleable.GetList();
|
|
|
|
foreach (UserListScheduleable.UserListScheduleableInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name(fmt);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name(fmt);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
|
|
case "UserPickList":
|
|
{
|
|
#region
|
|
UserPickList UList = UserPickList.GetList(Regional);
|
|
|
|
foreach (UserPickList.UserPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "UserPickListStaffOnly":
|
|
{//used for quote prepared by combo
|
|
#region
|
|
UserPickList UList = UserPickList.GetList(Regional);
|
|
|
|
foreach (UserPickList.UserPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active && ui.Type != UserTypes.Utility && ui.Type != UserTypes.Client && ui.Type != UserTypes.HeadOffice)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
else if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "ScheduleableUserGroupPickList":
|
|
{
|
|
#region
|
|
ScheduleableUserGroupPickList UList = ScheduleableUserGroupPickList.GetList();
|
|
|
|
foreach (ScheduleableUserGroupPickList.ScheduleableUserGroupPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "ClientUnitList":
|
|
{
|
|
#region
|
|
UnitPickList UList = UnitPickList.GetListByClient(ID1);
|
|
Global g = GlobalSettings;
|
|
|
|
foreach (UnitPickList.UnitPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
else if (SelectedIDList != null)
|
|
{
|
|
|
|
//is the current, inactive item selected in the workorder in any woitem?
|
|
foreach (Guid id in SelectedIDList)
|
|
{
|
|
if (id == ui.ID)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Now manually add items that are selected on the workorder but have changed owners and
|
|
//wouldn't have been picked up in the above
|
|
if (SelectedIDList != null)
|
|
{
|
|
foreach (Guid id in SelectedIDList)
|
|
{
|
|
if (!UList.Contains(id))
|
|
{
|
|
//manually add it, it's selected on the wo, but
|
|
//it's not in the client unit pick list
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + UnitNameFetcher.GetUnitNameFromUnitID(id) + " [" + GZTW.AyaNova.BLL.Unit.GetOwnerNameForUnit(id) + "]";
|
|
dr["Value"] = id;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PriorityPickList":
|
|
{
|
|
#region
|
|
PriorityPickList UList = PriorityPickList.GetList();
|
|
|
|
foreach (PriorityPickList.PriorityPickListInfo ui in UList)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dr["Color"] = ui.Color;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "TaxCodeList":
|
|
{
|
|
#region
|
|
TaxCodeList UList = TaxCodeList.GetList();
|
|
|
|
foreach (TaxCodeList.TaxCodeListInfo ui in UList)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
|
|
dt.Rows.Add(dr);
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "LaborRateList":
|
|
{
|
|
#region
|
|
//ID1 contains a contract ID or guid.empty if no contract
|
|
//SelectedIDList contains an arraylist of selected ID's or is null
|
|
RatePickList rates;
|
|
if (ID1 == Guid.Empty)
|
|
rates = RatePickList.GetList(true);
|
|
else
|
|
rates = RatePickList.GetListWithContract(ID1);
|
|
|
|
foreach (RatePickList.RatePickListInfo ui in rates)
|
|
{
|
|
if (ui.RateType != RateTypes.Service) continue;
|
|
|
|
//Case 186
|
|
//Selectable and active are same thing with no contract
|
|
//with a contract then selectable is active and then if contract rates only is
|
|
//set accordingly
|
|
if (/*ui.Active*/ui.Selectable == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
//Case 186 currently there are no calls to this list that are not activeonly
|
|
//so just removed it since it would conflict with contract rates
|
|
System.Diagnostics.Debug.Assert(ActiveOnly, "Util::GetDataBiz - LaborRateList called with !ActiveOnly");
|
|
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID /*|| !ActiveOnly*/))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
|
|
case "TravelRateList":
|
|
{
|
|
#region
|
|
//ID1 contains a contract ID or guid.empty if no contract
|
|
//SelectedIDList contains an arraylist of selected ID's or is null
|
|
RatePickList rates;
|
|
if (ID1 == Guid.Empty)
|
|
rates = RatePickList.GetList(true);
|
|
else
|
|
rates = RatePickList.GetListWithContract(ID1);
|
|
|
|
foreach (RatePickList.RatePickListInfo ui in rates)
|
|
{
|
|
if (ui.RateType != RateTypes.Travel) continue;
|
|
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartPickList":
|
|
{
|
|
#region
|
|
PartPickList UList = PartPickList.GetAllParts();
|
|
Global g = GlobalSettings;
|
|
foreach (PartPickList.PartPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.DisplayName(g.DefaultPartDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.DisplayName(g.DefaultPartDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartWarehousePickList":
|
|
{
|
|
#region
|
|
//Case 640
|
|
PartWarehousePickList UList = PartWarehousePickList.GetActiveOnlyListWithExceptions(SelectedIDList);
|
|
|
|
foreach (PartWarehousePickList.PartWarehousePickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartSerialPickList":
|
|
{
|
|
#region
|
|
//ID1 contains part ID and ID2 contains warehouse ID (optional)
|
|
PartSerialPickList serialz;
|
|
serialz = PartSerialPickList.GetList(ID1, ID2);
|
|
|
|
|
|
foreach (PartSerialPickList.PartSerialPickListInfo ui in serialz)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.SerialNumber;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartSerialPickListForWorkorder":
|
|
{
|
|
#region
|
|
//special version to ensure no sn's appear in the list that are
|
|
//already selected on this workorder
|
|
PartSerialPickList serialz;
|
|
serialz = PartSerialPickList.GetList(ID1, ID2);
|
|
|
|
|
|
foreach (PartSerialPickList.PartSerialPickListInfo ui in serialz)
|
|
{
|
|
//Ensure that we're only adding serials that are not
|
|
//already selected on teh workorder
|
|
if (!SelectedIDList.Contains(ui.ID))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.SerialNumber;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "LoanItemPickList":
|
|
{
|
|
#region
|
|
LoanItemPickList UList = LoanItemPickList.GetList(Regional);
|
|
|
|
foreach (LoanItemPickList.LoanItemPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name + " " + ui.Serial;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name + " " + ui.Serial;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "UnitList":
|
|
{
|
|
#region
|
|
UnitPickList UList = UnitPickList.GetListOfAll();
|
|
Global g = GlobalSettings;
|
|
|
|
foreach (UnitPickList.UnitPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
|
|
case "UnitModelList":
|
|
{
|
|
#region
|
|
UnitModelPickList UList = UnitModelPickList.GetList();
|
|
|
|
foreach (UnitModelPickList.UnitModelPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "Vendors:Shipper":
|
|
{
|
|
#region
|
|
VendorPickList UList = VendorPickList.GetList(VendorTypes.Shipper);
|
|
|
|
foreach (VendorPickList.VendorPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "Vendors:NonShipper":
|
|
{
|
|
#region
|
|
VendorPickList UList = VendorPickList.GetList();
|
|
|
|
foreach (VendorPickList.VendorPickListInfo ui in UList)
|
|
{
|
|
if (ui.VendorType != VendorTypes.Shipper)
|
|
{
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
//fogbugz case 11
|
|
case "WorkorderStatusList":
|
|
{
|
|
#region
|
|
WorkorderStatusPickList statuses = WorkorderStatusPickList.GetList();
|
|
|
|
|
|
foreach (WorkorderStatusPickList.WorkorderStatusPickListInfo ui in statuses)
|
|
{
|
|
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID /*|| !ActiveOnly*/))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "WorkorderItemPriorityList"://case 1121
|
|
{
|
|
#region
|
|
PriorityPickList ppl = PriorityPickList.GetList();
|
|
|
|
foreach (PriorityPickList.PriorityPickListInfo ui in ppl)
|
|
{
|
|
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dr["Color"] = ui.Color;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID /*|| !ActiveOnly*/))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dr["Color"] = ui.Color;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "WorkorderItemTypeList"://case 1121
|
|
{
|
|
#region
|
|
WorkorderItemTypePickList witpl = WorkorderItemTypePickList.GetList();
|
|
|
|
foreach (WorkorderItemTypePickList.WorkorderItemTypePickListInfo ui in witpl)
|
|
{
|
|
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID /*|| !ActiveOnly*/))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
default://generic list PickList contains biz object name
|
|
{
|
|
#region
|
|
GenericNVList l = GenericNVList.GetList("a" + PickList, "aID", "aName", true, ActiveOnly,Regional);
|
|
|
|
//ensure that non-active record
|
|
//still appears in list
|
|
bool bSelectedRecordIsInList = false;
|
|
|
|
|
|
foreach (DictionaryEntry d in l.BindableList)
|
|
{
|
|
|
|
Guid gValue = new Guid(d.Key.ToString());
|
|
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = d.Value.ToString();
|
|
dr["Value"] = gValue;
|
|
dt.Rows.Add(dr);
|
|
|
|
if (gValue == SelectedID)
|
|
bSelectedRecordIsInList = true;
|
|
|
|
}
|
|
|
|
if (ActiveOnly && SelectedID != Guid.Empty && !bSelectedRecordIsInList)
|
|
{
|
|
//retrieve manually non-active item
|
|
try
|
|
{
|
|
NameFetcher nf = NameFetcher.GetItem(PickList, "Name", SelectedID);
|
|
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + nf.RecordName;
|
|
dr["Value"] = SelectedID;
|
|
dt.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
}
|
|
return dt;
|
|
}
|
|
#endregion BizList
|
|
|
|
static private void AddNVRow(DataTable dt, object value, object display)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = display.ToString();
|
|
dr["Value"] = value;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
|
|
|
|
#endregion List retrievers
|
|
|
|
#region Grid helper methods
|
|
|
|
public static bool ObjectCanOpenInWBI(string localekey)
|
|
{
|
|
//Case 207 openable objects in WBI
|
|
//also change here needs to go into
|
|
//MainGrid->GridItemDataBound
|
|
switch (localekey)
|
|
{
|
|
case "LT_O_Workorder":
|
|
case "LT_O_Client":
|
|
case "LT_O_HeadOffice":
|
|
case "LT_O_Project":
|
|
case "LT_O_ClientNote":
|
|
case "LT_O_ClientServiceRequest":
|
|
case "LT_O_LoanItem":
|
|
case "LT_LoanItem_Label_Name":
|
|
case "LT_LoanItem_Label_Serial":
|
|
case "LT_O_Memo":
|
|
case "LT_O_ScheduleMarker":
|
|
case "LT_O_ServiceBank":
|
|
case "LT_O_Unit":
|
|
case "LT_Unit_Label_Serial":
|
|
case "LT_O_UnitModel":
|
|
//case 207 additional items
|
|
case "LT_Workorder_Label_FromQuoteID":
|
|
case "LT_Workorder_Label_FromPMID":
|
|
case "LT_O_WorkorderQuote":
|
|
case "LT_O_WorkorderPreventiveMaintenance":
|
|
case "LT_O_Contract":
|
|
case "LT_O_Part":
|
|
case "LT_WorkorderItemPart_Label_PartID":
|
|
//case 744
|
|
case "LT_Memo_Label_Subject":
|
|
//case 758
|
|
case "LT_SearchResult_Label_Source":
|
|
//case 898
|
|
case "LT_WorkorderItemLoan_Label_LoanItem":
|
|
//case 1417
|
|
case "LT_O_WikiPage":
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Check for broken rule, if so then cancel
|
|
/// update and display.
|
|
/// </summary>
|
|
/// <param name="o"></param>
|
|
/// <param name="e"></param>
|
|
public static void GridCheckForBrokenRule(CSLA.BusinessBase o, GridCommandEventArgs e)
|
|
{
|
|
if (o.IsDirty && !o.IsSavable)
|
|
{
|
|
GridItem d = (GridItem)e.Item;
|
|
|
|
e.Canceled = true;
|
|
foreach (TableCell cc in d.Cells)
|
|
{
|
|
cc.ToolTip = BrokenRuleCollectionLocalizer(o.BrokenRulesText);
|
|
cc.BorderStyle = BorderStyle.Dotted;
|
|
cc.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(2);
|
|
cc.BorderColor = System.Drawing.Color.Red;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public static Hashtable GridExtractValues(GridItem i)
|
|
{
|
|
GridEditableItem editedItem = i as GridEditableItem;
|
|
//Update new values
|
|
Hashtable newValues = new Hashtable();
|
|
//The GridTableView will fill the values from all editable columns in the hash
|
|
i.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
|
|
return newValues;
|
|
}
|
|
|
|
|
|
|
|
public static void GridSetReadOnly(Telerik.Web.UI.RadGrid g)
|
|
{
|
|
if (g.MasterTableView.Columns.FindByUniqueNameSafe("EditColumn") != null)
|
|
{
|
|
g.MasterTableView.Columns.FindByUniqueNameSafe("EditColumn").Visible = false;
|
|
}
|
|
if (g.MasterTableView.Columns.FindByUniqueNameSafe("DeleteColumn") != null)
|
|
{
|
|
g.MasterTableView.Columns.FindByUniqueNameSafe("DeleteColumn").Visible = false;
|
|
}
|
|
|
|
g.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
|
|
|
|
}
|
|
|
|
//case 1429
|
|
public static void GridSetNoDelete(Telerik.Web.UI.RadGrid g)
|
|
{
|
|
if (g.MasterTableView.Columns.FindByUniqueNameSafe("DeleteColumn") != null)
|
|
{
|
|
g.MasterTableView.Columns.FindByUniqueNameSafe("DeleteColumn").Visible = false;
|
|
}
|
|
}
|
|
|
|
|
|
public static void GridInitEditable(string GridKey, Telerik.Web.UI.RadGrid g, string bizObjectName)
|
|
{
|
|
|
|
GridSetLayout(GridKey, g);
|
|
LocalizeEditableGrid(bizObjectName, g);
|
|
//g.EditItemStyle.CssClass = "AYEditRow";
|
|
// g.MasterTableView.EditFormSettings.FormMainTableStyle.CssClass = "AYEditForm";
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="GridKey"></param>
|
|
/// <param name="g"></param>
|
|
public static void GridSetLayout(string GridKey, Telerik.Web.UI.RadGrid g)
|
|
{
|
|
|
|
if (gGridLastViews.Contains(GridKey))
|
|
{
|
|
//First hide all the columns
|
|
foreach (GridColumn gc in g.MasterTableView.Columns)
|
|
{
|
|
//If the column is preset as display=false then
|
|
//we don't want to mess with it so only set invisible (do not render)
|
|
//columns that are not set to display=false;
|
|
if(gc.Display)
|
|
gc.Visible = false;
|
|
}
|
|
|
|
|
|
g.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
|
|
//Get the total width of all visible columns so that
|
|
//we can set their width by percentage below
|
|
//this is because the widths come from a winform app and
|
|
//so the only way to replicate that is by relative percentage
|
|
//double nTotalRowWidth = 0;
|
|
//foreach (DataRow TabRow in Util.gGridLastViews[GridKey].ViewOrder.Rows)
|
|
//{
|
|
// nTotalRowWidth += System.Convert.ToDouble(TabRow["WIDTH"]);
|
|
//}
|
|
|
|
GridColumn c = null;
|
|
int nPosition = 0;
|
|
//Set the order for the first two command columns
|
|
if (g.MasterTableView.Columns.FindByUniqueNameSafe("SelectColumn") != null)
|
|
{
|
|
|
|
c = g.MasterTableView.Columns.FindByUniqueNameSafe("SelectColumn");
|
|
c.Visible = true;
|
|
c.OrderIndex = nPosition++;
|
|
c.HeaderStyle.Width = System.Web.UI.WebControls.Unit.Pixel(24);
|
|
//24=16 for image + 8 for inter column padding so text doesn't run together
|
|
}
|
|
|
|
if (g.MasterTableView.Columns.FindByUniqueNameSafe("EditColumn") != null)
|
|
{
|
|
|
|
c = g.MasterTableView.Columns.FindByUniqueNameSafe("EditColumn");
|
|
c.Visible = true;
|
|
c.OrderIndex = nPosition++;
|
|
c.HeaderStyle.Width = System.Web.UI.WebControls.Unit.Pixel(24);
|
|
//24=16 for image + 8 for inter column padding so text doesn't run together
|
|
}
|
|
|
|
|
|
//show the columns that are in the order collection
|
|
//And set their properties such as width etc
|
|
foreach (DataRow TabRow in Util.gGridLastViews[GridKey].ViewOrder.Rows)
|
|
{
|
|
string columnName = TabRow["UI"].ToString();
|
|
c = g.MasterTableView.Columns.FindByUniqueNameSafe(columnName);
|
|
if (c != null)
|
|
{
|
|
|
|
//c = g.MasterTableView.Columns.FindByUniqueName(columnName);
|
|
c.Visible = true;
|
|
c.OrderIndex = nPosition++;
|
|
|
|
|
|
//double nPercentageWidth = (System.Convert.ToDouble(TabRow["WIDTH"]) / nTotalRowWidth) * 100;
|
|
////Tested against winform on same screen dimensions a factor
|
|
////of 15% smaller for each column seems to be ideal to get same
|
|
////amount of text displayed in each column and account for
|
|
////command columns
|
|
//nPercentageWidth = nPercentageWidth * .98;
|
|
|
|
//nPercentageWidth = (int)nPercentageWidth;
|
|
//c.HeaderStyle.Width = System.Web.UI.WebControls.Unit.Percentage(nPercentageWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Delete column last (unless there is a bank column)
|
|
if (g.Columns.FindByUniqueNameSafe("DeleteColumn") != null)
|
|
{
|
|
|
|
c = g.MasterTableView.Columns.FindByUniqueNameSafe("DeleteColumn");
|
|
c.Visible = true;
|
|
c.OrderIndex = nPosition++;
|
|
c.HeaderStyle.Width = System.Web.UI.WebControls.Unit.Pixel(24);
|
|
//24=16 for image + 8 for inter column padding so text doesn't run together
|
|
|
|
|
|
}
|
|
|
|
//Bank column
|
|
if (g.Columns.FindByUniqueNameSafe("BankColumn") != null)
|
|
{
|
|
|
|
c = g.MasterTableView.Columns.FindByUniqueNameSafe("BankColumn");
|
|
c.Visible = true;
|
|
c.OrderIndex = nPosition++;
|
|
c.HeaderStyle.Width = System.Web.UI.WebControls.Unit.Pixel(24);
|
|
//24=16 for image + 8 for inter column padding so text doesn't run together
|
|
}
|
|
|
|
|
|
//Order index must be set even for columns that are not covered above
|
|
//otherwise no columns will appear in correct order
|
|
//this is a telerik bug and should be reported
|
|
foreach (GridColumn y in g.MasterTableView.Columns)
|
|
{
|
|
if (y.OrderIndex == -1)
|
|
y.OrderIndex = nPosition++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="g"></param>
|
|
/// <param name="VisibleColumns"></param>
|
|
public static void GridTCreateColumns(object obj, Telerik.Web.UI.RadGrid g, params string[] VisibleColumns)
|
|
{
|
|
List<string> vizlist = new List<string>(VisibleColumns);
|
|
|
|
//Inspect the public properties in the business collection object
|
|
//find the businesbase derived object
|
|
//iterate it's properties and generate grid columns accordingly
|
|
foreach (PropertyInfo fi in obj.GetType().GetProperties())
|
|
{
|
|
if (fi.PropertyType.IsPublic && fi.PropertyType.BaseType == typeof(CSLA.BusinessBase))
|
|
{
|
|
foreach (PropertyInfo pi in fi.PropertyType.GetProperties())
|
|
{
|
|
if (vizlist.Contains(pi.Name))
|
|
{
|
|
Telerik.Web.UI.GridBoundColumn c = new Telerik.Web.UI.GridBoundColumn();
|
|
c.HeaderText = pi.Name;
|
|
c.DataField = pi.Name;
|
|
if (pi.PropertyType == typeof(System.Object))
|
|
c.DataType = typeof(DateTime);
|
|
else
|
|
c.DataType = pi.PropertyType;
|
|
g.MasterTableView.Columns.Add(c);
|
|
}
|
|
|
|
}
|
|
//split now because there could be more than one variation
|
|
//of the same property type, i.e. more than one type of indexer (string, int etc)
|
|
//which would result in adding all the same columns again
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Custom Fields
|
|
/// <summary>
|
|
/// Returns true if there are custom fields to be shown for object passed in
|
|
/// used for leftnav
|
|
/// </summary>
|
|
/// <param name="sObject"></param>
|
|
/// <returns></returns>
|
|
static public bool ShowCustomFields(string sObject)
|
|
{
|
|
ObjectCustomFields ocf = ObjectCustomFields.GetItems(sObject);
|
|
if (ocf.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
foreach (ObjectCustomField f in ocf)
|
|
{
|
|
if (f.Visible)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Displays within an placeholder control
|
|
/// a series of controls for editing custom fields
|
|
/// and populates them with their values
|
|
/// </summary>
|
|
/// <param name="sObject"></param>
|
|
/// <param name="bizobject"></param>
|
|
/// <param name="CustDiv"></param>
|
|
/// <param name="ph"></param>
|
|
/// <returns></returns>
|
|
static public bool ShowCustomFields(string sObject, object BizObject, HtmlGenericControl CustDiv, PlaceHolder ph, bool ReadOnly,
|
|
string sSharedCalendarID, string sSharedTimeViewID)
|
|
{
|
|
|
|
|
|
ObjectCustomFields ocf = ObjectCustomFields.GetItems(sObject);
|
|
if (ocf.Count == 0)
|
|
{
|
|
CustDiv.Visible = false;
|
|
return false;
|
|
}
|
|
bool bAtLeastOneFieldIsVisible = false;
|
|
foreach (ObjectCustomField f in ocf)
|
|
{
|
|
if (f.Visible)
|
|
{
|
|
bAtLeastOneFieldIsVisible = true;
|
|
break;
|
|
}
|
|
|
|
}
|
|
if (!bAtLeastOneFieldIsVisible)
|
|
{
|
|
CustDiv.Visible = false;
|
|
return false;
|
|
}
|
|
|
|
//OK, we have fields to show, let's get showing...
|
|
//Case 305
|
|
ph.Controls.Clear();
|
|
|
|
int x = 0;
|
|
foreach (ObjectCustomField f in ocf)
|
|
{
|
|
if (f.Visible)
|
|
{
|
|
ph.Controls.Add(new LiteralControl("<div class=\"fld\">\r\n"));
|
|
Label lbl = new Label();
|
|
lbl.Text = LocaleText(sObject + ".Label." + f.FieldName) + ":";
|
|
lbl.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
ph.Controls.Add(lbl);
|
|
|
|
ph.Controls.Add(new LiteralControl("<br>"));
|
|
#region Set by field type
|
|
switch (f.FieldType)
|
|
{
|
|
case FormFieldDataTypes.Currency:
|
|
{
|
|
TextBox c = new TextBox();
|
|
c.ID = "Custom" + x.ToString();
|
|
c.EnableViewState = true;
|
|
if (BizObject != null)
|
|
{
|
|
object o = GetObjectValueInCustomField(x, BizObject);
|
|
|
|
if (o == null || o == System.DBNull.Value || o.ToString() == "")
|
|
o = "0";
|
|
|
|
decimal d = 0;
|
|
if (!decimal.TryParse(o.ToString(), out d))
|
|
d = 0;
|
|
c.Text = d.ToString("c");
|
|
}
|
|
|
|
c.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
c.ReadOnly = ReadOnly;
|
|
ph.Controls.Add(c);
|
|
|
|
}
|
|
break;
|
|
case FormFieldDataTypes.DateOnly:
|
|
{
|
|
Telerik.Web.UI.RadDatePicker c = new Telerik.Web.UI.RadDatePicker();
|
|
c.ID = "Custom" + x.ToString();
|
|
c.DateInput.DateFormat = "d";
|
|
c.EnableViewState = true;
|
|
//case 911
|
|
if (!string.IsNullOrEmpty(sSharedCalendarID))
|
|
c.SharedCalendarID = sSharedCalendarID;
|
|
c.MaxDate = DateTime.MaxValue;
|
|
c.MinDate = DateTime.MinValue;
|
|
|
|
if (BizObject != null)
|
|
{
|
|
object o = GetObjectValueInCustomField(x, BizObject);
|
|
c.DbSelectedDate = ParseDateToDbValue(o);
|
|
}
|
|
// c.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
c.Enabled = !ReadOnly;
|
|
ph.Controls.Add(c);
|
|
}
|
|
break;
|
|
case FormFieldDataTypes.DateTime:
|
|
{
|
|
Telerik.Web.UI.RadDateTimePicker c = new Telerik.Web.UI.RadDateTimePicker();
|
|
c.ID = "Custom" + x.ToString();
|
|
c.DateInput.DateFormat = "g";
|
|
c.EnableViewState = true;
|
|
|
|
//Case 911: Efficiency booster if users have a lot of or at least two calendar or timeview popups
|
|
if (!string.IsNullOrEmpty(sSharedCalendarID))
|
|
c.SharedCalendarID = sSharedCalendarID;
|
|
if (!string.IsNullOrEmpty(sSharedTimeViewID))
|
|
c.SharedTimeViewID = sSharedTimeViewID;
|
|
|
|
c.MaxDate = DateTime.MaxValue;
|
|
c.MinDate = DateTime.MinValue;
|
|
//c.TimeView.StartTime = new TimeSpan(8, 0, 0);
|
|
//c.TimeView.EndTime = new TimeSpan(21, 15, 0);
|
|
//c.TimeView.Interval = new TimeSpan(0, 15, 0);
|
|
//c.TimeView.HeaderText = "";
|
|
//c.TimeView.Columns = 4;
|
|
|
|
if (BizObject != null)
|
|
{
|
|
object o = GetObjectValueInCustomField(x, BizObject);
|
|
c.DbSelectedDate = ParseDateToDbValue(o);
|
|
}
|
|
|
|
|
|
|
|
c.Enabled = !ReadOnly;
|
|
ph.Controls.Add(c);
|
|
}
|
|
|
|
break;
|
|
case FormFieldDataTypes.Number:
|
|
{
|
|
TextBox c = new TextBox();
|
|
c.ID = "Custom" + x.ToString();
|
|
if (BizObject != null)
|
|
{
|
|
object o = GetObjectValueInCustomField(x, BizObject);
|
|
if (o == null || o == System.DBNull.Value || o.ToString() == "")
|
|
o = "0";
|
|
decimal d = 0;
|
|
if (!decimal.TryParse(o.ToString(), out d))
|
|
d = 0;
|
|
c.Text = d.ToString("g29");
|
|
}
|
|
c.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
c.ReadOnly = ReadOnly;
|
|
ph.Controls.Add(c);
|
|
|
|
}
|
|
break;
|
|
case FormFieldDataTypes.Text:
|
|
{
|
|
TextBox c = new TextBox();
|
|
c.ID = "Custom" + x.ToString();
|
|
if (BizObject != null)
|
|
{
|
|
object o = GetObjectValueInCustomField(x, BizObject);
|
|
if (o == null || o == System.DBNull.Value || o.ToString() == "")
|
|
o = "";
|
|
c.Text = o.ToString();
|
|
}
|
|
c.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
c.ReadOnly = ReadOnly;
|
|
ph.Controls.Add(c);
|
|
|
|
}
|
|
break;
|
|
case FormFieldDataTypes.TimeOnly:
|
|
{
|
|
Telerik.Web.UI.RadTimePicker c = new Telerik.Web.UI.RadTimePicker();
|
|
c.ID = "Custom" + x.ToString();
|
|
//case 911
|
|
if (!string.IsNullOrEmpty(sSharedTimeViewID))
|
|
c.SharedTimeViewID = sSharedTimeViewID;
|
|
|
|
c.EnableViewState = true;
|
|
if (BizObject != null)
|
|
{
|
|
object o = GetObjectValueInCustomField(x, BizObject);
|
|
c.DbSelectedDate = ParseDateToDbValue(o);
|
|
}
|
|
// c.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
c.Enabled = !ReadOnly;
|
|
ph.Controls.Add(c);
|
|
}
|
|
break;
|
|
case FormFieldDataTypes.TrueFalse:
|
|
{
|
|
CheckBox c = new CheckBox();
|
|
c.ID = "Custom" + x.ToString();
|
|
if (BizObject != null)
|
|
{
|
|
object o = GetObjectValueInCustomField(x, BizObject);
|
|
if (o == null || o == System.DBNull.Value || o.ToString() == "")
|
|
o = false;
|
|
c.Checked = System.Convert.ToBoolean(o);
|
|
}
|
|
c.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
|
c.Enabled = !ReadOnly;
|
|
ph.Controls.Add(c);
|
|
}
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
#endregion set by field type
|
|
|
|
ph.Controls.Add(new LiteralControl("</div>"));
|
|
//ph.Controls.Add(new LiteralControl("<br>"));
|
|
|
|
//dt.Rows.Add(new object[] { f.FieldName, f.FieldType, LocaleText.GetLocalizedText(sObject + ".Label." + f.FieldName), null });
|
|
|
|
}
|
|
x++;
|
|
}
|
|
return true;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get a custom field's value in the biz object
|
|
/// </summary>
|
|
/// <param name="position">customX</param>
|
|
/// <param name="BizObject"></param>
|
|
/// <returns></returns>
|
|
private static object GetObjectValueInCustomField(int position, object BizObject)
|
|
{
|
|
return (object)BizObject.GetType().GetProperty("Custom" + position.ToString()).GetValue(BizObject, null);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Suck the custom field values back into the biz object
|
|
/// </summary>
|
|
/// <param name="BizObject"></param>
|
|
/// <param name="ph"></param>
|
|
public static void GetCustomFields(string sObject, object BizObject, PlaceHolder ph)
|
|
{
|
|
|
|
foreach (Control c in ph.Controls)
|
|
{
|
|
|
|
if (c is Literal) continue;
|
|
if (c is LiteralControl) continue;
|
|
if (c is Label) continue;
|
|
object val = "";
|
|
bool bIsDate = false;
|
|
switch (c.GetType().ToString())
|
|
{
|
|
|
|
case "System.Web.UI.WebControls.TextBox":
|
|
val = ((System.Web.UI.WebControls.TextBox)c).Text;
|
|
break;
|
|
case "Telerik.Web.UI.RadDateTimePicker":
|
|
val = ((Telerik.Web.UI.RadDateTimePicker)c).DbSelectedDate;
|
|
bIsDate = true;
|
|
break;
|
|
case "Telerik.Web.UI.RadTimePicker":
|
|
val = ((Telerik.Web.UI.RadTimePicker)c).DbSelectedDate;
|
|
bIsDate = true;
|
|
break;
|
|
case "Telerik.Web.UI.RadDatePicker":
|
|
val = ((Telerik.Web.UI.RadDatePicker)c).DbSelectedDate;
|
|
bIsDate = true;
|
|
break;
|
|
|
|
case "System.Web.UI.WebControls.CheckBox":
|
|
val = ((System.Web.UI.WebControls.CheckBox)c).Checked;
|
|
break;
|
|
default:
|
|
throw new ApplicationException("GetCustomFields unknown control type:" + c.GetType().ToString());
|
|
|
|
}
|
|
if (val == null || val == System.DBNull.Value) val = "";
|
|
if (bIsDate && val.ToString() != "" && val is System.DateTime)
|
|
{
|
|
BizObject.GetType().GetProperty(c.ID).SetValue(BizObject, ((DateTime)val).ToString(System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat), null);
|
|
}
|
|
else
|
|
{
|
|
//bugbug case 455 is setting props that are bool or currency to "false" or "$0.00" unnecessarily
|
|
//triggering isdirty = true unnecessarily
|
|
//However once we have proper currency controls from telerik than we can flesh this out more
|
|
//as is now the user just needs to save once then it's never dirty unless they actually edit
|
|
BizObject.GetType().GetProperty(c.ID).SetValue(BizObject, val.ToString(), null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region String to web conversions
|
|
|
|
public static string StringWebify(string input)
|
|
{
|
|
if (string.IsNullOrEmpty(input)) return "";
|
|
return input.Replace("\r\n", "<br/>")
|
|
.Replace("\r", "<br/>")
|
|
.Replace("\n", "<br/>");
|
|
|
|
}
|
|
|
|
public static string StringJavaScriptify(string input)
|
|
{
|
|
return input.Replace(@"\", @"\\").Replace("\"", "\\").Replace("\n", @"\n").Replace("\r", @"\r").Replace("\t", @"\t");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sUrl"></param>
|
|
/// <returns></returns>
|
|
public static string StringToHTTP(string sUrl)
|
|
{
|
|
|
|
if (sUrl.ToLower().StartsWith("http://"))
|
|
return sUrl;
|
|
else
|
|
return "http://" + sUrl;
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Form helpers including Biz object editing factory
|
|
|
|
|
|
//doesn't work and not called from anywhere anyway
|
|
//when add new delete methods will find better alternative to this
|
|
//public static void FormAddDeleteConfirmScript(Page p)
|
|
//{
|
|
|
|
// p.ClientScript.RegisterClientScriptBlock(p.GetType(),"delconfirm","<script type='text/javascript'> " +
|
|
// "function OnClientItemClickingHandler(sender, eventArgs) " +
|
|
// "{if (eventArgs.Item.Value == 'LT:UI.Command.Delete'){return confirm('" +
|
|
// Util.LocaleText("UI.Label.DeletePrompt") + "');}} " +
|
|
// "</script> ");
|
|
//}
|
|
|
|
public static void SessionAddKeepAlive(Page p)
|
|
{
|
|
|
|
|
|
int int_MilliSecondsTimeOut = (p.Session.Timeout * 60000) - 30000;
|
|
string str_Script = @"<script type='text/javascript'>var count=0;" +
|
|
"function Reconnect(){ " +
|
|
"count++; " +
|
|
"window.status = 'Link to Server Refreshed ' + count.toString()+' time(s)' ; " +
|
|
" " +
|
|
"var img = new Image(1,1); " +
|
|
" " +
|
|
"img.src = 'Reconnect.aspx?xxx='+escape(new Date()); " +
|
|
" " +
|
|
"} " +
|
|
" " +
|
|
"window.setInterval('Reconnect()', " +
|
|
int_MilliSecondsTimeOut.ToString() +
|
|
@"); </script>";
|
|
|
|
p.ClientScript.RegisterClientScriptBlock(p.GetType(),"Reconnect", str_Script);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// centralized popup window for opening sub forms etc
|
|
/// this way we can modify centrally as required in future
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
/// <param name="toUrl"></param>
|
|
public static void OpenEditWindow(Page p, string sBizObject, Guid ID)
|
|
{
|
|
string toUrl = "";
|
|
switch (sBizObject)
|
|
{
|
|
case "Part":
|
|
toUrl = "PartInventoryView.aspx?id=" + ID.ToString();
|
|
break;
|
|
case "WikiPage":
|
|
toUrl = "Wiki?id=" + ID.ToString();
|
|
break;
|
|
|
|
default:
|
|
{
|
|
if (ID == Guid.Empty)
|
|
toUrl = sBizObject + "Edit.aspx";
|
|
else
|
|
toUrl = sBizObject + "Edit.aspx?id=" + ID.ToString();
|
|
}
|
|
break;
|
|
}
|
|
OpenEditWindowAddScript(p, toUrl);
|
|
}
|
|
/// <summary>
|
|
/// Overload for biz object instead of text
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
/// <param name="BizObject"></param>
|
|
/// <param name="ID"></param>
|
|
public static void OpenEditWindow(Page p, RootObjectTypes BizObject, Guid ID)
|
|
{
|
|
OpenEditWindow(p, BizObject.ToString(), ID);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Opener for wiki pages that take a type and ID url
|
|
///
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
/// <param name="tid"></param>
|
|
public static void OpenWikiPage(Page p, TypeAndID tid)
|
|
{
|
|
string toUrl = "wiki.aspx" + tid.ToAyaURLQueryParameter();
|
|
OpenEditWindowAddScript(p, toUrl);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles the actual work of creating the open script
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
/// <param name="toUrl"></param>
|
|
private static void OpenEditWindowAddScript(Page p, string toUrl)
|
|
{
|
|
p.Response.Write("<script>\r\n");
|
|
p.Response.Write("window.open('" + toUrl + "');");
|
|
p.Response.Write("\r\n</script>");
|
|
}
|
|
|
|
|
|
//Note: this example was used and also contains example of how to do this
|
|
//with an async callback: http://www.telerik.com/community/forums/thread/b311D-bkhmtk.aspx
|
|
public static void PopupAlert(Page p, string sMessage)
|
|
{
|
|
PopupAlert(p, sMessage, "");
|
|
}
|
|
public static void PopupAlert(Page p, string sMessage, string sTitle)
|
|
{
|
|
string popscript = string.Format(@"function _showAlert() {{
|
|
Sys.Application.remove_load(_showAlert);
|
|
radalert('{0}', 300, 200,'{1}');
|
|
}};
|
|
Sys.Application.add_load(_showAlert);", StringWebify(sMessage),StringWebify(sTitle));
|
|
p.ClientScript.RegisterStartupScript(typeof(string), "PopAlert", popscript, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Use to open a work order or quote or pm that
|
|
/// a user has typed in the number of in the direct open section of the menu
|
|
/// above schedule and main grid form
|
|
///
|
|
/// Added to comply with case 58 regionalization
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
/// <param name="sNumber"></param>
|
|
/// <param name="wotype"></param>
|
|
public static void DirectOpenWO(Page p, string sNumber, WorkorderTypes wotype)
|
|
{
|
|
Guid g = WorkorderInternalIDFetcher.GetItem(sNumber, wotype);
|
|
if (g != Guid.Empty && (AyaBizUtils.InYourRegion(ObjectRegionIDFetcher.ObjectRegion(new TypeAndID(RootObjectTypes.Workorder, g)))))//case 58
|
|
OpenEditWindow(p, RootObjectTypes.Workorder, g);
|
|
}
|
|
#endregion
|
|
|
|
#region Record History
|
|
public static string RecordHistoryText(Guid Creator, Guid Modifier, string CreatedDate, string ModifiedDate)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append(LocaleText("UI.RecordHistory.Creator"));
|
|
sb.Append(": ");
|
|
sb.Append(GetName(Creator));
|
|
sb.Append("<br />");
|
|
|
|
sb.Append(LocaleText("UI.RecordHistory.Created"));
|
|
sb.Append(": ");
|
|
sb.Append(CreatedDate);
|
|
sb.Append("<br /><br />");
|
|
|
|
sb.Append(LocaleText("UI.RecordHistory.Modifier"));
|
|
sb.Append(": ");
|
|
sb.Append(GetName(Modifier));
|
|
sb.Append("<br />");
|
|
|
|
sb.Append(LocaleText("UI.RecordHistory.Modified"));
|
|
sb.Append(": ");
|
|
sb.Append(ModifiedDate);
|
|
sb.Append("<br />");
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Build up a name string from passed in user record id
|
|
/// </summary>
|
|
/// <param name="UserID"></param>
|
|
/// <returns></returns>
|
|
private static string GetName(Guid UserID)
|
|
{
|
|
UserPickList upl = UserPickList.GetListOfOneSpecificUser(UserID);
|
|
if (upl.Count == 0) return "-";
|
|
|
|
return upl[0].Name;
|
|
|
|
}
|
|
#endregion Record history
|
|
|
|
#region Parsers
|
|
public static decimal ParseDecimal(object s)
|
|
{
|
|
if (s == null) return 0;
|
|
decimal d = 0;
|
|
//Case 512 - as part of fix for 512 discovered this method wasn't handling
|
|
//currency at all, wonder what else wasn't working before this?
|
|
if (!decimal.TryParse(s.ToString(), out d))
|
|
decimal.TryParse(s.ToString(),
|
|
NumberStyles.Currency,
|
|
System.Threading.Thread.CurrentThread.CurrentCulture, out d);
|
|
return d;
|
|
}
|
|
|
|
public static bool ParseBool(object s)
|
|
{
|
|
if (s == null) return false;
|
|
bool b = false;
|
|
bool.TryParse(s.ToString(), out b);
|
|
return b;
|
|
}
|
|
|
|
public static int ParseInt(object s)
|
|
{
|
|
if (s == null) return 0;
|
|
int d = 0;
|
|
int.TryParse(s.ToString(), out d);
|
|
return d;
|
|
}
|
|
|
|
public static long ParseLong(object s)
|
|
{
|
|
if (s == null) return 0;
|
|
long d = 0;
|
|
long.TryParse(s.ToString(), out d);
|
|
return d;
|
|
}
|
|
|
|
|
|
//Attempts to parse a string based on current thread culture
|
|
//if that fails then tries the invariant culture (to catch US users who have accidentally
|
|
//set their web browser to some other language or international users
|
|
//browsing through a US site for the most part as it won't work
|
|
//for other circumstances, so supporting most common scenario)
|
|
//if it can't figure it out at all then it will return an empty dbnull date
|
|
//the ideal fix is of course to convert dates to the invariant culture when they are
|
|
//first entered into AyaNova in custom fields where this is mostly used
|
|
//
|
|
public static object ParseDateToDbValue(object s)
|
|
{
|
|
if (s == null || s.ToString() == "") return System.DBNull.Value;
|
|
|
|
DateTime dt = new DateTime();
|
|
if (!DateTime.TryParse(s.ToString(), out dt))
|
|
if (!DateTime.TryParse(s.ToString(), System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat, System.Globalization.DateTimeStyles.None, out dt))
|
|
return System.DBNull.Value;
|
|
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// True if object contains a non empty guid
|
|
/// false if object is null or contains an empty guid
|
|
/// </summary>
|
|
/// <param name="s"></param>
|
|
/// <returns></returns>
|
|
public static bool GuidSelected(object s)
|
|
{
|
|
if (s == null) return false;
|
|
Guid g = new Guid(s.ToString());
|
|
if (g == Guid.Empty) return false;
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// convert object to string, if null returns empty string
|
|
/// </summary>
|
|
/// <param name="o"></param>
|
|
/// <returns></returns>
|
|
public static string ObjectToString(object o)
|
|
{
|
|
if (o == null) return "";
|
|
return o.ToString();
|
|
}
|
|
|
|
//case 1922
|
|
/// <summary>
|
|
/// Convert string with linefeeds only (\n) but no carriage returns (\r) to
|
|
/// CR/LF combination instead (\r\n).
|
|
/// </summary>
|
|
/// <param name="s"></param>
|
|
/// <returns></returns>
|
|
public static string ParseMultiLineText(object o)
|
|
{
|
|
string s = ObjectToString(o);
|
|
//Only do the conversion if there are not existing \r
|
|
if (!s.Contains("\r\n"))
|
|
return s.Replace("\n", "\r\n");
|
|
return s;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Graphic helpers
|
|
/// <summary>
|
|
/// Invert a color in such a manner as to render text on top of the color readable
|
|
/// </summary>
|
|
/// <param name="col"></param>
|
|
/// <returns></returns>
|
|
static public System.Drawing.Color InvertColor(System.Drawing.Color col)
|
|
{
|
|
|
|
int nSourceColor = col.R + col.G + col.B;
|
|
|
|
int r = 255 - col.R;
|
|
int g = 255 - col.G;
|
|
int b = 255 - col.B;
|
|
|
|
int nInvertColor = r + g + b;
|
|
|
|
System.Drawing.Color invert;
|
|
if (nSourceColor - nInvertColor < 28)
|
|
invert = System.Drawing.Color.White;
|
|
else
|
|
invert = System.Drawing.Color.FromArgb(r, g, b);
|
|
return invert;
|
|
}
|
|
#endregion
|
|
|
|
#region support info
|
|
/// <summary>
|
|
/// User specific info
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
static public string FullSettingsInfo()
|
|
{
|
|
User uCurrent = CurrentUser;
|
|
Region RegionalSettings = Region.GetItem(CurrentUser.RegionID);
|
|
Global globalSettings = GlobalSettings;
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
BusinessPrincipal p = ((BusinessPrincipal)Thread.CurrentPrincipal);
|
|
sb.Append("\tUser settings\r\n");
|
|
sb.Append("\t\tUser: " + uCurrent.Name(ScheduleableUserNameDisplayFormats.FirstLast) + "\r\n");
|
|
sb.Append("\t\tLanguage: " + uCurrent.DefaultLanguage + "\r\n");
|
|
sb.Append("\t\tUserType: " + uCurrent.UserType.ToString() + "\r\n");
|
|
sb.Append("\t\tSubContractor: " + uCurrent.SubContractor.ToString() + "\r\n");
|
|
sb.Append("\t\tRegion: " + RegionalSettings == null ? "-" : RegionalSettings.Name + "\r\n");
|
|
sb.Append("\tGlobal settings\r\n");
|
|
sb.Append("\t\tLanguage: " + globalSettings.DefaultLanguage + "\r\n");
|
|
sb.Append("\t\tUse Notification services: " + globalSettings.UseNotification.ToString() + "\r\n");
|
|
sb.Append("\t\tCJK Index: " + globalSettings.CJKIndex.ToString() + "\r\n");
|
|
sb.Append("\t\tUse inventory: " + globalSettings.UseInventory.ToString() + "\r\n");
|
|
//sb.Append("\t\tUse regions: " + globalSettings.UseRegions.ToString() + "\r\n");
|
|
return sb.ToString();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// General info
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
static public string FullSupportInfo()
|
|
{
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append(
|
|
"\tMachine name: " + System.Environment.MachineName + "\r\n" +
|
|
//"\tAyaNova Connection: " + DiagnosticConnectionInfo + "\r\n" +
|
|
//"\tGenerate PM and Notify from this connection: " + IAmAGenerator.ToString() + "\r\n" +
|
|
"\tOS user name: " + System.Environment.UserName + "\r\n" +
|
|
//"\tNetworked: " + SystemInformation.Network.ToString() + "\r\n" +
|
|
"\tOS user domain name: " + System.Environment.UserDomainName + "\r\n" +
|
|
//"\tOS version: " + System.Environment.OSVersion.ToString() + "\r\n" +
|
|
OSVersionInfo.FullOperatingSystemInformationForDisplay + "\r\n" +
|
|
"\tSystem folder: " + System.Environment.SystemDirectory + "\r\n" +
|
|
|
|
"\tCLR version: " + System.Environment.Version.ToString() + "\r\n" +
|
|
|
|
"\tCurrent directory: " + System.Environment.CurrentDirectory + "\r\n");
|
|
|
|
sb.Append(
|
|
"\tWorking set: " + System.Environment.WorkingSet.ToString() + "\r\n" +
|
|
//"\tPrimary monitor size: " + SystemInformation.PrimaryMonitorSize.ToString() + "\r\n" +
|
|
|
|
"\tLocale current culture: " + System.Threading.Thread.CurrentThread.CurrentCulture.EnglishName + "\r\n" +
|
|
"\tLocale currency symbol: " + System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol + "\r\n" +
|
|
"\tLocale short date pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern + "\r\n" +
|
|
"\tLocale short time pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern + "\r\n");
|
|
|
|
|
|
Assembly a = Assembly.GetExecutingAssembly();
|
|
AssemblyName an = a.GetName();
|
|
sb.Append("\tAyaNova WBI version: " + Version + "\r\n");
|
|
//Hotfix if any
|
|
if (HotfixVersion > 0)
|
|
sb.AppendLine("\t(Patch " + HotfixVersion.ToString() + ")");
|
|
|
|
|
|
// sb.Append("\tPrimary assembly location: " + an.CodeBase + "\r\n");
|
|
|
|
sb.Append("\t\tReferences:\r\n");
|
|
foreach (AssemblyName arn in a.GetReferencedAssemblies())
|
|
{
|
|
sb.Append("\t\t" + arn.Name + " " + arn.Version.ToString() + "\r\n");
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(AyaBizUtils.PortalDiagnostics))
|
|
{
|
|
sb.Append("DataPortal diagnostics:\r\n");
|
|
sb.Append(AyaBizUtils.PortalDiagnostics);
|
|
}
|
|
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
|
|
|
|
#endregion supportinfo
|
|
|
|
#region SQL error
|
|
/// <summary>
|
|
/// translates obscure sql errors into html compatible, human readable form,
|
|
/// and returns
|
|
/// </summary>
|
|
/// <param name="ex"></param>
|
|
static public string ReportSQLError(Exception ex)
|
|
{
|
|
if (ex.InnerException == null) throw ex;
|
|
string sErrorMessage = "";
|
|
if (ex.InnerException is FbException)
|
|
{//TODO: this is forcing a dependancy on the firebird sql driver
|
|
//Move this down to the database level
|
|
FbException fex = (FbException)ex.InnerException;
|
|
switch (fex.ErrorCode)
|
|
{
|
|
case 335544466:
|
|
sErrorMessage = LocaleText("Error.DB.ForeignKeyViolation") + "\r\n\r\n----------------------------------------\r\n" + fex.Message;
|
|
break;
|
|
default://rethrow it, it's nothing we can handle here
|
|
throw fex;
|
|
}
|
|
}
|
|
else if (ex.InnerException is System.Data.SqlClient.SqlException)
|
|
{
|
|
System.Data.SqlClient.SqlException sex = (System.Data.SqlClient.SqlException)ex.InnerException;
|
|
|
|
switch (sex.Number)
|
|
{
|
|
case 547:
|
|
sErrorMessage = LocaleText("Error.DB.ForeignKeyViolation") + "\r\n\r\n----------------------------------------\r\n" + sex.Message;
|
|
break;
|
|
default://rethrow it, it's nothing we can handle here
|
|
throw sex;
|
|
}
|
|
}
|
|
else
|
|
throw ex.InnerException;
|
|
|
|
return StringWebify(sErrorMessage);
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Telerik RadDatePicker time bug workaround (Case 455)
|
|
///// <summary>
|
|
/////
|
|
/////
|
|
///// Deprecated, no longer necessary telerik control now gets correct seconds as well
|
|
/////
|
|
/////
|
|
///// Due to bug in Telerik RadDatePicker as of this version
|
|
///// it loses the seconds when populated on a web form
|
|
///// so it appears that datetimepicker controls have all be edited when in fact
|
|
///// they have not
|
|
/////
|
|
///// This method will compare all but the seconds to determine equality and return the
|
|
///// dtDest if they are equal in all but seconds else dtSource
|
|
///// </summary>
|
|
///// <param name="dtDest"></param>
|
|
///// <param name="dtSource"></param>
|
|
///// <returns></returns>
|
|
//public static DateTime GetDateIfChanged(object Dest, object Source)
|
|
//{
|
|
// //Case 582 changes
|
|
// DateTime dtDest;
|
|
// DateTime dtSource;
|
|
// if (Source == null || Source is System.DBNull)
|
|
// return DateTime.MinValue;
|
|
// else
|
|
// dtSource = (DateTime)Source;
|
|
|
|
// if (Dest == null || Dest is System.DBNull)
|
|
// dtDest = DateTime.MinValue;
|
|
// else
|
|
// dtDest = (DateTime)Dest;
|
|
|
|
// //dtSource from telerik control is always zero seconds so just
|
|
// //adding the original seconds should do the trick for comparison
|
|
// dtSource=dtSource.AddSeconds(dtDest.Second);
|
|
// dtSource = dtSource.AddMilliseconds(dtDest.Millisecond);
|
|
// if (dtDest.Equals(dtSource))
|
|
// return dtDest;
|
|
|
|
// return dtSource;
|
|
//}
|
|
#endregion
|
|
|
|
#region Case 349
|
|
/// <summary>
|
|
/// Walks the tree of a workorder and compiles all the broken rules
|
|
/// </summary>
|
|
/// <param name="w"></param>
|
|
/// <returns></returns>
|
|
public static string WorkorderBrokenRuleFinder(Workorder w)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("Broken rules in workorder tree\r\n-----------------------------\r\n");
|
|
if (!string.IsNullOrEmpty(w.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder header: \r\n");
|
|
sb.Append(w.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
|
|
foreach (WorkorderItem wi in w.WorkorderItems)
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(wi.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item: (");
|
|
sb.Append(wi.Summary);
|
|
sb.Append(")\r\n");
|
|
sb.Append(wi.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
|
|
#region workorder grandchildren
|
|
foreach (WorkorderItemLabor l in wi.Labors)
|
|
{
|
|
if (!string.IsNullOrEmpty(l.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item labor: \r\n");
|
|
sb.Append(l.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
|
|
foreach (WorkorderItemMiscExpense me in wi.Expenses)
|
|
{
|
|
if (!string.IsNullOrEmpty(me.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item misc expense: \r\n");
|
|
sb.Append(me.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
|
|
foreach (WorkorderItemLoan lo in wi.Loans)
|
|
{
|
|
if (!string.IsNullOrEmpty(lo.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item loan: \r\n");
|
|
sb.Append(lo.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(wi.OutsideService.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item outside service: \r\n");
|
|
sb.Append(wi.OutsideService.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
|
|
foreach (WorkorderItemPartRequest pr in wi.PartRequests)
|
|
{
|
|
if (!string.IsNullOrEmpty(pr.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item part request: \r\n");
|
|
sb.Append(pr.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
|
|
//Case 370 the following was wrongly coded
|
|
//as foreach(workorderitempartREQUEST instead of Part)
|
|
foreach (WorkorderItemPart p in wi.Parts)
|
|
{
|
|
if (!string.IsNullOrEmpty(p.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item part: \r\n");
|
|
sb.Append(p.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
|
|
foreach (WorkorderItemScheduledUser u in wi.ScheduledUsers)
|
|
{
|
|
if (!string.IsNullOrEmpty(u.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item sched. user: \r\n");
|
|
sb.Append(u.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
|
|
foreach (WorkorderItemTask t in wi.Tasks)
|
|
{
|
|
if (!string.IsNullOrEmpty(t.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item task: \r\n");
|
|
sb.Append(t.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
|
|
foreach (WorkorderItemTravel tr in wi.Travels)
|
|
{
|
|
if (!string.IsNullOrEmpty(tr.BrokenRulesText))
|
|
{
|
|
sb.Append("Workorder item travel: \r\n");
|
|
sb.Append(tr.BrokenRulesText);
|
|
sb.Append("\r\n");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
}//foreach workorder item
|
|
|
|
return sb.ToString();
|
|
}//end of method
|
|
#endregion
|
|
|
|
#region MRU case 535
|
|
/// <summary>
|
|
/// Fill an Telerik RadMenuItem panel item
|
|
/// with MRU
|
|
/// </summary>
|
|
/// <param name="ReportKey"></param>
|
|
static public void MRUFillList(Telerik.Web.UI.RadMenuItem topmenuitem)
|
|
{
|
|
topmenuitem.Items.Clear();
|
|
topmenuitem.PostBack = false;
|
|
|
|
//case 1305 - not refreshing properly between sessions, apparently ayabizutils is cached.
|
|
AyaBizUtils.MRU = null;
|
|
|
|
foreach (DataRowView r in AyaBizUtils.MRU.MRU)
|
|
{
|
|
TypeAndID tid = (TypeAndID)r["TID"];
|
|
if (tid.RootObjectType != RootObjectTypes.Vendor)
|
|
{
|
|
Telerik.Web.UI.RadMenuItem li = new Telerik.Web.UI.RadMenuItem();
|
|
li.Text = r["Description"].ToString();
|
|
li.Value = "MRU" + tid.ToString();
|
|
topmenuitem.Items.Add(li);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
#endregion mru
|
|
|
|
#region Wiki / ayaFile stuff case 73
|
|
|
|
#region WikiPage menu item insertion
|
|
/// <summary>
|
|
/// Insert a menu item for opening a wiki page
|
|
/// </summary>
|
|
/// <param name="rm">RadMenu object</param>
|
|
/// <param name="oType">RootObject type</param>
|
|
/// <param name="RootObjectID">RootObjectID</param>
|
|
public static void WikiPageInsertMenuItem(RadMenu rm, RootObjectTypes oType, Guid RootObjectID)
|
|
{
|
|
|
|
Telerik.Web.UI.RadMenuItem miWiki = new Telerik.Web.UI.RadMenuItem();
|
|
miWiki.ToolTip = Util.LocaleText("O.WikiPage");
|
|
miWiki.ImageUrl = "~/graphics/Wiki24.png";
|
|
miWiki.NavigateUrl = "Wiki.aspx" + TypeAndID.ToAyaURLQueryParameter(oType, RootObjectID);
|
|
miWiki.Target = "_blank";
|
|
rm.Items.Add(miWiki);
|
|
|
|
}
|
|
|
|
#endregion wikipage menu item insertion
|
|
|
|
#region AyaImage handler
|
|
/// <summary>
|
|
/// Used to serve up images based on AyaImage:guid tag
|
|
/// </summary>
|
|
/// <param name="response"></param>
|
|
/// <param name="ImageID"></param>
|
|
public static void WriteAyaImageToResponse(HttpResponse Response, Guid ImageID)
|
|
{
|
|
try
|
|
{
|
|
|
|
System.IO.MemoryStream ms = AyaFile.GetItem(ImageID).GetContent();
|
|
Response.Clear();
|
|
Response.ContentType = "image/png";
|
|
ms.WriteTo(Response.OutputStream);
|
|
ms.Dispose();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex.InnerException != null)
|
|
ex = ex.InnerException;
|
|
if (ex is GZTW.AyaNova.BLL.FetchException)
|
|
Response.Write("[Image not found in DataBase: " + ImageID.ToString() + "]");
|
|
else
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion ayaimage handler
|
|
|
|
#region AyaFile handler
|
|
/// <summary>
|
|
/// Used to delete a file based on it's tag, called by AyaFileHandler
|
|
/// </summary>
|
|
/// <param name="Response"></param>
|
|
/// <param name="AyaFileID"></param>
|
|
public static void DeleteAyaFile(HttpResponse Response, Guid AyaFileID, string RedirectUrl)
|
|
{
|
|
AyaFile.DeleteItem(AyaFileID);
|
|
Response.Redirect(RedirectUrl, true);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Used to serve up files based on AyaFile:guid tag
|
|
/// called by AyaFileHandler
|
|
/// </summary>
|
|
/// <param name="response"></param>
|
|
/// <param name="AyaFileID"></param>
|
|
public static void WriteAyaFileToResponse(HttpResponse Response, Guid AyaFileID)
|
|
{
|
|
//
|
|
try
|
|
{
|
|
AyaFile af = AyaFile.GetItem(AyaFileID);
|
|
|
|
System.IO.MemoryStream ms = af.GetContent();
|
|
Response.Clear();
|
|
//Tell the browser it's a file
|
|
Response.AddHeader("content-disposition","attachment; filename=\"" + af.Name + "\"");
|
|
//Tell the browser the mime type so it can offer to open or save if they have the app registered mime type
|
|
Response.ContentType = GetMimeTypeFromFileName(af.Name);
|
|
|
|
ms.WriteTo(Response.OutputStream);
|
|
ms.Dispose();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex.InnerException != null)
|
|
ex = ex.InnerException;
|
|
if (ex is GZTW.AyaNova.BLL.FetchException)
|
|
Response.Write("[File not found in DataBase: " + AyaFileID.ToString() + "]");
|
|
else
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static Dictionary<string, string> dictMimeTypes = null;
|
|
/// <summary>
|
|
/// Some important mime types, don't need them all for this purpose
|
|
/// </summary>
|
|
/// <param name="fileName"></param>
|
|
/// <returns></returns>
|
|
public static string GetMimeTypeFromFileName(string fileName)
|
|
{
|
|
|
|
string sExtension = System.IO.Path.GetExtension(fileName);
|
|
if (string.IsNullOrEmpty(sExtension))
|
|
sExtension = "";
|
|
sExtension = sExtension.ToLowerInvariant();
|
|
|
|
if (dictMimeTypes == null)
|
|
{
|
|
dictMimeTypes = new Dictionary<string, string>();
|
|
//Add specific mime types
|
|
#region mime types
|
|
dictMimeTypes.Add(".7z", "application/x-7z-compressed");
|
|
dictMimeTypes.Add(".7zip", "application/x-7z-compressed");
|
|
dictMimeTypes.Add(".323", "text/h323");
|
|
dictMimeTypes.Add(".acx", "application/internet-property-stream");
|
|
dictMimeTypes.Add(".ai", "application/postscript");
|
|
dictMimeTypes.Add(".aif", "audio/x-aiff");
|
|
dictMimeTypes.Add(".aifc", "audio/aiff");
|
|
dictMimeTypes.Add(".aiff", "audio/aiff");
|
|
dictMimeTypes.Add(".application", "application/x-ms-application");
|
|
dictMimeTypes.Add(".asf", "video/x-ms-asf");
|
|
dictMimeTypes.Add(".asr", "video/x-ms-asf");
|
|
dictMimeTypes.Add(".asx", "video/x-ms-asf");
|
|
dictMimeTypes.Add(".au", "audio/basic");
|
|
dictMimeTypes.Add(".avi", "video/x-msvideo");
|
|
dictMimeTypes.Add(".axs", "application/olescript");
|
|
dictMimeTypes.Add(".bas", "text/plain");
|
|
dictMimeTypes.Add(".bcpio", "application/x-bcpio");
|
|
dictMimeTypes.Add(".bin", "application/octet-stream");
|
|
dictMimeTypes.Add(".bmp", "image/bmp");
|
|
dictMimeTypes.Add(".c", "text/plain");
|
|
dictMimeTypes.Add(".cat", "application/vndms-pkiseccat");
|
|
dictMimeTypes.Add(".cdf", "application/x-cdf");
|
|
dictMimeTypes.Add(".cer", "application/x-x509-ca-cert");
|
|
dictMimeTypes.Add(".clp", "application/x-msclip");
|
|
dictMimeTypes.Add(".cmx", "image/x-cmx");
|
|
dictMimeTypes.Add(".cod", "image/cis-cod");
|
|
dictMimeTypes.Add(".cpio", "application/x-cpio");
|
|
dictMimeTypes.Add(".crd", "application/x-mscardfile");
|
|
dictMimeTypes.Add(".crl", "application/pkix-crl");
|
|
dictMimeTypes.Add(".crt", "application/x-x509-ca-cert");
|
|
dictMimeTypes.Add(".csh", "application/x-csh");
|
|
dictMimeTypes.Add(".css", "text/css");
|
|
dictMimeTypes.Add(".dcr", "application/x-director");
|
|
dictMimeTypes.Add(".deploy", "application/octet-stream");
|
|
dictMimeTypes.Add(".der", "application/x-x509-ca-cert");
|
|
dictMimeTypes.Add(".dib", "image/bmp");
|
|
dictMimeTypes.Add(".dir", "application/x-director");
|
|
dictMimeTypes.Add(".disco", "text/xml");
|
|
dictMimeTypes.Add(".dll", "application/x-msdownload");
|
|
dictMimeTypes.Add(".doc", "application/msword");
|
|
dictMimeTypes.Add(".dot", "application/msword");
|
|
dictMimeTypes.Add(".dvi", "application/x-dvi");
|
|
dictMimeTypes.Add(".dxr", "application/x-director");
|
|
dictMimeTypes.Add(".eml", "message/rfc822");
|
|
dictMimeTypes.Add(".eps", "application/postscript");
|
|
dictMimeTypes.Add(".etx", "text/x-setext");
|
|
dictMimeTypes.Add(".evy", "application/envoy");
|
|
dictMimeTypes.Add(".exe", "application/octet-stream");
|
|
dictMimeTypes.Add(".fif", "application/fractals");
|
|
dictMimeTypes.Add(".flr", "x-world/x-vrml");
|
|
dictMimeTypes.Add(".gif", "image/gif");
|
|
dictMimeTypes.Add(".gtar", "application/x-gtar");
|
|
dictMimeTypes.Add(".gz", "application/x-gzip");
|
|
dictMimeTypes.Add(".h", "text/plain");
|
|
dictMimeTypes.Add(".hdf", "application/x-hdf");
|
|
dictMimeTypes.Add(".hlp", "application/winhlp");
|
|
dictMimeTypes.Add(".hqx", "application/mac-binhex40");
|
|
dictMimeTypes.Add(".hta", "application/hta");
|
|
dictMimeTypes.Add(".htc", "text/x-component");
|
|
dictMimeTypes.Add(".htm", "text/html");
|
|
dictMimeTypes.Add(".html", "text/html");
|
|
dictMimeTypes.Add(".htt", "text/webviewhtml");
|
|
dictMimeTypes.Add(".ico", "image/x-icon");
|
|
dictMimeTypes.Add(".ief", "image/ief");
|
|
dictMimeTypes.Add(".iii", "application/x-iphone");
|
|
dictMimeTypes.Add(".ins", "application/x-internet-signup");
|
|
dictMimeTypes.Add(".isp", "application/x-internet-signup");
|
|
dictMimeTypes.Add(".IVF", "video/x-ivf");
|
|
dictMimeTypes.Add(".jfif", "image/pjpeg");
|
|
dictMimeTypes.Add(".jpe", "image/jpeg");
|
|
dictMimeTypes.Add(".jpeg", "image/jpeg");
|
|
dictMimeTypes.Add(".jpg", "image/jpeg");
|
|
dictMimeTypes.Add(".js", "application/x-javascript");
|
|
dictMimeTypes.Add(".latex", "application/x-latex");
|
|
dictMimeTypes.Add(".lsf", "video/x-la-asf");
|
|
dictMimeTypes.Add(".lsx", "video/x-la-asf");
|
|
dictMimeTypes.Add(".m13", "application/x-msmediaview");
|
|
dictMimeTypes.Add(".m14", "application/x-msmediaview");
|
|
dictMimeTypes.Add(".m1v", "video/mpeg");
|
|
dictMimeTypes.Add(".m3u", "audio/x-mpegurl");
|
|
dictMimeTypes.Add(".man", "application/x-troff-man");
|
|
dictMimeTypes.Add(".manifest", "application/x-ms-manifest");
|
|
dictMimeTypes.Add(".mdb", "application/x-msaccess");
|
|
dictMimeTypes.Add(".me", "application/x-troff-me");
|
|
dictMimeTypes.Add(".mht", "message/rfc822");
|
|
dictMimeTypes.Add(".mhtml", "message/rfc822");
|
|
dictMimeTypes.Add(".mid", "audio/mid");
|
|
dictMimeTypes.Add(".mmf", "application/x-smaf");
|
|
dictMimeTypes.Add(".mny", "application/x-msmoney");
|
|
dictMimeTypes.Add(".mov", "video/quicktime");
|
|
dictMimeTypes.Add(".movie", "video/x-sgi-movie");
|
|
dictMimeTypes.Add(".mp2", "video/mpeg");
|
|
dictMimeTypes.Add(".mp3", "audio/mpeg");
|
|
dictMimeTypes.Add(".mpa", "video/mpeg");
|
|
dictMimeTypes.Add(".mpe", "video/mpeg");
|
|
dictMimeTypes.Add(".mpeg", "video/mpeg");
|
|
dictMimeTypes.Add(".mpg", "video/mpeg");
|
|
dictMimeTypes.Add(".mpp", "application/vnd.ms-project");
|
|
dictMimeTypes.Add(".mpv2", "video/mpeg");
|
|
dictMimeTypes.Add(".ms", "application/x-troff-ms");
|
|
dictMimeTypes.Add(".mvb", "application/x-msmediaview");
|
|
dictMimeTypes.Add(".nc", "application/x-netcdf");
|
|
dictMimeTypes.Add(".nws", "message/rfc822");
|
|
dictMimeTypes.Add(".oda", "application/oda");
|
|
dictMimeTypes.Add(".ods", "application/oleobject");
|
|
dictMimeTypes.Add(".p10", "application/pkcs10");
|
|
dictMimeTypes.Add(".p12", "application/x-pkcs12");
|
|
dictMimeTypes.Add(".p7b", "application/x-pkcs7-certificates");
|
|
dictMimeTypes.Add(".p7c", "application/pkcs7-mime");
|
|
dictMimeTypes.Add(".p7m", "application/pkcs7-mime");
|
|
dictMimeTypes.Add(".p7r", "application/x-pkcs7-certreqresp");
|
|
dictMimeTypes.Add(".p7s", "application/pkcs7-signature");
|
|
dictMimeTypes.Add(".pbm", "image/x-portable-bitmap");
|
|
dictMimeTypes.Add(".pdf", "application/pdf");
|
|
dictMimeTypes.Add(".pfx", "application/x-pkcs12");
|
|
dictMimeTypes.Add(".pgm", "image/x-portable-graymap");
|
|
dictMimeTypes.Add(".pko", "application/vndms-pkipko");
|
|
dictMimeTypes.Add(".pma", "application/x-perfmon");
|
|
dictMimeTypes.Add(".pmc", "application/x-perfmon");
|
|
dictMimeTypes.Add(".pml", "application/x-perfmon");
|
|
dictMimeTypes.Add(".pmr", "application/x-perfmon");
|
|
dictMimeTypes.Add(".pmw", "application/x-perfmon");
|
|
dictMimeTypes.Add(".png", "image/png");
|
|
dictMimeTypes.Add(".pnm", "image/x-portable-anymap");
|
|
dictMimeTypes.Add(".pnz", "image/png");
|
|
dictMimeTypes.Add(".pot", "application/vnd.ms-powerpoint");
|
|
dictMimeTypes.Add(".ppm", "image/x-portable-pixmap");
|
|
dictMimeTypes.Add(".pps", "application/vnd.ms-powerpoint");
|
|
dictMimeTypes.Add(".ppt", "application/vnd.ms-powerpoint");
|
|
dictMimeTypes.Add(".prf", "application/pics-rules");
|
|
dictMimeTypes.Add(".ps", "application/postscript");
|
|
dictMimeTypes.Add(".pub", "application/x-mspublisher");
|
|
dictMimeTypes.Add(".qt", "video/quicktime");
|
|
dictMimeTypes.Add(".ra", "audio/x-pn-realaudio");
|
|
dictMimeTypes.Add(".ram", "audio/x-pn-realaudio");
|
|
dictMimeTypes.Add(".ras", "image/x-cmu-raster");
|
|
dictMimeTypes.Add(".rgb", "image/x-rgb");
|
|
dictMimeTypes.Add(".rmi", "audio/mid");
|
|
dictMimeTypes.Add(".roff", "application/x-troff");
|
|
dictMimeTypes.Add(".rtf", "application/rtf");
|
|
dictMimeTypes.Add(".rtx", "text/richtext");
|
|
dictMimeTypes.Add(".scd", "application/x-msschedule");
|
|
dictMimeTypes.Add(".sct", "text/scriptlet");
|
|
dictMimeTypes.Add(".setpay", "application/set-payment-initiation");
|
|
dictMimeTypes.Add(".setreg", "application/set-registration-initiation");
|
|
dictMimeTypes.Add(".sh", "application/x-sh");
|
|
dictMimeTypes.Add(".shar", "application/x-shar");
|
|
dictMimeTypes.Add(".sit", "application/x-stuffit");
|
|
dictMimeTypes.Add(".smd", "audio/x-smd");
|
|
dictMimeTypes.Add(".smx", "audio/x-smd");
|
|
dictMimeTypes.Add(".smz", "audio/x-smd");
|
|
dictMimeTypes.Add(".snd", "audio/basic");
|
|
dictMimeTypes.Add(".spc", "application/x-pkcs7-certificates");
|
|
dictMimeTypes.Add(".spl", "application/futuresplash");
|
|
dictMimeTypes.Add(".src", "application/x-wais-source");
|
|
dictMimeTypes.Add(".sst", "application/vndms-pkicertstore");
|
|
dictMimeTypes.Add(".stl", "application/vndms-pkistl");
|
|
dictMimeTypes.Add(".stm", "text/html");
|
|
dictMimeTypes.Add(".sv4cpio", "application/x-sv4cpio");
|
|
dictMimeTypes.Add(".sv4crc", "application/x-sv4crc");
|
|
dictMimeTypes.Add(".t", "application/x-troff");
|
|
dictMimeTypes.Add(".tar", "application/x-tar");
|
|
dictMimeTypes.Add(".tcl", "application/x-tcl");
|
|
dictMimeTypes.Add(".tex", "application/x-tex");
|
|
dictMimeTypes.Add(".texi", "application/x-texinfo");
|
|
dictMimeTypes.Add(".texinfo", "application/x-texinfo");
|
|
dictMimeTypes.Add(".tgz", "application/x-compressed");
|
|
dictMimeTypes.Add(".tif", "image/tiff");
|
|
dictMimeTypes.Add(".tiff", "image/tiff");
|
|
dictMimeTypes.Add(".tr", "application/x-troff");
|
|
dictMimeTypes.Add(".trm", "application/x-msterminal");
|
|
dictMimeTypes.Add(".tsv", "text/tab-separated-values");
|
|
dictMimeTypes.Add(".txt", "text/plain");
|
|
dictMimeTypes.Add(".uls", "text/iuls");
|
|
dictMimeTypes.Add(".ustar", "application/x-ustar");
|
|
dictMimeTypes.Add(".vcf", "text/x-vcard");
|
|
dictMimeTypes.Add(".wav", "audio/wav");
|
|
dictMimeTypes.Add(".wbmp", "image/vnd.wap.wbmp");
|
|
dictMimeTypes.Add(".wcm", "application/vnd.ms-works");
|
|
dictMimeTypes.Add(".wdb", "application/vnd.ms-works");
|
|
dictMimeTypes.Add(".wks", "application/vnd.ms-works");
|
|
dictMimeTypes.Add(".wmf", "application/x-msmetafile");
|
|
dictMimeTypes.Add(".wps", "application/vnd.ms-works");
|
|
dictMimeTypes.Add(".wri", "application/x-mswrite");
|
|
dictMimeTypes.Add(".wrl", "x-world/x-vrml");
|
|
dictMimeTypes.Add(".wrz", "x-world/x-vrml");
|
|
dictMimeTypes.Add(".wsdl", "text/xml");
|
|
dictMimeTypes.Add(".xaf", "x-world/x-vrml");
|
|
dictMimeTypes.Add(".xbm", "image/x-xbitmap");
|
|
dictMimeTypes.Add(".xla", "application/vnd.ms-excel");
|
|
dictMimeTypes.Add(".xlc", "application/vnd.ms-excel");
|
|
dictMimeTypes.Add(".xlm", "application/vnd.ms-excel");
|
|
dictMimeTypes.Add(".xls", "application/vnd.ms-excel");
|
|
dictMimeTypes.Add(".xlt", "application/vnd.ms-excel");
|
|
dictMimeTypes.Add(".xlw", "application/vnd.ms-excel");
|
|
dictMimeTypes.Add(".xml", "text/xml");
|
|
dictMimeTypes.Add(".xof", "x-world/x-vrml");
|
|
dictMimeTypes.Add(".xpm", "image/x-xpixmap");
|
|
dictMimeTypes.Add(".xsd", "text/xml");
|
|
dictMimeTypes.Add(".xsl", "text/xml");
|
|
dictMimeTypes.Add(".xwd", "image/x-xwindowdump");
|
|
dictMimeTypes.Add(".z", "application/x-compress");
|
|
dictMimeTypes.Add(".zip", "application/x-zip-compressed");
|
|
|
|
//Office 2007 types
|
|
dictMimeTypes.Add(".docm", "application/vnd.ms-word.document.macroEnabled.12");
|
|
dictMimeTypes.Add(".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
|
dictMimeTypes.Add(".dotm", "application/vnd.ms-word.template.macroEnabled.12");
|
|
dictMimeTypes.Add(".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template");
|
|
dictMimeTypes.Add(".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12");
|
|
dictMimeTypes.Add(".potx", "application/vnd.openxmlformats-officedocument.presentationml.template");
|
|
dictMimeTypes.Add(".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12");
|
|
dictMimeTypes.Add(".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12");
|
|
dictMimeTypes.Add(".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow");
|
|
dictMimeTypes.Add(".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12");
|
|
dictMimeTypes.Add(".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
|
|
dictMimeTypes.Add(".xlam", "application/vnd.ms-excel.addin.macroEnabled.12");
|
|
dictMimeTypes.Add(".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12");
|
|
dictMimeTypes.Add(".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12");
|
|
dictMimeTypes.Add(".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
dictMimeTypes.Add(".xltm", "application/vnd.ms-excel.template.macroEnabled.12");
|
|
dictMimeTypes.Add(".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template");
|
|
#endregion mimetypes
|
|
|
|
}
|
|
|
|
if (dictMimeTypes.ContainsKey(sExtension))
|
|
return dictMimeTypes[sExtension];
|
|
else
|
|
return "application/octet-stream";
|
|
}
|
|
|
|
#endregion ayafile handler
|
|
|
|
#endregion wiki / ayafile stuff
|
|
|
|
#region custom header footers case 1111
|
|
/// <summary>
|
|
/// Adds any custom content provided by the WBI admin if available
|
|
///
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
public static void PageAddCustomContent(Page p, bool bForce)
|
|
{
|
|
|
|
//if force then just do it regardless, this is for the login page
|
|
if (bForce)
|
|
{
|
|
InsertCustomContent(p);
|
|
return;
|
|
}
|
|
|
|
//check if user is a client or head office because some pages are shared by both customers and techs
|
|
if (Util.CurrentUser.IsClientOrHeadOfficeAccount)
|
|
{
|
|
InsertCustomContent(p);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// Adds any custom content provided by the WBI admin if available
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
public static void PageAddCustomContent(Page p)
|
|
{
|
|
PageAddCustomContent(p, false);
|
|
}
|
|
|
|
private static void InsertCustomContent(Page p)
|
|
{
|
|
if (p.FindControl("pnlclhead") != null)
|
|
{
|
|
Panel pnl = (Panel)p.FindControl("pnlclhead");
|
|
pnl.Controls.Clear();
|
|
pnl.Controls.Add(new LiteralControl(CustomContent("CustomClientHeader")));
|
|
}
|
|
|
|
if (p.FindControl("pnlclfoot") != null)
|
|
{
|
|
Panel pnl = (Panel)p.FindControl("pnlclfoot");
|
|
pnl.Controls.Clear();
|
|
pnl.Controls.Add(new LiteralControl(CustomContent("CustomClientFooter")));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cached Custom content
|
|
/// Valid items are "CustomClientFooter", "CustomClientHeader"
|
|
/// </summary>
|
|
public static string CustomContent(string sContentType)
|
|
{
|
|
if (HttpContext.Current.Cache[sContentType] == null)
|
|
{
|
|
string sContent = "NA";
|
|
string sFilePath = System.Web.HttpContext.Current.Server.MapPath("~/" + sContentType + "Content.txt");
|
|
//Check for existance of file
|
|
if (System.IO.File.Exists(sFilePath))
|
|
{
|
|
try
|
|
{
|
|
sContent = System.IO.File.ReadAllText(sFilePath);
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
HttpContext.Current.Cache.Insert(sContentType, sContent, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
|
|
}
|
|
string sRet=(string)HttpContext.Current.Cache[sContentType];
|
|
if (sRet == "NA") return "";
|
|
else
|
|
return sRet;
|
|
}
|
|
|
|
#endregion
|
|
|
|
//-----------------------------------------------------------------------------------------
|
|
}//end of Util class
|
|
|
|
#region Get enum from combo box
|
|
public class cb2e<T>
|
|
{
|
|
public static T get(Telerik.Web.UI.RadComboBox cb)
|
|
{
|
|
return (T)Enum.Parse(typeof(T), cb.SelectedValue);
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region RadGrid templates
|
|
public class ListItemTemplate : ITemplate
|
|
{
|
|
protected TextBox textBox;
|
|
protected string fieldName = "";
|
|
protected string listName = "";
|
|
protected bool biz = false;
|
|
public ListItemTemplate(string FieldName, string ListName, bool Biz)
|
|
{
|
|
fieldName = FieldName;
|
|
listName = ListName;
|
|
biz = Biz;
|
|
}
|
|
public void InstantiateIn(System.Web.UI.Control container)
|
|
{
|
|
Label textBox = new Label();
|
|
//textBox.ID = "tbli";
|
|
|
|
textBox.Visible = true;
|
|
textBox.DataBinding += new EventHandler(textBox_DataBinding);
|
|
|
|
|
|
container.Controls.Add(textBox);
|
|
}
|
|
|
|
void textBox_DataBinding(object sender, EventArgs e)
|
|
{
|
|
Label textBox;
|
|
textBox = (Label)sender;
|
|
GridDataItem container = (GridDataItem)textBox.NamingContainer;
|
|
object o=DataBinder.Eval(container.DataItem, fieldName);
|
|
|
|
string s = "";
|
|
if (!biz)
|
|
s=Util.GetNonBizName(listName, System.Convert.ToInt32(o));
|
|
else
|
|
s=Util.GetBizObjectName(listName, new Guid(o.ToString()));
|
|
textBox.Text += s;
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region messing about stuff
|
|
//class ControlFactory
|
|
//{
|
|
// public static CPControl CreateControl(object htmlElementObj)//sb static
|
|
//{
|
|
|
|
// //what if the parameter is null? Or not the object desired?
|
|
// if(htmlElementObj==null || !(htmlElementObj is mshtml.IHTMLElement))
|
|
// return (CPControl)null;
|
|
|
|
// //Always think localization
|
|
// string elementName=((mshtml.IHTMLElement)htmlElementObj).tagName.ToUpperInvariant();
|
|
|
|
// //no need to check for "input" specifically since the original code seems to be designed
|
|
// //to either return an object of interest or null
|
|
// switch(elementName)
|
|
// {
|
|
// case "TEXT": return new CPTextBox();
|
|
// case "CHECKBOX": return new CPCheckBox();
|
|
// case "RADIO": return new CPRadioButton();
|
|
// case "PASSWORD": return new CPPasswordTextBox();
|
|
// case "HIDDEN": return new CPHiddenControl();
|
|
|
|
// }
|
|
|
|
// return (CPControl)null;
|
|
//}
|
|
//}
|
|
#endregion |