public void LoadUsers()
        {
            // update users list
            // load auto complete source
            textBox_UserName.AutoCompleteCustomSource.Clear();
            string[] UserSource = RoboSep_UserDB.getInstance().getAllUsers();
            if (UserSource != null)
            {
                for (int i = 0; i < UserSource.Length; i++)
                {
                    if (UserSource[i] != "All Human" && UserSource[i] != "All Mouse" &&
                        UserSource[i] != "Whole Blood" && UserSource[i] != "Full List")
                    {
                        textBox_UserName.AutoCompleteCustomSource.Add(UserSource[i]);
                    }
                }
            }

            // LOG
            string LOGmsg = "Reloading Auto Complete for User Textbox";

            //GUI_Controls.uiLog.LOG(this, "LoadUsers", GUI_Controls.uiLog.LogLevel.INFO, LOGmsg);
            //  (LOGmsg);
            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, LOGmsg);
        }
        private void Form_UserLoginNew_Load(object sender, EventArgs e)
        {
            // add forms to form tracker
            Offset = new Point((RoboSep_UserConsole.getInstance().Size.Width - this.Size.Width) / 2,
                               (RoboSep_UserConsole.getInstance().Size.Height - this.Size.Height) / 2);

            this.Location = new Point(Offset.X + RoboSep_UserConsole.getInstance().Location.X,
                                      Offset.Y + RoboSep_UserConsole.getInstance().Location.Y);

            RoboSep_UserConsole.getInstance().addForm(this, Offset);

            bool bAddEvent = true;

            if (!bCreateNewUser && !string.IsNullOrEmpty(DefaultLoginID))
            {
                textBox_NewUserLoginID.Text = Utilities.GetUserName(DefaultLoginID, spaceChar, reservedChar);
                if (RoboSep_UserDB.getInstance().IsPresetUser(DefaultLoginID))
                {
                    textBox_NewUserLoginID.ReadOnly = true;
                    bAddEvent = false;
                }
            }

            if (bAddEvent)
            {
                evTextBoxClicked = new System.EventHandler(this.textBox_NewUserLoginID_Click);
                this.textBox_NewUserLoginID.Click += evTextBoxClicked;
            }
            label_User.Select();
        }
Beispiel #3
0
        private void hex_service_Click(object sender, EventArgs e)
        {
            // LOG
            string logMSG = "Service button clicked";

            //GUI_Controls.uiLog.LOG(this, "hex_service_Click", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG);

            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);

            RoboSep_UserConsole.getInstance().SuspendLayout();
            closeHomeWindow();

            // see if Service target directory exist
            string systemPath = RoboSep_UserDB.getInstance().sysPath;

            string[] directories = systemPath.Split('\\');

            //string servicePath = string.Empty;
            //for (int i = 0; i < directories.Length-2; i++)
            //    servicePath += directories[i] + "\\";
            //servicePath += "RoboSepService\\bin\\";

            StringBuilder sPath = new StringBuilder();

            for (int i = 0; i < directories.Length - 2; i++)
            {
                sPath.Append(directories[i]);
                sPath.Append("\\");
            }
            sPath.Append("RoboSepService\\bin\\");

            string servicePath = sPath.ToString();

            // check if service directory exists
            if (!System.IO.Directory.Exists(servicePath))
            {
                System.IO.Directory.CreateDirectory(servicePath);
            }

            // if Service.exe exists, run service.exe
            if (System.IO.File.Exists(servicePath + SERVICE_EXE_FILENAME))
            {
                // run Service
                ProcessStartInfo ServiceStartInfo = new ProcessStartInfo();
                ServiceStartInfo.WorkingDirectory = servicePath;
                ServiceStartInfo.FileName         = SERVICE_EXE_FILENAME;
                ServiceStartInfo.WindowStyle      = ProcessWindowStyle.Normal;

                Process ServiceProgram = new Process();
                ServiceProgram.StartInfo = ServiceStartInfo;
                ServiceProgram.Start();

                LogFile.AddMessage(TraceLevel.Warning, "Starting Service program");
            }
            else
            {
                logMSG = "Could not locate Service Program at '" + servicePath + SERVICE_EXE_FILENAME + "'";
                LogFile.AddMessage(TraceLevel.Warning, logMSG);
            }
        }
Beispiel #4
0
        private FileInfo[] getReportFiles2()
        {
            FileInfo[] theReportFiles = null;
            string     sysPath        = RoboSep_UserDB.getInstance().sysPath;
            string     reportsPath    = sysPath + "Reports\\";

            DirectoryInfo DI = new DirectoryInfo(reportsPath);

            theReportFiles = DI.GetFiles("*.xml", SearchOption.AllDirectories);

            Array.Sort(theReportFiles, delegate(FileInfo f1, FileInfo f2)
            {
                return(f1.LastWriteTime.CompareTo(f2.LastWriteTime));
            });

            int DisplayedLogsCount = MAX_RUNS_DISPLAYED;

            if (theReportFiles.Length < MAX_RUNS_DISPLAYED)
            {
                DisplayedLogsCount = theReportFiles.Length;
            }

            FileInfo[] returnreports = new FileInfo[DisplayedLogsCount];
            for (int i = 0; i < DisplayedLogsCount; i++)
            {
                returnreports[i] = theReportFiles[(theReportFiles.Length - 1) - i];
            }
            return(returnreports);
        }
        public void LoadUserToServer(string ActiveUser)
        {
            // LOG
            string logMSG = "Loading user profile";

            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            // load user from ini
            List <RoboSep_Protocol> tempList = RoboSep_UserDB.getInstance().loadUserProtocols(ActiveUser);

            if (tempList == null)
            {
                // prompt user that no protocols to load
                string           sTitle  = LanguageINI.GetString("headerNoProtocols");
                string           sMsg    = LanguageINI.GetString("msgNoProtocols");
                string           sButton = LanguageINI.GetString("Ok");
                RoboMessagePanel prompt  = new RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING, sMsg, sTitle, sButton);
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                prompt.Dispose();
                RoboSep_UserConsole.hideOverlay();
                return;
            }

            StartLoadingProtocolsToServer(ActiveUser, tempList);
        }
Beispiel #6
0
 public void RefreshDisplayName()
 {
     if (Name != null)
     {
         bool DisplayProtocolsAbbv = RoboSep_UserDB.getInstance().UseAbbreviationsForProtocolNames;
         Name.Text = DisplayProtocolsAbbv ? ((!string.IsNullOrEmpty(QuadrantLabel_Abbv)) ? QuadrantLabel_Abbv : QuadrantLabel) : QuadrantLabel;
     }
 }
 public void saveUserList()
 {
     // create array of protocols
     string[] protocolList = new string[myUserProtocols.Count];
     for (int i = 0; i < myUserProtocols.Count; i++)
     {
         protocolList[i] = myUserProtocols[i].Protocol_FileName;
     }
     RoboSep_UserDB.getInstance().saveUserProtocols(/*RoboSep_UserConsole.strCurrentUser*/ strUserName, protocolList);
 }
        public void StartLoadingProtocolsToServer(string ActiveUser, List <RoboSep_Protocol> tempList)
        {
            if (tempList == null)
            {
                return;
            }

            // LOG
            string logMSG = "Start thread for loading profile";

            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            try
            {
                RoboSep_UserConsole.strCurrentUser = ActiveUser;// textBox_UserName.Text;
                UserNameHeader.Text = ActiveUser;

                string[] sProtocols = new string[tempList.Count];
                for (int i = 0; i < tempList.Count; i++)
                {
                    sProtocols[i] = tempList[i].Protocol_FileName;
                }

                // save over user1.udb
                RoboSep_UserDB.getInstance().XML_SaveUserProfile(ActiveUser, sProtocols);
                protocolsToLoad = sProtocols.Length;

                // Reload protocols with SeparatorGateway using a thread
                myReloadProtocolsThread = new Thread(new ThreadStart(this.ReloadProtocolsThread));
                myReloadProtocolsThread.IsBackground = true;
                myReloadProtocolsThread.Start();

                // set sep-gateway to updating Separator Protocols
                // so that we can watch for when it is updated
                // (in timer_tick)
                SeparatorGateway.GetInstance().separatorUpdating = true;

                string sMSG   = LanguageINI.GetString("msgLoadingProtocols");
                string sTitle = LanguageINI.GetString("headerLoadingUserProtocols");
                loading = new RoboMessagePanel5(RoboSep_UserConsole.getInstance(), sTitle, sMSG, GUI_Controls.GifAnimationMode.eUploadingMultipleFiles);
                RoboSep_UserConsole.showOverlay();
                loading.Show();
                //Thread.Sleep(SERVER_WAIT_TIME);
                // add loop to that polls loading status
                LoadUserTimer.Start();
            }
            catch (Exception ex)
            {
                // LOG
                logMSG = "Failed to save user to server";

                LogFile.AddMessage(System.Diagnostics.TraceLevel.Error, logMSG);
            }
        }
Beispiel #9
0
        public RoboSep_ScanSelection()
        {
            InitializeComponent();

            IList.Add(GUI_Controls.Properties.Resources.BUTTON_HOMECANCEL0);
            IList.Add(GUI_Controls.Properties.Resources.BUTTON_HOMECANCEL0);
            IList.Add(GUI_Controls.Properties.Resources.BUTTON_HOMECANCEL0);
            IList.Add(GUI_Controls.Properties.Resources.BUTTON_HOMECANCEL1);
            button_Cancel.ChangeGraphics(IList);

            userList   = RoboSep_UserDB.getInstance().loadUserProtocols(RoboSep_UserConsole.strCurrentUser);
            allList    = RoboSep_UserDB.getInstance().getAllProtocols();
            filterList = new List <RoboSep_Protocol>();
        }
        public bool RenameUserNameInUserInfoINI(string sOldUserLoginID, string sNewUserLoginID)
        {
            if (string.IsNullOrEmpty(sOldUserLoginID) || string.IsNullOrEmpty(sNewUserLoginID))
            {
                return(false);
            }

            string fullPathUserFileName = RoboSep_UserDB.getInstance().sysPath;

            fullPathUserFileName += "protocols\\";
            fullPathUserFileName += UserInfoFileName;

            if (!File.Exists(fullPathUserFileName))
            {
                return(false);
            }

            // read values
            string[]      lines = File.ReadAllLines(fullPathUserFileName, System.Text.Encoding.UTF8);
            List <string> lst   = new List <string>();

            lst.AddRange(lines);

            int    index;
            string temp;
            // rename section
            string sSection = String.Format("[{0}]", sOldUserLoginID);

            index = lst.FindIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length == sSection.Length && x.ToLower() == (sSection.ToLower())); });
            if (0 <= index)
            {
                temp       = String.Format("[{0}]", sNewUserLoginID);
                lst[index] = lst[index].Replace(sSection, temp);
            }

            // rename image path
            string sImageDefaultPath = String.Format("{0}Image", sOldUserLoginID);

            index = lst.FindLastIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= sImageDefaultPath.Length && x.ToLower().Contains(sImageDefaultPath.ToLower()) && x.Trim().Substring(0, sImageDefaultPath.Length) == sImageDefaultPath); });
            if (0 <= index)
            {
                temp       = String.Format("{0}Image", sNewUserLoginID);
                lst[index] = lst[index].Replace(sImageDefaultPath, temp);
            }

            File.WriteAllLines(fullPathUserFileName, lst.ToArray());
            return(true);
        }
Beispiel #11
0
        public void setProtocol(ISeparationProtocol protocol)
        {
            // Sunny to do
            QuadrantLabel          = protocol.Label;
            QuadrantLabel_Abbv     = RoboSep_UserDB.getInstance().getProtocolAbbvNameFromList(protocol.Label);
            Quadrant_message       = protocol.Description;
            QuadrantVolume         = Convert.ToDouble(Vol.Text);
            volMax                 = protocol.MaximumSampleVolume / 1000;
            volMin                 = protocol.MinimumSampleVolume / 1000;
            bQuadrantInUse         = true;
            SelectProtocol.Visible = false;
            QuadrantsRequired      = protocol.QuadrantCount;


            Update();
        }
Beispiel #12
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            string logMSG = "Saving user preferences for '" + userName + "'";

            //  (logMSG);
            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            getPreferences(dictUserPreferencesFromConfig, dictUserPreferences);
            getPreferences(dictDevicePreferencesFromConfig, dictDevicePreferences);

            if (bIsNewUser == true)
            {
                if (GetUserPreferences != null)
                {
                    GetUserPreferences(this, new EventArgs());
                }
            }
            else
            {
                string            title  = LanguageINI.GetString("headerSavingInProgress");
                RoboMessagePanel4 prompt = new GUI_Controls.RoboMessagePanel4(RoboSep_UserConsole.getInstance(), title, 500, 20);
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();

                RoboSep_UserConsole.hideOverlay();

                // update the user preferences file for old user
                UserDetails.SaveUserPreferences(userName, dictUserPreferences, dictDevicePreferences);

                // reload the user preferences to refresh the changes
                RoboSep_UserDB.getInstance().loadCurrentUserPreferences(userName);

                prompt.Dispose();
            }

            this.SendToBack();

            if (ClosingUserPreferencesApp != null)
            {
                ClosingUserPreferencesApp(this, new EventArgs());
            }

            this.Hide();
        }
        public RoboSep_Protocols()
        {
            InitializeComponent();

            // LOG
            string logMSG = "Initializing Protocols user control";

            //GUI_Controls.uiLog.LOG(this, "RoboSep_Protocols", GUI_Controls.uiLog.LogLevel.EVENTS, logMSG);

            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);

            // get user names
            allUsers = RoboSep_UserDB.getInstance().getAllUsers();

            // change button graphics.
            // LOAD USER BUTTON

            ilist1.Add(GUI_Controls.Properties.Resources.btnLG_STD);
            ilist1.Add(GUI_Controls.Properties.Resources.btnLG_STD);
            ilist1.Add(GUI_Controls.Properties.Resources.btnLG_STD);
            ilist1.Add(GUI_Controls.Properties.Resources.btnLG_HIGHLIGHT);
            button_LoadUser.ChangeGraphics(ilist1);
            // EDIT LIST BUTTON

            ilist2.Add(GUI_Controls.Properties.Resources.btnLG_STD);
            ilist2.Add(GUI_Controls.Properties.Resources.btnLG_STD);
            ilist2.Add(GUI_Controls.Properties.Resources.btnLG_STD);
            ilist2.Add(GUI_Controls.Properties.Resources.btnLG_CLICK);
            button_EditList.ChangeGraphics(ilist2);

            // set label and button text based on language settings
            //roboPanel2.Title = LanguageINI.GetString("lblUserList");
            lblUser.Text           = LanguageINI.GetString("lblUsr");
            button_EditList.Text   = LanguageINI.GetString("lblEditList");
            lblProtocolEdit.Text   = LanguageINI.GetString("lblProtocolEditor");
            button_AllHuman.Text   = LanguageINI.GetString("lblHuman");
            button_AllMouse.Text   = LanguageINI.GetString("lblMouse");
            button_WholeBlood.Text = LanguageINI.GetString("lblWB");
            button_FullList.Text   = LanguageINI.GetString("lblFull");
            button_LoadUser.Text   = LanguageINI.GetString("lblLoadUser");
        }
        private void button_AddUser_Click(object sender, EventArgs e)
        {
            // get all users to see if new user name has been entered
            string[] UserNames = RoboSep_UserDB.getInstance().getAllUsers();
            // Create keyboard to allow user to enter user name
            generateKeyboard();
            // check if name entered is new user
            bool isNewUser = true;

            for (int userNum = 0; userNum < UserNames.Length; userNum++)
            {
                if (textBox_UserName.Text == UserNames[userNum])
                {
                    isNewUser = false;
                }
            }
            if (isNewUser)
            {
                button_EditList_Click(sender, e);
            }
        }
        private void listview_lvUser_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            ListViewItem lvItem    = e.Item;
            string       sUserName = lvItem.Tag as string;

            if (string.IsNullOrEmpty(sUserName))
            {
                sUserName = lvItem.Text;
            }

            Rectangle  rc = e.Bounds;
            SolidBrush theBrush;

            if (e.Item.Selected)
            {
                theBrush = new SolidBrush(BG_Selected);
                e.Graphics.FillRectangle(theBrush, rc);
                theBrush.Dispose();
            }
            else if (RoboSep_UserDB.getInstance().IsPresetUser(sUserName))
            {
                theBrush = new SolidBrush(BG_Preset);
                e.Graphics.FillRectangle(theBrush, rc);
                theBrush.Dispose();
            }
            else if (e.ItemIndex % 2 == 0)
            {
                theBrush = new SolidBrush(BG_ColorEven);
                e.Graphics.FillRectangle(theBrush, rc);
                theBrush.Dispose();
            }
            else
            {
                theBrush = new SolidBrush(BG_ColorOdd);
                e.Graphics.FillRectangle(theBrush, rc);
                theBrush.Dispose();
            }
        }
        private void DeleteUser(string selectedUser)
        {
            if (string.IsNullOrEmpty(selectedUser))
            {
                return;
            }

            // Remove user preference file for this user
            RoboSep_UserDB.getInstance().deleteUserPreferences(selectedUser);

            // Delete all MRU protocols
            ProtocolMRUList MRUList = new ProtocolMRUList();

            if (MRUList != null)
            {
                MRUList.DeleteAllMostRecentlyUsedProtocols(selectedUser);
            }

            // Delete the image file associated with this user
            UserDetails.deleteUserImageFile(selectedUser);

            // Remove all the protocols associated with this user
            UserDetails.removeSection("USER", selectedUser);
        }
        private void Button_ProtocolEdit_Click(object sender, EventArgs e)
        {
            // LAUNCH PROTOCOL EDITOR
            // see if Service target directory exist
            string systemPath = RoboSep_UserDB.getInstance().sysPath;

            string[] directories = systemPath.Split('\\');

            string EditorPath = string.Empty;

            for (int i = 0; i < (directories.Length - 2); i++)
            {
                EditorPath += directories[i] + "\\";
            }
            EditorPath += "RoboSepEditor\\bin\\";

            // check if service directory exists
            if (!System.IO.Directory.Exists(EditorPath))
            {
                System.IO.Directory.CreateDirectory(EditorPath);
            }

            // if Service.exe exists, run service.exe
            if (System.IO.File.Exists(EditorPath + "ProtocolEditor.exe"))
            {
                // run Service
                System.Diagnostics.ProcessStartInfo EditorStartInfo = new System.Diagnostics.ProcessStartInfo();
                EditorStartInfo.WorkingDirectory = EditorPath;
                EditorStartInfo.FileName         = "ProtocolEditor.exe";
                EditorStartInfo.WindowStyle      = System.Diagnostics.ProcessWindowStyle.Normal;

                System.Diagnostics.Process ProtocolEditorProgram = new System.Diagnostics.Process();
                ProtocolEditorProgram.StartInfo = EditorStartInfo;
                ProtocolEditorProgram.Start();
            }
        }
Beispiel #18
0
 public void Update()
 {
     if (Name != null)
     {
         bool DisplayProtocolsAbbv = RoboSep_UserDB.getInstance().UseAbbreviationsForProtocolNames;
         Name.Text = DisplayProtocolsAbbv ? ((!string.IsNullOrEmpty(QuadrantLabel_Abbv)) ? QuadrantLabel_Abbv : QuadrantLabel) : QuadrantLabel;
     }
     if (Vol != null)
     {
         if (QuadrantVolume == 0)
         {
             Vol.Text = "";
         }
         else
         {
             Vol.Text = string.Format("{0:0.00}", QuadrantVolume) + " mL";
         }
     }
     //      Cancel.Visible = bIsMaintenance || !(bQuadrantInUse && QuadrantVolume == 0) ? bQuadrantInUse: false;
     if (Icon != null)
     {
         Icon.Check = !bQuadrantInUse;
     }
 }
        private void button_DeleteUser_Click(object sender, EventArgs e)
        {
            // Get list of user names
            List <string> UserNames = new List <string>();

            for (int i = 0; i < Users.Count; i++)
            {
                if (Users[i].Username != RoboSep_UserConsole.strCurrentUser && !RoboSep_UserDB.getInstance().IsPresetUser(Users[i].Username))
                {
                    UserNames.Add(Users[i].Username);
                }
            }

            // Show Overlay window
            RoboSep_UserConsole.showOverlay();
            RoboSep_UserConsole.getInstance().frmOverlay.BringToFront();

            // create new user select control form
            IniFile LanguageINI = GUI_Console.RoboSep_UserConsole.getInstance().LanguageINI;
            string  windowTitle = LanguageINI.GetString("lblSelectUserToDelete");

            Form_UserSelect UserSelectMenu = new Form_UserSelect(UserNames, windowTitle);

            UserSelectMenu.ShowDialog();

            RoboSep_UserConsole.hideOverlay();
            if (UserSelectMenu.DialogResult != DialogResult.OK)
            {
                UserSelectMenu.Dispose();
                ResumeLayout();
                return;
            }

            // check to see if user name was selected
            string selectedUser = UserSelectMenu.User;

            UserSelectMenu.Dispose();
            if (selectedUser == null && selectedUser == string.Empty)
            {
                return;
            }

            // Show Overlay window
            RoboSep_UserConsole.showOverlay();

            DeleteUser(selectedUser);

            // update the list
            UpdateUserProfiles();

            lvUser.UpdateScrollbar();

            RoboSep_UserConsole.hideOverlay();

            ResumeLayout();

            // LOG
            string logMSG = "Opening user screen to select user to be deleted.";

            //  (logMSG);
            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
        }
        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);
        }
        private void SelectUser(string UserLogin)
        {
            if (string.IsNullOrEmpty(UserLogin))
            {
                return;
            }

            string usrName = UserLogin;

            RoboSep_UserConsole.strCurrentUser = usrName;

#if false
            // load user preferences
            RoboSep_UserDB.getInstance().loadCurrentUserPreferences(usrName);

            // load user protocols
            List <RoboSep_Protocol> tempList = RoboSep_UserDB.getInstance().loadUserProtocols(usrName);

            // it could be new user with no protocols
            if (tempList != null && tempList.Count > 0)
            {
                // load user protocols
                RoboSep_Protocols.getInstance().LoadUserToServer(usrName);
                RoboSep_Protocols.getInstance().setProtocolLoading(true);
                SeparatorGateway.GetInstance().separatorUpdating = true;

                if (evhHandleUserProtocolsReloaded == null)
                {
                    evhHandleUserProtocolsReloaded = new EventHandler(HandleUserProtocolsReloadedBeforeExiting);
                }

                RoboSep_UserConsole.getInstance().NotifyUserSeparationProtocolsUpdated += evhHandleUserProtocolsReloaded;
                return;
            }
#else
            // load user protocols
            List <RoboSep_Protocol> tempList = RoboSep_UserDB.getInstance().loadUserProtocols(usrName);

            // it could be new user with no protocols
            if (tempList != null && tempList.Count > 0)
            {
                // load user protocols
                RoboSep_Protocols.getInstance().LoadUserToServer(usrName);
                RoboSep_Protocols.getInstance().setProtocolLoading(true);
                SeparatorGateway.GetInstance().separatorUpdating = true;

                // load user preferences
                RoboSep_UserDB.getInstance().loadCurrentUserPreferences(usrName);

                if (evhHandleUserProtocolsReloaded == null)
                {
                    evhHandleUserProtocolsReloaded = new EventHandler(HandleUserProtocolsReloadedBeforeExiting);
                }

                RoboSep_UserConsole.getInstance().NotifyUserSeparationProtocolsUpdated += evhHandleUserProtocolsReloaded;
                return;
            }
            else
            {
                // load user preferences
                RoboSep_UserDB.getInstance().loadCurrentUserPreferences(usrName);
            }
#endif
            // open run samples window
            RoboSep_UserConsole myUC = RoboSep_UserConsole.getInstance();
            RoboSep_UserConsole.ctrlCurrentUserControl = RoboSep_RunSamples.getInstance();
            RoboSep_RunSamples.getInstance().UserName = usrName;
            RoboSep_RunSamples.getInstance().Enabled  = false;
            myUC.SuspendLayout();
            myUC.Controls.Remove(this);
            myUC.Controls.Add(RoboSep_RunSamples.getInstance());
            myUC.ResumeLayout();
            if (RoboSep_RunSamples.getInstance().IsInitialized)
            {
                RoboSep_RunSamples.getInstance().ReInitialize();
            }
            RoboSep_RunSamples.getInstance().Enabled = true;
        }
Beispiel #22
0
        public static bool RenameProtocolsAndMRUs(string inOldUserName, string inNewUserName)
        {
            if (string.IsNullOrEmpty(inOldUserName) || string.IsNullOrEmpty(inNewUserName))
            {
                return(false);
            }
            string fullPathUserFileName = RoboSep_UserDB.getInstance().sysPath;

            fullPathUserFileName += "protocols\\";
            fullPathUserFileName += UserInfoFileName;

            if (!File.Exists(fullPathUserFileName))
            {
                return(false);
            }

            // read values
            string[]      lines = File.ReadAllLines(fullPathUserFileName, System.Text.Encoding.UTF8);
            List <string> lst   = new List <string>();

            lst.AddRange(lines);

            string OldUserName = inOldUserName.Trim();
            string NewUserName = inNewUserName.Trim();

            string tempPrefixProtocol = OldUserName + PrefixProtocol;                 // Protocol
            string tempPrefixLabel = OldUserName + PrefixProtocolLabel;               // "MruProtocolLabelQ"
            string tempPrefixSampleVolume = OldUserName + PrefixSampleVolumeUl;       // "MruSampleVolumeUlQ"
            string tempPrefixUsageTime = OldUserName + PrefixUsageTime;               // "MruUsageTimeQ"
            string temp1, temp2;
            int    index = 0;

            // rename Protocols
            do
            {
                index = lst.FindIndex(index, x => { return(!string.IsNullOrEmpty(x) && x.Length >= tempPrefixProtocol.Length && x.ToLower().Contains(tempPrefixProtocol.ToLower())); });
                if (0 <= index)
                {
                    temp1 = NewUserName + PrefixProtocol;

                    lst[index] = lst[index].Replace(tempPrefixProtocol, temp1);
                    index++;
                }
            } while (0 <= index);

            //rename MRUs for all quadrant
            for (int i = MinQuadrantNumber; i <= MaxQuadrantNumber; i++)
            {
                // label
                index = 0;
                temp1 = tempPrefixLabel + i.ToString();
                index = lst.FindIndex(0, x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp1.Length && x.ToLower().Contains(temp1.ToLower())); });
                if (0 <= index)
                {
                    temp2      = NewUserName + PrefixProtocolLabel + i.ToString();
                    lst[index] = lst[index].Replace(temp1, temp2);
                }

                // sample volume
                temp1 = tempPrefixSampleVolume + i.ToString();
                index = lst.FindIndex(0, x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp1.Length && x.ToLower().Contains(temp1.ToLower())); });
                if (0 <= index)
                {
                    temp2      = NewUserName + PrefixSampleVolumeUl + i.ToString();
                    lst[index] = lst[index].Replace(temp1, temp2);
                }

                // time
                temp1 = tempPrefixUsageTime + i.ToString();
                index = lst.FindIndex(0, x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp1.Length && x.ToLower().Contains(temp1.ToLower())); });
                if (0 <= index)
                {
                    temp2      = NewUserName + PrefixUsageTime + i.ToString();
                    lst[index] = lst[index].Replace(temp1, temp2);
                }
            }

            // write text to file
            File.WriteAllLines(fullPathUserFileName, lst.ToArray());
            return(true);
        }
        private bool ValidateName(string iLoginID)
        {
            if (string.IsNullOrEmpty(iLoginID))
            {
                return(false);
            }

            string newLoginID = iLoginID.Trim();

            char[] invalidCharacters = new char[] { '~', '[', ']', '{', '}', '<', '>', '&', '/', '\\', '\'', '=', '~' };
            int    nIndex            = -1;

            // Check for duplicate
            if (slistUserNames.Contains(newLoginID))
            {
                // prompt user
                string sMsg    = LanguageINI.GetString("msgUserOccupied");
                string sHeader = LanguageINI.GetString("headerUserInvalid");
                string sButton = LanguageINI.GetString("Ok");
                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, sMsg, sHeader, sButton);
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                prompt.Dispose();
                RoboSep_UserConsole.hideOverlay();
                return(false);
            }
            else if ((nIndex = newLoginID.IndexOfAny(invalidCharacters)) >= 0)
            {
                string sInvalidCharacter = newLoginID.Substring(nIndex, 1);

                // prompt user
                string sTemp   = LanguageINI.GetString("msgUserInvalidCharacters");
                string sMsg    = String.Format(sTemp, sInvalidCharacter);
                string sHeader = LanguageINI.GetString("headerUserInvalid");
                string sButton = LanguageINI.GetString("Ok");
                GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, sMsg, sHeader, sButton);
                RoboSep_UserConsole.showOverlay();
                prompt.ShowDialog();
                prompt.Dispose();
                RoboSep_UserConsole.hideOverlay();
                return(false);
            }
            else
            {
                string[] aPresetNames = RoboSep_UserDB.getInstance().GetProtocolPresetNames();
                if (aPresetNames != null && aPresetNames.Length > 0)
                {
                    string sName = Array.Find(aPresetNames, (x => { return(!string.IsNullOrEmpty(x) && x.ToLower() == newLoginID.ToLower()); }));
                    if (!string.IsNullOrEmpty(sName))
                    {
                        // prompt user
                        string sMsg    = LanguageINI.GetString("msgNameUsedByPresets");
                        string sHeader = LanguageINI.GetString("headerUserInvalid");
                        string sButton = LanguageINI.GetString("Ok");
                        GUI_Controls.RoboMessagePanel prompt = new GUI_Controls.RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_ERROR, sMsg, sHeader, sButton);
                        RoboSep_UserConsole.showOverlay();;
                        prompt.ShowDialog();
                        prompt.Dispose();
                        RoboSep_UserConsole.hideOverlay();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #24
0
        public bool UpdateUserProtocolsMRU(string inUser, ProtocolMostRecentlyUsed[] arrProtocols)
        {
            if (string.IsNullOrEmpty(inUser) || arrProtocols == null || arrProtocols.Length == 0)
            {
                return(false);
            }
            string fullPathUserFileName = RoboSep_UserDB.getInstance().sysPath;

            fullPathUserFileName += "protocols\\";
            fullPathUserFileName += UserInfoFileName;

            if (!File.Exists(fullPathUserFileName))
            {
                return(false);
            }

            // read values
            string[]      lines = File.ReadAllLines(fullPathUserFileName, System.Text.Encoding.UTF8);
            List <string> lst   = new List <string>();

            lst.AddRange(lines);

            string User = inUser.Trim();
            string tempPrefixProtocol = User + PrefixProtocol;
            string tempPrefixLabel = User + PrefixProtocolLabel;
            string tempPrefixSampleVolume = User + PrefixSampleVolumeUl;
            string tempPrefixUsageTime = User + PrefixUsageTime;
            string temp1, temp2, temp3, temp4;
            int    index0 = 0, index1 = 0, index2 = 0, index3 = 0, index4 = 0, index5 = -1;

            string[] parts;
            string[] newParts     = new string[2];
            bool     bItemUpdated = false;
            bool     bDelete = false;

            for (int i = 0; i < arrProtocols.Length; i++)
            {
                if (arrProtocols[i].QuadrantNumber <MinQuadrantNumber || arrProtocols[i].QuadrantNumber> MaxQuadrantNumber)
                {
                    continue;
                }

                index0 = arrProtocols[i].QuadrantNumber;
                temp1  = tempPrefixLabel + index0.ToString();

                // protocol name
                index1 = lst.FindIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp1.Length && x.ToLower().Contains(temp1.ToLower())); });
                index4 = lst.FindLastIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= tempPrefixProtocol.Length && x.ToLower().Contains(tempPrefixProtocol.ToLower()) && x.Trim().Substring(0, tempPrefixProtocol.Length) == tempPrefixProtocol); });

                newParts[0] = temp1;
                newParts[1] = arrProtocols[i].ProtocolLabel;
                temp4       = "";
                if (!string.IsNullOrEmpty(newParts[1].Trim()))
                {
                    temp4   = string.Join(" = ", newParts);
                    bDelete = false;
                }
                else
                {
                    bDelete = true;
                }

                bItemUpdated = false;

                if (0 <= index1)
                {
                    if (bDelete == true)
                    {
                        lst.RemoveAt(index1);
                        bItemUpdated = true;
                    }
                    else
                    {
                        parts = lst[index1].Split('=');
                        if (0 < parts.Length && parts[0].Trim() == temp1)
                        {
                            // replace
                            lst[index1]  = temp4;
                            bItemUpdated = true;
                        }
                    }
                }
                if (!bItemUpdated && bDelete == false)
                {
                    // add new
                    index5 = 0 <= index1 ? index1 : 0 <= index5 ? index5 : index4;
                    if (0 <= index5)
                    {
                        lst.Insert(++index5, temp4);
                        index1 = index5;
                    }
                    else
                    {
                        lst.Add(temp4);
                    }
                }

                // sample volume
                temp2  = tempPrefixSampleVolume + index0.ToString();
                index2 = lst.FindIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp2.Length && x.ToLower().Contains(temp2.ToLower())); });
                index4 = lst.FindLastIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= tempPrefixProtocol.Length && x.ToLower().Contains(tempPrefixProtocol.ToLower()) && x.Trim().Substring(0, tempPrefixProtocol.Length) == tempPrefixProtocol); });

                bItemUpdated = false;
                newParts[0]  = temp2;
                if (bDelete == false)
                {
                    if (arrProtocols[i].SampleVolumeUl < 0)
                    {
                        newParts[1] = "";
                    }
                    else
                    {
                        newParts[1] = arrProtocols[i].SampleVolumeUl.ToString();
                    }

                    temp4 = string.Join(" = ", newParts);
                }
                if (0 <= index2)
                {
                    if (bDelete == true)
                    {
                        lst.RemoveAt(index2);
                        bItemUpdated = true;
                    }
                    else
                    {
                        parts = lst[index2].Split('=');
                        if (0 < parts.Length && parts[0].Trim() == temp2)
                        {
                            // replace
                            lst[index2]  = temp4;
                            bItemUpdated = true;
                        }
                    }
                }

                if (!bItemUpdated && bDelete == false)
                {
                    // add new
                    index5 = 0 <= index2 ? index2 : 0 <= index1 ? index1 : index4;
                    if (0 <= index5)
                    {
                        lst.Insert(++index5, temp4);
                        index2 = index5;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(arrProtocols[i].ProtocolLabel))
                        {
                            lst.Add(temp4);
                        }
                    }
                }

                // date time
                temp3  = tempPrefixUsageTime + index0.ToString();
                index3 = lst.FindIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp3.Length && x.ToLower().Contains(temp3.ToLower())); });
                index4 = lst.FindLastIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= tempPrefixProtocol.Length && x.ToLower().Contains(tempPrefixProtocol.ToLower()) && x.Trim().Substring(0, tempPrefixProtocol.Length) == tempPrefixProtocol); });

                bItemUpdated = false;
                newParts[0]  = temp3;

                temp4 = "";
                if (bDelete == false)
                {
                    newParts[1] = arrProtocols[i].usageTime.ToLongDateString();
                    temp4       = string.Join(" = ", newParts);
                }

                if (0 <= index3)
                {
                    if (bDelete == true)
                    {
                        lst.RemoveAt(index3);
                        bItemUpdated = true;
                    }
                    else
                    {
                        parts = lst[index3].Split('=');
                        if (0 < parts.Length && parts[0].Trim() == temp3)
                        {
                            // replace
                            lst[index3]  = temp4;
                            bItemUpdated = true;
                            index5       = index3;
                        }
                    }
                }

                if (!bItemUpdated && bDelete == false)
                {
                    // add new
                    index5 = 0 <= index3 ? index3 : 0 <= index2 ? index2 : index4;
                    if (0 <= index5)
                    {
                        lst.Insert(++index5, temp4);
                    }
                }
            }

            // write text to file
            File.WriteAllLines(fullPathUserFileName, lst.ToArray());

            return(true);
        }
Beispiel #25
0
        public bool DeleteAllMostRecentlyUsedProtocols(string inUser)
        {
            if (string.IsNullOrEmpty(inUser))
            {
                return(false);
            }
            string fullPathUserFileName = RoboSep_UserDB.getInstance().sysPath;

            fullPathUserFileName += "protocols\\";
            fullPathUserFileName += UserInfoFileName;

            if (!File.Exists(fullPathUserFileName))
            {
                return(false);
            }

            // read values
            string[]      lines = File.ReadAllLines(fullPathUserFileName, System.Text.Encoding.UTF8);
            List <string> lst   = new List <string>();

            lst.AddRange(lines);

            string User = inUser.Trim();

            string tempPrefixLabel = User + PrefixProtocolLabel;               // "MruProtocolLabelQ"
            string tempPrefixSampleVolume = User + PrefixSampleVolumeUl;       // "MruSampleVolumeUlQ"
            string tempPrefixUsageTime = User + PrefixUsageTime;               // "MruUsageTimeQ"
            string temp1, temp2, temp3;
            int    index = 0;

            string[] parts;
            for (int i = MinQuadrantNumber; i <= MaxQuadrantNumber; i++)
            {
                // protocol name
                temp1 = tempPrefixLabel + i.ToString();
                index = lst.FindIndex(0, x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp1.Length && x.ToLower().Contains(temp1.ToLower())); });
                while (0 <= index)
                {
                    if (0 <= index)
                    {
                        parts = lst[index].Split('=');
                        if (0 < parts.Length && parts[0].Trim().Substring(0, 2) != @"//" && parts[0].Trim() == temp1)
                        {
                            lst.RemoveAt(index--);

                            // sample volume
                            temp2 = tempPrefixSampleVolume + i.ToString();
                            RemoveEntry(temp2, ref lst, ref index);

                            // usage time
                            temp3 = tempPrefixUsageTime + i.ToString();
                            RemoveEntry(temp3, ref lst, ref index);
                        }
                    }
                    index++;
                    index = lst.FindIndex(index, x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp1.Length && x.ToLower().Contains(temp1.ToLower())); });
                }
            }

            // write text to file
            File.WriteAllLines(fullPathUserFileName, lst.ToArray());
            return(true);
        }
Beispiel #26
0
        public bool LoadUserPreferences(string userName)
        {
            if (string.IsNullOrEmpty(userName) && !bIsNewUser)
            {
                return(false);
            }

            string logMSG = "";

            logMSG = ":Load " + userName + "preferences";

            dictMasterUserPreferences.Clear();
            dictMasterDevicePreferences.Clear();

            if (bIsNewUser)
            {
                RoboSep_UserDB.getInstance().getDefaultUserAndDevicePreferences(dictMasterUserPreferences, dictMasterDevicePreferences);
            }
            else
            {
                Dictionary <string, bool> dictUserDefault   = new Dictionary <string, bool>();
                Dictionary <string, bool> dictDeviceDefault = new Dictionary <string, bool>();
                RoboSep_UserDB.getInstance().getDefaultUserAndDevicePreferences(dictUserDefault, dictDeviceDefault);
                RoboSep_UserDB.getInstance().getUserAndDevicePreferences(userName, dictMasterUserPreferences, dictMasterDevicePreferences);

                bool bUserDirty   = UpdateDefaultPreferences(dictUserDefault, dictMasterUserPreferences);
                bool bDeviceDirty = UpdateDefaultPreferences(dictDeviceDefault, dictMasterDevicePreferences);

                if (bUserDirty || bDeviceDirty)
                {
                    // Update the user preferences file
                    UserDetails.SaveUserPreferences(userName, dictMasterUserPreferences, dictMasterDevicePreferences);
                }
            }

            if (dictMasterUserPreferences.Count > 0)
            {
                //enumerate the keys
                string dispName, helpString;
                dictUserPreferencesFromConfig.Clear();
                IDictionaryEnumerator aEnumerator = dictMasterUserPreferences.GetEnumerator();
                while (aEnumerator.MoveNext())
                {
                    dispName   = LanguageINI.GetString((string)aEnumerator.Key);
                    helpString = LanguageINI.GetString((string)aEnumerator.Key + "Help");

                    if (string.IsNullOrEmpty(dispName))
                    {
                        dispName = (string)aEnumerator.Key;
                    }

                    if (string.IsNullOrEmpty(helpString))
                    {
                        helpString = (string)aEnumerator.Key;
                    }

                    PreferenceSettings s = new PreferenceSettings((bool)aEnumerator.Value, dispName, helpString);
                    dictUserPreferencesFromConfig.Add((string)aEnumerator.Key, s);
                }
            }

            if (dictMasterDevicePreferences.Count > 0)
            {
                //enumerate the keys
                string dispName, helpString;
                dictDevicePreferencesFromConfig.Clear();
                IDictionaryEnumerator aEnumerator = dictMasterDevicePreferences.GetEnumerator();
                while (aEnumerator.MoveNext())
                {
                    dispName   = LanguageINI.GetString((string)aEnumerator.Key);
                    helpString = LanguageINI.GetString((string)aEnumerator.Key + "Help");
                    if (string.IsNullOrEmpty(dispName))
                    {
                        dispName = (string)aEnumerator.Key;
                    }
                    if (string.IsNullOrEmpty(helpString))
                    {
                        helpString = (string)aEnumerator.Key;
                    }

                    PreferenceSettings s = new PreferenceSettings((bool)aEnumerator.Value, dispName, helpString);
                    dictDevicePreferencesFromConfig.Add((string)aEnumerator.Key, s);
                }
            }

            // LOG
            logMSG = "Get user preferences settings";
            //  (logMSG);
            LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, logMSG);
            return(true);
        }
Beispiel #27
0
        private void handleItemAction(ListViewItem lvItem)
        {
            if (lvItem == null || lvItem.Tag == null)
            {
                return;
            }

            string key = lvItem.Tag as string;

            if (string.IsNullOrEmpty(key))
            {
                return;
            }

            ItemAction = null;
            if (horizontalTabs1.TabActive == tabDeviceSettings)
            {
                if (RoboSep_UserDB.getInstance().KeyDisableCamera == key)
                {
                    ItemAction = Utilities.DisableCamera;
                }
                else if (RoboSep_UserDB.getInstance().KeyDeleteVideoLogFiles == key)
                {
                    ItemAction = Utilities.DeleteVideoLogFiles;
                }

                try
                {
                    if (ItemAction != null)
                    {
                        ItemAction(userName, lvItem.Checked);
                    }
                }
                catch (Exception ex)
                {
                    // log exception message
                    //  (ex.Message);
                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, ex.Message);
                }
            }
            else if (horizontalTabs1.TabActive == tabUserSettings && lvItem.Checked)
            {
                string sItem = String.Empty;
                if (RoboSep_UserDB.getInstance().KeyEnableAutoScanBarcodes == key)
                {
                    ItemAction = UncheckItem;
                    sItem      = RoboSep_UserDB.getInstance().KeySkipResourcesScreen;
                }
                else if (RoboSep_UserDB.getInstance().KeySkipResourcesScreen == key)
                {
                    ItemAction = UncheckItem;
                    sItem      = RoboSep_UserDB.getInstance().KeyEnableAutoScanBarcodes;
                }
                try
                {
                    if (ItemAction != null)
                    {
                        ItemAction(sItem, true);
                    }
                }
                catch (Exception ex)
                {
                    // log exception message
                    //  (ex.Message);
                    LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, ex.Message);
                }
            }
        }
Beispiel #28
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 void button_EditList_Click(object sender, EventArgs e)
        {
            if (!RoboSep_UserConsole.bIsRunning)
            {
                // check if protocols loaded for run will be lost if list is re-loaded
                // caused by adding from the "All list" section of the selct protocol window
                if (RoboSep_RunSamples.getInstance().iSelectedProtocols.Length > 0)
                {
                    List <RoboSep_Protocol> usrLst  = RoboSep_UserDB.getInstance().loadUserProtocols(textBox_UserName.Text);
                    QuadrantInfo[]          RunInfo = RoboSep_RunSamples.getInstance().RunInfo;

                    List <int> removeQuadrants = new List <int>();

                    for (int Quadrant = 0; Quadrant < 4; Quadrant++)
                    {
                        if (RunInfo[Quadrant].bQuadrantInUse)
                        {
                            bool ProtocolInList = false;
                            for (int i = 0; i < usrLst.Count; i++)
                            {
                                if (RunInfo[Quadrant].QuadrantLabel == usrLst[i].Protocol_Name)
                                {
                                    ProtocolInList = true;
                                    break;
                                }
                            }
                            if (!ProtocolInList)
                            {
                                for (int i = 0; i < RunInfo[Quadrant].QuadrantsRequired; i++)
                                {
                                    removeQuadrants.Add(Quadrant + i);
                                }
                            }
                        }
                    }

                    // check if any protocols have been selected
                    // for the current run and will be lost
                    // when reloading profile
                    if (removeQuadrants.Count > 0)
                    {
                        string           sMSG   = LanguageINI.GetString("msgRefreshList") + "\r\n\r\n" + LanguageINI.GetString("msgRefreshList2");
                        RoboMessagePanel prompt = new RoboMessagePanel(RoboSep_UserConsole.getInstance(), MessageIcon.MBICON_WARNING,
                                                                       sMSG, LanguageINI.GetString("Warning"), LanguageINI.GetString("Yes"), LanguageINI.GetString("Cancel"));
                        RoboSep_UserConsole.showOverlay();
                        prompt.ShowDialog();

                        // wait for response

                        if (prompt.DialogResult == DialogResult.OK)
                        {
                            for (int i = 0; i < removeQuadrants.Count; i++)
                            {
                                RoboSep_RunSamples.getInstance().CancelQuadrant(removeQuadrants[i]);
                            }
                        }

                        prompt.Dispose();
                    }
                    else
                    {
                        return;
                    }
                }


                LoadRequired = true;

                //RoboSep_UserConsole.strCurrentUser = textBox_UserName.Text;
                openProtocolList();

                // LOG
                string LOGmsg = "Edit list button clicked";
                //GUI_Controls.uiLog.LOG(this, "button_EditList_Click", GUI_Controls.uiLog.LogLevel.EVENTS, LOGmsg);
                //  (LOGmsg);
                LogFile.AddMessage(System.Diagnostics.TraceLevel.Info, LOGmsg);
            }
            else
            {
                Prompt_RunInProgress();
            }
        }
Beispiel #30
0
        public bool LoadUserProtocolsMRU(string inUser)
        {
            if (string.IsNullOrEmpty(inUser))
            {
                return(false);
            }

            string fullPathUserFileName = RoboSep_UserDB.getInstance().sysPath;

            fullPathUserFileName += "protocols\\";
            fullPathUserFileName += UserInfoFileName;

            if (!File.Exists(fullPathUserFileName))
            {
                return(false);
            }

            // read values
            string[]      lines = File.ReadAllLines(fullPathUserFileName, System.Text.Encoding.UTF8);
            List <string> lst   = new List <string>();

            lst.AddRange(lines);

            ClearMRUList();

            string User = inUser.Trim();
            string tempPrefixLabel = User + PrefixProtocolLabel;
            string tempPrefixSampleVolume = User + PrefixSampleVolumeUl;
            string tempPrefixUsageTime = User + PrefixUsageTime;
            string temp1, temp2, temp3;
            int    index0 = 0, index1 = 0, index2 = 0, index3 = 0;

            string[] parts;
            bool     bProtocolNameNotEmpty = false;

            for (int i = 0; i < arrProtocolMRU.Length; i++)
            {
                // Quadrant starts at 1 instead of 0
                index0 = i + 1;
                bProtocolNameNotEmpty = false;
                temp1 = tempPrefixLabel + index0.ToString();
                temp2 = tempPrefixSampleVolume + index0.ToString();
                temp3 = tempPrefixUsageTime + index0.ToString();

                index1 = lst.FindIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp1.Length && x.ToLower().Contains(temp1.ToLower())); });
                index2 = lst.FindIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp2.Length && x.ToLower().Contains(temp2.ToLower())); });
                index3 = lst.FindIndex(x => { return(!string.IsNullOrEmpty(x) && x.Length >= temp3.Length && x.ToLower().Contains(temp3.ToLower())); });

                arrProtocolMRU[i].QuadrantNumber = i;
                if (0 <= index1)
                {
                    parts = lst[index1].Split('=');
                    if (parts.Length > 1 && parts[0].Trim() == temp1 && parts[0].Trim().Substring(0, 2) != @"//")
                    {
                        if (!string.IsNullOrEmpty(parts[1]) && parts[1].Trim().Length > 0)
                        {
                            arrProtocolMRU[i].ProtocolLabel = parts[1].Trim();
                            bProtocolNameNotEmpty           = true;
                        }
                    }
                }

                if (bProtocolNameNotEmpty)
                {
                    if (0 <= index2)
                    {
                        parts = lst[index2].Split('=');
                        if (parts.Length > 1 && !string.IsNullOrEmpty(parts[1]) && parts[1].Trim().Length > 0)
                        {
                            arrProtocolMRU[i].SampleVolumeUl = Convert.ToDouble(parts[1].Trim());
                        }
                    }
                    if (0 <= index3)
                    {
                        parts = lst[index3].Split('=');
                        if (parts.Length > 1 && !string.IsNullOrEmpty(parts[1]) && parts[1].Trim().Length > 0)
                        {
                            arrProtocolMRU[i].usageTime = Convert.ToDateTime(parts[1].Trim());
                        }
                    }
                }
            }
            return(true);
        }