index

Visual Studio

Notes


8:52 AM Tuesday, November 30, 2010: MS Office activation key for VRM: BT3V9-4JRPQ-PK4P8-3M9YC-Q9H7C
http://www.akxl.net/labs/articles/converting-a-hexadecimal-color-to-a-system.drawing.color-object/

easy way:
with this method, you must include the leading '#' sign
System.Drawing.Color myOrangeColor = System.Drawing.ColorTranslator.FromHtml("#CE560C");

harder way:

protected System.Drawing.Color HexStringToColor(string hex)
{
	hex = hex.Replace("#", "");
	if (hex.Length != 6)
	{
		throw new System.Exception(hex + " is not a valid 6-place hexadecimal color code");
	}
	string r = hex.Substring(0, 2);
	string g = hex.Substring(2, 2);
	string b = hex.Substring(4, 2);
	return System.Drawing.Color.FromArgb(HexStringToBase10Int(r), HexStringToBase10Int(g), HexStringToBase10Int(b));
	
}

protected int HexStringToBase10Int(string hex)
{
	int base10value = 0;
	try{ base10value = System.Convert.ToInt32(hex, 16); }
	catch{ base10value = 0; }
	return base10value;
}


Data access in Framework:
C:\vrm\Products\VMS\3.1\SourceCode\VRM.Business.VMS\BusinessIndustryDesignations.custom.cs
using System.Data;
using System.Data.SqlClient; //for SqlParameter
using VRM.Data; //for DataLayer
using VRM.Configuration; //for Settings

public static DataSet GetData(int businessID)
{
	IDbCommand command = DataLayer.CommandCreateForProcedure("BusinessIndustryDesignations_Select");
	command.Parameters.Add(new SqlParameter("@intBusinessID", businessID));
	return DataLayer.GetDataSet(command, Settings.ConnectionStringVMS);
}

Mime Types:
C:\vrm\Products\VRMS\2.1.2\Sourcecode\VRM.Website.VRMS\Web.config (212)
<add key="FileViewerFileTypes" value="csv,text/csv | pdf,application/pdf | tiff,image/tiff | tif,image/tiff | xls,application/ms-excel | xlsx,application/ms-excel"/>
Google: split string parameter in sql
http://www.codeproject.com/KB/database/splitparameterstring.aspx

This works without a function!

DECLARE @AllEmails VARCHAR(MAX) = 'jbreo@soldinoregon.com,info@soldinoregon.com, barbralston@comcast.net,reo@soldinoregon.com,loraparnell1@yahoo.com, nivrita@exitadvancedrealtyca.com,Mark@elitearizona.com,Jeff@atlantareopartners.com, Charlotte@YesNoPlaceLikeHome.com,cgim@expertrei.com,lashelle@windermere.com, eric.egeland@remax.net,tonyacuffee@msn.com,james@ReoRealtorSpokane.com, REOsales@JulieBaldino.com';

SELECT ContactID, BusinessID, ContactTypeID, FirstName, LastName, EmailAddress
FROM Contacts 
WHERE 
	',' + @AllEmails + ',' LIKE '%,' + CAST(EmailAddress as VARCHAR(MAX))+',%'

Google: format phone number C#

C:\vrm\Products\Corporate\2.2\SourceCode\VRM.Website.Corporate\Admin\AdminTopics.aspx

<asp:DropDownList ID="ddlTopicTypes" runat="server" AutoPostBack="true"
	OnSelectedIndexChanged="ddlTopicTypes_SelectedIndexChanged" />
	
protected void ddlTopicTypes_SelectedIndexChanged(object sender, EventArgs e)
{
	if (ddlTopicTypes.SelectedIndex != -1)
	{
		int selIndex = ddlTopicTypes.SelectedIndex;
		if (ddlTopicTypes.Items[selIndex] != null)
		{
			ListItem li = ddlTopicTypes.Items[selIndex];
			//for retrieve, for add new
			TopicType = (li.Value).ToEnum(); //(Convert.ToInt32(li.Value));
			LoadData();
		}
	}
}

private void LoadData()
{
	gvTopics.DataSource = TopicsCollection.RetrieveByTopicType(TopicType, true);
	//topicType.ToString() 
	lblPageHeader.Text = "Manage " + Topics.GetNameField(TopicType.FromEnum()) + " Section";
	gvTopics.DataBind();
}//LoadData()

partial class TopicsCollection
{
	public static TopicsCollection RetrieveByTopicType(TopicType typeID, bool showInactiveRecords)
	{
		string sWhere = "WHERE TopicTypeID = " + typeID.FromEnum();
		if (!showInactiveRecords)
		{
			sWhere += " AND IsActive = 1";
		}
		return Retrieve(sWhere, true, "SortIndex ASC");
	}
}

Using cache manager to set standard dropdownlists

THIS:
VMSDataCacheManager.SetTypeTableDropDownList(ref ddlVendorType, VMSDataCacheTable.ValidBusinessSubTypes, string.Concat("BusinessTypeID = ", BusinessType.Vendor.FromEnum()), "-1", "-1", "-Select-");
REPLACES THIS:
DataView results = VMSDataCacheManager.GetTypeTableData(
	VMSDataCacheTable.ValidBusinessSubTypes, 
	string.Concat("BusinessTypeID = " , BusinessType.Vendor.FromEnum()));
if (results.Count > 0)
{
	ddlVendorType.DataSource = results;
	ddlVendorType.DataTextField = "Name";
	ddlVendorType.DataValueField = "ID";
	ddlVendorType.DataBind();
}

Check this out! VMS\3.1\SourceCode\VRM.Website.VMS\App_Themes\Default\InputFields.skin
Add keys to app.config and add properties to VRM.Jobs.VMS.Configuration.JobConfig rather than hardcoding where needed
<VRMCustomConfig>
	<JobConfig>
		<add key="ExecuteAsUserID" value="1" />
		<add key="VendorAdministratorRoleName" value="Administrator" />
		<add key="EquatorMailServer" value="mail" />
		<add key="EquatorMailPort" value="993" />
		<add key="EquatorMailUserName" value="equatorsupport" />
		<add key="EquatorMailPassword" value="EQmail4vrm!" />
		<add key="EquatorMailTimeout" value="90000" />
		<add key="EquatorMailToAddress" value="jbechtold@vrmco.com" />
	</JobConfig>
</VRMCustomConfig>
  
public static string EquatorMailServer { get; private set; }
public static int EquatorMailPort { get; private set; }

EquatorMailServer = ReadString(config, "EquatorMailServer");
EquatorMailPort = ReadInteger(config, "EquatorMailPort");

Google: C# what is the difference between a service reference and web reference
DOS Commands
Windows Explorer -> Organize -> Folder and Search Options -> Navigation Pane -> Automaticaly expand to current folder, to make it work like the old versions of Windows Explorer:)
To use the Telerik RadDatePicker:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>    
<div class="date">
	<telerik:RadDatePicker ID="txtRequestedCompletionDate" runat="server" />
</div>

How to write to the Event log in dev tools:
if (ds == null || ds.Tables.Count == 0)
{
	VRM.Common.Logging.Event.Write("Asset Assignment - File Cannot Be Generated - No EquatorAssets for this upload.");
	return;
}

There is some sort of caching mechanism in place in the framework for populating ValidBlah data in DDLs:
C:\vrm\Products\VMS\3.1\SourceCode\VRM.Website.VMS\Administration\Vendors\VendorSearch.aspx.cs(553)
C:\vrm\Products\VMS\3.1\SourceCode\VRM.Website.VMS\Administration\Vendors\VendorCompare.aspx.cs(544)
private void LoadVendorTypes()
{
	DataView results = VMSDataCacheManager.GetTypeTableData(
		VMSDataCacheTable.ValidBusinessSubTypes, 
		string.Concat("BusinessTypeID = " , BusinessType.Vendor.FromEnum()));
	if (results.Count > 0)
	{
		ddlVendorType.DataSource = results;
		ddlVendorType.DataTextField = "Name";
		ddlVendorType.DataValueField = "ID";
		ddlVendorType.DataBind();
	}
}//end ()
Update: there is a 1-line version of the above:
/// <summary>
/// VendorTypes in this case are ValidBusinessSubTypes where ValidBusinessTypeID = 3
/// </summary>
private void LoadVendorTypes()
{
	VMSDataCacheManager.SetTypeTableDropDownList(ref ddlVendorTypes, VMSDataCacheTable.ValidBusinessSubTypes, 
	 	string.Concat("BusinessTypeID = ", BusinessType.Vendor.FromEnum()), "-1", "-1", "-Select-");
}
To get the name out of cache:
string name = VMSDataCacheManager.GetName(VMSDataCacheTable.ValidBusinessSubTypes, ddlVendorType.SelectedValue);
Look at C:\vrm\Products\VMS\3.1\SourceCode\VRM.Business.VMS\Caching\VMSTableCache.cs
To get the name of the curent user:

using System.Security.Principal;
WindowsIdentity wi = WindowsIdentity.GetCurrent();
private string _windowsIndentityName = wi.Name;
lblUserEntered.Text = _windowsIndentityName;

Or

using System.Web;
_windowsIndentityName = ((WindowsPrincipal)HttpContext.Current.User).Identity.Name;


ClearControls(this);

private void ClearControls(Control parent)
{
	foreach (Control control in parent.Controls)
	{
		if (control is TextBox)
		{
			((TextBox)control).Text = string.Empty;
		}
		else if (control is DropDownList)
		{
			((DropDownList)control).SelectedIndex = 0;
		}
		else if (control is RadNumericTextBox)
		{
			((RadNumericTextBox)control).Value = null;
		}
		else if (control is RadMaskedTextBox)
		{
			((RadMaskedTextBox)control).Text = string.Empty;
		}

		if (control.HasControls())
		{
			ClearControls(control);
		}
	}
	UserSession.ContactSearch = null;
	gvContacts.DataSource = null;
	gvContacts.DataBind();
}