Esempio n. 1
0
        private void DeleteAlert_Click(object sender, EventArgs e)
        {
            int row, alertId;

            row = V.GetFocusedDataSourceRowIndex();
            if (row < 0)
            {
                return;
            }
            alertId = (int)DataTable.Rows[row]["AlertId"];
            UserObjectDao.Delete(alertId);
            DataTable.Rows.RemoveAt(row);
            Grid.Refresh();
            return;
        }
Esempio n. 2
0
        private void DeleteAlert_Click(object sender, EventArgs e)
        {
            if (QueryName.Text != "")
            {
                DialogResult dr = MessageBoxMx.Show("Are you sure you want to delete the alert on query: \"" +
                                                    QueryName.Text + "\"?", UmlautMobius.String, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (dr != DialogResult.Yes)
                {
                    return;
                }
            }

            if (Alert.Id > 0)
            {
                UserObjectDao.Delete(Alert.Id);
                Alert = null;
            }

            DialogResult = DialogResult.Abort;             // indicate alert deleted
        }
Esempio n. 3
0
/// <summary>
/// Do some combination of copy/cut/delete on a single userObject
/// </summary>
/// <param name="command"></param>
/// <param name="uoArray"></param>
/// <param name="ctc"></param>
/// <param name="copy"></param>
/// <param name="delete"></param>

        //private static void CopyCutDelete(
        //    string command,
        //    UserObject uo,
        //    ContentsTreeControl ctc,
        //    bool copy,
        //    bool delete)
        //{
        //    UserObject[] uoArray = new UserObject[1] { uo };
        //    CopyCutDelete(command, uoArray, ctc, copy, delete);
        //}

        /// <summary>
/// Do some combination of copy/cut/delete on an array of Userobjects
/// </summary>
/// <param name="command"></param>
/// <param name="uoArray"></param>
/// <param name="ctc"></param>
/// <param name="copy"></param>
/// <param name="delete"></param>

        static void CopyCutDelete(
            string command,
            UserObject[] uoArray,
            ContentsTreeControl ctc,
            bool copy,
            bool delete)
        {
// Copy to clipboard

            if (copy)
            {
                if (!UserHasReadAccess(SS.I.UserName, uoArray))
                {
                    MessageBoxMx.ShowError("You are not authorized to copy these nodes. Copy canceled.");
                    return;
                }

                if (!UserObject.CanCopyPaste(uoArray))
                {
                    MessageBoxMx.ShowError("Can't copy/cut user objects of these types. Copy/cut canceled.");
                    return;
                }

                List <UserObject> userObjectArray = new List <UserObject>();
                foreach (UserObject userObject in uoArray)
                {
                    UserObject uo = UserObjectDao.Read(userObject.Id);
                    userObjectArray.Add(uo);
                }

                string serializedUos = Serialize(userObjectArray.ToArray());
                if (serializedUos != null)
                {
                    Clipboard.SetText(serializedUos);
                }
            }

// Delete object

            if (delete)
            {
                if (!UserHasWriteAccess(SS.I.UserName, uoArray))
                {
                    MessageBoxMx.ShowError("You are not authorized to cut/delete these nodes.");
                    return;
                }

                //for now, don't allow folders to be deleted if they aren't empty
                foreach (var uo in uoArray)
                {
                    if (uo.Type == UserObjectType.Folder)
                    {
                        MetaTreeNode folderNode = UserObjectTree.BuildNode(uo);
                        if (UserObjectTree.FolderNodes.ContainsKey(folderNode.Target.ToUpper()))
                        {
                            folderNode = UserObjectTree.FolderNodes[folderNode.Target.ToUpper()];

                            if (folderNode.Nodes.Count > 0)
                            {
                                MessageBoxMx.ShowError("Folder \"" + folderNode.Label + "\" is not empty and cannot be deleted.");
                                return;
                            }
                        }
                    }
                }

                if (!copy)
                {
                    string caption = "Confirm " + UserObject.GetTypeLabel(uoArray[0].Type) + " Delete";
                    string txt     = "Are you sure you want to delete " + Lex.Dq(uoArray[0].Name);
                    if (uoArray.Length > 1)
                    {
                        txt = "Are you sure you want to delete these " + uoArray.Length + " items?";
                    }
                    DialogResult dr = MessageBoxMx.Show(txt, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr != DialogResult.Yes)
                    {
                        return;
                    }

                    foreach (var uo in uoArray)
                    {
                        UserObject userObject = null;
                        userObject = UserData.IsUserDataObject(uo) ? UserObjectDao.Read(uo.Id) : uo;
                        bool succeeded = userObject != null && UserObjectDao.Delete(userObject.Id);
                        // remove userobject from database
                        if (UserData.IsUserDataObject(userObject))             // start removing any associated user data
                        {
                            UserData.StartBackgroundDataDelete(userObject);
                        }
                    }

                    //if (UserData.IsUserDataObject(uo)) uo = UserObjectDao.Read(uo.Id); // will need content to del assoc user data
                    //bool succeeded = UserObjectDao.Delete(uo.Id); // remove userobject from database
                    //if (UserData.IsUserDataObject(uo)) // start removing any associated user data
                    //    UserData.StartBackgroundDataDelete(uo);
                }

                else
                {
                    foreach (var uo in uoArray)
                    {
                        UserObjectDao.Delete(uo.Id);              // just remove userobject from database, will leave orphan data for annotation tables but need for paste
                    }
                }


                if (ctc != null)             // redraw the subtree without the deleted user object
                {
                    UserObjectTree.RefreshSubtreeInTreeControl(uoArray[0], ctc);
                }
            }
        }
Esempio n. 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;
        }