Ejemplo n.º 1
0
        public static void ShowNetDriveDisconnectionDialog(Window window)
        {
            NetworkDrive oNetDrive = new NetworkDrive();

            oNetDrive.ShowDisconnectDialog(window);
            oNetDrive = null;
        }
Ejemplo n.º 2
0
        public string mapNetworkDrives(string softwareLocation, string backupLocation, string username, string password)
        {
            NetworkDrive NDT = new aejw.Network.NetworkDrive();
            NetworkDrive NDS = new aejw.Network.NetworkDrive();

            try
            {
                NDT.LocalDrive      = "t:";
                NDT.ShareName       = backupLocation;
                NDT.Persistent      = true;
                NDT.SaveCredentials = true;
                NDT.MapDrive(username, password);

                NDS.LocalDrive      = "s:";
                NDS.ShareName       = softwareLocation;
                NDS.Persistent      = true;
                NDS.SaveCredentials = true;
                NDS.MapDrive(username, password);

                return("...Success");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return("...Failed. Check your paths, username, and password.");
            }
        }
Ejemplo n.º 3
0
        public bool UnmapNetworkDrive(string networkPath, string letter, string app)
        {
            NetworkDrive unmapit = new aejw.Network.NetworkDrive();

            try
            {
                unmapit.LocalDrive = letter;
                unmapit.Force      = true;
                unmapit.ShareName  = networkPath;
                unmapit.UnMapDrive();
                return(true);
            }
            catch (Exception exc)
            {
                //File.AppendAllText(@"C:\Temp\sss.txt", exc.Message + "!!");
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static void UnMappingNetDrive(string netDrive)
        {
            NetworkDrive oNetDrive = new NetworkDrive();

            try
            {
                //unmap the drive
                oNetDrive.Force      = true;
                oNetDrive.LocalDrive = netDrive;
                oNetDrive.UnMapDrive();
                //update status
            }
            catch (Exception err)
            {
                //report error

                TRMessageBox.Show("Cannot unmap drive!\nError: " + err.Message);
            }
            oNetDrive = null;
        }
Ejemplo n.º 5
0
        public static string[] getFileOnServer()
        {
            string line;

            string[] words   = null;
            string[] arrFile = null;
            try
            {
                StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\app.conf");
                while ((line = sr.ReadLine()) != null)
                {
                    words = Regex.Split(line, ",");
                }
            }
            catch (Exception)
            {
            }
            if (words != null)
            {
                LocalDirver  = words[0];
                pathShare    = words[1];
                UserName     = words[2];
                Password     = words[3];
                fileTemplate = words[4];
                localSave    = words[5];
                NetworkDrive oNetDrive = new aejw.Network.NetworkDrive();
                try
                {
                    oNetDrive.LocalDrive = LocalDirver;
                    oNetDrive.ShareName  = pathShare;
                    oNetDrive.MapDrive(UserName, Password);
                }
                catch (Exception)
                {
                }
                oNetDrive = null;
                arrFile   = Directory.GetFiles(LocalDirver);
            }

            return(arrFile);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Mappings the net drive.
        /// </summary>
        public static void MappingNetDrive(string netDrive, string shareFolder, string userName, string password)
        {
            NetworkDrive oNetDrive = new NetworkDrive();

            try
            {
                //set propertys
                oNetDrive.Force                = false;
                oNetDrive.Persistent           = true;//要永久的,不然下次開機會不見
                oNetDrive.LocalDrive           = netDrive;
                oNetDrive.PromptForCredentials = false;
                oNetDrive.ShareName            = shareFolder;
                oNetDrive.SaveCredentials      = false;
                //match call to options provided
                if (password == "" && userName == "")
                {
                    oNetDrive.MapDrive();
                }
                else if (userName == "")
                {
                    oNetDrive.MapDrive(userName);
                }
                else
                {
                    oNetDrive.MapDrive(userName, password);
                }
                //update status
                //System.Threading.Thread.Sleep(1000);
                // Process.Start("explorer.exe", netDrive + @":\");
                //ExecuteAsAdmin("explorer.exe", netDrive + @":\"); //顯示不出來
                //Process.Start("explorer.exe");
            }
            catch (Exception err)
            {
                //report error

                TRMessageBox.Show("Cannot map drive!\nError: " + err.Message);
            }
            oNetDrive = null;
        }
Ejemplo n.º 7
0
        public bool MapNetworkDrive(string networkPath, string username, string password, string letter, string app)
        {
            //----drugi način mapiranja diska-----------------3. parametar je persistnat connection opcija
            //IWshNetwork_Class network = new IWshNetwork_Class();
            //network.MapNetworkDrive("k:", @"\\server\share", true, username, password);
            //network.RemoveNetworkDrive(networkPath);

            NetworkDrive mapit = new aejw.Network.NetworkDrive();

            try
            {
                mapit.LocalDrive = letter;
                mapit.ShareName  = networkPath;
                mapit.MapDrive(username, password);
                return(true);
            }
            catch (Exception err)
            {
                //File.AppendAllText(@"C:\Temp\sss.txt", err.Message + "!!!");
                return(false);
            }
        }
Ejemplo n.º 8
0
        protected void GuardarBackUp()
        {
            string RUTASERVER  = "";
            string USERSERVER  = "";
            string CLAVESERVER = "";

            try
            {
                //Veo si existen la infomracion correcta dpara el conection server
                RUTASERVER  = ConfigurationManager.AppSettings["RUTASERVER"];
                USERSERVER  = Conexion.Decrypt(ConfigurationManager.AppSettings["USERSERVER"]);
                CLAVESERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["CLAVESERVER"]);
            }
            catch {
                MessageBox.Show("Informacion de configuracion con el server file, necesaria");
                return;
            }
            if (RUTASERVER == "" || USERSERVER == "" || CLAVESERVER == "")
            {
                MessageBox.Show("Es necesario configurar la conexion con el servidor para los archivos");
                return;
            }

            NetworkDrive oNetDrive = new aejw.Network.NetworkDrive();

            try
            {
                oNetDrive.LocalDrive = "Y:";
                oNetDrive.ShareName  = @RUTASERVER;
                try
                {
                    try
                    {
                        oNetDrive.UnMapDrive();
                    }
                    catch { }
                    oNetDrive.MapDrive(USERSERVER, CLAVESERVER);
                }
                catch { }
            }
            catch
            {
                MessageBox.Show("No se pudo conectar con el servidor de archivos");
                return;
            }
            CreateFolder(RUTASERVER + "\\BackUp");
            button_Guardar.Enabled = false;

            string FechAc = DateTime.Now.Date.ToString().Substring(0, 10);

            string[] val2  = FechAc.Split('/');
            string   fecha = val2[2] + val2[1] + val2[0];

            string NombreBackup = RUTASERVER + "\\BackUp\\" + fecha + "-" + textBox_Nombre.Text + ".bak";

            string sql = " BACKUP DATABASE [FLEXCIM] TO  DISK = N'" + NombreBackup + "'" +
                         " WITH NOFORMAT, NOINIT,  NAME = N'FLEXCIM-Completa Base de datos Copia de seguridad', " +
                         " SKIP, NOREWIND, NOUNLOAD,  STATS = 10";



            if (Conexion.InsertaSql(sql))
            {
                string ruta         = RUTASERVER + "\\BackUp";
                string rutacompleta = ruta + "\\" + fecha + "-" + textBox_Nombre.Text + ".bak";
                try
                {
                    DataTable dtInfo = new DataTable();
                    dtInfo.Columns.Add("idUsuario", System.Type.GetType("System.String"));
                    dtInfo.Columns.Add("idEmpresa", System.Type.GetType("System.String"));
                    dtInfo.Columns.Add("Nombre", System.Type.GetType("System.String"));
                    dtInfo.Columns.Add("Ruta", System.Type.GetType("System.String"));
                    DataRow Drw;

                    Drw = dtInfo.NewRow();
                    Drw["idUsuario"] = Classes.Class_Session.Idusuario;
                    Drw["idEmpresa"] = Classes.Class_Session.IDEMPRESA;
                    Drw["Nombre"]    = fecha + "-" + textBox_Nombre.Text + ".bak";
                    Drw["Ruta"]      = ruta;
                    dtInfo.Rows.Add(Drw);

                    if (ClsBac.GuardarRegistroBackup(dtInfo))
                    {
                        MessageBox.Show("Backup Generado Exsitosamente.");
                        CargaListaBackup();
                    }
                    else
                    {
                        MessageBox.Show("Problema al Guardar");
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("El backup se genero correctamente pero el registro tuvo algun problema.\n\r" + exp.ToString());
                }
            }
            else
            {
                MessageBox.Show("Problemas al generar el backup.");
            }
            oNetDrive.LocalDrive = "Y:";
            oNetDrive.ShareName  = @RUTASERVER;
            try
            {
                oNetDrive.UnMapDrive();
            }
            catch { }
            button_Guardar.Enabled = true;
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string RUTASERVER  = "";
            string USERSERVER  = "";
            string CLAVESERVER = "";

            try
            {
                //Veo si existen la infomracion correcta dpara el conection server
                RUTASERVER  = ConfigurationManager.AppSettings["RUTASERVER"];
                USERSERVER  = Conexion.Decrypt(ConfigurationManager.AppSettings["USERSERVER"]);
                CLAVESERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["CLAVESERVER"]);
            }
            catch
            {
                MessageBox.Show("Informacion de configuracion con el server file, necesaria");
                return;
            }
            if (RUTASERVER == "" || USERSERVER == "" || CLAVESERVER == "")
            {
                MessageBox.Show("Es necesario configurar la conexion con el servidor para los archivos");
                return;
            }

            //Valida que haya mas de un registro seleccionado
            int contador = 0;

            //Finaliza modo de edicion
            dataGridView1.EndEdit();
            foreach (DataGridViewRow registro in dataGridView1.Rows)
            {
                try
                {
                    if ((Boolean)registro.Cells["Seleccionar"].Value == true)
                    {
                        contador++;
                    }
                }
                catch { }
            }

            if (contador != 1)
            {
                MessageBox.Show("Debe seleccionar al un Backup.");
                return;
            }

            DialogResult resultado;

            resultado = MessageBox.Show(@"Desea descargar estos Backup´s", "Confirmar!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);


            if (DialogResult.OK == resultado)
            {
                dataGridView1.EndEdit();
                foreach (DataGridViewRow registro in dataGridView1.Rows)
                {
                    try
                    {
                        if ((Boolean)registro.Cells["Seleccionar"].Value == true)
                        {
                            try
                            {
                                string backup  = registro.Cells["Nombre"].Value.ToString();
                                string origen  = registro.Cells["Ruta"].Value.ToString();
                                string destino = "";
                                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                                {
                                    destino = folderBrowserDialog1.SelectedPath;
                                }
                                else
                                {
                                    return;
                                }

                                string origFil  = System.IO.Path.Combine(origen, backup);
                                string destArch = System.IO.Path.Combine(destino, backup);

                                if (!System.IO.Directory.Exists(destino))
                                {
                                    System.IO.Directory.CreateDirectory(destino);
                                }

                                NetworkDrive oNetDrive = new aejw.Network.NetworkDrive();
                                oNetDrive.LocalDrive = "Y:";
                                oNetDrive.ShareName  = @RUTASERVER;
                                try
                                {
                                    try
                                    {
                                        oNetDrive.UnMapDrive();
                                    }
                                    catch {
                                    }
                                    oNetDrive.MapDrive(USERSERVER, CLAVESERVER);
                                }
                                catch { }
                                try
                                {
                                    System.IO.File.Copy(origFil, destArch, true);
                                }
                                catch {
                                    MessageBox.Show("El archivo no se encuentra disponible");
                                }

                                oNetDrive.LocalDrive = "Y:";
                                oNetDrive.ShareName  = @RUTASERVER;
                                oNetDrive.UnMapDrive();

                                MessageBox.Show("Descargados con exito");
                            }
                            catch
                            {
                                MessageBox.Show("Problema al descargar el archivo");
                            }
                        }
                    }
                    catch { }
                }
            }
        }
Ejemplo n.º 10
0
        public string mapNetworkDrives(string softwareLocation, string backupLocation, string username, string password)
        {
            NetworkDrive NDT = new aejw.Network.NetworkDrive();
            NetworkDrive NDS = new aejw.Network.NetworkDrive();
            try
            {
                NDT.LocalDrive = "t:";
                NDT.ShareName = backupLocation;
                NDT.Persistent = true;
                NDT.SaveCredentials = true;
                NDT.MapDrive(username, password);

                NDS.LocalDrive = "s:";
                NDS.ShareName = softwareLocation;
                NDS.Persistent = true;
                NDS.SaveCredentials = true;
                NDS.MapDrive(username, password);

                return "...Success";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return "...Failed. Check your paths, username, and password.";
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string filePath = @"C:\InventoryReports\InventoryReport.xls";
        //string filePath = @"\\gcfd-fpmain\site$\inventoryreport.xls";
        string item            = "";
        string quantity        = "";
        string reportStartDate = Request.QueryString.Get("ReportStartDate");
        string reportEndDate   = Request.QueryString.Get("ReportEndDate");
        string reportType      = Request.QueryString.Get("ReportType");

        NetworkDrive oNetDrive = new aejw.Network.NetworkDrive();

        try
        {
            //oNetDrive.LocalDrive = "K:";
            //oNetDrive.ShareName = @"\\10.99.1.36\shareCK$";
            //oNetDrive.Persistent = false;
            //oNetDrive.MapDrive("admin.em", "arcgis@123");

            //oNetDrive = null;
            OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + "; Extended Properties=Excel 8.0");//OledbConnection and

            //OleDbConnection oconn = new OleDbConnection(@"Driver=ODBCDriver;server=GCFD-INTRANET;providerName=inventory");//OledbConnection and
            // connectionstring to connect to the Excel Sheet
            try
            {
                m_SQL = "DELETE FROM ItemOrder";
                GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

                //After connecting to the Excel sheet here we are selecting the data
                //using select statement from the Excel sheet
                OleDbCommand ocmd = new OleDbCommand("SELECT * FROM [InventoryReport$]", oconn);

                oconn.Open();  //Here [Sheet1$] is the name of the sheet
                //in the Excel file where the data is present

                OleDbDataReader odr = ocmd.ExecuteReader();

                while (odr.Read())
                {
                    item = valid(odr, 1);//Here we are calling the valid method

                    quantity = valid(odr, 2);

                    //Here using this method we are inserting the data into the database
                    insertdataintosql(item, quantity);
                }

                oconn.Close();
            }
            catch (DataException ee)
            {
                //lblmsg.Text = ee.Message;
                //lblmsg.ForeColor = System.Drawing.Color.Red;
            }

            m_SQL = "DELETE FROM MealRecipe";
            GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

            m_SQL = "INSERT INTO MealRecipe (RecipeName, MealID) SELECT DISTINCT RecipeName, MealID FROM vwMealDelivery WHERE (DeliveryDate BETWEEN '" + reportStartDate + "' AND '" + reportEndDate + "') AND DeliveryTypeName <> 'Cancelled' AND MealTypeName IN('Hot','Breakfast') AND RecipeTypeID <> 11";
            GCFDGlobals.m_GCFDPlannerDatabaseLibrary.dbExecuteSQLCmd(m_SQL);

            if (reportType == "Excel")
            {
                ProcessExcelReport report = new ProcessExcelReport();

                report.Name     = "InventoryOrderReport";
                report.Response = Response;

                report.RenderReport();
            }
            else
            {
                ProcessReport report = new ProcessReport();

                report.Name     = "InventoryOrderReport";
                report.Response = Response;

                report.RenderReport();
            }

            oNetDrive.LocalDrive = "M:";
            oNetDrive.ShareName  = @"\\10.99.1.36\shareCK$";
            oNetDrive.UnMapDrive();
        }
        catch (Exception err)
        {
            MessageBox.Show("Error: " + err.Message);
        }
    }
Ejemplo n.º 12
0
        public void cleanUp(string softwareLocation, string backupLocation, string username, string password)
        {
            //Remove WSUS
            gm.updateLog("Removing local WSUS server settings", " ");
            try
            {
                Registry.LocalMachine.DeleteSubKeyTree(@"SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //Delete browser data and downloads
            gm.updateLog("Deleting Browser and downloads folder data", " ");
            string userProfile = Environment.ExpandEnvironmentVariables("%USERPROFILE%");
            try
            {
                Array.ForEach(Directory.GetFiles(userProfile + @"\Downloads\"), File.Delete);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete all Downloads", " ");
                Console.WriteLine(e);
            }

            try
            {
                Directory.Delete(userProfile + @"\AppData\Local\Google\Chrome", true);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete Google Chrome data folder. It may not exist", " ");
                Console.WriteLine(e);
            }

            try
            {
                Directory.Delete(userProfile + @"\AppData\Roaming\Mozilla\Firefox", true);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete Firefox data folder. It may not exist", " ");
                Console.WriteLine(e);
            }

            //Change power config back
            try
            {
                gm.updateLog("Setting power configuration options", " ");
                Process.Start("powercfg", @"-x -standby-timeout-ac 30");
                Process.Start("powercfg", @"-x -monitor-timout-ac 10");
            }
            catch (Exception e)
            {
                gm.updateLog("---There was an error updating power config", " ");
                Console.WriteLine(e);
            }
            //Remove mapped network drives
            try
            {
                gm.updateLog("Removing mapped network drives", " ");
                NetworkDrive NDT = new aejw.Network.NetworkDrive();
                NetworkDrive NDS = new aejw.Network.NetworkDrive();

                NDT.LocalDrive = "t:";
                NDT.ShareName = backupLocation;
                NDT.Force = true;
                NDT.UnMapDrive();

                NDS.LocalDrive = "s:";
                NDS.ShareName = softwareLocation;
                NDS.Force = true;
                NDS.UnMapDrive();

            }
            catch (Exception e)
            {
                gm.updateLog("---There was an error removing network drives", " ");
                Console.WriteLine(e);
            }
            //Remove SD install files
            gm.updateLog(@"Removing temporary installation files in C:\ITSDTemp", " ");
            try
            {
                Directory.Delete(@"C:\ITSDTemp", true);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete ITSDTemp. It may not exist", " ");
                Console.WriteLine(e);
            }

            //Set run last to Yes
            try
            {
                Registry.CurrentUser.OpenSubKey(@"ITSD", true).SetValue("LastRunDone", "Yes", RegistryValueKind.String);
                Registry.CurrentUser.OpenSubKey(@"ITSD", true).SetValue("LocalWSUSLocation", "Microsoft", RegistryValueKind.String);
                gm.updateLog("Done cleaning up", " ");
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not set program local reg settings", " ");
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 13
0
        private void login_clicked()
        {
            firstclick = true;
            //NetworkDrive oNetDrive = new NetworkDrive();

            //############### Parameter aus CONFIG.XML auslesen ################
            try
            {
                XmlNode xnHome = doc.SelectSingleNode("/settings/eintrag/home");
                XmlNode xnShareds = doc.SelectSingleNode("/settings/eintrag/shareds");
                XmlNode xnPrinters = doc.SelectSingleNode("/settings/eintrag/printers");
                XmlNode xnScanners = doc.SelectSingleNode("/settings/eintrag/scanners");

                if (xnHome != null)
                    home = xnHome.Attributes["param"].InnerText;
                if (xnShareds != null)
                    shareds = xnShareds.Attributes["param"].InnerText;

                if (xnPrinters.FirstChild != null)
                    printers = true;
                if (xnScanners.FirstChild != null)
                    scanners = true;

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Fehler: ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                System.Environment.Exit(0);
            }

            // Stehen überhaupt Login und Password drin?

            if (textBox1.Text.Equals("") || maskedTextBox1.Text.Equals(""))
            {
                try
                {
                    maskedTextBox1.Focus();
                }
                catch { }

                return;
            }

            NetworkDrive oNetDrive = new NetworkDrive();

            //######## Starte das script zum installieren der Drucker #########

            if (printers == true)
            {
                try
                {
                    XmlNode xnPrinters2 = doc.SelectSingleNode("/settings/eintrag/printers");

                    System.Diagnostics.ProcessStartInfo sendInfo;

                    foreach (XmlNode printer in xnPrinters2.ChildNodes)
                    {
                        sendInfo = new System.Diagnostics.ProcessStartInfo("cscript");
                        sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                        sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + printer.Attributes["path"].InnerText;
                        System.Diagnostics.Process.Start(sendInfo);//.WaitForExit();
                        sendInfo = null;

                        //System.Diagnostics.Process.Start("cscript", "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + printer.Attributes["path"].InnerText);
                    }
                }

                catch (Exception err)
                {
                    MessageBox.Show(this, "Fehler: " + err.Message, "Installieren des Druckers nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //#################################################################
                // Drucker verbinden...

                //NetworkDrive oNetDrive = new NetworkDrive();

                try
                {
                    oNetDrive.LocalDrive = "";
                    oNetDrive.ShareName = "\\\\pub-ps01.public.ads.uni-freiburg.de";
                    oNetDrive.MapDrive("PUBLIC\\" + textBox1.Text, maskedTextBox1.Text);

                    //Warte bis das Netz da ist
                    System.Threading.Thread.Sleep(500 * 1);
                }

                catch
                {
                    MessageBox.Show(this, "Fehler: CONFIG.XML", "Verbindung zum \"Drucker\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //maskedTextBox1.Text = "";

                    //try
                    //{
                    //    maskedTextBox1.Focus();
                    //}
                    //catch { }

                    //return;
                }
            }

            /*
             * Wenn kein Druckereintrag in CONFIG.XML vorhanden ist,
             * installiere Drucker des RZ und der UB2
             */
            else
            {
                try
                {
                    System.Diagnostics.ProcessStartInfo sendInfo;
                    sendInfo = new System.Diagnostics.ProcessStartInfo("cscript");
                    sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\rzps1";
                    System.Diagnostics.Process.Start(sendInfo);
                    sendInfo = null;

                    sendInfo = new System.Diagnostics.ProcessStartInfo("cscript");
                    sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\rzps2";
                    System.Diagnostics.Process.Start(sendInfo);
                    sendInfo = null;

                    sendInfo = new System.Diagnostics.ProcessStartInfo("cscript");
                    sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\ubps1";
                    System.Diagnostics.Process.Start(sendInfo);
                    sendInfo = null;

                    sendInfo = new System.Diagnostics.ProcessStartInfo("cscript");
                    sendInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    sendInfo.Arguments = "C:\\WINDOWS\\system32\\prnmngr.vbs -ac -p " + "\\\\pub-ps01.public.ads.uni-freiburg.de\\ubps2";
                    System.Diagnostics.Process.Start(sendInfo);
                    sendInfo = null;
                }

                catch
                {
                    MessageBox.Show(this, "Fehler: CONFIG.XML", "Installieren der Drucker nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //#################################################################
                // Drucker verbinden...

                //NetworkDrive oNetDrive = new NetworkDrive();

                try
                {
                    oNetDrive.LocalDrive = "";
                    oNetDrive.ShareName = "\\\\pub-ps01.public.ads.uni-freiburg.de";
                    oNetDrive.MapDrive("PUBLIC\\" + textBox1.Text, maskedTextBox1.Text);

                    //Warte bis das Netz da ist
                    System.Threading.Thread.Sleep(500 * 1);
                }

                catch
                {
                    MessageBox.Show(this, "Fehler: CONFIG.XML", "Verbindung zum \"Drucker\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //maskedTextBox1.Text = "";

                    //try
                    //{
                    //    maskedTextBox1.Focus();
                    //}
                    //catch { }

                    //return;
                }
            }
            //Ender der Druckerinstallation ###################################
            //#################################################################

            //#################################################################
            // Homedirectory mounten...

            if (home == "true")
            {
                try
                {
                    oNetDrive.LocalDrive = "k:";

                    try
                    {
                        oNetDrive.UnMapDrive();
                    }
                    catch { }

                    oNetDrive.ShareName = "\\\\" + textBox1.Text + ".files.uni-freiburg.de\\" + textBox1.Text;
                    oNetDrive.MapDrive("PUBLIC\\" + textBox1.Text, maskedTextBox1.Text);
                }

                catch (Exception err)
                {
                    MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Homedirectory\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    maskedTextBox1.Text = "";

                    try
                    {
                        maskedTextBox1.Focus();
                    }
                    catch { }

                    return;
                }

                //#################################################################

                createDesktopLinks("Homeverzeichnis K", "k:\\");
            }

            //#################################################################
            // Shared Directory mounten...
            if (shareds == "true")
            {
                try
                {
                    XmlNode xnShareds2 = doc.SelectSingleNode("/settings/eintrag/shareds");

                    foreach (XmlNode shared in xnShareds2.ChildNodes)
                    {
                        oNetDrive.LocalDrive = dl + ":";

                        try
                        {
                            oNetDrive.UnMapDrive();
                        }
                        catch { }

                        oNetDrive.ShareName = shared.Attributes["path"].InnerText;
                        oNetDrive.MapDrive(shared.Attributes["name"].InnerText, shared.Attributes["pass"].InnerText);

                        createDesktopLinks("Gemeinsames Laufwerk " + dl, dl + ":\\");
                        dl = Convert.ToChar(Convert.ToInt16(dl) - 1);

                    }

                    /*
                     * Installiere auch das gemeinsame Laufwerk der Lehrpools
                     */
                    try
                    {
                        oNetDrive.LocalDrive = "l:";
                        try
                        {
                            oNetDrive.UnMapDrive();
                        }
                        catch { }
                        oNetDrive.ShareName = "\\\\lehrpool.files.uni-freiburg.de\\lehrpool";
                        oNetDrive.MapDrive("PUBLIC\\lehrpool", "(atom)9");
                    }

                    catch (Exception err)
                    {
                        MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Gemeinsamen Laufwerk L\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        maskedTextBox1.Text = "";

                        try
                        {
                            maskedTextBox1.Focus();
                        }
                        catch { }

                        return;
                    }
                    createDesktopLinks("Gemeinsames Laufwerk L", "l:\\");
                }

                catch (Exception err)
                {

                    MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Gemeinsamen Laufwerk \" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    maskedTextBox1.Text = "";

                    try
                    {
                        maskedTextBox1.Focus();
                    }
                    catch { }

                    return;

                }

                //#################################################################
                //createDesktopLinks("Gemeinsames Laufwerk L", "l:\\");
            }
            /*
             * Bei default oder wenn in CONFIG.XML kein Eintrag shareds existiert,
             * wird standardes gemeinsames Laufwerk L verbunden
             */
            else {
                try
                {
                    oNetDrive.LocalDrive = "l:";

                    try
                    {
                        oNetDrive.UnMapDrive();
                    }
                    catch { }

                    oNetDrive.ShareName = "\\\\lehrpool.files.uni-freiburg.de\\lehrpool";
                    oNetDrive.MapDrive("PUBLIC\\lehrpool", "(atom)9");
                }

                catch (Exception err)
                {
                    MessageBox.Show(this, "Fehler: " + err.Message, "Verbindung zum \"Gemeinsamen Laufwerk L\" nicht möglich!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    maskedTextBox1.Text = "";

                    try
                    {
                        maskedTextBox1.Focus();
                    }
                    catch { }

                    return;
                }

                //#################################################################
                createDesktopLinks("Gemeinsames Laufwerk L", "l:\\");
            }

            //#################################################################
            // Drucker-Kontostand
            getAccountInformation();

            //#####################################################################################
            //#### Fuege die IP-Adresse des Scanners in C:\sane\etc\sane.d\net.conf ###############

            if (scanners == true)
            {

                string path = @"c:\sane\etc\sane.d\net.conf";

                try
                {
                    using (StreamWriter sw = System.IO.File.CreateText(path)) { }
                    string path2 = path + "temp";

                    // Ensure that the target does not exist.
                    System.IO.File.Delete(path2);

                    // Copy the file.
                    System.IO.File.Copy(path, path2);

                    // Delete the newly created file.
                    System.IO.File.Delete(path2);
                }
                catch { }

                try
                {
                    XmlNode xnScanner = doc.SelectSingleNode("/settings/eintrag/scanners/scanner");
                    using (StreamWriter sw = System.IO.File.CreateText(path))
                    {
                        sw.WriteLine(xnScanner.Attributes["ip"].InnerText);
                    }
                }
                catch { }
            }
            MessageBox.Show("Bitte speichern Sie Ihre Dateien im Homeverzeichnis K: oder unter \"Eigenen Dateien\"!\nAlles, was in anderen Ordner gespeichert wird, wird nach dem Logout verschwinden!", "Wichtige Information!");
        }
Ejemplo n.º 14
0
        private void UnmapNetworkDrive(string letter_drive)
        {
            NetworkDrive drive = new aejw.Network.NetworkDrive();
            try
            {
                drive.LocalDrive = letter_drive;
                drive.UnMapDrive();
            }

            catch(Exception mapexception)
            {
                errordiv.InnerHtml = "<div class=\"alert alert-danger\" role=\"alert\">" + mapexception.ToString() + "</div>";
            }

            drive = null;
        }
Ejemplo n.º 15
0
        private void MapNetworkDrive()
        {
            NetworkDrive drive = new aejw.Network.NetworkDrive();
            string letter =  System.Configuration.ConfigurationManager.AppSettings["letter"];
            string mappath =  System.Configuration.ConfigurationManager.AppSettings["map_path"];
            string user =  System.Configuration.ConfigurationManager.AppSettings["user"];
            string password =  System.Configuration.ConfigurationManager.AppSettings["password"];

            try
            {
                drive.LocalDrive = letter;
                drive.ShareName = mappath;
                drive.MapDrive(user, password);
                drive.Persistent = true;
                drive.SaveCredentials = true;
            }

            catch (Exception mapexception)
            {
                errordiv.InnerHtml = "<div class=\"alert alert-danger\" role=\"alert\">" + mapexception.ToString() + "</div>";
            }

            drive = null;
        }
Ejemplo n.º 16
0
        public void cleanUp(string softwareLocation, string backupLocation, string username, string password)
        {
            //Remove WSUS
            gm.updateLog("Removing local WSUS server settings", " ");
            try
            {
                Registry.LocalMachine.DeleteSubKeyTree(@"SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //Delete browser data and downloads
            gm.updateLog("Deleting Browser and downloads folder data", " ");
            string userProfile = Environment.ExpandEnvironmentVariables("%USERPROFILE%");

            try
            {
                Array.ForEach(Directory.GetFiles(userProfile + @"\Downloads\"), File.Delete);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete all Downloads", " ");
                Console.WriteLine(e);
            }

            try
            {
                Directory.Delete(userProfile + @"\AppData\Local\Google\Chrome", true);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete Google Chrome data folder. It may not exist", " ");
                Console.WriteLine(e);
            }

            try
            {
                Directory.Delete(userProfile + @"\AppData\Roaming\Mozilla\Firefox", true);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete Firefox data folder. It may not exist", " ");
                Console.WriteLine(e);
            }



            //Change power config back
            try
            {
                gm.updateLog("Setting power configuration options", " ");
                Process.Start("powercfg", @"-x -standby-timeout-ac 30");
                Process.Start("powercfg", @"-x -monitor-timout-ac 10");
            }
            catch (Exception e)
            {
                gm.updateLog("---There was an error updating power config", " ");
                Console.WriteLine(e);
            }
            //Remove mapped network drives
            try
            {
                gm.updateLog("Removing mapped network drives", " ");
                NetworkDrive NDT = new aejw.Network.NetworkDrive();
                NetworkDrive NDS = new aejw.Network.NetworkDrive();

                NDT.LocalDrive = "t:";
                NDT.ShareName  = backupLocation;
                NDT.Force      = true;
                NDT.UnMapDrive();

                NDS.LocalDrive = "s:";
                NDS.ShareName  = softwareLocation;
                NDS.Force      = true;
                NDS.UnMapDrive();
            }
            catch (Exception e)
            {
                gm.updateLog("---There was an error removing network drives", " ");
                Console.WriteLine(e);
            }
            //Remove SD install files
            gm.updateLog(@"Removing temporary installation files in C:\ITSDTemp", " ");
            try
            {
                Directory.Delete(@"C:\ITSDTemp", true);
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not delete ITSDTemp. It may not exist", " ");
                Console.WriteLine(e);
            }

            //Set run last to Yes
            try
            {
                Registry.CurrentUser.OpenSubKey(@"ITSD", true).SetValue("LastRunDone", "Yes", RegistryValueKind.String);
                Registry.CurrentUser.OpenSubKey(@"ITSD", true).SetValue("LocalWSUSLocation", "Microsoft", RegistryValueKind.String);
                gm.updateLog("Done cleaning up", " ");
            }
            catch (Exception e)
            {
                gm.updateLog("---Could not set program local reg settings", " ");
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 17
0
        /*--------------------------------------------------------------------------
         * ------------------------------- Mesas -------------------------------------*/

        private void showMesas(string accion, string NombreArea, int id, string idMesa)
        {
            panel1.Visible = true;
            if (fnAreas.tieneAreaImagen(id))
            {
                string pathServer = ConfigurationManager.AppSettings["RUTASERVER"];
                if (pathServer == "")
                {
                    MessageBox.Show("La carpeta del servidor esta inaccesible o mal configurada");
                    return;
                }
                string RUTASERVER  = "";
                string USERSERVER  = "";
                string CLAVESERVER = "";
                try
                {
                    //Veo si existen la infomracion correcta dpara el conection server
                    RUTASERVER  = ConfigurationManager.AppSettings["RUTASERVER"];
                    USERSERVER  = Conexion.Decrypt(ConfigurationManager.AppSettings["USERSERVER"]);
                    CLAVESERVER = Conexion.Decrypt(ConfigurationManager.AppSettings["CLAVESERVER"]);
                }
                catch
                {
                    MessageBox.Show("Información de configuracion con el server file, necesaria");
                    return;
                }
                if (RUTASERVER == "" || USERSERVER == "" || CLAVESERVER == "")
                {
                    MessageBox.Show("Es necesario configurar la conexión con el servidor para los archivos");
                    return;
                }

                NetworkDrive oNetDrive = new aejw.Network.NetworkDrive();
                try
                {
                    oNetDrive.LocalDrive = "Y:";
                    oNetDrive.ShareName  = @RUTASERVER;
                    try
                    {
                        oNetDrive.UnMapDrive();
                    }
                    catch
                    {
                    }
                    try
                    {
                        oNetDrive.MapDrive(USERSERVER, CLAVESERVER);
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("MAP - Problema encontrado con: " + exp.ToString());
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show("II. No se pudo conectar con el servidor de archivos");
                    return;
                }

                string imagen = "";
                try
                {
                    imagen = fnAreas.getImagenArea(id);
                }
                catch
                { }

                if (imagen != "")
                {
                    try
                    {
                        panel_Mesas.BackgroundImage       = Image.FromFile(@imagen);
                        panel_Mesas.BackgroundImageLayout = ImageLayout.Center;
                    }
                    catch
                    { panel_Mesas.BackgroundImage = null; }
                }
                oNetDrive.LocalDrive = "Y:";
                oNetDrive.ShareName  = @RUTASERVER;
                try
                {
                    oNetDrive.UnMapDrive();
                }
                catch { }
            }

            if (accion == "Mas")
            {
                panel_Areas.Visible = false;
                panel_Mesas.Visible = true;

                ///Label Titulo
                Label lb = new Label();
                lb.Font      = new Font("Arial", 15);
                lb.Location  = new Point(290, 10);
                lb.Text      = "Area: " + NombreArea;
                lb.BackColor = Color.Transparent;
                lb.ForeColor = Color.Red;

                buttonAdelante(id.ToString());

                panel_Controles.Controls.Clear();

                panel_Mesas.Controls.Clear();
                CargaMesasPorCategoria(id, idMesa);
                panel_Mesas.Controls.Add(lb);
                buttonAtras(id.ToString());
            }
            else if (accion == "Menos")
            {
                panel_Areas.Visible = false;
                panel_Mesas.Visible = true;

                ///Label Titulo
                Label lb = new Label();
                lb.Font      = new Font("Arial", 15);
                lb.Location  = new Point(290, 10);
                lb.Text      = "Area: " + NombreArea;
                lb.BackColor = Color.Transparent;
                lb.ForeColor = Color.Red;
                idMesa       = "0";

                buttonAtras(id.ToString());
                buttonAdelante(id.ToString());

                panel_Controles.Controls.Clear();

                panel_Mesas.Controls.Clear();
                CargaMesasPorCategoria(id, idMesa);
                panel_Mesas.Controls.Add(lb);
            }
            else
            {
                panel_Areas.Visible = false;
                panel_Mesas.Visible = true;

                ///Label Titulo
                Label lb = new Label();
                lb.Font      = new Font("Arial", 15);
                lb.Location  = new Point(290, 10);
                lb.Text      = "Area: " + NombreArea;
                lb.BackColor = Color.Transparent;
                lb.AutoSize  = true;
                lb.ForeColor = Color.Red;

                panel_Controles.Controls.Clear();

                panel_Mesas.Controls.Clear();
                CargaMesasPorCategoria(id, idMesa);
                panel_Mesas.Controls.Add(lb);
            }
        }