Esempio n. 1
0
        private static WfMatrixRow GenerateMatrixRow(WfMatrix matrix, RowNode rowNode, NamedLocationCollection locations, int index)
        {
            WfMatrixRow mRow = new WfMatrixRow(matrix);

            mRow.RowNumber = index;

            int emptyCellCount = 0;

            foreach (WfMatrixDimensionDefinition dd in matrix.Definition.Dimensions)
            {
                CellLocation location = locations[dd.DimensionKey];

                CellNode cell = rowNode.GetCellByIndex(location.Column);

                WfMatrixCell mCell = new WfMatrixCell(dd);

                mCell.StringValue = cell.Data.InnerText.Trim();

                mRow.Cells.Add(mCell);

                switch (dd.DimensionKey)
                {
                case "Operator":
                    mRow.Operator = cell.Data.InnerText;
                    break;

                case "OperatorType":
                    WfMatrixOperatorType opType = WfMatrixOperatorType.Person;
                    Enum.TryParse(cell.Data.InnerText, out opType);
                    mRow.OperatorType = opType;
                    break;

                default:
                    if (mCell.StringValue.IsNullOrEmpty())
                    {
                        emptyCellCount++;
                    }
                    break;
                }
            }

            if (emptyCellCount >= matrix.Definition.Dimensions.Count - 2)
            {
                //如果每一列都为空(不算Operator和OperatorType),那么认为整行都为空
                mRow = null;
            }
            else
            {
                matrix.Rows.Add(mRow);
            }

            return(mRow);
        }
Esempio n. 2
0
        public int ReplcaeOperators(WfMatrixOperatorType typeFilter, string originalOperator, params string[] replaceOperators)
        {
            int result = 0;

            foreach (WfMatrixRow row in this)
            {
                if (row.OperatorType == typeFilter)
                {
                    result += row.ReplaceOperator(originalOperator, replaceOperators);
                }
            }

            return(result);
        }
Esempio n. 3
0
        private static void ImportExcel2007(Stream importStream, WfMatrix matrix, Action notifier, string processDescKey)
        {
            DataTable dt = DocumentHelper.GetRangeValuesAsTable(importStream, "Matrix", "A3");

            int rowIndex = 0;

            foreach (DataRow row in dt.Rows)
            {
                WfMatrixRow matrixRow = new WfMatrixRow(matrix)
                {
                    RowNumber = rowIndex
                };
                foreach (var dimension in matrix.Definition.Dimensions)
                {
                    WfMatrixCell matrixCell = new WfMatrixCell(dimension);
                    matrixCell.StringValue = row[dimension.DimensionKey].ToString();

                    switch (dimension.DimensionKey)
                    {
                    case "Operator":
                        matrixRow.Operator = row[dimension.DimensionKey].ToString();
                        break;

                    case "OperatorType":
                        WfMatrixOperatorType opType = WfMatrixOperatorType.Person;
                        Enum.TryParse(row[dimension.DimensionKey].ToString(), out opType);
                        matrixRow.OperatorType = opType;
                        break;

                    default:
                        break;
                    }
                    matrixRow.Cells.Add(matrixCell);
                }

                if (notifier != null)
                {
                    notifier();
                }

                rowIndex++;
                matrix.Rows.Add(matrixRow);
            }

            WfMatrixAdapter.Instance.DeleteByProcessKey(matrix.ProcessKey);
            WfMatrixAdapter.Instance.Update(matrix);
        }