コード例 #1
0
        public static void RemoveGroupFromEveryProject(string groupname)
        {
            string            confGrp = "[G] " + groupname;
            ProjectCollection projCol = ProjectBrowserStore.GetListProject();

            if (projCol.Count == 0)
            {
                return;
            }

            foreach (Project proj in projCol)
            {
                try
                {
                    ProjectBrowserStore.RemoveMemberFromProject(confGrp, proj);
                    MySQLAccountParsing.RemoveMemberFromProject(confGrp, proj);
                }
                catch (Exception ex)
                {
                    if (!(ex is MissingMemberException))
                    {
                        throw;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
コード例 #2
0
        public static void DeactivateProject(Packet packet)
        {
            Packet sendPacket;

            try
            {
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Deactivating project in the server [{1}]", packet.ClientIP, packet.Username));
                Project           project = null;
                ProjectCollection projCol = ProjectBrowserStore.GetListProject();
                foreach (Project proj in projCol)
                {
                    if (proj.ProjectName == packet.Argument)
                    {
                        project = proj;
                        break;
                    }
                }

                ProjectBrowserStore.DeactivateProject(project);

                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Success, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Deactivating project success: {1} [{2}]", packet.ClientIP, project.ProjectName, packet.Username));
            }
            catch (Exception e)
            {
                ConsoleUtils.Print(string.Format("Deactivate Project Error: [{0}] {1}", e.GetType().ToString(), e.Message));
                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Failure, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                return;
            }
        }
コード例 #3
0
        public static void DeleteProject(Packet packet)
        {
            Packet sendPacket;

            try
            {
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Delete project to the server [{1}]", packet.ClientIP, packet.Username));
                Project           project = null;
                ProjectCollection projCol = ProjectBrowserStore.GetListProject();
                foreach (Project proj in projCol)
                {
                    if (proj.ProjectName == packet.Argument)
                    {
                        project = proj;
                        break;
                    }
                }

                ProjectBrowserStore.DeactivateProject(project);
                ProjectBrowserStore.DeleteProject(project);

                using (var dbCon = new MySQLDatabaseConnection(System.Net.IPAddress.Parse("127.0.0.1"), "exceeddb"))
                {
                    dbCon.Username = "******";
                    dbCon.Password = "******";
                    dbCon.Connect();

                    string command = string.Format("DELETE FROM `projectDB` WHERE (`projectname`= '{0}')", project.ProjectName);
                    dbCon.ExecuteCommand(command);
                    command = string.Empty;
                    dbCon.Close();
                }

                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Success, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Successfully deleting project: {1} [{2}]", packet.ClientIP, project.ProjectName, packet.Username));
            }
            catch (Exception e)
            {
                ConsoleUtils.Print(string.Format("Delete Project Error: [{0}] {1}", e.GetType().ToString(), e.Message));
                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Failure, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                return;
            }
        }
コード例 #4
0
        public static void MemberFromProject(Packet packet)
        {
            Packet sendPacket;

            try
            {
                string[] combine     = packet.Argument.Split(char.Parse("|"));
                string   member      = combine[0];
                string   projectname = combine[1];
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Remove member from project {1} [{2}]",
                                                 packet.ClientIP, projectname, packet.Username));

                Project           project = null;
                ProjectCollection projCol = ProjectBrowserStore.GetListProject();
                foreach (Project proj in projCol)
                {
                    if (proj.ProjectName == projectname)
                    {
                        project = proj;
                        break;
                    }
                }

                ProjectBrowserStore.RemoveMemberFromProject(member, project);
                MySQLAccountParsing.RemoveMemberFromProject(member, project);

                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Success, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Removing member from project success: {1} [{2}]", packet.ClientIP, member, packet.Username));
            }
            catch (Exception e)
            {
                ConsoleUtils.Print(string.Format("Member From Project Error: [{0}] {1}", e.GetType().ToString(), e.Message));
                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Failure, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                return;
            }
        }
コード例 #5
0
        public static void CreateProject(Packet packet)
        {
            Packet sendPacket;

            try
            {
                string[] split       = packet.Argument.Split(char.Parse("|"));
                string   projectName = split[0];
                string   activate    = split[1];
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Create new project to the server [{1}]", packet.ClientIP, packet.Username));
                Project newProj = ProjectBrowserStore.CreateProject(projectName);
                ProjectBrowserStore.ActivateProject(newProj);

                using (var dbCon = new MySQLDatabaseConnection(System.Net.IPAddress.Parse("127.0.0.1"), "exceeddb"))
                {
                    dbCon.Username = "******";
                    dbCon.Password = "******";
                    dbCon.Connect();

                    string command = string.Format("INSERT INTO `exceeddb`.`projectDB` (`projectname`, `group`, `user`)" +
                                                   " VALUES ('{0}', '', '')", newProj.ProjectName);
                    dbCon.ExecuteCommand(command);
                    command = string.Empty;
                    dbCon.Close();
                }

                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Success, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
            }
            catch (Exception e)
            {
                ConsoleUtils.Print(string.Format("Create Project Error: [{0}] {1}", e.GetType().ToString(), e.Message));
                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Failure, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                return;
            }
        }