20 Nisan 2011 Çarşamba

Microsoft Dynamics CRM 4.0 Login Error “Invalid Action


Merhaba arkadaşlar bugün ms crm  login olmaya  çalışırken Microsoft Dynamics CRM 4.0 Login Error “Invalid Action” şeklinde bir hata ile karşılaştım. Google’dan biraz  araştırma yaptıktan sonra konunun “Microsoft CRM Asynchronous Processing Service” ile ilgili olduğunu öğrendim. Microsoft CRM Asynchronous Processing Service”sini yeniden başlatıktan sonra düzeldi.

MS CRM 4.0’da Performansı artırmak için AsyncOperationBase ve WorkflowLogBase Tablolarının Silinmesi

Merhaba arkadaşlar bugün sizlere Microsoft Dynamics CRM 4.0'da performansı artırmak için düzenli yapılması gereken bazı tekniklerden bahsedeceğim. Microsoft Dynamics CRM 4.0'da çok sayıda iş akışı kullanırız. AsyncOperationBase ve WorkflowLogBase tablolarının boyutu çok fazla artar ve performans sorunlarıyla karşılaşılır. Bu sorun, iş akışı kuralları uygulanırken MSCRM veritabanındaki AsyncOperationBase ve WorkflowLogBase tablolarında bir iş akışı örneği ve bir iş akışı kaydı oluşturulması nedeniyle ortaya çıkar. Ancak iş akışı örneği tamamlandığında, iş akışı kaydı veritabanında kalır. Bu nedenle, AsyncOperationBase ve WorkflowLogBase tabloları büyümeye devam eder. Zaman içinde performans düşer.

Bu işlemi  aşağıdaki sorguyu çalıştırak silebilirsiniz. Detaylı bilgiyi bu link’den alabilirisiniz. (http://support.microsoft.com/kb/968520/tr)


IF EXISTS (SELECT name from sys.indexes
WHERE name = N'CRM_AsyncOperation_CleanupCompleted')
DROP Index AsyncOperationBase.CRM_AsyncOperation_CleanupCompleted
GO
CREATE NONCLUSTERED INDEX CRM_AsyncOperation_CleanupCompleted
ON [dbo].[AsyncOperationBase] ([StatusCode],[StateCode],[OperationType])
GO
declare @DeleteRowCount int
Select @DeleteRowCount = 2000
declare @DeletedAsyncRowsTable table (AsyncOperationId uniqueidentifier not null primary key)
declare @continue int, @rowCount int
select @continue = 1
while (@continue = 1)
begin
begin tran
insert into @DeletedAsyncRowsTable(AsyncOperationId)
Select top (@DeleteRowCount) AsyncOperationId
from AsyncOperationBase
where OperationType in (1, 9, 12, 25, 27, 10) AND StateCode = 3 AND StatusCode in (30, 32)     
Select @rowCount = 0
Select @rowCount = count(*) from @DeletedAsyncRowsTable
select @continue = case when @rowCount <= 0 then 0 else 1 end     
if (@continue = 1)
begin
delete WorkflowLogBase from WorkflowLogBase W, @DeletedAsyncRowsTable d
where W.AsyncOperationId = d.AsyncOperationId
delete BulkDeleteFailureBase From BulkDeleteFailureBase B, @DeletedAsyncRowsTable d
where B.AsyncOperationId = d.AsyncOperationId
delete AsyncOperationBase From AsyncOperationBase A, @DeletedAsyncRowsTable d
where A.AsyncOperationId = d.AsyncOperationId            
delete @DeletedAsyncRowsTable
end
commit
end
--Drop the Index on AsyncOperationBase
DROP INDEX AsyncOperationBase.CRM_AsyncOperation_CleanupCompleted


Veya custom bir uygulama yazarak istediğiniz bir zamana ayarlayıp çalıştırabilirsiniz. Aşağıdaki gibi bir Console uygulaması yazarak toplu silme özelliğini kullanabilirsiniz.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BulkDeleteMessageSample.CrmSdk;
using CrmSdk;

namespace CrmSdk
{
    class Program
    {
        static void Main(string[] args)
        {
            // Set up the CRM Service.
            CrmAuthenticationToken token = new CrmAuthenticationToken();
            token.AuthenticationType = 0;
            token.OrganizationName = "OrganizasyonAdi";

            CrmService service = new CrmService();
            service.CrmAuthenticationTokenValue = token;
            service.Credentials = System.Net.CredentialCache.DefaultCredentials;

            runBulkDelete(service);
        }

        static void runBulkDelete(CrmService service)
        {
            // Create a query expression using the QueryExpressionHelper
            QueryExpressionHelper expression = new QueryExpressionHelper("asyncoperation");
            expression.Columns.AddColumn("asyncoperationid");
            expression.Criteria.Conditions.AddCondition("statecode", ConditionOperator.Equal, (int)AsyncOperationState.Completed);
            expression.Criteria.Conditions.AddCondition("completedon", ConditionOperator.OlderThanXMonths, 1);
            expression.Criteria.Conditions.AddCondition("operationtype", ConditionOperator.NotEqual, (int)AsyncOperationType.Import);

            Guid[] emptyRecipients = new Guid[0];
            BulkDeleteRequest request = new BulkDeleteRequest();
            request.JobName = "Bulk delete completed asyncoperations to free up space";
            request.QuerySet = new QueryBase[] { expression.Query };
            request.ToRecipients = emptyRecipients;
            request.CCRecipients = emptyRecipients;
            request.SendEmailNotification = false;
            request.RecurrencePattern = string.Empty;
            request.StartDateTime = CrmDateTime.Now;

            BulkDeleteResponse response = (BulkDeleteResponse)service.Execute(request);

            Console.WriteLine("Bulk delete job with id: {0} has been created", response.JobId);
            Console.ReadLine();
        }
    }
}


Gelecek yazımda görüşmek dileğiyle..