Tuesday, October 25, 2011

ADF / XML via PHP - Auto-lead data format


$xmladf='<?ADF VERSION "1.0"?>'. "\r\n";
$xmladf.='<?XML VERSION "1.0"?>'. "\r\n";
$xmladf.='<adf>'. "\r\n";
$xmladf.='<prospect>'. "\r\n";
$xmladf.='<requestdate>'.date(DATE_ATOM).'</requestdate>'. "\r\n";
$xmladf.='<vehicle>'. "\r\n";
$xmladf.='<year>'.$Year.'</year>'. "\r\n";
$xmladf.='<make>'.$Make.'</make>'. "\r\n";
$xmladf.='<model>'.$Model.'</model>'. "\r\n";
$xmladf.='<vin>'.$Vin.'</vin>'. "\r\n";
$xmladf.='</vehicle>'. "\r\n";
$xmladf.='<customer>'. "\r\n";
$xmladf.='<contact>'. "\r\n";
$xmladf.='<name part="full">'.$CustomerFirst </name>'. "\r\n";
$xmladf.='<phone>'.$CustomerPhone.'</phone>'. "\r\n";
$xmladf.='<email>'.$customeremail.'</email>'. "\r\n";
$xmladf.='<address type="home">'. "\r\n";
$xmladf.='<city>'.$CustomerCity.'</city>'. "\r\n";
$xmladf.='<regioncode>'.$CustomerState.'</regioncode>'. "\r\n";
$xmladf.='<postalcode>'.$CustomerZip.'</postalcode>'. "\r\n";
$xmladf.='</address>'. "\r\n";
$xmladf.='</contact>'. "\r\n";
$xmladf.='</customer>'. "\r\n";
$xmladf.='<vendor>'. "\r\n";
$xmladf.='<contact>'. "\r\n";
$xmladf.='<name part="full">'.$vendorname.'</name>'. "\r\n";
$xmladf.='</contact>'. "\r\n";
$xmladf.='</vendor>'. "\r\n";
$xmladf.='<provider>';
$xmladf.='<name part="full">triple tech soft</name>'. "\r\n";
$xmladf.='<service>triple tech soft</service>'. "\r\n";
$xmladf.='<url>http://tripletechsoft.com</url>'. "\r\n";
$xmladf.='<email>test@tripletechsoft.com</email>'. "\r\n";
$xmladf.='<phone>100-222-4444</phone>'. "\r\n";
$xmladf.='</provider>'. "\r\n";
$xmladf.='</prospect>'. "\r\n";
$xmladf.='</adf>'. "\r\n";
//
// CREATE THE MESSAGE FROM THE XML STUFF AND THE BUFFERED ADF STUFF 
$subject = "triple tech soft"; 

 
$headers .= "xml version: 1.0" . "\r\n";
$headers .= "Content-Type: application/xhtml+xml; charset=ISO-8859-1" . "\r\n"; //  encoding=ISO-8859-1
$headers .= 'Content-Transfer-Encoding: 7bit' . "\r\n\r\n";

$mail_sent = @mail($adfemailto, $subject, $xmladf, $headers);
   echo '[success: true, message: "message sent"]';

JQuery, the very very basics


For every programming language, there is invariably string manipulation and array fiddling. No exception with JQuery. Being unobtrusive in principal and complimentary in nature, it does not try to replace the existing bulk of JavaScript functions with its own, rather, it simply adds some of the most sorely missed functions.  
Trimming a string: $.trim(value)
In dealing with strings, JavaScript already has quite a comprehensive set of functions, such assplit, substr, charAt (see references at http://www.w3schools.com/jsref/jsref_obj_string.asp), however, for some mysterious reasons, it does not have a trim function for ridding of leading and trailing white space. Smart and generous people have contributed to the web various versions of their trim functions. Such as:
var trimmed = str.replace(/^\s+|\s+$/g, '') ;
It works perfectly. However, how about simply call trim() function provided by JQuery? The syntax is $.trim(value) 
var trimmed = $.trim(" this really needs to be trimmed ");
Clean and plain English, right?
Array functions:
 
$.each (container, callback)
 
In JQery, in addition to the conventional JavaScript array (array of strings, numerics, elements), there is also specifically object array in the form of key-value pairs.
 
The former array is coded as: 
var arr = [ "one""two""three""four""five" ];
 The later (each pair seperated by a colon :) :
var obj = { item1: "one", item2: "two" ,item3: "three", item4: "four"};
It has always been easy to loop through an JavaScript array. However, it can be easier with the JQuery $.each function. The syntax is
$.each (container, callback). The callback function receives two arguments with the passing of each element: with [] type (traditional JavaScript) array, index and value; with {} type (array of objects with properties), key and value.
 
So we can access JQuery array elements as such (forgive me for using so many alerts):
 
$.grep (array, callback, invert) 
 
JQuery offers a $.grep() function to return an array of elements that matches a certain condition. The callback function is passed two parameters: the current value and its index. For example,
 
$.map (array, callback) 
 
One convenient function to transform all of the elements in an array in one shot. Change a string array into a numeric array? Yes; Change the numeric array back to a string array? Yes; Add a 10 to every number in an array? Yes. Just call the $.map function.
 
For example:
 
Other extremely useful JQuery array functions are:
 
$.inArray(value, array), returns the position of the first occurance of the element by a specified value. As in:
$.unique(array), returns a deduplicated array. As in:
$.makeArray(object), create an array out of a selected elements. As in:
 
$.extend(target, source1, source2, ... sourceN), extends the target object with the properties of the sources. For example:
  
 

Improve Perfomance in ASP.net


While developing any web site, one should keep some points in mind.

1) Set debug=false under compilation as follows:
<compilation default Language="c#" debug="false">
2) Use Server.Transfer instead of Response.Redirect.
3) Always check Page.IsValid when using Validator Controls
4) Use Foreach loop instead of For loop for String Iteration.
5) Use Client-Side Validation. (but not all the time you have to validate even on the server side)
6) Check “Page.IsPostBack”. To avoid repetition code execution.
7) GIF and PNG are similar, but PNG typically produces a lower file size. (True, but some browsers not supporting PNG format)
8) Use the AppOffline.htm when updating binaries
9) Turn off Tracing unless until required. (by default it's off, use on the pages where it's required)
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
10) Precompiled pages and disable AutoEventWireup; setting the AutoEventWireup attribute to false in the Machine.config file.
11) Turn off Session State, if not required.
<sessionstate timeout="20" cookieless="false" mode="Off" stateconnectionstring="tcpip=127.0.0.1:42424" sqlconnectionstring="data source=127.0.0.1;Trusted_Connection=no">
12) Select the Release mode before making the final Build for your application.
This option is available in the Top Frame just under the Window Menu option. By default, the Mode is Debug
13) Disable ViewState when not required.
EnableViewState="false"
14) Avoid frequent round trips to the Database.
15) Use Caching to improve the performance of your application.
16) Validate all Input received from the Users.
17) Use Finally Method to kill resources. (But not in the case of using)
18) The String and Stringbuilder Magic.
It is nice to use Stringbuilder instead of String when string are Amended. Strings occupy different memory location in every time of amended where stringbuilder use single memory location
19) Never use object value directly; first get object value in local variable and then use. It takes more time then variable reading.
20) Avoid Exceptions: Use If condition (if it is check proper condition)
21) Code optimization:  Avoid using code like x = x +1; it is always better to use x+=1.
22) Data Access Techniques: DataReaders provide a fast and efficient method of data retrieval. DataReader is much faster than DataSets as far as performance is concerned
23) Before doing a bulky ASP code processing, you can check to make sure Response.IsClientConnected.
24) As always, avoid session variables because each ASP page runs in a different thread and session calls will be serialized one by one. So, this will slow down the application. Instead of session variables you can use the QueryString collection or hidden variables in the form which holds the values.
25) Enabling buffering will improve the performance, like
<% response.buffer=true %>
Then use:
<% response.flush=true %> 
26) Use Repeater control instead of DataGrid , DataList, Because It is efficient, customizable, and programmable.
27) Data listing is more time consume when large data are retrieve from database.
Paging will display only particular data but take load of all data.
Fetch only data that is needed for current page.
28) Avoid Inline JavaScript and CSS
29) Use single css file instead of multiple css file.
Try your best to combine all your CSS based classes into a single .css file as lot of .css files will cause a large amount of requests, regardless of the file sizes.
.css files are normally cached by browsers, so a single and heavy .css file doesn’t cause a long wait on each page request.
Inline .css classes could make HTML heavy, so again: go ahead with a single.css file.
30) Reduce cookie size
31) Compress CSS, JavaScript and Images
Online compressors are available; to compress file please refers following web and Replace your file content with optimize code.
32 .Use Cache appropriately
i. Page output caching:
<%@ OutputCache Duration="3600" VaryByParam="none" %>
ii. Page fragment caching:
Write a Page output caching code into each User Control
iii. Data caching:
<script language="C#" runat="server">
Protected void Page_Load (Object src, EventArgs e) {
DataView dv = (DataView) Cache. Get ("EmployeesDataView");
If (dv == null) { // wasn't thereSqlConnection conn =
new SqlConnection ("server=localhost;uid=sa;pwd=;database=Test");
SqlDataAdapter da =new SqlDataAdapter ("select * from Employees", conn);
Dataset ds = new DataSet();da.Fill(ds, "Employees");
dv = ds.Tables["Employees"].DefaultView;
Cache.Insert ("EmployeesDataView", dv);conn.Close();}
Else
Response.Write ("<h2>Loaded employees from data cache! </h2>");
lb1.DataSource = dv;
lb1.DataTextField = "Name";
lb1.DataValueField = "Age";
DataBind () ;}
</script>
33) Use server side compression software such as Port80shttp://www.port80software.com/products/httpzip/  
34) Usage of "using" and I don't know why it's not yet published.
35) Don't make the member variables public or proteted, try to keep private and use public/protected as properties.
36) Use strString=string.Empty instead of strString="" . [And perhaps instead of strString=null also (?)]
37) Make your page files as light as possible. That is try to avoid unnecessary markups, e.g. use div elements instead of tables.
38) Write static messages in div and make it visible when necessary. This is faster than letting server set Text property of your label or div.
39) Retrieve data from database at once, if possible. Don't add up to database trip as far as possible. For this, combine the datafields from different tables and select them.
40) Use short ID name for WebControl. 

How to rename files and folders in VB6?

Name "C:\NVIDIA" As "C:\NVIDIA2"

Friday, October 14, 2011

Error: The ordinal 2821 could not be located in the dynamic link library LIBEAY32.dll or SSLEAY32.dll


Error Message

During the installation or launching of any application, such as ArcGIS product, Microsoft Office, PostgreSQL, etc., an error message similar to the following may appear:

"The ordinal 2821 could not be located in the dynamic link library LIBEAY32.dll."

Another variation of this error message is as follows:

"The ordinal 284 could not be located in the dynamic link library SSLEAY32.dll."

 The actual number returned after 'ordinal' may vary.

Cause

This problem is caused by an incompatibility with the currently installed OpenSSL DLLs.

Solution or Workaround

Installing the latest version of the OpenSSL DLLs typically resolves this problem.

Download and install the latest version of Win32 OpenSSL from the corresponding link located in the Related Information section.

Related Information

Error: The ORDINAL 2821 could not be located in the dynamic link library LIBEAY32.dll


Error Message

After installing ArcGIS Desktop and Crystal Reports for ArcGIS Desktop on a DELL machine, the following error message is returned when booting the machine:

"The ORDINAL 2821 could not be located in the dynamic link library LIBEAY32.dll"

Cause

This is caused by a conflict in the version of LIBEAY32.DLL supplied with certain Dell products. In particular, it can be caused by Dell's SAS RAID Storage Manager, the files for which are located under the MegaPopup folder.

Solution or Workaround

To resolve this, check for any MegaPopup folders located on the system and rename them.

  1. Click on the Windows Start button.
  2. Click on Search...
  3. In the Search dialog box, select 'All files and folders'.
  4. In the 'All of part of the filename' box, type 'megapopup' (without the quotes).
  5. For any results that appear in the right pane, right-click on the folders and select Rename.
  6. Enter a new name for the folders.

Related Information

Monday, October 10, 2011

WARNING: Application does not specify an API level requirement!


You have to add the following line in your manifest:
<uses-sdk android:minSdkVersion=”8″ />
The following table specifies the API Level supported by each version of the Android platform.
Platform VersionAPI Level
Android 2.39
Android 2.28
Android 2.17
Android 2.0.16
Android 2.05
Android 1.64
Android 1.53
Android 1.12
Android 1.01
For more informations have a look at http://developer.android.com/guide/appendix/api-levels.html.

Understanding the LocationListener in Android


Introduction

Everybody who has done some Android development involving GPS location tracking is probably familiar with the LocationManager and LocationListener concepts.
  • The LocationManager provides access to the system location services
  • The LocationListener is used for receiving notifications from the LocationManager when the location has changed
However, there seems to be some doubt regarding the minTime and minDistance parameters that can be provided to the requestLocationUpdates call, and the way the locationlistener behaves.
Android Locationlistener

The LocationListener

When looking at the code below, we’re initializing a MyLocationListener (to track the phone’s position), and retrieving a references to the LocationManager. We’re requesting location updates from the locationmanager, and are going to use our locationlistener. We’re using a minDistance( minimum distance interval for notifications) of 10 meters, and a minTime (the minimum time interval for notifications) of 35 seconds.
LocationListener locationListener = new MyLocationListener();
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 35000, 10, this.locationListener);
The LocationListener is typically implemented as an inner class like this :
private final class MyLocationListener implements LocationListener {

        @Override
        public void onLocationChanged(Location locFromGps) {
            // called when the listener is notified with a location update from the GPS
        }

        @Override
        public void onProviderDisabled(String provider) {
           // called when the GPS provider is turned off (user turning off the GPS on the phone)
        }

        @Override
        public void onProviderEnabled(String provider) {
           // called when the GPS provider is turned on (user turning on the GPS on the phone)
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
           // called when the status of the GPS provider changes
        }
}
The status of the GPS The onStatusChanged allows the developer to act upon GPS changes. The android.location.LocationProvider defines the following 3 constants :
public static final int OUT_OF_SERVICE = 0;
public static final int TEMPORARILY_UNAVAILABLE = 1;
public static final int AVAILABLE = 2;


these constants are very important, as they can help you pinpoint the users location in an efficient way without consuming too much battery.
 GPS behavior 
When you enable the GPS on your Android phone, the GPS doesn’t immediately starts retrieving your location. No GPS icon will be shown in the title bar, unless a certain application (like Google Maps) triggers it to request a location. That being said, when you call requestLocationUpdates, you’ll start noticing the GPS icon. This means the GPS is trying to pinpoint your location. When you see the GPS icon on your phone, you know that it’s consuming your battery power. The GPS will try to pinpoint your location, by tracking whatever available sattelites, and your location listener will be notified of location updates. Going back to the minTime and minDistance in the requestLocationUpdates call, you’ll notice the following in the JavaDoc : The frequency of notification may be controlled using the minTime and minDistance parameters. If minTime is greater than 0, the LocationManager could potentially rest for minTime milliseconds between location updates to conserve power. If minDistance is greater than 0, a location will only be broadcasted if the device moves by minDistance meters. To obtain notifications as frequently as possible, set both parameters to 0. Important to understand here is that setting the frequency (minTime) to 35 does not mean that your locationListener will only kick-in once every 35 seconds. The minimum time interval for notifications, in milliseconds is only used as a hint to conserve power, and actual time between location updates may be greater or lesser than this value. 
A closer look at the Location updates:
So how exactly does the listener receive its updates from the GPS ? In order to get a better understanding, I’ve provided some debug output here :


06:08:26.563 onStatusChanged : 2
06:08:27.588 onLocationChanged(7) latitude:50.97449993688022,longitude:3.5358700188733723,accuracy:30.0,speed:0.0,distance:21.503359
06:08:30.623 onLocationChanged(8) latitude:50.974434293586995,longitude:3.5359907425477335,accuracy:30.0,speed:0.0,distance:32.218872
06:08:31.593 onStatusChanged : 1
06:09:05.608 onLocationChanged(9) latitude:50.9712038679967,longitude:3.5394928882769894,accuracy:50.0,speed:0.0,distance:467.71277
06:09:05.753 onStatusChanged : 2
06:09:06.533 onStatusChanged : 2
06:09:10.873 onLocationChanged(10) latitude:50.97110957602014,longitude:3.539618155022894,accuracy:10.0,speed:0.0,distance:13.691443
06:09:13.558 onLocationChanged(11) latitude:50.971016001083534,longitude:3.539753147820122,accuracy:10.0,speed:0.0,distance:27.766773
06:09:15.578 onLocationChanged(12) latitude:50.97075818753055,longitude:3.5401285967306433,accuracy:10.0,speed:13.815152,distance:66.72456
06:09:15.648 onStatusChanged : 1
06:09:49.478 onLocationChanged(13) latitude:50.96681933024499,longitude:3.545226289347784,accuracy:50.0,speed:0.0,distance:632.5491
06:09:49.608 onStatusChanged : 1
06:09:50.458 onStatusChanged : 2
06:09:51.473 onLocationChanged(14) latitude:50.966721746737235,longitude:3.545281927748393,accuracy:30.0,speed:0.0,distance:11.53809
06:09:53.573 onLocationChanged(15) latitude:50.96660884513233,longitude:3.545389390695079,accuracy:10.0,speed:0.0,distance:26.068806
06:09:55.678 onLocationChanged(16) latitude:50.96650791908139,longitude:3.545518472378957,accuracy:30.0,speed:0.0,distance:40.26756
06:09:57.573 onLocationChanged(17) latitude:50.96640155866962,longitude:3.5456730749013285,accuracy:30.0,speed:2.070427,distance:56.081165
06:09:59.673 onLocationChanged(18) latitude:50.96615563268463,longitude:3.5460949510506223,accuracy:10.0,speed:0.0,distance:95.787544
06:09:59.698 onStatusChanged : 1
06:10:41.473 onLocationChanged(19) - latitude:50.96205927969342,longitude:3.5524753138825638,accuracy:50.0,speed:0.0,distance:734.681
06:10:41.628 onStatusChanged : 2
06:10:42.758 onLocationChanged(20) - latitude:50.961888473230154,longitude:3.5527996196353895,accuracy:30.0,speed:0.0,distance:29.6679
06:10:43.403 onStatusChanged : 2
06:10:44.563 onLocationChanged(21) - latitude:50.961826897652465,longitude:3.552931366353259,accuracy:30.0,speed:0.0,distance:41.168972
06:10:47.568 onLocationChanged(22) - latitude:50.96176400602706,longitude:3.5530746256419548,accuracy:30.0,speed:0.0,distance:53.40253
06:10:50.568 onLocationChanged(23) - latitude:50.96166823279162,longitude:3.5532218977203804,accuracy:30.0,speed:0.0,distance:68.14442
06:10:51.578 onLocationChanged(24) - latitude:50.96148115687591,longitude:3.5534584966993483,accuracy:10.0,speed:10.618344,distance:94.38
06:10:51.658 onStatusChanged : 1
06:11:25.498 onLocationChanged(25) - latitude:50.95848676663813,longitude:3.55830634713322,accuracy:50.0,speed:0.0,distance:570.7769
06:11:25.658 onStatusChanged : 2
....
What we should notice from this logging :
 We notice multiple location updates that follow each other very quickly, followed by a period of inactivity. During that period of inactivity we don’t receive location updates no updates occur between 06:08:30 – 06:09:05 , 06:09:15 – 06:09:49 Prior to every period of inactivity, the GPS status is changed to TEMPORARILY_UNAVAILABLE Prior to each batch of locationupdates, the GPS status is changed to AVAILABLE Analyzing a bit more : At 06:08:26 the GPS is marked available and trying to pinpoint our location. (We receive 2 location updates) At 06:08:31 the GPS is marked temporarily unavailable and we aren’t getting any location updates for a period of 35 seconds. At 06:09:05 the GPS is marked available, and we’re again receiving updates. (We receive 4 location updates) At 06:09:15 the GPS is marked temporarily unavailable and we aren’t getting any location updates for a period of 35 seconds. At 06:09:49 the GPS is marked available, and we’re again receiving updates. (We receive 5 location updates) At 06:09:59 the GPS is marked temporarily unavailable At 06:10:41 the GPS is marked available, and we’re again receiving updates. (We receive 6 location updates) At 06:10:51 the GPS is marked temporarily unavailable So we’re seeing a pattern here, driven by our minTime = 35. Every 35 seconds our GPS kicks in and tries to retrieve the location. It does so by providing the location listener with multiple location updates that we can use to track t he users location, before going idle. Notice how during these windows where its pinpointing a location, and location updates are sent to the listeners, different accuracies are provided. When we look at the 06:09:05 – 06:09:15 range, the first location update has an accuracy of 50 meters, while subsequent location updates have an accuracy of 10 meters. The developer can choose the most accurate location update from the multiple location updates that the listener is receiving. The window where the GPS is sending location updates is the window where most of the battery consumption takes place. After that, a quiet period kicks in where you won’t see the GPS icon, and you won’t be receiving location updates. Conclusion: Tweaking the minTime and minDistance parameters on the LocationManager, and capturing GPS status updates allows you to fine-tune your user location development. It’s very important to : understand how the GPS interacts with the LocationManager and the LocationListener. have an understanding of the minTime and minDistance parameter. realize that although the emulator allows you to simulate geo fixes, you always need to spend time testing it on the actual device, with a live GPS connection.