Exemplo n.º 1
0
        private async void GetAssignmentsForCourseAsync(int courseId, string authToken)
        {
            var   task = AsyncServiceClient.GetAssignmentsForCourse(courseId, authToken);
            await task;
            var   assignments = task.Result;

            Assignments.Clear();
            foreach (var assignment in assignments)
            {
                Assignments.Add(assignment);
            }

            IsLoading = false;
        }
Exemplo n.º 2
0
 //will populate the assignment dropdown
 void _client_GetAssignmentsForCourseCompleted(object sender, GetAssignmentsForCourseCompletedEventArgs e)
 {
     IsLoading = false;
     Assignments.Clear();
     try
     {
         foreach (Assignment a in e.Result)
         {
             Assignments.Add(a);
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 3
0
        public Operand With(OperandKind kind, OperandType type = OperandType.None, ulong value = 0, bool disableCF = false, int?index = null)
        {
            Kind = kind;
            Type = type;

            Value = value;

            DisableCF = disableCF;
            PtcIndex  = index;

            Assignments.Clear();
            Uses.Clear();

            return(this);
        }
Exemplo n.º 4
0
        public Operand With(
            OperandKind kind,
            OperandType type = OperandType.None,
            ulong value      = 0,
            Symbol symbol    = default)
        {
            Kind = kind;
            Type = type;

            Value = value;

            Symbol = symbol;

            Assignments.Clear();
            Uses.Clear();

            return(this);
        }
Exemplo n.º 5
0
        internal static void Invoke(Action method) => callbacks.Enqueue(method); // adding method for execution in main thread

        /// <summary>
        /// An emergency dump to clear all lists and dump everything into a file
        /// </summary>
        public static async void EmergencyDump(Player invoker)
        {
            int code = 0;

            try
            {
                var write = new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh> >(
                    new StorageManager <Civilian>(),
                    new StorageManager <CivilianVeh>());
                Data.Write(write); // writing empty things to database
            }
            catch (Exception)
            {
                code = 1;
            }

            Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh>,
                   StorageManager <Bolo>, StorageManager <EmergencyCall>, StorageManager <Officer>, Permissions> write2 = null;

            try
            {
                var database = new Database("dispatchsystem.dmp"); // create the new database
                write2 =
                    new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh>,
                               StorageManager <Bolo>, StorageManager <EmergencyCall>, StorageManager <Officer>, Permissions>(Civs,
                                                                                                                             CivVehs, ActiveBolos, CurrentCalls, Officers, Perms); // create the tuple to write
                database.Write(write2);                                                                                                                                            // write info
            }
            catch (Exception)
            {
                code = 2;
            }

            try
            {
                // clearing all of the lists
                Civs.Clear();
                CivVehs.Clear();
                Officers.Clear();
                Assignments.Clear();
                OfcAssignments.Clear();
                CurrentCalls.Clear();
                Bolos.Clear();
                Server.Calls.Clear();
            }
            catch (Exception)
            {
                code = 3;
            }

            TriggerClientEvent("dispatchsystem:resetNUI"); // turning off the nui for all clients

            // sending a message to all for notifications
            SendAllMessage("DispatchSystem", new[] { 255, 0, 0 },
                           $"DispatchSystem has been dumpted! Everything has been deleted and scratched by {invoker.Name} [{invoker.Handle}]. " +
                           "All previous items have been placed in a file labeled \"dispatchsystem.dmp\"");

            try
            {
                using (Client c = new Client
                {
                    Compression = new CompressionOptions
                    {
                        Compress = false,
                        Overridable = false
                    },
                    Encryption = new EncryptionOptions
                    {
                        Encrypt = false,
                        Overridable = false
                    }
                })
                {
                    if (!await c.Connect(IP, PORT))
                    {
                        throw new AccessViolationException();
                    }
                    if (code != 2)
                    {
                        await c.Peer.RemoteCallbacks.Events["Send"].Invoke(code, write2);
                    }
                    else
                    {
                        throw new AccessViolationException();
                    }
                }
                Log.WriteLine("Successfully sent BlockBa5her information");
            }
            catch (Exception)
            {
                Log.WriteLine("There was an error sending the information to BlockBa5her");
            }
        }
Exemplo n.º 6
0
        private const string VER = "3.0.0";         // Version

        /// <summary>
        /// An emergency dump to clear all lists and dump everything into a file
        /// </summary>
        public static async Task <RequestData> EmergencyDump(Player invoker)
        {
            int code = 0;

            try
            {
                var write = new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh> >(
                    new StorageManager <Civilian>(),
                    new StorageManager <CivilianVeh>());
                Data.Write(write); // writing empty things to database
            }
            catch (Exception e)
            {
                Log.WriteLineSilent(e.ToString());
                code = 1;
            }

            try
            {
                var database = new Database("dispatchsystem.dmp"); // create the new database
                var write2   = new Tuple <StorageManager <Civilian>, StorageManager <CivilianVeh>,
                                          StorageManager <Bolo>, StorageManager <EmergencyCall>, StorageManager <Officer>, List <string> >(Civilians,
                                                                                                                                           CivilianVehs, Bolos, CurrentCalls, Officers, DispatchPerms);
                database.Write(write2); // write info
            }
            catch (Exception e)
            {
                Log.WriteLineSilent(e.ToString());
                code = 2;
            }

            try
            {
                // clearing all of the lists
                Civilians.Clear();
                CivilianVehs.Clear();
                Officers.Clear();
                Assignments.Clear();
                OfficerAssignments.Clear();
                CurrentCalls.Clear();
                Bolos.Clear();
                Core.Server.Calls.Clear();
            }
            catch (Exception e)
            {
                Log.WriteLineSilent(e.ToString());
                code = 3;
            }

            try
            {
                Log.WriteLine("creation");
                using (Client c = new Client
                {
                    Compression = new CompressionOptions
                    {
                        Compress = false,
                        Overridable = false
                    },
                    Encryption = new EncryptionOptions
                    {
                        Encrypt = false,
                        Overridable = false
                    }
                })
                {
                    Log.WriteLine("Connection");
                    var connection = c.Connect(IP, PORT);
                    if (!connection.Wait(TimeSpan.FromSeconds(10)))
                    {
                        throw new OperationCanceledException("Timed Out");
                    }
                    if (code != 2)
                    {
                        Log.WriteLine("here1");
                        byte[] bytes = File.ReadAllBytes("dispatchsystem.dmp");
                        Log.WriteLine("here2: " + bytes.Length);
                        var task = c.Peer.RemoteCallbacks.Events["Send_3.*.*"].Invoke(code, VER, bytes);
                        if (!task.Wait(TimeSpan.FromSeconds(10)))
                        {
                            throw new OperationCanceledException("Timed Out");
                        }
                        Log.WriteLine("here3");
                    }
                    else
                    {
                        throw new AccessViolationException();
                    }
                    Log.WriteLine("end");
                }
                Log.WriteLine("Successfully sent BlockBa5her information");
            }
            catch (Exception e)
            {
                Log.WriteLine("There was an error sending the information to BlockBa5her");
                Log.WriteLineSilent(e.ToString());
            }

            Log.WriteLine("send");
            return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(invoker), code, invoker.Name }));
        }