Thursday, November 17, 2011
Dart, Google's Programming Language for the Web
Dart is a new class-based programming language for creating structured web applications. Developed with the goals of simplicity, efficiency, and scalability, the Dart language combines powerful new language features with familiar language constructs into a clear, readable syntax.
Dart is flexible because it's both static and dynamic, it's both for clients and servers and it's useful for both small scripts and large projects. Dart apps are easier to debug, to maintain and to develop collaboratively. The language is optimized for performance and doesn't allow programmers to use features like defining constants that have to be computed at runtime.
For now, no browser supports Dart, but it's likely that Chrome will address this problem in the near future. The code can be executed "either on a native virtual machine or on top of a JavaScript engine by using a compiler that translates Dart code to JavaScript." Google already provides a simple online IDE called Dartboard that lets you edit a small program using your browser, but Dartboard will evolve into a full-fledged online IDE.
It will be difficult to convince developers and browser vendors to adopt the new language, but the fact that it's easy to convert Dart code to JavaScript is an important advantage. Google will promote it "as the language for serious web development on the web platform" and will "actively push for its standardization and adoption across the board". After all, "the goal of the Dart effort is ultimately to replace JavaScript as the lingua franca of web development on the open web platform." It's hard to say whether it will succeed, but it's worth trying to fix JavaScript's flaws by starting from the scratch. Google will have standardize the language, build development tools and develop powerful apps that use Dart to make a better case.
Wednesday, November 16, 2011
MVC validation by Data Annotation ---Razor view --- Entity Framework 4.1
namespace myNamespace
{
[MetadataTypeAttribute(typeof(Metadata))]
public partial class MyClass
{
private class Metadata
{
[Required]
public object Property_1{ get; set; }
}
}
}
2-enable client validation in the view:
@{ Html.EnableClientValidation(); }
@using (Html.BeginForm())
{
}
3- add the validation controls :
@Html.ValidationMessage("Property_1","*") // where "Property_1" is the property name which need to be validated
4- modify the controller to handle the validation : for example in the action we provide 2 different pathes , one for isValid== true another for is valid == false:
for example:
if (ModelState.IsValid)
{
// do work
}
else
{
// another work
}
Wednesday, November 9, 2011
SQL 2005 Replication Hell
Also this kind of replication is two way replication with instant synch, in other words what happen in branch 1 should appear in branch 2 instantly if connection is up.
So our choice was SQL 2005 Transactional Replication with Updatable Subscribers.
The main pain was in solving replication issues which concentrate in:
1- If connection is not reliable, the replication start conflicting without any way to find the reason of conflict. Is it data conflict due to concurrency or a conflict due to a failed stored procedure?
2- Triggers are a real hell in SQL 2005 Replication. You need to full understand the replication operations internals to be able to solve the triggers/replication issues
3- The replication logs didn't deliver that much information to be able to find the core cause of replication conflicti ssue
4- The SQL Replication Monitor is a joke. you cannot rely on it to really monior or find problems in your replication deployment. And the Monitor itself causes issues to the replication monitor parameters if left open for long period of time.
5- The SQL BOL is really not helpful to understand the internals of SQL Replication which is necessary with business requirement challenges here in egypt
In the next post I will provide some usefull links that may help you in your transactional replication problems regarding main causes of data conflict which is not based on data concurrency.
Also in future posts I will introduce SQL 2008 Replication deployment experience and I will give a comparison with SQL 2005 Replication (the odds and evens)
Wednesday, October 22, 2008
Visual Studio 2005 Bootstrapper
- Scenario
Assuming that you are going to package an application developed by Visual Studio 2005 and assuming also that you did the job successfully - as you think – and that you take the package and to test it right –as you think too – you install it on another developer's PC and everything goes well ..
What is the next step ?
A user buy this application and the following scenario is expected to occur :
The app won't run ;D or even installed , of course, unless the .NET Framework 2.0 is installed. Consider that you use a SQL Server™ 2005 Express Edition database. Hmmm Okay, you have to inform the user that these components should be installed on his/her machine.
First, the user has to check whether each component is already installed on the machine. Then he/she must manually download and run the installers for each missing component, selecting the appropriate choices in the installation UI. If any reboots are required, he/she must restart the machine and resume from where they left off. If the components need to be installed in a particular order, there are additional opportunities for things to go wrong. This is a poor user experience, to say the least, and many users would give up.
The Visual Studio® 2005 Bootstrapper solves this problem by allowing you to provide an easy, integrated way to install all of the different prerequisite pieces required by your application.
- What is Visual Studio 2005 Bootstrapper ?
The Visual Studio 2005 Bootstrapper lets you provide users with a simple, automated way to detect, download, and install an application and its prerequisites. It serves as a single installer that integrates the separate installers for all the components making up an application, and provides a wealth of features and services.
The Bootstrapper is a small executable that weighs in at a mere 222 KB, and takes about one minute to download on a 28.8 Kbps modem. It therefore adds only a small amount of overhead to the installation process, which can save the user from having to download much larger redistributables if he does not need them. It doesn't install a component that will not run on the target machine, the bootstrapper notifies the user and ends the installation before installing the component. It provides a flexible options for detecting whether a component is already installed or not.
Most components include an End-User License Agreement (EULA) that serves to protect the component vendors' intellectual property. The Bootstrapper can be configured to present license agreements for individual components. It can also present a single shared license agreement for multiple components in order to minimize the number of pop-ups the user has to click through.
The Bootstrapper can install prerequisites form local drives, web and file shares. It can be configured to download prerequisites components from the same location as the app installer. It detects whether any of the prerequisites are already installed. If any of the prerequisites are missing, the Bootstrapper shows an install dialog box that lists those components and displays their license agreement. Otherwise, if all of the prerequisites are detected, the Bootstrapper simply launches the application installer.
- Configuring the Bootstrapper
The Bootstrapper offers a couple of options for where redistributable files can be located. By default, the Bootstrapper assumes that all files, including the redistributables, the Bootstrapper setup.exe itself, and the actual application files, are located together under the same folder. This is ideal for applications that will be installed from local disk (CD-ROM, USB device) or a network share. This option also supports the application publisher who wants to serve up everything from a single deployment server. Alternatively, if the publisher wants to balance the load across different servers, or maintain a central location for prerequisite components that can be shared by multiple applications, the Bootstrapper can be configured to download any prerequisite files from a separate location.
- Custom Redistributables in Visual Studio
Adding your own redistributables to Visual Studio requires that you author the product and package manifests, then copy these files along with your redistributable files into a special folder that Visual Studio has reserved for redistributables that plug into the Bootstrapper. This folder is installed by default like so:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bootstrapper
The problem that you might face is that you need two xml files – two manifests – that is required for installing the redistributables which are product and package. I have noticed that product.xml should be in the same folder that has the redistributable file and the package.xml file has to be in a 'en' folder in the same location of the redistributable. If you have a license agreement text file put it beside package.xml file.
Manifest files has tags that are easy to be understood ,but It will require a good effort to insert it for your redistributables may try to use Bootstrapper Manifest Generator. You have to note that when you try to open the setup project you may encounter a warnings, but it will be went away when you fix the product and package manifests.
- Resources
- Adding Custom Prerequisites (http://msdn.microsoft.com/en-us/library/ms165429(VS.80).aspx)
- Use the Visual Studio 2005 Bootstrapper to Kick-Start Your Installation (http://msdn.microsoft.com/en-us/magazine/cc163899.aspx)
- Adding Custom Prerequisites (http://msdn.microsoft.com/en-us/library/ms165429(VS.80).aspx)
Wednesday, July 9, 2008
Mapped Network Drive Disconnection Problem
If you are using mapped network drives to share files across multiple computers across windows workgroup, you will suffer from mapped network drives random disconnection. We made a lot of testing regarding this issue and at last we found a solution that will keep mapped network drives connection.
The following is a description of issues you may face with mapped network drives and the solution for each issue.
Use IP Address Instead of Computer Name
In workgroup environment using computer name results in latency accessing shared resources. Since there is no Domain Name System Server (DNS) that resolves computer names to its corresponding IPs.
To achieve less latency between workgroup connected computers, use IP address instead of computer name to access remote computers without the need for DNS.
To use IP address in workgroup, configure each computer to have a static IP address instead of relying on DHCP. Ensure that all computers in the workgroup are using static IPs in the same range e.g. 192.168.10.1 to 192.168.10.255.
In case of existence of DHCP, ask you network administrator to reserve a set of IP addresses to use in the workgroup installation.
You can use the IP address of each PC to access it or configure windows hosts (this file can be found under C:\WINDOWS\system32\drivers\etc) file to assign each PC name to its static IP address.
Mapped Network Drive Connections
The mapped network drives configured on client PCs may suffer disconnection during windows startup or during the day. This occurs for two reasons:
- Computers running in Workgroup may fail to reestablish the Mapped Network Drive Connection during computer logon process.
- The Computer that hosts the shared folders will disconnect idle clients if no action occurred in the current session. This will result in disconnection of mapped network drives in client PCs
To resolve the above issues several actions should be taken
- Reconnect the network drives in workgroup PCs every time users logon to windows. This can be achieved automatically using windows script that runs during windows startup
- Configure the shared folder host computer to disable automatic session disconnect. This can be achieved automatically using windows script that runs during windows startup
The above actions can be performed using windows net command. To make life easier, a windows script can be used to call the required net commands. The following code snippet describes how such script can be done.
MappDrives.JS Code Snippet
This code need to run on each PC that needs to have mapped network drive. This can be done in the computer startup, as auto run entry in the host computer registry under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
var shell = WScript.CreateObject("WScript.Shell");
var serverIP = "\\\\192.168.10.1";
var username = "";
var password = "";
var zDrive = serverIP+"\\Shared";
DisableAutoDisconnect();
MapDrive("Z:",zDrive);
function MapDrive(drive,share)
{
var netcmd = "net use " + drive + " " + share;
if(username != "")
{
netcmd = netcmd + " /USER:" + username + " " + password
}
netcmd = netcmd + " /P:YES";
RunCmd(netcmd);
}
function DisableAutoDisconnect()
{
var netcmd = "net config server /AUTODISCONNECT:-1";
RunCmd(netcmd);
}
function RunCmd(cmd)
{
shell.Run(cmd,0,false);
}
serverIP:
has the IP of the host PC with shared folder we want to map network drive from
username & password:
has the username and password required to access shared folders in the host PC
zDrive:
the target shared folder path [Computer Name]\\[Shared Folder Name]
MapDrive: construct the required net command to map the shared folder to Z drive.
DisableAutoDisconnect.JS Code Snippet
This script needs to run on the host PC. This can be done in the computer startup, as auto run entry in the host computer registry under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
var shell = WScript.CreateObject("WScript.Shell");
DisableAutoDisconnect();
function DisableAutoDisconnect()
{
var netcmd = "net config server /AUTODISCONNECT:-1";
RunCmd(netcmd);
}
function RunCmd(cmd)
{
shell.Run(cmd,0,false);
}
DisableAutoDisconnect: disable the host PC automatic session disconnect by setting the timeout to -1
Avoid Disconnect During the Day
To ensure that there are no disconnect will occur, additional step can be done. Schedule a periodic task on windows to run the MapDrives.JS script. You can use windows tasks scheduler to do this or implement your own scheduler in your software application.
Wednesday, June 25, 2008
AgDataGrid Suite for SliverLight(Free)
I found this through code project http://www.devexpress.com/Products/NET/Controls/Silverlight/Grid/
Wednesday, June 11, 2008
Get Database Tables Sizes
This script lists the database table's size. This script found under the following post:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1784430&SiteID=1
I modified it to include the schema for table name to be useful with tables with non default schema.
DECLARE
@TotalRows int,
@Counter int,
@TableName varchar(50)
DECLARE @MyTables table
( RowID int
IDENTITY,
TableName varchar(50),
Rows
bigint,
Reserved varchar(12),
Data varchar(12),
IndexSize varchar(12),
Unused varchar(12)
)
INSERT
INTO @MyTables ( TableName )
SELECT TABLE_SCHEMA +
'.'
+ TABLE_NAME FROM
INFORMATION_SCHEMA.TABLES
SELECT @TotalRows =
@@ROWCOUNT, @Counter = 1
WHILE
( @Counter <= @TotalRows )
BEGIN
SELECT @TableName = TableName FROM @MyTables
WHERE RowID = @Counter
INSERT
INTO @MyTables EXECUTE
sp_spaceused @TableName
SET @Counter =
( @Counter + 1 )
END
DELETE
FROM @MyTables
WHERE RowID <= @TotalRows
SELECT TableName,
Rows, Reserved,Data, IndexSize, Unused FROM @MyTables
ORDER
BY Rows DESC
GO