Ejemplo n.º 1
0
        public SPWorkflowCollectionInstance CreateWorkflowFromWeb(SPWebInstance web, object inclusiveFilterStates,
                                                                  object exclusiveFilterStates, object rowCountLimit, object descending)
        {
            if (web == null)
            {
                throw new JavaScriptException(Engine, "Error", "A web must be supplied.");
            }

            SPWorkflowCollection result;

            if (inclusiveFilterStates == Undefined.Value && exclusiveFilterStates == Undefined.Value &&
                rowCountLimit == Undefined.Value && descending == Undefined.Value)
            {
                result = new SPWorkflowCollection(web.Web);
            }
            else
            {
                SPWorkflowState wsInclusiveFilterStates;
                if (!TypeConverter.ToString(inclusiveFilterStates).TryParseEnum(true, out wsInclusiveFilterStates))
                {
                    throw new JavaScriptException(Engine, "Error", "inclusiveFilerStates argument must be a valid SPWorkflowState.");
                }

                SPWorkflowState wsExclusiveFilterStates;
                if (!TypeConverter.ToString(exclusiveFilterStates).TryParseEnum(true, out wsExclusiveFilterStates))
                {
                    throw new JavaScriptException(Engine, "Error", "exclusiveFilterStates argument must be a valid SPWorkflowState.");
                }

                result = new SPWorkflowCollection(web.Web, wsInclusiveFilterStates, wsExclusiveFilterStates, TypeConverter.ToInteger(rowCountLimit), TypeConverter.ToBoolean(descending));
            }

            return(new SPWorkflowCollectionInstance(Engine.Object.InstancePrototype, result));
        }
        public void CreateHistoryEvent(SPWebInstance web, object workflowId, int eventId, object user, string duration, string outcome, string description, string otherData)
        {
            if (web == null)
            {
                throw new JavaScriptException(Engine, "Error", "A web must be supplied as the first argument.");
            }

            SPMember member;

            if (user is SPUserInstance)
            {
                member = (user as SPUserInstance).User;
            }
            else if (user is SPGroupInstance)
            {
                member = (user as SPGroupInstance).Group;
            }
            else
            {
                throw new JavaScriptException(Engine, "Error", "User must be a SPUser or SPGroup.");
            }

            SPWorkflow.CreateHistoryEvent(web.Web, GuidInstance.ConvertFromJsObjectToGuid(workflowId), eventId, member, TimeSpan.Parse(duration), outcome,
                                          description, otherData);
        }
Ejemplo n.º 3
0
        public string GetPagesListName(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A SPWeb must be supplied as the first parameter.");
            }

            return(PublishingWeb.GetPagesListName(web.Web));
        }
        public string MapToServerFileRedirect(SPWebInstance web, string fileName, string progId)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            return(SPUtility.MapToServerFileRedirect(web.Web, fileName, progId));
        }
        public void EnsureSiteAdminAccess(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            SPUtility.EnsureSiteAdminAccess(web.Web);
        }
        public bool IsEmailServerSet(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            return(SPUtility.IsEmailServerSet(web.Web));
        }
Ejemplo n.º 7
0
        public bool IsPublishingWeb(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A SPWeb must be supplied as the first parameter.");
            }

            return(PublishingWeb.IsPublishingWeb(web.Web));
        }
Ejemplo n.º 8
0
        public int GetWorkflowAvailableRunCount(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPWeb object must be supplied as the first argument.");
            }

            return(m_workflowManager.GetWorkflowAvailableRunCount(web.Web));
        }
        public DateInstance GetServerNow(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            var result = SPUtility.GetServerNow(web.Web);

            return(JurassicHelper.ToDateInstance(this.Engine, result));
        }
        public SPWorkflowAssociationInstance ImportFromXml(SPWebInstance rootWeb, string xml)
        {
            if (rootWeb == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be supplied as the first argument.");
            }

            var result = SPWorkflowAssociation.ImportFromXml(rootWeb.Web, xml);

            return(result == null
                ? null
                : new SPWorkflowAssociationInstance(this.Engine.Object.InstancePrototype, result));
        }
        public ArrayInstance GetStatusChoices(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(Engine, "Error", "A SPWeb must be supplied as the first argument.");
            }

            var result = m_workflowTemplate.GetStatusChoices(web.Web);

            return(result == null
                ? null
// ReSharper disable once CoVariantArrayConversion
                : Engine.Array.Construct(result.OfType <string>().ToArray()));
        }
Ejemplo n.º 12
0
        public SPWorkflowTemplateCollectionInstance GetWorkflowTemplatesByCategory(SPWebInstance web, string strReqCaegs)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPWeb object must be supplied as the first argument.");
            }

            var result = m_workflowManager.GetWorkflowTemplatesByCategory(web.Web, strReqCaegs);

            return(result == null
                ? null
                : new SPWorkflowTemplateCollectionInstance(this.Engine.Object.InstancePrototype, result));
        }
Ejemplo n.º 13
0
        public SPListInstance GetSPListFromName(SPWebInstance web, object webId, string listGuid, string listUrl, string listDisplayName)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            var guidWebId = GuidInstance.ConvertFromJsObjectToGuid(webId);

            var result = SPUtility.GetSPListFromName(web.Web, guidWebId, listGuid, listUrl, listDisplayName);

            return(result == null
                ? null
                : new SPListInstance(this.Engine, null, null, result));
        }
Ejemplo n.º 14
0
        public ObjectInstance CountWorkflowsInWeb(SPWebInstance web)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "An instance of a SPWeb object must be supplied as the first argument.");
            }

            var result = m_workflowManager.CountWorkflows(web.Web);

            var obj = this.Engine.Object.Construct();

            foreach (var r in result)
            {
                obj.SetPropertyValue(r.Key.ToString(), r.Value, false);
            }
            return(obj);
        }
Ejemplo n.º 15
0
        public string MapToIcon(SPWebInstance web, string fileName, string progId, object size)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            if (size != Undefined.Value && size != Null.Value && size != null)
            {
                IconSize isSize;
                if (TypeConverter.ToString(size).TryParseEnum(true, out isSize))
                {
                    SPUtility.MapToIcon(web.Web, fileName, progId, isSize);
                }
            }

            return(SPUtility.MapToIcon(web.Web, fileName, progId));
        }
Ejemplo n.º 16
0
        public ObjectInstance GetFullNameandEmailfromLogin(SPWebInstance web, string login)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            string displayName;
            string email;

            SPUtility.GetFullNameandEmailfromLogin(web.Web, login, out displayName, out email);

            var result = this.Engine.Object.Construct();

            result.SetPropertyValue("displayName", displayName, false);
            result.SetPropertyValue("email", email, false);
            return(result);
        }
Ejemplo n.º 17
0
        public ObjectInstance GetPrincipalsInGroup(SPWebInstance web, string input, int maxCount)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be specified as the first parameter.");
            }

            bool reachedMaxCount;
            var  principals    = SPUtility.GetPrincipalsInGroup(web.Web, input, maxCount, out reachedMaxCount);
            var  arrPrincipals = this.Engine.Array.Construct();

            foreach (var principal in principals)
            {
                ArrayInstance.Push(arrPrincipals, new SPPrincipalInfoInstance(this.Engine, principal));
            }

            var result = this.Engine.Object.Construct();

            result.SetPropertyValue("principals", arrPrincipals, false);
            result.SetPropertyValue("reachedMaxCount", reachedMaxCount, false);
            return(result);
        }