Пример #1
0
        public ActionResult CreateReference(int formDefinitionID)
        {
            FormDefinition form = FormService.Get(formDefinitionID);

            if (form == null)
            {
                ShowMessage((L)"No such form!", HtmlMessageType.Warning);
                return(RedirectToAction("index", "project"));
            }

            IEnumerable <LightFormDefinition> forms = FormService.GetList(form.ProjectID).Select(f => new LightFormDefinition {
                ID   = f.ID,
                Name = f.Name
            });

            IDictionary <string, IEnumerable <LightFieldDefinition> > fields = new Dictionary <string, IEnumerable <LightFieldDefinition> >();

            foreach (LightFormDefinition item in forms)
            {
                fields.Add(item.Name, FormService.GetFields(item.ID).Select(f => new LightFieldDefinition
                {
                    ID   = f.ID,
                    Name = f.Name
                }));
            }

            return(View(new CreateReferenceFieldDefinitionModel
            {
                FormDefinitionID = formDefinitionID,
                FormType = form.FormType,
                FieldType = FieldType.ReferenceField,
                Fields = fields
            }));
        }
        protected IActionResult ValidateParentAndRedirect(IValidatable parent, FormSection section, string actionName)
        {
            parent.Validate();
            var nextActionName = FormDefinition.GetNextPage(section, actionName).ActionName;

            return(parent.IsValid ? RedirectToLastActionForNewSection(section) : RedirectToAction(section, nextActionName));
        }
Пример #3
0
        public void Throw_KeyNotFoundException_On_GetField_For_Wrong_Key()
        {
            const string key   = "key";
            const string value = "value";

            var fieldDefinition = new FieldDefinition {
                Key = key, Type = "string", Prompt = "Name"
            };
            var field = Substitute.For <INZazuWpfField>();

            field.Key.Returns(key);
            var formDefinition = new FormDefinition {
                Fields = new[] { fieldDefinition }
            };
            var formData = new FormData(new Dictionary <string, string> {
                { key, value }
            });
            var factory = Substitute.For <INZazuWpfFieldFactory>();

            factory.CreateField(fieldDefinition).Returns(field);

            var sut = new NZazuView {
                FormDefinition = formDefinition, FormData = formData, FieldFactory = factory
            };

            new Action(() => sut.GetField("I do not exist")).Invoking(a => a()).Should().Throw <KeyNotFoundException>();
        }
Пример #4
0
        public void Update_FormData_On_LostFocus()
        {
            var view = new NZazuView();

            const string key   = "key";
            const string value = "value";

            var formDefinition = new FormDefinition {
                Fields = new[] { new FieldDefinition {
                                     Key = key, Type = "string"
                                 } }
            };

            view.FormDefinition = formDefinition;
            var values = new Dictionary <string, string> {
                { key, value }
            };

            view.FormData = values;
            view.FormData.Values.Should().BeEquivalentTo(values);

            // simulate user editing
            const string changedValue = "other";

            view.GetField(key).SetValue(changedValue);

            // simulate user leaves the field -> LostFoucs
            view.RaiseEvent(new RoutedEventArgs(UIElement.LostFocusEvent));

            // verify (bound) FormData has been updated, so thumbs up for binding experience
            view.FormData.Values[key].Should().Be(changedValue);
        }
Пример #5
0
        public PreviewViewModel(IEventAggregator events,
                                FormDefinition definition, FormData data,
                                INZazuWpfFieldFactory fieldFactory = null)
        {
            _events = events ?? throw new ArgumentNullException(nameof(events));
            _events.Subscribe(this);
            _definition = definition ?? throw new ArgumentNullException(nameof(definition));
            _data       = data ?? throw new ArgumentNullException(nameof(data));

            _fieldFactory = fieldFactory ?? new XceedFieldFactory();
            _fieldFactory.Use <INZazuTableDataSerializer>(new NZazuTableDataJsonSerializer());
            _fieldFactory.Use <ISupportGeoLocationBox>(new SupportGeoLocationBox());

            var dbSuggestor =
                new SuggestionsProxy(
                    new ElasticSearchSuggestions(
                        connectionPrefix: "http://127.0.0.1:9200"))     // instead of localhost. this changes the server
            {
                BlackListSize = 10,
                CacheSize     = 3000,
                MaxFailures   = int.MaxValue
            };

            // lets do some stuff with the suggestor
            _fieldFactory.Use <IProvideSuggestions>(new AggregateProvideSuggestions(new IProvideSuggestions[]
            {
                new ProvideValueSuggestions(),
                new ProvideFileSuggestions(),
                dbSuggestor
            }));
        }
Пример #6
0
        public Form(string name, string description, FormDefinition definition)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            if (name.Length > 100)
            {
                throw new ArgumentException("'Name' is too long");
            }

            if (description?.Length > 1000)
            {
                throw new ArgumentException("'Description' is too long");
            }

            Name        = name;
            Definition  = definition ?? throw new ArgumentNullException(nameof(definition));
            Description = description;
        }
Пример #7
0
        public object GetDefinition(string formPublicIdentifier)
        {
            FormDefinition form = FormService.Get(formPublicIdentifier);

            if (form == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            return(JsonP(new FormDefinitionModel
            {
                PublicIdentifier = formPublicIdentifier,
                PublicContent = form.PublicContent,
                Type = FormType.GetTypes().FirstOrDefault(t => t.Key == form.FormType).Value,
                Fields = form.Fields.Select(f => new FieldDefinitionModel
                {
                    Name = f.Name,
                    PublicIdentifier = f.PublicIdentifier,
                    Required = f.Required,
                    Type = FieldType.GetTypes().FirstOrDefault(t => t.Key == f.FieldType).Value,
                    FileIdentifier = f.FieldType == FieldType.FileField ? Guid.NewGuid().ToString() : null,
                    TargetFormPublicIdentifier = f.ReferenceFormID != null ? f.FormDefinition.PublicIdentifier : null,
                    TargetFieldPublicIdentifier = f.ReferenceDisplayFieldID != null ? f.ReferenceDisplayField.PublicIdentifier : null
                })
            }));
        }
Пример #8
0
        public void Return_field_values_on_GetFieldValues()
        {
            const string key   = "key";
            const string value = "value";

            var fieldDefinition = new FieldDefinition {
                Key = key, Type = "string"
            };
            var formDefinition = new FormDefinition {
                Fields = new[] { fieldDefinition }
            };
            var factory = Substitute.For <INZazuWpfFieldFactory>();
            var field   = Substitute.For <INZazuWpfField>();

            field.GetValue().Returns(value);
            field.IsEditable.Returns(true);
            field.Key.Returns(key);
            factory.CreateField(fieldDefinition).Returns(field);

            var view = new NZazuView();

            view.FormDefinition = formDefinition;
            view.FieldFactory   = factory;

            var actual = view.GetFieldValues();

            actual.Keys.Should().Contain(key);
            actual[key].Should().Be(value);
        }
Пример #9
0
        public ActionResult GetFormData(string formPublicIdentifier, int pageSize = 20, int pageIndex = 0)
        {
            UrlHelper url = new UrlHelper(ControllerContext.RequestContext);

            //TODO: Ordering,filtering,column selection
            FormDefinition form = FormService.Get(formPublicIdentifier);

            if (form == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            IEnumerable <FormData> formData = DataService.GetList(form.ID).OrderByDescending(d => d.Created).Skip(pageSize * pageIndex).Take(pageSize).ToArray();

            return(JsonP(formData.Select(d => new FormListDataModel {
                Created = d.Created,
                PublicIdentifier = d.PublicIdentifier,
                Fields = d.Fields.Select(f => new FieldListDataModel {
                    PublicIdentifier = f.FieldDefinition.PublicIdentifier,
                    Name = f.FieldDefinition.Name,
                    Value = f.GetDisplayValue(),
                    FileUrl = f.FieldDefinition.FieldType == FieldType.FileField ? ResolveUrl("~" + url.Action("File", new { FieldID = f.ID })) : null
                })
            })));
        }
Пример #10
0
        public UpdateFormDefinitionStatus UpdateForm(int id, string name, bool publicContent)
        {
            if (!Validator.CheckName(name))
            {
                return(UpdateFormDefinitionStatus.InvalidName);
            }

            FormDefinition form = Get(id);

            if (form == null)
            {
                return(UpdateFormDefinitionStatus.NoSuchFormDefinition);
            }

            if (!ProjectService.CanUserManage(form.ProjectID))
            {
                return(UpdateFormDefinitionStatus.PermissionDenied);
            }

            form.Name          = name;
            form.PublicContent = publicContent;
            FormRepository.Update(form);
            ActivityService.FormDefinitionUpdated(form.ID);
            return(UpdateFormDefinitionStatus.Updated);
        }
Пример #11
0
        private void UpdateFields(
            FormDefinition formDefinition,
            INZazuWpfFieldFactory fieldFactory,
            IResolveLayout resolveLayout)
        {
            Dispose();
            DisposeChecks();

            // make sure at least the minimum is set for render the layout
            if (formDefinition?.Fields == null)
            {
                return;
            }

            CreateFields(formDefinition.Fields, fieldFactory);

            if (formDefinition.Checks != null)
            {
                CreateFormChecks(formDefinition.Checks, fieldFactory.Resolve <ICheckFactory>());
            }

            var layout = resolveLayout.Resolve(formDefinition.Layout);

            var parentFields = FormDefinition.Fields.Select(fd => GetField(fd.Key));

            layout.DoLayout(Layout, parentFields, resolveLayout);

            this.SetFieldValues(FormData.Values);

            SetReadOnly(IsReadOnly);
        }
Пример #12
0
        private static void VerifyUpdate(Action <INZazuWpfView> act)
        {
            var formDefinition = new FormDefinition {
                Fields = new FieldDefinition[] { }
            };

            var resolveLayout = Substitute.For <IResolveLayout>();
            var layout        = Substitute.For <INZazuWpfLayoutStrategy>();

            resolveLayout.Resolve(formDefinition.Layout).Returns(layout);
            var fieldFactory = Substitute.For <INZazuWpfFieldFactory>();

            var sut = new NZazuView
            {
                ResolveLayout  = resolveLayout,
                FieldFactory   = fieldFactory,
                FormDefinition = formDefinition
            };

            fieldFactory.ClearReceivedCalls();
            resolveLayout.ClearReceivedCalls();
            layout.ClearReceivedCalls();

            act(sut);

            sut.ResolveLayout.Received().Resolve(sut.FormDefinition.Layout);
        }
        protected IActionResult ValidateParentAndRedirectBack(IValidatable parent, FormSection section, string actionName, FormSection?parentSection = null)
        {
            parent.Validate();
            var prevPage = FormDefinition.GetPreviousPage(section, actionName);

            return(parent.IsValid
                ? RedirectToLastActionForNewSection(parentSection ?? section)
                : RedirectBackToAction(section, prevPage.ActionName));
        }
Пример #14
0
        protected static IFiddle ToFiddle(FormDefinition formDefinition, FormData formData)
        {
            var events = new EventAggregator();

            return(new FiddleViewModel(
                       new FormDefinitionViewModel(events, formDefinition),
                       new FormDataViewModel(events, formData),
                       new PreviewViewModel(events, formDefinition, formData)));
        }
Пример #15
0
 public static FormDefinitionDTO ToDTO(this FormDefinition def)
 => new FormDefinitionDTO
 {
     Id           = def.Id,
     Name         = def.Name,
     Description  = def.Description,
     ObjectsCount = def.ObjectsCount,
     Fields       = def.FieldDefinitions //.Select(fd => fd.ToDTO()).ToList()
 };
Пример #16
0
        public FormDefinition Get(string publicIdentifier)
        {
            FormDefinition form = FormRepository.FirstOrDefault(f => f.PublicIdentifier == publicIdentifier);

            //if (form != null && !ProjectService.CanUserRead(form.ProjectID))
            //    return null;

            return(form);
        }
Пример #17
0
    public async System.Threading.Tasks.Task ListForms2Async()
    {
        var            tenantId = Guid.Parse(TenantId);
        FormDefinition form     = await this.client.CreateFormAsync(
            new CreateFormRequest
        {
            Name   = "TestForm",
            Fields = new List <FormFieldDefinition>
            {
                new FormFieldDefinition
                {
                    Name = "Name",
                    Type = "string",
                },
                new FormFieldDefinition
                {
                    Name = "Age",
                    Type = "int",
                },
            },
        },
            tenantId).ConfigureAwait(false);

        form.Should().NotBeNull();

        form = await this.client.GetFormAsync(tenantId, form.FormId).ConfigureAwait(false);

        form.Should().NotBeNull();

        FormSubmission submission = await this.client.SubmitFormAsync(
            form.FormId,
            new Dictionary <string, string>
        {
            ["Name"] = "Test",
            ["Age"]  = "30",
        },
            new Dictionary <string, HttpFile>
        {
            ["ProfilePicture"] = new HttpFile(File.OpenRead("350x350.png"), "test.png", "image/png"),
        },
            tenantId).ConfigureAwait(false);

        submission.Should().NotBeNull();

        submission = await this.client.GetSubmissionAsync(tenantId, form.FormId, submission.SubmissionId).ConfigureAwait(false);

        submission.Should().NotBeNull();

#pragma warning disable CA2000 // Dispose objects before losing scope
        HttpFile attachment = await this.client.GetSubmissionAttachmentAsync(form.FormId, submission.SubmissionId, "ProfilePicture", tenantId).ConfigureAwait(false);

#pragma warning restore CA2000 // Dispose objects before losing scope
        attachment.Should().NotBeNull();

        ICollection <FormDefinition> forms = await this.client.ListFormsAsync(tenantId).ConfigureAwait(false);
    }
 public async Task Execute(FormDefinition form)
 {
     //There is no such requirement in the task.
     //I just want to show difference between repository and use-case.
     if (!await guard.CanCreateNewForms(requester))
     {
         throw new System.UnauthorizedAccessException();
     }
     await repository.CreateFormDefinition(form);
 }
Пример #19
0
        public void CannotCreateFormObjectIfSomeValueTooShort()
        {
            var testForm = new FormDefinition("test")
                           .AddField(() =>
                                     new TextFieldDefinition("MIN", "Min length test", false)
                                     .Min(5));

            Assert.Throws <ValidationException>(
                () => new FormObject(testForm
                                     , fromJson("{'MIN':'123'}")));
        }
Пример #20
0
        public void CannotCreateFormObjectIfSomeValueTooLong()
        {
            var testForm = new FormDefinition("test")
                           .AddField(() =>
                                     new TextFieldDefinition("MAX", "Max length test", false)
                                     .Max(5));

            Assert.Throws <ValidationException>(
                () => new FormObject(testForm
                                     , fromJson("{'MAX':'1234567'}")));
        }
Пример #21
0
        public FormDefinition Get(int id)
        {
            FormDefinition form = FormRepository.Get(id);

            if (form != null && !ProjectService.CanUserRead(form.ProjectID))
            {
                return(null);
            }

            return(form);
        }
Пример #22
0
        public static FormDefinition GetConnectionFormDefintion()
        {
            var formDefinition = new FormDefinition
            {
                CompanyName = Connector.CompanyName,
                CryptoKey   = Connector.CryptoKey,
                HelpUri     = new Uri(HelpLink)
            };

            return(formDefinition);
        }
Пример #23
0
        public IQueryable <FieldDefinition> GetFields(int id)
        {
            FormDefinition form = Get(id);

            if (form != null)
            {
                return(form.Fields.AsQueryable());
            }

            return(new FieldDefinition[0].AsQueryable());
        }
Пример #24
0
    public async System.Threading.Tasks.Task ListFormSubmissionsAsync()
    {
        var tenantId = Guid.Parse(TenantId);
        ICollection <FormDefinition> forms = await this.client.ListFormsAsync(tenantId).ConfigureAwait(false);

        FormDefinition form = forms.First();

        ICollection <FormSubmissionSummary> submissions = await this.client.ListSubmissionsAsync(tenantId, form.FormId).ConfigureAwait(false);

        FormSubmissionSummary submissionInfo = submissions.FirstOrDefault(s => s.AttachmentCount > 0);
        FormSubmission        submission     = await this.client.GetSubmissionAsync(tenantId, form.FormId, submissionInfo.SubmissionId).ConfigureAwait(false);
    }
Пример #25
0
        public ActionResult GetInquiryData(string formPublicIdentifier)
        {
            FormDefinition form = FormService.Get(formPublicIdentifier);

            if (form == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            //TODO: Compute inquiry data! (Use cache?)
            return(View());
        }
Пример #26
0
        public void Update_when_FormDefinition_changed()
        {
            var formDefinition = new FormDefinition {
                Layout = "grid", Fields = new FieldDefinition[] { }
            };

            VerifyUpdate(view =>
            {
                view.FormDefinition = formDefinition;
                view.FormDefinition.Should().Be(formDefinition);
            });
        }
Пример #27
0
        private static FormDefinition BuildWith(DataFormField field)
        {
            var definition = new FormDefinition(field.PropertyType);

            definition.FormRows.Add(new FormRow
            {
                Elements = { new FormElementContainer(0, 1, field) }
            });

            field.Freeze();
            return(definition);
        }
Пример #28
0
        internal static FormDefinition GetConnectionFormDefintion()
        {
            var formDefinition = new FormDefinition
            {
                CompanyName = Connector.CompanyName,
                CryptoKey   = Connector.CryptoKey,
                HelpUri     = new Uri(HelpLink)
            };

            formDefinition.Add(BuildTokenDefinition(0));

            return(formDefinition);
        }
Пример #29
0
        public void Preserve_Formdata_if_FormDefinition_changed()
        {
            const string key   = "name";
            const string value = "John";

            var fieldDefinition = new FieldDefinition {
                Key = key, Type = "string", Prompt = "Name"
            };
            var initialFormDefinition = new FormDefinition {
                Fields = new[] { fieldDefinition }
            };
            var formData = new FormData(new Dictionary <string, string> {
                { key, value }
            });

            var sut = new NZazuView {
                FormDefinition = initialFormDefinition, FormData = formData
            };

            sut.FormData.Should().Be(formData);
            var actual = sut.GetFieldValues();

            actual.Should().Contain(formData.Values);

            fieldDefinition.Prompt = "Login";
            var changedFormDefinition = new FormDefinition {
                Fields = new[] { fieldDefinition }
            };

            // it is ugly to attach to depProperty.changed. It goes like this
            // https://social.msdn.microsoft.com/Forums/vstudio/en-US/262df30c-8383-4d5c-8d76-7b8e2cea51de/how-do-you-attach-a-change-event-to-a-dependency-property?forum=wpf
            var dpDescriptor =
                DependencyPropertyDescriptor.FromProperty(NZazuView.FormDefinitionProperty, typeof(NZazuView));
            var          formDefinitionChanged = false;
            EventHandler handler = (sender, args) => { formDefinitionChanged = true; };

            dpDescriptor.AddValueChanged(sut, handler);
            try
            {
                sut.FormDefinition = changedFormDefinition;
            }
            finally
            {
                dpDescriptor.RemoveValueChanged(sut, handler);
            }

            formDefinitionChanged.Should().BeTrue();

            actual = sut.GetFieldValues();
            actual.Should().Contain(formData.Values);
        }
        /// <exclude />
        public static FormTreeCompiler BuildWidgetForParameters(IEnumerable <ParameterProfile> parameterProfiles, Dictionary <string, object> bindings, string uniqueName, string panelLabel, IFormChannelIdentifier channelIdentifier)
        {
            XNamespace stdControlLibSpace = Namespaces.BindingFormsStdUiControls10;

            var bindingsDeclaration = new XElement(Namespaces.BindingForms10 + "bindings");
            var widgetPlaceholder   = new XElement(stdControlLibSpace + "FieldGroup", new XAttribute("Label", panelLabel));

            var bindingsValidationRules = new Dictionary <string, List <ClientValidationRule> >();

            foreach (ParameterProfile parameterProfile in parameterProfiles.Where(f => f.WidgetFunction != null))
            {
                IWidgetFunction widgetFunction = parameterProfile.WidgetFunction;

                Type bindingType = widgetFunction != null && parameterProfile.Type.IsLazyGenericType() ?
                                   widgetFunction.ReturnType : parameterProfile.Type;

                bindingsDeclaration.Add(
                    new XElement(Namespaces.BindingForms10 + "binding",
                                 new XAttribute("optional", true),
                                 new XAttribute("name", parameterProfile.Name),
                                 new XAttribute("type", bindingType.AssemblyQualifiedName)));

                var      context  = new FunctionContextContainer();
                XElement uiMarkup = FunctionFacade.GetWidgetMarkup(widgetFunction, parameterProfile.Type, parameterProfile.WidgetFunctionParameters, parameterProfile.Label, parameterProfile.HelpDefinition, parameterProfile.Name, context);

                widgetPlaceholder.Add(uiMarkup);

                if (!bindings.ContainsKey(parameterProfile.Name))
                {
                    bindings.Add(parameterProfile.Name, "");
                }

                if (parameterProfile.IsRequired)
                {
                    bindingsValidationRules.Add(parameterProfile.Name, new List <ClientValidationRule> {
                        new NotNullClientValidationRule()
                    });
                }
            }

            FormDefinition widgetFormDefinition = BuildFormDefinition(bindingsDeclaration, widgetPlaceholder, bindings);

            var compiler = new FormTreeCompiler();

            using (XmlReader reader = widgetFormDefinition.FormMarkup)
            {
                compiler.Compile(reader, channelIdentifier, widgetFormDefinition.Bindings, false, "WidgetParameterSetters" + uniqueName, bindingsValidationRules);
            }

            return(compiler);
        }
Пример #31
0
        public CreateFormDefinitionStatus CreateForm(string name, int formType, bool publicContent, int projectID)
        {
            if (GetList(projectID).Count() == Validator.MaxUserProjects)
                return CreateFormDefinitionStatus.FormCountExceeded;

            if(!Validator.CheckName(name))
                return CreateFormDefinitionStatus.InvalidName;

            if(!Validator.CheckFormType(formType))
                return CreateFormDefinitionStatus.InvalidFormType;

            Project project = ProjectService.Get(projectID);
            if(project == null)
                return CreateFormDefinitionStatus.NoSuchProject;

            if(!ProjectService.CanUserManage(projectID))
                return CreateFormDefinitionStatus.PermissionDenied;

            FormDefinition form = new FormDefinition
            {
                Name = name,
                FormType = formType,
                PublicContent = publicContent,
                ProjectID = projectID,
                PublicIdentifier = HashHelper.ComputePublicIdentifier(typeof(FormDefinition).Name, name),
                Created = DateTime.Now
            };
            FormRepository.Insert(form);
            ActivityService.FormDefinitionCreated(form.ID);
            return CreateFormDefinitionStatus.Created;
        }
Пример #32
0
        public string PreConnect(IDictionary<string, string> properties)
        {
            var form = new FormDefinition
                {
                    CompanyName = "etouches, Inc.",
                    CryptoKey = "{B5D0EEE1-40CE-4D34-B161-52B8620903EE}",
                    HelpUri = new Uri("https://developer.etouches.com/"),
                    Entries = new Collection<EntryDefinition>
                    {
                        new EntryDefinition
                        {
                            InputType = InputType.Text,
                            IsRequired = true,
                            Label = "Account Id",
                            PropertyName = "AccountId"
                        },
                        new EntryDefinition
                        {
                            InputType = InputType.Text,
                            IsRequired = true,
                            Label = "Event Id",
                            PropertyName = "EventId"
                        },
                        new EntryDefinition
                        {
                            InputType = InputType.Text,                               
                            IsRequired = true,
                            Label = "API Key",
                            PropertyName = "ApiKey"
                        },
                        new EntryDefinition
                        {
                            InputType = InputType.Text,
                            IsRequired = true,
                            Label = "TTL for Cache In Minutes",
                            PropertyName = "TTL"
                        },
                        new EntryDefinition
                        {
                            InputType = InputType.Text,
                            IsRequired = true,
                            Label = "Page Size",
                            PropertyName = "PageSize"
                        },
                        new EntryDefinition
                        {
                            InputType = InputType.Text,
                            IsRequired = true,
                            Label = "Base URL (leave blank for https://eiseverywhere.com)",
                            PropertyName = "BaseUrl"
                        },
                        new EntryDefinition
                        {
                            InputType = InputType.Text,
                            IsRequired = true,
                            Label = "API V2 URL (leave blank for https://eiseverywhere.com)",
                            PropertyName = "V2Url"
                        }
                    }


            };

            return form.Serialize();
        }
        internal object OpenNamedWindow(FormDefinition formDef, XElement xml, ActivityHarness sourceHarness)
        {
            string url = FormsURL + formDef.Path;
            object o = null;

            try
            {
                System.Xml.XmlTextReader rdr = UrlAsXmlTextReader(url);
                o = XamlReader.Load(rdr);
            }
            catch (Exception ex)
            {
                ApplicationEx.DebugException(ex, url);
                return null;
            }

            if (o is WindowEx)
            {
                WindowEx w = (WindowEx)o;
                if (sourceHarness == null)
                {
                    w.Initialise(xml);
                }
                else
                {
                    w.InitialiseCopy(sourceHarness);
                }
                w.Show();
            }
            else if (o is TabItem)
            {
                TabItem ti = (TabItem)o;
                if (ti is TabItemEx)
                {
                    TabItemEx ati = (TabItemEx)ti;
                    ati.IsDynamic = true;
                    if (sourceHarness == null)
                    {
                        ati.Initialise(xml);
                    }
                    else
                    {
                        ati.InitialiseCopy(sourceHarness);
                        ati.Harness.IsActivityOwner = false;
                    }
                }
                //homeTabControl.Items.Add(ti);
                //homeTabControl.SelectedItem = ti;
            }

            return o;
        }
Пример #34
0
        /// <summary>
        /// Construct an XML serialized form that will define the input properties that will be displayed in the UI and 
        /// used to pass back into the connection using the connect method the connection method
        /// </summary>
        /// <returns></returns>
        private string BuildUiFormDefinition()
        {
            FormDefinition formDefinition = new FormDefinition();
            //Add your company name here, this is a required field
            formDefinition.CompanyName = "Scribe Software Corporation © 1996-2011 All rights reserved.";
            //declare the key used for transfering of sensative data
            //this is a required
            formDefinition.CryptoKey = CryptoKey;

            //decalare a help uri, this is not required and will not be display if it is not declared
            formDefinition.HelpUri = new Uri("http://www.scribesoft.com");

            //for each input item on the screen a new entry definition will need to be created and
            //added to the form definition in order to be serialized and passed up to the ui.
            //this first entry will define a combo box
            EntryDefinition entry = new EntryDefinition();

            //set the input type to plain text
            entry.InputType = InputType.Text;
            entry.IsRequired = true;

            //set the Label that is displayed to the user and the identifying property name
            //note: the label and the property name may be different
            entry.Label = "Provider";
            entry.PropertyName = "Provider";

            //set the position in which the control will be displayed
            entry.Order = 1;

            //the options will hold the list of values to be placed in the combo box
            //The first value is what will be displayed to the user
            //The second value is the actual value that will be passed back to the connector
            entry.Options.Add("SQL Server 2012", "SQLNCLI11");
            entry.Options.Add("SQL Server 2008", "SQLNCLI10");
            entry.Options.Add("SQL Server 2005", "SQLNCLI");
            //finally add the entry definition representing the combobox to the form definition
            formDefinition.Add(entry);

            //create and entry for a standard text box
            formDefinition.Add(new EntryDefinition { InputType = InputType.Text, PropertyName = "Server", Label = "Server", Order = 2, IsRequired = true });
            formDefinition.Add(new EntryDefinition { InputType = InputType.Text, PropertyName = "Database", Label = "Database", Order = 3, IsRequired = true });
            formDefinition.Add(new EntryDefinition { InputType = InputType.Text, PropertyName = "UserName", Label = "UserName", Order = 4, IsRequired = true });

            //Finally create a password field
            formDefinition.Add(new EntryDefinition { InputType = InputType.Password, PropertyName = "Password", Label = "Password", Order = 5, IsRequired = true });

            //serialize the formDefinition so that it can be sent back to the UI
            return formDefinition.Serialize();
        }
Пример #35
0
        //-----------------------------------------------------------------------------------------------------
        public string PreConnect(IDictionary<string, string> properties)
        {
            var form = new FormDefinition
            {
                CompanyName = ("Melissa Data. Additional Information : http://www.melissadata.com/dqt/scribe.htm"),
                CryptoKey = "1",
                HelpUri = new Uri("http://wiki.melissadata.com/index.php?title=Data_Quality_Components_for_Scribesoft"),
                Entries =
                new Collection<EntryDefinition>
                {
                     new EntryDefinition
                    {
                    InputType = InputType.Text,
                    IsRequired = true,
                    Label = "Melissa Data License Key",
                    PropertyName = "licensekey"
                    },
                }
            };

            return form.Serialize();
        }