Exemple #1
0
        /// <summary>
        /// Creates Messages object by calling Messages data provider create method.
        /// <example>[Example]bool status=MessagesFactory.Create(msg);.</example>
        /// </summary>
        /// <param name="msg">The Messages object.</param>
        /// <returns>Status of create operation.</returns>
        public static bool Create(MessagesEntity msg, bool createMsgFolder)
        {
            //Insert user name------------------------------------------
            string username = "";

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                username           = HttpContext.Current.User.Identity.Name;
                msg.InsertUserName = username;
            }
            //----------------------------------------------------------
            bool status = MessagesSqlDataPrvider.Instance.Create(msg);

            //-------------------------------------
            if (status && createMsgFolder)
            {
                // Create msg folder
                string folder             = DCSiteUrls.GetPath_MessagesDirectory(msg.OwnerName, msg.ModuleTypeID, msg.CategoryID, msg.MessageID);
                string folderPhysicalPath = DCServer.MapPath(folder);
                if (!Directory.Exists(folderPhysicalPath))
                {
                    string        defaultFolder             = DCSiteUrls.GetPath_DefaultMessageFolder();
                    string        defaultFolderPhysicalPath = DCServer.MapPath(defaultFolder);
                    DirectoryInfo diSource = new DirectoryInfo(defaultFolderPhysicalPath);
                    DirectoryInfo diTarget = new DirectoryInfo(folderPhysicalPath);
                    DcDirectoryManager.CopyAll(diSource, diTarget);
                }
            }
            //-------------------------------------
            return(status);
        }
Exemple #2
0
        //------------------------------------------
        #endregion

        #region --------------Delete--------------
        /// <summary>
        /// Deletes single Messages object .
        /// <example>[Example]bool status=MessagesFactory.Delete(messageID);.</example>
        /// </summary>
        /// <param name="messageID">The msg id.</param>
        /// <returns>Status of delete operation.</returns>
        public static bool Delete(int messageID)
        {
            MessagesEntity msg    = MessagesFactory.GetMessagesObject(messageID, UsersTypes.Admin, SitesHandler.GetOwnerIDAsGuid());
            bool           status = MessagesSqlDataPrvider.Instance.Delete(messageID);

            //-------------------------------------
            if (status)
            {
                //delete message folder
                //-------------------------------------
                string folder             = DCSiteUrls.GetPath_MessagesDirectory(msg.OwnerName, msg.ModuleTypeID, msg.CategoryID, msg.MessageID);
                string folderPhysicalPath = DCServer.MapPath(folder);
                if (Directory.Exists(folderPhysicalPath))
                {
                    DirectoryInfo dir = new DirectoryInfo(folderPhysicalPath);
                    DcDirectoryManager.DeletDirectory(dir);
                }
            }
            //-------------------------------------
            return(status);
        }