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

  • click serviceProcessInstaller and go to properties
    1. change account property : LocalService for local and LocalSystem for server

  • click serviceInstaller and go to properties
    1. start type - automatic
    2. update service name and description to project name
Go to developer cmd: run as ADMINISTRATOR
Create batch files
  • InstallUtil ServiceName.exe
  • InstallUtil /u ServiceName
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe

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);
        }      
    }


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

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
---------------------------------------------------