Beispiel #1
0
        /// <summary>
        /// Get user info for all users
        /// </summary>
        /// <returns></returns>

        public static ArrayList GetAllUserInfo()
        {
            List <UserObject> al  = UserObjectDao.ReadMultiple(UserObjectType.UserParameter, "NameAddress", false, false);
            ArrayList         al2 = new ArrayList();

            for (int i1 = 0; i1 < al.Count; i1++)
            {
                UserObject uo = al[i1];
                UserInfo   ui = UserInfo.Deserialize(uo.Description);
                ui.UserName = uo.Owner;
                al2.Add(ui);
            }

            return(al2);
        }
Beispiel #2
0
        /// <summary>
        /// Get all alerts from the DB. Sort alerts from oldest to newest LastCheck Date so oldest alerts are put at the top of the queue.
        /// </summary>
        /// <returns></returns>
        private static List <Alert> GetAllAlerts()
        {
            List <UserObject> alertUos = UserObjectDao.ReadMultiple(UserObjectType.Alert, false);

            List <Alert> alerts = new List <Alert>();

            for (int ai = 1; ai < alertUos.Count; ai++)             // deserialize alerts so they can be sorted
            {
                UserObject uo    = alertUos[ai];
                Alert      alert = Alert.GetAlertFromUserObject(uo, false);
                alerts.Add(alert);
            }
            List <Alert> sortedAlerts = alerts.OrderBy(o => o.StartTime).ThenBy(o => o.LastCheck).ToList();

            return(sortedAlerts);
        }
Beispiel #3
0
        /// <summary>
        /// Display the grid of alerts & let user add, edit and cancel them.
        /// </summary>
        /// <returns></returns>
        public static string Show(string args)
        {
            List <UserObject> alerts;
            Alert             alert = null;
            int    alertId, queryId, row;
            string txt;

            string userid = SS.I.UserName;

            if (args == null || args == "")
            {
                Progress.Show("Retrieving alerts...", UmlautMobius.String, false);
                alerts = UserObjectDao.ReadMultiple(UserObjectType.Alert, SS.I.UserName, false, false);
            }

            else
            {
                if (!Security.IsAdministrator(SS.I.UserName))
                {
                    return("Only administrators can execute this command");
                }
                Progress.Show("Retrieving alerts...", UmlautMobius.String, false);
                if (Lex.Eq(args, "All"))                 // all users
                {
                    alerts = UserObjectDao.ReadMultiple(UserObjectType.Alert, false);
                }
                else                 // some other user
                {
                    alerts = UserObjectDao.ReadMultiple(UserObjectType.Alert, args, false, false);
                }
            }

            AlertGridDialog Instance = new AlertGridDialog();

            Instance.SetupGrid(alerts);
            Progress.Hide();

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            return("");
        }
Beispiel #4
0
        /// <summary>
        /// Thread to check to see if any imports need to started
        /// </summary>

        public void CheckForImportFileUpdatesThreadMethod(Object CheckAll)
        {
            // Check each ImportState user object for the user to see if any imports need to be started.
            // If any are found then start a new hidden Mobius client & server to upload the file(s)
            // and start an import user data process for each one.

            UserDataImportState udis;

            List <UserObject> imps = new List <UserObject>();
            UserCmpndDbDao    udbs = new UserCmpndDbDao();

            int t0 = TimeOfDay.Milliseconds();

            bool checkAllImportFiles = (bool)CheckAll;

            if (checkAllImportFiles)
            {
                imps = UserObjectDao.ReadMultiple(UserObjectType.ImportState, false);
            }
            else
            {
                imps = UserObjectDao.ReadMultiple(UserObjectType.ImportState, SS.I.UserName, false, false);
            }

            int t1 = TimeOfDay.Milliseconds() - t0;

            if (imps.Count == 0)
            {
                return;
            }
            //			return ""; // debug

            int i1 = 0;

            while (i1 < imps.Count)
            {             // pare list down do those needing updating
                UserObject uo = imps[i1];

                try { udis = UserDataImportState.Deserialize(uo); }
                catch (Exception ex)
                {
                    imps.RemoveAt(i1);
                    continue;
                }

                if (udis.CheckForFileUpdates && ((checkAllImportFiles == true && udis.ClientFile.Substring(0, 1) == "\\" && FileUtil.Exists(udis.ClientFile)) || checkAllImportFiles == false))
                {
                    DateTime clientFileModDt = FileUtil.GetFileLastWriteTime(udis.ClientFile); // get client file mod date

                    if (clientFileModDt == DateTime.MinValue ||                                // skip if client file not found or
                        udis.ImportIsRunning ||                                                // import is already running
                        ((clientFileModDt - udis.ClientFileModified).TotalSeconds < 1 &&       // no change in client file mod date and
                         !udis.ImportHasFailed))                                               // prev load attempt hasn't failed
                    {
                        imps.RemoveAt(i1);
                        continue;
                    }

                    udis.ClientFileModified = clientFileModDt;                     // write the updated file date
                    uo.Description          = udis.Serialize();
                    UserObjectDao.Write(uo);
                }

                else                          // running or failed manual background import
                {
                    if (udis.ImportHasFailed) // delete if failed
                    {
                        bool deleted = UserObjectDao.Delete(udis.Id);
                        udbs.LogMessage("Deleted ImportState object for failed manual background import on " + uo.Name);
                    }

                    imps.RemoveAt(i1);                     // don't consider further here
                    continue;
                }

                i1++;
            }

            //write a debug message and return
            udbs.LogMessage(string.Format("Found {0} annotation files that could be updated by the {1} account", imps.Count, SS.I.UserName));

            int t2 = TimeOfDay.Milliseconds() - t0;

            if (imps.Count == 0)
            {
                return;
            }

            // Upload the file to the server and start a background process to update the annotation table

            foreach (UserObject uo2 in imps)
            {
                try
                {
                    udis = UserDataImportState.Deserialize(uo2);
                    string internalUoName = "Annotation_" + uo2.Id;
                    string exportDir      = ServicesIniFile.Read("BackgroundExportDirectory");
                    string serverFileName =                     // location for file on server
                                            exportDir + @"\" + internalUoName + Path.GetExtension(udis.FileName);
                    ServerFile.CopyToServer(udis.FileName, serverFileName);
                    string command = "ImportUserData " + serverFileName + ", " + internalUoName;
                    CommandLine.StartBackgroundSession("ImportUserData " + serverFileName + ", " + uo2.Name);
                    udbs.LogMessage("Auto-upload for ImportState ObjId = " + ", " + uo2.Id + ", Name = " + uo2.Name + ", Desc = " + uo2.Description);
                }

                catch (Exception ex)
                {
                    try
                    {
                        udbs.LogMessage("Auto-upload exception ImportState ObjId = " + uo2.Id + ", Name = " + uo2.Name +
                                        ", Desc = " + uo2.Description +
                                        "\n" + DebugLog.FormatExceptionMessage(ex));
                    }

                    catch (Exception ex2) { ex2 = ex2; }

                    continue;
                }
            }

            Progress.Hide();

            int t3 = TimeOfDay.Milliseconds() - t0;

            return;
        }