Ejemplo n.º 1
0
        public static void FillResult(this IEnumerable <IOguObject> objs, List <IOguObject> queryResult, UserGraphControlObjectMask listMask,
                                      Func <IOguObject, bool> filter = null, Action <IOguObject, IOguObject> addedAction = null)
        {
            objs.ForEach(obj =>
            {
                if (((int)obj.ObjectType & (int)listMask) != 0)
                {
                    bool canAdd = true;

                    if (filter != null)
                    {
                        canAdd = filter(obj);
                    }

                    if (canAdd)
                    {
                        IOguObject newObj = OguBase.CreateWrapperObject(obj);

                        if (addedAction != null)
                        {
                            addedAction(obj, newObj);
                        }

                        queryResult.Add(newObj);
                    }
                }
            }
                         );
        }
        private void FillObjectToUsers(OguDataCollection <IUser> users, IOguObject obj)
        {
            OguBase wrappedObj = (OguBase)OguBase.CreateWrapperObject(obj);

            wrappedObj.FullPath = obj.FullPath;

            switch (obj.ObjectType)
            {
            case SchemaType.Users:
                if (users.Exists(u => string.Compare(u.ID, obj.ID, true) == 0) == false)
                {
                    users.Add((IUser)wrappedObj);
                }
                break;

            case SchemaType.Groups:
                IGroup group = (IGroup)wrappedObj;
                group.Members.ForEach(u =>
                {
                    if (users.Exists(ul => string.Compare(ul.ID, u.ID, true) == 0) == false)
                    {
                        users.Add(u);
                    }
                });
                break;

            case SchemaType.Organizations:
            case SchemaType.OrganizationsInRole:
                IOrganization dept = (IOrganization)obj;
                dept.Children.ForEach(o => FillObjectToUsers(users, o));
                break;
            }
        }
Ejemplo n.º 3
0
        public static SchemaObjectBase ToSchemaObject(this ClientSchemaObjectBase clientObj, bool validateID)
        {
            clientObj.NullCheck("clientObj");
            clientObj.SchemaType.CheckStringIsNullOrEmpty("SchemaType");

            var config             = SchemaDefine.GetSchemaConfig(clientObj.SchemaType);
            SchemaObjectBase scObj = (SchemaObjectBase)config.CreateInstance();

            scObj.ID = clientObj.ID;

            if (validateID && clientObj.ID.IsNullOrEmpty())
            {
                throw new InvalidOperationException("客户端对象ID不存在");
            }

            scObj.Status           = (SchemaObjectStatus)clientObj.Status;
            scObj.CreateDate       = clientObj.CreateDate;
            scObj.VersionStartTime = clientObj.VersionStartTime;
            scObj.VersionEndTime   = clientObj.VersionEndTime;

            scObj.Properties.CopyFrom(clientObj.Properties);

            if (clientObj.Creator != null)
            {
                scObj.Creator = (IUser)OguBase.CreateWrapperObject(clientObj.Creator.ID, SchemaType.Users);
            }

            return(scObj);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <returns></returns>
        private DynamicEntity creatEntity()
        {
            string entityId = Guid.NewGuid().ToString();

            var entity = new DynamicEntity
            {
                ID = entityId,
                //CodeName = "Entity1",
                Name        = "实体1",
                Description = "描述",
                CreateDate  = DateTime.Now,
                CategoryID  = "763DF7AB-4B69-469A-8A01-041DDEAB19F7",//已存在的分类编码
                Fields      = new DynamicEntityFieldCollection(),
                //OuterEntities = new OuterEntityCollection(),
                Creator = (IUser)OguBase.CreateWrapperObject(new OguUser("22c3b351-a713-49f2-8f06-6b888a280fff")),//wangli5
                SortNo  = 0
            };

            for (var i = 0; i < 1; i++)
            {
                var field = creatEntityField();
                entity.Fields.Add(field);
            }
            return(entity);
        }
        private IEnumerable <IOguObject> groupControl_GetChildren(UserOUGraphControl treeControl, IOguObject parent)
        {
            IEnumerable <IOguObject> result = null;

            if (parent is IOrganization)
            {
                result = ((IOrganization)parent).Children;
            }
            else
            {
                List <IOguObject> resultList = new List <IOguObject>();

                if (parent is IGroup)
                {
                    foreach (IUser user in ((IGroup)parent).Members)
                    {
                        resultList.Add(OguBase.CreateWrapperObject(user));
                    }

                    result = resultList;
                }

                result = resultList;
            }

            return(result);
        }
 private static void AddUserToList(IUser user, List <IUser> targetUsers)
 {
     if (OguBase.IsNotNullOrEmpty(user))
     {
         targetUsers.Add((IUser)OguBase.CreateWrapperObject(user));
     }
 }
Ejemplo n.º 7
0
        protected void InnerGetDataSource(string sPrefix, int iCount, object context, ref IEnumerable result)
        {
            ServiceBrokerContext.Current.Timeout = QueryUserTimeout;

            IOrganization rootOrg = UserOUControlSettings.GetConfig().UserOUControlQuery.GetOrganizationByPath(this.RootPath);
            OguDataCollection <IOguObject> users = QueryChildrenBySelectMask(rootOrg, sPrefix);

            ArrayList arrList = new ArrayList();

            if (this.CanSelectRoot)
            {
                if (rootOrg.DisplayName.IndexOf(sPrefix) == 0)
                {
                    arrList.Add(OguBase.CreateWrapperObject(rootOrg));
                }
            }

            for (int i = 0; i < users.Count; i++)
            {
                //资源类型过滤
                IOguObject oguObject = OguBase.CreateWrapperObject(users[i]);

                if (this.SelectMask == UserControlObjectMask.All || (((int)this.SelectMask & (int)oguObject.ObjectType)) != 0)
                {
                    arrList.Add(oguObject);
                }
            }

            //修饰一下结果
            foreach (OguBase obj in arrList)
            {
                string path = string.Empty;
                if (obj.Parent != null)
                {
                    path = obj.Parent.FullPath;
                }

                if (path.IndexOf(rootOrg.FullPath) == 0)
                {
                    path = path.Substring(rootOrg.FullPath.Length);
                    path = path.Trim('\\');
                }

                if (obj is OguBase)
                {
                    // v-weirf changed : obj must be a OguBase to use Description
                    if (obj is IUser)
                    {
                        ((OguBase)obj).Description = string.Format("{0} {1}", ((IUser)obj).Occupation, path);
                    }
                    else if (obj is OguOrganization)
                    {
                        ((OguBase)obj).Description = path;
                    }
                }
            }

            result = arrList;
        }
 protected void userInput_ObjectsLoaded(object sender, IEnumerable data)
 {
     foreach (OguBase obj in data)
     {
         if (obj.Parent != null)
         {
             obj.Tag = JSONSerializerExecute.Serialize(OguBase.CreateWrapperObject(obj.Parent));
         }
     }
 }
Ejemplo n.º 9
0
        public static IOguObject ToOguObject(this WfClientOguObjectBase client)
        {
            OguBase result = null;

            if (client != null)
            {
                result             = (OguBase)OguBase.CreateWrapperObject(client.ID, client.ObjectType.ToOguSchemaType());
                result.Name        = client.Name;
                result.DisplayName = client.Name;
            }

            return(result);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 创建外部实体
        /// </summary>
        /// <returns></returns>
        private OuterEntityField createOuterEntityField(string flag = "new")
        {
            var outerEntity = new OuterEntityField()
            {
                ID          = Guid.NewGuid().ToString(),
                Name        = "外部实体字段",
                Description = "描述" + flag,
                //CodeName = "OuterEntityField",
                Creator = (IUser)OguBase.CreateWrapperObject(new OguUser("22c3b351-a713-49f2-8f06-6b888a280fff")),//wangli5
            };

            return(outerEntity);
        }
Ejemplo n.º 11
0
        private OguDataCollection <IOguObject> InnerCheckInputOuUser(string chkString)
        {
            //ServiceBrokerContext.Current.Timeout = QueryUserTimeout;

            IOrganization dept = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.FullPath, OguPermissionSettings.GetConfig().RootOUPath)[0];

            OguDataCollection <IOguObject> users       = QueryChildrenBySelectMask(dept, chkString);
            OguDataCollection <IOguObject> forSelected = new OguDataCollection <IOguObject>();

            for (int i = 0; i < users.Count; i++)
            {
                forSelected.Add(OguBase.CreateWrapperObject(users[i]));
            }

            if (dept.DisplayName.IndexOf(chkString) == 0)
            {
                forSelected.Add(OguBase.CreateWrapperObject(dept));
            }

            IOrganization root = OguMechanismFactory.GetMechanism().GetRoot();

            foreach (OguBase obj in forSelected)
            {
                string path = string.Empty;
                if (obj.Parent != null)
                {
                    path = obj.Parent.FullPath;
                }

                if (path.IndexOf(root.FullPath) == 0)
                {
                    path = path.Substring(root.FullPath.Length);
                    path = path.Trim('\\');
                }

                if (obj is IUser)
                {
                    ((OguUser)obj).Description = string.Format("{0} {1}", ((OguUser)obj).Occupation, path);
                }
                else if (obj is OguOrganization)
                {
                    ((OguOrganization)obj).Description = path;
                }
                else
                {
                    ((OguUser)obj).Description = path;
                }
            }

            return(forSelected);
        }
Ejemplo n.º 12
0
        public static WfClientOguObjectBase ToClientOguObject(this IOguObject oguObject)
        {
            WfClientOguObjectBase result = null;

            if (oguObject != null)
            {
                OguBase wrappedObj = (OguBase)OguBase.CreateWrapperObject(oguObject);

                string name = wrappedObj.IsNameInitialized() ? wrappedObj.Name : null;

                result = WfClientOguObjectBase.CreateWrapperObject(wrappedObj.ID, name, wrappedObj.ObjectType.ToClientOguSchemaType());
            }

            return(result);
        }
Ejemplo n.º 13
0
        public static IOguObject ToOguObject(this SCSimpleObject obj)
        {
            OguBase result = null;

            string     category   = SchemaDefine.GetSchemaConfig(obj.SchemaType).Category;
            SchemaType schemaType = SchemaExtensions.SchemaCategoryToOguSchemaType(category);

            if (schemaType != OGUPermission.SchemaType.Unspecified)
            {
                result             = (OguBase)OguBase.CreateWrapperObject(obj.ID, schemaType);
                result.Name        = obj.Name;
                result.DisplayName = obj.DisplayName;
            }

            return(result);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 创建实体字段
        /// </summary>
        /// <returns></returns>
        private DynamicEntityField creatEntityField(int sortNo, string flag = "new")
        {
            var field = new DynamicEntityField()
            {
                ID           = Guid.NewGuid().ToString(),
                Name         = string.Format("字段{0}", sortNo),
                Description  = "描述" + flag,
                Length       = 2,
                DefaultValue = "默认值",
                FieldType    = FieldTypeEnum.Decimal,
                Creator      = (IUser)OguBase.CreateWrapperObject(new OguUser("22c3b351-a713-49f2-8f06-6b888a280fff")),//wangli5
                SortNo       = sortNo
            };

            return(field);
        }
        /// <summary>
        /// 创建实体字段
        /// </summary>
        /// <returns></returns>
        private static DynamicEntityField CreateEntityField(string flag = "new")
        {
            var field = new DynamicEntityField()
            {
                ID           = Guid.NewGuid().ToString(),
                Name         = "字段",
                Description  = "描述" + flag,
                Length       = 2,
                DefaultValue = "默认值",
                FieldType    = FieldTypeEnum.Decimal,
                //CodeName = "Field",
                Creator = (IUser)OguBase.CreateWrapperObject(new OguUser("22c3b351-a713-49f2-8f06-6b888a280fff")),//wangli5
                SortNo  = 0
            };

            return(field);
        }
        public void ConvertToPropertyValue(Type objectValueType, object objectValue, PropertyValue pv, object target)
        {
            CheckObjectValueType(objectValueType, objectValue);

            pv.Definition.EditorKey    = "OUUserInputPropertyEditor";
            pv.Definition.EditorParams = JSONSerializerExecute.Serialize(CreateEditorParams(objectValueType, objectValue));

            if (objectValue != null)
            {
                if (objectValue is IEnumerable == false)
                {
                    objectValue = OguBase.CreateWrapperObject((IOguObject)objectValue);
                }

                pv.StringValue = GetPropertyValue(objectValueType, objectValue);
            }
        }
Ejemplo n.º 17
0
        private static void AssignUsers(List <AU.AURoleDisplayItem> items)
        {
            AU.AUCommon.DoDbAction(() =>
            {
                foreach (var item in items)
                {
                    var members = PC.Adapters.SCMemberRelationAdapter.Instance.LoadByContainerID(item.ID).FilterByStatus(PC.SchemaObjectStatusFilterTypes.Normal);

                    List <IUser> users = new List <IUser>();
                    foreach (var m in members)
                    {
                        users.Add((IUser)OguBase.CreateWrapperObject(new OguUser(m.ID)));
                    }

                    item.Users = users;
                }
            });
        }
Ejemplo n.º 18
0
        private void InitRootTreeNode()
        {
            IOrganization innerRoot = this.Root;

            ServiceBrokerContext.Current.SaveContextStates();

            try
            {
                if (ShowDeletedObjects)
                {
                    ServiceBrokerContext.Current.UseLocalCache       = false;
                    ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.All;
                }

                if (innerRoot == null)
                {
                    var tmpRootPath = this.RootPath;

                    if (string.IsNullOrEmpty(tmpRootPath))
                    {
                        tmpRootPath = OguPermissionSettings.GetConfig().RootOUPath;
                    }

                    innerRoot = UserOUControlSettings.GetConfig().UserOUControlQuery.GetOrganizationByPath(tmpRootPath); // OguMechanismFactory.GetMechanism().GetRoot();
                }

                DeluxeTreeNode rootNode = new DeluxeTreeNode();

                BindOguObjToTreeNode((IOrganization)OguBase.CreateWrapperObject(innerRoot), rootNode, MultiSelect, SelectMask);

                rootNodesData.Add(rootNode);

                if (RootExpanded)
                {
                    rootNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal;
                    rootNode.Expanded = true;
                    BindChildren(rootNode.Nodes, OnGetChildren(innerRoot), MultiSelect, ListMask, SelectMask);
                }
            }
            finally
            {
                ServiceBrokerContext.Current.RestoreSavedStates();
            }
        }
Ejemplo n.º 19
0
        public static void ExecuteReplace(ReplaceAssigneeHelperData rahd)
        {
            rahd.NullCheck("错误:传入参数为空");

            //取原始待办人
            IUser originalUser = (IUser)OguBase.CreateWrapperObject(rahd.OriginalUserID, SchemaType.Users);

            //取目的待办人
            List <IUser> targetUsers = new List <IUser>();

            foreach (string userID in rahd.TargetUsersID)
            {
                IUser targetUser = (IUser)OguBase.CreateWrapperObject(userID, SchemaType.Users);
                targetUsers.Add(targetUser);
            }

            //获取用户任务
            UserTaskCollection tasks = UserTaskAdapter.Instance.LoadUserTasks(
                build => build.AppendItem("TASK_GUID", rahd.TaskID, "="));

            (tasks.Count > 0).FalseThrow("指定的任务ID'{0}'不存在!", rahd.TaskID);

            //取出Activity
            string activityID = tasks[0].ActivityID;

            //待办人替换处理
            try
            {
                IWfProcess process = WfRuntime.GetProcessByActivityID(activityID);

                IWfActivity activity = process.Activities[activityID];

                //创建Executor并执行
                WfReplaceAssigneesExecutor replaceExec = new WfReplaceAssigneesExecutor(activity, activity,
                                                                                        originalUser, targetUsers);
                replaceExec.Execute();
            }
            catch
            {
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 将ClenteState中的信息生成ClientState字符串
        /// </summary>
        /// <returns>ClientState字符串</returns>
        protected override string SaveClientState()
        {
            object[] foArray = new object[2];
            var      tmpRoot = UserOUControlSettings.GetConfig().UserOUControlQuery.GetOrganizationByPath(this.RootPath);

            if (tmpRoot != null)
            {
                this.foOUCtrl.Root = tmpRoot;
            }

            for (int i = 0; i < this.SelectedOuUserData.Count; i++)
            {
                this.SelectedOuUserData[i] = (IOguObject)OguBase.CreateWrapperObject(this.SelectedOuUserData[i]);
            }

            OccupyUserPresenceAddress(this.SelectedOuUserData);

            foArray[0] = this.SelectedOuUserData;
            foArray[1] = this.Text;

            return(JSONSerializerExecute.Serialize(foArray));
        }
Ejemplo n.º 21
0
        private OguDataCollection <IOguObject> CreateWrappedObjects(IEnumerable <IOguObject> objects)
        {
            OguDataCollection <IOguObject> wrappedObjects = new OguDataCollection <IOguObject>();

            OguDataCollection <IUser> usersNeedToGetPresence = new OguDataCollection <IUser>();

            foreach (IOguObject obj in objects)
            {
                if (this.EnableUserPresence && obj is IUser)
                {
                    usersNeedToGetPresence.Add((IUser)obj);
                }

                wrappedObjects.Add(OguBase.CreateWrapperObject(obj));
            }

            if (this.EnableUserPresence)
            {
                OccupyUserPresenceAddress(wrappedObjects, usersNeedToGetPresence);
            }

            return(wrappedObjects);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <returns></returns>
        private DynamicEntity creatChildEntity(string categoryID)
        {
            string entityId = Guid.NewGuid().ToString();

            var entity = new DynamicEntity
            {
                ID          = entityId,
                Name        = "行项目实体1",
                Description = "描述",
                CreateDate  = DateTime.Now,
                CategoryID  = categoryID,//已存在的分类编码
                Fields      = new DynamicEntityFieldCollection(),
                SortNo      = 0,
                Creator     = (IUser)OguBase.CreateWrapperObject(new OguUser("22c3b351-a713-49f2-8f06-6b888a280fff")),//wangli5
            };

            for (var i = 0; i < 2; i++)
            {
                var field = creatEntityField(i);
                entity.Fields.Add(field);
            }
            return(entity);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jObject = JObject.Load(reader);

            JToken objTypeToken = jObject.GetValue("objectType");
            string id           = (string)jObject.GetValue("id");

            SchemaType objType = DataConverter.ChangeType <int, SchemaType>((int)objTypeToken);

            OguBase oguObj = (OguBase)OguBase.CreateWrapperObject(id, objType);

            oguObj.Name        = (string)jObject.GetValue("name");
            oguObj.DisplayName = (string)jObject.GetValue("displayName");
            oguObj.Description = (string)jObject.GetValue("description");
            oguObj.FullPath    = (string)jObject.GetValue("fullPath");

            string codeName = (string)jObject.GetValue("codeName");

            (oguObj as OguUser).IsNotNull(user => user.LogOnName = codeName);
            (oguObj as OguOrganization).IsNotNull(org => org.Properties["codeName"] = codeName);
            (oguObj as OguGroup).IsNotNull(group => group.Properties["codeName"]    = codeName);

            return(oguObj);
        }
Ejemplo n.º 24
0
        private OguDataCollection <IOguObject> InnerCheckInputOuUser(string chkString)
        {
            ServiceBrokerContext.Current.Timeout = QueryUserTimeout;

            IOrganization root = UserOUControlSettings.GetConfig().UserOUControlQuery.GetOrganizationByPath(this.RootPath);

            OguDataCollection <IOguObject> users       = QueryChildrenBySelectMask(root, chkString);
            OguDataCollection <IOguObject> forSelected = new OguDataCollection <IOguObject>();

            for (int i = 0; i < users.Count; i++)
            {
                if (((int)users[i].ObjectType & (int)this.SelectMask) != 0)
                {
                    forSelected.Add(OguBase.CreateWrapperObject(users[i]));
                }
            }

            if (this.CanSelectRoot)
            {
                if (root.DisplayName.IndexOf(chkString) == 0)
                {
                    forSelected.Add(OguBase.CreateWrapperObject(root));
                }
            }

            //沈峥添加,修饰一下Description
            //IOrganization root = OguMechanismFactory.GetMechanism().GetRoot();

            foreach (OguBase obj in forSelected)
            {
                string path = string.Empty;
                if (obj.Parent != null)
                {
                    path = obj.Parent.FullPath;
                }

                if (path.IndexOf(root.FullPath) == 0)
                {
                    path = path.Substring(root.FullPath.Length);
                    path = path.Trim('\\');
                }

                if (obj is OguBase)
                {
                    //v-weirf changed, for Description setable,obj must be OguBase
                    if (obj is IUser)
                    {
                        ((OguBase)obj).Description = string.Format("{0} {1}", ((IUser)obj).Occupation, path);
                    }
                    else if (obj is IOrganization)
                    {
                        ((OguBase)obj).Description = path;
                    }
                    else
                    {
                        ((OguBase)obj).Description = path;
                    }
                }
            }

            return(forSelected);
        }