/// <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); } } } }
private static void AppendOperator(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string apUser) { string columnName = SOARolePropertyDefinition.OperatorColumn; if (columns.ContainsKey(columnName)) { SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName); if (pValue == null) { pValue = new SOARolePropertyValue(columns[columnName]); row.Values.Add(pValue); } if (apUser.IsNotEmpty()) { pValue.Value = pValue.Value.NullOrEmptyIs(row.Operator); if (pValue.Value.IsNotEmpty()) { pValue.Value += ","; } else { pValue.Value = string.Empty; } pValue.Value += apUser; row.Operator = pValue.Value; } } }
private static object GetDataValueByBookmark(DefinedName bookmark, SOARolePropertyRow row) { object result = null; SOARolePropertyValue propertyValue = row.Values.FindByColumnName(bookmark.Name); if (propertyValue != null) { if (propertyValue.Column.DataType != ColumnDataType.String) { result = DataConverter.ChangeType(typeof(string), propertyValue.Value, propertyValue.Column.RealDataType); } else { result = propertyValue.Value; } } else { switch (bookmark.Name.ToLower()) { case "operatortype": result = row.OperatorType.ToString(); break; case "operator": result = row.Operator; break; } } return(result); }
/// <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 override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer) { string columnName = dictionary.GetValue("columnName", string.Empty); SOARolePropertyValue pv = new SOARolePropertyValue(new SOARolePropertyDefinition() { Name = columnName }); pv.Value = dictionary.GetValue("value", string.Empty); return pv; }
public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); SOARolePropertyValue pv = (SOARolePropertyValue)obj; DictionaryHelper.AddNonDefaultValue(dictionary, "columnName", pv.Column.Name); DictionaryHelper.AddNonDefaultValue(dictionary, "value", pv.Value); return(dictionary); }
private void Save(Stream strem) { DataTable dt = DocumentHelper.GetRangeValuesAsTable(strem, "Matrix", "A3"); string[] itemsInfo = this.MCRolePropertyEditTemplate.RequestContext.Split(';'); string roleID = itemsInfo[1]; string defID = itemsInfo[2]; SOARole role = PrepareRole(roleID, defID); role.Rows.Clear(); int rowIndex = 0; foreach (DataRow row in dt.Rows) { SOARolePropertyRow mRow = new SOARolePropertyRow(role) { RowNumber = rowIndex }; foreach (var dimension in role.PropertyDefinitions) { SOARolePropertyValue mCell = new SOARolePropertyValue(dimension); mCell.Value = row[dimension.Name].ToString(); switch (dimension.Name) { case "Operator": mRow.Operator = row[dimension.Name].ToString(); break; case "OperatorType": SOARoleOperatorType opType = SOARoleOperatorType.User; Enum.TryParse(row[dimension.Name].ToString(), out opType); mRow.OperatorType = opType; break; default: break; } mRow.Values.Add(mCell); } rowIndex++; role.Rows.Add(mRow); } //更新数据库 SOARolePropertiesAdapter.Instance.Update(role); }
public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { string columnName = dictionary.GetValue("columnName", string.Empty); SOARolePropertyValue pv = new SOARolePropertyValue(new SOARolePropertyDefinition() { Name = columnName }); pv.Value = dictionary.GetValue("value", string.Empty); return(pv); }
private static void SetCellValue(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string columnName, string cellValue) { if (columns.ContainsKey(columnName)) { SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName); if (pValue == null) { pValue = new SOARolePropertyValue(columns[columnName]); row.Values.Add(pValue); } pValue.Value = cellValue; } }
private SOARolePropertyRow GenerateMatrixRow(SOARole role, RowNode rowNode, NamedLocationCollection locations, int index) { SOARolePropertyRow mRow = new SOARolePropertyRow(role); mRow.RowNumber = index; int emptyCellCount = 0; foreach (var row in this.Definition) { CellLocation location = locations[row.Name]; CellNode cell = rowNode.GetCellByIndex(location.Column); SOARolePropertyValue mCell = new SOARolePropertyValue(row); mCell.Value = cell.Data.InnerText.Trim(); mRow.Values.Add(mCell); switch (row.Name) { case "Operator": mRow.Operator = cell.Data.InnerText; break; case "OperatorType": SOARoleOperatorType opType = SOARoleOperatorType.User; Enum.TryParse(cell.Data.InnerText, out opType); mRow.OperatorType = opType; break; default: if (mCell.Value.IsNullOrEmpty()) { emptyCellCount++; } break; } } role.Rows.Add(mRow); return(mRow); }
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 WfClientRolePropertyValue ServerToClient(SOARolePropertyValue server, WfClientRolePropertyDefinitionCollection clientColumns, ref WfClientRolePropertyValue client) { server.NullCheck("server"); clientColumns.NullCheck("clientColumns"); if (client == null) { WfClientRolePropertyDefinition clientColumn = clientColumns[server.Column.Name]; clientColumn.NullCheck("clientColumn"); client = new WfClientRolePropertyValue(clientColumn); } client.Value = server.Value; return(client); }
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 WfClientRolePropertyValue ServerToClient(SOARolePropertyValue server, WfClientRolePropertyDefinitionCollection clientColumns, ref WfClientRolePropertyValue client) { server.NullCheck("server"); clientColumns.NullCheck("clientColumns"); if (client == null) { WfClientRolePropertyDefinition clientColumn = clientColumns[server.Column.Name]; clientColumn.NullCheck("clientColumn"); client = new WfClientRolePropertyValue(clientColumn); } client.Value = server.Value; return client; }
public SOARolePropertyRow ClientToServer(WfClientRolePropertyRow client, SOARolePropertyDefinitionCollection serverColumns, ref SOARolePropertyRow server) { client.NullCheck("client"); if (server == null) { server = new SOARolePropertyRow(); } server.RowNumber = client.RowNumber; server.Operator = client.Operator; server.OperatorType = client.OperatorType.ToRoleOperatorType(); foreach (WfClientRolePropertyValue cpv in client.Values) { SOARolePropertyValue spv = null; WfClientRolePropertyValueConverter.Instance.ClientToServer(cpv, serverColumns, ref spv); server.Values.Add(spv); } return(server); }
private SOARolePropertyRow GenerateMatrixRow(SOARole role, RowNode rowNode, NamedLocationCollection locations, int index) { SOARolePropertyRow mRow = new SOARolePropertyRow(role); mRow.RowNumber = index; int emptyCellCount = 0; foreach (var row in this.Definition) { CellLocation location = locations[row.Name]; CellNode cell = rowNode.GetCellByIndex(location.Column); SOARolePropertyValue mCell = new SOARolePropertyValue(row); mCell.Value = cell.Data.InnerText.Trim(); mRow.Values.Add(mCell); switch (row.Name) { case "Operator": mRow.Operator = cell.Data.InnerText; break; case "OperatorType": SOARoleOperatorType opType = SOARoleOperatorType.User; Enum.TryParse(cell.Data.InnerText, out opType); mRow.OperatorType = opType; break; default: if (mCell.Value.IsNullOrEmpty()) emptyCellCount++; break; } } role.Rows.Add(mRow); return mRow; }
/// <summary> /// 导入Open Xml格式的文件 /// </summary> /// <param name="importStream"></param> /// <param name="notifier"></param> private void ImportFromExcel2007(Stream importStream, Action notifier) { WorkBook workbook = WorkBook.Load(importStream); SOARole role = null; ServiceBrokerContext.Current.SaveContextStates(); try { ServiceBrokerContext.Current.UseLocalCache = false; ServiceBrokerContext.Current.UseServerCache = false; if (this.AppCodeName.IsNotEmpty() && this.RoleCodeName.IsNotEmpty()) role = new SOARole(this.AppCodeName + ":" + this.RoleCodeName); else role = new SOARole(this.Definition) { ID = RoleID }; if (NeedValidateSource) CheckImportSource(role, workbook); DataTable dt = DocumentHelper.GetRangeValuesAsTable(workbook, "Matrix", "A3"); role.Rows.Clear(); int rowIndex = 0; foreach (DataRow row in dt.Rows) { SOARolePropertyRow mRow = new SOARolePropertyRow(role) { RowNumber = rowIndex }; foreach (var dimension in this.Definition) { SOARolePropertyValue mCell = new SOARolePropertyValue(dimension); mCell.Value = row[dimension.Name].ToString(); switch (dimension.Name) { case "Operator": mRow.Operator = row[dimension.Name].ToString(); break; case "OperatorType": SOARoleOperatorType opType = SOARoleOperatorType.User; Enum.TryParse(row[dimension.Name].ToString(), out opType); mRow.OperatorType = opType; break; default: break; } mRow.Values.Add(mCell); } if (notifier != null) { notifier(); } rowIndex++; role.Rows.Add(mRow); } //插入记录 SOARolePropertiesAdapter.Instance.Update(role); } finally { ServiceBrokerContext.Current.RestoreSavedStates(); } }
private void Save(Stream strem) { DataTable dt = DocumentHelper.GetRangeValuesAsTable(strem, "Matrix", "A3"); string[] itemsInfo = this.materialCtrlForMatrix.RequestContext.Split(';'); string roleID = itemsInfo[1]; string defID = itemsInfo[2]; SOARole role = PrepareRole(roleID, defID); role.Rows.Clear(); int rowIndex = 0; foreach (DataRow row in dt.Rows) { SOARolePropertyRow mRow = new SOARolePropertyRow(role) { RowNumber = rowIndex }; foreach (var dimension in role.PropertyDefinitions) { SOARolePropertyValue mCell = new SOARolePropertyValue(dimension); mCell.Value = row[dimension.Name].ToString(); switch (dimension.Name) { case "Operator": mRow.Operator = row[dimension.Name].ToString(); break; case "OperatorType": SOARoleOperatorType opType = SOARoleOperatorType.User; Enum.TryParse(row[dimension.Name].ToString(), out opType); mRow.OperatorType = opType; break; default: break; } mRow.Values.Add(mCell); } rowIndex++; role.Rows.Add(mRow); } //更新数据库 SOARolePropertiesAdapter.Instance.Update(role); }
/// <summary> /// 导入Open Xml格式的文件 /// </summary> /// <param name="importStream"></param> /// <param name="notifier"></param> private void ImportFromExcel2007(Stream importStream, Action notifier) { WorkBook workbook = WorkBook.Load(importStream); SOARole role = null; ServiceBrokerContext.Current.SaveContextStates(); try { ServiceBrokerContext.Current.UseLocalCache = false; ServiceBrokerContext.Current.UseServerCache = false; if (this.AppCodeName.IsNotEmpty() && this.RoleCodeName.IsNotEmpty()) { role = new SOARole(this.AppCodeName + ":" + this.RoleCodeName); } else { role = new SOARole(this.Definition) { ID = RoleID } }; if (NeedValidateSource) { CheckImportSource(role, workbook); } DataTable dt = DocumentHelper.GetRangeValuesAsTable(workbook, "Matrix", "A3"); role.Rows.Clear(); int rowIndex = 0; foreach (DataRow row in dt.Rows) { SOARolePropertyRow mRow = new SOARolePropertyRow(role) { RowNumber = rowIndex }; foreach (var dimension in this.Definition) { SOARolePropertyValue mCell = new SOARolePropertyValue(dimension); mCell.Value = row[dimension.Name].ToString(); switch (dimension.Name) { case "Operator": mRow.Operator = row[dimension.Name].ToString(); break; case "OperatorType": SOARoleOperatorType opType = SOARoleOperatorType.User; Enum.TryParse(row[dimension.Name].ToString(), out opType); mRow.OperatorType = opType; break; default: break; } mRow.Values.Add(mCell); } if (notifier != null) { notifier(); } rowIndex++; role.Rows.Add(mRow); } //插入记录 SOARolePropertiesAdapter.Instance.Update(role); } finally { ServiceBrokerContext.Current.RestoreSavedStates(); } }
//导出带数据的Excel private static void FillMatrixRowsToWorksheet(WorkbookNode workbook, SOARolePropertyRowCollection rows) { NamedLocationCollection locations = workbook.Names.ToLocations(); locations.SortByColumn(); WorksheetNode worksheet = workbook.Worksheets[GetWorksheet(locations)]; int startRowIndex = GetStartRow(locations); int currentRowIndex = -1; foreach (SOARolePropertyRow matrixRow in rows) { RowNode row = new RowNode(); if (currentRowIndex == -1) { currentRowIndex = startRowIndex + 1; row.Index = currentRowIndex; } for (int i = 0; i < locations.Count; i++) { CellNode cell = new CellNode(); CellLocation location = locations[i]; SOARolePropertyValue propertyValue = matrixRow.Values.FindByColumnName(location.Name); string dataValue = null; if (propertyValue != null) { dataValue = propertyValue.Value; } else { switch (location.Name.ToLower()) { case "operatortype": dataValue = matrixRow.OperatorType.ToString(); break; case "operator": dataValue = matrixRow.Operator; break; } } if (dataValue != null) { cell.Data.Value = dataValue; } else { cell.Data.Value = string.Empty; } row.Cells.Add(cell); } worksheet.Table.Rows.Add(row); } }
private static void AppendOperator(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string apUser) { string columnName = SOARolePropertyDefinition.OperatorColumn; if (columns.ContainsKey(columnName)) { SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName); if (pValue == null) { pValue = new SOARolePropertyValue(columns[columnName]); row.Values.Add(pValue); } if (apUser.IsNotEmpty()) { pValue.Value = pValue.Value.NullOrEmptyIs(row.Operator); if (pValue.Value.IsNotEmpty()) pValue.Value += ","; else pValue.Value = string.Empty; pValue.Value += apUser; row.Operator = pValue.Value; } } }
private static void SetCellValue(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string columnName, string cellValue) { if (columns.ContainsKey(columnName)) { SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName); if (pValue == null) { pValue = new SOARolePropertyValue(columns[columnName]); row.Values.Add(pValue); } pValue.Value = cellValue; } }
private static string PrepareValueSql(string roleID, SOARolePropertyRow row, SOARolePropertyValue propValue) { InsertSqlClauseBuilder builder = ORMapping.GetInsertSqlClauseBuilder(propValue); builder.AppendItem("ROLE_ID", roleID); builder.AppendItem("PROPERTIES_ROW_ID", row.RowNumber); builder.AppendItem("PROPERTY_NAME", propValue.Column.Name); return "INSERT INTO WF.ROLE_PROPERTIES_CELLS" + builder.ToSqlString(TSqlBuilder.Instance); }