private void DeleteMatrix() { WfMatrix matrix = WfMatrixAdapter.Instance.LoadByProcessKey(ProcessKey, false); matrix.Rows.Clear(); WfMatrixAdapter.Instance.Update(matrix); }
private void ExportMatrixData() { WfMatrix matrix = WfMatrixAdapter.Instance.Load(this.ExportKey); matrix.Loaded = true; switch (this.ExFormat) { case ExportFormat.Xlsx: Response.Clear(); Response.ClearHeaders(); using (MemoryStream fileSteam = matrix.ExportToExcel2007(this.RoleAsPerson)) { fileSteam.CopyTo(Response.OutputStream); } //Response.BinaryWrite(bytes); //Response.ContentType = MediaTypeNames.Text.Xml; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AppendHeader("CONTENT-DISPOSITION", "attachment;filename=" + matrix.ProcessKey + ".xlsx"); Response.Flush(); Response.End(); break; case ExportFormat.Xml: WorkbookNode workbook = matrix.ExportToExcelXml(this.RoleAsPerson); workbook.Response(matrix.ProcessKey); break; } }
protected void btnSaveMatrix_Click(object sender, EventArgs e) { int count = this.materialCtrlForMatrix.Materials.Count; if (count > 0 && !this.materialCtrlForMatrix.DeltaMaterials.IsEmpty()) { Material keyTerial = null; if (this.materialCtrlForMatrix.DeltaMaterials.Inserted.Count > 0) { keyTerial = this.materialCtrlForMatrix.DeltaMaterials.Inserted[this.materialCtrlForMatrix.DeltaMaterials.Inserted.Count - 1]; } else if (this.materialCtrlForMatrix.DeltaMaterials.Updated.Count > 0) { keyTerial = this.materialCtrlForMatrix.DeltaMaterials.Updated[this.materialCtrlForMatrix.DeltaMaterials.Updated.Count - 1]; } if (keyTerial != null) { string[] itemsInfio = this.materialCtrlForMatrix.RequestContext.Split(';'); string processKey = itemsInfio[2]; using (Stream LoadFile = keyTerial.GetTemporaryContent(this.materialCtrlForMatrix.RootPathName)) { WfMatrix.ImportExistMatrixFromExcel2007(LoadFile, null, processKey); } } } }
protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result) { ExceptionHelper.FalseThrow(Path.GetExtension(file.FileName).ToLower() == ".xml", "'{0}'权限矩阵必须是xml电子表格", file.FileName); UploadProgressStatus status = new UploadProgressStatus(); status.CurrentStep = 1; status.MinStep = 0; status.MaxStep = 20; WfMatrix.ImportExistMatrixFromExcelXml(file.InputStream, () => { if (status.CurrentStep + 1 < status.MaxStep) { status.CurrentStep++; } status.Response(); }, Request["processkey"]); status.MaxStep = 20; status.Response(); string logInfo = string.Format("导入完成"); PrepareResultInfo(result, logInfo); }
protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result) { var fileType = Path.GetExtension(file.FileName).ToLower(); if (fileType != ".xml" && fileType != ".xlsx") { throw new Exception("'{0}' must be a xml or xlsx file."); } UploadProgressStatus status = new UploadProgressStatus(); status.CurrentStep = 1; status.MinStep = 0; status.MaxStep = 20; Action notifier = () => { if (status.CurrentStep + 1 < status.MaxStep) { status.CurrentStep++; } status.Response(); }; if (fileType == ".xml") { WfMatrix.ImportExistMatrixFromExcelXml(file.InputStream, notifier, ProcessKey); } else if (fileType == ".xlsx") { WfMatrix.ImportExistMatrixFromExcel2007(file.InputStream, notifier, ProcessKey); } result.DataChanged = true; result.CloseWindow = true; }
private void RenderByMatrix(WfMatrix matrix) { if (matrix != null) { noMartrixInfoContainer.Visible = false; martrixInfoContainer.Visible = true; exportBtn.Disabled = false; importBtn.Disabled = false; btnDeleteMatrix.Disabled = false; //editBtn.Disabled = false; matrixID.Value = matrix.MatrixID; processKey.Value = matrix.ProcessKey; matrixInfo.InnerText = string.Format("当前权限矩阵定义为\"{0}({1})\"。点击这里", matrix.Definition.Name, matrix.Definition.Key); materialCtrlContainer.Style["display"] = "block"; this.materialCtrlForMatrix.RequestContext = matrixID.Value + ";" + chkRoleAsPerson.Checked + ";" + processKey.Value + ";"; } else { noMartrixInfoContainer.Visible = true; martrixInfoContainer.Visible = false; exportBtn.Disabled = true; importBtn.Disabled = true; btnDeleteMatrix.Disabled = true; //editBtn.Disabled = true; matrixID.Value = string.Empty; processKey.Value = string.Empty; materialCtrlContainer.Style["display"] = "none"; } }
public int DisplaceUserInProcessMatrix(string processDespKey, string userID, string[] displacingUserIDArray) { WfMatrix matrix = WfMatrixAdapter.Instance.LoadByProcessKey(processDespKey, true); IUser originalUser = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userID).FirstOrDefault(); OguObjectCollection <IUser> displacingUsers = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, displacingUserIDArray); string originalUserCodeName = originalUser != null ? originalUser.LogOnName : string.Empty; List <string> desplacingUserCodeNames = new List <string>(); foreach (IUser user in displacingUsers) { if (desplacingUserCodeNames.Contains(user.LogOnName) == false) { desplacingUserCodeNames.Add(user.LogOnName); } } int result = matrix.Rows.ReplcaeOperators(WfMatrixOperatorType.Person, originalUserCodeName, desplacingUserCodeNames.ToArray()); using (TransactionScope scope = TransactionScopeFactory.Create()) { WfMatrixAdapter.Instance.Update(matrix); scope.Complete(); } return(result); }
protected void bindMatrixBtn_Click(object sender, EventArgs e) { try { string mdKey = selectedMatrix.Value; WfMatrixDefinition md = WfMatrixDefinitionAdapter.Instance.Load(mdKey); WfMatrix matrix = new WfMatrix(md); matrix.MatrixID = UuidHelper.NewUuidString(); matrix.ProcessKey = ProcessKey; if (DeluxePrincipal.IsAuthenticated) { matrix.CreatorID = DeluxeIdentity.CurrentUser.ID; matrix.CreatorName = DeluxeIdentity.CurrentUser.DisplayName; } WfMatrixAdapter.Instance.Update(matrix); } catch (System.Exception ex) { WebUtility.ShowClientError(ex.Message, ex.StackTrace, "错误"); } }
public void Setup() { WfMatrixAdapter.Instance.ClearAll(); WfMatrixDefinitionAdapter.Instance.ClearAll(); _wfMatrixInstance = BuildWfMatrix(); _isWfMatrixDefExist = CheckWfMatrixDef(_wfMatrixInstance.Definition.Key); }
protected void generateMatrixButton_Click(object sender, EventArgs e) { WfMatrix matrix = CreateMatrix(); WorkbookNode workbook = matrix.ExportToExcelXml(false); workbook.Response("Matrix"); }
public void Setup() { WfMatrixAdapter.Instance.ClearAll(); WfMatrixDefinitionAdapter.Instance.ClearAll(); _wfMatrixInstance = BuildWfMatrix(); _isWfMatrixDefExist = WfMatrixDefinitionAdapterTest.CheckWfMatrixDef(_wfMatrixInstance.Definition.Key); }
private void SaveMatrix() { foreach (var part in MatrixParts) { var partMapInfo = this.MappingInfo[part.Uri.ToString()]; var matrixDef = this.MatrixDefinitions[partMapInfo.MatrixDefID]; WfMatrix.ImportNewMatrixFromExcel2007(part.GetStream(), null, partMapInfo.ProcessDescriptionID, matrixDef); } }
private static void SaveMatrix(WfProcessImporterContext context) { foreach (var part in context.MatrixParts) { WfPackageRelationMapping partMapInfo = context.MappingInfo[part.Uri.ToString()]; WfMatrixDefinition matrixDef = context.MatrixDefinitions[partMapInfo.MatrixDefID]; WfMatrix.ImportNewMatrixFromExcel2007(part.GetStream(), null, partMapInfo.ProcessDescriptionID, matrixDef); } }
private static WfMatrix CreateMatrix() { WfMatrix matrix = new WfMatrix(CreateMatrixDefinition()); AddMatrixRow(matrix, "1001", "0"); AddMatrixRow(matrix, "1002", "1"); AddMatrixRow(matrix, "1001", "0"); AddMatrixRow(matrix, "1002", "1"); return matrix; }
private static WfMatrix CreateMatrix() { WfMatrix matrix = new WfMatrix(CreateMatrixDefinition()); AddMatrixRow(matrix, "1001", "0"); AddMatrixRow(matrix, "1002", "1"); AddMatrixRow(matrix, "1001", "0"); AddMatrixRow(matrix, "1002", "1"); return(matrix); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); string processKey = ProcessKey; if (processKey.IsNotEmpty()) { WfMatrix matrix = WfMatrixAdapter.Instance.LoadByProcessKey(processKey, false); RenderByMatrix(matrix); } }
public void ReplaceTest() { _wfMatrixInstance.Rows.ReplcaeOperators(WfMatrixOperatorType.Person, "fanhy", "liming"); WfMatrixAdapter.Instance.Update(_wfMatrixInstance); WfMatrix loadMatrix = WfMatrixAdapter.Instance.Load(_wfMatrixInstance.MatrixID); foreach (WfMatrixRow row in loadMatrix.Rows) { Assert.AreEqual(-1, row.Operator.IndexOf("fanhy")); } }
protected void btnConfirm_Click(object sender, EventArgs e) { var keys = MatrixDefDeluxeGrid.SelectedKeys; List <string> validKeys = new List <string>(); List <string> invalidKeys = new List <string>(); try { foreach (var item in keys) { WfMatrix matrix = null; try { matrix = WfMatrixAdapter.Instance.Load(item); } catch (Exception) { } if (matrix == null) { validKeys.Add(item); } else { invalidKeys.Add(item); } } WfMatrixDefinitionAdapter.Instance.Delete(validKeys.ToArray()); LastQueryRowCount = -1; if (invalidKeys.Count != 0) { string strInvalidKeys = string.Join(",", invalidKeys.ToArray()); string strProcessMapMatrix = string.Empty; Page.ClientScript.RegisterStartupScript(this.GetType(), "undeleteMatrix", string.Format("alert('Key为[{0}]的矩阵定义无法删除,因为已经有流程模板在使用此矩阵。');", strInvalidKeys), true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "deleteMatrix", string.Format("alert('删除成功!');"), true); } } catch (Exception ex) { WebUtility.ShowClientError(ex.Message, ex.StackTrace, "错误"); } }
protected void materialCtrl_PrepareDownloadStream(object sender, PrepareDownloadStreamEventArgs args) { bool roleAsPerson = false; string[] itemsInfio = args.DownloadInfo.RequestContext.Split(';'); Boolean.TryParse(itemsInfio[1], out roleAsPerson); string downloadkey = itemsInfio[0]; WfMatrix matrix = WfMatrixAdapter.Instance.Load(downloadkey); matrix.Loaded = true; using (MemoryStream excelStream = matrix.ExportToExcel2007(roleAsPerson)) { excelStream.CopyTo(args.OutputStream); } }
public WfMatrix BuildWfMatrix() { var matrixDef = BuildNewMatrixDef(_matrixColumnNum); WfMatrix matrixInstance = new WfMatrix(matrixDef) { CreatorID = "testCreatorID1", CreatorName = "testCreatorName1", MatrixID = UuidHelper.NewUuidString(), ProcessKey = "testProcessKey", ActivityKey = "testActivityKey" }; for (int i = 0; i < _matrixRowNum; i++) { var row = new WfMatrixRow() { RowNumber = i, OperatorType = WfMatrixOperatorType.Person, Operator = "wanhw" }; if (i % 2 == 0) { row.Operator = "fanhy"; } for (int j = 0; j < matrixDef.Dimensions.Count; j++) { row.Cells.Add(new WfMatrixCell(matrixDef.Dimensions[j]) { StringValue = "String" + j.ToString() }); } matrixInstance.Rows.Add(row); } return(matrixInstance); }
private static WfMatrixRow AddMatrixRow(WfMatrix matrix, params string[] values) { WfMatrixRow row = new WfMatrixRow(matrix); row.RowNumber = matrix.Rows.Count; for (int i = 0; i < matrix.Definition.Dimensions.Count; i++) { WfMatrixDimensionDefinition dd = matrix.Definition.Dimensions[i]; WfMatrixCell cell = new WfMatrixCell(dd); if (i < values.Length) cell.StringValue = values[i]; row.Cells.Add(cell); } matrix.Rows.Add(row); return row; }
private static WfMatrixRow AddMatrixRow(WfMatrix matrix, params string[] values) { WfMatrixRow row = new WfMatrixRow(matrix); row.RowNumber = matrix.Rows.Count; for (int i = 0; i < matrix.Definition.Dimensions.Count; i++) { WfMatrixDimensionDefinition dd = matrix.Definition.Dimensions[i]; WfMatrixCell cell = new WfMatrixCell(dd); if (i < values.Length) { cell.StringValue = values[i]; } row.Cells.Add(cell); } matrix.Rows.Add(row); return(row); }
private WfMatrixRowCollection FilterRowsByActivity(WfMatrix matrix) { WfMatrixRowCollection result = new WfMatrixRowCollection(); if (matrix.Definition.Dimensions.ContainsKey("ActivityKey")) { foreach (WfMatrixRow row in matrix.Rows) { if (string.Compare(row.Cells.GetValue("ActivityKey", string.Empty), this.Descriptor.Key, true) == 0) { result.Add(row); } } } return result; }
private bool IsApplicationParametersAvailableForMatrix(WfMatrix matrix) { bool result = true; foreach (WfMatrixDimensionDefinition dd in matrix.Definition.Dimensions) { if (dd.DimensionKey != "OperatorType" && dd.DimensionKey != "Operator" && dd.DimensionKey != "ProcessKey" && dd.DimensionKey != "ActivityKey") { if (this.ApplicationRuntimeParameters.GetValueRecursively(dd.DimensionKey, (string)null) == null) { result = false; break; } } } return result; }
protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result) { ExceptionHelper.FalseThrow(Path.GetExtension(file.FileName).ToLower() == ".xml", "'{0}'权限矩阵必须是xml电子表格", file.FileName); WorkbookNode workbook = new WorkbookNode(); workbook.Load(file.InputStream); //矩阵在文件第1个sheet,sheet名称为矩阵引用的定义名称 TableNode table = workbook.Worksheets[0].Table; var matrixDef = WfMatrixDefinitionAdapter.Instance.Load(workbook.Worksheets[0].Name); WfMatrix matrix = new WfMatrix(matrixDef) { MatrixID = Guid.NewGuid().ToString() }; if (table.Rows.Count <= 1) { PrepareResultInfo(result, "没有数据或格式不正确"); return; } UploadProgressStatus status = new UploadProgressStatus(); status.CurrentStep = 1; status.MinStep = 0; status.MaxStep = table.Rows.Count; for (int i = status.CurrentStep; i < status.MaxStep; i++) { var newRow = new WfMatrixRow() { RowNumber = i }; for (int j = 0; j < table.Rows[i].Cells.Count; j++) { if (table.Rows[0].Cells[j].Data.InnerText == "操作人") { newRow.Operator = table.Rows[i].Cells[j].Data.InnerText; continue; } var newCell = new WfMatrixCell(matrixDef.Dimensions[table.Rows[0].Cells[j].Data.InnerText]) { StringValue = table.Rows[i].Cells[j].Data.InnerText }; newRow.Cells.Add(newCell); } matrix.Rows.Add(newRow); status.CurrentStep = i; status.Response(); Thread.Sleep(100); } status.CurrentStep = status.MaxStep; status.Response(); WfMatrixAdapter.Instance.Update(matrix); string logInfo = string.Format("导入成功,权限矩阵名称:{0}{1}共导入{2}行数据.", matrix.MatrixID, Environment.NewLine, table.Rows.Count - 1); PrepareResultInfo(result, logInfo); }
public WfMatrix BuildWfMatrix() { var matrixDef = WfMatrixDefinitionAdapterTest.BuildNewMatrixDef(_matrixColumnNum); WfMatrix matrixInstance = new WfMatrix(matrixDef) { CreatorID = "testCreatorID1", CreatorName = "testCreatorName1", MatrixID = UuidHelper.NewUuidString(), ProcessKey = "testProcessKey", ActivityKey = "testActivityKey" }; for (int i = 0; i < _matrixRowNum; i++) { var row = new WfMatrixRow() { RowNumber = i, OperatorType = WfMatrixOperatorType.Person, Operator = "wanhw" }; if (i % 2 == 0) { row.Operator = "fanhy"; } for (int j = 0; j < matrixDef.Dimensions.Count; j++) { row.Cells.Add(new WfMatrixCell(matrixDef.Dimensions[j]) { StringValue = "String" + j.ToString() }); } matrixInstance.Rows.Add(row); } return matrixInstance; }
internal void GenerateCandidatesFromMatrix(WfMatrix matrix) { WfMatrixRowCollection rows = FilterRowsByActivity(matrix); WfMatrixRowUsersCollection rowsUsers = rows.GenerateRowsUsers(); foreach (WfMatrixRowUsers ru in rowsUsers) { this.Candidates.Add(ru.Users); } Candidates.Distinct((a1, a2) => string.Compare(a1.User.ID, a2.User.ID, true) == 0 && a1.AssigneeType == a2.AssigneeType); }