public override bool IsAuthorized(AuthFilterContext context) { if (DomainUtility.IsTestEnvironment) { return(true); } using (APIAccessService apiAccessService = new APIAccessService()) { //when a client is calling main api ,they have to put token,which is password, in header named token if (context.ActionContext.Request.Headers.Contains("token")) { return(apiAccessService.HasAccess(ApiUtility.GetIPAddress(), context.ActionContext.Request.Headers.GetValues("token").FirstOrDefault())); } else { if (AccessUtility.CalledByLocalSA(HttpContext.Current.Request)) { //it is called from single action module in same server with same ip. return(true); } else { //when bpms user panel is calling engine api,every request should have formToken in its parameters. string formToken = context.ActionContext.RequestContext.Url.Request.GetHttpContext().Request.QueryString[FormTokenUtility.FormToken]; return(FormTokenUtility.ValidateFormToken(formToken, HttpContext.Current.Session.SessionID)); } } } }
public override bool IsAuthorized(AuthFilterContext context) { using (APIAccessService apiAccessService = new APIAccessService()) { return(DomainUtility.IsTestEnvironment ? true : FormTokenUtility.ValidateFormToken(context.ActionContext.RequestContext.Url.Request.GetHttpContext().Request.QueryString[FormTokenUtility.FormToken], HttpContext.Current.Session.SessionID)); } }
public System.Net.Http.HttpResponseMessage PostData(string controller, string action, string formToken = "") { if (FormTokenUtility.ValidateFormToken(formToken, HttpContext.Current.Session.SessionID)) { SingleActionSettingDTO setting = new SingleActionSettingDTO(new HttpRequestWrapper(HttpContext.Current.Request), base.PortalSettings.PortalId); //when calling main api from client application, there is no need to pass formToken to main bpms api. string url = UrlUtility.GetApiUrl(setting.WebApiAddress, action, controller, "", this.GetParameters().ToArray()); return(ApiUtility.PostData(url, QueryModel.GetFormDataList(this.MyRequest).ToList(), setting.WebServicePass, base.UserInfo.Username, ApiUtility.GetIPAddress(), HttpContext.Current.Session.SessionID, FormTokenUtility.GetIsEncrypted(formToken, HttpContext.Current.Session.SessionID))); } else { throw new System.Web.Http.HttpResponseException(System.Net.HttpStatusCode.Unauthorized); } }
public BpmsCartableApiControlBase() { if (this.MyRequest.Headers.AllKeys.Contains("clientIp")) { this.ClientIp = this.MyRequest.Headers["clientIp"].ToStringObj(); } else { this.ClientIp = ApiUtility.GetIPAddress(); } using (APIAccessService apiAccessService = new APIAccessService()) { //api call using toke header,which is password, or formToken ,which is a parameter like antiforgerytoken cosist of sessionId and mainDynamicFormId encripted by sessionId. if (!this.MyRequest.Headers.AllKeys.Contains("token")) { this.ClientUserName = DomainUtility.IsTestEnvironment ? "bpms_expert" : base.UserInfo.Username; this.ClientFormToken = this.MyRequest.QueryString[FormTokenUtility.FormToken].ToStringObj(); this.ClientId = HttpContext.Current.Session.SessionID; this.ApiSessionId = DomainUtility.CreateApiSessionID(this.ClientId, this.ClientIp); this.IsEncrypted = FormTokenUtility.GetIsEncrypted(this.ClientFormToken, this.ClientId); } else { if (this.MyRequest.Headers.AllKeys.Contains("userName")) { this.ClientUserName = this.MyRequest.Headers["userName"].ToStringObj(); } this.ClientId = this.MyRequest.Headers["clientId"].ToStringObj(); this.ApiSessionId = DomainUtility.CreateApiSessionID(this.ClientId, this.ClientIp);; //set ApiSessionID if (!apiAccessService.HasAccess(ApiUtility.GetIPAddress(), this.MyRequest.Headers.GetValues("token").FirstOrDefault())) { throw new Exception("You are not authorized to access this application."); } this.IsEncrypted = this.MyRequest.Headers["isEncrypted"].ToStringObj() == "1"; } } }
public System.Net.Http.HttpResponseMessage GetData(string controller, string action, string formToken = "") { if (FormTokenUtility.ValidateFormToken(formToken, HttpContext.Current.Session.SessionID)) { SingleActionSettingDTO setting = new SingleActionSettingDTO(new HttpRequestWrapper(HttpContext.Current.Request), base.PortalSettings.PortalId); //when calling main bpms api from client application, there is no need to pass formToken to main bpms api. string url = UrlUtility.GetApiUrl(setting.WebApiAddress, action, controller, "", this.GetParameters().ToArray()); var result = ApiUtility.GetData(url, setting.WebServicePass, base.UserInfo.Username, ApiUtility.GetIPAddress(), HttpContext.Current.Session.SessionID, FormTokenUtility.GetIsEncrypted(formToken, HttpContext.Current.Session.SessionID)); /* * In ReportEngine.cs response would be flushed and as a result sessionID will be rewrite with server * session ID which is different with singleAction sessionID because it sends data using api to server * and therefore it must rewrite sessionid there in case user call report or download a file. */ SessionIDManager Manager = new SessionIDManager(); Manager.SaveSessionID(HttpContext.Current, HttpContext.Current.Session.SessionID, out bool redirected, out bool IsAdded); return(result); } else { throw new System.Web.Http.HttpResponseException(System.Net.HttpStatusCode.Unauthorized); } }
public object GetPreviewForm(Guid FormId) { using (DynamicFormService dynamicFormService = new DynamicFormService()) { try { EngineFormModel engineForm = dynamicFormService.PreviewForm(FormId, base.userName); engineForm.SetUrls(string.Empty, string.Empty, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(HttpContext.Current.Session.SessionID, engineForm?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, engineForm?.FormModel?.IsEncrypted ?? false)); return(new { Model = engineForm, Result = true, }); } catch (Exception ex) { return(new { MessageList = new List <PostMethodMessage>() { new PostMethodMessage(ex.ToString(), DisplayMessageType.error) }, Result = false }); } } }
public object GetPopUp(Guid threadTaskID, Guid formID) { using (ThreadTaskService threadTaskService = new ThreadTaskService()) { using (DynamicFormService dynamicFormService = new DynamicFormService()) { sysBpmsThreadTask threadTask = threadTaskService.GetInfo(threadTaskID, new string[] { nameof(sysBpmsThreadTask.Thread) }); using (ProcessEngine ProcessEngine = new ProcessEngine(new EngineSharedModel(threadTask.ThreadID, threadTask.Thread.ProcessID, this.MyRequest.GetList(dynamicFormService.GetInfo(formID).ConfigXmlModel.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId))) { GetTaskFormResponseModel responseVM = ProcessEngine.GetForm(threadTaskID, formID); if (responseVM.EngineFormModel != null) { string popUpUrl = UrlUtility.GetCartableApiUrl(base.MyRequest, base.PortalSettings.DefaultPortalAlias, nameof(CartableThreadController.GetPopUp), nameof(CartableThreadController), "", "threadTaskID=" + threadTaskID); string postUrl = UrlUtility.GetCartableApiUrl(base.MyRequest, base.PortalSettings.DefaultPortalAlias, nameof(CartableThreadController.PostPopUp), nameof(CartableThreadController), "", UrlUtility.GetParamsAsArray(new HttpRequestWrapper(base.MyRequest), new string[] { $"formID={formID}", $"threadTaskID={threadTaskID}", $"stepID={responseVM.EngineFormModel.FormModel.StepID}" }).ToArray()); responseVM.EngineFormModel.SetUrls(popUpUrl, postUrl, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false)); } return(new { Model = responseVM?.EngineFormModel, MessageList = responseVM?.ListMessageModel.Select(c => new PostMethodMessage(c.Message, c.DisplayMessageType)), RedirectUrl = base.GetRedirectUrl(responseVM?.RedirectUrlModel), Result = true, }); } } } }
public object GetThreadDetail(Guid ThreadID) { using (ThreadService threadService = new ThreadService()) { using (ThreadTaskService threadTaskService = new ThreadTaskService()) { using (DynamicFormService dynamicFormService = new DynamicFormService()) { ThreadDetailDTO threadDetailDTO = new ThreadDetailDTO( threadService.GetInfo(ThreadID, new string[] { nameof(sysBpmsThread.User), nameof(sysBpmsThread.Process) }), threadTaskService.GetList(ThreadID, (int)sysBpmsTask.e_TypeLU.UserTask, null, null, new string[] { $"{nameof(sysBpmsThreadTask.Task)}.{nameof(sysBpmsThreadTask.Task.Element)}", nameof(sysBpmsThreadTask.User) }).Select(c => new ThreadHistoryDTO(c)).ToList()); List <sysBpmsDynamicForm> listForms = dynamicFormService.GetList(threadDetailDTO.ProcessID, null, null, "", true, null); using (ProcessEngine processEngine = new ProcessEngine(new EngineSharedModel(ThreadID, threadDetailDTO.ProcessID, this.MyRequest.GetList(false, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId))) { foreach (var item in listForms) { var result = processEngine.GetContentHtmlByFormID(item.ID, true); EngineFormModel engineFormModel = new EngineFormModel(result.FormModel, ThreadID, null, threadDetailDTO.ProcessID); string popUpUrl = UrlUtility.GetCartableApiUrl(base.MyRequest, base.PortalSettings.DefaultPortalAlias, nameof(CartableThreadController.GetPopUp), nameof(CartableThreadController), ""); engineFormModel.SetReadOnlyUrls(popUpUrl, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(base.ApiSessionId, engineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, engineFormModel?.FormModel?.IsEncrypted ?? false)); threadDetailDTO.ListOverviewForms.Add(engineFormModel); } } return(threadDetailDTO); } } } }
public object GetIndex(Guid?threadTaskID = null, Guid?stepID = null, Guid?applicationPageId = null, Guid?formId = null, Guid?threadId = null) { SingleActionSettingDTO setting = base.GetSetting(); try { if (setting.ProcessID.HasValue) { #region .:: Thread ::. //If bpms engine is in different domain. EngineProcessProxy engineProcessProxy = null; if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { engineProcessProxy = new EngineProcessProxy(setting.WebApiAddress, setting.WebServicePass, base.ClientUserName, ApiUtility.GetIPAddress(), base.ApiSessionId, this.IsEncrypted); } if (!threadTaskID.HasValue && !threadId.HasValue) { //begin Process BeginTaskResponseModel beginTaskResponseVM = null; //If bpms engine is in different domain. if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { beginTaskResponseVM = engineProcessProxy.BeginTask(setting.ProcessID.Value, base.MyRequest.GetList(false, string.Empty).ToList()); } else { beginTaskResponseVM = this.BeginTask(setting.ProcessID.Value); } threadTaskID = beginTaskResponseVM.ThreadTaskID; if (!beginTaskResponseVM.Result) { return(new { MessageList = new List <PostMethodMessage>() { new PostMethodMessage(beginTaskResponseVM.Message, DisplayMessageType.error) }, Result = false, setting.ShowCardBody }); } } if (!threadTaskID.HasValue && threadId.HasValue) { //If bpms engine is in different domain. if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { threadTaskID = engineProcessProxy.GetAccessibleThreadTasks(threadId.Value).FirstOrDefault(); } else { threadTaskID = this.GetAccessibleThreadTasks(threadId.Value).FirstOrDefault(); } if (!threadTaskID.HasValue || threadTaskID == Guid.Empty) { ThreadDetailDTO threadDetailDTO = null; //show history //If bpms engine is in different domain. if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { threadDetailDTO = engineProcessProxy.GetThreadDetails(threadId.Value); } else { threadDetailDTO = this.GetThreadDetails(threadId.Value); } return(new { ThreadDetailModel = threadDetailDTO, Result = true, setting.ShowCardBody }); } } GetTaskFormResponseModel responseVM = null; //If it must load end process form. if (formId.HasValue) { //If bpms engine is in different domain. if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { responseVM = engineProcessProxy.GetForm(threadTaskID.Value, formId.Value, base.MyRequest.GetList(false, string.Empty).ToList(), false); } else { //if engine is in same domain, call it directly. using (ThreadTaskService threadTaskService = new ThreadTaskService()) { sysBpmsThreadTask threadTask = new ThreadTaskService().GetInfo(threadTaskID.Value, new string[] { nameof(sysBpmsThreadTask.Thread) }); using (ProcessEngine ProcessEngine = new ProcessEngine(new EngineSharedModel(threadTask.ThreadID, threadTask.Thread.ProcessID, base.MyRequest.GetList(this.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId))) responseVM = ProcessEngine.GetForm(threadTask.ID, formId.Value, false); } } if (responseVM.EngineFormModel != null) { responseVM.EngineFormModel.FormModel.HasSubmitButton = true; } } else { if (threadTaskID.HasValue) { //If bpms engine is in different domain. if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { engineProcessProxy.GetTaskForm(threadTaskID.Value, stepID, base.MyRequest.GetList(false, string.Empty).ToList()); } else { //If engine is in same domain, call it directly. using (ThreadTaskService threadTaskService = new ThreadTaskService()) { sysBpmsThreadTask threadTask = new ThreadTaskService().GetInfo(threadTaskID.Value, new string[] { nameof(sysBpmsThreadTask.Thread) }); using (ProcessEngine ProcessEngine = new ProcessEngine(new EngineSharedModel(threadTask.ThreadID, threadTask.Thread.ProcessID, base.MyRequest.GetList(this.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId))) responseVM = ProcessEngine.GetTaskForm(threadTaskID.Value, stepID); } } } else { responseVM = null; } } if (responseVM?.EngineFormModel != null) { string popUpUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.GetPopUp), nameof(SingleActionWorkerController), "", "threadTaskID=" + threadTaskID); string postUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.PostIndex), nameof(SingleActionWorkerController), "", UrlUtility.GetParamsAsArray(new HttpRequestWrapper(base.MyRequest), new string[] { $"threadTaskID={threadTaskID}", $"stepID={responseVM.EngineFormModel.FormModel.StepID}" }).ToArray()); //If bpms engine is in different domain. if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { responseVM.EngineFormModel.SetUrlsForSingleAction(base.PortalSettings.DefaultPortalAlias, new HttpRequestWrapper(base.MyRequest), popUpUrl, postUrl, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false), base.TabModuleID); } else { responseVM.EngineFormModel.SetUrls(popUpUrl, postUrl, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false)); } return(new { Model = responseVM?.EngineFormModel, MessageList = responseVM?.ListMessageModel.Select(c => new PostMethodMessage(c.Message, c.DisplayMessageType)), RedirectUrl = base.GetRedirectUrl(responseVM?.RedirectUrlModel), Result = true, setting.ShowCardBody }); } else { return new { MessageList = new List <PostMethodMessage>() { new PostMethodMessage("Error in getting information", DisplayMessageType.error) }, Result = false, setting.ShowCardBody } }; #endregion } else { #region .:: Application Page ::. applicationPageId = applicationPageId ?? setting.ApplicationPageID; GetFormResponseModel responseVM = null; //if bpms engine is in different domain if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { EngineApplicationProxy engineApplicationProxy = new EngineApplicationProxy(setting.WebApiAddress, setting.WebServicePass, base.ClientUserName, ApiUtility.GetIPAddress(), base.ApiSessionId, this.IsEncrypted); responseVM = engineApplicationProxy.GetForm(applicationPageId, null, base.MyRequest.GetList(false, string.Empty).ToList()); } else { EngineSharedModel engineSharedModel = new EngineSharedModel(applicationPageId.Value, base.MyRequest.GetList(this.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId); using (ApplicationPageEngine applicationPageEngine = new ApplicationPageEngine(engineSharedModel)) responseVM = applicationPageEngine.GetForm(); } if (responseVM?.EngineFormModel != null) { string popUpUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.GetPopUp), nameof(SingleActionWorkerController), ""); string postUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.PostIndex), nameof(SingleActionWorkerController), "", UrlUtility.GetParamsAsArray(new HttpRequestWrapper(base.MyRequest), new string[] { $"applicationPageId={applicationPageId}" }).ToArray()); if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { responseVM.EngineFormModel.SetUrlsForSingleAction(base.PortalSettings.DefaultPortalAlias, new HttpRequestWrapper(base.MyRequest), popUpUrl, postUrl, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false), base.TabModuleID); } else { responseVM.EngineFormModel.SetUrls(popUpUrl, postUrl, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false)); } return(new { Model = responseVM?.EngineFormModel, MessageList = responseVM?.ListMessageModel.Select(c => new PostMethodMessage(c.Message, c.DisplayMessageType)), RedirectUrl = base.GetRedirectUrl(responseVM?.RedirectUrlModel), Result = true, setting.ShowCardBody }); } else { return new { MessageList = new List <PostMethodMessage>() { new PostMethodMessage("Error while getting information", DisplayMessageType.error) }, Result = false, setting.ShowCardBody } }; #endregion } } catch { return(new { MessageList = new List <PostMethodMessage>() { new PostMethodMessage("Setting is not complete", DisplayMessageType.error) }, Result = false, setting.ShowCardBody }); } }
public object GetPopUp(Guid formID, Guid?threadTaskID = null) { SingleActionSettingDTO setting = base.GetSetting(); if (setting.ProcessID.HasValue) { #region .:: Thread ::. GetTaskFormResponseModel responseVM = null; //If bpms engine is in different domain. if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { responseVM = new EngineProcessProxy(setting.WebApiAddress, setting.WebServicePass, base.ClientUserName, ApiUtility.GetIPAddress(), base.ApiSessionId, this.IsEncrypted).GetForm(threadTaskID.Value, formID, base.MyRequest.GetList(false, string.Empty).ToList()); } else { //if engine is in same domain, call it directly. using (ThreadTaskService threadTaskService = new ThreadTaskService()) { sysBpmsThreadTask threadTask = new ThreadTaskService().GetInfo(threadTaskID.Value, new string[] { nameof(sysBpmsThreadTask.Thread) }); using (ProcessEngine ProcessEngine = new ProcessEngine(new EngineSharedModel(threadTask.ThreadID, threadTask.Thread.ProcessID, base.MyRequest.GetList(this.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId))) responseVM = ProcessEngine.GetForm(threadTask.ID, formID, null); } } if (responseVM.EngineFormModel != null) { string popUpUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.GetPopUp), nameof(SingleActionWorkerController), "", "threadTaskID=" + threadTaskID); string postUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.PostPopUp), nameof(SingleActionWorkerController), "", UrlUtility.GetParamsAsArray(new HttpRequestWrapper(base.MyRequest), new string[] { $"formID={formID}", $"threadTaskID={threadTaskID}", $"stepID={responseVM.EngineFormModel.FormModel.StepID}" }).ToArray()); if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { responseVM.EngineFormModel.SetUrlsForSingleAction(base.PortalSettings.DefaultPortalAlias, new HttpRequestWrapper(base.MyRequest), popUpUrl, postUrl, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false), base.TabModuleID); } else { responseVM.EngineFormModel.SetUrls(popUpUrl, postUrl, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false)); } } return(new { Model = responseVM?.EngineFormModel, MessageList = responseVM?.ListMessageModel.Select(c => new PostMethodMessage(c.Message, c.DisplayMessageType)), RedirectUrl = base.GetRedirectUrl(responseVM?.RedirectUrlModel), Result = true, }); #endregion } else { #region .:: Application ::. GetFormResponseModel responseVM = null; //if bpms engine is in different domain if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { EngineApplicationProxy engineApplicationProxy = new EngineApplicationProxy(setting.WebApiAddress, setting.WebServicePass, base.ClientUserName, ApiUtility.GetIPAddress(), base.ApiSessionId, this.IsEncrypted); responseVM = engineApplicationProxy.GetForm(null, formID, new HttpRequestWrapper(base.MyRequest).GetList(false, string.Empty).ToList()); } else { using (DynamicFormService dynamicFormService = new DynamicFormService()) { EngineSharedModel engineSharedModel = new EngineSharedModel(dynamicFormService.GetInfo(formID).ApplicationPageID.Value, base.MyRequest.GetList(false, string.Empty).ToList(), base.ClientUserName, base.ApiSessionId); using (ApplicationPageEngine applicationPageEngine = new ApplicationPageEngine(engineSharedModel)) responseVM = applicationPageEngine.GetForm(); } } if (responseVM.EngineFormModel != null) { string popUpUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.GetPopUp), nameof(SingleActionWorkerController), ""); string postUrl = UrlUtility.GetSingleActionApiUrl(base.MyRequest, base.TabModuleID, base.PortalSettings.DefaultPortalAlias, nameof(SingleActionWorkerController.PostPopUp), nameof(SingleActionWorkerController), "", UrlUtility.GetParamsAsArray(new HttpRequestWrapper(base.MyRequest), new string[] { $"applicationPageId={responseVM.EngineFormModel.ApplicationID}" }).ToArray()); if (!string.IsNullOrWhiteSpace(setting.WebApiAddress)) { responseVM.EngineFormModel.SetUrlsForSingleAction(base.PortalSettings.DefaultPortalAlias, new HttpRequestWrapper(base.MyRequest), popUpUrl, postUrl, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false), base.TabModuleID); } else { responseVM.EngineFormModel.SetUrls(popUpUrl, postUrl, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false)); } } return(new { Model = responseVM?.EngineFormModel, MessageList = responseVM?.ListMessageModel.Select(c => new PostMethodMessage(c.Message, c.DisplayMessageType)), RedirectUrl = base.GetRedirectUrl(responseVM?.RedirectUrlModel), Result = true, }); #endregion } }
public ActionResult Settings() { var settings = new SingleActionSettingDTO(base.PortalSettings.PortalId, ModuleContext.Configuration.ModuleSettings); try { if (!string.IsNullOrWhiteSpace(settings.WebApiAddress)) { settings.ProcessName = settings.ProcessID.HasValue ? new EngineProcessProxy(settings.WebApiAddress, settings.WebServicePass, base.User.Username, ApiUtility.GetIPAddress(), base.Session.SessionID, false).GetInfo(settings.ProcessID.Value)?.Name : ""; settings.ProcessEndFormName = settings.ProcessEndFormID.HasValue ? new EngineFormProxy(settings.WebApiAddress, settings.WebServicePass, base.User.Username, ApiUtility.GetIPAddress(), base.Session.SessionID, false).GetInfo(settings.ProcessEndFormID.Value)?.Name : "";; settings.ApplicationName = settings.ApplicationPageID.HasValue ? new EngineApplicationProxy(settings.WebApiAddress, settings.WebServicePass, base.User.Username, ApiUtility.GetIPAddress(), base.Session.SessionID, false).GetInfo(settings.ApplicationPageID.Value)?.Name : ""; } else { if (settings.ProcessID.HasValue) { using (ProcessService processService = new ProcessService()) settings.ProcessName = processService.GetInfo(settings.ProcessID.Value).Name; } if (settings.ProcessEndFormID.HasValue) { using (DynamicFormService dynamicFormService = new DynamicFormService()) settings.ProcessEndFormName = dynamicFormService.GetInfo(settings.ProcessEndFormID.Value).Name; } if (settings.ApplicationPageID.HasValue) { using (DynamicFormService dynamicFormService = new DynamicFormService()) settings.ApplicationName = dynamicFormService.GetInfoByPageID(settings.ApplicationPageID.Value).Name; } } if (string.IsNullOrWhiteSpace(settings.ApplicationName) && string.IsNullOrWhiteSpace(settings.ProcessName)) { settings.ProcessID = null; settings.ApplicationPageID = null; } } catch { } if (!string.IsNullOrWhiteSpace(settings.WebApiAddress)) { ViewBag.ApplicationPageUrl = ApiUtility.GetGeneralApiUrl(base.Request, base.ModuleContext.TabModuleId, base.PortalSettings.DefaultPortalAlias, "GetList", "EngineApplication", FormTokenUtility.GetFormToken(base.Session.SessionID, Guid.Empty, false), true); ViewBag.ProcessFormUrl = ApiUtility.GetGeneralApiUrl(base.Request, base.ModuleContext.TabModuleId, base.PortalSettings.DefaultPortalAlias, "GetList", "EngineForm", FormTokenUtility.GetFormToken(base.Session.SessionID, Guid.Empty, false), true); ViewBag.ProcessUrl = ApiUtility.GetGeneralApiUrl(base.Request, base.ModuleContext.TabModuleId, base.PortalSettings.DefaultPortalAlias, "GetList", "EngineProcess", FormTokenUtility.GetFormToken(base.Session.SessionID, Guid.Empty, false), true); } else { ViewBag.ApplicationPageUrl = UrlUtility.GetApiUrl(base.Request, base.PortalSettings.DefaultPortalAlias, "GetList", "EngineApplication", FormTokenUtility.GetFormToken(base.Session.SessionID, Guid.Empty, false)); ViewBag.ProcessFormUrl = UrlUtility.GetApiUrl(base.Request, base.PortalSettings.DefaultPortalAlias, "GetList", "EngineForm", FormTokenUtility.GetFormToken(base.Session.SessionID, Guid.Empty, false)); ViewBag.ProcessUrl = UrlUtility.GetApiUrl(base.Request, base.PortalSettings.DefaultPortalAlias, "GetList", "EngineProcess", FormTokenUtility.GetFormToken(base.Session.SessionID, Guid.Empty, false)); } ViewBag.Url = base.ActivePage.FullUrl + "/controller/Settings/action/UpdatePass"; return(View(settings)); }
public object GetPopUp(Guid formID) { using (DynamicFormService dynamicFormService = new DynamicFormService()) { sysBpmsDynamicForm dynamicForm = dynamicFormService.GetInfo(formID); Guid applicationId = dynamicForm.ApplicationPageID.Value; EngineSharedModel engineSharedModel = new EngineSharedModel(applicationId, base.MyRequest.GetList(this.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId); using (ApplicationPageEngine applicationPageEngine = new ApplicationPageEngine(engineSharedModel)) { GetFormResponseModel responseVM = applicationPageEngine.GetForm(); if (responseVM.EngineFormModel != null) { string popUpUrl = UrlUtility.GetCartableApiUrl(base.MyRequest, base.PortalSettings.DefaultPortalAlias, nameof(CartablePageController.GetPopUp), nameof(CartablePageController), ""); string postUrl = UrlUtility.GetCartableApiUrl(base.MyRequest, base.PortalSettings.DefaultPortalAlias, nameof(CartablePageController.PostPopUp), nameof(CartablePageController), "", UrlUtility.GetParamsAsArray(new HttpRequestWrapper(base.MyRequest), new string[] { $"applicationPageId={applicationId}" }).ToArray()); responseVM.EngineFormModel.SetUrls(popUpUrl, postUrl, new HttpRequestWrapper(base.MyRequest), base.PortalSettings.DefaultPortalAlias, FormTokenUtility.GetFormToken(base.ApiSessionId, responseVM?.EngineFormModel?.FormModel?.ContentHtml?.DynamicFormID ?? Guid.Empty, responseVM?.EngineFormModel?.FormModel?.IsEncrypted ?? false)); } return(new { Model = responseVM?.EngineFormModel, MessageList = responseVM?.ListMessageModel.Select(c => new PostMethodMessage(c.Message, c.DisplayMessageType)), RedirectUrl = base.GetRedirectUrl(responseVM?.RedirectUrlModel), Result = true, }); } } }