Exemplo n.º 1
0
        public JsonResult GetFolderChildren(String ParentId = "", Int32 Depth = 1, bool includeParent = false)
        {
            ////If we are requesting the root node then return an empty list. This should only happen on systems with 0 folders.
            if (ParentId == ROOTNODE)
            {
                return(Result(new List <JSTreeData>(), null, JsonRequestBehavior.AllowGet));
            }
            Guid?rootNodeId        = String.IsNullOrWhiteSpace(ParentId) ? null : new Guid?(new Guid(ParentId));
            var  clientV2          = SvcBldr.FolderV2();
            var  foldRecursionArgs = new FolderRecursionArgs
            {
                ParentId = rootNodeId,
                Depth    = Depth
            };
            var srChildren = clientV2.GetChildren(foldRecursionArgs);

            if (srChildren.Error != null)
            {
                return(Result(null, srChildren.Error));
            }
            var children = srChildren.Result;
            var subNodes = JSTreeFormat.ConvertToJSTreeFormat(children);

            if (rootNodeId == null) // Is the Root Folder
            {
                var rootNode = new JSTreeData("Folders");
                rootNode.children = subNodes;
                return(Result(rootNode, srChildren.Error, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (includeParent)
                {
                    var srRoot = clientV2.Get(rootNodeId.Value);
                    if (srRoot.Error != null)
                    {
                        return(Result(null, srRoot.Error, JsonRequestBehavior.AllowGet));
                    }
                    if (srRoot.Result != null)
                    {
                        var rootNode = new JSTreeData(srRoot.Result.Title);
                        rootNode.children = subNodes;
                        rootNode.attr.Id  = rootNodeId.ToString();
                        return(Result(rootNode, srChildren.Error, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Result(null, ExceptionsML.GetExceptionML(new Exception(Constants.i18n("parentFolderNotFound"))), JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Result(subNodes, srChildren.Error, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 2
0
        public JsonResult GetLDAPContainers(string idStr, string node, bool subtree, string username, string password)
        {
            var ldapSvc = SvcBldr.LDAPV2();
            var pkg     = new LDAPGetQuery {
                ConnectionId = new Guid(idStr), Node = node, Subtree = subtree, Username = username, Password = password
            };
            var sr = ldapSvc.GetContainers(pkg);

            if (sr.Error != null)
            {
                return(Result(null, sr.Error));
            }
            var treeData = JSTreeFormat.ConvertToJSTreeFormat(sr.Result.ToList());

            return(Result(treeData, sr.Error));
        }
Exemplo n.º 3
0
        public JsonResult GetAllInboxes(String ParentId = "", Int32 Depth = 1)
        {
            var client = SvcBldr.InboxV2();

            if (!String.IsNullOrEmpty(ParentId)) //Return Empty array for now, if in the future we support subInboxes we will need to remove this.
            {
                return(Result(new List <JSTreeData>(), null, JsonRequestBehavior.AllowGet));
            }

            var result = new JSTreeData("Inboxes");
            var sr     = client.GetSlim();

            if (sr.Error != null)
            {
                return(Result(null, sr.Error, JsonRequestBehavior.AllowGet));
            }
            result.children = JSTreeFormat.ConvertToJSTreeFormat(sr.Result);

            return(Result(result, sr.Error, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        /// <summary>
        /// load data for the home model
        /// </summary>
        public void LoadData(string baseUri)
        {
            var bulkClient   = _sb.BulkDataV2();
            var hostBulkData = bulkClient.GetHostData();

            ExceptionsML.Check(hostBulkData.Error);

            HostBulkData = JsonConvert.SerializeObject(hostBulkData);

            CurrentDBName         = hostBulkData.Result.CurrentDB;
            DefaultDBName         = hostBulkData.Result.DefaultDB;
            DefaultInstanceId     = hostBulkData.Result.DefaultInstanceId;
            Instances             = hostBulkData.Result.UserCompanyInstances;
            SystemPreferences     = JsonConvert.SerializeObject(hostBulkData.Result.CompanySettings);
            SystrayConnections    = JsonConvert.SerializeObject(hostBulkData.Result.SysTrayConnections);
            AutomationConnections = JsonConvert.SerializeObject(hostBulkData.Result.AutomationConnections);
            HttpRuntimeSection httpRuntimeSection = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection;

            MaxRequestLength = httpRuntimeSection.MaxRequestLength;
            DateTime?lastChecked = null;

            if (hostBulkData.Result.UserSettings.ContainsKey(Constants.WORKFLOW_LAST_CHECKED))
            {
                lastChecked = DateTime.Parse(hostBulkData.Result.UserSettings[Constants.WORKFLOW_LAST_CHECKED]);
            }

            var bulkData = bulkClient.Get(lastChecked);

            ExceptionsML.Check(bulkData.Error);
            BulkData = JsonConvert.SerializeObject(bulkData);
            var result = bulkData.Result;

            UserMessages = result.ExpiringMessage;
            var importData    = new AdvancedImportData();
            var licenseTokens = result.LicenseTokens;

            if (licenseTokens != null)
            {
                Licenses.AddRange(licenseTokens);
            }
            if (!Licenses.Any(r => (TokenKey)r == TokenKey.View))
            {
                Unlicensed = true;
            }
            // Gateway permissions
            importData.GatewayPermissions = result.GatewayPermissions;
            var user = result.CurrentUser;

            _baseCache.Remove(USERINFO + user.Id.ToString());
            _baseCache.Add(USERINFO + user.Id.ToString(), new object[] { user, result.GatewayPermissions }, new CacheItemPolicy());
            LoadUserData();
            CurrentUser           = JsonConvert.SerializeObject(new { Name = user.Username, Id = user.Id, HasPassword = HasPassword });
            importData.RootFolder = result.RootFolders;
            var rootNode = new JSTreeData(Constants.i18n("folders"));

            rootNode.children = JSTreeFormat.ConvertToJSTreeFormat(importData.RootFolder);
            FolderData        = JsonConvert.SerializeObject(rootNode);

            // Inbox data
            var inboxes = new JSTreeData(Constants.i18n("inboxes"));

            importData.Inboxes = result.Inboxes.ToList();
            inboxes.children   = JSTreeFormat.ConvertToJSTreeFormat(result.Inboxes);
            InboxData          = JsonConvert.SerializeObject(inboxes);
            // Security Class Data
            importData.SecurityClasses = result.SecurityClasses.ToList();
            // Content Type Data
            ContentTypes            = result.ContentTypes;
            importData.ContentTypes = new List <ContentTypeLight>();
            foreach (var ct in ContentTypes)
            {
                importData.ContentTypes.Add(new ContentTypeLight
                {
                    Id   = ct.Id,
                    Name = ct.Name,
                    DefaultFolderName      = "", //TODO: scain need to obtain the default folder Name
                    DefaultFolderId        = ct.DefaultFolderId,
                    DefaultInboxId         = ct.DefaultInboxId,
                    DefaultSecurityClassid = ct.DefaultSecurityClassId,
                    DefaultWorkflowId      = ct.DefaultWorkflowId,
                    EffectivePermissions   = ct.EffectivePermissions
                });
            }

            NewApprovals         = result.NewApprovals;
            NewWorkflows         = result.NewWorkflows;
            importData.Workflows = result.Workflows.ToList();
            ImportData           = JsonConvert.SerializeObject(importData);
            var views = GetCachedViews(baseUri);

            CommonTemplates = JsonConvert.SerializeObject(views);
        }