Archive for January, 2007

Pascal to C# conversion

Tuesday, January 30th, 2007
Conversion is software re-engineering process. For using that, you should know both the languages. i.e. Pascal and C#.Why do we opt for Conversion Software ?:1) For Better Technology2) For Better Speed3) For Modularity

4) For Process Optimization

1) For Better Technology :

As Pascal is very old language, some of the features are not available as required for 3G Software like.- User Interface, Client Server Architecture etc.. And aAs C# is 3G Language, . bBetter GUI can be made easily.

2) For Better Speed. / Process Optimization

In Some applications, Pascal is more efficient and speedy than many 3G Languages.

Eg. File Manipulation Project. But Commercial Application can not be more efficient in Pascal. Application having extensive use of DATABASE can not be possible with Ppascal.

3) For Modularity :

Pascal is sequential language. It is not object oriented language. Variable declared in any Units of C# can be made available in current unit by just including that unit on the top of the file. wWhile in c# wWhole pProject is dDivided into Classes and hence wWithout an oObject wWe can not access variable declared in that class. C# have access specifier like Public, Private, Protected while fFor Pascal all variables iare s Public and can be available every where. Reusability can not be possible up to that extent ds as it is possible in c#.

What steps should be considered while using conversion software re-engg. Process ?:

1) Learning and Understanding Both Languages ( C# and Pascal )

2) Data Type Mapping for both languages.

a. Match types of Variable in Pascal with best match variable in c# ( eg . Integer in Pascal and int in c#).

b. Size of Variable.

Integer Int

3) Memory Management.

As Pointer is directly supported by Pascal., dDirect implementation of pointer is not possible in c#.. As Pascal is using stack to store all the values of variable but c# is storing all the values in stack and heap memory.

4) File Management

File manipulation of Pascal is more efficient than C#. aAs Pascal provides direct support of sequential file access and random file access (through index). In C# nNo direct namespace is available for such file management function.

Another advantage of Pascal over c# is that structure (Record) is more efficient with file manipulation. wWhile in c# Structure is just logical bifurcation of Records.

Another advantage of Pascal over c# is that it provides better searching facilities in file with the help of Indexes. wWhile nNo such provision is there in c#.

5) Value Truncation (Implicit Conversion and Explicit Conversion)

We need to considered, Value truncation at the time of using Cconversion Software of Re-Engg. Process..

Pascal to C# Journey:

(1) We have decoded all the lines of pascal code.

(2) We have prepared Algorithm and Flow Charts of Existing Pascal code.

(3) We have studied both languages and considered all Factors mentioned above.

(4) We have dDecided all general Functions , wWhich will be required in c#

(5) We have developed Code Architecture and GUI Design.

(6) Started converting writing c# Code.

Author:

By Krunal Mevada

Krunal Mevada is working as a Jr. Programmer at Semaphore Infotect Pvt. Ltd, India. He has 4 months Experience.

By Narendra Desai

Narendra Desai is working as a Programmer at Semaphore Infotech Pvt. Ltd, India. He has more than 1.5 years Experience.

Record Locking in SQL Server

Tuesday, January 30th, 2007

Pessimistic and Optimistic Concurrency

In a multi-user environment, there are two models for updating data in a database: optimistic concurrency and pessimistic concurrency.

Pessimistic concurrency involves locking the data at the database when you read it. You essentially lock the database record and don’t allow anyone to touch it until you are done modifying and saving it back to the database. Here you have 100% assurance that nobody will modify the record and while you check it have it checked out, out. aAnother person will have to wait until you have made the your changes.

By default, SQL Server controls lock escalation, but you can control it yourself by using lock optimizer hints. Here are some lock escalation hints you may want to consider:

· ROWLOCK This hint guides tells SQL Server to use row-level locking instead of page locks for INSERTS. By default, SQL Server may perform as a page-level lock instead of a less intrusive row-level lock when inserting data. By using this hint, you can guide tell SQL Server to always start out using row-level locking. But, this hint does not prevent lock escalation if the number of locks exceeds SQL Server’s lock threshold.

· SERIALIZABLE (equivalent to HOLDLOCK) applies only to the table specified and only for the duration of the transaction, and it will hold a shared lock for this duration instead of releasing it as soon as the required table, data page, row or data is no longer required.

· TABLOCK specifies that a table lock to be used instead of a page or row level lock. This lock will be remained held until the end of the statement.

· TABLOCKX specifies that an exclusive lock will be applied held on the table until the end of the statement or transaction, and will prevent others from reading or updating the table.

· UPDLOCK specifies that update locks will be used instead of shared locks, and will hold the locks until the end of the statement or transaction.

· XLOCK specifies that an exclusive lock be used and kept activated held until the end of the end of the transaction on all data being processed by the statement. The granularity of XLOCK will be adjusted if it is used with the PAGLOCK or TABLOCK hints.

SQL Server 7.0 and SQL Server 2000 Lock Escalation Options

You can override how SQL Server performs locking on a table by using the SP_INDEXOPTION command. Below is an example of code you can run to guide tell SQL Server to use page locking, not row locks, for a specific table:

SP_INDEXOPTION ‘INDEX_NAME’, ‘ALLOWPAGELOCKS’, TRUE

When FALSE, page locks are not used. Access to the specified indexes is obtained using row- and table-level locks only.

SP_INDEXOPTION ‘INDEX_NAME’, ‘ALLOWROWLOCKS’, TRUE

When FALSE, row locks are not used, . aAccess to the specified indexes is obtained using page- and table-level locks only.

SQL Server 2000 Lock Escalation Options

SP_INDEXOPTION ‘INDEX_NAME’, ‘DISALLOWPAGELOCKS’, TRUE

When TRUE, page locks are not used,. aAccess to the specified indexes is obtained using row- and table-level locks, only.

SP_INDEXOPTION ‘INDEX_NAME’, ‘ALLOWROWLOCKS’, TRUE

When TRUE, row locks are not used., aAccess to the specified indexes is obtained using page- and table-level locks, only.

When these commands are used, they affect all queries that eaffect these indexes. This command should not be used unless you know, positively, that they always produce the results you desire.

Important

The SQL Server query optimizer automatically makes the correct determination. It is recommended that you do not override the choices the optimizer makes. Disallowing a locking level can affect the concurrency for a table or index adversely. For example, specifying only table-level locks on a large table accessed heavily by many users can affect performance significantly. Users must wait for the table-level lock to be released before accessing the table.

Optimistic concurrency means you read the database record, but don’t lock it. Anyone can read and modify the record at anytime and you will take your chances that the record is not modified by someone else before you have a chance to modify and save it. As a developer, the burden is on you to check for changes in the original data (collisions) and act accordingly based on any errors that may occur during the updating e process..

With optimistic concurrency, the application has to check for changes to the original record to avoid overwriting changes. There is no guarantee that the original record has not been changed, because no lock has been placed on that data at its source - the database. Hence, there is the real possibility of losing changes made by another person.

Optimistic Concurrency Strategies

If you are in a performance state-of-mind, there are chances of your chosingchances are you will go with optimistic concurrency. Optimistic concurrency frees up database resources as quickly as possible so that other users and processes can act upon that data as soon as possible.

There are four popular strategies to deal ing with optimistic concurrency:

1. Do Nothing.

2. Check for changes to all fields during update.

3. Check for changes tof modified fields during update.

4. Check for changes to timestamp (row version) during update.

All of these strategies have to deal with the shaping of the Update T-SQL Command sent to the database during the updating of the data. The examples below are not very detailed on purpose and assume a basic understanding of ADO.NET.

Optimistic Concurrency on Update Strategy #1 - Do Nothing

The simplest strategy for dealing with concurrency issues during the updating of data is to do nothing.

The update command will not check for any changes in the data, only specify the primary key of the record to be changed. If someone else changed the data, those changes will more than likely be overwritten:

Update Product

Set

Name = @Name

Where

ID = @ID

One would hope that this means either 1) the application is a single-user application, or 2) the chance of multi-user update collisions is very unlikely and the repercussions of overwriting data is negligible.

Optimistic Concurrency on Update Strategy #2 - Check All Fields

With this strategy, the update command will check that all fields in the row (usually minus BLOB fields) are equal to their original values when performing the update to assure no changes have been made to the original record. A check of the return value of the ExecuteNonQuery Command will indicatetell you if the update actually took place. The return value of the ExecuteNonQuery Command is typically the number of rows affected by the query.

Update Product

Set

Name = @Name,

Where

ID = @ID

AND

Name = @OriginalName

AND

Price = @OriginalPrice

This is essentially what CommandBuilder creates when using DataSets and is a strategy that doesn’t want to see any changes to the data.

Optimistic Concurrency on Update Strategy #3 - Check Only Changed Fields

Rather than checking all fields in the row to make sure they match their original value, this strategy checks only those fields whichthat are being updated in the command.

Update Product

Set

Name = @Name

Where

ID = @ID

AND

Name = @OriginalName

This strategy only cares that it is not overwriting any data and could care less thant other fields in the record may have been changed. This could create an interesting combination of data in the row.

Optimistic Concurrency on Update Strategy #4 - Implement Timestamp

SQL Server has a timestamp ( alias rowversion ) field that is modified every time a change is made to a record that contains such a field. Therefore, if you add such a field to a table you only have to verify the timestamp record contains the same original value to be assured none of the fields have been changed in the record.

Update Product

Set

Name = @Name

Where

ID = @ID

AND

TimestampID = @TimestampID

This is the same as Strategy #2 above without the need for checking all fields.

Optimistic concurrency has a performance component to it that suggests a higher performing ASP.NET website.

There are other methods of achieving optimistic concurrency, but I think the ones above are the most popular. A developer needs to look at the application itself to determine which strategy makes sense. The DataSet, Command Builder, and DataAdapter typically handle this stuff for you using Strategy #2. However, if you work with objects instead of DataSets, you need to handle concurrency issues yourself.

Author:

By Kalpesh Bakotiya

Kalpesh Bakotiya is working as a Programmer at Semaphore Infotech Pvt. Ltd, India.

Overview of Ajax

Tuesday, January 30th, 2007
Ajax (Asynchronous JavaScript And Xml), term coined by Jesse James Garret of adaptive path. Ajax is not a new technology but it’s a web development technique for creating interactive web applications. Ajax is used to exchange small amount of data with server behind the  scenes, so that the entire web pages does not have to be reloaded each time when user makes a change. AJAX programming is centered around the XMLHTTPRequest () Object.  This is the piece that makes all AJAX programming possible.  Unfortunately, creating the XMLHTTPRequest () object is different for each browser.

Internet Explorer uses an ActiveX object to create its XMLHttpRequst object:

Var myRequest = new ActiveXObject (”Microsoft.XMLHTTP”);

While Mozilla/FireFox and Safari use a native object:

            Var myRequest = new XMLHttpRequest ();

Here are the basic technologies involved in Ajax applications:· XHTML (or HTML) and CSS, for marking up and styling information.

· The DOM accessed with a client-side scripting language, especially ECMAScript implementations such as JavaScript and JScript, to dynamically display and interact with the information presented.

· The XMLHttpRequest object is used to exchange data asynchronously with the web server. In some Ajax frameworks and in certain situations, an IFrame object is used instead of the XMLHttpRequest object to exchange data with the web server, and in other implementations, dynamically added

How to upload large file in php?

Tuesday, January 30th, 2007
I have one form  Mmy aim was to upload big files from local disk to server.

but when i click on upload button it does not upload the file without showing any error. then Ii searched for a solution from web site  and  for this solution

then i found solution by changing environment variable of php.ini

To find ound where php.ini file,  is located run this small code

phpinfo();

?>

and search “Configuration File (php.ini) Path ” row , there will be an in output window and this  which will contain path  of php.ini file in your PC

and in this php.ini file, change the variable size as per requirement

            upload_max_filesize = (size)M

            post_max_size = (size)M

new in php 5

            max_input_time = (value)   //in second

 max_input_time variable  which sets a time limit in seconds for receiving input data through POST, GET, and PUT. If your application is running over a slow link,

it is sometimes worthwhile to explore increasing this value to allow the script more time to receive input data. or you can change this variable at run time through programme

example

ini_set(‘post_max_size’,'9M’)

now post_max_size variable is 9 MB set.

using

string ini_set ( string varname, string newvalue )

now i added client side validation for restricting user to upload more than particular file size.

           

use this hidden variable and its value contain how many bytes allow to be upload.

if you want store file in mysql Long blog data type.

set the variable

max_allowed_packet = (byte)

The above steps solved my problem and i can upload big file without any hurdle..

Author:

By Jayesh Sorathia

Jayesh Sorathia is working as a Jr. Programmer at Semaphore Infotech Pvt. Ltd, India. He has 8 months Experience. You can contact on email: jayesh@semaphore-software.com.

Developing Web Application with Web Service

Tuesday, January 30th, 2007
Introduction:Web services extend the World Wide Web infrastructure to provide the means for software to connect to other software applications. The Applications access Web services via ubiquitous Web protocols and data formats such as HTTP, XML, and SOAP, without no need getting to worried or confused y about how each Web service is implemented. Web services combine with the best aspects of component-based development and the Web, and are a cornerstone of the Microsoft .NET programming model.

How to create web service project:

1. Select New Web Site option from File Menu in .net IDE.

By default it created one method HelloWorld() with string return type.

All web method I defined in “Service.vb” file.

You can test it by running it (pressing F5).

You will find following result.

Pressing invoke button will invoke or call HelloWorld() define in web service.

2. The second step is to publish web service created by you. For that right click on web service project name in solution explorer and select publish web site option . aAs shown in the following window :figure.

Where “MyWebService” is name of web service to be published (virtual directory).

3. The third step is to create blank web application and link created web service with website project. So, first create a blank website project.

4. Adding Web Reference to web project by right clicking on project name as shown in the following window :.

5. It Will lead to Add Web Reference dialog box. Where you can find or type url of your web service and browse also.

6. Dialog box gives u three option to search web service

a. Web services in this solution

b. Web services on the local machine

c. Browse UDDI Servers on the local network

The fFirst option is used to search web service in current solution. Second option is used to search web service on your local computer. I do not have any idea about the third option since Third option has no idea for me.Because I never used that one.

So, select second option and that will gives u result of all web service names resides on your local computer.

Select your development ed service from that list.

It will show a method hello world() which we developed in web service.

7. Now you can change of web service object while you adding web reference to your project by entering text at right side of upper screen and thenat click on add reference button.

After adding web reference solution explorer will get the has this structure as shown In following dialogue box :picture.

Now, the main question is how to access that service in your web site. So we move to that step.

8. Now to access web methods create one object of web reference in your project

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim objWebService As New MyWebService.Service

Response.Write(objWebService.HelloWorld)

End Sub

Running project will give output Hello World String return by web service.

Similarly you can define any method in web service and access in your web site.


Developing Web Application with AJAXThe In asp.net 2.0 Microsoft has provided net ajax structure that is known as CallBack feature , in background it uses XMLHttpRequest object for asynchronous data transmission between pages without full page refreshing method.Components of Client Callbacks

· Implement the ICallbackEventHandler interface. You can add this interface declaration to any ASP.NET Web page.

· Include a method that implements the GetCallbackResult() interface. This method will be invoked by the callback, and then it returns a string to the clientCallback function.

· Include a method that implements the RaiseCallbackEvent interface. This method will be invoked by the callback, and process which ever is writing in to it at server side.

Steps to make callback application.

1. Implement ICallbackEventHanlder in page class

public partial class _Default : System.Web.UI.Page , ICallbackEventHandler

2. Creating serverside callback method

string eventArgument = “”;

public void RaiseCallbackEvent(string eventArgument)

{

this.eventArgument = eventArgument;

}

3. Creating server side return result method that returns a result to client side function

public string GetCallbackResult()

{

return “Hello from the Server.\nTime is: ” + DateTime.Now.ToString() +

“\r\nPassed event argument: ” + this.eventArgument;

}

4. Creating client script function and actual implmementation of callback technique.

protected void Page_Load(object sender, EventArgs e)

{

if (!IsCallback)

{

ScriptRef = this.ClientScript.GetCallbackEventReference(

this,

“document.forms[0].btnCallServer.value”,

“OnCallback”,

“this”,

“OnCallback”,

true);

this.btnCallServer.Attributes.Add(”onclick”, ScriptRef);

}

}

5. The Client side code should look like this.

Simple Client Callback
Page loaded on:

You can see that when button is pressed thean callback event is fired and it passes argument as value field of button that is ”Get Server Time” and “GetCallbackResult()” method return time string to “OnCallBack()” method and it displays as alert.In “RaiseCallbackEvent(string eventArgument)” you can perform any serverside functionality and return any result via “eventArgument” variable.So this way you can perform and asynchronous operation using callback functionality and this feature is successfully runs on many browsers that support XMLHttpRequest object.

Author:

By Dhaval Charavda

Dhaval Charavda is working as a Programmer at Semaphore Infotech Pvt. Ltd, India.

Integrating Oracle Forms 6i with Oracle Applications

Tuesday, January 30th, 2007
Introduction

Enterprise Resource Planning or ERP is an industry term for integrated, multi-module application software packages that are designed to serve and support multiple business functions.

ERP applications consist of many modules such as Sales and Marketing, Field Service, Production, Inventory Control(Warehouse), Procurement(Purchase), Distribution, Human Resources(HR), Finance and Accounting.

Some of the very popular ERP packages are SAP, PeopleSoft, Baan and Oracle Applications etc.

Oracle Applications ERP (Oracle Apps) is developed using multi-tier architecture. Though it covers a large no. of functionalities for various functional domains, it also supports customized forms, which user can develop and the same can then be integrated into the Oracle Apps.

To work with Oracle Applicationss, one needs to understand its APIs and Processing logic. API stands for Application Program Interface. Oracle has Provided API in the form of PL/SQL Packages.

So, any developer who needs to develop custom form and integrate it with Oracle Applicationss, it is very important for him to understand these APIs and how they work in the application.

I have developed custom forms in Forms 6i and then integrated these forms with Oracle Applicationss. During this process, I have used some of the APIs as mentioned below:

1. Fnd_File           -        It is PL/SQL package for Input /Output processes.
2. Fnd_set            -        The FND_SET package includes procedures for creating concurrent

program request sets, adding programs to a request set, deleting

programs from a request set.

3. Fnd_program    -        The FND_PROGRAM package includes procedures for creating

concurrent program executables, concurrent programs with parameters

and incompatibility rules, request sets, and request groups.

4. Fnd_request     -        Stored procedure concurrent programs accept input parameters only,

and are submitted with the FND_REQUEST package.

5. Fnd_Submit      -        This package will submit the request sets.

As the Oracle Apps provides menu-driven application, a developer should use Form module of Oracle Forms 6i in his/her custom form. There is no need to use Menu modules in Oracle Applicationss custom form.

The following steps describe how to develop a custom form & integrate it with Oracle Apps:

1) Oracle Apps provides a template form called TEMPLATE.fmb to assist any developer with standard built-in controls & properties. The developer should save this template form as his/her form for ex. FRMMYFORM.fmb
2) Create a new window, by right clicking on Window/new

    Name this window as WIN_TEMP, and assign it Subclass Type “WINDOW”     

    from pick list.
3) Create a new canvas and name it CANC_MAIN, and make sure that its Subclass Type is “Content”.
4) Make the windows property under  reference canvas CANC_MAIN and vice versa make the canvas

    reference to windows WIN_TEMP.
5) Now create a block called CTL_BLOCK. Keep this a control block for simplicity.
6) Go to form level property, and set first navigation block to CTL_BLOCK.
7) Add a label and a field named “HELLO_WORLD” to this block.

8) Compile the form using Control + Shift + K.
9) Generate the form on PC using Control-T keystrokes. This will ensure that nothing turns wrong with the form.

10)  After doing all this process, you should move your form to your server’s directory.

11)  Now logon to your Linux server and do f60gen on FRMMYFORM.fmb

 
 

  


12) This will create a file executable as FRMMYFORM.fmx

13) Go to Administrator responsibility
      Menu /application  / / form and then register the form.

14) Register the Forms Function
      Please visit the following link for more information

http://getappstraining.blogspot.com/2006/10/oracle-forms-functions-menus-and-their.html
Author:

By Dharti Chaudhary

My Name is Dharti Chaudhary, I have experience of 1.5 years in Oracle Forms 6i, Oracle Reports 6i, Oracle 9i, PL/SQL scripting, Visual Basic 6.0. And now I am working on Oracle Apps at Semaphore Infotech Pvt. Ltd, India. You can contact on email: dharti@semaphore-software.com.



View My Stats