Beispiel #1
0
        public async Task <ActionResult> ImportModule(HttpPostedFileBase __filename, ImportModuleModel model)
#endif
        {
            FileUpload upload   = new FileUpload();
            string     tempName = await upload.StoreTempPackageFileAsync(__filename);

            List <string> errorList = new List <string>();
            bool          success   = await ModuleDefinition.ImportAsync(tempName, model.CurrentPageGuid, true, model.ModulePane, model.ModuleLocation == Location.Top, errorList);

            await FileSystem.TempFileSystemProvider.DeleteFileAsync(tempName);

            string errs = "";

            if (errorList.Count > 0)
            {
                ScriptBuilder sbErr = new ScriptBuilder();
                sbErr.Append(errorList, LeadingNL: true);
                errs = sbErr.ToString();
            }
            if (success)
            {
                string         msg  = this.__ResStr("imported", "\"{0}\" successfully imported(+nl)", __filename.FileName) + errs;
                UploadResponse resp = new UploadResponse {
                    Result = $"$YetaWF.confirm('{Utility.JserEncode(msg)}', null, function() {{ $YetaWF.reloadPage(true); }} );",
                };
                return(new YJsonResult {
                    Data = resp
                });
            }
            else
            {
                // Anything else is a failure
                throw new Error(this.__ResStr("cantImport", "Can't import {0}:(+nl)", __filename.FileName) + errs);
            }
        }
Beispiel #2
0
 public async Task <ActionResult> ImportModule(IFormFile __filename, ImportModuleModel model)