Tuesday, May 25, 2010

JavaScript Addition

Apparently, IEEE makes standards for JavaScript that make accurate addition difficult.

I haven't found the exact standard, but I'm looking for it.

When you add numbers with decimals, JavaScript will add value.

For instance:

115.04 + 15 = 130.04000000000002

Instead of 130.04

So, I found a work around for this. Use *.toPrecision(##).

toPrecision will allows you to truncate the value.

Tuesday, May 11, 2010

Z-index

There is a CSS property z-index, which lets the developer set the 'stack order' of elements on an HTML page.

Z-index only works with 'positioned' elements, for instance: position: absolute;

Z-index, also, has the greatest number in front of the lowest number.

ASP.NET MVC 403 Error

There is an error, when using ASP.NET MVC, that gives you HTTP 403 error.

When, the rest of the MVC site is working, but it cannot access a specific controller, look for a folder named after the controller.

For instance,

If the controller that cannot be accessed is SecurityController, but the rest of the controllers work, look for a folder in the root directory named "Security". ASP.NET MVC tries to access this folder instead of the actual controller.

Wednesday, May 5, 2010

WCF Alternative Config with MEF

This website describes how to use an alternate config file with WCF.

http://weblogs.asp.net/cibrax/archive/2009/09/08/client-configuration-in-wcf-4-0.aspx

Basically, this is a way to do it, also.

ConfigurationChannelFactory factory = null;
try
{
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string configFile = path + @"\FOT.Services.Plugins.RAT.MainServer.dll.config";

ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = configFile;

Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);

System.ServiceModel.EndpointAddress endPointAddress = new System.ServiceModel.EndpointAddress("net.tcp://" + rigIP + ":8052/SatelliteAuthorizationService");

factory = new ConfigurationChannelFactory("NetTcpBinding_IAuthorizationService", config, endPointAddress);

EventLogger.LogEvent(EventLogger.LogCode.Debug, EventLogger.LogLevel.Trace, id: "877", className: "Moderator", methodName: "CreateWell", eventMessage: "Loaded Config File.");
}
catch (Exception ex)
{
EventLogger.LogEvent(EventLogger.LogCode.Unknown_Error, EventLogger.LogLevel.Error, id: "881", className: "Moderator", methodName: "CreateWell", eventMessage: ex.Message, stackTrace: ex.StackTrace);
}
IAuthorizationService client = factory.CreateChannel();
int error = client.CreateWell(authorizationKey, Convert.ToInt32(wellId), databaseName, productType, productVersion);