/// <inheritdoc />
        /// <summary>
        /// Check if user is an (possibly indirect) member of an identity group
        /// </summary>
        /// <param name="body">Method XML body item</param>
        /// <returns>'true' as string result if membership matches</returns>
        public override Item DoApply(Item body)
        {
            XmlPropertyAttribute.BindXml(body.node, this);

            var userId = Innovator.getUserID();

            var userAlias = Innovator.newItem("Alias", "get");

            userAlias.setAttribute("select", "related_id");
            userAlias.setProperty("source_id", userId);
            userAlias = Innovator.ApplyItem(userAlias);

            var identityId = userAlias.getProperty("related_id");

            return(Innovator.newResult(CheckIfMemberOfIdentity(identityId) ? "true" : "false"));
        }
Beispiel #2
0
        /// <inheritdoc />
        /// <summary>
        /// Check if user is an (possibly indirect) member of an identity group
        /// </summary>
        /// <param name="body">Method XML body item</param>
        /// <returns>'true' as string result if membership matches</returns>
        public override Item DoApply(Item body)
        {
            XmlPropertyAttribute.BindXml(body.node, this);

            var userId = Innovator.getUserID();

            var userAlias = Innovator.newItem("Alias", "get");

            userAlias.setAttribute("select", "related_id");
            userAlias.setProperty("source_id", userId);
            userAlias = Innovator.ApplyItem(userAlias);

            var ids = new List <string> {
                userAlias.getProperty("related_id")
            };

            // not the fastest, but it works.
            // should be optimized by asking for batches of identities.
            // (see below for fast recursive SQL .. that Aras doesn't permit in ApplySQL.)
            while (ids.Any())
            {
                var id = ids.Last();
                ids.RemoveAt(ids.Count - 1);

                var identityItem = Innovator.newItem("Identity", "get");
                identityItem.setAttribute("select", "keyed_name");

                var memberRelation = identityItem.createRelationship("Member", "get");
                memberRelation.setAttribute("select", "keyed_name");
                memberRelation.setProperty("related_id", id);
                identityItem = Innovator.ApplyItem(identityItem);

                if (identityItem.Enumerate()
                    .Any(i => i.getProperty("keyed_name") == IdentityName))
                {
                    return(Innovator.newResult("true"));
                }

                ids.AddRange(identityItem.Enumerate().Select(i => i.getID()));
            }

            return(Innovator.newResult("false"));
        }
Beispiel #3
0
        public string CallAction(string action, string input, IProgressCallback progressReporter)
        {
            XmlNode     fault;
            XmlDocument outputDoc = null;
            var         inputDoc  = new XmlDocument();

            inputDoc.LoadXml(input);
            if (_userInfo == null)
            {
                _userInfo = _inn.applyAML(string.Format("<AML><Item type='User' action='get' select='default_vault' expand='1'><id>{0}</id><Relationships><Item type='ReadPriority' action='get' select='priority, related_id' expand='1' orderBy='priority'/></Relationships></Item></AML>", _inn.getUserID()));
            }

            if (action == "ApplyItem" || action == "ApplyAML")
            {
                var     fileNodes = XPathCache.SelectNodes("descendant-or-self::Item[@type='File' and (@action='add' or @action='update' or @action='create') and actual_filename]", inputDoc.DocumentElement);
                XmlNode locatedNode;
                if (fileNodes.Count > 0)
                {
                    Item fileItem = _inn.newItem();
                    foreach (var fileNode in fileNodes.OfType <XmlElement>())
                    {
                        if (string.IsNullOrEmpty(fileNode.Attribute("id")))
                        {
                            fileNode.Attr("id", _inn.getNewID());
                        }
                        fileNode.Elem("checkedout_path", Path.GetDirectoryName(fileNode.Element("actual_filename", "")));
                        fileNode.Elem("filename", Path.GetFileName(fileNode.Element("actual_filename", "")));
                        locatedNode = XPathCache.SelectSingleNode("Relationships/Item[@type='Located']/related_id", fileNode);
                        if (locatedNode == null)
                        {
                            fileItem.dom      = inputDoc;
                            fileItem.node     = (XmlElement)fileNode;
                            fileItem.nodeList = null;
                            fileItem.attachPhysicalFile(fileNode.Element("actual_filename", ""), _userInfo.getProperty("default_vault"));
                        }
                    }

                    var firstItem = XPathCache.SelectSingleNode("//Item[1]", inputDoc.DocumentElement);
                    IList <XmlElement> items;
                    if (firstItem.ParentNode == null)
                    {
                        items = new XmlElement[] { (XmlElement)firstItem };
                    }
                    else
                    {
                        items = firstItem.Parent().Elements("Item").ToList();
                    }

                    Item       result;
                    XmlElement resultNode = null;

                    for (var i = 0; i < items.Count; i++)
                    {
                        fileItem.dom      = items[i].OwnerDocument;
                        fileItem.node     = items[i];
                        fileItem.nodeList = null;
                        result            = fileItem.apply();
                        fault             = XPathCache.SelectSingleNode(faultXPath, result.dom.DocumentElement);
                        if (fault != null)
                        {
                            fault.AppendChild(result.dom.CreateElement("original_query")).InnerText = input;
                            return(result.dom.DocumentElement.OuterXml);
                        }
                        else if (result.isError())
                        {
                            throw new InvalidOperationException();
                        }

                        if (outputDoc == null)
                        {
                            outputDoc  = result.dom;
                            resultNode = XPathCache.SelectSingleNode("//Item[1]", outputDoc.DocumentElement).Parent() as XmlElement;
                        }
                        else
                        {
                            resultNode.AppendChild(outputDoc.ImportNode(result.node, true));
                        }

                        if (progressReporter != null)
                        {
                            progressReporter.ReportProgress(i + 1, items.Count);
                        }
                    }

                    return(outputDoc.OuterXml);
                }
            }

            outputDoc = new XmlDocument();
            outputDoc.Elem("Empty");
            _inn.getConnection().CallAction(action, inputDoc, outputDoc);
            fault = XPathCache.SelectSingleNode(faultXPath, outputDoc.DocumentElement);
            if (fault != null)
            {
                fault.AppendChild(outputDoc.CreateElement("original_query")).InnerText = input;
            }
            return(outputDoc.DocumentElement.OuterXml);
        }
        private void ActivityForm_Load(object sender, EventArgs e)
        {
            //1 Get the WorkFlow Name based on the docid is related to primarylinkedid (CBP) populate form
            Item Workflow = inn.applyAML(u.AddtoItem(Settings.Default.getWorkFlowAML, "source_id", primarylinkedid));
            //need to fix to check for first occurance of "related_id"
            string Workflowprocessid = Workflow.getProperty("related_id");
            Item   WorkFlowProcess   = inn.applyAML(u.AddtoItem(Settings.Default.getWorkFlowProcessAML, "id", Workflowprocessid));
            string WorkflowName      = inn.applyAML(u.AddtoItem(Settings.Default.getWorkflowMapNameAML, "id", WorkFlowProcess.getProperty("copied_from_string"))).getProperty("name");

            WorkflowNameLbl.Text = WorkflowName;

            //Get current Activity.  Get list of all activities and see which one is active
            Item WorkFlowProcessActivities = inn.applyAML(u.AddtoItem(Settings.Default.getActivitiesAML, "source_id", Workflowprocessid));

            for (int i = 0; i < WorkFlowProcessActivities.getItemCount(); i++)
            {
                Item   WorkFlowProcessActivity = WorkFlowProcessActivities.getItemByIndex(i);
                Item   Activity     = WorkFlowProcessActivity.getPropertyItem("related_id");
                string currentstate = Activity.getPropertyAttribute("current_state", "keyed_name");
                if (currentstate == "Active")
                {
                    string currentactivity = Activity.getPropertyAttribute("config_id", "keyed_name");
                    ActivityNameLabel.Text = currentactivity;
                    currentActivityID      = Activity.getID();
                    break;
                }
            }

            //Get the tasks to complete based on the currentActivityID
            Item tasks = inn.applyAML(u.AddtoItem(Settings.Default.getTasksAML, "source_id", currentActivityID));

            for (int i = 0; i < tasks.getItemCount(); i++)
            {
                Item task = tasks.getItemByIndex(i);

                string sequence    = task.getProperty("sequence", "");
                string is_required = task.getProperty("is_required");
                string description = task.getProperty("description");
                //add to taskdatagrid
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(TaskDataGridView);
                row.Cells[0].Value = sequence;
                row.Cells[1].Value = is_required == "1" ? 1 : 0;
                row.Cells[2].Value = description;
                row.Cells[3].Value = 0;
                row.Cells[4].Value = task.getID();
                TaskDataGridView.Rows.Add(row);
            }

            //get list of voting options.
            VoteComboBox.Items.Clear();
            Item votes = inn.applyAML(u.AddtoItem(Settings.Default.getVotePaths, "source_id", currentActivityID));

            for (int i = 0; i < votes.getItemCount(); i++)
            {
                Item   vote            = votes.getItemByIndex(i);
                string votedescription = vote.getProperty("name");
                VoteComboBox.Items.Add(votedescription);
                Item activity = vote.getPropertyItem("related_id");
                //Don't know what to do with these options.
                if (activity.getProperty("can_delegate") == "1")
                {
                    VoteComboBox.Items.Add("Delegate");
                }
                if (activity.getProperty("can_refuse") == "1")
                {
                    VoteComboBox.Items.Add("Refuse");
                }
            }

            //get user information this is used when completing the activity
            string UserID = inn.getUserID();

            loggedinuserID = inn.applyAML(u.AddtoItem(Settings.Default.getLoggedInIdentityID, "id", inn.getUserID())).getProperty("owned_by_id");
        }
 public string GetCurrentUserId()
 {
     return(Innovator.getUserID());
 }
Beispiel #6
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpCookie cookie = HttpContext.Request.Cookies["Passport.Token"];

            if (cookie == null) // 站内凭证不存在
            {
                Response.Redirect("/Login/Index");
            }
            else
            {
                if (Userinfo == null || Userinfo.LoginName != cookie.Value)
                {
                    //string language = Request.Headers["Accept-Language"].ToString();
                    //language = language.Split(',')[0].ToString();
                    Userinfo = UserBll.GetUserInfoByUserName(cookie.Value);

                    if (Userinfo == null)
                    {
                        Response.Redirect("/Login/Index");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(Userinfo.department))
                        {
                            CommonMethod.GetAdInfoByUser(Userinfo, "bordrin.com");
                        }
                        ViewBag.userName = Userinfo.UserName;
                        ViewBag.language = Userinfo.language;
                    }

                    bool isaddCache = false;

                    inn = Userinfo.inn;
                    if (inn == null || inn.getUserID() != Userinfo.UserId)
                    {
                        using (ArasInnovator arasConn = new ArasInnovator())
                        {
                            inn          = arasConn.ArasConnection(Userinfo.LoginName, Userinfo.Password);
                            Userinfo.inn = inn;
                            isaddCache   = true;
                        }
                    }


                    //如果角色为空,获取角色权限
                    if (Userinfo.Roles == null)
                    {
                        Userinfo.Roles = IdentityDA.getIdentityListByUserID(inn, Userinfo.UserId);
                        isaddCache     = true;
                    }

                    //如果菜单权限为空,获取菜单权限
                    if (Userinfo.MemuAuth == null)
                    {
                        Userinfo.MemuAuth = new List <string>();
                        for (int j = 0; j < Userinfo.Roles.Count; j++)
                        {
                            string id = Userinfo.Roles[j];
                            //根据Id获取权限列表
                            Item ItemTypes = ItemTypeDA.GetMenuAuthByIdentity(inn, id);
                            if (ItemTypes.getItemCount() > 0)
                            {
                                for (int i = 0; i < ItemTypes.getItemCount(); i++)
                                {
                                    Item   itemobj  = ItemTypes.getItemByIndex(i);
                                    string itemName = itemobj.getProperty("name");
                                    if (Userinfo.MemuAuth.IndexOf(itemName) < 0)
                                    {
                                        Userinfo.MemuAuth.Add(itemName);
                                    }
                                }
                            }
                        }
                        isaddCache = true;
                    }

                    //获取委托的权限数据
                    DateTime currentTime = DateTime.Now.AddMinutes(-10);
                    if ((Userinfo.AgentAuth == null && Userinfo.AgentCreateTime == null) || (Userinfo.AgentCreateTime != null && currentTime > Userinfo.AgentCreateTime))
                    {
                        List <AgentSetEntity> AgentSetList = AgentSetBll.GetAgentSetByUserName(Userinfo.UserName);
                        if (AgentSetList.Count > 0)
                        {
                            AgentSetBll.GetAgentRoles(inn, Userinfo, AgentSetList);
                            isaddCache = true;
                        }
                    }

                    //重新添加缓存
                    if (isaddCache)
                    {
                        CacheItemPolicy policy = new CacheItemPolicy();
                        policy.Priority = CacheItemPriority.NotRemovable;
                        MemoryCacheUtils.Set(Userinfo.LoginName, Userinfo, policy);
                    }
                }
                else
                {
                    ViewBag.userName = Userinfo.UserName;
                    ViewBag.language = Userinfo.language;
                }

                ViewData["MemuAuth"] = Userinfo.MemuAuth;
                string strController = filterContext.RouteData.Values["controller"].ToString();
                switch (strController)
                {
                case "MenuAuthManage":
                    string menuAuthManage = Userinfo.MemuAuth.Where(x => x == "b_MenuAuthManage").FirstOrDefault();
                    if (string.IsNullOrEmpty(menuAuthManage))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                case "RoleManage":
                    string roleManage = Userinfo.MemuAuth.Where(x => x == "b_RoleManage").FirstOrDefault();
                    if (string.IsNullOrEmpty(roleManage))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                case "ProjectManage":
                    string projectManage = Userinfo.MemuAuth.Where(x => x == "b_ProjectManage").FirstOrDefault();
                    if (string.IsNullOrEmpty(projectManage))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                case "OrganizationalStructure":
                    string organizationalStructure = Userinfo.MemuAuth.Where(x => x == "b_OrganizationalStructure").FirstOrDefault();
                    if (string.IsNullOrEmpty(organizationalStructure))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                case "User":
                    string user = Userinfo.MemuAuth.Where(x => x == "b_User").FirstOrDefault();
                    if (string.IsNullOrEmpty(user))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                case "ExpenseCategory":
                    string expenseCategory = Userinfo.MemuAuth.Where(x => x == "b_ExpenseCategory").FirstOrDefault();
                    if (string.IsNullOrEmpty(expenseCategory))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                case "ExpenseAuditConfiguration":
                    string expenseAuditConfiguration = Userinfo.MemuAuth.Where(x => x == "b_ExpenseAuditConfiguration").FirstOrDefault();
                    if (string.IsNullOrEmpty(expenseAuditConfiguration))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                case "AgentSet":
                    string agentSet = Userinfo.MemuAuth.Where(x => x == "b_AgentSet").FirstOrDefault();
                    if (string.IsNullOrEmpty(agentSet))
                    {
                        Response.Redirect("/Home/AuthWarn");
                    }
                    break;

                default:
                    break;
                }
            }
            base.OnActionExecuting(filterContext);
        }