Ejemplo n.º 1
0
        /// <summary>
        /// 将活动矩阵与审批矩阵进行合并,以第一个矩阵的列定义为准
        /// </summary>
        /// <param name="amRows"></param>
        /// <param name="amDefinitions"></param>
        /// <param name="apRows"></param>
        /// <param name="apDefinitions"></param>
        public static void MergeActivityMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable<SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        {
            amDefinitions.NullCheck("amDefinitions");
            amRows.NullCheck("amRows");
            apDefinitions.NullCheck("apDefinitions");
            apRows.NullCheck("apRows");

            int maxRowNumber = GetMaxRowNumber(amRows);

            foreach (SOARolePropertyRow apRow in apRows)
            {
                SOARolePropertyRow newRow = new SOARolePropertyRow(amRows.Role);

                newRow.RowNumber = ++maxRowNumber;
                newRow.OperatorType = apRow.OperatorType;
                newRow.Operator = apRow.Operator;

                foreach (SOARolePropertyValue srv in apRow.Values)
                {
                    if (amDefinitions.ContainsKey(srv.Column.Name))
                    {
                        SOARolePropertyValue newValue = new SOARolePropertyValue(amDefinitions[srv.Column.Name]);

                        newValue.Value = srv.Value;

                        newRow.Values.Add(newValue);
                    }
                }
            }
        }
        public static WfCreateActivityParam FromRowUsers(SOARolePropertyRowUsers rowUsers, SOARolePropertyDefinitionCollection definitions, PropertyDefineCollection definedProperties)
        {
            rowUsers.NullCheck("rowUsers");
            definitions.NullCheck("definitions");
            definedProperties.NullCheck("definedProperties");

            WfCreateActivityParam cap = new WfCreateActivityParam();

            cap.Source = rowUsers.Row;

            string strActivitySN = rowUsers.Row.Values.GetValue(SOARolePropertyDefinition.ActivitySNColumn, "0");

            int activitySN = 0;

            int.TryParse(strActivitySN, out activitySN).FalseThrow("不能将值为{0}的ActivitySN转换为整数", strActivitySN);

            cap.ActivitySN = activitySN;
            cap.Template.Properties.MergeDefinedProperties(definedProperties);

            InitActivityTemplateProperties(cap, definitions, rowUsers.Row);

            rowUsers.Users.ForEach(u => cap.Template.Resources.Add(new WfUserResourceDescriptor(u)));
            rowUsers.EnterNotifyUsers.ForEach(u => cap.Template.EnterEventReceivers.Add(new WfUserResourceDescriptor(u)));
            rowUsers.LeaveNotifyUsers.ForEach(u => cap.Template.LeaveEventReceivers.Add(new WfUserResourceDescriptor(u)));

            return(cap);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 将活动矩阵与审批矩阵进行合并,以第一个矩阵的列定义为准
        /// </summary>
        /// <param name="amRows"></param>
        /// <param name="amDefinitions"></param>
        /// <param name="apRows"></param>
        /// <param name="apDefinitions"></param>
        public static void MergeActivityMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable <SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        {
            amDefinitions.NullCheck("amDefinitions");
            amRows.NullCheck("amRows");
            apDefinitions.NullCheck("apDefinitions");
            apRows.NullCheck("apRows");

            int maxRowNumber = GetMaxRowNumber(amRows);

            foreach (SOARolePropertyRow apRow in apRows)
            {
                SOARolePropertyRow newRow = new SOARolePropertyRow(amRows.Role);

                newRow.RowNumber    = ++maxRowNumber;
                newRow.OperatorType = apRow.OperatorType;
                newRow.Operator     = apRow.Operator;

                foreach (SOARolePropertyValue srv in apRow.Values)
                {
                    if (amDefinitions.ContainsKey(srv.Column.Name))
                    {
                        SOARolePropertyValue newValue = new SOARolePropertyValue(amDefinitions[srv.Column.Name]);

                        newValue.Value = srv.Value;

                        newRow.Values.Add(newValue);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static SOARoleContext CreateContext(SOARolePropertyDefinitionCollection propertyDefines, IWfProcess process)
        {
            propertyDefines.NullCheck("propertyDefines");

            SOARolePropertiesQueryParamCollection queryParams = CreateQueryParams(propertyDefines, process);

            SOARoleContext context = SOARoleContext.CreateContext(queryParams, process);

            context.PropertyDefinitions = propertyDefines;

            return context;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 将活动矩阵与审批矩阵进行合并
        /// </summary>
        /// <param name="amRows"></param>
        /// <param name="amDefinitions"></param>
        /// <param name="apRows"></param>
        /// <param name="apDefinitions"></param>
        public static void MergeApprovalMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable <SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        {
            amDefinitions.NullCheck("amDefinitions");
            amRows.NullCheck("amRows");
            apDefinitions.NullCheck("apDefinitions");
            apRows.NullCheck("apRows");

            int maxActivitySN = GetMaxActivitySN(amRows);
            int maxRowNumber  = GetMaxRowNumber(amRows);

            List <SOARolePropertyRow> newAmRows = new List <SOARolePropertyRow>();

            foreach (SOARolePropertyRow apRow in apRows)
            {
                int columnIndex = 1;

                while (columnIndex < apDefinitions.Count)
                {
                    List <SOARolePropertyRow> amUserRows     = FindMatchedActivityMatrixUserRows(amRows, apDefinitions[columnIndex].Name, apRow);
                    List <SOARolePropertyRow> amTemplateRows = FindMatchedActivityMatrixTemplateRows(amRows, apDefinitions[columnIndex].Name, apRow);

                    string apUser = apRow.Values.GetValue(apDefinitions[columnIndex].Name, string.Empty);

                    if (amUserRows.Count == 0 && apUser.IsNotEmpty())
                    {
                        SOARolePropertyRow templateRow = amTemplateRows.LastOrDefault();

                        maxActivitySN += 10;
                        SOARolePropertyRow amRow = CreateNewActivityMatrixRow(maxActivitySN, ++maxRowNumber, amDefinitions, templateRow);

                        newAmRows.Add(amRow);

                        MergeToActivityMatrixRow(amRow, amDefinitions, apUser);
                    }
                    else
                    {
                        foreach (SOARolePropertyRow amRow in amUserRows)
                        {
                            MergeToActivityMatrixRow(amRow, amDefinitions, apUser);
                        }
                    }

                    columnIndex++;
                }
            }

            amRows.CopyFrom(newAmRows);
        }
Ejemplo n.º 6
0
        public SOARolePropertyValue ClientToServer(WfClientRolePropertyValue client, SOARolePropertyDefinitionCollection serverColumns, ref SOARolePropertyValue server)
        {
            client.NullCheck("client");
            serverColumns.NullCheck("serverColumns");

            if (server == null)
            {
                SOARolePropertyDefinition serverColumn = serverColumns[client.Column.Name];

                serverColumn.NullCheck("serverColumn");

                server = new SOARolePropertyValue(serverColumn);
            }

            server.Value = client.Value;

            return(server);
        }
		public SOARolePropertyValue ClientToServer(WfClientRolePropertyValue client, SOARolePropertyDefinitionCollection serverColumns, ref SOARolePropertyValue server)
		{
			client.NullCheck("client");
			serverColumns.NullCheck("serverColumns");

			if (server == null)
			{
				SOARolePropertyDefinition serverColumn = serverColumns[client.Column.Name];

				serverColumn.NullCheck("serverColumn");

				server = new SOARolePropertyValue(serverColumn);
			}

			server.Value = client.Value;

			return server;
		}
        public void Update(string roleID, SOARolePropertyDefinitionCollection properties)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            properties.NullCheck("properties");

            StringBuilder strB = new StringBuilder();

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_DEFINITIONS WHERE {0}", roleID.ToRoleIDCriteria());

            foreach (SOARolePropertyDefinition property in properties)
            {
                if (strB.Length > 0)
                    strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

                property.RoleID = roleID;

                strB.AppendFormat(ORMapping.GetInsertSql(property, TSqlBuilder.Instance));
            }

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                DbHelper.RunSql(strB.ToString(), GetConnectionName());

                scope.Complete();
            }

            string cacheKey = roleID.ToRoleIDCacheKey();

            CacheNotifyData notifyData1 = new CacheNotifyData(typeof(SOARolePropertiesDefinitionCache), cacheKey, CacheNotifyType.Invalid);
            CacheNotifyData notifyData2 = new CacheNotifyData(typeof(SOARolePropertiesCache), cacheKey, CacheNotifyType.Invalid);

            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData1, notifyData2);
            MmfCacheNotifier.Instance.SendNotify(notifyData1, notifyData2);
        }
        public void Update(IRole role, SOARolePropertyDefinitionCollection properties)
        {
            role.NullCheck("role");
            properties.NullCheck("properties");

            this.Update(role.ID, properties);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 将活动矩阵与审批矩阵进行合并
        /// </summary>
        /// <param name="amRows"></param>
        /// <param name="amDefinitions"></param>
        /// <param name="apRows"></param>
        /// <param name="apDefinitions"></param>
        public static void MergeApprovalMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable<SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        {
            amDefinitions.NullCheck("amDefinitions");
            amRows.NullCheck("amRows");
            apDefinitions.NullCheck("apDefinitions");
            apRows.NullCheck("apRows");

            int maxActivitySN = GetMaxActivitySN(amRows);
            int maxRowNumber = GetMaxRowNumber(amRows);

            List<SOARolePropertyRow> newAmRows = new List<SOARolePropertyRow>();

            foreach (SOARolePropertyRow apRow in apRows)
            {
                int columnIndex = 1;

                while (columnIndex < apDefinitions.Count)
                {
                    List<SOARolePropertyRow> amUserRows = FindMatchedActivityMatrixUserRows(amRows, apDefinitions[columnIndex].Name, apRow);
                    List<SOARolePropertyRow> amTemplateRows = FindMatchedActivityMatrixTemplateRows(amRows, apDefinitions[columnIndex].Name, apRow);

                    string apUser = apRow.Values.GetValue(apDefinitions[columnIndex].Name, string.Empty);

                    if (amUserRows.Count == 0 && apUser.IsNotEmpty())
                    {
                        SOARolePropertyRow templateRow = amTemplateRows.LastOrDefault();

                        maxActivitySN += 10;
                        SOARolePropertyRow amRow = CreateNewActivityMatrixRow(maxActivitySN, ++maxRowNumber, amDefinitions, templateRow);

                        newAmRows.Add(amRow);

                        MergeToActivityMatrixRow(amRow, amDefinitions, apUser);
                    }
                    else
                    {
                        foreach (SOARolePropertyRow amRow in amUserRows)
                            MergeToActivityMatrixRow(amRow, amDefinitions, apUser);
                    }

                    columnIndex++;
                }
            }

            amRows.CopyFrom(newAmRows);
        }
        /// <summary>
        /// 根据RoleID加载行信息
        /// </summary>
        /// <param name="roleID"></param>
        /// <param name="role"></param>
        /// <param name="definition">列定义</param>
        /// <returns></returns>
        public SOARolePropertyRowCollection LoadByRoleID(string roleID, IRole role, SOARolePropertyDefinitionCollection definition)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            definition.NullCheck("definition");

            StringBuilder strB = new StringBuilder();

            strB.AppendFormat("SELECT * FROM WF.ROLE_PROPERTIES_ROWS WHERE {0} ORDER BY ROW_NUMBER", roleID.ToRoleIDCriteria());

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

            strB.AppendFormat("SELECT * FROM WF.ROLE_PROPERTIES_CELLS WHERE {0} ORDER BY PROPERTIES_ROW_ID", roleID.ToRoleIDCriteria());

            SOARolePropertyRowCollection result = new SOARolePropertyRowCollection(role);

            using (TransactionScope scope = TransactionScopeFactory.Create(TransactionScopeOption.Suppress))
            {
                DataSet ds = DbHelper.RunSqlReturnDS(strB.ToString(), GetConnectionName());
                Dictionary<int, SOARolePropertyValueCollection> propertyValues = SOARolePropertyValueCollection.LoadAndGroup(ds.Tables[1].DefaultView, definition);

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    SOARolePropertyRow property = new SOARolePropertyRow(role);

                    ORMapping.DataRowToObject(row, property);

                    SOARolePropertyValueCollection values = null;

                    if (propertyValues.TryGetValue(property.RowNumber, out values))
                        property.Values.CopyFrom(values);

                    result.Add(property);
                }
            }

            return result;
        }