Beispiel #1
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)
        {
            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);
        }