Friday, January 25, 2013

CRM TimeZone Codes

You know when you're minding your own business, doing things with CRM when all the sudden you realize you need the CRM time zone code for a specific time zone? No? Well, happens to me all the time and I'm tired of looking it up. Well, here they are:

CRM TimeZoneCode Time Zone Name GMT Off-set
0 Dateline Time -12
1 Samoa Time -11
2 Hawaiian Time -10
3 Alaskan Time -9
4 Pacific Time -8
10 Mountain Time -7
13 Mexico2 Time -7
15 US Mountain Time -7
20 Central Time -6
25 Canada Central Time -6
30 Mexico Time -6
33 Central America Time -6
35 Eastern Time -5
40 US Eastern Time -5
45 SA Pacific Time -5
50 Atlantic Time -4
55 SA Western Time -4
56 Pacific SA Time -4
60 Newfoundland Time -3.5
65 E. South America Time -3
70 SA Eastern Time -3
73 Greenland Time -3
75 Mid-Atlantic Time -2
80 Azores Time -1
83 Cape Verde Time -1
85 GMT Time 0
90 Greenwich Time 0
95 Central Europe Time 1
100 Central European Time 1
105 Romance Time 1
110 W. Europe Time 1
113 W. Central Africa Time 1
115 E. Europe Time 2
120 Egypt Time 2
125 FLE Time 2
130 GTB Time 2
135 Jerusalem Time 2
140 South Africa Time 2
145 Russian Time 3
150 Arab Time 3
155 E. Africa Time 3
158 Arabic Time 3
160 Iran Time 3.5
165 Arabian Time 4
170 Caucasus Time 4
175 Afghanistan Time 4.5
180 Ekaterinburg Time 5
185 West Asia Time 5
190 India Time 5.5
193 Nepal Time 5.75
195 Central Asia Time 6
200 Sri Lanka Time 6
201 N. Central Asia Time 6
203 Myanmar Time 6.5
205 SE Asia Time 7
207 North Asia Time 7
210 China Time 8
215 Malay Peninsula Time 8
220 Taipei Time 8
225 W. Australia Time 8
227 North Asia East Time 8
230 Korea Time 9
235 Tokyo Time 9
240 Yakutsk Time 9
245 AUS Central Time 9.5
250 Cen. Australia Time 9.5
255 AUS Eastern Time 10
260 E. Australia Time 10
265 Tasmania Time 10
270 Vladivostok Time 10
275 West Pacific Time 10
280 Central Pacific Time 11
285 Fiji Islands Time 12
290 New Zealand Time 12
300 Tonga Time 13
360 Coordinated Universal Time (UTC) 0

Friday, May 28, 2010

Examples of Basic SQL Queries

Example 1: INSERT INTO PhoneNumbers (name, number) VALUES(‘john’, 2034329343);

Given tables as follows: Company (companyName, id); EmployeesHired(id, numHired, fiscalQuarter)

Example 2: SELECT companyName FROM Company, EmployeesHired WHERE Company.id = EmployeesHired.id AND fiscalQuarter = 4;

Example 3: SELECT companyName FROM Company WHERE id NOT IN (SELECT id from EmployeesHired WHERE numHired > 0);

Example 4: SELECT companyName, SUM(numHired) FROM Company, EmployeesHired WHERE Company.id = EmployeesHired.id GROUP BY companyName;

Tuesday, May 25, 2010

Multithreading

Classes that support multithreaded programming are defined in the System.Threading namespace in C#.

using System.Threading;

Creating a Thread

Instatiate an object of type Thread.Thread

public Thread( ThreadStart entrypoint)

Here, entrypoint is the name of the method that will be called to begin execution of the thread. ThreadStart is a delegate defined by:

public delegate void ThreadStart()

Once created, the new thread will not start running until you call its Start() method.

using System;
using System.Threading;
namespace CSharpThreadExample
{
    class Program
    {
        public static void run()
        {
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("In thread " + Thread.CurrentThread.Name + i);
                Thread.Sleep(1000);
            }  
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Main Thread Starting");
            Thread.CurrentThread.Name = "Main ";
            Thread t1 = new Thread(new ThreadStart(run));

            t1.Name = "Child";
            t1.Start();

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("In thread " + Thread.CurrentThread.Name + i);
                Thread.Sleep(1000);
            }

            Console.WriteLine("Main Thread Terminates");
            Console.Read();
        }
    }

Methods


• Suspend() -> Suspends the execution of a thread till Resume() is called on that.

• Resume() -> Resumes a suspended thread. Can throw exceptions for bad state of the thread.

• Sleep() -> A thread can suspend itself by calling Sleep(). Takes parameter in form of milliseconds. We can use a special timeout 0 to terminate the current time slice and give other thread a chance to use CPU time

• Join()-> Called on a thread makes other threads wait for it till it finishes its task.

Syncronizing Shared Objects

The lock(object) is used to synchronize shared data.

lock (objecttobelocked) { objecttobelocked.somemethod(); }

Here objecttobelocked is the object reference which is used by more than one thread to call the method on that object. The lock keyword requires us to specify a token (an object reference) that must be acquired by a thread to enter within the lock scope. When we are attempting to lock down an instance level method, we can simply pass the reference to that instance. (We can use this keyword to lock the current object) Once the thread enters into a lock scope, the lock token (object reference) is inaccessible by other threads until the lock is released or the lock scope has exited.

If we want to lock down the code in a static method, we need to provide the System.Type of the respective class.

public void PrintNumbers()
{
 lock (this)
 {
  for (int i = 0; i < 5; i++)
  {
    Thread.Sleep(100);
    Console.Write(i + ",");
  }
  Console.WriteLine();
 }
}


Source: The Code Project http://www.codeproject.com/KB/threads/thread_synchronization.aspx