c# etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
c# etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

25 Temmuz 2011 Pazartesi

Truncate Table SQL CF desteklenmiyor

aşağıdakinin yerine CF de

TRUNCATE TABLE [NAMEOFTABLE];

bunu

DELETE FROM [NAMEOFTABLE];

ALTER TABLE [NAMEOFTABLE] ALTER COLUMN ID IDENTITY (1,1);

 

yazmak gerekiyor. aynı şekilde CE cihazlarda .net 3.5 ‘da multithread kod yazarken MethodInvoker nesnenesi yok ve yerine ThreadStart ile casting yapabiliyoruz.

 

if (mControl.InvokeRequired)

{

    mControl.Invoke((System.Threading.ThreadStart)delegate {

        showProgressBar(Progress);

       });

}

voila

18 Temmuz 2011 Pazartesi

Windows Mobile Compact Framework- Uygulama Yolu

 

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().FullName.CodeBase)

compact framework de desteklenmeyenler

AppDomain.CurrentDomain.BaseDirectory

System.Environment.CurrentDirectory

Application.StartupPath

8 Haziran 2011 Çarşamba

Visual Studio Output Panel mesaj yazma

System.Diagnostics.Trace.WriteLine("Second's destructor is called.");

 

using System.Diagnostics;

 

System.Diagnostics.Trace.WriteLine("Second's destructor is called.");

 

TraceSource ts = new TraceSource("HelloWorld", SourceLevels.All);

 

ts.TraceInformation("# of records processed: {0}", n);

ts.TraceEvent(TraceEventType.Information, 10, "# of records processed: {0}", n);

ts = new TraceSource("HelloWorld", SourceLevels.Critical | SourceLevels.ActivityTracing);

 

<system.diagnostics>

  <sources>

    <source name="HelloWorld">

      <listeners>

        <remove name="Default"/>

 

        <add name="consoleListener"

            type="System.Diagnostics.ConsoleTraceListener"/>

 

        <add name="eventlogListener"

            type="System.Diagnostics.EventLogTraceListener"

            initializeData="Application"/>

 

        <add name="textfileListener"

            type="System.Diagnostics.TextWriterTraceListener"

            initializeData="helloworld.log" />

 

        <add name="xmlfileListener"

            type="System.Diagnostics.XmlWriterTraceListener"

            initializeData="helloworld.xml" />

 

        <add name="defaultListener"

            type="System.Diagnostics.DefaultTraceListener"/>

      </listeners>

    </source>

  </sources>

</system.diagnostics>

 

<system.diagnostics>

    <sharedListeners>

        <add name="myListener"

             type="MyTestTraceListener, MyAssembly">

            <filter type="System.Diagnostics.EventTypeFilter"

                    initializeData="Information"/>

        </add>

    </sharedListeners>

    <sources>

        <source name="mySource" switchValue="All">

            <listeners>

                <add name="myListener" />

            </listeners>

        </source>

    </sources>

</system.diagnostics>

 

log.Info( m=>m("some logger info {0}", (object)myObj) )

log.Info( ()=>String.Format("some logger info {0}", (object)myObj) )

 

image

    Critical Error Warning Information Verbose Start Stop Suspend Resume Transfer

30 Mayıs 2011 Pazartesi

WCF Duplex callback ile mesaj almak ve göndermek

<system.serviceModel>

        <protocolMapping>

                <add scheme="http" binding="wsDualHttpBinding" />

        </protocolMapping>

        <services>

                <service name="Plugins.Intranet.Library.SupportService" behaviorConfiguration="SupportServiceBehaviors" >

                        <endpoint contract="Plugins.Intranet.Library.ISupportService" binding="wsDualHttpBinding" />

                </service>

        </services>

        <behaviors>

                <serviceBehaviors>

                        <behavior name="SupportServiceBehaviors" >

                               <serviceMetadata httpGetEnabled="true" />

                               <serviceDebug includeExceptionDetailInFaults="True" />

                        </behavior>

                </serviceBehaviors>

        </behaviors>

</system.serviceModel>

 

WCF Svc file

<%@ServiceHost language="c#" Debug="true" Service="Plugins.Intranet.Library.SupportService" %>

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.ServiceModel;

 

namespace Plugins.Intranet.Library

{

    // The callback interface is used to send messages from service back to client.

    // The Result operation will return the current result after each operation.

    // The Equation opertion will return the complete equation after Clear() is called.

    public interface ISupportServiceDuplexCallback

    {

        [OperationContract(IsOneWay = true)]

        void NewMessage(SupportMessage msg);

    }

 

    // Define a duplex service contract.

    // A duplex contract consists of two interfaces.

    // The primary interface is used to send messages from the client to the service.

    // The callback interface is used to send messages from the service back to the client.

    // ICalculatorDuplex allows one to perform multiple operations on a running result.

    // The result is sent back after each operation on the ICalculatorCallback interface.

    [ServiceContract(Namespace = "http://intranet.metafor",

    SessionMode = SessionMode.Required,

    CallbackContract = typeof(ISupportServiceDuplexCallback))]

    public interface ISupportService

    {

 

        [OperationContract(IsOneWay = true)]

        void TestService();

        [OperationContract(IsOneWay = true)]

        void GetMessages(string UserID);

 

    }

 

    // Service class which implements a duplex service contract.

    // Use an InstanceContextMode of PerSession to store the result

    // An instance of the service will be bound to each duplex session

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

    public class SupportService : ISupportService

    {

        public int ServiceStatus { get; set; }

 

        public void TestService()

        {

            ServiceStatus= 11;

        }

 

        public void GetMessages(string UserID)

        {

            // dummy message for test

            var buf = new SupportMessage()

            {

                Title="Test Message Title",

                Description= "Lorem ipsum",

                CreateTime= DateTime.Now

            };

 

            Callback.NewMessage(buf);

        }

 

        ISupportServiceDuplexCallback Callback

        {

            get

            {

                return OperationContext.Current.GetCallbackChannel<ISupportServiceDuplexCallback>();

            }

        }

 

 

    }

 

    public class SupportMessage

    {

        public string Sender { get; set; }

        public string Title { get; set; }

        public string Description { get; set; }

        public int      Category { get; set; }

        public DateTime CreateTime { get; set; }

 

    }

 

 

}

 

http://localhost/metafor/plugins/SupportService.svc

web result

C#

class Test

{

    static void Main()

    {

        SupportServiceClient client = new SupportServiceClient();

 

        // Hizmetteki işlemleri çağırmak için 'client' değişkenini kullanın.

 

        // Her zaman istemciyi kapatın.

        client.Close();

    }

}

 

Visual Basic

Class Test

    Shared Sub Main()

        Dim client As SupportServiceClient = New SupportServiceClient()

        ' Hizmetteki işlemleri çağırmak için 'client' değişkenini kullanın.

 

        ' Her zaman istemciyi kapatın.

        client.Close()

    End Sub

End Class

 

Client code :

Svcutil.exe http://localhost/metafor/plugins/SupportService.svc

Output.config

<system.serviceModel>

        <bindings>

                <wsDualHttpBinding>

                        <binding name="WSDualHttpBinding_ISupportService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">

                               <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>

                               <reliableSession ordered="true" inactivityTimeout="00:10:00"/>

                               <security mode="Message">

                                       <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>

                               </security>

                        </binding>

                </wsDualHttpBinding>

        </bindings>

        <client>

                <endpoint address="http://localhost/metafor/plugins/SupportService.svc" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ISupportService" contract="ISupportService" name="WSDualHttpBinding_ISupportService">

                        <identity>

                               <servicePrincipalName value="host/localhost"/>

                        </identity>

                </endpoint>

        </client>

</system.serviceModel>

 

namespace Plugins.Intranet.Library

{

    public class SupportSelfCallback : ISupportServiceCallback

    {

 

        public delegate void MessageReceivedEventHandler(object sender, MessageReceivedEventArgs e);

        public event MessageReceivedEventHandler MessageReceived;

 

        protected void RaiseMessageReceived(object propertyName)

        {

            MessageReceivedEventHandler messageChanged = this.MessageReceived;

            if ((MessageReceived != null))

            {

                MessageReceived(this, new MessageReceivedEventArgs(propertyName));

            }

        }

 

        #region ISupportServiceCallback Members

 

        public void NewMessage(ServiceReferenceSupport.SupportMessage msg)

        {

            RaiseMessageReceived(msg);

        }

 

        #endregion

    }

 

    public class MessageReceivedEventArgs : EventArgs

    {

        public MessageReceivedEventArgs(object message)

        {

            this.MessageField = message;

        }

 

        private object MessageField;

        public virtual object Message { get { return MessageField; } }

    }

 

}

 

End of code

 

    SupportSelfCallback duplexCallBack = new SupportSelfCallback();

    duplexCallBack.MessageReceived += new SupportSelfCallback.MessageReceivedEventHandler(duplexCallBack_MessageReceived);

    // Construct InstanceContext to handle messages on callback interface.

    InstanceContext instanceContext = new InstanceContext(duplexCallBack);

 

    SupportServiceClient client = new SupportServiceClient(instanceContext);

   

    void duplexCallBack_MessageReceived(object sender, MessageReceivedEventArgs e)

    {

        // do stuff

    }