Inheritance: System.Web.UI.Page
Exemplo n.º 1
0
        public ActionResult UsersList()
        {
            List <UsersListVM> l_ousersList = new List <UsersListVM>();
            UsersListVM        l_oUserListVM;

            using (MasterDbContext db = new MasterDbContext())
            {
                foreach (var User in db.users.ToList())
                {
                    group l_oGroup = new group();
                    l_oGroup = db.groups.Where(b => b.id == User.groupId).FirstOrDefault();

                    l_oUserListVM = new UsersListVM(User, l_oGroup.groupName);

                    l_ousersList.Add(l_oUserListVM);
                }
                return(View(l_ousersList));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Enumerates all units within the group that match the given filter. This will empty the group in the process.
 /// </summary>
 public static IEnumerable <unit> Enumerate(this group group, Func <unit, bool> filter)
 {
     while (true)
     {
         var unit = FirstOfGroup(group);
         if (unit == null)
         {
             yield break;
         }
         else
         {
             GroupRemoveUnit(group, unit);
             if (filter.Invoke(unit))
             {
                 yield return(unit);
             }
         }
     }
 }
Exemplo n.º 3
0
        internal group SerializeGroup(Group grp, string rootPath)
        {
            if (grp == null)
            {
                return(null);
            }
            var ret = new group();

            ret.name            = grp.Name;
            ret.background      = (grp.Background ?? "").Replace(rootPath, "");
            ret.backgroundStyle = (groupBackgroundStyle)Enum.Parse(typeof(groupBackgroundStyle), grp.BackgroundStyle);
            grp.BoardPosition   = grp.BoardPosition ?? new DataRectangle();
            ret.boardPosition   = string.Join(",", grp.BoardPosition.X, grp.BoardPosition.Y, grp.BoardPosition.Width, grp.BoardPosition.Height);
            ret.collapsed       = grp.Collapsed ? boolean.True : boolean.False;
            ret.height          = grp.Height.ToString();
            ret.width           = grp.Width.ToString();
            ret.icon            = (grp.Icon ?? "").Replace(rootPath, "");
            ret.ordered         = grp.Ordered ? boolean.True : boolean.False;
            ret.shortcut        = grp.Shortcut;
            var itemList = SerializeActions(grp.CardActions).ToList();

            itemList.AddRange(SerializeActions(grp.GroupActions).ToArray());
            ret.Items = itemList.ToArray();
            switch (grp.Visibility)
            {
            case GroupVisibility.Undefined:
                ret.visibility = groupVisibility.undefined;
                break;

            case GroupVisibility.Nobody:
                ret.visibility = groupVisibility.none;
                break;

            case GroupVisibility.Owner:
                ret.visibility = groupVisibility.me;
                break;

            case GroupVisibility.Everybody:
                ret.visibility = groupVisibility.all;
                break;
            }
            return(ret);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Borra un grupo especificado por su Id
        /// </summary>
        /// <param name="groupId">Id del grupo a borrar</param>
        /// <returns>
        /// True si se pudo borrar, false en caso contrario
        /// </returns>
        public bool DeleteGroup(long groupId)
        {
            try
            {
                IEnumerable <group> query = from groups in data.groups
                                            where groups.group_id == groupId
                                            select groups;

                group group = query.First <group>();

                this.data.groups.DeleteOnSubmit(query.First <group>());
                this.data.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public JsonResult UpdateGroupDetails(StudentGroupViewModel grp)
        {
            group gp = new group()
            {
                Id = grp.group_id
            };

            db.groups.Attach(gp);
            gp.GroupName = grp.Group_Name;
            //user.Is_Pending = false;

            db.SaveChanges();
            notification not = new notification();

            not.Notification_Msg = "Your Group name is Changed to " + grp.Group_Name + " By Admin";
            not.Group_Id         = grp.group_id;
            NotificationAdd(grp.group_id);
            return(Json(new { success = true, msg = "Updated" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Cambia la privacidad del grupo
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="isPrivate">Lo ponemos a true si queremos que el grupo sea privado y viceversa</param>
        /// <returns>
        /// True si se pudo cambiar, false en caso contrario
        /// </returns>
        public bool SetGroupPrivacy(long groupId, bool isPrivate)
        {
            var query = from groups in data.groups
                        where groups.group_id == groupId
                        select groups;

            try
            {
                group group = query.First <group>();
                group.group_is_private = isPrivate;

                data.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        // GET: Groups/Delete/5
        public ActionResult Delete(int?id)
        {
            ViewBag.Updates      = db.updates.ToList().OrderBy(t => t.update_date).Reverse();
            ViewBag.contentNote  = db.contents.ToList().OrderBy(p => p.content_id).Reverse();
            ViewBag.responseNote = db.responses.ToList().OrderBy(s => s.response_date).Reverse();
            ViewBag.reactionNote = db.reactions.ToList();
            ViewBag.users        = db.users.ToList();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            group group = db.groups.Find(id);

            if (group == null)
            {
                return(HttpNotFound());
            }
            return(View(group));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Crea un grupo con el nombre especificado por el usuario especificado
        /// </summary>
        /// <param name="name">Nombre del grupo</param>
        /// <param name="userId">Usuario que crea el grupo</param>
        /// <returns>
        /// True si pudo crear el grupo, false en caso contrario
        /// </returns>
        public bool CreateGroup(string name, long userId)
        {
            try
            {
                group group = new group();
                group.group_creation = DateTime.Now;
                group.group_name     = name;
                group.user_id_owner  = userId;

                data.groups.InsertOnSubmit(group);
                data.SubmitChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 9
0
        public ActionResult AddProjects(int GroupId)
        {
            //iewBag.ProjectID = ProjectID;

            group model = groupRepository.FindGroup(GroupId);

            ViewBag.PossibleProjects = projectRepository.All;

            //model.selectedProject = ProjectID;

            //var project = projectRepository.Find(ProjectID);
            //model.projects.Add(project);
            //{
            //    projectIds = new int[0]
            //};


            return(PartialView("ProjectCheckList", model));
        }
Exemplo n.º 10
0
        public SearchGroup ProcessGroup(group g)
        {
            SearchGroup group = new SearchGroup();

            group.IsAndOperator = g.selectedLogicalOperator == "AND";
            foreach (var c in g.children)
            {
                if (c.GetType() == typeof(group))
                {
                    group.Children.Add(this.ProcessGroup((group)c));
                }
                else
                {
                    group.Children.Add(this.ProcessCondition((condition)c));
                }
            }

            return(group);
        }
Exemplo n.º 11
0
 void register(group g)
 {
     // phbContext db3 = new phbContext();
     if (g.groupName.Length >= 2 && new CRUD_Group().search(g) != true)
     {
         // db3.groups.Add(new group { groupName = g.groupName, persons = g.persons });
         // db3.SaveChanges();
         new CRUD_Group().Create(new group {
             groupName = g.groupName, persons = g.persons
         });
         GroupSuccessForm gsf = new GroupSuccessForm();
         gsf.Show();
     }
     else
     {
         GroupFailedForm gff = new GroupFailedForm();
         gff.Show();
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Method to add a group-associated picture file both physically on the server and in the database.
 /// The file must be passed as a Byte array parameter.
 /// </summary>
 /// <param name="fileByteArray">The Byte array of the picture file itself.</param>
 /// <param name="groupID">The group ID (Int32) of the group the picture is associated to.</param>
 /// <param name="originalFileName">The original file name (String) saved by the database for later user readability</param>
 public void AddPictureToGroup(Byte[] fileByteArray, int groupID, string originalFileName)
 {
     try
     {
         group  groupe      = groupService.GetByID(groupID);
         string pictureLink = SaveByteFile(fileByteArray, originalFileName);
         groupe.Group_picture_link = pictureLink;
         groupService.Update(groupe);
         file Fichier = new file();
         Fichier.FileURL  = pictureLink;
         Fichier.FileName = originalFileName;
         fileService.InsertFileInformations(Fichier);
     }
     catch (Exception error)
     {
         Debug.WriteLine(error.Message);
         throw new ControllerException(error.Message);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// 查找历史位置
 /// </summary>
 /// <param name="value">待查找对象</param>
 /// <param name="key">查找关键字</param>
 /// <param name="values">列表数据集合</param>
 /// <returns>历史位置,失败为-1</returns>
 private int indexOf(valueType value, keyType key, out group values)
 {
     if (groups.TryGetValue(key, out values))
     {
         valueType[] array = values.List.UnsafeArray;
         int         index = Array.LastIndexOf(array, value, values.List.Count - 1);
         if (index != -1)
         {
             if (values.Index > index)
             {
                 values.Index = index;
                 groups[key]  = values;
             }
             return(index);
         }
     }
     log.Error.Add(typeof(valueType).FullName + " 缓存同步错误", null, true);
     return(-1);
 }
Exemplo n.º 14
0
 public void MinGroup(int group_id)
 {
     try
     {
         group group = db.groups.Where((x) => x.idgroups == group_id).First();
         decimal[,] matrix = new decimal[group.users.Count, group.users.Count];
         var list = group.users.ToList();
         for (var i = 0; i < list.Count; i++)
         {
             var debt_list = list[i].debts.Where((x) => x.column == list[i].id).ToList();
             foreach (var debt in debt_list)
             {
                 int user_id = list.IndexOf(db.users.Where((x) => x.id == debt.row).First());
                 if (user_id != -1)
                 {
                     matrix[user_id, i] = debt.value.Value;
                     db.debts.Remove(debt);
                 }
             }
         }
         //db.SaveChanges();
         Res(matrix);
         for (int i = 0; i < list.Count; i++)
         {
             for (int j = 0; j < list.Count; j++)
             {
                 if (matrix[i, j] != 0)
                 {
                     debt d = new debt();
                     d.row    = list[i].id;
                     d.column = list[j].id;
                     d.value  = matrix[i, j];
                     list[i].debts1.Add(d);
                 }
             }
         }
         db.SaveChanges();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 15
0
        public ActionResult AddProjects(group group)
        {
            if (ModelState.IsValid)
            {
                group originalGroup = this.groupRepository.FindGroup(group.groupID);

                originalGroup.groupName = group.groupName;

                //originalGroup.groupManager = group.groupManager;


                originalGroup.projects.Clear();


                if (group.projectIds != null)
                {
                    originalGroup.projects = (from s in this.projectRepository.All where @group.projectIds.Contains(s.projectID) select s).ToList();
                }

                groupRepository.InsertOrUpdate(originalGroup);

                try
                {
                    // Your code...
                    // Could also be before try if you know the exception occurs in SaveChanges

                    groupRepository.Save();
                }
                catch (DbEntityValidationException e)
                {
                }

                //projectRepository.Save();
                string url = Url.Action("ProjectIndex", "Project", new { id = originalGroup.groupID });
                return(Json(new { success = true, url = url }));
            }
            else
            {
                ViewBag.PossibleProjects = projectRepository.All;
                return(PartialView("AddProjects", group));
            }
        }
Exemplo n.º 16
0
        public ActionResult Group(group model, string groupBut)
        {
            GroupManager GM = new GroupManager();

            if (groupBut.Equals("Join Group"))
            {
                GM.AddMember(model, User.Identity.Name);
                return(View(model));
            }
            else if (groupBut.Equals("Leave Group"))
            {
                GM.RemoveMember(model, User.Identity.Name);
                return(RedirectToAction("Groups", "Account"));
            }
            else if (groupBut.Equals("Manage Group"))
            {
                return(RedirectToAction("ManageGroup", new { g_id = model.group_id }));
            }
            return(View(model));
        }
        void register(group g)
        {
            phbContext db1 = new phbContext();

            if (g.groupName.Length >= 2 && search(g) != true)
            {
                db1.groups.Add(new group {
                    groupName = g.groupName, persons = g.persons
                });

                db1.SaveChanges();
                MessageBox.Show("ثبت شد" + GroupNamebunifuMaterialTextbox1.Text + "گروه");

                NewGroupMemberlistBox1.ClearSelected();
            }
            else
            {
                MessageBox.Show("امکان ثبت  وجود ندارد");
            }
        }
Exemplo n.º 18
0
        public RequestResponse createGroup(Groupdto group)
        {
            GroupLogic ul = new GroupLogic();
            group      g  = group.castDtoToDull();

            db.db.groups.Add(g);
            if (!db.Save())
            {
                return new RequestResponse()
                       {
                           Message = "שגיאה בשמירה", Result = false
                       }
            }
            ;
            group.dullToDto(g);
            return(new RequestResponse()
            {
                Message = "הפתיחה בוצעה בהצלחה", Result = true, Data = group
            });
        }
Exemplo n.º 19
0
        /// <summary>
        /// Recherche des follower actif d'un groupe
        /// </summary>
        /// <param name="groupID">Le ID du groupe pour lequel nous désirons les followers</param>
        /// <returns>Une liste de follower, une liste vide sinon</returns>
        public IEnumerable <person> GetTheFollowers(object groupID)
        {
            if (groupID == null)
            {
                throw new ServiceException("Le ID du group est null");
            }

            try
            {
                using (var context = new pigeonsEntities1())
                {
                    group group = groupDAO.GetByID(context, groupID);

                    if (group == null)
                    {
                        throw new ServiceException("Ce groupe n'existe pas");
                    }

                    if (!group.Is_active)
                    {
                        throw new ServiceException("Ce groupe n'est pas actif");
                    }

                    IEnumerable <following> followingList = followingDAO.GetTheFollowers(context, groupID);
                    IList <person>          followers     = new List <person>();

                    foreach (following follower in followingList)
                    {
                        if (follower.Is_active)
                        {
                            followers.Add(follower.person);
                        }
                    }
                    return(followers);
                }
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Authenticates a user against a database, web service, etc.
        /// </summary>
        /// <param name="username">Username</param>
        /// <param name="password">Password</param>
        /// <returns>User</returns>
        public static employee AuthenticateUser(string username, string password, CronusDatabaseEntities db)
        {
            employee user = null;

            // Lookup user in database, web service, etc. We'll just generate a fake user for this demo.

            var employeeIDList = db.employees.Select(x => x.employeeID).ToList();

            if (employeeIDList.Contains(username))
            {
                user = db.employees.Find(username);

                //bool isManager = db.groups.Select(g => g).Where(g => g.groupManager.Equals(user.employeeID)).Any();
                int?employeeManages = null;

                group group = db.groups.Select(g => g).Where(g => g.groupManager.Equals(user.employeeID)).FirstOrDefault();

                if (group != null)
                {
                    employeeManages = group.groupID;
                }

                if (user.employeePwd == password)
                {
                    user = new employee {
                        employeeID       = user.employeeID, employeeFirstName = user.employeeFirstName,
                        employeeLastName = user.employeeLastName, employeePrivileges = user.employeePrivileges,
                        managesgroup     = employeeManages/*, isManager = isManager*/
                    };
                    return(user);
                }

                return(null);
            }
            //if (username == "abel" && password == "abel")
            //{
            //    user = new employee { employeeID = "125", employeeFirstName = "Abel", employeeLastName = "Teferra" };
            //}

            return(user);
        }
Exemplo n.º 21
0
 //succesful integrated into a new group
 private void changeGroup()
 {
     newGroup.currentGroup.Add(gameObject);
     //on Territory change forget about the former partner
     if (partner != null)
     {
         partner.GetComponent <wolf>().partner = null;
         partner = null;
     }
     group.currentGroup.Remove(gameObject);
     group = newGroup;
     GetComponentInChildren <Renderer>().material.color = newGroup.color;
     newGroup    = null;
     withParents = false;
     state       = States.idl;
     //search for new Partner in the new Group
     if (age > 0)
     {
         findPartner();
     }
 }
Exemplo n.º 22
0
        protected void btnAddGroup_Click(object sender, EventArgs e)
        {
            string groupName = "НОВАЯ ГРУППА";
            var    db        = new ssmDataContext();
            var    nGroup    = new group {
                name = groupName
            };

            db.groups.InsertOnSubmit(nGroup);
            db.SubmitChanges();
            lstGroupFill();
            if (lstGroup.Items.FindByText(groupName) != null)
            {
                lstGroup.SelectedIndex = lstGroup.Items.IndexOf(lstGroup.Items.FindByText(groupName));
                lstGroup_SelectedIndexChanged(new object(), new EventArgs());
            }
            else
            {
                txtGroupName.Text = lstGroup.SelectedItem.Text;
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Appel le DAO pour trouver les Events d'un groupe qui ne sont pas complétés
        /// </summary>
        /// <param name="groupID">Le ID du groupe</param>
        /// <param name="date">La date visible du calendrier pour laquel nous voulons les events</param>
        /// <returns>Une liste de Events ou une liste vide</returns>
        public IEnumerable <@event> GetGroupEvent(object groupID, object date)
        {
            if (groupID == null)
            {
                throw new ServiceException("Le ID du group est null");
            }

            try
            {
                using (var context = new pigeonsEntities1())
                {
                    // Validation du groupe
                    group groupValidation = groupDAO.GetByID(context, groupID);

                    if (groupValidation == null)
                    {
                        throw new ServiceException(string.Format("Le groupe no.{0} n'existe pas", groupID));
                    }

                    if (!groupValidation.Is_active)
                    {
                        throw new ServiceException(string.Format("Le groupe no.{0} n'est pas actif.", groupID));
                    }

                    // Recherche des events
                    if (date == null)
                    {
                        return(eventDAO.GetGroupEvent(context, groupID));
                    }
                    else
                    {
                        return(eventDAO.GetGroupEventByMonth(context, groupID, date));
                    }
                }
            }
            catch (DAOException daoException)
            {
                throw new ServiceException(daoException.Message);
            }
        }
Exemplo n.º 24
0
        public override Cast GetBestCast(Playfield p)
        {
            Cast bc = null;

            // Peros: Contains mobs, buildings and towers
            group ownGroup = p.getGroup(true, 85, boPriority.byTotalNumber, 3000);

            #region Apollo Magic
            FightState currentSituation = CurrentFightState(p);
            Handcard   hc = SpellMagic(p, currentSituation);
            if (hc == null)
            {
                return(null);
            }

            VectorAI nextPosition = GetNextSpellPosition(currentSituation, hc, p);
            bc = new Cast(hc.name, nextPosition, hc);
            #endregion

            Logger.Information("BestCast: {SpellName} {Position}", bc?.SpellName, bc?.Position);
            return(bc);
        }
Exemplo n.º 25
0
        public async Task <ActionResult> Create([Bind(Include = "id_key,title,level,orders,desc,flag")] group group)
        {
            try
            {
                group.id         = Guid.NewGuid();
                group.app_key    = Common.Objects.groups.reportDay;
                group.created_by = Authentication.Auth.AuthUser.id.ToString();
                group.created_at = DateTime.Now;
                group.updated_by = Authentication.Auth.AuthUser.id.ToString();
                group.updated_at = DateTime.Now;
                db.groups.Add(group);
                await db.SaveChangesAsync();

                this.success(TM.Common.Language.msgCreateSucsess);
                return(RedirectToAction("Create"));
            }
            catch (Exception)
            {
                this.danger(TM.Common.Language.msgCreateError);
            }
            return(View(group));
        }
Exemplo n.º 26
0
        public async Task <ActionResult> Edit([Bind(Include = "id,id_key,title,level,orders,desc,flag")] group group)
        {
            try
            {
                db.groups.Attach(group);
                var entry = db.Entry(group);
                entry.Property(m => m.title).IsModified  = true;
                entry.Property(m => m.level).IsModified  = true;
                entry.Property(m => m.orders).IsModified = true;
                entry.Property(m => m.desc).IsModified   = true;
                entry.Property(m => m.flag).IsModified   = true;
                await db.SaveChangesAsync();

                this.success(TM.Common.Language.msgUpdateSucsess);
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                this.danger(TM.Common.Language.msgUpdateError);
            }
            return(View(group));
        }
Exemplo n.º 27
0
        /// <summary>
        /// Метод для получения комментариев конкретной группы
        /// </summary>
        /// <param name="group">Группа, комментарии которой нужно получить</param>
        /// <returns></returns>
        public List <group_comments> SelectGroupComments(group group)
        {
            List <group_comments> groupComments = new List <group_comments>();

            using (var connection = SqlConncetionHelper.Connection)
            {
                connection.Open();
                DbCommand command = connection.CreateCommand();

                DbParameter groupParameter = command.CreateParameter();
                groupParameter.DbType        = DbType.Int32;
                groupParameter.ParameterName = "@GroupId";
                groupParameter.Value         = group.Group_id;

                command.Parameters.Add(groupParameter);
                command.CommandText = "select * from group_comments" +
                                      " where group_id = @GroupId";

                DbDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    group_comments comment = new group_comments()
                    {
                        Gc_id        = (int)reader["gc_id"],
                        User_id      = (int)reader["user_id"],
                        Group_id     = (int)reader["group_id"],
                        Comment_text = reader["comment_text"].ToString(),
                        Send_date    = (DateTime)reader["send_date"]
                    };
                    comment.User = GetGroupCommentUser(comment);

                    groupComments.Add(comment);
                }
            }

            return(groupComments);
        }
Exemplo n.º 28
0
        //gets projects for the calender
        public JsonResult GetEvents(string empId)
        {
            //create an employee object mathcing the empId passed through
            employee emp    = db.employees.Find(empId);
            var      dbGrps = db.groups.ToList();
            //all groups where the employee is within the list of employees assigned to the group.
            var groups = (from s in dbGrps where s.employees.Contains(emp) select s).ToList();

            //list of projects to return
            List <project> returnProj = new List <project>();

            //for each group found for that employee
            foreach (group grp in groups)
            {
                group grpObject  = db.groups.Find(grp.groupID);
                var   dbProjects = db.projects.ToList();
                //you find a list of projects where the project has that group assigned to it.
                List <project> projects = (from s in dbProjects where s.groups.Contains(grpObject) select s).ToList();

                foreach (project proj in projects)
                {
                    //for each of those projects, add them to the returnProj list.
                    if (proj.projectActive == 1)
                    {
                        returnProj.Add(new project()
                        {
                            projectID        = proj.projectID,
                            projectName      = proj.projectName,
                            projectStartDate = proj.projectStartDate,
                            projectEndDate   = proj.projectEndDate
                        });
                    }
                }
            }

            //return a list of projects defined above
            return(Json(returnProj, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 29
0
        public HttpResponseMessage CreateANewGroup(GroupClassCustom listOfGroup)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (var context_Var = new MlaDatabaseEntities1())
                    {
                        int id1;


                        id1 = listOfGroup.OwnerId;
                        group grpobj = new group();
                        grpobj.userId    = id1;
                        grpobj.groupType = 2;
                        grpobj.groupName = listOfGroup.groupName;
                        context_Var.groups.Add(grpobj);
                        context_Var.SaveChanges();

                        group_key grpkey = new group_key();
                        grpkey.groupNo  = grpobj.groupNo;
                        grpkey.groupKey = listOfGroup.groupKey;
                        grpkey.userId   = id1;
                        context_Var.group_key.Add(grpkey);
                        context_Var.SaveChanges();
                        res_Var = Request.CreateResponse <int>(System.Net.HttpStatusCode.Created, grpobj.groupNo);
                    }
                    scope.Complete();
                    return(res_Var);
                }
            }

            catch (Exception e)
            {
                res_Var = Request.CreateResponse <string>(System.Net.HttpStatusCode.BadRequest, "Error");
                return(res_Var);
            }
        }
Exemplo n.º 30
0
        protected void btnAddSubGroup_Click(object sender, EventArgs e)
        {
            if (lstGroup.SelectedIndex > -1)
            {
                string subGroupName = "Новая Подгруппа";
                var    db           = new ssmDataContext();
                int    parentId     = int.Parse(lstGroup.SelectedItem.Value);
                var    nGroup       = new group {
                    name = subGroupName, parent = parentId
                };
                db.groups.InsertOnSubmit(nGroup);
                db.SubmitChanges();
                lstGroupFill();

                txtGroupName.Text = lstGroup.SelectedItem.Text;
                LoadLstSubGroup();
                if (lstSubGroup.Items.FindByText(subGroupName) != null)
                {
                    lstSubGroup.SelectedIndex = lstSubGroup.Items.IndexOf(lstSubGroup.Items.FindByText(subGroupName));
                    lstSubGroup_SelectedIndexChanged(new object(), new EventArgs());
                }
            }
        }
Exemplo n.º 31
0
 protected override DHJassValue Run()
 {
     group g = new group();
     return new DHJassHandle(null, g.handle);
 }
        public static void UserMode()
        {
            // record start DateTime of execution
            string currentDateTime = DateTime.Now.ToUniversalTime().ToString();
            #region Setup Microsoft Graph Client for user

            //*********************************************************************
            // setup Microsoft Graph Client for user...
            //*********************************************************************
            try
            {
                client = AuthenticationHelper.GetActiveDirectoryClientAsUser();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Acquiring a token failed with the following error: {0}", ex.Message);
                if (ex.InnerException != null)
                {
                    //You should implement retry and back-off logic per the guidance given here:http://msdn.microsoft.com/en-us/library/dn168916.aspx
                    //InnerException Message will contain the HTTP error status codes mentioned in the link above
                    Console.WriteLine("Error detail: {0}", ex.InnerException.Message);
                }
                Console.ResetColor();
                Console.ReadKey();
                return;
            }

            #endregion

            Console.WriteLine("\nStarting user-mode requests...");
            Console.WriteLine("\n=============================\n\n");

            #region Get the signed in user's details, manager, reports and group memberships
            //// GET /me

            user user = new user();
            try
            {

                user = (user)client.me.ExecuteAsync().Result;
                Console.WriteLine();
                Console.WriteLine("GET /me");
                Console.WriteLine();
                Console.WriteLine("    Id: {0}  UPN: {1}", user.id, user.userPrincipalName);
            }
            catch (Exception e)
            {
                Console.WriteLine("\nError getting /me user {0} {1}",
                     e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }

            try
            {
                // get signed in user's picture.  
                // Drop to REST for this - Client Library doesn't support this yet :(
                string token = AuthenticationHelper.TokenForUser;
                string request = "me/Photo/$value";
                Stream photoStream = Helper.GetRestRequestStream(request, token).Result;
                Console.WriteLine("Got stream photo");
            }
            catch (Exception)
            {
                Console.WriteLine("Failed to get stream");
            }
             
            try
            {
                // GET /me/directReports
                List<IdirectoryObject> directs = client.me.directReports.ExecuteAsync().Result.CurrentPage.ToList();
                Console.WriteLine();
                Console.WriteLine("GET /me/directReports");
                Console.WriteLine();
                if (directs.Count == 0)
                {
                    Console.WriteLine("      no reports");
                }
                else
                {
                    foreach (IdirectoryObject _user in directs)
                    {
                        if (_user is Iuser)
                        {
                            Iuser __user = (Iuser)_user;
                            Console.WriteLine("      Id: {0}  UPN: {1}", __user.id, __user.userPrincipalName);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("\nError getting directReports {0} {1}",
                     e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }

            try
            {
                // GET /me/manager
                IdirectoryObject manager = client.me.manager.ExecuteAsync().Result;
                Console.WriteLine();
                Console.WriteLine("GET /me/manager");
                Console.WriteLine();
                if (manager == null)
                {
                    Console.WriteLine("      no manager");
                }
                else
                {
                    Iuser _user = client.users.GetById(manager.id).ExecuteAsync().Result;
                    Iuser __user = (Iuser)_user;
                    Console.WriteLine("\nManager      Id: {0}  UPN: {1}", __user.id, __user.userPrincipalName);
                    //    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("\nError getting directReports {0} {1}",
                     e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }

            // GET /me/memberOf
            try
            {
                IuserFetcher uFetcher = user;
                List<IdirectoryObject> _groups = uFetcher.memberOf.ExecuteAsync().Result.CurrentPage.ToList();
                // List<IdirectoryObject> _groups = client.me.memberOf.ExecuteAsync().Result.CurrentPage.ToList();
                Console.WriteLine();
                Console.WriteLine("GET /me/memberOf");
                Console.WriteLine();
                if (_groups.Count == 0)
                {
                    Console.WriteLine("    user is not a member of any groups");
                }
                foreach (IdirectoryObject _group in _groups)
                {
                    if (_group is group)
                    {
                        group __group = _group as group;
                        Console.WriteLine("    Id: {0}  UPN: {1}", __group.id, __group.displayName);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("\nError getting group memberships {0} {1}",
                     e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }

            #endregion

            #region Get the signed in user's files, who last modified them, messages and events, and personal contacts
            try
            {
                IList<IdriveItem> _items = client.me.drive.root.children.Take(5).ExecuteAsync().Result.CurrentPage.ToList();
                Console.WriteLine();
                Console.WriteLine("GET /me/files?$top=5");
                Console.WriteLine();
                foreach (IdriveItem _item in _items)
                {

                    if (_item.file != null)
                    {
                        Console.WriteLine("    This is a folder: File Id: {0}  WebUrl: {1}", _item.id, _item.webUrl);
                    }
                    else
                    {

                        Console.WriteLine("    File Id: {0}  WebUrl: {1}", _item.id, _item.webUrl);
                    }
                }
            }

            catch (Exception e)
            {
                Console.WriteLine("\nError getting files or content {0} {1}",
                     e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }

            try
            {

                // GET /me/Messages?$top=5
                List<Imessage> messages = client.me.messages.Take(5).ExecuteAsync().Result.CurrentPage.ToList();
                Console.WriteLine();
                Console.WriteLine("GET /me/messages?$top=5");
                Console.WriteLine();
                if (messages.Count == 0)
                {
                    Console.WriteLine("    no messages in mailbox");
                }
                foreach (Imessage message in messages)
                {
                    Console.WriteLine("    Message: {0} received {1} ", message.subject, message.receivedDateTime);
                }

                // GET /me/Events?$top=5
                List<IEvent> events = client.me.events.Take(5).ExecuteAsync().Result.CurrentPage.ToList();
                Console.WriteLine();
                Console.WriteLine("GET /me/events?$top=5");
                Console.WriteLine();
                if (events.Count == 0)
                {
                    Console.WriteLine("    no events scheduled");
                }
                foreach (IEvent _event in events)
                {
                    Console.WriteLine("    Event: {0} starts {1} ", _event.subject, _event.start);
                }

                // GET /me/contacts?$top=5
                List<Icontact> myContacts = client.me.contacts.Take(5).ExecuteAsync().Result.CurrentPage.ToList();
                Console.WriteLine();
                Console.WriteLine("GET /me/myContacts?$top=5");
                Console.WriteLine();
                if (myContacts.Count == 0)
                {
                    Console.WriteLine("    You don't have any contacts");
                }
                foreach (Icontact _contact in myContacts)
                {
                    Console.WriteLine("    Contact: {0} ", _contact.displayName);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("\nError getting messages, events and contacts {0} {1}",
                     e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }
            #endregion

            #region People picker example
            //*********************************************************************
            // People picker
            // Search for a user using text string "Sample" match against userPrincipalName, displayName, giveName, surname
            // Change searchString to suite your needs
            //*********************************************************************
            Console.WriteLine("\nSearch for user (enter search string):");
            String searchString = Console.ReadLine();

            List<Iuser> usersList = null;
            IPagedCollection<Iuser> searchResults = null;
            try
            {
                IuserCollection userCollection = client.users;
                searchResults = userCollection.Where(u =>
                    u.userPrincipalName.StartsWith(searchString) ||
                    u.displayName.StartsWith(searchString) ||
                    u.givenName.StartsWith(searchString) ||
                    u.surname.StartsWith(searchString)).Take(5).ExecuteAsync().Result;
                usersList = searchResults.CurrentPage.ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine("\nError getting User {0} {1}", e.Message,
                    e.InnerException != null ? e.InnerException.Message : "");
            }

            if (usersList != null && usersList.Count > 0)
            {
                do
                {
                    int j = 1;
                    usersList = searchResults.CurrentPage.ToList();
                    foreach (Iuser u in usersList)
                    {
                        Console.WriteLine("User {2} DisplayName: {0}  UPN: {1}",
                            u.displayName, u.userPrincipalName, j);
                        j++;
                    }
                    searchResults = searchResults.GetNextPageAsync().Result;
                } while (searchResults != null);
            }
            else
            {
                Console.WriteLine("User not found");
            }

            #endregion

            #region Create a unified group
            // POST /groups - create unified group 
            Console.WriteLine("\nDo you want to create a new unified group? Click y/n\n");
            ConsoleKeyInfo key = Console.ReadKey();
            group uGroup = null;
            if (key.KeyChar == 'y')
            {
                string suffix = Helper.GetRandomString(5);
                uGroup = new group
                {
                    groupTypes = new List<string> { "Unified" },
                    displayName = "Unified group " + suffix,
                    description = "Group " + suffix + " is the best ever",
                    mailNickname = "Group" + suffix,
                    mailEnabled = true,
                    securityEnabled = false
                };
                try
                {
                    client.groups.AddgroupAsync(uGroup).Wait();
                    Console.WriteLine("\nCreated unified group {0}", uGroup.displayName);
                }
                catch (Exception)
                {
                    Console.WriteLine("\nIssue creating the group {0}", uGroup.displayName);
                    uGroup = null;
                }
            }

            #endregion

            #region Add/remove group members
            // Currently busted through the client library.  Investigating...  Will re-add commented section once fixed.
            client.Context.SaveChanges();
            group retreivedGroup = new group();
            // get a set of users to add
            List<Iuser> members = client.users.Take(3).ExecuteAsync().Result.CurrentPage.ToList();

            // Either add to newly created group, OR add to an existing group
            if (uGroup != null)
            {
                retreivedGroup = (group)client.groups.GetById(uGroup.id).ExecuteAsync().Result;
            }
            else
            {
                List<Igroup> foundGroups = client.groups.Where(ug => ug.groupTypes.Any(gt => gt == "Unified")).Take(5).ExecuteAsync().Result.CurrentPage.ToList();
                if (foundGroups != null && foundGroups.Count > 0)
                {
                    retreivedGroup = foundGroups.First() as group;
                }
            }

            retreivedGroup.SaveChangesAsync().Wait();

            //if (retreivedGroup != null)
            //{
            //    // Add users
            //    foreach (Iuser _user in members)
            //    {
            //        try
            //        {
            //            directoryObject user1 = new user();
            //            user1.id = _user.id;
            //            retreivedGroup.members.Add(user1);
            //            retreivedGroup.UpdateAsync().Wait();
            //            Console.WriteLine("\nAdding {0} to group {1}", _user.userPrincipalName, uGroup.displayName);
            //        }
            //        catch (Exception e)
            //        {
            //            Console.WriteLine("\nError assigning member to group. {0} {1}",
            //                 e.Message, e.InnerException != null ? e.InnerException.Message : "");
            //        }
            //    }

            //    // now remove the added users
            //    foreach (user _user in members)
            //    {
            //        try
            //        {
            //            retreivedGroup.members.Remove(_user as directoryObject);
            //            retreivedGroup.UpdateAsync().Wait();
            //            Console.WriteLine("\nRemoved {0} from group {1}", _user.userPrincipalName, retreivedGroup.displayName);
            //        }
            //        catch (Exception e)
            //        {
            //            Console.WriteLine("\nError removing member from group. {0} {1}",
            //                 e.Message, e.InnerException != null ? e.InnerException.Message : "");
            //        }
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("\nCan't find any unified groups to add members to.\n");
            //}

            #endregion

            #region Get groups
            // GET /groups?$top=5
            List<Igroup> groups = client.groups.Take(5).ExecuteAsync().Result.CurrentPage.ToList();
            Console.WriteLine();
            Console.WriteLine("GET /groups?$top=5");
            Console.WriteLine();
            foreach (Igroup _group in groups)
            {
                Console.WriteLine("    Group Id: {0}  upn: {1}", _group.id, _group.displayName);
                foreach (string _type in _group.groupTypes)
                {
                    if (_type == "Unified")
                    {
                        Console.WriteLine(": This is a Unifed Group");
                    }
                }
            }
            #endregion

            #region Get the first 3 UNIFIED groups and view their associated content
            // GET /groups?$top=5&$filter=groupType eq 'Unified'
            // groups = client.me.memberOf.OfType<Igroup>().Where(ug => ug.groupTypes.Any(gt => gt == "Unified")).Take(3).ExecuteAsync().Result.CurrentPage.ToList();
            groups = client.groups.Where(ug => ug.groupTypes.Any(gt => gt == "Unified")).Take(3).ExecuteAsync().Result.CurrentPage.ToList();
            Console.WriteLine();
            Console.WriteLine("GET /groups?$top=5&$filter=groupType eq 'Unified'");
            Console.WriteLine();
            foreach (Igroup _group in groups)
            {
                Console.WriteLine("    Unified Group: {0}", _group.displayName);

                try
                {
                    // get group members
                    List<IdirectoryObject> unifiedGroupMembers = client.groups.GetById(_group.id).members.ExecuteAsync().Result.CurrentPage.ToList();
                    if (unifiedGroupMembers.Count == 0)
                    {
                        Console.WriteLine("      no members for group");
                    }
                    foreach (IdirectoryObject _member in unifiedGroupMembers)
                    {
                        if (_member is Iuser)
                        {
                            Iuser memberUser = (Iuser)_member;
                            Console.WriteLine("        User: {0} ", memberUser.displayName);
                        }
                    }

                    //get group files
                    try
                    {
                        IList<IdriveItem> unifiedGroupFiles = client.groups.GetById(_group.id).drive.root.children.Take(5).ExecuteAsync().Result.CurrentPage.ToList();
                        if (unifiedGroupFiles.Count == 0)
                        {
                            Console.WriteLine("      no files for group");
                        }
                        foreach (IdriveItem _file in unifiedGroupFiles)
                        {
                            Console.WriteLine("        file: {0} url: {1}", _file.name, _file.webUrl);
                        }
                    }
                    catch (Exception)
                    {
                        Console.Write("Unexpected exception when enumerating group files");
                    }

                    //get group conversations
                    try
                    {
                        List<Iconversation> unifiedGroupConversations = client.groups.GetById(_group.id).conversations.ExecuteAsync().Result.CurrentPage.ToList();
                        if (unifiedGroupConversations.Count == 0)
                        {
                            Console.WriteLine("      no conversations for group");
                        }
                        foreach (Iconversation _conversation in unifiedGroupConversations)
                        {
                            Console.WriteLine("        conversation topic: {0} ", _conversation.topic);
                        }
                    }
                    catch (Exception)
                    {
                        Console.Write("Unexpected exception when enumerating group conversations");
                    }

                    //get group events
                    try
                    {
                        List<IEvent> unifiedGroupEvents = client.groups.GetById(_group.id).events.ExecuteAsync().Result.CurrentPage.ToList();
                        if (unifiedGroupEvents.Count == 0)
                        {
                            Console.WriteLine("      no meeting events for group");
                        }
                        foreach (IEvent _event in unifiedGroupEvents)
                        {
                            Console.WriteLine("        meeting event subject: {0} ", _event.subject);
                        }
                    }
                    catch (Exception)
                    {
                        Console.Write("Unexpected exception when enumerating group events");
                    }
                }
                catch (Exception)
                {
                    Console.Write("Unexpected exception when enumerating group members and events");
                }
            }
            #endregion

            #region Get the top 10 users and create a recipient list (to be used later)
            IList<recipient> messageToList = new List<recipient>();

            // GET /users?$top=5
            List<Iuser> users = client.users.Take(10).ExecuteAsync().Result.CurrentPage.ToList();
            foreach (Iuser _user in users)
            {
                if (_user.assignedPlans.Count != 0)
                {
                    recipient messageTo = new recipient();
                    emailAddress emailAdress = new emailAddress();
                    emailAdress.address = _user.userPrincipalName;
                    emailAdress.name = _user.displayName;
                    messageTo.emailAddress = emailAdress;
                    messageToList.Add(messageTo);
                }
            }

            // also add current signed in user to the recipient list IF they have a license
            if (user.assignedPlans.Count != 0)
            {
                recipient messageTo = new recipient();
                emailAddress emailAdress = new emailAddress();
                emailAdress.address = user.userPrincipalName;
                emailAdress.name = user.displayName;
                messageTo.emailAddress = emailAdress;
                messageToList.Add(messageTo);
            }
            #endregion

            #region Send mail to signed in user and the recipient list
            // POST /me/SendMail

            Console.WriteLine();
            Console.WriteLine("POST /me/sendmail");
            Console.WriteLine();

            try
            {
                itemBody messageBody = new itemBody();
                messageBody.content = "<report pending>";
                messageBody.contentType = bodyType.text;

                message newMessage = new message();
                newMessage.subject = string.Format("\nCompleted test run from console app at {0}.", currentDateTime);
                newMessage.toRecipients = (IList<recipient>)messageToList;
                newMessage.body = (itemBody)messageBody;

                client.me.sendMailAsync(newMessage, true);

                Console.WriteLine("\nMail sent to {0}", user.displayName);
            }
            catch (Exception)
            {
                Console.WriteLine("\nUnexpected Error attempting to send an email");
                throw;
            }
            #endregion

            #region clean up (delete any created items)
            if (uGroup != null)
            {
                try
                {
                    uGroup.DeleteAsync().Wait();
                    Console.WriteLine("\nDeleted group {0}", uGroup.displayName);
                }
                catch (Exception e)
                {
                    Console.Write("Couldn't delete group.  Error detail: {0}", e.InnerException.Message);
                }
            }
            #endregion

        }
        /// <summary>
        /// Get the parent groups associated with the given group.
        /// </summary>
        /// <param name="childGroup">Group to get the parent groups for.</param>
        /// <param name="isRoot">True if the given child group shouldn't be included in the returned value.</param>
        /// <returns>Enumerable </returns>
        private static IEnumerable<group> GetParentGroups( group childGroup, bool isRoot )
        {
            IEnumerable<group> parentGroups = new[] { childGroup };

            if (childGroup.parent_id != null)
            {
                if (isRoot)
                {
                    parentGroups = GetParentGroups(childGroup.group2, false);
                }
                else
                {
                    parentGroups = GetParentGroups(childGroup.group2, false).Concat<group>(parentGroups);
                }
            }

            return parentGroups;
        }
Exemplo n.º 34
0
        public static String Group(group group)
        {
            try
            {
                String groupCSV = group.sourcedid[0].id + ",";
                if (group.description != null)
                {
                    groupCSV += group.description.@short;
                    groupCSV += "," + group.description.@long + ",";
                }
                else
                    groupCSV += " , ,";
                if (group.grouptype != null && group.grouptype[0] != null)
                {
                    if (group.grouptype[0].typevalue != null && group.grouptype[0].typevalue[0] != null)
                        groupCSV += group.grouptype[0].typevalue[0].Value + ",";
                    else
                        groupCSV += " ,";
                }
                else
                    groupCSV += " ,";
                if (group.timeframe != null)
                {
                    if (group.timeframe.begin != null)
                        groupCSV += group.timeframe.begin.Value + ",";
                    else
                        groupCSV += " ,";
                    if (group.timeframe.end != null)
                        groupCSV += group.timeframe.end.Value + ",";
                    else
                        groupCSV += " ,";
                }
                else
                    groupCSV += " , ,";
                if (group.extension != null)
                {
                    if (group.extension.coursecode != null)
                        groupCSV += group.extension.coursecode + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.csncode != null)
                        groupCSV += group.extension.csncode + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.governedby != null)
                        groupCSV += group.extension.governedby + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.groupusage != null)
                        groupCSV += group.extension.groupusage + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.hours != null)
                        groupCSV += group.extension.hours + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.languagecode != null)
                        groupCSV += group.extension.languagecode + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.locality != null)
                        groupCSV += group.extension.locality + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.municipalitycode != null)
                        groupCSV += group.extension.municipalitycode + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.municipalityname != null)
                        groupCSV += group.extension.municipalityname + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.pcode != null)
                        groupCSV += group.extension.pcode + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.period != null)
                        groupCSV += group.extension.period + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.phone != null)
                        groupCSV += group.extension.phone + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.point != null)
                        groupCSV += group.extension.point + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.schooltype != null)
                        groupCSV += group.extension.schooltype + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.schoolyear != null)
                        groupCSV += group.extension.schoolyear + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.street != null)
                        groupCSV += group.extension.street + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.subjectcode != null)
                        groupCSV += group.extension.subjectcode + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.timestamp != null)
                        groupCSV += group.extension.timestamp + ",";
                    else
                        groupCSV += " ,";
                    if (group.extension.web != null)
                        groupCSV += group.extension.web + ",";
                    else
                        groupCSV += " ,";
                }

                return groupCSV + "\r\n";
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 35
0
 internal Group DeserialiseGroup(group grp, int id)
 {
     if (grp == null)
         return null;
     var ret = new Group
     {
         Id = (byte)id,
         Name = grp.name,
         Background = grp.background == null ? null : Path.Combine(directory, grp.background),
         BackgroundStyle = grp.backgroundStyle.ToString(),
         Collapsed = bool.Parse(grp.collapsed.ToString()),
         Height = Int32.Parse(grp.height),
         Width = Int32.Parse(grp.width),
         Icon = grp.icon == null ? null : Path.Combine(directory, grp.icon),
         Ordered = bool.Parse(grp.ordered.ToString()),
         Shortcut = grp.shortcut,
         MoveTo = bool.Parse(grp.moveto.ToString()),
         CardActions = new List<IGroupAction>(),
         GroupActions = new List<IGroupAction>()
     };
     if (ret.Width == 0)
     {
         ret.Width = 1;
     }
     if (ret.Height == 0)
     {
         ret.Height = 1;
     }
     if (grp.Items != null)
     {
         foreach (var item in grp.Items)
         {
             if (item is action)
             {
                 var i = item as action;
                 var to = new GroupAction
                              {
                                  Name = i.menu,
                                  Shortcut = i.shortcut,
                                  ShowIf = i.showIf,
                                  BatchExecute = i.batchExecute,
                                  Execute = i.execute,
                                  DefaultAction = bool.Parse([email protected]())
                              };
                 if (item is cardAction)
                 {
                     to.IsGroup = false;
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupAction)
                 {
                     to.IsGroup = true;
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
             else if (item is actionSubmenu)
             {
                 var i = item as actionSubmenu;
                 var to = new GroupActionGroup
                 {
                     Children = new List<IGroupAction>(),
                     Name = i.menu,
                     ShowIf = i.showIf,
                 };
                 if (item is cardActionSubmenu)
                 {
                     to.IsGroup = false;
                     to.Children = this.DeserializeGroupActionGroup(i, false);
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupActionSubmenu)
                 {
                     to.IsGroup = true;
                     to.Children = this.DeserializeGroupActionGroup(i, true);
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
             else if (item is actionSeparator)
             {
                 var separator = new GroupActionSeparator {
                     ShowIf = item.showIf,
                 };
                 if (item is groupActionSeparator)
                 {
                     separator.IsGroup = true;
                     (ret.GroupActions as List<IGroupAction>).Add(separator);
                 }
                 else if (item is cardActionSeparator)
                 {
                     separator.IsGroup = false;
                     (ret.CardActions as List<IGroupAction>).Add(separator);
                 }
             }
         }
     }
     switch (grp.visibility)
     {
         case groupVisibility.none:
             ret.Visibility = GroupVisibility.Nobody;
             break;
         case groupVisibility.me:
             ret.Visibility = GroupVisibility.Owner;
             break;
         case groupVisibility.all:
             ret.Visibility = GroupVisibility.Everybody;
             break;
         case groupVisibility.undefined:
             ret.Visibility = GroupVisibility.Undefined;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return ret;
 }
Exemplo n.º 36
0
 internal Group DeserialiseGroup(group grp, int id)
 {
     var ret = new Group
     {
         Id = (byte)id,
         Name = grp.name,
         Background = grp.background == null ? null : Path.Combine(directory, grp.background),
         BackgroundStyle = grp.backgroundStyle.ToString(),
         Board = grp.board == null ? null : Path.Combine(directory, grp.board),
         BoardPosition = grp.boardPosition == null ? new DataRectangle { X = 0, Y = 0, Height = 0, Width = 0 } :
             new DataRectangle
             {
                 X = double.Parse(grp.boardPosition.Split(',')[0]),
                 Y = double.Parse(grp.boardPosition.Split(',')[1]),
                 Width = double.Parse(grp.boardPosition.Split(',')[2]),
                 Height = double.Parse(grp.boardPosition.Split(',')[3])
             },
         Collapsed = bool.Parse(grp.collapsed.ToString()),
         Height = Int32.Parse(grp.height),
         Width = Int32.Parse(grp.width),
         Icon = grp.icon == null ? null : Path.Combine(directory, grp.icon),
         Ordered = bool.Parse(grp.ordered.ToString()),
         Shortcut = grp.shortcut,
         CardActions = new List<IGroupAction>(),
         GroupActions = new List<IGroupAction>()
     };
     if (grp.Items != null)
     {
         foreach (var item in grp.Items)
         {
             if (item is action)
             {
                 var i = item as action;
                 var to = new GroupAction
                              {
                                  Name = i.menu,
                                  Shortcut = i.shortcut,
                                  BatchExecute = i.batchExecute,
                                  Execute = i.execute,
                                  DefaultAction = bool.Parse([email protected]())
                              };
                 if (item is cardAction)
                 {
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupAction)
                 {
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
             else if (item is actionSubmenu)
             {
                 var i = item as actionSubmenu;
                 var to = new GroupActionGroup { Children = new List<IGroupAction>(), Name = i.menu };
                 to.Children = this.DeserializeGroupActionGroup(i);
                 if (item is cardActionSubmenu)
                 {
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupActionSubmenu)
                 {
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
         }
     }
     switch (grp.visibility)
     {
         case groupVisibility.none:
             ret.Visibility = GroupVisibility.Nobody;
             break;
         case groupVisibility.me:
             ret.Visibility = GroupVisibility.Owner;
             break;
         case groupVisibility.all:
             ret.Visibility = GroupVisibility.Everybody;
             break;
         case groupVisibility.undefined:
             ret.Visibility = GroupVisibility.Undefined;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return ret;
 }
Exemplo n.º 37
0
 internal group SerializeGroup(Group grp, string rootPath)
 {
     if (grp == null)
         return null;
     var ret = new group();
     ret.name = grp.Name;
     ret.background = (grp.Background ?? "").Replace(rootPath, "");
     ret.backgroundStyle = (groupBackgroundStyle)Enum.Parse(typeof(groupBackgroundStyle), grp.BackgroundStyle);
     ret.collapsed = grp.Collapsed ? boolean.True : boolean.False;
     ret.height = grp.Height.ToString();
     ret.width = grp.Width.ToString();
     ret.icon = (grp.Icon ?? "").Replace(rootPath, "");
     ret.ordered = grp.Ordered ? boolean.True : boolean.False;
     ret.shortcut = grp.Shortcut;
     ret.moveto = grp.MoveTo ? boolean.True : boolean.False;
     var itemList = SerializeActions(grp.CardActions).ToList();
     itemList.AddRange(SerializeActions(grp.GroupActions).ToArray());
     ret.Items = itemList.ToArray();
     switch (grp.Visibility)
     {
         case GroupVisibility.Undefined:
             ret.visibility = groupVisibility.undefined;
             break;
         case GroupVisibility.Nobody:
             ret.visibility = groupVisibility.none;
             break;
         case GroupVisibility.Owner:
             ret.visibility = groupVisibility.me;
             break;
         case GroupVisibility.Everybody:
             ret.visibility = groupVisibility.all;
             break;
     }
     return ret;
 }
Exemplo n.º 38
0
        private void addGroupNode(member member, group group, int index, TreeNode subNode = null) // add a tree node which is of the type group
        {
            TreeNode node = new TreeNode(); // create the new node
            node.Name = group.grouptype[0].typevalue[0].Value;// set the nam to the grouptype
            if ([email protected]())
                node.Text = group.description.@short; //the text should be the description
            else
            {
                node.Text = "No desc: " + group.sourcedid[0].id;
                addProblem(new Error(index, "The groups short description is empty!", "Group", ErrorType.Warning, group.sourcedid[0].id));
            }
            if (group.sourcedid[0].id.IsEmpty())
                addProblem(new Error(index, "The group did not have a sourcedID", "Group", ErrorType.Error, "No ID"));

            node.Nodes.Add(""); // add a subnode so user can check for subnodes
            node.Tag = index; // the tag will be the index of this groups index in ep.group

            if (member.role != null)
            {
                string tips = member.role[0].roletype.ToString();

                if (member.role[0].timeframe != null)
                    tips += " from " + member.role[0].timeframe.begin.Value + " to " + member.role[0].timeframe.end.Value;
/*
                if (member.role[0].extension != null)
                {
                    var result = member.role[0].extension;
                    foreach (XmlNode ext in result[0].ChildNodes)
                    {
                        if ((ext.Name == "course_code" || ext.Name == "subject_code") && ext.InnerText != string.Empty)
                            tips += " " + ext.InnerText;
                    }
                }
*/
                node.ToolTipText = tips;
            }


            if (subNode != null)
                subNode.Nodes.Add(node); // add the new node to the current nodes subnodes
            else
                enterpriseList.Nodes.Add(node);
        }