public JsonResult GetWorkTypes(string userName, string password, string domain, string companies, string utcTime, string signatureValue) { ValidateSignature.Check(userName, password, utcTime, signatureValue); using (Axapta ax = AxaptaInstanceContainer.GetInstance(userName, new SecurityHelper().Decrypt(password, true), domain, "")) { List <WorkType> list = new List <WorkType>(); if (companies != null && companies.Length > 0) { using (AxaptaRecord workflowWorkItemTableRecord = ax.CreateAxaptaRecord("WorkflowWorkItemTable")) { using (AxaptaRecord workflowTrackingStatusTableRecord = ax.CreateAxaptaRecord("WorkflowTrackingStatusTable")) { string query = "select RecId from %1 " + "where %1.UserId == curUserId() && %1.Status == WorkflowWorkItemStatus::Pending " + "join DocumentType, ContextTableId, count(RecId) from %2 group by DocumentType, ContextTableId " + "where %1.CorrelationId == %2.CorrelationId " + "&& %2.TrackingStatus == WorkflowTrackingStatus::Pending"; ax.ExecuteStmt(query, workflowWorkItemTableRecord, workflowTrackingStatusTableRecord); string axRecCount = ax.ToString(); while (workflowWorkItemTableRecord.Found == true) { string empty = string.Empty; if (workflowTrackingStatusTableRecord.Found == true) { empty = workflowTrackingStatusTableRecord.get_Field("ContextTableId").ToString(); } if (DataAreaIncluding.Check(empty, companies)) { object contextTableId = workflowTrackingStatusTableRecord.get_Field("ContextTableId"); object documentType = workflowTrackingStatusTableRecord.get_Field("DocumentType"); object recId = workflowTrackingStatusTableRecord.get_Field("RecId"); object tblName = ax.CallStaticClassMethod("Global", "tableId2Name", recId); list.Add(new WorkType() { WorkTypeName = documentType.ToString(), WorkTypeCount = Convert.ToInt32(recId) }); workflowWorkItemTableRecord.Next(); } } } } } return(Json(list, JsonRequestBehavior.AllowGet)); } }