Posted by Ron Rechtman
Wednesday, July 28, 2010 5:54:07 PM
Took me a few hours and reading a few posts until I got this working. It seems that you must have the service published on HTTP even if you require HTTPS.
<system.serviceModel>
<serviceHostingEnvironmentaspNetCompatibilityEnabled="false" />
<services>
<servicename="Xxxx.API.Order.Sale"behaviorConfiguration="Xxxx.API.Order.SaleBehavior">
<host>
<baseAddresses>
<addbaseAddress="https://zzzz.com/xxxxapi_wcf"/>
</baseAddresses>
</host>
<!-- Service Endpoints -->
<endpointaddress="https://zzzz.com/xxxxapi_wcf/xxxx.svc"binding="wsHttpBinding"bindingConfiguration="HttpsBinding"contract="Xxxx.API.Order.ISale">
<dnsvalue="zzzz.com"/>
</identity>
</endpoint>
</service>
</services>
<bindings>
<wsHttpBinding>
<bindingname="HttpsBinding">
<securitymode="Transport">
<transportclientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behaviorname="Xxxx.API.Order.SaleBehavior">
<serviceMetadatahttpsGetEnabled="true"httpGetUrl="http://zzzz.com/xxxxapi_wcf/xxxx.svc/mex"httpsGetUrl="https://zzzz.com/xxxxapi_wcf/xxxx.svc/mex"httpGetEnabled="true"/>
<serviceDebugincludeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Posted by Ron Rechtman
Wednesday, June 02, 2010 9:39:10 AM
So I had to do manipulate data to a PHP app that needed to be pack("H*",...) in the PHP world. After a lot of digging I found
public static byte[] PackH(string hex)
{
if ((hex.Length % 2) == 1) hex += '0';
byte[] bytes = new byte[hex.Length / 2];
for (int i = 0; i < hex.Length; i += 2)
{
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
}
return bytes;
}
Posted by Ron Rechtman
Wednesday, March 24, 2010 11:45:38 PM
So you want to know if a process is running...
using System.Diagnostics;
public static bool IsProcessAlreadyRunning()
{
Process currentProcess = Process.GetCurrentProcess();
List<Process> processes = Process.GetProcesses().Where(x=>x.ProcessName == currentProcess.ProcessName).ToList<Process>();
return (processes.Count > 1);
}
Enjoy!
Posted by Ron Rechtman
Wednesday, January 27, 2010 3:59:31 PM
I had a problem with one of my clients that each time i turned around the data needed to be posted to someone new...
So I decided to create an configurable posting mechanism. A UI that you place the URL and some static data for the partner and a mapping section.
What I came up with is:
- The Admin UI has a DataList which the postback will build the XML as needed to be stored in the database.
- Some reflection code based off the XML that build the string to post to the 3rd party.
The hardest part was figuring out the reflection so the object with the data in it, lets call it Cutomer c, to get c.FirstName dynamically it is done by c.GetType().GetProperty("FirstName").GetValue(c, null).
Not too bad at the end.
Posted by Ron Rechtman
Friday, September 18, 2009 12:30:42 PM
Most complete email regex I have found...
It is adaptaion of RFC 2822 from (http://www.regular-expressions.info/email.html) to allow upper & lower case & not allow comma
RegexStringValidator
x = new RegexStringValidator("(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x7f\x2c]|\\[\x01-\x09\x0b\x0c\x0e-\x7f\x2c])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f\x2c]|\\[\x01-\x09\x0b\x0c\x0e-\x7f\x2c])+)\\])");
Posted by Ron Rechtman
Saturday, September 05, 2009 4:29:00 PM
So I needed to create an audit trail on SQL with ASP_NET authentication. I did some digging and came up with:
http://www.simple-talk.com/sql/database-administration/pop-rivetts-sql-server-faq-no.5-pop-on-the-audit-trail/
http://www.auditdatabase.com/Downloads.html
I took the code from AuditDatabase.com and made some changes.
You can find it all in the downloads area: http://www.nuronconsulting.com/File-Download.aspx in the SQL folder Auditing.
There is also a script there that will generate the triggers for this.
Posted by Ron Rechtman
Tuesday, August 18, 2009 8:19:07 AM
I was having a hard time finding a way to calculate holidays. I put together some things I found on the web and came up with Holidays.cs It provides a way to easily get US & Jewish holidays if you are working in C# or VB.NET.
Enjoy! & here is the file.
Posted by Ron Rechtman
Tuesday, August 18, 2009 7:42:34 AM
Just getting this site up and running. I plan to use the blog as a place to put code that I hunt for which can be widely used.