private void LoadFields() { foreach (var field in GridFields) { try { var viewModel = field.CreateFieldViewModel(RecordType, RecordService, this, ApplicationController); if (field.AliasedFieldName == null) { var isWriteable = RecordService?.GetFieldMetadata(field.FieldName, RecordType).Createable == true || RecordService?.GetFieldMetadata(field.FieldName, RecordType).Writeable == true; viewModel.IsEditable = !IsReadOnly && isWriteable && FormService != null && FormService.AllowGridFieldEditEdit(ParentFormReference) && (!(viewModel is LookupFieldViewModel) || FormService.AllowLookupFunctions); } AddField(viewModel); } catch (Exception ex) { ApplicationController.ThrowException(ex); } } }
public async Task PathFindingTest() { var repo = new Mock <IFormRepository>(); var provider = new Mock <IStaticFormProvider>(); var service = new FormService(repo.Object, provider.Object); var form = await service.InitialiseForm("test", FormType.Test); var fromNode = form.Nodes.FindByKey(Key.ForTaskList()); var toNode = form.Nodes.FindByKey(Key.ForPostTaskPage("last-task")); var stopKey = Key.ForTaskList(); var pathFinder = new GraphPathFinderBuilder <Key, FormNode>(PathFinderType.PriorityPathFinder) .WithOnEdgeDiscoveredHandler((e, output) => { if (e.ToNode.Key.Equals(stopKey)) { output.ShouldQueue = false; } }) .Build(); var result = pathFinder.FindPath(form, fromNode, toNode); Assert.Equal(18, result.Cost); }
public ActionResult Handle(FormCollection form) { JsonResult jResult = new JsonResult(); bool bol = false; try { FormService former = AntApi.Former; Dictionary <string, object> fieldDict = new Dictionary <string, object>(); foreach (string key in form.Keys) { fieldDict.Add(key, form[key]); } //TryUpdateModel<Dictionary<string, object>>(fieldDict, form); former.SubmitFormData(new Guid(form["InstanceGuid"]), fieldDict); RuntimeService run = AntApi.Runtime; run.Next(new Guid(form["InstanceGuid"]), new Guid(form["TaskGuid"])); bol = true; } catch (Exception e) { } //Response.Redirect("/Home/List"); if (bol) { jResult.Data = new { Code = "200", Message = "保存成功" }; } else { jResult.Data = new { Code = "400", Message = "保存失败" }; } return(jResult); }
private void PopulateSelectLists(Review review) { var ratingSelectList = new List <SelectListItem>(); for (int i = 1; i <= 5; i++) { var current = new SelectListItem { Text = i.ToString(), Value = i.ToString(), Selected = i == 5 }; ratingSelectList.Add(current); } var commentTypesSelectList = FormService.GetCommentTypes().Select(commentType => new SelectListItem { Text = commentType.Name, Value = commentType.Id.ToString(), Selected = commentType.Id == review.Id }); review.Ratings = ratingSelectList; review.CommentTypes = commentTypesSelectList; }
public FormController(FormService formService, SystemService systemService, AuditLogService auditLog, ILogger <FormController> logger) { _formService = formService; _systemService = systemService; _auditLog = auditLog; _logger = logger; }
public void ServiceTest() { var service = new FormService(); var result = service.GetJson(TestFrom); Assert.AreEqual(result, ResultString); }
/// <summary> /// 流程处理页面:显示 /// isNew:true 新建,false 待办 /// </summary> /// <returns></returns> public ActionResult Handle(bool isNew, string id) { RuntimeService runtime = AntApi.Runtime; TaskService tasker = AntApi.Tasker; FormService former = AntApi.Former; RtTask task = null; string step = string.Empty; Guid instanceGuid = new Guid(); if (isNew) { instanceGuid = runtime.NewInstanceByID(new Guid(id), Guid.Empty, null); step = "0008"; task = tasker.GetFirstTaskByInstance(instanceGuid); } else { RtInstance instance = tasker.GetInstanceByTask(new Guid(id)); instanceGuid = instance.InstanceGuid; task = tasker.GetTaskByTaskGuid(new Guid(id)); } ViewBag.FormHtml = former.GetFormByTaskGuid(task.TaskGuid); ViewBag.Step = step; ViewBag.InstanceGuid = instanceGuid; ViewBag.TaskGuid = task.TaskGuid; return(View()); }
protected override IEnumerable <ReferencePicklistItem> GetPicklistOptions() { return(GetSearchResults() .Select(r => new ReferencePicklistItem(r, r.GetStringField(FormService.GetPicklistDisplayField(FieldName, GetRecordType(), LookupService, RecordTypeToLookup)))) .Union(new[] { new ReferencePicklistItem(null, null) }) .ToArray()); }
public void AddRow() { LoadingViewModel.IsLoading = true; try { var viewModel = FormService.GetLoadRowViewModel(SectionIdentifier, RecordForm, (record) => DoOnMainThread(() => { InsertRecord(record, 0); RecordForm.ClearChildForm(); }), () => RecordForm.ClearChildForm()); if (viewModel == null) { InsertRecord(GetRecordService().NewRecord(RecordType), 0); } else { RecordForm.LoadChildForm(viewModel); } } catch (Exception ex) { ApplicationController.UserMessage(string.Format("Error Adding Row: {0}", ex.DisplayString())); } finally { LoadingViewModel.IsLoading = false; } }
private void button3_Click(object sender, EventArgs e) { FormService formService = new FormService(); String text = formService.OpenDir("选择要保存的位置"); textBox3.Text = text; }
public void LoadPicklistItems() { _itemsSource = new ReferencePicklistItem[0]; if (LookupService != null) { ItemsSource = (FormService?.OrderPicklistItems(FieldName, GetRecordType(), GetPicklistOptions()) ?? GetPicklistOptions().OrderBy(p => p.Name)).ToArray(); if (Value == null && ItemsSource.Count(i => i.Record != null) == 1 && (FormService?.InitialisePicklistIfOneOption(FieldName, GetRecordType()) ?? false)) { SelectedItem = ItemsSource.First(i => i.Record != null); } } var matchingItem = MatchSelectedItemInItemsSourceToValue(); if (matchingItem == null) { SelectedItem = GetValueAsPicklistItem(); if (SelectedItem != null) { ItemsSource = ItemsSource.Union(new[] { SelectedItem }); } } else { SelectedItem = matchingItem; } OnPropertyChanged(nameof(SelectedItem)); }
public virtual void LoadFormSections() { //forcing enumeration up front var sections = FormService.GetFormMetadata(RecordType, RecordService).FormSections.ToArray(); var sectionViewModels = new List <SectionViewModelBase>(); //Create the section view models foreach (var section in sections) { if (section is FormFieldSection) { sectionViewModels.Add(new FieldSectionViewModel( (FormFieldSection)section, this )); } } //now set the section view model property in the ui thread which will notify the ui with the sections DoOnMainThread( () => { FormSectionsAsync = new ObservableCollection <SectionViewModelBase>(sectionViewModels); OnSectionLoaded(); }); }
protected override IEnumerable <IRecord> GetSearchResults() { if (LookupService == null) { throw new NullReferenceException(string.Format("Error searching field {0}. {1} is null", FieldName, "LookupService")); } if (UsePicklist) { return(FormService.GetLookupPicklist(FieldName, RecordEntryViewModel.GetRecordType(), RecordEntryViewModel.ParentFormReference, RecordEntryViewModel.GetRecord(), LookupService, RecordTypeToLookup)); } else { var primaryField = LookupService.GetPrimaryField(RecordTypeToLookup); var conditions = FormService.GetLookupConditions(FieldName, RecordEntryViewModel.GetRecordType(), RecordEntryViewModel.ParentFormReference, RecordEntryViewModel.GetRecord()); if (!EnteredText.IsNullOrWhiteSpace()) { conditions = conditions.Union(new[] { new Condition(primaryField, ConditionType.BeginsWith, EnteredText) }); } return(LookupService.GetFirstX(RecordTypeToLookup, UsePicklist ? -1 : MaxRecordsForLookup, null, conditions, new[] { new SortExpression(primaryField, SortType.Ascending) })); } }
public async void SearchFormAsync_ExistingData_ReturnsForm() { // Arrange var input = new SearchFormInput { Request = "John" }; var forms = new List <Form> { new Form { Json = "\"name\":\"John\"" } }; var repo = new Mock <IFormRepository>(MockBehavior.Strict); repo.Setup(s => s.FindAsync(It.Is <string>(s => s == input.Request))) .ReturnsAsync(forms); var uow = new Mock <IUnitOfWork>(MockBehavior.Strict); uow .Setup(s => s.Forms) .Returns(repo.Object); uow .Setup(s => s.Dispose()); var service = new FormService(uow.Object); // Act var output = await service.SearchFormAsync(input); // Assert Assert.True(output.Result.Count == 1); Assert.Equal(forms.First().Json, output.Result.First()); }
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 }) })); }
public WorkFlowController(IUnitOfWork unitOfWork, WorkFlowService workFlowService) { _unitOfWork = unitOfWork; _workFlowService = workFlowService; _formService = new FormService(_unitOfWork); _decisionMethodService = new DecisionMethodService(_unitOfWork); }
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 }) }))); }
public void IframeModLogin(FormCollection collection) { string name = collection["hdLoginname"].ToString(); string pwd = collection["hdPassword"].ToString(); string remusrname = collection["hdReUsername"].ToString(); Entity.User user = Users.Login(name, pwd); if (user == null) { Response.Write("<script type='text/javascript' type='language'>window.parent.App.loginCallBack(false);</script>"); } else { if (user.IsEmailValidate == 0) { Response.Write("<script type='text/javascript' type='language'>window.parent.App.loginCallBack(true,0);</script>"); } else { FormService.SignIn(user, remusrname == "true"); if (user.NickName == "") { Response.Write("<script type='text/javascript' type='language'>window.parent.App.loginCallBack(true,1);</script>"); } else { Response.Write("<script type='text/javascript' type='language'>window.parent.App.loginCallBack(true,2);</script>"); } } } }
/// <summary> /// Start the application async. /// </summary> private async void Run() { // If StartupRegister is enabled, init providers on the load of the first CropForm if (ConfigService.Current.StartupRegister) { await RestoreProviders(); if (ProviderService.RegisteredProviders.Count > 0) { FormService.ShowCropForms(); } else { FormService.ConfigForm.Show(); } } else if (ConfigService.Current.SafeProviders.Count > 0) { // Show settings if no providers gonna be loaded - not safe, this is a prediction FormService.ShowCropForms(); } else { FormService.ConfigForm.Show(); } }
public ActionResult Edit(EditFormDefinitionModel model) { if (ModelState.IsValid) { if (model.IsNew()) { CreateFormDefinitionStatus status = FormService.CreateForm(model.Name, model.FormType, model.PublicContent, model.ProjectID); switch (status) { case CreateFormDefinitionStatus.Created: ShowMessage(String.Format((L)"Form '{0}' created.", model.Name)); return(RedirectToAction("forms", "project", new { projectID = model.ProjectID })); case CreateFormDefinitionStatus.InvalidName: ModelState.AddModelError("Name", (L)"Invalid name!"); break; case CreateFormDefinitionStatus.InvalidFormType: ModelState.AddModelError("FormType", (L)"Invalid form type!"); break; case CreateFormDefinitionStatus.NoSuchProject: ShowMessage((L)"No such project!", HtmlMessageType.Warning); return(RedirectToAction("index", "project")); case CreateFormDefinitionStatus.FormCountExceeded: ShowMessage((L)"Maximum forms in project count exceeded!", HtmlMessageType.Warning); return(RedirectToAction("forms", "project", new { projectID = model.ProjectID })); case CreateFormDefinitionStatus.PermissionDenied: ShowMessage((L)"You can't create form!", HtmlMessageType.Warning); return(RedirectToAction("forms", "project", new { projectID = model.ProjectID })); } } else { UpdateFormDefinitionStatus status = FormService.UpdateForm(model.FormDefinitionID, model.Name, model.PublicContent); switch (status) { case UpdateFormDefinitionStatus.Updated: ShowMessage(String.Format((L)"Form '{0}' updated.", model.Name)); return(RedirectToAction("forms", "project", new { projectID = model.ProjectID })); case UpdateFormDefinitionStatus.InvalidName: ModelState.AddModelError("Name", (L)"Invalid name!"); break; case UpdateFormDefinitionStatus.NoSuchFormDefinition: ShowMessage((L)"No such form definition!", HtmlMessageType.Warning); return(RedirectToAction("forms", "project", new { projectID = model.ProjectID })); case UpdateFormDefinitionStatus.PermissionDenied: ShowMessage((L)"You can't update this form!", HtmlMessageType.Warning); return(RedirectToAction("forms", "project", new { projectID = model.ProjectID })); } } } return(View(model)); }
public ActionResult OpenForm(int formId) { FormService formService = new FormService(); var form = formService.get(formId); return(View(form)); }
public virtual async Task <IActionResult> Index() { ViewData["Title"] = StringLocalizer["Contact"]; var isConfigured = await FormService.IsConfigured(); if (!isConfigured) { return(View("NotConfigured")); } var model = new MessageViewModel(); var form = await FormService.GetFormSettings(); model.FormId = form.Id; if (!HttpContext.User.Identity.IsAuthenticated) { var captchaKeys = await FormService.GetRecaptchaKeys(); model.RecaptchaPublicKey = captchaKeys.PublicKey; model.UseInvisibleCaptcha = captchaKeys.Invisible; } else { await FormPopulator.Prepopulate(model, User); } return(View(model)); }
public virtual JObject GetFormStateInfo(HttpContext context) { YZRequest request = new YZRequest(context); string app = request.GetString("app"); string key = request.GetString("key", null); string formstate = request.GetString("formstate", null); FormApplication formApplication; FormState formState; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); formApplication = FormApplication.Open(cn, app); formState = FormService.GetFormStateBasicInfo(cn, app, formstate); } JObject rv = new JObject(); rv[YZJsonProperty.success] = true; rv["appShortName"] = formApplication.Name; rv["formstate"] = formState.Name; rv["token"] = YZSecurityHelper.GenFormApplicationToken(app, key, formState.Name); rv["showSaveButton"] = formState.ShowSaveButton; rv["validationGroup"] = formState.ValidationGroup; rv["url"] = YZUtility.GetFormRedirectUrl(formApplication.Form).ToString(); return(rv); }
public AssessmentCarouselPage(string selectedItem) { _friendlyName = selectedItem; ToolbarItem saveToolbarItem = new ToolbarItem(); saveToolbarItem.Text = "Save"; saveToolbarItem.Clicked += SaveToolbarItem_Clicked; ToolbarItems.Add(saveToolbarItem); FormService formService = new FormService(); //Get Form Instance var formInstance = formService.GetFormInstance(AppDataWallet.SelectedAssessmentMetadata.AssessmentTrackingNumber.ToString(), selectedItem); _validationSchema = formInstance.ValidationSchema; //generate Layout Dynamically //Set static FormData FormDataService.FormData = formInstance.FormData;; List <ContentPage> contentPages = formService.GenerateCarouselLayout(formInstance.FormModelView, formInstance.FormData); foreach (ContentPage page in contentPages) { Children.Add(page); } }
public void Run() { var service = XrmCommand.GetService(); var core = new FormService(service); core.DeactivateEntityForms(FormIds); }
public ActionResult Details(int id) { var formElements = FormService.FindById(id); ViewBag.FormId = id; return(View(formElements)); }
internal void AddConfiguration(FormService formService, CoreService core, IExecutable executable, MethodProvider methodProvider) { _core = core; _formService = formService; _executable = executable; _processorService = _core.GetProcessors(); _processorCreateService = _core.GetCreateService(); Methods = methodProvider; }
/// /// <param name="formService"></param> /// <param name="storeService"></param> /// <param name="variableService"></param> /// <param name="labelService"></param> public FormController(FormService formService, FormStoreService storeService, //FormVariableService variableService, LabelService labelService) { _formService = formService; _StoreService = storeService; //_VariableService = variableService; _labelService = labelService; }
public void Post(Bridge model) { if (queryService.Query(model.InstanceID) == null) { CommandBus.Dispatch <Bridge>(new CreateBridge(), model); } FormService.Execute(model.CategoryID, model.InstanceID); }
public WebApiController(UserService userService, FormService formService, SystemService systemService, OrganizationService organizationService, AuditLogService auditLog) { _userService = userService; _formService = formService; _systemService = systemService; _organizationSevice = organizationService; _auditLog = auditLog; }
public void FormServiceGetListShouldReturnListOfForms() { // Arrange var unitOfWorkMock = new Mock<IUnitOfWork>(MockBehavior.Strict); var expectedData = this.GetSampleData().OrderBy(f => f.Title).ToArray(); unitOfWorkMock.Setup(u => u.Query<Form>()).Returns(expectedData.AsQueryable()); var service = new FormService(unitOfWorkMock.Object); // Act var actual = service.GetList(); CollectionAssert.AreEqual(expectedData, actual); }
public void FormServiceGetAllShouldReturnAllForms() { // Arrange var expected = this.GetSampleData(); var unitOfWork = this.SetupUnitOfWork(expected); var service = new FormService(unitOfWork.Object); // Act var actual = service.GetAll(); // Assert CollectionAssert.AreEqual(expected, actual); }
public void FormServiceGetShouldRetrieveSingleForm() { // Arrange var sampleData = this.GetSampleData(); Form expected = sampleData[1]; // Arbritary Value var unitOfWork = this.SetupUnitOfWork(sampleData); var service = new FormService(unitOfWork.Object); // Act var actual = service.Get(expected.Id); // Assert Assert.IsNotNull(actual); Assert.AreSame(expected, actual); }
public PrFieldGridView(PrForm form, string fieldKey, string actionKey, FormService formService, bool clientSide, string tableLabel) : base(form, fieldKey) { ActionKey = actionKey; ClientSide = clientSide; if (ClientSide) { Data = formService.GetDataTableAll(actionKey, null); } else { Data = formService.GetDataTableZero(actionKey, null); } MergeWithNext = false; FieldLabel = ""; TableLabel = new Escaper().EscapeJavaScript(tableLabel); MultipleSelection = false; Required = false; }
public PrFieldGridView AddFieldGridView(string fieldKey, string actionKey, FormService formService, bool clientSide, string tableLabel) { return Form.AddFieldGridView(fieldKey, actionKey, formService, clientSide, tableLabel); }