private mvc.ActionResult CreateDocumentAndRedirect(ProxyAuthRequestResult req, JObject jArgs, Guid instanceId) { var fSvc = SvcBldr.FormsV2(); var cdsr = fSvc.CreateDocument(new FormDocumentCreateArgs { IsTemporary = true, FormTemplateId = new Guid(jArgs["FormTemplateId"].Value <string>()) //Convert failure when .Value<Guid> is used. }); ExceptionsML.Check(cdsr.Error); var vrId = Functions.NewSeq(); jArgs["DocumentVersionId"] = cdsr.Result.Version.Id; jArgs["FormRequestId"] = req.Id; jArgs["ViewRequestId"] = vrId; jArgs["UseRecaptcha"] = false; ExceptionsML.Check(cdsr.Error); var secSvc = SvcBldr.SecurityV2(); var viewerCPR = new ProxyAuthRequest { Id = vrId, ExpirationType = ExpirationMode.CustomCount, ExpirationValue = "1", //Expires as soon as the form is submitted. RequestType = ProxyAuthRequestType.AccessViewer, Token = req.Token, Parameters = JsonConvert.SerializeObject(jArgs) }; var cprSR = secSvc.CreateProxyRequest(viewerCPR); ExceptionsML.Check(cprSR.Error); var fsc = GuestSessionCookie.Create(Response, cprSR.Result, instanceId, req.Id); return(RedirectToAction("Index", fsc)); }
public JsonResult GetAllData() { var clientV2 = SvcBldr.AdministrationV2(); var freezes = clientV2.GetAllFreezes(); if (freezes != null && freezes.Error != null) { return(Result(null, freezes.Error, JsonRequestBehavior.AllowGet)); } var fList = freezes.Result.ToList(); fList.Insert(0, new Freeze() { Id = Guid.Empty, Name = Constants.i18n("newTitle"), Active = true }); var srRecCats = clientV2.GetAllRecordCategories(); if (srRecCats.Error != null) { return(Result(null, srRecCats.Error, JsonRequestBehavior.AllowGet)); } var rcats = srRecCats.Result.ToList(); rcats.Insert(0, new RecordCategory() { Id = Guid.Empty, Name = Constants.i18n("newTitle") }); var scRC = SvcBldr.SecurityV2().GetSecurityClassSlims(); if (scRC.Error != null) { return(Result(null, scRC.Error, JsonRequestBehavior.AllowGet)); } var customFields = SvcBldr.CustomFieldV2().GetCustomFields(); if (customFields.Error != null) { return(Result(null, customFields.Error, JsonRequestBehavior.AllowGet)); } var dateFields = customFields.Result.Where(c => c.Type == CFTypeCode.DateTime) .Select(f => new SlimEntity(f.Id, f.Name, PermissionType.NotSet)).ToList(); dateFields.Insert(0, new SlimEntity(DateFieldConstants.Created, Constants.i18n("createdOn"), PermissionType.NotSet)); dateFields.Insert(1, new SlimEntity(DateFieldConstants.Modified, Constants.i18n("modifiedOn"), PermissionType.NotSet)); dateFields.Insert(2, new SlimEntity(DateFieldConstants.Accessed, Constants.i18n("accessedOn"), PermissionType.NotSet)); return(Result(new { f = fList.Where(f => f.Active), rcs = rcats, sc = scRC.Result, cf = dateFields }, null, JsonRequestBehavior.AllowGet)); }
public mvc.ActionResult ProcessDownloadRequestResult() { Guid id = new Guid(Request.QueryString["id"]); Guid instanceId = new Guid(Request.QueryString["instanceId"]); var password = Request.QueryString["password"]; var fileId = Request.QueryString["fileId"]; SR <ProxyAuthRequestResult> sr = null; try { var client = SvcBldr.SecurityV2(); sr = client.GetProxyRequest(new GetProxyRequestArgs { Id = id, InstanceId = instanceId, Password = password }); ExceptionsML.Check(sr.Error); BaseToken = sr.Result.Token; var ip = GetIP(); var server = GetServerURI(); var sb = new ServiceBuilder(server, BaseToken, ip); var fileName = Path.GetFileName(fileId); var mimeType = fileId.GetMIMEType(); var ftSvc = sb.FileTransferV2(); var bytes = RemoteFileHandler.DownloadFile(fileId, ftSvc); return(File(bytes, mimeType, fileName)); } catch (LoginRequiredException lex) { if (lex.Reason == LoginRequiredReason.ProxyMoveInProgress) { var proxyUrl = Functions.GetAuthenticationProxyUrl(); var domain = Functions.GetProxyCookieDomain(); var url = Functions.CombineUri(proxyUrl, "Guest"); url += String.Format("?RequestId={0}&InstanceId={1}&auto={2}", id, instanceId, String.IsNullOrEmpty(password)); return(View("../Home/Oops", new ExceptionsML { Message = url, Type = LoginRequiredReason.ProxyMoveInProgress.ToString() })); } return(View("../Home/Oops", ExceptionsML.GetExceptionML(lex))); } catch (RecordNotFoundException rex) { return(View("../Home/Oops", new ExceptionsML { Message = Constants.i18n("invalidGuestDownloadRequest"), Type = rex.GetType().ToString() })); } catch (Exception ex) { return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex))); } }
private mvc.ActionResult RedirectToLastSession(GuestSessionCookie fsc) { var client = SvcBldr.SecurityV2(); var sr = client.GetProxyRequest(new GetProxyRequestArgs { Id = fsc.RequestId, InstanceId = fsc.InstanceId, DontGetToken = true }); if (sr.Error != null) { if (sr.Error.Type == typeof(ProxyAuthRequestExpiredException).ToString()) { fsc.Delete(Request, Response); return(null); } ExceptionsML.Check(sr.Error); } return(RedirectToAction("Index", fsc)); }
/// <summary> /// fetches all groups and users /// </summary> /// <returns></returns> public JsonResult GetAllRoleData() { var client = SvcBldr.SecurityV2(); var srRoles = client.GetAllRoles(); if (srRoles.Error != null) { return(Result(null, srRoles.Error)); } var ldapClient = SvcBldr.LDAPV2(); var srldaps = ldapClient.GetSlim(); if (srldaps.Error != null) { return(Result(null, srldaps.Error)); } return(Result(new { r = srRoles.Result, l = srldaps.Result }, srldaps.Error, JsonRequestBehavior.AllowGet)); }
public mvc.ActionResult ProcessDownloadRequest() { Guid id = new Guid(Request.QueryString["id"]); Guid instanceId = new Guid(Request.QueryString["instanceId"]); var password = Request.QueryString["password"]; var connectionId = Request.QueryString["connectionId"]; SR <ProxyAuthRequestResult> sr = null; try { var client = SvcBldr.SecurityV2(); sr = client.GetProxyRequest(new GetProxyRequestArgs { Id = id, InstanceId = instanceId, Password = password }); ExceptionsML.Check(sr.Error); return(DownloadFiles(sr.Result, connectionId)); } catch (LoginRequiredException lex) { if (lex.Reason == LoginRequiredReason.ProxyMoveInProgress) { var proxyUrl = Functions.GetAuthenticationProxyUrl(); var domain = Functions.GetProxyCookieDomain(); var url = Functions.CombineUri(proxyUrl, "Guest"); url += String.Format("?{0}={1}&{2}={3}&{4}={5}", Constants.REQUESTID, id, Constants.INSTANCEID, instanceId, Constants.AUTO, String.IsNullOrEmpty(password)); return(View("../Home/Oops", new ExceptionsML { Message = url, Type = LoginRequiredReason.ProxyMoveInProgress.ToString() })); } return(View("../Home/Oops", ExceptionsML.GetExceptionML(lex))); } catch (RecordNotFoundException rex) { return(View("../Home/Oops", new ExceptionsML { Message = Constants.i18n("invalidGuestDownloadRequest"), Type = rex.GetType().ToString() })); } catch (Exception ex) { return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex))); } }
/// <summary> /// Retrieves all data required by the designer /// </summary> public JsonResult GetData() { var wfSvc = SvcBldr.WorkflowV2(); var secSvc = SvcBldr.SecurityV2(); var ibxSvc = SvcBldr.InboxV2(); var companySvc = SvcBldr.Company(); var adminSvc = SvcBldr.AdministrationV2(); var userSvc = SvcBldr.UserV2(); var dlSvc = SvcBldr.DataLinkV2(); var ctSvc = SvcBldr.ContentTypeV2(); var cfSvc = SvcBldr.CustomFieldV2(); var licSvc = SvcBldr.LicenseV2(); var docSVC = SvcBldr.DocumentV2(); var searchSvc = SvcBldr.SearchV2(); var tokens = licSvc.GetLicenseTokens(); if (tokens.Error != null) { return(Result(null, tokens.Error)); } var dbFieldsSR = searchSvc.GetFields(); if (dbFieldsSR.Error != null) { return(Result(null, dbFieldsSR.Error)); } var dbFields = dbFieldsSR.Result; var advancedWF = false; if (tokens.Result != null) { advancedWF = tokens.Result.HasTokenKey(TokenKey.AdvancedWorkflow); } var customLists = adminSvc.GetCustomListsSlim(); if (customLists.Error != null) { return(Result(null, customLists.Error)); } var userPrefsSR = userSvc.GetPreferences(); if (userPrefsSR.Error != null) { return(Result(null, userPrefsSR.Error)); } var userPrefsKVP = new Dictionary <String, String>(); var upLen = userPrefsSR.Result.Length; for (int i = 0; i < upLen; i++) { if (userPrefsKVP.ContainsKey(userPrefsSR.Result[i].Key)) { continue; } userPrefsKVP.Add(userPrefsSR.Result[i].Key, userPrefsSR.Result[i].Value); } var allTasks = TaskDesignProperties.GetAll(); var uiTasks = allTasks.Where(r => r.NeedsUserInput); var clientTasks = allTasks.Where(r => r.NeedsClientService); var autoTasks = allTasks.Where(r => !r.NeedsClientService && !r.NeedsUserInput).ToList(); var actionLibrary = wfSvc.GetActionLibrarySlim(); if (actionLibrary.Error != null) { return(Result(null, actionLibrary.Error)); } actionLibrary.Result.Append(new SlimActionLibraryItem() { Id = Guid.Empty, EffectivePermissions = (int)PermissionType.Full, Name = Constants.i18n("newTitle"), Type = (int)WFActionType.LibraryItem }); var wfNames = wfSvc.GetSlim(); if (wfNames.Error != null) { return(Result(null, wfNames.Error)); } var wfNamesWithNew = wfNames.Result.Prepend(new SlimEntity(Guid.Empty, Constants.i18n("newTitle"), PermissionType.Full)); var inboxes = ibxSvc.GetSlim(); if (inboxes.Error != null) { return(Result(null, inboxes.Error)); } var inboxNVP = inboxes.Result.ToDictionary(k => k.Id.ToString(), v => v.Name); var contentTypes = ctSvc.GetContentTypesSlim(); if (contentTypes.Error != null) { return(Result(null, contentTypes.Error)); } var ctNVP = contentTypes.Result.ToDictionary(k => k.Id.ToString(), v => v.Name); var securityClasses = secSvc.GetAllSecurityClassesSlim(); if (securityClasses.Error != null) { return(Result(null, securityClasses.Error)); } var scNVP = securityClasses.Result.ToDictionary(k => k.Id.ToString(), v => v.Name); var users = userSvc.GetAll(); if (users.Error != null) { return(Result(null, users.Error)); } var slimUsers = users.Result.Select(r => new { Id = r.Id, Username = r.Username, Flags = r.Flags, SiteUser = r.SiteUser }).ToList(); var roles = secSvc.GetAllRolesSlim(); if (roles.Error != null) { return(Result(null, roles.Error)); } var rolesNVP = roles.Result.ToDictionary(k => k.Id.ToString(), v => v.Name); var customFields = cfSvc.GetCustomFields(); if (customFields.Error != null) { return(Result(null, customFields.Error)); } var customFieldsNVP = customFields.Result.ToDictionary(k => k.Id.ToString(), v => v.Name); var cfGroupsSR = cfSvc.GetGroups(); if (cfGroupsSR.Error != null) { return(Result(null, cfGroupsSR.Error)); } var docProps = WFDocMeta.GetProperties(); var args = new Dictionary <string, WFMetaPropertyInfo> { { Constants.i18n("argSysCurrUser"), new WFMetaPropertyInfo() { Name = Argument.SystemProperty(SystemArguments.CurrentUser), ReadOnly = true, PropertyType = CFTypeCode.Object, SupportedActionType = WFActionType.SyncVerifyAction | WFActionType.AutoRun } }, { Constants.i18n("argSysNow"), new WFMetaPropertyInfo() { Name = Argument.SystemProperty(SystemArguments.Now), ReadOnly = true, PropertyType = CFTypeCode.DateTime, SupportedActionType = WFActionType.SyncVerifyAction | WFActionType.AutoRun } }, { Constants.i18n("argSysToday"), new WFMetaPropertyInfo() { Name = Argument.SystemProperty(SystemArguments.Today), ReadOnly = true, PropertyType = CFTypeCode.DateTime, SupportedActionType = WFActionType.SyncVerifyAction | WFActionType.AutoRun } }, { Constants.i18n("argSysTomorrow"), new WFMetaPropertyInfo() { Name = Argument.SystemProperty(SystemArguments.Tomorrow), ReadOnly = true, PropertyType = CFTypeCode.DateTime, SupportedActionType = WFActionType.SyncVerifyAction | WFActionType.AutoRun } }, { Constants.i18n("argDocFolder"), new WFMetaPropertyInfo() { Name = Argument.DocProperty(Argument.FOLDERS), ReadOnly = true, PropertyType = CFTypeCode.Object, SupportedActionType = WFActionType.SyncAutoRunAction } }, { Constants.i18n("argDocText"), new WFMetaPropertyInfo() { Name = Argument.DocProperty(Argument.TEXT), ReadOnly = false, PropertyType = CFTypeCode.String, Indexable = true, SupportedActionType = WFActionType.SyncVerifyAction | WFActionType.AutoRun } } }; foreach (var docProp in docProps) { args.Add(Constants.i18n("argDoc" + docProp.Name), new WFMetaPropertyInfo() { Name = Argument.DocProperty(docProp.Name), ReadOnly = docProp.ReadOnly, PropertyType = docProp.PropertyType, SupportedActionType = docProp.SupportedActionType }); } foreach (var cf in customFields.Result) { args.Add(String.Format(Constants.i18n("argDocCustomField"), cf.Name), new WFMetaPropertyInfo() { Name = Argument.DocCustomField(cf.Name), ReadOnly = false, PropertyType = cf.Type, SupportedActionType = WFActionType.SyncVerifyAction | WFActionType.AutoRun }); } var orderedArgs = args.OrderBy(r => r.Key).ToDictionary(k => k.Key, v => v.Value); var datalinks = new SR <DataLinkQueryPackage[]>(); if (!(tokens.Result != null && tokens.Result.HasTokenKey(TokenKey.DataLink))) { autoTasks.Remove(autoTasks.First(r => r.TaskClassName == "DatalinkTask")); } else { datalinks = dlSvc.GetDataLinkQueries(); if (datalinks.Error != null) { return(Result(null, datalinks.Error)); } } var recognitionOptions = docSVC.GetRecognitionOptions(); if (recognitionOptions.Error != null) { return(Result(null, recognitionOptions.Error)); } var xml = this.GetHelpXML("en"); // TRANSLATE THIS FRIGGIN KEY ;) var retObj = new { HelpXMLString = xml, BuiltInArgs = orderedArgs, ActionLibrary = actionLibrary.Result, UITasks = uiTasks, ClientTasks = clientTasks, AutoTasks = autoTasks, Workflows = wfNamesWithNew, Inboxes = inboxNVP, ContentTypes = ctNVP, CustomFields = customFieldsNVP, SecurityClasses = scNVP, Users = slimUsers, Roles = rolesNVP, AdvancedWF = advancedWF, CustomLists = customLists.Result, Datalinks = datalinks.Result, UserPreferences = userPrefsKVP, CustomFieldGroups = cfGroupsSR.Result, RecognitionOptions = recognitionOptions.Result, DatabaseFields = dbFields }; return(Result(retObj, null)); }