/// <summary>
        /// 创建一个与活动矩阵不匹配列的审批矩阵
        /// </summary>
        /// <returns></returns>
        public static WfApprovalMatrix PrepareExtrApprovalMatrix()
        {
            WfApprovalMatrix matrix = new WfApprovalMatrix() { ID = UuidHelper.NewUuidString() };

            matrix.PropertyDefinitions.Add(new SOARolePropertyDefinition() { Name = "CostCenter", SortOrder = 0 });
            matrix.PropertyDefinitions.Add(new SOARolePropertyDefinition() { Name = "ExtraApprover", SortOrder = 1 });

            SOARolePropertyDefinitionCollection pds = matrix.PropertyDefinitions;

            SOARolePropertyRow row1 = new SOARolePropertyRow() { RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = string.Empty };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row1.Values.Add(new SOARolePropertyValue(pds["ExtraApprover"]) { Value = "wangli5" });

            matrix.Rows.Add(row1);

            SOARolePropertyRow row2 = new SOARolePropertyRow() { RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = string.Empty };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row2.Values.Add(new SOARolePropertyValue(pds["ExtraApprover"]) { Value = "InvalidUser" });

            matrix.Rows.Add(row2);

            return matrix;
        }
        public WfApprovalMatrix ClientToServer(WfClientApprovalMatrix client, ref WfApprovalMatrix server)
        {
            client.NullCheck("client");

            if (server == null)
                server = new WfApprovalMatrix();

            server.ID = client.ID;

            foreach (WfClientRolePropertyDefinition cpd in client.PropertyDefinitions)
            {
                SOARolePropertyDefinition spd = null;

                WfClientRolePropertyDefinitionConverter.Instance.ClientToServer(cpd, ref spd);

                server.PropertyDefinitions.Add(spd);
            }

            foreach (WfClientRolePropertyRow cRow in client.Rows)
            {
                SOARolePropertyRow sRow = null;

                WfClientRolePropertyRowConverter.Instance.ClientToServer(cRow, server.PropertyDefinitions, ref sRow);

                server.Rows.Add(sRow);
            }

            return server;
        }
        public WfClientApprovalMatrix ServerToClient(WfApprovalMatrix server, ref WfClientApprovalMatrix client)
        {
            server.NullCheck("server");

            if (client == null)
                client = new WfClientApprovalMatrix();

            client.ID = server.ID;

            foreach (SOARolePropertyDefinition spd in server.PropertyDefinitions)
            {
                WfClientRolePropertyDefinition cpd = null;

                WfClientRolePropertyDefinitionConverter.Instance.ServerToClient(spd, ref cpd);

                client.PropertyDefinitions.Add(cpd);
            }

            foreach (SOARolePropertyRow sRow in server.Rows)
            {
                WfClientRolePropertyRow cRow = null;

                WfClientRolePropertyRowConverter.Instance.ServerToClient(sRow, client.PropertyDefinitions, ref cRow);

                client.Rows.Add(cRow);
            }

            return client;
        }
        /// <summary>
        /// 准备一个一行的矩阵
        /// </summary>
        /// <returns></returns>
        public static WfApprovalMatrix PrepareOneRowApprovalMatrixResourceDescriptor()
        {
            WfApprovalMatrix resource = new WfApprovalMatrix();

            resource.PropertyDefinitions.CopyFrom(PreparePropertiesDefinition());
            resource.Rows.Add(PrepareOneRow(resource.PropertyDefinitions));

            return resource;
        }
        public static WfApprovalMatrix PrepareApprovalMatrix()
        {
            WfApprovalMatrix matrix = new WfApprovalMatrix() { ID = UuidHelper.NewUuidString() };

            matrix.PropertyDefinitions.CopyFrom(PreparePropertiesDefinition());
            matrix.Rows.CopyFrom(PrepareRows(matrix.PropertyDefinitions));

            return matrix;
        }
        public WfApprovalMatrix GetByID(string id)
        {
            id.NullCheck("id");

            WfApprovalMatrix matrix = new WfApprovalMatrix() { ID = id };

            matrix.PropertyDefinitions = SOARolePropertyDefinitionAdapter.Instance.GetByRoleID(id);
            matrix.Rows = SOARolePropertiesAdapter.Instance.GetByRoleID(id);

            return matrix;
        }
        protected override void OnExecute(WfDesignerExecutorDataContext dataContext)
        {
            this._InputStream.Seek(0, SeekOrigin.Begin);

            WorkBook workBook = WorkBook.Load(this._InputStream);

            WfApprovalMatrix matrix = workBook.ToApprovalMatrix();

            matrix.ID = this.MatrixID;

            WfApprovalMatrixAdapter.Instance.Update(matrix);
        }
Esempio n. 8
0
        /// <summary>
        /// 更新矩阵
        /// </summary>
        /// <param name="matrix"></param>
        public void Update(WfApprovalMatrix matrix)
        {
            matrix.NullCheck("matrix");
            matrix.ID.CheckStringIsNullOrEmpty("matrix.ID");

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                SOARolePropertyDefinitionAdapter.Instance.Update(matrix.ID, matrix.PropertyDefinitions);
                SOARolePropertiesAdapter.Instance.Update(matrix.ID, matrix.Rows);

                scope.Complete();
            }
        }
        /// <summary>
        /// 更新矩阵
        /// </summary>
        /// <param name="matrix"></param>
        public void Update(WfApprovalMatrix matrix)
        {
            matrix.NullCheck("matrix");
            matrix.ID.CheckStringIsNullOrEmpty("matrix.ID");

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                SOARolePropertyDefinitionAdapter.Instance.Update(matrix.ID, matrix.PropertyDefinitions);
                SOARolePropertiesAdapter.Instance.Update(matrix.ID, matrix.Rows);

                scope.Complete();
            }
        }
Esempio n. 10
0
        public WfApprovalMatrix GetByID(string id)
        {
            id.NullCheck("id");

            WfApprovalMatrix matrix = new WfApprovalMatrix()
            {
                ID = id
            };

            matrix.PropertyDefinitions = SOARolePropertyDefinitionAdapter.Instance.GetByRoleID(id);
            matrix.Rows = SOARolePropertiesAdapter.Instance.GetByRoleID(id);

            return(matrix);
        }
Esempio n. 11
0
        /// <summary>
        /// 得到外部矩阵
        /// </summary>
        /// <returns></returns>
        public IWfMatrixContainer GetExternalMatrix()
        {
            WfApprovalMatrix result = null;

            if (this.ExternalMatrixID.IsNotEmpty())
            {
                result = WfApprovalMatrixAdapter.Instance.GetByID(this.ExternalMatrixID);
            }
            else
            {
                result = new WfApprovalMatrix();
            }

            return(result);
        }
        /// <summary>
        /// 得到外部矩阵
        /// </summary>
        /// <returns></returns>
        public IWfMatrixContainer GetExternalMatrix()
        {
            WfApprovalMatrix result = null;

            if (this.ExternalMatrixID.IsNotEmpty())
                result = WfApprovalMatrixAdapter.Instance.GetByID(this.ExternalMatrixID);
            else
                result = new WfApprovalMatrix();

            return result;
        }
        public static void AreSame(this WfApprovalMatrix expected, WfApprovalMatrix actual)
        {
            AssertStringEqual(expected.ID, actual.ID);

            AreSame(expected.PropertyDefinitions, actual.PropertyDefinitions);
            AreSame(expected.Rows, actual.Rows);
        }