public bool LoadUSBPicture(string UserName)
        {
            // load from usb....
            systemPath = RoboSep_UserDB.getInstance().sysPath;

            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Report SysPath: " + systemPath);
            //systemPath = @"C:\Program Files (x86)\STI\RoboSep\";

            string IconsPath = systemPath + "images\\";

            if (!Directory.Exists(IconsPath))
            {
                Directory.CreateDirectory(IconsPath);
            }

            // search for usb directory
            string[] USBdirs     = new string[] { "D:\\", "E:\\", "F:\\", "G:\\" };
            int      usbDirIndex = -1;

            for (int i = 0; i < USBdirs.Length; i++)
            {
                if (Directory.Exists(USBdirs[i]))
                {
                    usbDirIndex = i;
                    break;
                }
            }

            if (usbDirIndex > -1)
            {
                string      sTitle = LanguageINI.GetString("headerSelectImageFile");
                FileBrowser fb     = new FileBrowser(RoboSep_UserConsole.getInstance(), sTitle, USBdirs[usbDirIndex], IconsPath,
                                                     new string[] { ".jpg", ".jpeg", ".png", ".tga", ".bmp" }, FileBrowser.BrowseResult.SelectFile);
                fb.ShowDialog();

                // make sure that file browser finished properly
                if (fb.DialogResult == DialogResult.OK)
                {
                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "File Browser result: OK!!");
                    // store target file path
                    string fileTarget = fb.Target;

                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "File target = " + fileTarget);
                    // generate icon graphic
                    string IconPath = GenerateProfileIcon(fileTarget, UserName);

                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "New User " + UserName + " Icon Path : " + IconPath);
                    // create user info in INI file
                    UserINI.IniWriteValue(UserName, (UserName + "Image"), IconPath);
                }

                fb.Dispose();

                return(true);
            }
            else
            {
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Failed to locate USB Drive");
            }
            return(false);
        }
Exemple #2
0
        private void copyDeleteFiles(bool isCopy)
        {
            List <string> paths = getSelectedLogs();

            if (paths.Count > 0)
            {
                if (isCopy)
                {
                    List <string> lstUSBDrives = Utilities.GetUSBDrives();
                    if (lstUSBDrives != null && lstUSBDrives.Count > 0)
                    {
                        // determine usb directory
                        string USBpath = string.Empty;
                        try
                        {
                            for (int i = 0; i < lstUSBDrives.Count; i++)
                            {
                                if (Directory.Exists(lstUSBDrives[i]))
                                {
                                    USBpath = lstUSBDrives[i];
                                    break;
                                }
                            }
                            if (USBpath != string.Empty)
                            {
                                FileBrowser SelectFolder = new FileBrowser(RoboSep_UserConsole.getInstance(), "Please pick a destination folder", USBpath, "");
                                SelectFolder.ShowDialog();
                                if (SelectFolder.DialogResult == DialogResult.Yes)
                                {
                                    String destinationFolder = SelectFolder.Target;
                                    for (int i = 0; i < paths.Count; i++)
                                    {
                                        File.Copy(paths[i], destinationFolder + getLogFileName(paths[i]), true);
                                        File.Copy(getPathInSMIExt(paths[i]), destinationFolder + getPathInSMIExt(getLogFileName(paths[i])), true);
                                    }
                                }
                                SelectFolder.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            showGeneralErrorMessage(ex.Message);
                        }
                    }
                    else
                    {
                        showNoUSBErrorMessage();
                    }
                }
                else
                {
                    RoboMessagePanel dlg = new RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING,
                                                                "Are you sure to delete the selected logs?", "", LanguageINI.GetString("Yes"), LanguageINI.GetString("No"));
                    RoboSep_UserConsole.showOverlay();
                    dlg.ShowDialog();
                    RoboSep_UserConsole.hideOverlay();

                    if (dlg.DialogResult == DialogResult.OK)
                    {
                        for (int i = 0; i < paths.Count; i++)
                        {
                            File.Delete(paths[i]);
                            File.Delete(getPathInSMIExt(paths[i]));
                        }
                    }
                    dlg.Dispose();
                }
                refreshTableLayoutPanel();
            }
            else
            {
                showNoSelectionErrorMessage();
            }
        }
Exemple #3
0
        private void button_SaveReports_Click(object sender, EventArgs e)
        {
            string msg = "", title = "";

            GUI_Controls.RoboMessagePanel prompt = null;

            int[] arrItemsChecked = GetItemsChecked();
            if (arrItemsChecked == null || arrItemsChecked.Length == 0)
            {
                msg    = LanguageINI.GetString("msgSelectReports");
                title  = LanguageINI.GetString("headerSelectReports");
                prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING, msg, title, LanguageINI.GetString("Ok"));
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();
                prompt.Dispose();
                return;
            }

            List <string> lstUSBDrives = AskUserToInsertUSBDrive();

            if (lstUSBDrives == null || lstUSBDrives.Count == 0)
            {
                return;
            }

            string USBDrive = "";

            // search for directory
            foreach (string drive in lstUSBDrives)
            {
                if (Directory.Exists(drive))
                {
                    USBDrive = drive;
                    break;
                }
            }

            if (string.IsNullOrEmpty(USBDrive))
            {
                msg    = LanguageINI.GetString("msgUSBFail");
                prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, msg, LanguageINI.GetString("headerSaveUSB"), LanguageINI.GetString("Ok"));
                //RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();

                //GUI_Controls.uiLog.LOG(this, "button_SaveReports_Click", GUI_Controls.uiLog.LogLevel.WARNING, "USB drive not detected");
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "USB drive not detected");
                prompt.Dispose();
                return;
            }

            // see if save target directory exist
            string systemPath  = RoboSep_UserDB.getInstance().sysPath;
            string reportsPath = systemPath + "reports\\";

            if (!Directory.Exists(reportsPath))
            {
                Directory.CreateDirectory(reportsPath);
            }

            string      sTitle       = LanguageINI.GetString("headerSaveReportUSB");
            FileBrowser SelectFolder = new FileBrowser(RoboSep_UserConsole.getInstance(), sTitle, USBDrive, "");

            SelectFolder.ShowDialog();
            if (SelectFolder.DialogResult != DialogResult.Yes)
            {
                RoboSep_UserConsole.hideOverlay();
                SelectFolder.Dispose();
                return;
            }

            string Target = SelectFolder.Target;

            List <string> lstSourceFiles = new List <string>();

            // copy all selected folders to Target Directory
            FileInfo selectedReport;
            int      nIndex = 0;

            for (int i = 0; i < arrItemsChecked.Length; i++)
            {
                int ReportNumber = arrItemsChecked[i];

                // open file browser to allow user to select specific file location
                selectedReport = myReportFiles[ReportNumber];

                nIndex = selectedReport.Name.LastIndexOf('.');
                if (nIndex < 0)
                {
                    return;
                }

                string sFileName = selectedReport.Name.Substring(0, nIndex);
                sFileName += ".pdf";

                string sFullFileName = selectedReport.DirectoryName;
                if (sFullFileName.LastIndexOf('\\') != sFullFileName.Length - 1)
                {
                    sFullFileName += "\\";
                }

                sFullFileName += sFileName;
                if (File.Exists(sFullFileName))
                {
                    lstSourceFiles.Add(sFullFileName);
                }
            }

            // Copy files
            SelectFolder.ShowProgressBarWhileCopying = true;
            SelectFolder.CopyToTargetDirEx(lstSourceFiles.ToArray(), Target);
            SelectFolder.Dispose();
        }
        private bool LoadPicture(string[] drives)
        {
            if (drives == null)
            {
                return(false);
            }


            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Report SysPath: " + systemPath);
            //systemPath = @"C:\Program Files (x86)\STI\RoboSep\";

            string IconsPath = systemPath + "images\\";

            if (!Directory.Exists(IconsPath))
            {
                Directory.CreateDirectory(IconsPath);
            }

            string TempPath = systemPath + "temp\\";

            if (!Directory.Exists(TempPath))
            {
                Directory.CreateDirectory(TempPath);
            }

            // Check if there is any previous images
            if (tempUser.ImageIcon != null)
            {
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "User has already load an image");
                if (tempUser.TempImageIconPath != null)
                {
                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Temporary image file location: " + tempUser.TempImageIconPath);
                }

                // Sunny to do
                // set up message prompt
                string sMSG  = LanguageINI.GetString("lblPreviousImageLoaded");;
                string sMSG2 = LanguageINI.GetString("lblOverwritePreviousImage");
                sMSG += sMSG2;
                RoboMessagePanel prompt = new RoboMessagePanel(this, MessageIcon.MBICON_WARNING, sMSG,
                                                               LanguageINI.GetString("Warning"), LanguageINI.GetString("Yes"), LanguageINI.GetString("No"));
                RoboSep_UserConsole.showOverlay();

                //prompt user
                prompt.ShowDialog();
                RoboSep_UserConsole.hideOverlay();

                if (prompt.DialogResult != DialogResult.OK)
                {
                    prompt.Dispose();
                    return(false);
                }
                prompt.Dispose();
                try
                {
                    // Remove the temporary directory and its contents
                    Utilities.RemoveTempFileDirectory(tempUser.TempImageIconPath);
                }
                catch (Exception ex)
                {
                    // LOG
                    LogFile.LogException(System.Diagnostics.TraceLevel.Error, ex);
                }

                // Clear the previous image info
                tempUser.TempImageIconPath = "";
                tempUser.ImageIcon         = null;
            }

            // get the default image directory
            string sDefaultImgDirectory = String.Empty;
            string sTempImgDirectory    = GUIini.IniReadValue("General", "DefaultUserHDImageDirectory", DefaultUserHDImageDirectory);

            sTempImgDirectory = Utilities.RemoveIllegalCharsInDirectory(sTempImgDirectory);

            DriveInfo d = new DriveInfo(sTempImgDirectory);

            if (d.IsReady)
            {
                string        sName    = d.Name;
                List <string> lstDrive = new List <string>(drives);
                string        sDrive   = lstDrive.Find(x => { return(!string.IsNullOrEmpty(x) && x.ToLower() == sName.ToLower()); });
                if (!string.IsNullOrEmpty(sDrive))
                {
                    if (Directory.Exists(sTempImgDirectory))
                    {
                        sDefaultImgDirectory = sTempImgDirectory;
                    }
                }
            }

            if (string.IsNullOrEmpty(sDefaultImgDirectory))
            {
                // search for directory
                string[] dirs     = drives;
                int      dirIndex = -1;
                for (int i = 0; i < dirs.Length; i++)
                {
                    if (Directory.Exists(dirs[i]))
                    {
                        dirIndex             = i;
                        sDefaultImgDirectory = dirs[dirIndex];
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(sDefaultImgDirectory))
            {
                string      sTitle = LanguageINI.GetString("headerSelectImageFile");
                FileBrowser fb     = new FileBrowser(RoboSep_UserConsole.getInstance(), sTitle, sDefaultImgDirectory, IconsPath,
                                                     new string[] { ".jpg", ".jpeg", ".png", ".tga", ".bmp" }, FileBrowser.BrowseResult.SelectFile);
                fb.ShowDialog();
                // make sure that file browser finished properly
                if (fb.DialogResult == DialogResult.OK)
                {
                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "File Browser result: OK!!");
                    // store target file path
                    string fileTarget = fb.Target;

                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "File target = " + fileTarget);
                    // generate icon graphic
                    string IconPath = GenerateProfileIcon(fileTarget);

                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Temorary Icon Path : " + IconPath);
                }
                fb.Dispose();
                return(true);
            }
            else
            {
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, "Failed to locate drive");
            }
            return(false);
        }