Ejemplo n.º 1
0
 internal static void UnableToAllocateMemory(WinErrors errorCode)
 {
     if (errorCode == WinErrors.ERROR_WORKING_SET_QUOTA)
     {
         ThrowException(new InvalidOperationException("Insufficient quota of working set to lock the memory from paging."));
     }
     ThrowException(new InvalidOperationException($"Unable to allocate memory with error code {errorCode}"));
 }
Ejemplo n.º 2
0
        //Maps Network drive asynchronously to interacting with the ui
        public async Task <string> RunMapDriveThread()
        {
            string message = "You'll usually only need to enter your credentials from administrator account.";

            return(await Task.Run <string>(() =>
            {
                int error = 0;

                if (MapDriveTextBox.Text == "1")
                {
                    if (MapPasswordTextBox.Text == string.Empty && MapUserNameTextBox.Text == string.Empty)
                    {
                        message = RunCommand(@"net use Z: \\jdnet\jdmedia /persistent:no");
                    }
                    else
                    {
                        error = MapNetworkDrive.NetworkDrive.MapNetworkDrive("Z", @"\\jdnet\jdmedia", MapPasswordTextBox.Text, MapUserNameTextBox.Text);
                        message = WinErrors.GetSystemMessage((uint)error);
                    }
                }
                else if (MapDriveTextBox.Text == "2")
                {
                    if (MapPasswordTextBox.Text == string.Empty && MapUserNameTextBox.Text == string.Empty)
                    {
                        message = RunCommand(@"net use Z: \\wdx0000041205a\tier2share /persistent:no");
                    }
                    else
                    {
                        error = MapNetworkDrive.NetworkDrive.MapNetworkDrive("Z", @"\\wdx0000041205a\tier2share", MapPasswordTextBox.Text, MapUserNameTextBox.Text);
                        message = WinErrors.GetSystemMessage((uint)error);
                    }
                }

                else if (MapDriveTextBox.Text == "3")
                {
                    if (UNCPathTextBox.Visible)
                    {
                        if (MapPasswordTextBox.Text == string.Empty && MapUserNameTextBox.Text == string.Empty)
                        {
                            message = RunCommand($@"net use {MapLetterTextBox.Text}: {UNCPathTextBox.Text} /persistent:no");
                        }
                        else
                        {
                            try
                            {
                                error = MapNetworkDrive.NetworkDrive.MapNetworkDrive(MapLetterTextBox.Text, UNCPathTextBox.Text, MapPasswordTextBox.Text, MapUserNameTextBox.Text);
                                message = WinErrors.GetSystemMessage((uint)error);
                            }
                            catch (Exception)
                            {
                                message = "Invalid path";
                            }
                        }
                    }
                    else
                    {
                        //Turns on Visability of the UNC Drive letter and path
                        //Runs it as a dummy delegate outside of the async thread
                        this.Invoke((MethodInvoker)(() =>
                        {
                            UNCPathTextBox.Visible = true;
                            MapLetterTextBox.Visible = true;
                            DriveLetterLabel.Visible = true;
                        }));
                    }
                }

                else if (MapDriveTextBox.Text == "4")
                {
                    this.Invoke((MethodInvoker)(() =>
                    {
                        panel1.Show();
                        panel2.Hide();
                        MapDriveErrorLabel.Text = "You'll usually only need to enter your credentials from administrator account.";
                    }));
                }

                else if (MapDriveTextBox.Text == "5")
                {
                    System.Environment.Exit(1);
                }

                else
                {
                    message = "Invalid number";
                }



                return message;
            }));
        }
Ejemplo n.º 3
0
 internal static void UnableToFreeMemory(WinErrors errorCode) => ThrowException(new InvalidOperationException($"Unable to free the allocated memory with errorcode {errorCode}"));
Ejemplo n.º 4
0
 internal CryptographyException(WinErrors nativeError)
     : base(string.Format("Error {0}.", nativeError))
 {
     return;
 }