Ejemplo n.º 1
0
        /// <summary>
        /// Sets a Data Link Connection (Create and Edit)
        /// </summary>
        /// <param name="dataLink">Data Link Connection to be updated</param>
        /// <param name="originalPassword">Ignored; formerly used to detect whether a password had changed and thereby if it required encryption, but 3 bells prefix is used now</param>
        /// <returns>Updated Data Link Connection</returns>
        public JsonResult SetDataLinkConnection(DataLinkConnectionJS dataLink, string originalPassword)
        {
            var client  = SvcBldr.DataLinkV2();
            var package = new DataLinkConnectionPackage();

            if (dataLink.Id == Guid.Empty)
            {
                dataLink.Id = Functions.NewSeq();
                package.DataLinkConnection = dataLink.ToDataLinkConnection();
                package.DataLinkQueries    = dataLink.DataLinkQueries;
                var result = client.CreateDataLinkConnection(package);
                if (result.Error != null)
                {
                    return(Result(null, result.Error));
                }
                var dataLinkJS = result.Result.ToPackageJS();
                return(Result(dataLink = dataLinkJS, result.Error, JsonRequestBehavior.AllowGet));
            }
            else
            {
                package.DataLinkConnection = dataLink.ToDataLinkConnection();
                var result = client.UpdateDataLinkConnection(package);
                return(Result(new { Id = dataLink.Id, successResult = result.Result }, result.Error, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests all updates for the current site
        /// Uses saved parameters.
        /// </summary>
        /// <returns></returns>
        public JsonResult TestDataLinkUpdates()
        {
            var client = SvcBldr.DataLinkV2();
            var result = client.ExecuteUpdateTests();

            return(Result(null, result.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get a specific Data Link Connection
        /// </summary>
        /// <param name="datalinkId">Data Link Connection id</param>
        /// <returns>Data Link Connection</returns>
        public JsonResult GetDataLinkConnection(Guid datalinkId)
        {
            var client   = SvcBldr.DataLinkV2();
            var datalink = client.GetDataLinkConnection(datalinkId);

            return(Result(datalink.Result, datalink.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get data pertaining to Data Link Connections
        /// </summary>
        /// <returns>Data Link Connections</returns>
        public JsonResult GetDataLinkConnections()
        {
            var client    = SvcBldr.DataLinkV2();
            var dataLinks = client.GetDataLinkConnections();

            return(Result(dataLinks.Result, dataLinks.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Tests the given update using saved parameters
        /// </summary>
        /// <param name="queryId"></param>
        /// <returns></returns>
        public JsonResult TestDataLinkUpdate(Guid queryId)
        {
            var client = SvcBldr.DataLinkV2();
            var result = client.ExecuteUpdateTest(queryId);

            return(Result(result.Result, result.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Tests all queries for the current site.
        /// Uses saved parameters.
        /// </summary>
        /// <returns></returns>
        public JsonResult TestDataLinkQueries()
        {
            var client = SvcBldr.DataLinkV2();
            var dlqs   = client.ExecuteQueryTests();

            return(Result(dlqs.Result, dlqs.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get a specific Data Link Query
        /// </summary>
        /// <param name="queryId">Data Link Query id</param>
        /// <returns>Data Link Query</returns>
        public JsonResult GetDataLinkQuery(Guid queryId)
        {
            var client        = SvcBldr.DataLinkV2();
            var dataLinkQuery = client.GetDataLinkQuery(queryId);

            return(Result(dataLinkQuery.Result, dataLinkQuery.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Get data pertaining to Data Link Queries
        /// </summary>
        /// <returns>Data Link Queries</returns>
        public JsonResult GetDataLinkQueries()
        {
            var client            = SvcBldr.DataLinkV2();
            var dataLinkQueriesSR = client.GetDataLinkQueries();
            var dataLinkQueries   = dataLinkQueriesSR.Result != null?dataLinkQueriesSR.Result.OrderBy(r => r.Name) : null;

            return(Result(dataLinkQueries, dataLinkQueriesSR.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Deletes a datalink query
        /// </summary>
        /// <param name="queryId"></param>
        /// <returns></returns>
        public JsonResult DeleteDataLinkQuery(Guid queryId)
        {
            var client = SvcBldr.DataLinkV2();

            var result = client.DeleteDataLinkQuery(queryId);

            return(Result(null, result.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Deletes a datalink connection and all associated queries.
        /// </summary>
        /// <param name="datalinkId"></param>
        /// <param name="canDelete"></param>
        /// <returns></returns>
        public JsonResult DeleteDataLinkConnection(Guid datalinkId, bool canDelete = false)
        {
            var client = SvcBldr.DataLinkV2();
            DataLinkConnectionDeletePackage package = new DataLinkConnectionDeletePackage
            {
                connectionId = datalinkId
            };
            var result = client.DeleteDataLinkConnection(package);

            return(Result(null, result.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Runs a given query using the passed in parameters
        /// </summary>
        /// <param name="queryId"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsonResult RunDataLinkQuery(Guid queryId, Dictionary <string, string> parameters)
        {
            var client  = SvcBldr.DataLinkV2();
            var package = new ExecuteDataLinkPackage
            {
                parameterValues = parameters,
                queryId         = queryId
            };
            var result = client.ExecuteQuery(package);

            return(Result(result.Result, result.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
        public JsonResult TestDataLinkQueryLive(DataLinkConnection connection, DataLinkQueryPackage query)
        {
            var client  = SvcBldr.DataLinkV2();
            var package = new ExecuteLiveQueryTestPackage
            {
                connection = connection,
                query      = query
            };
            var result = client.ExecuteLiveQueryTest(package);

            return(Result(result.Result, result.Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Sets a Data Link Query (Create and Edit)
        /// </summary>
        /// <param name="query">Data Link Query to be updated</param>
        /// <returns>Updated Data Link Query</returns>
        public JsonResult SetDataLinkQuery(DataLinkQueryPackage query)
        {
            var client = SvcBldr.DataLinkV2();

            if (query.Id == Guid.Empty)
            {
                query.Id = Functions.NewSeq();
                var result = client.CreateDataLinkQuery(query);
                return(Result(result.Result, result.Error,
                              JsonRequestBehavior.AllowGet));
            }
            else
            {
                var result = client.UpdateDataLinkQuery(query);

                return(Result(new { id = query.Id, successResult = result.Result }, result.Error, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 14
0
        /// <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));
        }