Monday, November 12, 2012

WCF Service Host without app.config (configuration by code) example

using System;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;


namespace wcf3
{
    class Program
    {
        static void Main(string[] args)
        {

            ServiceHost serviceHost = new ServiceHost(typeof(TestService), new Uri("http://localhost:80/Test3"));

            // Create Meta Behavior
            ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
            behavior.HttpGetEnabled = true;

            serviceHost.Description.Behaviors.Add(behavior);

            Binding mexBinding = MetadataExchangeBindings.CreateMexHttpBinding();

            serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "mex");

            WSHttpBinding httpBinding = new WSHttpBinding(SecurityMode.None);

            serviceHost.AddServiceEndpoint(typeof(ITestService), httpBinding, "rest");

            serviceHost.Open();
            Console.WriteLine("TestService is now running. at: " + serviceHost.BaseAddresses.First());
            Console.WriteLine("Press any key to stop it ...");
            Console.ReadKey();
            serviceHost.Close();
        }
    }

    [ServiceContract]
    public interface ITestService
    {
        [OperationContract]
        string Test(string input);
    }

    public class TestService : ITestService
    {

        public string Test(string input)
        {
            return input + DateTime.Now.ToString();
        }
    }



}

WCF Basics

1) Visual Stuido: WCF Service Projekt anlegen (=Server) :
Erzeugt ein .svc File, in dem der ServiceHost deklariert wird, der dann das eigentlcihe Service , die Klasse Service 1 im .svc.cs, die wiederum das Interface IService1 implementiert. GetData ist die Beispielmethode.0

1a) Klasse ServiceContract mit Methoden OperationCopntracts
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
    }

2a) CLient anlegen:  z.b. WinForm oder WPF oder CMD Line  Projekt - oder mitgeliefreten WcfTestClient.exe verwenden (im Projekt wird bei Debug Command Line Arguments  /client:"WcfTestClient.exe" hinzugefügt bei einer WCF Class LIbrary - zu finden in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE)
2b) Service Reference hinzufügen, Discover und OK drücken und ServiceReference1 wird erzeugt
2c) In einem Button Click einen Client erzeugen und auf dem GetData aufrufen:


        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
            string s=client.GetData(10);
            MessageBox.Show("returns: " + s);
        }

weitere Info:
http://www.michis-blog.net/wp-content/uploads/2007/05/wcf-tutorial.pdf
http://www.codeproject.com/Articles/97204/Implementing-a-Basic-Hello-World-WCF-Service
https://weblogs.asp.net/ralfw/a-truely-simple-example-to-get-started-with-wcf


3) Error Handling

ServiceHost only supports class service types

maybe the interface was specified instead of the implementation in the .svc file

WCF Basics

1) Visual Stuido: WCF Service Projekt anlegen (=Server) :
Erzeugt ein .svc File, in dem der ServiceHost deklariert wird, der dann das eigentlcihe Service , die Klasse Service 1 im .svc.cs, die wiederum das Interface IService1 implementiert. GetData ist die Beispielmethode.0

1a) Klasse ServiceContract mit Methoden OperationCopntracts
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
    }

2a) CLient anlegen:  z.b. WinForm oder WPF oder CMD Line  Projekt - oder mitgeliefreten WcfTestClient.exe verwenden (im Projekt wird bei Debug Command Line Arguments  /client:"WcfTestClient.exe" hinzugefügt bei einer WCF Class LIbrary - zu finden in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE)
2b) Service Reference hinzufügen, Discover und OK drücken und ServiceReference1 wird erzeugt
2c) In einem Button Click einen Client erzeugen und auf dem GetData aufrufen:


        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
            string s=client.GetData(10);
            MessageBox.Show("returns: " + s);
        }

weitere Info:
http://www.michis-blog.net/wp-content/uploads/2007/05/wcf-tutorial.pdf
http://www.codeproject.com/Articles/97204/Implementing-a-Basic-Hello-World-WCF-Service
https://weblogs.asp.net/ralfw/a-truely-simple-example-to-get-started-with-wcf


3) Error Handling

ServiceHost only supports class service types

maybe the interface was specified instead of the implementation in the .svc file

Friday, November 09, 2012

WPF Databinding: über DataContext

z.b.:

im Xaml:

IsEnabled="{Binding Source={StaticResource DataContextBridge}, Path=DataContext.Model.IsLocked}"

im CodeBehind:


        public void Initialize(ImportExportViewModel model, IUnityContainer unityContainer)
        {
            ((FrameworkElement)Resources["DataContextBridge"]).DataContext = DataContext;
DataContext = yourDatModel;
        }

Wednesday, November 07, 2012

oracle simple stored procedure


create or replace
PROCEDURE TESTHM AS
BEGIN
--set serveroutput on;
  --does not work: SELECT SESSIONTIMEZONE, CURRENT_DATE FROM DUAL;
  dbms_output.put_line ('TestHm');
  --does not work: ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
  dbms_output.put_line (CURRENT_DATE);
END TESTHM;

testen:
set serveroutput on;      
execute testhm;

mit Parameter:
create or replace

PROCEDURE TESTHM
(
     InTest   IN  VARCHAR2
)
IS
BEGIN
--set serveroutput on;
  dbms_output.put_line ('TestHm Begin');
  dbms_output.put_line (InTest);
END TESTHM;




set serveroutput on;  
execute testhm('Hallo');

Monday, November 05, 2012

oracle enterprisemanger urls

sind in C:\oracle\product\10.2.0\db_1\install\readme.txt

Wednesday, October 24, 2012

batch file pruefen ob parameter uebergeben wurde


@echo off
echo start
if X%1X==XX goto ende
echo commandozeilen parameter 1 wurde uebergeben
:ende
echo ende

Monday, October 22, 2012

Oracle Bildschirmausgabe basics (if, dbms_output)


prompt 'bildschirmausgabe in sql scripts - in stored Proc dbms_output.put_line verwenden'
-- damit  dbms_output.put_line('Bildschrimasugabe in PL SQL Blocks (Stored Proc.)'); funktioniert
set serveroutput on;
begin
  dbms_output.put_line('Bildschrimasugabe in PL SQL Blocks (Stored Proc.)');
  if (1=0) THEN
    dbms_output.put_line('true');
    else
    dbms_output.put_line('false');
  end if;
end;

Tuesday, October 16, 2012

refresh / recompile sql server Inline table valued Functions / Tabellenwert Funktionen aktualisieren

select  'exec sp_refreshsqlmodule '+name  from sys.objects where type='IF'  and schema_id=1

ergebnis kopieren und ausführen

type="IF" Inline Function

Monday, October 15, 2012

powershelll erste schritte

in powershell ausführung von unsigned scripts zulaassen:
Set-ExecutionPolicy RemoteSigned

powershell e:\SendMail.ps1

e:\SendMail.ps1:

#gwmi win32_operatingsystem

 Write-Host "Sending Email"

 #SMTP server name
 $smtpServer = "mail.server.com"
 $cred = new-object Net.NetworkCredential("user", "pwd!")

 #Creating a Mail object
 $msg = new-object Net.Mail.MailMessage

 #Creating SMTP server object
 $smtp = new-object Net.Mail.SmtpClient($smtpServer)


 $smtp.Credentials = $cred


 #Email structure
 $msg.From = "x@y.z"
 $msg.ReplyTo = "x@y.z"
 $msg.To.Add("x@y.z")
 $msg.subject = "test"

 $msg.IsBodyHTML = $true

 $msg.body ="
------------       Backup:       ---------------------"
 $msg.body += Get-Content e:\backuplog.txt

 $msg.Attachments.Add('c:\bat\report.txt')

 #Sending email
 $smtp.Send($msg)

 Write-Host "Email Sent"

Friday, October 05, 2012

Oracle Nationalen Zeichensatz (Collation) ändern:


Der NLS Nationale Zeichensatzin Oracle, den man beim Erzeugen der Db angibt kann wie folg ausgelesen werden:

SELECT parameter, value FROM nls_database_parameters WHERE parameter LIKE 'NLS_NCHAR_CHAR%';

und so geändert werden (nicht supported):

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE AL16UTF16;
SHUTDOWN IMMEDIATE;

bzw ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE UTF8;

Wednesday, September 05, 2012

Oracle Basics

Db connectionstrings stehen am server in: C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora Sqlplus verbindet sich immer zu der db, die in Umgebungsvariable ORACLE_SID steht, außer man verwendet diesen syntax: sqlplus "sys/password@dbFromTns as sysdba" test abfrage: select table_Name from user_tables;

Tuesday, August 28, 2012

Oracle imp / impdp

impdp (ab oracle 10g)
wichtig - dumpfile muß im directory C:\oracle\product\10.2.0\admin\DATABASENAME\dpdump liegen und ORACLE_SID Umgebungsvariable auf die Db, in die importiert werden soll zeigen

C:\oracle\product\10.2.0\admin\LDLDeploy\dpdump>impdp dumpfile=PSA20120515.DMP Import: Release 10.2.0.1.0 - Production on Monday, 27 August, 2012 14:33:00 Copyright (c) 2003, 2005, Oracle. All rights reserved. Username: sys as sysdba Password: Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded Starting "SYS"."SYS_IMPORT_FULL_01": sys/******** AS SYSDBA dumpfile=P20120515.DMP Processing object type SCHEMA_EXPORT/USER

welche schemas sind im dmp file ?
mit notepad++ oder ähnlichem öffnen und nach  OWNER_NAME  suchen

imp (vor oracle10g, wird aber bei 10 und 11 auch noch mitgeliefert)
der user steht in der 2. zeile des dumps ab Zeichen 2 (1. Zeichen ist D):


TEXPORT:V09.02.00
DUSER
RTABLES

Sunday, August 26, 2012

Windows 8 Product Key ändern

In Systemsteuerung / System / Windows Activation gibt es nicht wie bei Windows 7 die Möglichkeit den product key zu ändern, aber mittels vb scrip von einer administrativen sell ist es möglich: slmgr.vbs -ipk "neuer Product Key"

Thursday, August 23, 2012

Tabellen Speicherplatz: sp_spaceused

exec sp_spaceused tLog exec sp_spaceused tLog1 exec sp_spaceused tAdressen

Wednesday, August 22, 2012

Sql Server Page Dump

dbcc traceon(3604) dbcc IND(Datenbank,Tabelle,-1) dbcc PAGE(datenbank,FileId,PagePID,3) -- FileId =1 PagePID von dbcc IND

Tuesday, August 07, 2012

from SqlServer to Oracle

sql database servcie default port 1433 - oracle listener def. port 1521 lassen sich mit telnet hostname port verifizieren ob sie laufen Der Listener wird mit Net Configuration Assistent konfiguriert, der Aministrations Assistent von Windows zeigt an welche Listener und admins es gibt Datenbanken werden mit dem Database Configuration Assistent angelegt In C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN ist das tnsnames.ora und andere config files

WSS Wiki aus dem SQL Server

Wollte mal wissen, wo die Wiki Einträge am Sharepoint in der dahinterliegenden SQL Server Datenbank abgelegt werden:

Wiki ist Liste von HTML Seiten, [[WikiSeitenname]] wird auf Link
<a class=ms-wikilink href="/myWiki/Home.aspx">Home</a> umgewandelt

und werden in CONTEN_Portal abgelegt:
select ui.tp_login,du.tp_Dirname,du.tp_leafname,du.tp_version,du.tp_author,du.ntext2, du.tp_created,du.tp_editor,du.Tp_modified,*
from AllUserData du join UserInfo ui on du.tp_editor=ui.tp_id
where tp_contenttype like 'Wiki%'
order by du.tp_leafname,du.tp_version

weitere Sql Queries auf die Sharepoint Content Db

Visual Studio Shortcuts

CRTL SHIFT SPACE ... Intellisense Tooltip für aktuellen Parameter

Windows7 Aktivierungsfehler / Activation

einfach denselben Productkey nochmals eingeben (Systemsteuerung / System / Windows aktivieren ganz unten)

renter the same product key (system / activate windows)