Пример #1
0
        public bool RoundDatesEquals(groups rhs)
        {
            bool result = true;

            List <KeyValuePair <string, string> > roundDates = RoundDates; // Чтобы свойство вычислялось только 1 раз

            if (roundDates == null || roundDates.Count == 0)
            {
                result = rhs.round_dates == null || rhs.round_dates.Count == 0;
            }
            else
            {
                foreach (KeyValuePair <string, string> RoundDate in roundDates)
                {
                    round_dates DateInDB = rhs.round_dates.FirstOrDefault(arg => arg.round == GlobalDefines.ROUND_IDS[RoundDate.Key]);
                    if (RoundDate.Value == null)
                    {
                        result = DateInDB == null;
                    }
                    else
                    {
                        result = RoundDate.Value == DateInDB.date;
                    }

                    if (!result)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Пример #2
0
        public void CacheGroups()
        {
            Groups = new Dictionary <int, groups>();
            DateTime Start = DateTime.Now;

            DataTable Data    = Engine.dbManager.ReadTable("SELECT * FROM groups");
            var       RowEnum = Data.Rows.GetEnumerator();

            while (RowEnum.MoveNext())
            {
                DataRow Row = (DataRow)RowEnum.Current;

                groups group = new groups()
                {
                    ID          = (int)Row["id"],
                    Admins      = Row["admins"].ToString().Split(';'),
                    Badges      = Row["badge"].ToString(),
                    Created     = Row["created"].ToString(),
                    Description = Row["description"].ToString(),
                    Members     = Row["members"].ToString().Split(';'),
                    Name        = Row["name"].ToString(),
                    Owner       = Row["owner"].ToString()
                };

                Groups.Add(group.ID, group);
            }

            DateTime End     = DateTime.Now;
            TimeSpan Expired = (End - Start);

            Engine.Logging.WriteTagLine("Cache", "Loaded {0} Groups in {1} s and {2} ms", Groups.Count, Expired.Seconds, Expired.Milliseconds);
        }
        public IHttpActionResult Putgroups(int id, groups groups)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != groups.id)
            {
                return(BadRequest());
            }

            db.Entry(groups).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!groupsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #4
0
        public string Delete(int id)
        {
            groups g = Read(id);

            db1.groups.Remove(g);
            db1.SaveChanges();
            return("حذف اطلاعات با موفقیت انجام شد");
        }
Пример #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            groups groups = db.groups.Find(id);

            db.groups.Remove(groups);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #6
0
        public string Update(int id, person p)
        {
            groups g1 = new groups();

            g1           = Read(id);
            g1.groupName = p.fullName;
            db1.SaveChanges();
            return("ویرایش اطلاعات با موفقیت انجام شد");
        }
Пример #7
0
 public ActionResult Edit(groups group)
 {
     if (ModelState.IsValid)
     {
         _groups.UpdateGroup(group);
         return(RedirectToAction("Index"));
     }
     return(View(group));
 }
Пример #8
0
 public ActionResult Create(groups group)
 {
     if (ModelState.IsValid)
     {
         _groups.AddGroup(group);
         _groups.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(group));
 }
Пример #9
0
 public ActionResult Edit(groups groups)
 {
     if (ModelState.IsValid)
     {
         db.Entry(groups).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(groups));
 }
Пример #10
0
        //
        // GET: /Groups/Edit/5

        public ActionResult Edit(int id = 0)
        {
            groups groups = db.groups.Find(id);

            if (groups == null)
            {
                return(HttpNotFound());
            }
            return(View(groups));
        }
Пример #11
0
        public ActionResult Edit(string id)
        {
            groups group = _groups.GetGroupbyId(id);

            if (group == null)
            {
                return(HttpNotFound());
            }
            return(View(group));
        }
Пример #12
0
        public JsonResult addyhz(string name)
        {
            groups g = new groups();

            g.GroupName = name;
            g.Privilege = context.privilege.FirstOrDefault(a => a.ID > 0).ID;
            context.groups.Add(g);
            context.SaveChanges();
            return(Json(new { success = true }));
        }
Пример #13
0
 public ActionResult Edit([Bind(Include = "ID,title")] groups group)
 {
     //TODO: This action need to be deeply reviewed
     if (ModelState.IsValid)
     {
         db.Entry(group).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(group));
 }
        public IHttpActionResult Getgroups(int id)
        {
            groups groups = db.groups.Find(id);

            if (groups == null)
            {
                return(NotFound());
            }

            return(Ok(groups));
        }
Пример #15
0
        public ActionResult Create(groups groups)
        {
            if (ModelState.IsValid)
            {
                db.groups.Add(groups);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(groups));
        }
        public IHttpActionResult Postgroups(groups groups)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.groups.Add(groups);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = groups.id }, groups));
        }
Пример #17
0
        public bool GroupPropsEquals(groups rhs, string FullFilePath)
        {
            bool result = SecondColName == rhs.second_col_name &&
                          MainJudge == rhs.main_judge &&
                          MainSecretary == rhs.main_secretary &&
                          Row6 == rhs.row6 &&
                          rhs.xml_file_name == FullFilePath &&
                          (MembersFrom1stQualif == rhs.from_1_qualif ||
                           (MembersFrom1stQualif == GlobalDefines.DEFAULT_XML_BYTE_VAL && rhs.from_1_qualif == null)) &&
                          (MembersFrom2ndQualif == rhs.from_2_qualif ||
                           (MembersFrom2ndQualif == GlobalDefines.DEFAULT_XML_BYTE_VAL && rhs.from_2_qualif == null));

            if (result)
            {
                if (AgeGroup == null)
                {   // В текущих нстройках группы нет
                    result = string.IsNullOrWhiteSpace(rhs.name) &&
                             (rhs.start_year == null || rhs.start_year <GlobalDefines.MIN_GROUP_YEAR || rhs.start_year> GlobalDefines.MAX_GROUP_YEAR) &&
                             (rhs.end_year == null || rhs.end_year <GlobalDefines.MIN_GROUP_YEAR || rhs.end_year> GlobalDefines.MAX_GROUP_YEAR);
                }
                else
                {
                    result = rhs == AgeGroup;
                }
            }

            if (result)
            {
                if (StartDate == null)
                {   // Начальной даты нет
                    result = rhs.comp_start_date == null;
                }
                else
                {
                    result = StartDate.Date == rhs.comp_start_date;
                }
            }

            if (result)
            {
                if (EndDate == null)
                {   // Начальной даты нет
                    result = rhs.comp_end_date == null;
                }
                else
                {
                    result = EndDate.Date == rhs.comp_end_date;
                }
            }

            return(result && RoundDatesEquals(rhs));
        }
Пример #18
0
        public ActionResult Create([Bind(Include = "ID,title")] groups group)
        {
            //1. Convert the entry to Db Model
            if (ModelState.IsValid == true)
            {
                //TODO: This action need to be deeply reviewed
                db.groups.Add(group);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(group));
        }
        public IHttpActionResult Deletegroups(int id)
        {
            groups groups = db.groups.Find(id);

            if (groups == null)
            {
                return(NotFound());
            }

            db.groups.Remove(groups);
            db.SaveChanges();

            return(Ok(groups));
        }
Пример #20
0
        //Populate GroupList from groups file
        public void PopulateGroups()
        {
            GroupList.RemoveRange(0, GroupList.Count);
            string line;
            //string p = System.AppDomain.CurrentDomain.BaseDirectory;
            StreamReader file = new System.IO.StreamReader(grpPath);

            while ((line = file.ReadLine()) != null)
            {
                groups newgroup = ParseGroupString(line);
                // add each group to list
                GroupList.Add(newgroup);
            }
        }
Пример #21
0
        // GET: templates/Delete/5
        public ActionResult Delete(int?id)
        {
            //TODO: This action need to be deeply reviewed
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            groups group = db.groups.Find(id);

            if (group == null)
            {
                return(HttpNotFound());
            }
            return(View(group));
        }
        public EditGroupsDataPage(DispatcherWindow window, groups CurrentGroup)
        {
            InitializeComponent();

            this.dispatcherWindow = window;

            this.CurrentGroup       = (groups)CurrentGroup.Clone();
            this.EditGroupReference = CurrentGroup;

            Faculties   = Connection.Database.faculties.ToList();
            Specialties = Connection.Database.specialties.ToList();
            Train_types = Connection.Database.train_types.ToList();

            IsNotChangeMode = false;

            DataContext = this;
        }
Пример #23
0
        /// <summary>
        /// Helper method for getting report data
        /// </summary>
        /// <returns></returns>
        private string GetReportDataText()
        {
            Inheritance inh = new Inheritance();
            string      authenticatedUserMail = Session["AuthenticatedUserMail"] as string;
            student     stud      = inh.db.student.Where <student>(item => item.studentEmail == authenticatedUserMail).First <student>();
            int         studentId = stud.studentID;
            groups      group     = inh.db.groups.Where <groups>(item => item.student1.studentID == studentId ||
                                                                 item.student2.studentID == studentId ||
                                                                 item.student3.studentID == studentId ||
                                                                 item.student4.studentID == studentId).First <groups>();
            projects project       = inh.db.projects.Where <projects>(item => item.groupID == group.groupID).First <projects>();
            int      projectID     = project.projectID;
            report   currentReport = inh.db.report.Where <report>(item => item.projectID == project.projectID).First <report>();

            Session["CurrentReportID"]            = currentReport.reportID;
            Session["CurrentReportGetLatestDate"] = currentReport.date;
            return(currentReport.text);
        }
Пример #24
0
        internal static void Serialize(ServerMessage Msg, rooms Room)
        {
            Msg.Append <uint>(Room.ID);
            Msg.Append <bool>(false);
            Msg.Append <string>(Room.Caption);
            Msg.Append <bool>(true);
            Msg.Append <int>(Engine.dbManager.ReadInt("SELECT id FROM members WHERE username = '******'"));
            Msg.Append <string>(Room.Owner);
            Msg.Append <int>(Room.State);
            Msg.Append <int>(Room.Users_Now);
            Msg.Append <int>(Room.Users_Max);
            Msg.Append <string>(Room.Description);
            Msg.Append <int>(0);
            Msg.Append <int>(0);
            Msg.Append <int>(Room.Score);
            Msg.Append <int>(Room.Category);
            Msg.Append <int>(Room.GroupID);

            if (Room.GroupID > 0)
            {
                groups group = Engine.GetHabboHotel.getGroups.Groups[Room.GroupID];
                Msg.Append <string>(group.Name);
                Msg.Append <string>(group.Badges);
                Msg.Append <string>("");
            }
            else
            {
                Msg.Append <string>("");
                Msg.Append <string>("");
                Msg.Append <string>("");
            }


            Msg.Append <int>(Room.Tags.Length);
            Msg.Append <string[]>(Room.Tags);
            Msg.Append <int>(0);
            Msg.Append <int>(0);
            Msg.Append <int>(0);
            Msg.Append <bool>(true);
            Msg.Append <bool>(true);
        }
        private CGroupItem AddNewGroup(CCompItem Comp, long GroupId)
        {
            CGroupItem result = new CGroupItem(GroupId)
            {
                FileName = GroupId.ToString() + GlobalDefines.PUBLISHING_LOG_FILE_EXTENSION
            };
            groups gr = DBManagerApp.m_Entities.groups.FirstOrDefault(arg => arg.id_group == GroupId);

            if (gr == null)
            {
                return(null);
            }
            else
            {
                CCompSettings Group = new CCompSettings(gr);
                result.GroupName = Group.AgeGroup.FullGroupName;
            }
            Comp.Groups.Add(result);

            return(result);
        }
        public groups GetSpecificGroup()
        {
            string fullstr = this.Url.Request.RequestUri.OriginalString;
            string tempuid;
            int    id;
            int    idpos = fullstr.LastIndexOf('/');

            tempuid = fullstr.Substring(idpos + 1);
            Int32.TryParse(tempuid, out id);
            groups reqGrp = Userrepo.GetSingleGroupById(id);

            if (reqGrp != null)
            {
                return(reqGrp);
            }
            else
            {
                //throw 404 exception if gid not found
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
Пример #27
0
 public ActionResult ResetDatabase()
 {
     if (ModelState.IsValid)
     {
         try
         {
             bool             justSentMessage;
             List <caretaker> caretakers = new List <caretaker>();
             caretakers = operations.GetAllCaretakers();
             if (caretakers.Count == 0)
             {
                 justSentMessage = false;
                 return(RedirectToAction("ResetDatabase", "Admin", new { justSentMessage = justSentMessage }));
             }
             else
             {
                 operations.ResetChildGroupRelation();
                 operations.ResetChildren();
                 operations.ResetCaretakers();
                 operations.ResetEmployeGroups();
                 groups lowestGroup = operations.GetLowestGroup();
                 operations.DeleteFromGroups(lowestGroup.birth_year);
                 groups highestGroup = operations.GetHighestGroup();
                 int    newGroupYear = highestGroup.birth_year + 1;
                 operations.AddNewGroups(newGroupYear);
                 operations.UpdateEmployeGroup(highestGroup.group_id);
                 justSentMessage = true;
                 return(RedirectToAction("ResetDatabase", "Admin", new { justSentMessage = justSentMessage }));
             }
         }
         catch (Exception)
         {
             string message = "Det går inte att återställa databasen, vänligen försök igen.";
             return(RedirectToAction("Error", "Home", new { message = message }));
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
Пример #28
0
        //
        // GET: /Permissions/Create

        public ActionResult Save(int id = 0)
        {
            groups group = db.groups.Find(id);
            Dictionary <string, string[]> list_roles = new Dictionary <string, string[]>();

            PermissionModel permission_m = new PermissionModel()
            {
                group_name = group.name, group_id = group.id
            };

            permission_m.list_module_m = new List <ModuleModel>();

            foreach (var module in db.modules.Where(w => w.enabled == 1))
            {
                var permision_exists = db.permissions.Where(w => w.group_id == id)
                                       .Where(w => w.module == module.slug)
                                       .SingleOrDefault();

                switch (module.slug)
                {
                case "comisiones":
                    list_roles.Add(module.slug, new string[] { "create", "update", "delete", "extra" });
                    break;

                default:
                    list_roles[module.slug] = new string[] { "create", "update", "delete" };
                    break;
                }
                //Response.Write(permision_exists);
                permission_m.list_module_m.Add(new ModuleModel {
                    id_module = module.id, slug = module.slug, name = module.name, check = (permision_exists == null ? false : true), roles = permision_exists != null && permision_exists.roles != null ? JsonConvert.DeserializeObject <string[]>(permision_exists.roles) : new string[] { }
                });
            }

            ViewBag.Roles = list_roles;
            return(View(permission_m));
        }
Пример #29
0
        // Parse each line recieved when populating groups and return a group data structure
        public groups ParseGroupString(string line)
        {
            string[] attr   = line.Split(':');
            groups   newgrp = new groups();

            if (attr.Length != 4)
            {
                throw new HttpException("Malformed groups file");
            }
            newgrp.name = attr[0];
            newgrp.gid  = Convert.ToInt32(attr[2]);
            if (attr.Length > 3)
            {
                string[] usrnams = attr[3].Split(',');
                foreach (string u in usrnams)
                {
                    if (u != "")
                    {
                        newgrp.members.Add(u);
                    }
                }
            }
            return(newgrp);
        }
Пример #30
0
        public CCompSettings(groups GroupInDB)
        {
            CompName = GroupInDB.descriptions.name;

            AgeGroup = new CAgeGroup()
            {
                Name      = GroupInDB.name,
                StartYear = GroupInDB.start_year.HasValue ? GroupInDB.start_year.Value : GlobalDefines.DEFAULT_XML_INT_VAL,
                Sex       = GroupInDB.sex
            };

            StartDate = new Scanning.XMLDataClasses.CCompDate()
            {
                Day   = GroupInDB.comp_start_date.Day,
                Month = GroupInDB.comp_start_date.Month - 1,
                Year  = GroupInDB.comp_start_date.Year
            };

            SecondColName = GroupInDB.second_col_name;

            MainJudge     = GroupInDB.main_judge;
            MainSecretary = GroupInDB.main_secretary;
            Row6          = GroupInDB.row6;

            if (GroupInDB.from_1_qualif.HasValue)
            {
                MembersFrom1stQualif = GroupInDB.from_1_qualif.Value;
            }

            if (GroupInDB.from_2_qualif.HasValue)
            {
                MembersFrom2ndQualif = GroupInDB.from_2_qualif.Value;
            }

            if (GroupInDB.end_year.HasValue)
            {
                switch (GroupInDB.end_year)
                {
                case (int)CAgeGroup.enEndYearSpecVals.AndElder:
                    AgeGroup.EndYear = Properties.Resources.resAndElder;
                    break;

                case (int)CAgeGroup.enEndYearSpecVals.AndYounger:
                    AgeGroup.EndYear = Properties.Resources.resAndYounger;
                    break;

                default:
                    AgeGroup.EndYear = GroupInDB.end_year.Value.ToString();
                    break;
                }
            }

            if (GroupInDB.comp_end_date.HasValue)
            {
                EndDate = new Scanning.XMLDataClasses.CCompDate()
                {
                    Day   = GroupInDB.comp_end_date.Value.Day,
                    Month = GroupInDB.comp_end_date.Value.Month - 1,
                    Year  = GroupInDB.comp_end_date.Value.Year
                };

                foreach (round_dates RoundDate in GroupInDB.round_dates)
                {
                    switch ((enRounds)RoundDate.round)
                    {
                    case enRounds.Qualif:
                        QualifDate = RoundDate.date;
                        break;

                    case enRounds.OneEighthFinal:
                        OneEighthFinalDate = RoundDate.date;
                        break;

                    case enRounds.QuaterFinal:
                        QuaterFinalDate = RoundDate.date;
                        break;

                    case enRounds.SemiFinal:
                        SemiFinalDate = RoundDate.date;
                        break;

                    case enRounds.Final:
                        FinalDate = RoundDate.date;
                        break;
                    }
                }
            }
        }