コード例 #1
0
        /// <summary>
        /// Handles the form data.
        /// </summary>
        /// <param name="formData">The form data.</param>
        public void HandleForm(FormData formData)
        {
            Success  = true;
            FormData = formData;
            Guid webFormId = WebFormHelper.GetWebFormId(formData);

            if (webFormId.Equals(Guid.Empty))
            {
                SetErrorStatus(GeneratedWebFormLczUtilities
                               .GetLczStringValue("UnknownWebFormIdentifierMessage",
                                                  "WebFormHandler", _userConnection));
                return;
            }
            if (!(ImportParamsGenerator is IImportParamsGenerator))
            {
                SetErrorStatus(GeneratedWebFormLczUtilities
                               .GetLczStringValue("ImportParamsGeneratorImplementationMessage",
                                                  "WebFormHandler", _userConnection));
                return;
            }
            InitHandlers(webFormId);
            Guid newEntityId = SetUpNewEntityId(formData);

            FormData = PreProcessData(formData);
            EntitySchema     schema     = WebFormHelper.GetWebFormEntitySchema(webFormId, _userConnection);
            ImportParameters parameters =
                ((IImportParamsGenerator)ImportParamsGenerator).GenerateParameters(schema);

            if (!ImportParamsGenerator.Success)
            {
                SetErrorStatus(ImportParamsGenerator.ErrorMessage);
                return;
            }
            FileImporter.ImportEntitySaveError += (sender, args) => {
                SetErrorStatus(args.Message ?? args.Exception.Message, args.Exception);
            };
            FileImporter.ColumnProcessError += (sender, args) => {
                SetErrorStatus(args.Message);
            };
            FileImporter.ImportWithParams(parameters);
            if (Success)
            {
                PostProcessData(formData, webFormId, newEntityId);
            }
        }