Esempio n. 1
0
/// <summary>
/// Import a list
/// </summary>
/// <returns></returns>

        static string ImportList()
        {
            string filePath = SelectListFileDialog("List File to Import", "");

            if (String.IsNullOrEmpty(filePath))
            {
                return("");
            }

            string fileName = Path.GetFileNameWithoutExtension(filePath);

            UserObject oListName = new UserObject(UserObjectType.CnList, SS.I.UserName, fileName);

            oListName = UserObjectSaveDialog.Show("Database List to Import Into", oListName);
            if (oListName == null)
            {
                return("");
            }

            Progress.Show("Importing List...");
            CidList list = CidList.ReadFromFile(filePath); // read file list

            Write(list, oListName);                        // write database list
            Progress.Hide();

            return(list.Count.ToString() + " " + MetaTable.KeyMetaTable.KeyMetaColumn.Label + "s have been imported");
        }
Esempio n. 2
0
        bool Save(bool prompt)
        {
            UserObject uo2;

            if (!IsValidCalcField())
            {
                return(false);
            }
            if (!GetCalcFieldForm())
            {
                return(false);
            }
            if (prompt)
            {
                uo2 = UserObjectSaveDialog.Show("Save Calculated Field Definition", UoIn);
                if (uo2 == null)
                {
                    return(false);
                }
            }
            else
            {
                uo2 = UoIn.Clone();
            }

            if (!UserObjectUtil.UserHasWriteAccess(uo2))
            {             // is the user authorized to save this?
                MessageBoxMx.ShowError("You are not authorized to save this calculated field");
                return(false);
            }

            SessionManager.DisplayStatusMessage("Saving calculated field...");

            string content = CalcField.Serialize();

            uo2.Content = content;

            //need the name of the folder to which the object will be saved
            MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(uo2);

            if (targetFolder == null)
            {
                MessageBoxMx.ShowError("Failed to save your calculated field.");
                return(false);
            }

            UserObjectDao.Write(uo2);

            string tName = "CALCFIELD_" + uo2.Id.ToString();

            QbUtil.UpdateMetaTableCollection(tName);
            MainMenuControl.UpdateMruList(tName);

            string title = "Edit Calculated Field - " + uo2.Name;

            Text = title;
            UoIn = uo2.Clone();             // now becomes input object
            SessionManager.DisplayStatusMessage("");
            return(true);
        }
Esempio n. 3
0
 internal static UserObjectSaveDialog GetInstance()
 {
     if (Instance == null)
     {
         Instance = new UserObjectSaveDialog();
     }
     return(Instance);
 }
Esempio n. 4
0
/// <summary>
/// Save the SpotfireLink UserObject
/// </summary>
/// <param name="prompt"></param>
/// <returns></returns>

        bool Save(bool prompt)
        {
            UserObject uo2;

            if (!IsValidSpotfireLink())
            {
                return(false);
            }
            if (!GetSpotfireLinkForm())
            {
                return(false);
            }
            if (prompt)
            {
                uo2 = UserObjectSaveDialog.Show("Save Spotfire link Definition", UoIn);
                if (uo2 == null)
                {
                    return(false);
                }
            }

            else
            {
                uo2 = UoIn.Clone();
            }

            uo2.Content = SpotfireViewProps.Serialize();

            if (!UserObjectUtil.UserHasWriteAccess(uo2))
            {             // is the user authorized to save this?
                MessageBoxMx.ShowError("You are not authorized to save this Spotfire link");
                return(false);
            }

            SessionManager.DisplayStatusMessage("Saving Spotfire link...");

            //need the name of the folder to which the object will be saved
            MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(uo2);

            if (targetFolder == null)
            {
                MessageBoxMx.ShowError("Failed to save your Spotfire link.");
                return(false);
            }

            UserObjectDao.Write(uo2);

            MainMenuControl.UpdateMruList(uo2.InternalName);

            string title = "Edit Spotfire Link - " + uo2.Name;

            Text = title;
            UoIn = uo2.Clone();             // now becomes input object
            SessionManager.DisplayStatusMessage("");
            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Save the specified list object
        /// </summary>
        /// <returns></returns>

        public static UserObject SaveList(
            CidList list,
            string caption,
            bool saveToTempList,
            string tempListName)
        {
            UserObject uo = null;
            String     name, txt;

            uo = new UserObject(UserObjectType.CnList);
            if (saveToTempList)
            {
                if (Lex.IsNullOrEmpty(tempListName))
                {
                    tempListName = InputBoxMx.Show("Enter the name of the temporary list to be saved to:", caption);
                }
                if (Lex.IsNullOrEmpty(tempListName))
                {
                    return(null);
                }

                uo.Owner        = SS.I.UserName;
                uo.ParentFolder = UserObject.TempFolderName;
                uo.Name         = tempListName;
            }

            else
            {
                uo = UserObjectSaveDialog.Show(caption, uo);              // save to permanent list
            }
            if (uo == null)
            {
                return(null);
            }
            if (!uo.IsTempObject)             // assign valid folder unless current list
            {
                UserObjectTree.GetValidUserObjectTypeFolder(uo);
            }

            SessionManager.DisplayStatusMessage("Saving List " + uo.Name + "...");

            list.UserObject = uo;
            int rc = Write(list);

            MainMenuControl.UpdateMruList(uo.InternalName);

            SessionManager.DisplayStatusMessage("");
            return(uo);
        }
Esempio n. 6
0
        /// <summary>
        /// Create a new conditional format user object
        /// </summary>
        /// <returns></returns>

        public static CondFormat CreateNewUserObject()
        {
            MetaColumnType mcType = MetaColumnType.Number;
            CondFormat     cf     = CreateAndInitializeCf(mcType);

            string     title = "New Conditional Format";
            CondFormat cf2   = Edit(cf, true, title);

            if (cf2 == null)
            {
                return(null);
            }

            UserObject uo = new UserObject(UserObjectType.CondFormat);

            //  Predefined cond formats by default are owned by a single owner and stored in a single folder

            uo.Owner        = SS.I.UserName;
            uo.ParentFolder = CondFormat.PredefinedCondFormatFolderName;
            uo.AccessLevel  = UserObjectAccess.ACL;
            uo.ACL          = AccessControlList.GetAdministratorGroupRwPublicReadAcl(SS.I.UserName);

            uo = UserObjectSaveDialog.Show("Save As", uo);
            if (uo == null)
            {
                return(null);
            }

            uo.Content = cf2.Serialize();
            UserObjectDao.Write(uo, uo.Id);

            MessageBoxMx.Show("Conditional format " + uo.Name + " saved (" + uo.InternalName + ")");             // show internal name so it may be referenced in a MetaColumn definition

            if (MainMenuControl != null)
            {
                MainMenuControl.UpdateMruList(uo.InternalName);
            }

            return(cf);
        }
Esempio n. 7
0
        ContentsTreeControlUoMenus CommonUoMenus; // common menus

        public UserObjectSaveDialog()
        {
            InitializeComponent();

            Instance = this;
        }
Esempio n. 8
0
/// <summary>
/// Save/SaveAs the list
/// </summary>
/// <param name="saveAs">SaveAs under another list name</param>
/// <param name="saveAsTempList">Save as a temp list</param>
/// <param name="tempListName">Temp list name to save under, prompt if null</param>
/// <returns></returns>

        bool Save(
            bool saveAs,
            bool saveAsTempList,
            string tempListName)
        {
            if (!ValidateList())
            {
                return(false);                             // Validate the list if requested
            }
// Get list name if needed & check that user can modify it

            if (saveAs || CidList.UserObject.Id == 0)
            {
                CidList.UserObject.Id = 0;                 // assign new id
                if (saveAsTempList)
                {
                    if (tempListName == null)                     // prompt for name
                    {
                        tempListName = CidListCommand.PromptForNewTempListName();
                        if (tempListName == null)
                        {
                            return(false);
                        }
                    }
                    CidList.UserObject = new UserObject(UserObjectType.CnList);
                    CidList.UserObject.ParentFolder = UserObject.TempFolderName;
                    CidList.UserObject.Name         = tempListName;
                    CidList.UserObject.Owner        = SS.I.UserName;
                }

                else                 // save as permanent list
                {
                    UserObject existingUo = CidList.UserObject;
                    if (CidList.UserObject.Id == 0)
                    {
                        existingUo = new UserObject(UserObjectType.CnList);
                    }
                    UserObject listUo = UserObjectSaveDialog.Show("Save As", existingUo);
                    if (listUo == null)
                    {
                        return(false);
                    }
                    CidList.UserObject = listUo;
                }
            }

            if (!UserObjectUtil.UserHasWriteAccess(CidList.UserObject))
            {             // is the user authorized to save this list?
                MessageBoxMx.ShowError("You are not authorized to save this list");
                return(false);
            }

// Write out the list

            DisplayStatusMsg("Saving list...");

            if (CidList.UserObject.HasDefinedParentFolder)
            {
                MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(CidList.UserObject);
                if (targetFolder == null)
                {                 // shouldn't happen
                    MessageBoxMx.ShowError("The list could not be saved because the folder it was in no longer exists.  Please try SaveAs instead.");
                    return(false);
                }
            }

            GetNormalizedListFromControl(CidList);

            if (!CidList.UserObject.IsCurrentObject)             // normal list?
            {
                CidListCommand.Write(CidList);
            }

            else                                       // special processing for current list
            {
                SessionManager.LockResultsKeys = true; // avoid possible overwrite of ResultsKeys if in single step query
                int           rc            = CidListCommand.Write(CidList);
                List <string> curListString = CidListCommand.ReadCurrentListLocal().ToStringList();
                SessionManager.CurrentResultKeys = curListString;
                SessionManager.DisplayCurrentCount();
                SessionManager.LockResultsKeys = false;
            }

            //string cFile = SS.I.ClientDefaultDir + @"\Previous.lst"
            //if (UIMisc.CanWriteFileToDefaultDir(cFile))
            //{
            //  StreamWriter sw = new StreamWriter(cFile); // save copy to disk
            //  sw.Write(CidList.UserObject.Content);
            //  sw.Close();
            //}

            int cncnt = CidList.Count;

            DisplayStatusMsg("List saved");

            Before = CidListCtl.Text;
            string tok = UserObjectUtil.GetName(ListName);

            Text = "Edit List - [" + CidList.UserObject.Name + "]";
            return(true);
        }