示例#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);
        }
        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);
        }
示例#3
0
        protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result)
        {
            ExceptionHelper.FalseThrow(Path.GetExtension(file.FileName).ToLower() == ".xml",
                                       "'{0}' must be a xml file.", file.FileName);

            WorkbookNode workbook = new WorkbookNode();

            workbook.Load(file.InputStream);

            ExceptionHelper.FalseThrow(workbook.Worksheets.Contains("Matrix"),
                                       "The workbook must contains a 'Matrix' worksheet.");

            NamedLocationCollection fieldLocations = workbook.Names.ToLocations();

            TableNode table = workbook.Worksheets["Matrix"].Table;

            StringBuilder strB = new StringBuilder();

            int baseRowIndex = GetStartRow(fieldLocations);

            RowNode titleRow = table.GetRowByIndex(baseRowIndex);

            int currentRowIndex = table.Rows.IndexOf(titleRow) + 1;

            if (table.Rows.Count > currentRowIndex)
            {
                UploadProgressStatus status = new UploadProgressStatus();

                status.CurrentStep = 1;
                status.MinStep     = 0;
                status.MaxStep     = table.Rows.Count - currentRowIndex;

                int currentVirtualRow = baseRowIndex;

                for (int i = status.MinStep; i < status.MaxStep; i++)
                {
                    RowNode row = table.Rows[currentRowIndex];

                    if (row.Index > 0)
                    {
                        currentVirtualRow = row.Index;
                    }
                    else
                    {
                        currentVirtualRow++;
                    }

                    if (strB.Length > 0)
                    {
                        strB.Append("\n");
                    }

                    strB.AppendFormat("Processed={0}, Row={1}:", (i + 1), currentVirtualRow);

                    foreach (CellLocation location in fieldLocations)
                    {
                        CellNode cell = row.GetCellByIndex(location.Column);

                        strB.AppendFormat(";Name={0}, Value={1}", location.Name, cell != null ? cell.Data.Value : string.Empty);
                    }

                    status.CurrentStep = i;
                    status.Response();

                    currentRowIndex++;
                }

                status.CurrentStep = status.MaxStep;
                status.Response();
            }

            result.DataChanged = true;
            result.CloseWindow = false;
            result.ProcessLog  = strB.ToString();
        }
示例#4
0
		protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result)
		{
			string tag = uploadProgress.Tag;

			const int baseRowIndex = 3;

			ExceptionHelper.FalseThrow(Path.GetExtension(file.FileName).ToLower() == ".xml",
				"'{0}' must be a xml file.", file.FileName);

			WorkbookNode workbook = new WorkbookNode();

			workbook.Load(file.InputStream);

			ExceptionHelper.FalseThrow(workbook.Worksheets.Contains("PC Tracker Form"),
				"The workbook must contains a 'PC Tracker Form' worksheet.");

			Dictionary<string, CellLocation> fieldLocations = BuildNameColumnDictionary(workbook);

			TableNode table = workbook.Worksheets["PC Tracker Form"].Table;

			StringBuilder strB = new StringBuilder();

			if (table.Rows.Count > 3)
			{
				int currentRowIndex = baseRowIndex;

				UploadProgressStatus status = new UploadProgressStatus();

				status.CurrentStep = 1;
				status.MinStep = 0;
				status.MaxStep = table.Rows.Count - currentRowIndex;

				int currentVirtualRow = baseRowIndex;

				for (int i = status.MinStep; i < status.MaxStep; i++)
				{
					currentRowIndex = baseRowIndex + i;

					RowNode row = table.Rows[currentRowIndex];

					if (row.Index > 0)
						currentVirtualRow = row.Index;
					else
						currentVirtualRow++;

					if (strB.Length > 0)
						strB.Append("\n");

					strB.AppendFormat("Processed={0}, Row={1}:", (i + 1), currentVirtualRow);

					foreach (KeyValuePair<string, CellLocation> kp in fieldLocations)
					{
						CellNode cell = row.GetCellByIndex(kp.Value.Column);

						strB.AppendFormat(";Name={0}, Value={1}", kp.Key, cell != null ? cell.Data.Value : string.Empty);
					}

					status.CurrentStep = i;
					status.Response();

					int ms = 1000;

					if (Request.Form["longProgress"] == "true")
						ms = 2000;

					Thread.Sleep(ms);	//假装等待
				}

				status.CurrentStep = status.MaxStep;
				status.Response();
			}

			result.DataChanged = true;
			result.CloseWindow = false;
			result.ProcessLog = strB.ToString();
		}