simple example reddis c#

1 Download MSI from here
https://github.com/MSOpenTech/redis/releases



2 Install nuget package in your project

3 How to use

using StackExchange.Redis;
//...
            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("10.10.0.100:6379"))
            {
                IDatabase cache = redis.GetDatabase();

                cache.StringSet("key1", "value");
                cache.StringSet("key2", 25);

                string key1 = cache.StringGet("key1");
                int key2 = (int)cache.StringGet("key2");
            }

async await c# simple example

    public class MegaClass
    {
        public async void StartAsync()
        {
            await Task.Run(() => { LongProcedure(); });
            Console.WriteLine("End");
        }

        public void Start()
        {
            LongProcedure();
            Console.WriteLine("End");
        }

        private void LongProcedure()
        {
            Thread.Sleep(3000);
        }

        public async Task MyMethodAsync()
        {
            int x = await LongRunningOperationAsync();
            Console.WriteLine(x);
        }


        public async Task LongRunningOperationAsync() 
        {
            await Task.Delay(3000); 
            return 1;
        }

        public async Task LongRunningOperationAsync(int _param)
        {
            await Task.Delay(3000);
            return _param;
        }

    }

    class Program
    {
        static void Main(string[] args)
        {
            var _c = new MegaClass();

            //1 Sync
            //_c.Start();

            //2 Async
            //c.StartAsync();

            //3 Start and return task
            //Task t = _c.MyMethodAsync();
            //t.Wait();

            //4
            //Task task = new Task(_c.StartAsync);
            //task.Start();

            //5 GetResult 
            //Task x = _c.LongRunningOperationAsync();
            //x.Wait();
            //Console.WriteLine(x.Result);

            //6 with param
            //Task x = _c.LongRunningOperationAsync(3);
            //x.Wait();
            //Console.WriteLine(x.Result);

            Console.WriteLine("Wait");
            Console.ReadLine();
        }
    }

c# Simple socket example


client
    public class SynchronousSocketClient
    {

        public static void StartClient()
        {
            byte[] bytes = new byte[4096];

            try
            {
                IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
                IPAddress ipAddress = ipHostInfo.AddressList[0];
                IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);

                Socket sender = new Socket(AddressFamily.InterNetwork,
                    SocketType.Stream, ProtocolType.Tcp);

                try
                {
                    sender.Connect(remoteEP);

                    Console.WriteLine("Socket connected to {0}",
                        sender.RemoteEndPoint.ToString());

                    byte[] msg = Encoding.UTF8.GetBytes("TEST MSG!EOF");

                    int bytesSent = sender.Send(msg);

                    int bytesRec = sender.Receive(bytes);
                    Console.WriteLine("Echoed test = {0}",
                        Encoding.UTF8.GetString(bytes, 0, bytesRec)
                        );

                    sender.Shutdown(SocketShutdown.Both);
                    sender.Close();

                }
                catch (ArgumentNullException ane)
                {
                    Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
                }
                catch (SocketException se)
                {
                    Console.WriteLine("SocketException : {0}", se.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine("Unexpected exception : {0}", e.ToString());
                }

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }


    }
server
    public class SynchronousSocketListener
    {

        public static string data = null;

        public static void StartListening()
        {
            byte[] bytes = new Byte[4096];

            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);

            Socket listener = new Socket(AddressFamily.InterNetwork,
                SocketType.Stream, ProtocolType.Tcp);

            try
            {
                listener.Bind(localEndPoint);
                listener.Listen(10);

                while (true)
                {
                    Console.WriteLine("Waiting for a connection...");
                    Socket handler = listener.Accept();
                    data = null;

                    while (true)
                    {
                        bytes = new byte[1024];
                        int bytesRec = handler.Receive(bytes);
                        data += Encoding.UTF8.GetString(bytes, 0, bytesRec);
                        if (data.IndexOf("!EOF") > -1)
                        {
                            break;
                        }
                    }


                    Console.WriteLine("Text received : {0}", data);

                    byte[] msg = Encoding.UTF8.GetBytes(data);

                    handler.Send(msg);
                    handler.Shutdown(SocketShutdown.Both);
                    handler.Close();
                }

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            Console.WriteLine("\nPress ENTER to continue...");
            Console.Read();

        }

    }
test console
    class Program
    {
        static void Main(string[] args)
        {

            Task.Factory.StartNew(() => SynchronousSocketListener.StartListening());
            Thread.Sleep(2000);
            Task.Factory.StartNew(() => SynchronousSocketClient.StartClient());
            Console.Read();
            Task.Factory.StartNew(() => SynchronousSocketClient.StartClient());
            Console.Read();
            Task.Factory.StartNew(() => SynchronousSocketClient.StartClient());
            Console.Read();
        }
    }

allowed clock skew is '00:05:00'



I had the same issue and followed all recommendations. But my fault was that I changed only server configuration, whereas I had to change client configuration too.
This is my config without maxClockSkew
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <!-- -->
  </connectionStrings>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IHotLine1" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security>
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="localhost:6767/blabla.svc" binding="wsHttpBinding"
        bindingConfiguration="WSHttpBinding_IHotLine1" contract="ServiceReference2.IHotLine"
        name="WSHttpBinding_IHotLine1">
        <identity>
          <certificate encodedValue="====encodedvalue===" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>
And updated with clock skew
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="WSHttpBinding_IHotLine1">
          <transactionFlow/>
          <security authenticationMode="SecureConversation"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings maxClockSkew="01:30:00" />
            <localServiceSettings maxClockSkew="01:30:00" />
            <secureConversationBootstrap authenticationMode="UserNameForSslNegotiated"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" >
              <localClientSettings maxClockSkew="01:30:00" />
              <localServiceSettings maxClockSkew="01:30:00" />
            </secureConversationBootstrap>
          </security>
          <textMessageEncoding/>
          <httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
        </binding>
      </customBinding>
    </bindings>
    <client>

      <endpoint address="http://localhost:6767/blabla.svc" binding="customBinding"
        bindingConfiguration="WSHttpBinding_IHotLine1" contract="ServiceReference2.IHotLine"
        name="WSHttpBinding_IHotLine1">
        <identity>
          <certificate encodedValue="====encodedva

json javascriptserializer length error

        protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
        {
            return new JsonResult()
            {
                Data = data,
                ContentType = contentType,
                ContentEncoding = contentEncoding,
                JsonRequestBehavior = behavior,
                MaxJsonLength = Int32.MaxValue
            };
        }

c# check either work or not service on a remote computer

 
using System.Management;

       static bool ServiceIsRunning(string ServiceName)
        {
            ConnectionOptions op = new ConnectionOptions();
            op.Username = "domain\\username";
            op.Password = "password";
            ManagementScope scope = new ManagementScope("\\\\OLAP1\\root\\cimv2", op);
            scope.Connect();

            string objPath = string.Format("Win32_Service.Name='{0}'", "SubscribeReportService");
            using (ManagementObject service = new ManagementObject(scope, new ManagementPath(objPath), null))
            {
                if (service.GetPropertyValue("State").ToString() == "Running")
                    return true;
                else
                    return false;
            }
        }

http://stackoverflow.com/questions/1335065/check-status-of-services-that-run-in-a-remote-computer-using-c-sharp

Good article about possible solutions for creating WEB DataTables

http://www.sitepoint.com/responsive-data-tables-comprehensive-list-solutions/

react js
http://adazzle.github.io/react-data-grid/examples.html#/basic