Add this nmethod after OnPropertyChanged("");
CommandManager.InvalidateRequerySuggested();
Thursday, June 25, 2015
Monday, August 4, 2014
Tuesday, July 15, 2014
Json.Net
Adding Json string to sql.
Model
[{"LocationId":152,"BranchCode":"21","SourceSystem":"RSSSP"}]
List
[{"LocationId":152,"BranchCode":"21","SourceSystem":"RSSSP"},{"LocationId":156,"BranchCode":"17","SourceSystem":"RSSSP"}]
.Net
using Newtonsoft.Json;
Create exact model
List<Model> objs = JsonConvert.DeserializeObject<List<Model>>(string);
Ref
http://james.newtonking.com/json
Model
[{"LocationId":152,"BranchCode":"21","SourceSystem":"RSSSP"}]
List
[{"LocationId":152,"BranchCode":"21","SourceSystem":"RSSSP"},{"LocationId":156,"BranchCode":"17","SourceSystem":"RSSSP"}]
.Net
using Newtonsoft.Json;
Create exact model
List<Model> objs = JsonConvert.DeserializeObject<List<Model>>(string);
Ref
http://james.newtonking.com/json
Tuesday, December 10, 2013
MVC 4 and Ninject
Starting MVC 4 with Ninject.
In VS 2012, Go to > Tools > Library Package Manager > Manage NuGet Packages for Solution.
----
Search for and select Ninject.MVC3 then install.
----
It will create a NinjectWebCommon.cs inside App_Start
Reference your dependency resolution project / dll
Add code to instantiate implementations for your interfaces.
e.g: //IKernel kernel = new StandardKernel(
// new LoggingModule(typeof(App).ToString(), App.AppPath.ToString())
// );
//kernel.Bind<IUserService>().To<UserService>();
//kernel.Bind<IDialogService>().To<DialogService>();
//kernel.Bind<IWorker>().To<AsyncWorker>();
//kernel.Bind<IDialogService>().To<DialogService>();
string appPath = System.Web.Hosting.HostingEnvironment.MapPath(System.Web.HttpRuntime.AppDomainAppVirtualPath);
var modules = new List<INinjectModule>
{
new LoggingModule(("Ninject"), appPath)
//new RepositoryModule()
};
kernel.Load(modules);
In VS 2012, Go to > Tools > Library Package Manager > Manage NuGet Packages for Solution.
----
Search for and select Ninject.MVC3 then install.
----
It will create a NinjectWebCommon.cs inside App_Start
Reference your dependency resolution project / dll
Add code to instantiate implementations for your interfaces.
e.g: //IKernel kernel = new StandardKernel(
// new LoggingModule(typeof(App).ToString(), App.AppPath.ToString())
// );
//kernel.Bind<IUserService>().To<UserService>();
//kernel.Bind<IDialogService>().To<DialogService>();
//kernel.Bind<IWorker>().To<AsyncWorker>();
//kernel.Bind<IDialogService>().To<DialogService>();
string appPath = System.Web.Hosting.HostingEnvironment.MapPath(System.Web.HttpRuntime.AppDomainAppVirtualPath);
var modules = new List<INinjectModule>
{
new LoggingModule(("Ninject"), appPath)
//new RepositoryModule()
};
kernel.Load(modules);
Monday, July 15, 2013
Self Hosting WCF
Security Rights
Check and firewall:
Window 7 Client
XP
Refference:
http://msdn.microsoft.com/en-us/library/ms733768.aspx
Check and firewall:
Window 7 Client
- netsh http add urlacl url=http://+:8090/ClientService/AppointmentNotification user=myUser or = users
XP
- httpcfg.exe set urlacl /u http://+:11715/service/ /a <http://+:11715/service/%20/a> D:(A;;GX;;;BU)
Refference:
http://msdn.microsoft.com/en-us/library/ms733768.aspx
Tuesday, June 25, 2013
Sync to ancestors properties
<Canvas>
<DockPanel
Width="{Binding RelativeSource=
{RelativeSource FindAncestor,
AncestorType={x:Type Canvas}},
Path=ActualWidth}"
Height="{Binding RelativeSource=
{RelativeSource FindAncestor,
AncestorType={x:Type Canvas}},
Path=ActualHeight}">
</DockPanel>
</Canvas>
Window Service - Pointers and troubles encountered.
AppDomain.CurrentDomain.BaseDirectory - To have a path same as the service location.
----------------------------------------
Add debug mode in win service
#if DEBUG #else #end
----------------------------------------
Install Manually
Right click window service and add install
Create batch files
Right click service and select recovery
----------------------------------------
Error encountered 1
System.ComponentModel.Win32Exception: The specified service already exists serviceInstaller.DisplayName = "A new name";
Error encountered 2
Error 1053: The service did not respond to the start or control request in a timely fashion framework version problem 2008 r2
----------------------------------------
Error Handling
Add another thread to catch the error
catch (Exception exception)
{
System.Threading.ThreadPool.QueueUserWorkItem(
_ => { _logger.Error("", exception.Message, "", "", exception.StackTrace); });
//_ => { throw new Exception("Exception on timer.", exception); });
}
----------------------------------------
Setup same framework
Check Windows Event, Windows Logs, System
----------------------------------------
Helpfull Links
http://stackoverflow.com/questions/14121079/windows-could-not-start-service-on-win-server-2008-r2-sp1-error-1053
http://www.coretechnologies.com/products/AlwaysUp/Apps/RunCommandPromptAsAService.html
----------------------------------------
Install Automatically manually
Add a new project
----------------------------------------
Add debug mode in win service
#if DEBUG #else #end
----------------------------------------
Install Manually
Right click window service and add install
- click serviceProcessInstaller and go to properties
- change account property : LocalService for local and LocalSystem for server
- click serviceInstaller and go to properties
- start type - automatic
- update service name and description to project name
Create batch files
- InstallUtil ServiceName.exe
- InstallUtil /u ServiceName
Right click service and select recovery
----------------------------------------
Error encountered 1
System.ComponentModel.Win32Exception: The specified service already exists serviceInstaller.DisplayName = "A new name";
- sc delete YourServiceName
Error encountered 2
Error 1053: The service did not respond to the start or control request in a timely fashion framework version problem 2008 r2
----------------------------------------
Error Handling
Add another thread to catch the error
catch (Exception exception)
{
System.Threading.ThreadPool.QueueUserWorkItem(
_ => { _logger.Error("", exception.Message, "", "", exception.StackTrace); });
//_ => { throw new Exception("Exception on timer.", exception); });
}
----------------------------------------
Setup same framework
Check Windows Event, Windows Logs, System
----------------------------------------
Helpfull Links
http://stackoverflow.com/questions/14121079/windows-could-not-start-service-on-win-server-2008-r2-sp1-error-1053
http://www.coretechnologies.com/products/AlwaysUp/Apps/RunCommandPromptAsAService.html
----------------------------------------
Install Automatically manually
Add a new project
Thursday, April 18, 2013
Ninject
I was once using IOC in one of my earlier projects back in 2007. "Castle Windsor" Now it's time to explore new dependency injectors. Ninject.
I am creating an admin tool for my current project. I want to explore new architecture, patterns and a testable loosely coupled application. So first goal is to setup a dependency resolution project which will help me decoupled my concrete classes from my client. To achieve this, here is a sample of code.
This is the entry point of my application. ILogger is the interface of my service that i will be using in my application. In this example, I used IKernel to create an instance of my ILogger to implement a specific implementation which is FileLogger.
using Infrastructure.Interfaces;
using Ninject.Modules;
public partial class App : Application
{
ILogger _logger;
protected override void OnStartup(System.Windows.StartupEventArgs e)
{
SingleInstance.Make();
base.OnStartup(e);
IKernel kernel = new StandardKernel(new LoggingModule(typeof(App).ToString(), App.AppPath.ToString()));
DependencyResolution(kernel.Get<ILogger>());
CreateEntryWindow();
_logger.Info("Application started!");
}
}
private void DependencyResolution(ILogger logger)
{
_logger = logger;
}
------------------------------------------------------------------------------
using BackDoors.Logger;
using Infrastructure.Interfaces;
using Ninject.Modules;
public class LoggingModule: NinjectModule
{
string _classObject;
string _appPath;
public LoggingModule(string classObject,string appPath="")
{
_classObject = classObject;
_appPath = appPath;
}
public override void Load()
{
Bind<ILogger>().To<FileLogger>()
.WithConstructorArgument("classObject", _classObject)
.WithConstructorArgument("appPath", _appPath);
}
}
Wednesday, March 20, 2013
Monday, October 1, 2012
Share...
I'm doing a research on how to setup a free sharepoint server to play with and study c# programming related codes.
I came to this page which i think will help a newbie like me. http://maanehunden.wordpress.com/2011/11/30/sharepoint-2010-create-a-free-test-environment/
Now setting up..., will do an update once these instructions are okay. 10/01/2012 3:15 pm
I came to this page which i think will help a newbie like me. http://maanehunden.wordpress.com/2011/11/30/sharepoint-2010-create-a-free-test-environment/
Now setting up..., will do an update once these instructions are okay. 10/01/2012 3:15 pm
Tuesday, August 7, 2012
WPF Style overriding
GLOBAL
--------------------------------------------------------------------------------
<Style BasedOn="{StaticResource {x:Type ListViewItem}}"
TargetType="ListViewItem">
<Setter Property="VerticalContentAlignment" Value="Top" />
</Style>
Use BasedOn to inherit from existing style, Then override only the line needed.
InLine
----------------------------------------------------------------------------------
<ListView.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ListViewItem}}"
TargetType="ListViewItem">
<Setter Property="VerticalContentAlignment" Value="Top" />
</Style>
</ListView.ItemContainerStyle>
Thursday, July 26, 2012
ClickOnce
ClickOnce allows you to deploy and updates application via IIS. Like a web page or web service, Windows application can now be deployed in servers and allowed to be consume by clients.
Steps:
1.) Setup web server where installer can be viewed via http.
2.) Setup shared folder where application can publish the installer.
3.) Setup project's properties ---> Publish Tab ---> (Refer to screen shot).
4.) 2 options in updating client application. Before the application launch and after.
Before application launch, a pop-up message will appear if there is an update. a user can defer this update by selecting "skip" button or can proceed with the update by selecting "ok" button.
Forced update to client can also be implemented by setting the minimum version before publishing the installer.
SETUP---------------------------------
IIS-------------------
-SiteName == SharedFolder
SiteName
http://sgurcmsap1rh:8088/
app pool to framework 4
sharedfolder
c:\sharedFolder
Share to everyone with read and write
CLICK ONCE----------------
publishing folder
\\SGURCMSAP1RH\EMRDeployment\
Installation folder url - -AssignPort 8088
http://sgurcmsap1rh:8088/
use only the root in the installation folder url
since no application is converted.
http://sgurcmsap1rh:8088/
not
http://sgurcmsap1rh:8088/RafflesEMRUAT.htm
---------------------------------------------------
Steps:
1.) Setup web server where installer can be viewed via http.
2.) Setup shared folder where application can publish the installer.
3.) Setup project's properties ---> Publish Tab ---> (Refer to screen shot).
4.) 2 options in updating client application. Before the application launch and after.
Before application launch, a pop-up message will appear if there is an update. a user can defer this update by selecting "skip" button or can proceed with the update by selecting "ok" button.
Forced update to client can also be implemented by setting the minimum version before publishing the installer.
SETUP---------------------------------
IIS-------------------
-SiteName == SharedFolder
SiteName
http://sgurcmsap1rh:8088/
app pool to framework 4
sharedfolder
c:\sharedFolder
Share to everyone with read and write
CLICK ONCE----------------
publishing folder
\\SGURCMSAP1RH\EMRDeployment\
Installation folder url - -AssignPort 8088
http://sgurcmsap1rh:8088/
use only the root in the installation folder url
since no application is converted.
http://sgurcmsap1rh:8088/
not
http://sgurcmsap1rh:8088/RafflesEMRUAT.htm
---------------------------------------------------
Tuesday, March 20, 2012
AutoCompleteBox KeyPress
I was looking for ways to get enter key in an AutoCompleteBox. But no events supports it. Key Down event of AutoCompleteBox does not trigger the EnterKeyEvent.
Solution:
Create a custom NewAutoCompleteBox then inherit AutoCompleteBox.
Override OnKeyDown
Access the base.OnKeyDown(e); then this will trigger the enter key event.
Solution:
Create a custom NewAutoCompleteBox then inherit AutoCompleteBox.
Override OnKeyDown
Access the base.OnKeyDown(e); then this will trigger the enter key event.
if(e.Key == Key.Enter) RaiseEnterKeyDownEvent();
Sunday, March 18, 2012
Expanded ListBoxItem's Width
This will allow element inside to expand its width.
The key here is in red font. This will allow you to stretch the grid element inside the ListBox.
-----------------------------------------------------------------------------------------------------
e.g (Maximize Grid element inside <ListBox.ItemTemplate> <DataTemplate> </DataTemplate> </ListBox.ItemTemplate>)
<Grid Width="auto" >
<Grid.Resources>
<Style x:Key="listContainerStyle" TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</Grid.Resources>
<ListBox ScrollViewer.VerticalScrollBarVisibility="Auto" ItemContainerStyle="{StaticResource listContainerStyle}" ScrollViewer.CanContentScroll="True" ItemsSource="{Binding Path=Model.Object}" Grid.ColumnSpan="2" Grid.Row="1" Name="lstDiagnosis" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem HorizontalContentAlignment="Stretch">
<Grid Margin="2" >
<Grid.ColumnDefinitions >
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock FontWeight="Bold" Text="{Binding Name}" Grid.Column="0" >
</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding Path=Description}" Grid.Column="1">
</TextBlock>
<Button HorizontalAlignment="Right" VerticalContentAlignment="Center" VerticalAlignment="Center" Margin="0,0,2,0" Style="{x:Null}" Grid.Column="2" FontWeight="Bold" FontSize="8" Tag="{Binding}" >
<TextBlock Text=" X " VerticalAlignment="Top" ></TextBlock>
</Button>
</Grid>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
-----------------------------------------------------------------------------------------------------
The key here is in red font. This will allow you to stretch the grid element inside the ListBox.
-----------------------------------------------------------------------------------------------------
e.g (Maximize Grid element inside <ListBox.ItemTemplate> <DataTemplate> </DataTemplate> </ListBox.ItemTemplate>)
<Grid Width="auto" >
<Grid.Resources>
<Style x:Key="listContainerStyle" TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</Grid.Resources>
<ListBox ScrollViewer.VerticalScrollBarVisibility="Auto" ItemContainerStyle="{StaticResource listContainerStyle}" ScrollViewer.CanContentScroll="True" ItemsSource="{Binding Path=Model.Object}" Grid.ColumnSpan="2" Grid.Row="1" Name="lstDiagnosis" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem HorizontalContentAlignment="Stretch">
<Grid Margin="2" >
<Grid.ColumnDefinitions >
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock FontWeight="Bold" Text="{Binding Name}" Grid.Column="0" >
</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding Path=Description}" Grid.Column="1">
</TextBlock>
<Button HorizontalAlignment="Right" VerticalContentAlignment="Center" VerticalAlignment="Center" Margin="0,0,2,0" Style="{x:Null}" Grid.Column="2" FontWeight="Bold" FontSize="8" Tag="{Binding}" >
<TextBlock Text=" X " VerticalAlignment="Top" ></TextBlock>
</Button>
</Grid>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
-----------------------------------------------------------------------------------------------------
Thursday, March 15, 2012
Self Titled
This is my first blog! :) Hope to enjoy it and if I do, I will create another one for my hobby which is photography. I created this blog to have a collection of information about my work. Latest technologies, codes, programming techniques, software architecture and design, web, windows, tablet and mobile application, gadgets, internet, but not limited to software development. basically everything about 0's and 1's.
This doesn't mean that I'm a savvy with technology, it's just that I need to learn and store more info as possible to survive in this field. This blog will serve as a reference and library of informations from day to day work.
This doesn't mean that I'm a savvy with technology, it's just that I need to learn and store more info as possible to survive in this field. This blog will serve as a reference and library of informations from day to day work.
Subscribe to:
Posts (Atom)


