Feedjit

Articles for you

Showing posts with label Visual Studio 2012. Show all posts
Showing posts with label Visual Studio 2012. Show all posts

Sunday, June 15, 2014

Log4net Implementation in CRM 2011, log4net in CRM Plugins, WebServices and Custom aspx Pages.

This post is about log4net logger implementation in CRM 2011. I will provide details about log4net in CRM Plugins. It is as the same with Web-services and Custom aspx Pages.


1. First we will have a Config file for log4net so that, its configuration/settings can be read and applied to logger.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="D:\Logger\Log4net\logs\log.txt" />
      <appendToFile value="false" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="5" />
      <maximumFileSize value="1GB" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="MemoryAppender" type="log4net.Appender.MemoryAppender">
    </appender>
    <root>
      <level value="Info" />
      <appender-ref ref="RollingLogFileAppender" />
      <appender-ref ref="MemoryAppender" />
    </root>
  </log4net>
</configuration
Copy all this into a file named "log4net.config" and place it in D:\Logger\Log4net\Config\

2. Add log4net.dll to your Plugin.

3.
using log4net;
using log4net.Config;
public class MyPlugin: IPlugin
    {
    protected static readonly ILog Logger = LogManager.GetLogger(typeof(PublishToGRID));
    static MyPlugin()
    {
      XmlConfigurator.Configure(new System.IO.FileInfo(@"D:\Logger\Log4net\Config\log4net.config"));
    }
try
{
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
  Logger.Info("Plugin Executed");
}
}
catch (Exception ex)
{
  string ErrorMessage = "Exception Occured in CRM";
  Logger.Error(ErrorMessage,ex);              
}


After your plugin executed: you will se the log file generated in D drive.
containing the following text:

Logger.info: 6/15/2014  7:11 p.m
Plugin Excuted







Wednesday, May 28, 2014

Bridge Inspection and Management system in Asp Dot Net (.NET C#) with Source Code and Database in MS Sql Server 2008


I have developed Bridge Inspection System using Visual Studio Web-Site Project in Asp.net with C#, using my own CSS styling.
Database: in Microsoft SQL server 2008 R2.
Above is the Main Screen, Default Page.
Following are features in this Bridge Inspection System:



  • Admin who can add more admins,Collectors,Inspectors and Bridges to be inspected in  System
    Delete Collectors, Inspectors and Bridges from the System.
  • Bridge Inspector who can Inspect the Bridges that are currently added and make a report
  • Bridge Collector who can View the final Reports added by BI.
  • Reports Generation from Inspected Bridge Data and Export Reports in PDF format to be ready for download and printing.
  • Profile Management.
  • and more ..........................
  • Sql Server 2008 Database, Normalized and Complete Relationships.
Following are some screen-shots of the system.




Admin Login:





Admin Page:





 Add Bridge Profile:





Profile Managment:








 Bridge Profile View:
If anyone need Source Code along with the Database file, please ask in Comments I will provide links:
Thanks,
Saqib Khan. (Dynamics CRM developer).


Tuesday, December 31, 2013

Simplest and Easiest Inheritance in C++: Easy Implementation of Inheritance in C++ Student/Teacher Program in C++

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include<iostream.h>
#include<conio.h>
#define size 20

  class person

  {
      protected:

          char name[size];
          int id;

      public:

           person():id(0) {name[size]=' ';}
           virtual void getd();
           virtual void putd();
           virtual int isoutstanding()=0;

  };
class student : public person

      {
          protected:

              float gpa;

          public:

              student():person(){gpa=0;}
              void getd();
              void putd();
              int isoutstanding();

      };
class teacher : public person

        {
            protected:

                  int publish;

            public:

                 teacher():person(){publish=0;}
                 void getd();
                 void putd();
                int isoutstanding();

        };

                     //defineing functions for student class
void student::getd()


             {
                 cout<<"Enter the name of student\n";
                 cin.get(name,size);

                   cout<<"Enter ID or REG\n";
                   cin>>id;

                      cout<<"Enter gpa\n";
                      cin>>gpa;

             }
void student::putd()


                 {
                     int i=0;

                     cout<<"Name of student is\n";

                      while(name[i]!='\0')

                      {
                          cout<<name[i];
                           i++;
                      }

                          cout<<"Reg or ID is\n";
                          cout<<id;


                              cout<<"gpa is\n";
                              cout<<gpa;


                 }
int student::isoutstanding()

           {
               if(gpa>=3.5)
               return 1;
               else
               return 0;
           }



                       //defineing methods of teacher 
void teacher::getd()


             {
                 cout<<"Enter the name of teacher\n";
                 cin.get(name,size);

                   cout<<"Enter ID or REG\n";
                   cin>>id;

                      cout<<"Enter number of publishes\n";
                      cin>>publish;

}void teacher::putd()


                 {
                     int i=0;

                     cout<<"Name of teacher is\n";

                      while(name[i]!='\0')

                      {
                          cout<<name[i];
                           i++;
                      }

                          cout<<"Reg or ID is\n";
                          cout<<id;


                              cout<<"Number of publish is\n";
                              cout<<publish;


                 }
int teacher::isoutstanding()

           {
               if(publish>=5)
               return 1;
               else
               return 0;
           }




                 int main()

             {
                 person *pptr[20];
                  int n=0;
                  char choice,reply;

                        do

                     {
                          cout<<"Enter your choice";
                          cin>>choice;

                             if(choice=='s')
                             {
                              pptr[n] = new student;
                             }

                               else
                               {
                                pptr[n] = new teacher;
                               }

                                 pptr[n]->getd();

                                n++;

                                cout<<"Do you want to run it again\n";
                                cin>>reply;

                       }

                                 while(reply=='y');


                                    getche();

                                      return 0;

          }

Tuesday, December 24, 2013

How to Create a new Guid CRM 2011 C# xRM Empty Guid or Null Guid

 How to Create/Generate a New GUID using Vb.Net, C# and Vb.Script

 Suppose i have got a guid in Query String like


http://localhost:3214/Default.aspx?id=9D2B0228-4D0D-4C23-8B49-01A698857709


or

like this

// Without Dashes
http://localhost:3214/Default.aspx?id=9D2B02284D0D4C238B4901A698857709










if (Request.QueryString["id"] != null)

string Id = Request.QueryString["id"];

Guid guid = new Guid(Id);

if(guid!= Guid.Empty)
{
  //Use id here to retreive the record.
}








Sunday, September 29, 2013

Software with Source Code to convert RGB to CMYK Converter in C# Image Resizer and Without Using Color Profile

using Photoshop;
using System.IO;
namespace Image_Converter

{
    public partial class Form1 : Form
    {
Photoshop.Application appRef = default(Photoshop.Application);
        Photoshop.Document currentDoc = default(Photoshop.Document);
public Form1()
        {
            InitializeComponent();
         
        }
private void convert_Click(object sender, EventArgs e)
        {
            long originalWidth;
            long originalHeight;
         
            if (txtFrom.Text != "" && txtTo.Text!= "")
            {
                Thread th_1 = new Thread(new ThreadStart(show));
                try
                {
                 
                 
                    th_1.Start();
                    appRef = new Photoshop.Application();
                    appRef.Visible = false;
                    appRef.DisplayDialogs = PsDialogModes.psDisplayNoDialogs;

                    String[] files = Directory.GetFiles(txtFrom.Text);
                    foreach (string fl in files)
                    {
                        if (fl.EndsWith(".jpg") || fl.EndsWith(".jpeg"))
                        {
                            currentDoc = appRef.Open(fl);
                            currentDoc.ChangeMode(PsChangeMode.psConvertToCMYK);
                            appRef.Preferences.RulerUnits = Photoshop.PsUnits.psPixels;
                            originalHeight = (long)currentDoc.Height;
                            originalWidth = (long)currentDoc.Width;
                            int targetHeight = (int)(originalHeight);
                            int targetWidth = (int)(originalWidth);
                            Photoshop.JPEGSaveOptions jpeg = new Photoshop.JPEGSaveOptions();
                            jpeg.Quality = 8;
                            currentDoc.ResizeImage(targetWidth, targetHeight, 300, PsResampleMethod.psBicubic);
                            string temp = txtTo.Text + Path.GetFileName(fl);
                            currentDoc.SaveAs(txtTo.Text + "\\" + Path.GetFileName(fl), jpeg);
                            currentDoc.Close(PsSaveOptions.psDoNotSaveChanges);

                        }
                    }

                }

                catch (Exception ex) {
                    MessageBox.Show(ex.ToString());
                    label3.Hide();
                }

Sunday, September 15, 2013

Simplest and Fastest File Searcher in C#. How to Copy Zip Files from Source to Destination Using C#, .NET

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace Utillity_1
{
    public partial class Form1 : Form
    {
        public string source_path = "E:\\Received files";
        public string destination_path = "D:\\Saqib\\Approved";
        public Form1()
        {
            InitializeComponent();
        }

     

     
        private void btn_Browse_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Open CSV/TSV File";
            openFileDialog1.Filter = "CSV(*.csv)|*.csv";//|TSV(*.tsv)|*.tsv";
            openFileDialog1.Multiselect = false;
           // openFileDialog1.ShowDialog();
            try
            {
                string[] filePaths = Directory.GetFiles(source_path,"*.zip");
         
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    StreamReader csv_reader = new StreamReader(openFileDialog1.FileName);
                    //string temp = csv_reader.ReadToEnd();
                    string temp=null;
                    while (!csv_reader.EndOfStream)
                    {
                        string line = csv_reader.ReadLine();
                        if (!(string.IsNullOrEmpty(line)))
                        {
                            string[] values = line.Split(',');

                           // temp += values[0];
                           // temp += Environment.NewLine;
                            foreach (string file in filePaths)
                            {
                                //Console.WriteLine(file);
                                if (file.EndsWith(".zip"))
                                {
                                  string path = Path.GetFileName(file);
                                  string[] to_get_filename = path.Split('.');
                                  string filename = to_get_filename[0];
                                  if (filename.Equals(values[1]))
                                  {
                                      // MessageBox.Show(file);
                                     // source_path +="\\"+ filename+".zip";
                                      destination_path = Path.Combine(destination_path, path);
                                     // File.Move(file, destination_path);
                                      File.Copy(file, destination_path, true);
                                   
                                  }
                                }
                            }
                        }
                    }
                    MessageBox.Show(temp);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btn_Close_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Really Close?", "Confirm close", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                this.Close();
            }
         
        }

    }
}

Tuesday, August 20, 2013

How to Get All Uparas from the XML using XPATH and C#. XSL XSLT XPATH XML Using Regular Expression REGEX

using System.IO;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Xsl;
namespace XML_Parser
{
    class Program
    {
        public static Hashtable hash_table = new Hashtable();
        static void Main(string[] args)
        {
            string path = @"C:\Documents and Settings\saqib\My Documents\OMessenger\Received files\KOKODA-With Index.xml";
            string pattern = @"[a-z][a-z]+\.[a-z]+";
            XslCompiledTransform myxsl = new XslCompiledTransform();
            myxsl.Load("XSLTFile1.xslt");
            myxsl.Transform(path, "To_Table.html");
          //  var xDocument = XDocument.Load(path);
          //  string xmll = xDocument.ToString();
            XmlDocument xml =new XmlDocument();
            xml.Load(path);

XmlNodeList xnList = xml.SelectNodes("//upara");
//Console.WriteLine(xnList.Count);
foreach (XmlNode xn in xnList)

{
    //Console.WriteLine(xn.InnerText);
    string upara = xn.InnerText;
 
    MatchCollection matches = Regex.Matches(upara, pattern);
    foreach (Match match in matches)
    {
        foreach (Capture capture in match.Captures)
        {
            Console.WriteLine("Index={0}, Value={1}", capture.Index, capture.Value);
            hash_table.Add(capture.Index, capture.Value);
        }
    }

}
Console.ReadKey();
        }          
                    }
                }
         
        

Saturday, June 22, 2013

Node.js Server code to Send and Recieve a Json file. Also A Simple Calculator in Node.js Client Server code in node.js Using Express Framework and Socket.IO

App.js code

///////////////
var express = require('express')
  , app = express()
  , http = require('http')
  , server = http.createServer(app)
  , io = require('socket.io').listen(server)
  var file= require('./data');    // Gets the JSON data file
 

server.listen(8765);
console.log("Server Listening on 8765");

// routing
app.get('/', function (req, res) {
  res.sendfile(__dirname + '/index.html');
});

// usernames which are currently connected to the chat
var usernames = {};

io.sockets.on('connection', function (socket) {

    // when the client emits 'sendchat', this listens and executes
    socket.on('sendchat', function (data) {
        // we tell the client to execute 'updatechat' with 2 parameters
        io.sockets.emit('updatechat', socket.username, data);
    });
    //////////////////////////////////////////////////////////////
    socket.on('add', function (data1,data2) {
   
    var n = parseInt(data1);
    var n2= parseInt(data2);
    socket.emit('fill', n+n2);
    });
    /////////////////////////////////////////////////////////////
    socket.on('readjson',function(datajson){
    datajson=JSON.stringify(file);
    socket.emit('filljs',datajson)
    });
   /////////////////////////////////////////////////////////////
    // when the client emits 'adduser', this listens and executes       
    socket.on('adduser', function (username) {
        // we store the username in the socket session for this client
        socket.username = username;
        // add the client's username to the global list
        usernames[username] = username;
        // echo to client they've connected
        socket.emit('updatechat', 'SERVER', 'you have connected');
        // echo globally (all clients) that a person has connected
        socket.broadcast.emit('updatechat', 'SERVER', username + ' has connected');
        // update the list of users in chat, client-side
        io.sockets.emit('updateusers', usernames);
    });
    ///////////////////////
socket.on('uploaded',function(js){
    var file=JSON.stringify(js);
    console.log(file)});
    //////////////////////

    // when the user disconnects.. perform this
    socket.on('disconnect', function () {
        // remove the username from global usernames list
        delete usernames[socket.username];
        // update list of users in chat, client-side
        io.sockets.emit('updateusers', usernames);
        // echo globally that this client has left
        socket.broadcast.emit('updatechat', 'SERVER', socket.username + ' has disconnected');
    });
});
//////////////////////////////////////

Html Code of Client named index.html
/////////////////////////////
<script src="/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

<script>
  var socket = io.connect('http://localhost:8765');

  // on connection to server, ask for user's name with an anonymous callback
  socket.on('connect', function(){
    // call the server-side function 'adduser' and send one parameter (value of prompt)
    socket.emit('adduser', prompt("What's your name?"));
  ////////////////////////
  ///////////////////////
   });
 


  // listener, whenever the server emits 'updatechat', this updates the chat body
  socket.on('updatechat', function (username, data) {
    $('#conversation').append('<b>'+username + ':</b> ' + data + '<br>');
  });
 
  ////////////////////////////////////
  socket.on('fill',function(data){
  $('#txt').append("Result is :"+data);
 });

 socket.on('filljs',function(data){
 //if(data!='')
  $('#jsn').append(data);
 });
  //////////////////////////////////////
 

  // listener, whenever the server emits 'updateusers', this updates the username list
  socket.on('updateusers', function(data) {
    $('#users').empty();
    $.each(data, function(key, value) {
      $('#users').append('<div>' + key + '</div>');
    });
  });

  // on load of page
  $(document).ready(function() {
    // when the client clicks SEND
    $('#datasend').click( function() {
      var message = $('#data').val();
      var message2 = $('#data2').val();
      $('#data').val('');
      $('#data2').val('');
      $('#txt').empty();
      // tell server to execute 'sendchat' and send along one parameter
    //  socket.emit('sendchat', message);
        socket.emit('add',message,message2);
    });
    /////////////////////////////
    $('#rdr').click(function(){
    socket.emit('readjson');
    });
    /////////////////////////////
    // when the client hits ENTER on their keyboard
    $('#data').keypress(function(e) {
      if(e.which == 13) {
        $(this).blur();
        $('#datasend').focus().click();
      }
    });
    /////////////////////////////////////////////
   
    $('#upload').bind("click",function()
    {
        var imgVal = $('#uploadImage').val();
    //  document.getElementById("#uploadImage").files[0];
        socket.emit('uploaded',imgVal);
    });

    ////////////////////////////////////////////
  });

</script>
<html>
<head>
<link rel="stylesheet" type="text/css" href=style.css">
</head>
<div style="float:left;width:100px;border-right:1px solid black;height:300px;padding:10px;overflow:scroll-y;">
  <b>USERS</b>
  <div id="users"></div>
</div>
<div style="float:left;width:400px;height:250px;overflow:scroll-y;padding:10px;">
  <div id="conversation"></div>
  <p>
    <input id="data" style="width:200px;" />
    <input id="data2" style="width:200px"/>
  </p>
  <p>
    <input type="button" id="datasend" value="send";
    style="width:100;height:50" />
    <br>
    <textarea name="text" id="txt"></textarea>
  </p>
  <p>
  <textarea name="jsn" id="jsn" rows="10" cols="50"></textarea></p>
  <input id="rdr" type="button" value="Read Json" style="width:100;height:50"/>
 <!-- <input type="submit" size="40">-->
</div>
<input type="file" name="image" id="uploadImage" size="30" />
<input type="submit" name="upload" id="upload"  class="send_upload" value="upload" />
<html>     


WPF Client for Console Server Signalr Server. ASP.NET, Signalr, WPF Client

Main Window.Xaml
////////////////////////////
<Window x:Class="Virtual_Trainer_Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button x:Name="Button1" Content="Send" HorizontalAlignment="Left" Margin="268,35,0,0" VerticalAlignment="Top" Width="75" Click="Button1_Click"/>
        <Button x:Name="Button2" Content="Connect" HorizontalAlignment="Left" Margin="385,35,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.5,0.5" Click="Button2_Click"/>
        <ListBox x:Name="listBox1" HorizontalAlignment="Left" Height="100" Margin="183,107,0,0" VerticalAlignment="Top" Width="258" RenderTransformOrigin="0.231,0.401"/>
        <TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="39" Margin="87,63,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="127"/>
        <TextBox x:Name="textbox2" HorizontalAlignment="Left" Height="80" Margin="29,107,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="149"/>
        <Label x:Name="label_welcome" Content="" HorizontalAlignment="Left" Margin="19,10,0,0" VerticalAlignment="Top" Height="26" Width="149"/>

    </Grid>
</Window>
///////////////////////////////////////////////////////////////////
Main Window.xaml.cs
///////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Client;
using Microsoft.AspNet.SignalR.Client.Hubs;
//using System.Windows.Threading.Dispatcher;


namespace Virtual_Trainer_Client
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        IHubProxy proxy;
        HubConnection connection;
        public MainWindow()
        {
            InitializeComponent();
         
       
        }
        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            connection = new HubConnection(@"http://localhost:8081/");
            proxy = connection.CreateHubProxy("commHub");
           
          
            proxy.On("broadCastToClients", message =>function(message));
            proxy.On("joined",mess=>this.Dispatcher.Invoke((Action)(()=>label_welcome.Content="Wellcome from Server")));
          
            connection.Error += connection_Error;
            connection.Start().Wait();
        }
        void connection_Error(Exception obj)
        {
            MessageBox.Show(obj.Message);
        }

        void function(string mess)
        {
            this.Dispatcher.Invoke((Action)(() => { textbox2.Text += mess+'\n'; }));
        }
      

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
      
          
            proxy.Invoke("send", textBox1.Text);
            textBox1.Text = null;
       
        }
        private  void UpdateApplicationDataUI(string msg)
        {
            //txtStatus.Text = "test";
            textbox2.Text = msg;
        }
   
       
    }
    public static class ControlExtensions
    {
        public static void Invoke(this Control Control, Action Action)
        {
            Control.Invoke(Action);
        }
    }
}
/////////////////////////////////////////////////////
Run Server
then Client
Click on connect a welcome message will be sent from server to client.
Then any message sent by the client will be received back from the server.

Asp.NET Signalr SelfHost Server in Console. C# Asp.NET Signalr with WPF Client/Console Client/ JavaScript Client

using System;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Hosting;
using Owin;
using Microsoft.AspNet.SignalR.Hubs;
using System.Threading.Tasks;
using System.Threading;

namespace SignalR.Hosting.Self.Samples
{
    class Program
    {
     public  IHubContext context = GlobalHost.ConnectionManager.GetHubContext<CommunicationHub>();
        static public void Tick(Object stateInfo)
        {
           // context.Clients.All.joined("HELLO");
            //Console.WriteLine(context.Clients.ToString());
            Console.WriteLine("Tick: {0}", DateTime.Now.ToString("h:mm:ss"));
           
            //context.Clients.All.joined("Tick: {0}", DateTime.Now.ToString("h:mm:ss"));
        }
       // DateTime obje = new DateTime();
       
        public static string message=null;

       // public void Messagetoall()
       //{
       //     context.Clients.All.joined("HeLLO"); }
        static void Main(string[] args)
        {
            TimerCallback callback = new TimerCallback(Tick);
           
            string url = "http://localhost:8081";

            using (WebApplication.Start<Startup>(url))
            {
                Console.WriteLine("Server running on {0}", url);
                Console.WriteLine("Creating timer: {0}\n",
                             DateTime.Now.ToString("h:mm:ss"));
                for (int i = 0; i < 100; i++)
                { Thread.Sleep(50); }
                    //while (true)
                    //{// broadcast obj = new broadcast();
                    //    // obj.Messagetoall();
                    //   // Program prg = new Program();
                    //   // prg.Messagetoall();
                    //}
                // create a one second timer tick
                Timer stateTimer = new Timer(callback, null, 0, 1000);
                // loop here forever
                for (; ; )
                {            }
            }
           
        }
    }
    //public class broadcast:Program
    //{

    //    public void Messagetoall()
    //    { context.Clients.All("HeLLO"); }
    //}

 public   class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Turn cross domain on
            var config = new HubConfiguration { EnableCrossDomain = true };

            // This will map out to http://localhost:8080/signalr by default
            app.MapHubs(config);
        }
    }
    [HubName("commHub")]
    public class CommunicationHub : Hub
    {
        public void send(string message)
        {
            Console.WriteLine(message);
            Clients.Caller.broadCastToClients(message);
        }
        public override Task OnConnected()
        {
            Console.WriteLine("Request from "+Context.ConnectionId+" is recieved");
            return Clients.All.joined(Context.ConnectionId, DateTime.Now.ToString());
        }
        public override Task OnDisconnected()
        {
            Console.WriteLine(Context.ConnectionId + " is Disconnected");
            return Clients.All.left(Context.ConnectionId, DateTime.Now.ToString());
        }
    }
}

Circle Rotation Around X-Axis Y-Axis Z-AXis, C++ Source Code, Opengl, Computer Graphics,

#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include<iostream>
#include<math.h>
using namespace std;
float angle=1.0;
void createcircle () {
// Create the circle in the coordinates origin
const int sides = 20;  // The amount of segment to create the circle
const double radius = 10; // The radius of the circle
 glBegin(GL_LINE_LOOP);
 for (int a = 0; a < 360; a += 360 / sides)
  {
    double heading = a * 3.1415926535897932384626433832795 / 180;
    glVertex2d(cos(heading) * radius, sin(heading) * radius);
  }

glEnd();
}

void RotateCircle(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glColor3f(1.0, 1.0, 1.0);

  glMatrixMode(GL_MODELVIEW);

    glTranslatef(0,3,0);
    glRotatef(angle, 1.0, 0.0, 0.0);
    //glRotatef(angle, 0.0, 1.0, 0.0);
    //glRotatef(angle, 0.0, 0.0, 1.0);
    createcircle();
    glutSwapBuffers();

}


int main(int argc, char **argv)
{
  glutInit(&argc, argv);
  glutInitWindowSize(500, 500);
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
  glutCreateWindow("Assignment# 3");
  glutDisplayFunc(RotateCircle);
  glutIdleFunc(RotateCircle);
  glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
  glutMainLoop();
  return(0);
}
// //    #include <GL/gl.h>
//#include <math.h>
//#include <GL/glut.h>
//
//
//typedef struct
//{
//float x;
//float y;
//}CIRCLE;
//
//CIRCLE circle;
//
//float rot = 0;
//
//void createcircle (int k, int r, int h) {
//    glBegin(GL_LINES);
//    for (double i = 0; i < 180; i++)
//    {
//    circle.x = r * cos(i) - h;
//    circle.y = r * sin(i) + k;
//    glVertex3f(circle.x + k,circle.y - h,0);
//   
//    circle.x = r * cos(i + 0.1) - h;
//    circle.y = r * sin(i + 0.1) + k;
//    glVertex3f(circle.x + k,circle.y - h,0);
//    }
//    glEnd();
//}
//
//void display (void) {
//    glClearColor (0.0,0.0,0.0,1.0);
//    glClear (GL_COLOR_BUFFER_BIT);
//    glLoadIdentity();
//    glTranslatef(0,0,-20);
//    glRotatef(rot,0,1,0);
//    glRotatef(rot,1,0,0);
//    glRotatef(rot,0,0,1);
//    glColor3f(1,1,1);
//    createcircle(0,10,0);
//    glRotatef(rot,0,1,0);
//    glRotatef(rot,1,0,0);
//    glRotatef(rot,0,0,1);
//    glColor3f(1,0,0);
//    createcircle(-2,8,-2);
//    glRotatef(rot,0,1,0);
//    glRotatef(rot,1,0,0);
//    glRotatef(rot,0,0,1);
//    glColor3f(0,1,0);
//    createcircle(-1,6,-1);
//    glRotatef(rot,0,1,0);
//    glRotatef(rot,1,0,0);
//    glRotatef(rot,0,0,1);
//    glColor3f(0,0,1);
//    createcircle(2,4,2);
//    glRotatef(rot,0,1,0);
//    glRotatef(rot,1,0,0);
//    glRotatef(rot,0,0,1);
//    glColor3f(0,1,1);
//    createcircle(1,2,1);
//    glutSwapBuffers();
//    rot++;
//}
//
//void reshape (int w, int h) {
//    glViewport (0, 0, (GLsizei)w, (GLsizei)h);
//    glMatrixMode (GL_PROJECTION);
//    glLoadIdentity ();
//    gluPerspective (60, (GLfloat)w / (GLfloat)h, 0.1, 100.0);
//    glMatrixMode (GL_MODELVIEW);
//}
//
//int main (int argc, char **argv) {
//    glutInit (&argc, argv);
//    glutInitDisplayMode (GLUT_DOUBLE);
//    glutInitWindowSize (500, 500);
//    glutInitWindowPosition (100, 100);
//    glutCreateWindow ("A basic OpenGL Window");
//
//    glutDisplayFunc (display);
//    glutIdleFunc (display);
//    glutReshapeFunc (reshape);
//    glutMainLoop ();
//    return 0;
//}

Bresmen's Ellipse Algorithm for Ellipse Drawing in all vertices C++ Source Code OpengL VS-2012 Computer Graphics

#include <glut.h>
using namespace std;
void Start_Line( );
void Set_Graphics( int, int );
//void Line_Algo( int, int, int, int );

int main( int argc, char** argv  )
{
   
    glutInit( &argc, argv );
    glutInitWindowSize( 640,480);
    glutInitWindowPosition( 100, 150 );
    glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
    glutCreateWindow( " Elipse Drawing" );
    glutDisplayFunc( Start_Line );
    Set_Graphics( 100, 100 /*window_width, window_height*/ );
    glutMainLoop( );
    return 0;
}

void drawDot (GLint x, GLint y, GLfloat r, GLfloat g, GLfloat b)
{ glColor3f(r,g,b);
  glBegin (GL_POINTS);
      glVertex2i (x,y);
  glEnd();
}

void symmetricPixels (int x, int y, int xc, int yc, float r, float g, float b)
{ drawDot (xc + x, yc + y, r,g,b);
  drawDot (xc - x, yc + y,r,g,b);
  drawDot (xc + x, yc - y,r,g,b);
  drawDot (xc - x, yc - y,r,g,b);
}

void Ellipse (int a, int b, int xc, int yc, float r, float g, float bl)
{ int aSq,bSq,twoASq,twoBSq,d,dx,dy,x,y;

  aSq = a*a;
  bSq = b*b;
  twoASq = 2*aSq;
  twoBSq = 2*bSq;
  d = bSq - b*aSq + aSq/4;
  dx = 0;
  dy = twoASq*b;
  x = 0;
  y = b;
  symmetricPixels(x,y,xc,yc,r,g,bl);
  while (dx < dy)
  { x++;
    dx += twoBSq;
    if (d >= 0)
    { y--;
      dy -= twoASq;
    }
    if (d < 0)
     d += bSq + dx;
    else
     d += bSq + dx - dy;
    symmetricPixels (x,y,xc,yc,r,g,bl);
  }
  d = (int)(bSq*(x+0.5)*(x+0.5) + aSq*(y-1)*(y-1) -
                 aSq*bSq);
  while (y > 0)
  { y--;
    dy -= twoASq;
    if (d <= 0)
    { x++;
      dx += twoBSq;
    }
    if (d > 0)
         d += aSq - dy;
    else
         d += aSq -dy +dx;
    symmetricPixels(x,y,xc,yc,r,g,bl);
  }
}   
void Set_Graphics( int width, int height )
{
    glClearColor( 1.0, 1.0, 1.0, 0.0 );
    glColor3f( 0.0f, 0.0f, 0.0f );
    glViewport( 0, 0, width, height );
    glMatrixMode( GL_PROJECTION );   
    glLoadIdentity( );
    glEnable( GL_DEPTH_TEST );
    gluPerspective( 45, ( float ) width / height, 1.0, 0 );
    glMatrixMode( GL_MODELVIEW );
    glTranslatef( 0, 0, 5 * ( -height) );
}
void Start_Line( )
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
//    Line_Algo( 5, 8, 29,32 );
//    Circle (40,0,0,1);
    Ellipse (100,30,20,20,0,1,0);
  // glFlush();
    glutSwapBuffers( );
}

Read More

Articles for you