public JsonResult GetIndexInfo() { var client = SvcBldr.SearchV2(); var sr = client.GetIndexInfo(false); return(Result(sr.Result, sr.Error, JsonRequestBehavior.AllowGet)); }
public JsonResult InboxIsEmpty(Guid inboxId) { var clientV2 = SvcBldr.SearchV2(); var result = clientV2.Search(new SearchRequest { InboxId = inboxId, IncludeDocuments = true, IncludeFolders = true, IncludeInboxes = true, MaxRows = 1 }); if (result.Error != null) { return(Result(null, result.Error, JsonRequestBehavior.AllowGet)); } return(Result(result.Result.Results.Count <= 0, null, JsonRequestBehavior.AllowGet)); }
/// <summary> /// sets search results /// </summary> public JsonResult Search(String searchRequest, int page, int rows, bool jqGrid = false, string sidx = "title", string sord = "desc") { var client = SvcBldr.SearchV2(); // jqgrid page 1-based (not 0) var searchRequestObj = new SearchRequest(); if (searchRequest != null) { searchRequestObj = JsonConvert.DeserializeObject <SearchRequest>(searchRequest); } searchRequestObj.MaxRows = rows; searchRequestObj.Start = (page - 1) * rows; searchRequestObj.SortBy = sidx; searchRequestObj.SortOrder = sord; var sr1 = client.Search(searchRequestObj); if (sr1.Error != null) { return(Result(null, sr1.Error)); } if (!jqGrid) { return(Result(sr1.Result, sr1.Error)); } var sr2 = client.GetCustomFields(); if (sr2.Error != null) { return(Result(null, sr2.Error)); } var length = sr2.Result.Length; var cf = new String[length]; for (int i = 0; i < length; i++) { cf[i] = sr2.Result[i].DisplayName; } var jqGridData = ConvertToJQGrid(sr1.Result, page, rows, cf); var data = new { jqGridData = jqGridData, request = sr1.Result.Request }; return(Result(data, null, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAllData() { var cfClient = SvcBldr.CustomFieldV2(); var adClient = SvcBldr.AdministrationV2(); var client = SvcBldr.SearchV2(); var result = cfClient.GetCustomFields(); if (result.Error != null) { return(Result(null, result.Error, JsonRequestBehavior.AllowGet)); } var lists = adClient.GetCustomListsSlim(); if (lists.Error != null) { return(Result(null, lists.Error, JsonRequestBehavior.AllowGet)); } var sr = client.GetFieldNames(); if (sr.Error != null) { return(Result(null, sr.Error, JsonRequestBehavior.AllowGet)); } var srGroups = cfClient.GetGroups(); if (srGroups.Error != null) { return(Result(null, srGroups.Error, JsonRequestBehavior.AllowGet)); } var fieldsnames = sr.Result.Where(r => result.Result == null || result.Result.ToList().All(l => l.Name != r)).ToList(); fieldsnames.AddRange(new List <string> { "id", Constants.CN_ENTITY_ID, Constants.DOCTYPE, Constants.DOCID, Constants.WFDOCID, Constants.APPID, Constants.SF_TYPE }); return(Result(new { cfs = result.Result, cls = lists.Result, cfg = srGroups.Result, spnms = fieldsnames }, null, JsonRequestBehavior.AllowGet)); }
public JsonResult ReIndexInstance(string instanceId) { ExceptionsML bizEx; var companyClient = SvcBldr.Company(); var hostingClient = SvcBldr.Hosting(); var token = hostingClient.SwitchContext(instanceId, out bizEx); if (bizEx != null) { return(Result(null, bizEx, JsonRequestBehavior.AllowGet)); } var authCookie = AstriaCookie.SetToken(token, Functions.GetProxyCookieDomain()); Response.Cookies.Add(authCookie); SvcBldr.Token = token; var idxClient = SvcBldr.SearchV2(); var sr = idxClient.DeleteReIndex(); return(Result(sr.Result, sr.Error, JsonRequestBehavior.AllowGet)); }
private ServiceReturn GetInboxDocuments(string inboxId, int start, int count, string sortColumn) { if (count == 0) { count = 1000; } var sr = new SearchRequest { Start = start, MaxRows = count, InboxId = new Guid(inboxId), IncludeDocuments = true, SortBy = sortColumn }; var client = SvcBldr.SearchV2(); var sr1 = client.Search(sr); var result = new ServiceReturn(); result.Result = sr1.Result; result.BizEx = sr1.Error; return(result); }
private string GetRedirectURL(out Astria.Framework.DataContracts.ExceptionsML bizEx) { bizEx = null; var redirectUrl = ""; if (!String.IsNullOrEmpty(Request.QueryString[Constants.INSTANCEID])) { var hostingClient = SvcBldr.Hosting(); var token = hostingClient.SwitchContext(Request.QueryString[Constants.INSTANCEID], out bizEx); if (bizEx == null) { redirectUrl = Url.Content("~/"); var authCookie = AstriaCookie.SetToken(token, Functions.GetProxyCookieDomain()); Response.Cookies.Add(authCookie); SvcBldr.Token = token; } } if (!String.IsNullOrEmpty(Request.QueryString[Constants.TYPE]) && bizEx == null) { if (String.IsNullOrEmpty(redirectUrl)) { redirectUrl = Url.Content("~/"); } var type = (DC.EntityType)Enum.Parse(typeof(DC.EntityType), Request.QueryString[Constants.TYPE], true); string typeString = type.ToString(); switch (type) { case DC.EntityType.DocumentVersion: typeString = "ver"; // this abbreviation used for DocumentVersion, the most common cache entity goto case Astria.Framework.DataContracts.EntityType.Document; case DC.EntityType.Document: var searchClient = SvcBldr.SearchV2(); var data = new Dictionary <Guid, string>(); data.Add(new Guid(Request.QueryString[Constants.ENTITYID]), typeString); if (Request.QueryString[Constants.WF_LINK_ACTION] == Constants.WF_UPDATE_DUEDATE) { var dueDate = Request.QueryString[Constants.DUEDATE]; DateTime tempDate; if (!DateTime.TryParse(dueDate, out tempDate)) { throw new Exception(Constants.i18n("invalidDueDate")); } UpdateDueDate(new Guid(Request.QueryString[Constants.ENTITYID]), Convert.ToDateTime(dueDate)); } var sr = searchClient.SetCachedViewData(data); if (sr.Error == null) { if (!String.IsNullOrEmpty(Request.QueryString[Constants.WF_LINK_ACTION])) { redirectUrl += String.Format("#Retrieve/view/{0}/index/1/page/1/query?{1}={2}", sr.Result, Constants.WF_LINK_ACTION, Request.QueryString[Constants.WF_LINK_ACTION]); } else { redirectUrl += String.Format("#Retrieve/view/{0}/index/1/page/1", sr.Result); } } break; case DC.EntityType.Workflow: redirectUrl = String.Format("#Workflow/queues/1/25/DFWfId/asc/wfItems/{0}/{1}", Request.QueryString[Constants.ENTITYID], Request.QueryString[Constants.USERID]); break; // direct links to other entities are not currently supported default: break; } } return(redirectUrl); }
/// <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)); }