public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientProcessQueryCondition condition = new WfClientProcessQueryCondition();

            condition.ApplicationName = DictionaryHelper.GetValue(dictionary, "applicationName", string.Empty);
            condition.ProgramName = DictionaryHelper.GetValue(dictionary, "programName", string.Empty);

            condition.BeginStartTime = DictionaryHelper.GetValue(dictionary, "beginStartTime", DateTime.MinValue);
            condition.EndStartTime = DictionaryHelper.GetValue(dictionary, "endStartTime", DateTime.MinValue);

            condition.DepartmentName = DictionaryHelper.GetValue(dictionary, "departmentName", string.Empty);
            condition.ProcessName = DictionaryHelper.GetValue(dictionary, "processName", string.Empty);

            condition.AssigneesSelectType = DictionaryHelper.GetValue(dictionary, "assigneesSelectType", WfClientAssigneesFilterType.CurrentActivity);
            condition.AssigneesUserName = DictionaryHelper.GetValue(dictionary, "assigneesUserName", string.Empty);

            condition.AssigneeExceptionFilterType = DictionaryHelper.GetValue(dictionary, "assigneeExceptionFilterType", WfClientAssigneeExceptionFilterType.All);

            condition.ProcessStatus = DictionaryHelper.GetValue(dictionary, "processStatus", string.Empty);

            condition.ProcessCreatorID = DictionaryHelper.GetValue(dictionary, "processCreatorID", string.Empty);
            condition.ProcessCreatorName = DictionaryHelper.GetValue(dictionary, "processCreatorName", string.Empty);

            JSONSerializerExecute.FillDeserializedCollection(dictionary.GetValue("currentAssignees", (ArrayList)null), condition.CurrentAssignees);

            return condition;
        }
        private static WfClientProcessQueryCondition PrepareQueryCondition()
        {
            WfClientProcessQueryCondition condition = new WfClientProcessQueryCondition();

            condition.ApplicationName = "My Applicaiton";
            condition.ProcessName = "My Process";
            condition.AssigneesUserName = "******";
            condition.AssigneesSelectType = WfClientAssigneesFilterType.AllActivities;
            condition.AssigneeExceptionFilterType = WfClientAssigneeExceptionFilterType.CurrentActivityError;
            condition.BeginStartTime = DateTime.Now;
            condition.EndStartTime = DateTime.Now.AddDays(1);
            condition.DepartmentName = "流程管理部";
            condition.ProcessStatus = WfClientProcessStatus.Running.ToString();

            condition.CurrentAssignees.Add(Consts.Users["Approver1"]);

            return condition;
        }
        public static void AreSame(this WfClientProcessQueryCondition expected, WfClientProcessQueryCondition actual)
        {
            AssertStringEqual(expected.ApplicationName, actual.ApplicationName);
            AssertStringEqual(expected.ProcessName, actual.ProcessName);
            AssertStringEqual(expected.AssigneesUserName, actual.AssigneesUserName);
            AssertStringEqual(expected.DepartmentName, actual.DepartmentName);
            AssertStringEqual(expected.ProcessStatus, actual.ProcessStatus);

            AssertDateTimeEqual(expected.BeginStartTime, actual.BeginStartTime);
            AssertDateTimeEqual(expected.EndStartTime, actual.EndStartTime);

            Assert.AreEqual(expected.AssigneesSelectType, actual.AssigneesSelectType);
            Assert.AreEqual(expected.AssigneeExceptionFilterType, actual.AssigneeExceptionFilterType);

            Assert.AreEqual(expected.CurrentAssignees.Count, actual.CurrentAssignees.Count);

            for (int i = 0; i < expected.CurrentAssignees.Count; i++)
            {
                expected.CurrentAssignees[i].AreSame(actual.CurrentAssignees[i]);
            }
        }
        public void ClearTenantProcessInstanceDataTest()
        {
            WfClientProcessQueryCondition condition = new WfClientProcessQueryCondition();

            condition.BeginStartTime = DateTime.Now.AddHours(-1);
            condition.EndStartTime = DateTime.Now.AddHours(1);
            condition.ProcessCreatorID = Consts.Users["Requestor"].ID;

            TenantContext.Current.DoActions("Test2", () =>
                {
                    WfClientProcessInfo process = OperationHelper.PrepareSimpleProcessInstance();

                    WfClientProcess processLoaded = WfClientProcessRuntimeServiceProxy.Instance.GetProcessByID(process.ID, Consts.Users["Requestor"]);

                    Assert.IsNotNull(processLoaded);

                    WfClientProcessRuntimeServiceProxy.Instance.ClearTenantProcessInstanceData("Test2");

                    try
                    {
                        processLoaded = WfClientProcessRuntimeServiceProxy.Instance.GetProcessByID(process.ID, Consts.Users["Requestor"]);

                        Assert.Fail("流程已经被删除,加载流程不能成功");
                    }
                    catch (System.Exception)
                    {
                    }
                });
        }
        public void QueryProcessesTest()
        {
            WfClientProcessQueryCondition condition = new WfClientProcessQueryCondition();

            condition.BeginStartTime = DateTime.Now.AddHours(-1);
            condition.EndStartTime = DateTime.Now.AddHours(1);
            condition.ProcessCreatorID = Consts.Users["Requestor"].ID;

            WfClientProcessInfo process = OperationHelper.PrepareSimpleProcessInstance();

            WfClientProcessCurrentInfoPageQueryResult result = WfClientProcessRuntimeServiceProxy.Instance.QueryProcesses(condition, 0, 1, string.Empty, -1);

            Assert.IsTrue(result.QueryResult.ContainsKey(process.ID));
        }
        public WfClientProcessCurrentInfoPageQueryResult QueryProcesses(WfClientProcessQueryCondition condition, int startRowIndex, int maximumRows, string orderBy, int totalCount)
        {
            condition.NullCheck("condition");

            OperationContext.Current.FillContextToOguServiceContext();

            WfProcessQueryCondition serverCondition = null;

            WfClientProcessQueryConditionConverter.Instance.ClientToServer(condition, ref serverCondition);

            if (orderBy.IsNullOrEmpty())
                orderBy = "START_TIME DESC";

            ConnectiveSqlClauseCollection connective = serverCondition.ToSqlBuilder();

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendItem("COMMITTED", "1");
            builder.AppendTenantCode();

            connective.Add(builder);

            QueryCondition qc = new QueryCondition(startRowIndex, maximumRows,
                ORMapping.GetSelectFieldsNameSql<WfProcessCurrentInfo>(),
                ORMapping.GetMappingInfo(typeof(WfProcessCurrentInfo)).TableName,
                orderBy);

            qc.WhereClause += connective.ToSqlString(TSqlBuilder.Instance);

            return QueryProcessInfo(qc, totalCount);
        }