Пример #1
0
        /// <summary>
        /// 进度条
        /// </summary>
        /// <param name="file"></param>
        /// <param name="result"></param>
        protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result)
        {
            ExceptionHelper.FalseThrow(Path.GetExtension(file.FileName).ToLower() == ".xml",
                                       "'{0}' must be a xml file.", file.FileName);

            StreamReader reader = new StreamReader(file.InputStream);

            XElement element = XElement.Parse(reader.ReadToEnd());

            string msg = string.Empty;

            DEDynamicEntityImportAdapter.Instance.Import(element, Request.QueryString["CategoryID"].Trim(), out msg);

            UploadProgressStatus status = new UploadProgressStatus
            {
                CurrentStep = 1,
                MinStep     = 0,
                MaxStep     = 1,
                StatusText  = "处理完成"
            };

            status.Response();

            result.DataChanged = true;
            result.CloseWindow = false;
            result.ProcessLog  = msg;
        }
Пример #2
0
        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;
        }
        protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result)
        {
            var fileType = Path.GetExtension(file.FileName).ToLower();

            if (fileType != ".xml" && fileType != ".zip")
            {
                throw new InvalidDataException("请上传一个xml或zip文件!");
            }

            if (fileType == ".xml")
            {
                var logger = ParseXmlFile(file);
                result.DataChanged = true;
                result.CloseWindow = false;
                result.ProcessLog  = logger.ToString();

                return;
            }

            if (fileType == ".zip")
            {
                var logger = ParseZipFile(file);
                result.DataChanged = true;
                result.CloseWindow = false;
                result.ProcessLog  = logger.ToString();
                return;
            }
        }
Пример #4
0
        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);
        }
        /// <summary>
        /// 上传属性定义
        /// </summary>
        /// <param name="file"></param>
        /// <param name="result"></param>
        protected void ImportSOARole_DoUploadProgress(HttpPostedFile file, UploadProgressResult result)
        {
            var fileType = Path.GetExtension(file.FileName).ToLower();

            if (string.Compare(fileType, ".xml", true) == 0)
            {
                StringBuilder logger = new StringBuilder();
                try
                {
                    CheckEditMode();

                    var xmlDoc      = XDocument.Load(file.InputStream);
                    var wfProcesses = xmlDoc.Descendants("Root");
                    XElementFormatter    formatter = new XElementFormatter();
                    UploadProgressStatus status    = new UploadProgressStatus();

                    status.CurrentStep = 1;
                    status.MinStep     = 0;
                    status.MaxStep     = wfProcesses.Count() + 1;
                    logger.AppendFormat("开始导入角色属性定义...\n", file.FileName, status.MaxStep);

                    SOARole role = new SOARole {
                        ID = this.DefinitionID
                    };

                    SOARolePropertyDefinitionAdapter.Instance.Delete(role);

                    foreach (var wfProcess in wfProcesses)
                    {
                        SOARolePropertyDefinitionCollection rowsColl = (SOARolePropertyDefinitionCollection)formatter.Deserialize(wfProcess);

                        SOARolePropertyDefinitionAdapter.Instance.Update(role, rowsColl);

                        logger.Append("保存成功...\n");

                        status.CurrentStep++;
                        status.Response();
                    }
                    logger.AppendFormat("导入完成!", file.FileName);
                }
                catch (Exception ex)
                {
                    logger.AppendFormat("导入错误,{0},错误堆栈:{1}", ex.Message, ex.StackTrace);
                }

                result.DataChanged = true;
                result.CloseWindow = false;
                result.ProcessLog  = logger.ToString();
            }
        }
Пример #6
0
        protected void DoFileUpload(HttpPostedFile file, UploadProgressResult result)
        {
            var fileType = Path.GetExtension(file.FileName).ToLower();

            if (fileType != ".xml")
            {
                throw new InvalidDataException("上传的文件类型错误");
            }

            ImportExecutor exec = new ImportExecutor(file, result);

            exec.AddAction(new AllUserImportAction()
            {
                IncludeOrganizationRelation = Request.Form["includeOrg"] == "includeOrg", IncludeSecretaries = Request.Form["includeSecretaries"] == "includeSecretaries", IncludeGroupConstMembers = this.Request.Form["includeGroupMembers"] == "includeGroupMembers"
            });
            exec.Execute();
        }
Пример #7
0
        protected void UploadActivityMatrixProgress(HttpPostedFile file, UploadProgressResult result)
        {
            var fileType = Path.GetExtension(file.FileName).ToLower();

            if (fileType != ".xlsx")
            {
                throw new SystemSupportException("'{0}' 必须是xlsx文件。");
            }

            WorkBook workBook = WorkBook.Load(file.InputStream);

            WfActivityMatrixResourceDescriptor matrix = workBook.ToActivityMatrixResourceDescriptor("Matrix", "A3");

            result.Data        = JSONSerializerExecute.Serialize(matrix);
            result.DataChanged = true;
            result.CloseWindow = true;
        }
        /// <summary>
        /// 上传矩阵的内容(行)
        /// </summary>
        /// <param name="file"></param>
        /// <param name="result"></param>
        protected void uploadProgress_DoUploadProgress(HttpPostedFile file, UploadProgressResult result)
        {
            CheckEditMode();

            var fileType = Path.GetExtension(file.FileName).ToLower();

            if (fileType != ".xml" && fileType != ".xlsx")
            {
                throw new SystemSupportException("'{0}' 必须是 xml 或 xlsx 文件。");
            }

            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")
            {
                ImportFromXml(file.InputStream);
            }
            else if (fileType == ".xlsx")
            {
                ImportFromExcel2007(file.InputStream, notifier);
            }

            result.DataChanged = true;
            result.CloseWindow = true;
        }
Пример #9
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();
        }
Пример #10
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();
		}
Пример #11
0
 private static void PrepareResultInfo(UploadProgressResult result, string logInfo)
 {
     result.DataChanged = true;
     result.CloseWindow = false;
     result.ProcessLog  = logInfo;
 }
Пример #12
0
        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);
        }