Code (27)

25-09-2019 Programmatic Logic - Munafiq, Amanat may Khayanat - Hypocrite, Breach of Trust
06-10-2018 From wireframe to HTML, Design to Code - AI Power Sample
08-11-2012 Recursive Query Parent Child Concatenation
25-04-2012 Change or remove filter / filter content from Sharepoint list / library view columns
20-04-2011 Sigin as different user in asp.net using Windows authentication
26-01-2011 Powershell CmdLets
30-05-2010 Update Statistics - Query to find tables and index number of statistics being old
15-03-2010 Passing encrypted data between JavaScript and C#
12-02-2010 Sharepoint - SPWeb.Groups Vs SPWeb.SiteGroups
28-01-2010 Accessing JD Edwards Data on iSeries or AS/400 from a ASP.NET / SQL Encoding / Error problem
28-01-2010 Controls not functional after Export to Excel or Export to PDF of Telerik in Sharepoint Application page
05-10-2009 ASP.NET Cannot open log for source {0}. You may not have write access. - Access is denied
28-08-2009 CRM - The SELECT permission was denied on the object 'BuildVersion', database 'MicrosoftCRM_MSCRM', schema 'dbo'
22-08-2009 CRM - Retrieve Cultures information from CRM into your Custom Web Application
21-08-2009 CRM - Globalization / Localization in Custom Web Application
19-08-2009 CRM - Do you want to save this file? Blank.aspx?
18-08-2009 CRM Exception - Microsoft.Crm Application.Platform.Report. InternalCreate(String xml)
18-08-2009 CRM Exception - Microsoft.Crm.Reporting SRSReport.convertDataSource()
24-06-2009 Oracle SQL Developer - Unable to create an instance of the Java Virtual Machine
27-01-2009 Detecting Idle time or Inactivity in Windows Forms
23-01-2009 PasswordChar and Set focus on page load for ToolStripTextBox
21-01-2009 Capture Form Close Event
21-01-2009 Richtextbox or multiline textbox and AcceptButton to handle Enter or Tab key press
21-01-2009 Key Combination shortcuts in C# Windows Form
01-01-2009 Convert string to hexadecimal and hexadecimal to string
31-12-2008 Implementing Transaction in Stored Procedure
31-12-2008 Implementing Transaction in .NET
Fri 21 Aug 2009

If you required to set localization / culture in your custom web application that is running in IFRAME section of your CRM Application, according to User preferred language selected by user in Language option, go with the following

 Override the InitializeCulture() method in your custom web application as


        protected override void InitializeCulture()
        {
                base.InitializeCulture();

                WhoAmIRequest whoAmIRequest = new WhoAmIRequest();
                WhoAmIResponse whoAmIResponse = (WhoAmIResponse)crmService.Execute(whoAmIRequest);

                // Get the usersettings entity
                RetrieveUserSettingsSystemUserRequest reqUserSettings = new RetrieveUserSettingsSystemUserRequest();
                reqUserSettings.EntityId = whoAmIResponse.UserId;
                ColumnSet columns = new ColumnSet();
                columns.Attributes = new String[] { "uilanguageid" };
                reqUserSettings.ColumnSet = columns;
                reqUserSettings.ReturnDynamicEntities = true;
                CrmNumberProperty langProp = null;
                int langCode = 0;
                try
                {
                    //Get current logged in user setting
                    RetrieveUserSettingsSystemUserResponse resUserSttings = (RetrieveUserSettingsSystemUserResponse)crmService.Execute(reqUserSettings);
                    DynamicEntity objUserSettings = (DynamicEntity)resUserSttings.BusinessEntity;
                    foreach (Property prop in objUserSettings.Properties)
                    {
                        langProp = (CrmNumberProperty)prop;
                        if (langProp.Name.Equals("uilanguageid"))
                        {
                            //langCode = (CrmNumberProperty)objUserSettings.Properties["uilanguageid"];
                            langCode = langProp.Value.Value;
                            break;
                        }
                    }

                    //Set culture
                    Thread.CurrentThread.CurrentCulture = new CultureInfo(langCode);
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(langCode);

               }

                catch (System.Web.Services.Protocols.SoapException se)
                {
                    // Log it
                }
        }

If you are looking for Retrieve Cultures information from CRM into your Custom Web Application, have a look at

http://faisal.azmza.com/post/CRM-Retrieve-Cultures-information-from-CRM-into-your-Custom-Web-Application.aspx

 

Tags: ,
Comments here
Wed 19 Aug 2009

If you are getting a popup while navigating through Microsoft Dynamics CRM Application asking you to save Blank.aspx file, following workaround will help you

 

 

Please edit the default blank.aspx file in CRM (Sever where CRM is installed) so it contains data. This file is located at My Computer | System Drive | Program Files | Microsoft Dynamics CRM | CRMWeb |_ root. Here you will find the Blank.aspx text file.

 

Open the file and add some text to the file, for example you can add "Test" to the file (then there would be following three lines)

 

Test

<% Response.Expires = 1440; %>

<% Response.Cache.SetCacheability(HttpCacheability.Public); %>

 

 

 

Once you have added data, save the file, clear your temporary Internet Files, and do an IISreset. Once this is done go back into CRM to verify that this has resolved this issue.

 

 

 

 

Comments (7)
Tue 18 Aug 2009

If you get following exception while uploading / creating new report using Source Report Type -> Exising file

==============
[CrmException: Exception of type Microsoft.Crm.CrmException was thrown.]
  Microsoft.Crm.Application.Platform.Report.InternalCreate(String xml) +721
  Microsoft.Crm.Application.Platform.Entity.Create() +109
  Microsoft.Crm.Application.Forms.AppForm.RaiseDataEvent(FormEventId eventId) +408
  Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity) +57
  Microsoft.Crm.Application.Forms.EndUserForm.Execute(Entity entity) +13
  Microsoft.Crm.Web.Tools.ReportProperty.ReportPropertyPage.ConfigureForm() +202
  Microsoft.Crm.Application.Controls.AppPage.OnPreRender(EventArgs e) +30
==============

The issue lay with our RS permissions.
In addition to failing to upload reports, we tried downloading them from CRM too. This gave us an NT permissions error.
So, we opened up (localhost)/reports, navigated to the CRM datasource (typcially 'Organization_MSCRM), then properties, then security,
and then added a user / group called NT AUTHORITY\NETWORK SERVICE,
and gave them the permissions of CRM Publisher.
After that it all worked fine.

Thanks to Lee/Ronald

 

Comments here
Tue 18 Aug 2009

If you get following exception while uploading / creating new report using Source Report Type -> Exising file

=============
Stack Trace Info: [NullReferenceException: Object reference not set to an instance of an object.]
   at Microsoft.Crm.Reporting.SRSReport.convertDataSource()
   at Microsoft.Crm.Reporting.SRSReport..ctor(String xmlContent, String originalFilter, Boolean convertReportToCrm, ExecutionContext context)
   at Microsoft.Crm.ObjectModel.ReportService.CreateInternal(IBusinessEntity entity, Boolean isScheduledReport, ExecutionContext context)
   at Microsoft.Crm.ObjectModel.ReportService.Create(IBusinessEntity entity, ExecutionContext context)
=============

The reason can be the Shared Datasource used while creating Report in Visual Studio 2005.

1. Create a new Report Project in Visual Studio 2005

2. Right click on Reports, choose to add Existing Item

3. Double Click on the report to open it.

4. Click on the Data (top tab) above the open report file.

5. Click the "..." button just to the right of Dataset to open Dataset Properties.

6. Click on the "..." button to the right of the Data Source drop down list.

7. Clear the "Use shared data source reference" option.

8. Click on the "Edit..." button to the right of Connection string.

9. Enter the correct SRS Server Name, enter the authentication method, and choose the correct database name.

10. Click OK, this will change the source for the entire report.

11. Click OK to the Visual Studio window again.

12. Choose, File, Save <Report>.

13. Try to upload it again. This time it should load.

 Thanks to mennotk

 

Comments here
Wed 24 Jun 2009

After extracting sqldeveloper-1.5.4.59.40.zip and executing sqldeveloper.exe, I received following error

---------------------------
Oracle SQL Developer
---------------------------
Unable to create an instance of the Java Virtual Machine
Located at path:
<SQLDEVELOPER>\jdk\jre\bin\client\jvm.dll
---------------------------
OK  
---------------------------

Resolution for this error which works for me, as follow :-


Open ide.conf file from

<SQLDEVELOPER>/jdev/bin/ide.conf
or
<SQLDEVELOPER>\ide\bin\ide.conf


In this file, change this line :
AddVMOption -Xmx512M

by

AddVMOption -Xmx256M

Now, the executable is lauching correctly. No more errors with Java Virtual Machine.

 

Also check the diskspace where sqldeveloper is extracted and available RAM.
You may need to revert back in future if there is no more issue with original file's setting.

 

Tags: ,
Comments (30)
Tue 27 Jan 2009

Today I was required to implement detecting the idle time or user inactivity in windows form. Here it is how it works
The theme behind is the usage of MessageFiler that will be intercepting calls (Keyboard / Mouse activities) and usage of System.Windows.Forms.Timer

Step 1.

Create MessageFilter class as

using System;
using System.Windows.Forms;

 public class MessageFilter : IMessageFilter
    {
       //Following are the Windows API hex values. You can find more at http://faisal.azmza.com/post/2009/01/Values-of-Windows-API.aspx
       // Here we are only interested in only Keyboard and Mouse activities
        private int WM_LBUTTONDOWN = 0x0201;
        private int WM_KEYDOWN = 0x0100;
        private int WM_RBUTTONDOWN = 0x0204;
        private int WM_MBUTTONDOWN = 0x0207;
        private int WM_MOUSEWHEEL = 0x020A;
        private int WM_MOUSEMOVE = 0x0200;

        public bool PreFilterMessage(ref Message m)
        {
            if (m.Msg == WM_MOUSEMOVE || m.Msg == WM_KEYDOWN || m.Msg == WM_LBUTTONDOWN || m.Msg == WM_MOUSEWHEEL || m.Msg == WM_RBUTTONDOWN || m.Msg == WM_MBUTTONDOWN)
            {
                //Reset the timer of form1
                Form1.timerIdle.Stop();
                Form1.timerIdle.Start();
            }
            return false;
        }
    }

Step 2:

In the form where you actually want to implement what to do if user is inactive for particular period, like redirecting to Login page, performing Session / objects cleanup, hiding or locking touchy form etc etc, put following peace of code,

a) Declare static timer as

//Reason for taking this timer as static becasue we need to reset timer in MessageFilter class.
//If don't want to use static then you can implement your own logic. The theme is to reset the timer in MessageFilter on any Keyboard or Mouse activity

internal static Timer timerIdle;

b) Put following initializing code after InitializeComponent or on Form_Load. Note to set Interval of timer to your requirement. Here it is set for 5 minutes.

            timerIdle = new System.Windows.Forms.Timer();
            timerIdle.Enabled = true;
            timerIdle.Interval = 50000; // Idle time period. Here after 5 minutes perform task in  timerIdle_Tick
            timerIdle.Tick += new EventHandler(timerIdle_Tick);

 c) Put following inside your form

        private void timerIdle_Tick(object sender, EventArgs e)
        {
            //Here perform your action by first validating that idle task is not already running.
           // If you want to redirect user to login page, then first check weather login page is already displayed or not
           // if not then show loign page. Same logic for other task or Implement your own.
           // Remember after every five minutes or period you defined above this timerIdle_Tick will be called
           //so first check weather idle task is already running or not. If not then perform
            //if (Login.Visible == false)
            //{
                   //PerformNecessoryActions();
                  //ShowLoginForm();
            //}
        }

 

Step 3.

So far we have created MessageFilter class (On keyboard or mouse activity it will reset the timer of form). In form we have declared and initialize timer. On timer_Tick event we have implement the task which we need to do when user become inactive for particular period of time. Now in last step, Add our MessageFilter class in Application to intercept calls as

static void Main(string[] args)
{
            Application.AddMessageFilter(new MessageFilter());
            Application.Run(new Form1());
}


Hope it helps.

 

Comments (1)
Fri 23 Jan 2009

In first sight you will not see  PasswordChar property in ToolStripTextBox.
If you want Password char in ToolStripTextBox and To allow ToolStripTextBox to act as Password textbox like * do following

ToolStripTextBox1.TextBox.PasswordChar = '*';


===========================


Usually ToolStripTextBox.Focus() doesn't focus to ToolStripTextBox when opening form or on form load.
To set focus on ToolStripTextBox when opening form or form load, do following

In FOrm1_Activated event

        private void Form1_Activated(object sender, EventArgs e)
        {
            ToolStripTextBox1.Focus();
        }

Or

on Form1_Load event

this.ActiveControl = ToolStripTextBox1.Control;

 

Tags: ,
Comments here