예제 #1
0
        private static void CreateMatrixHeaderRow(WorkSheet sheet, WfActivityMatrixResourceDescriptor activityMatrix, int startRowIndex)
        {
            Row headerRow = new Row(startRowIndex);

            headerRow.Style.Fill.SetBackgroundColor(Color.Gold, ExcelFillStyle.Solid);
            headerRow.Style.Border.Top.Style = ExcelBorderStyle.Thin;
            headerRow.Style.Border.Top.Color.SetColor(Color.Black);
            headerRow.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
            headerRow.Style.Border.Bottom.Color.SetColor(Color.Black);
            headerRow.Style.Border.Left.Style = ExcelBorderStyle.Thin;
            headerRow.Style.Border.Left.Color.SetColor(Color.Black);
            headerRow.Style.Font.Bold = true;

            sheet.Rows.Add(headerRow);

            int columnIndex = 1;

            foreach (SOARolePropertyDefinition dimension in activityMatrix.PropertyDefinitions)
            {
                sheet.Cells[headerRow.Index, columnIndex].Value = dimension.Description.IsNotEmpty() ? dimension.Description : dimension.Name;
                sheet.Names.Add(CellAddress.Parse(columnIndex, headerRow.Index).ToString(), dimension.Name);

                columnIndex++;
            }
        }
        public override void ClientToServer(WfClientResourceDescriptor client, ref WfResourceDescriptor server)
        {
            client.NullCheck("client");

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

            WfActivityMatrixResourceDescriptor amr = (WfActivityMatrixResourceDescriptor)server;
            WfClientActivityMatrixResourceDescriptor cmr = (WfClientActivityMatrixResourceDescriptor)client;

            amr.ExternalMatrixID = cmr.ExternalMatrixID;

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

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

                amr.PropertyDefinitions.Add(spd);
            }

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

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

                amr.Rows.Add(sRow);
            }
        }
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfActivityMatrixResourceDescriptor resource = (WfActivityMatrixResourceDescriptor)base.Deserialize(dictionary, type, serializer);

            JSONSerializerExecute.FillDeserializedCollection(dictionary["definitions"], resource.PropertyDefinitions);
            JSONSerializerExecute.FillDeserializedCollection(dictionary["rows"], resource.Rows);

            return(resource);
        }
        private static WfActivityMatrixResourceDescriptor PrepareSampleActivityMatrixResourceDescriptor()
        {
            WfActivityMatrixResourceDescriptor resource = new WfActivityMatrixResourceDescriptor();

            resource.PropertyDefinitions.CopyFrom(PrepareSamplePropertiesDefinition());
            resource.Rows.CopyFrom(PrepareSampleRows(resource.PropertyDefinitions));

            return resource;
        }
예제 #5
0
        /// <summary>
        /// 将WfActivityMatrixResourceDescriptor填充到Excel的WorkBook中
        /// </summary>
        /// <param name="workBook"></param>
        /// <param name="activityMatrix"></param>
        public static void FillActivityMatrixResourceDescriptor(this WorkBook workBook, WfActivityMatrixResourceDescriptor activityMatrix)
        {
            workBook.NullCheck("workBook");

            workBook.Sheets.Remove("Matrix");

            WorkSheet sheet = new WorkSheet(workBook, "Matrix");

            workBook.Sheets.Add(sheet);

            sheet.FillActivityMatrixResourceDescriptor(activityMatrix);
        }
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            IDictionary <string, object> dictionary = base.Serialize(obj, serializer);

            WfActivityMatrixResourceDescriptor resource = (WfActivityMatrixResourceDescriptor)obj;

            dictionary["definitions"] = resource.PropertyDefinitions;
            dictionary["rows"]        = resource.Rows;

            FillColumnInfoToRowValues(resource.PropertyDefinitions, resource.Rows);

            return(dictionary);
        }
        private void ResponseExcelWorkBook(WfActivityMatrixResourceDescriptor activityMatrix, string fileName)
        {
            WorkBook workBook = WorkBook.CreateNew();

            workBook.Sheets.Clear();

            workBook.FillActivityMatrixResourceDescriptor(activityMatrix);

            Response.AppendExcelOpenXmlHeader(fileName);

            workBook.Save(Response.OutputStream);

            Response.End();
        }
예제 #8
0
        private static int FillMatrixSheetData(WorkSheet sheet, WfActivityMatrixResourceDescriptor activityMatrix, int startRowIndex)
        {
            SOARolePropertyRowCollection rows = activityMatrix.Rows;

            foreach (SOARolePropertyRow row in rows)
            {
                foreach (DefinedName bookmark in sheet.Names)
                {
                    object dataValue = GetDataValueByBookmark(bookmark, row);

                    if (dataValue != null)
                    {
                        sheet.Cells[startRowIndex, bookmark.Address.StartColumn].Value = dataValue;
                    }
                }

                startRowIndex++;
            }

            return(startRowIndex);
        }
예제 #9
0
        public static IWfProcessDescriptor GetDynamicProcessDesp(WfActivityMatrixResourceDescriptor activityMatrixResource, string externalMatrixID = null)
        {
            IWfProcessDescriptor processDesp = CreateSimpleProcessDescriptor();

            IWfActivityDescriptor normalActDesp = processDesp.Activities["NormalActivity"];

            normalActDesp.Properties.SetValue("IsDynamic", true);

            WfActivityMatrixResourceDescriptor resource = activityMatrixResource;

            normalActDesp.Resources.Add(resource);

            resource.ExternalMatrixID = externalMatrixID;

            return processDesp;
        }
예제 #10
0
        /// <summary>
        /// 将WfActivityMatrixResourceDescriptor填充到Excel的WorkSheet中
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="activityMatrix"></param>
        public static void FillActivityMatrixResourceDescriptor(this WorkSheet sheet, WfActivityMatrixResourceDescriptor activityMatrix)
        {
            sheet.NullCheck("sheet");
            activityMatrix.NullCheck("activityMatrix");

            int startRowIndex = 1;

            Row titleRow = new Row(startRowIndex) { Height = 30d };
            titleRow.Style.Fill.SetBackgroundColor(Color.LightGray, ExcelFillStyle.Solid);
            titleRow.Style.Font.Size = 20;

            sheet.Rows.Add(titleRow);
            sheet.Cells[titleRow.Index, 1].Value = "角色属性";

            startRowIndex += 2;

            CreateMatrixHeaderRow(sheet, activityMatrix, startRowIndex++);

            FillMatrixSheetData(sheet, activityMatrix, startRowIndex);
        }
예제 #11
0
        private static int FillMatrixSheetData(WorkSheet sheet, WfActivityMatrixResourceDescriptor activityMatrix, int startRowIndex)
        {
            SOARolePropertyRowCollection rows = activityMatrix.Rows;

            foreach (SOARolePropertyRow row in rows)
            {
                foreach (DefinedName bookmark in sheet.Names)
                {
                    object dataValue = GetDataValueByBookmark(bookmark, row);

                    if (dataValue != null)
                        sheet.Cells[startRowIndex, bookmark.Address.StartColumn].Value = dataValue;
                }

                startRowIndex++;
            }

            return startRowIndex;
        }
        public static WfActivityMatrixResourceDescriptor GetServerActivityMatrixResourceDescriptor()
        {
            WfActivityMatrixResourceDescriptor resource = new WfActivityMatrixResourceDescriptor();

            resource.ExternalMatrixID = UuidHelper.NewUuidString();

            resource.PropertyDefinitions.CopyFrom(PrepareServerPropertiesDefinition());
            resource.Rows.CopyFrom(PrepareServerRows(resource.PropertyDefinitions));

            return resource;
        }
예제 #13
0
        public void FilterAndMergeEmptyActivityMatrixAndApprovalMatrixTest()
        {
            WfActivityMatrixResourceDescriptor resource = new WfActivityMatrixResourceDescriptor();

            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName = "CostCenter";
            queryParam.QueryValue = "1001";

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            SOARolePropertyRowCollection approvalRows = approvalMatrix.Rows.Query(queryParam);

            resource.Rows.MergeApprovalMatrix(resource.PropertyDefinitions, approvalRows, approvalMatrix.PropertyDefinitions);

            //输出的只有RowNumber。因为活动矩阵没有列
            resource.Rows.AssertAndOutputMatrixOperators();

            Assert.AreEqual(3, resource.Rows.Count);
        }
예제 #14
0
        /// <summary>
        /// 将WfActivityMatrixResourceDescriptor填充到Excel的WorkBook中
        /// </summary>
        /// <param name="workBook"></param>
        /// <param name="activityMatrix"></param>
        public static void FillActivityMatrixResourceDescriptor(this WorkBook workBook, WfActivityMatrixResourceDescriptor activityMatrix)
        {
            workBook.NullCheck("workBook");

            workBook.Sheets.Remove("Matrix");

            WorkSheet sheet = new WorkSheet(workBook, "Matrix");

            workBook.Sheets.Add(sheet);

            sheet.FillActivityMatrixResourceDescriptor(activityMatrix);
        }
예제 #15
0
        private static void CreateMatrixHeaderRow(WorkSheet sheet, WfActivityMatrixResourceDescriptor activityMatrix, int startRowIndex)
        {
            Row headerRow = new Row(startRowIndex);

            headerRow.Style.Fill.SetBackgroundColor(Color.Gold, ExcelFillStyle.Solid);
            headerRow.Style.Border.Top.Style = ExcelBorderStyle.Thin;
            headerRow.Style.Border.Top.Color.SetColor(Color.Black);
            headerRow.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
            headerRow.Style.Border.Bottom.Color.SetColor(Color.Black);
            headerRow.Style.Border.Left.Style = ExcelBorderStyle.Thin;
            headerRow.Style.Border.Left.Color.SetColor(Color.Black);
            headerRow.Style.Font.Bold = true;

            sheet.Rows.Add(headerRow);

            int columnIndex = 1;

            foreach (SOARolePropertyDefinition dimension in activityMatrix.PropertyDefinitions)
            {
                sheet.Cells[headerRow.Index, columnIndex].Value = dimension.Description.IsNotEmpty() ? dimension.Description : dimension.Name;
                sheet.Names.Add(CellAddress.Parse(columnIndex, headerRow.Index).ToString(), dimension.Name);

                columnIndex++;
            }
        }
예제 #16
0
        /// <summary>
        /// 将WfActivityMatrixResourceDescriptor填充到Excel的WorkSheet中
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="activityMatrix"></param>
        public static void FillActivityMatrixResourceDescriptor(this WorkSheet sheet, WfActivityMatrixResourceDescriptor activityMatrix)
        {
            sheet.NullCheck("sheet");
            activityMatrix.NullCheck("activityMatrix");

            int startRowIndex = 1;

            Row titleRow = new Row(startRowIndex)
            {
                Height = 30d
            };

            titleRow.Style.Fill.SetBackgroundColor(Color.LightGray, ExcelFillStyle.Solid);
            titleRow.Style.Font.Size = 20;

            sheet.Rows.Add(titleRow);
            sheet.Cells[titleRow.Index, 1].Value = "角色属性";

            startRowIndex += 2;

            CreateMatrixHeaderRow(sheet, activityMatrix, startRowIndex++);

            FillMatrixSheetData(sheet, activityMatrix, startRowIndex);
        }
        public static void AreSame(this WfClientActivityMatrixResourceDescriptor expected, WfActivityMatrixResourceDescriptor actual)
        {
            AssertStringEqual(expected.ExternalMatrixID, actual.ExternalMatrixID);

            AreSame(expected.PropertyDefinitions, actual.PropertyDefinitions);

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