Example #1
0
        /// <summary>
        /// Creates ItemCategories object by calling ItemCategories data provider create method.
        /// <example>[Example]bool status=ItemCategoriesFactory.Create(itemCategoriesObject);.</example>
        /// </summary>
        /// <param name="itemCategoriesObject">The ItemCategories object.</param>
        /// <returns>Status of create operation.</returns>
        public static ExecuteCommandStatus Create(ItemCategoriesEntity category, ItemsModulesOptions currentModule)
        {
            //Insert user name------------------------------------------
            string username = "";

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                username = HttpContext.Current.User.Identity.Name;
                category.InsertUserName = username;
            }
            //----------------------------------------------------------
            ExecuteCommandStatus status = ItemCategoriesSqlDataPrvider.Instance.Create(category, currentModule);

            //-------------------------------------
            if (status == ExecuteCommandStatus.Done)
            {
                string folder             = DCSiteUrls.GetPath_ItemCategoriesDirectory(category.OwnerName, category.ModuleTypeID, category.CategoryID);
                string folderPhysicalPath = DCServer.MapPath(folder);
                if (!Directory.Exists(folderPhysicalPath))
                {
                    string        defaultFolder             = DCSiteUrls.GetPath_DefaultCategoryFolder();
                    string        defaultFolderPhysicalPath = DCServer.MapPath(defaultFolder);
                    DirectoryInfo diSource = new DirectoryInfo(defaultFolderPhysicalPath);
                    DirectoryInfo diTarget = new DirectoryInfo(folderPhysicalPath);
                    DcDirectoryManager.CopyAll(diSource, diTarget);
                }
            }
            //-------------------------------------
            return(status);
        }
Example #2
0
 public static void DeleteUserFolder(MembershipUser user, UsersDataEntity userdata)
 {
     if (user != null && userdata != null)
     {
         if (user.IsApproved && UsersDataFactory.IsSubSubSiteOwner(userdata.UserType))
         {
             string subSiteFolder             = DCSiteUrls.GetPath_SubSiteUploadFolder(user.UserName);
             string subSiteFolderPhysicalPath = DCServer.MapPath(subSiteFolder);
             if (Directory.Exists(subSiteFolderPhysicalPath))
             {
                 DirectoryInfo dir = new DirectoryInfo(subSiteFolderPhysicalPath);
                 DcDirectoryManager.DeletDirectory(dir);
             }
         }
         else
         {
             string folder             = DCSiteUrls.GetPath_UserDataDirectory(userdata.OwnerName, userdata.ModuleTypeID, userdata.CategoryID, userdata.UserProfileID);
             string folderPhysicalPath = DCServer.MapPath(folder);
             if (Directory.Exists(folderPhysicalPath))
             {
                 DirectoryInfo dir = new DirectoryInfo(folderPhysicalPath);
                 DcDirectoryManager.DeletDirectory(dir);
             }
         }
     }
 }
Example #3
0
 public static void CreateUserFolder(MembershipUser user, UsersDataEntity userdata)
 {
     if (user != null && userdata != null)
     {
         if (user.IsApproved && UsersDataFactory.IsSubSubSiteOwner(userdata.UserType))
         {
             string subSiteFolder             = DCSiteUrls.GetPath_SubSiteUploadFolder(user.UserName);
             string subSiteFolderPhysicalPath = DCServer.MapPath(subSiteFolder);
             if (!Directory.Exists(subSiteFolderPhysicalPath))
             {
                 string        subSiteEmptyFolderPhysicalPath = DCServer.MapPath(DCSiteUrls.GetPath_DefaultSubSiteFolder());
                 DirectoryInfo diSource = new DirectoryInfo(subSiteEmptyFolderPhysicalPath);
                 DirectoryInfo diTarget = new DirectoryInfo(subSiteFolderPhysicalPath);
                 DcDirectoryManager.CopyAll(diSource, diTarget);
             }
         }
         else
         {
             // Create msg folder
             string folder             = DCSiteUrls.GetPath_UserDataDirectory(userdata.OwnerName, userdata.ModuleTypeID, userdata.CategoryID, userdata.UserProfileID);
             string folderPhysicalPath = DCServer.MapPath(folder);
             if (!Directory.Exists(folderPhysicalPath))
             {
                 string        defaultFolder             = DCSiteUrls.GetPath_DefaultUserDataFolder();
                 string        defaultFolderPhysicalPath = DCServer.MapPath(defaultFolder);
                 DirectoryInfo diSource = new DirectoryInfo(defaultFolderPhysicalPath);
                 DirectoryInfo diTarget = new DirectoryInfo(folderPhysicalPath);
                 DcDirectoryManager.CopyAll(diSource, diTarget);
             }
         }
     }
 }
Example #4
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);
        }
Example #5
0
    //--------------------------------------------------------
    #endregion

    public string GetSubSiteFolderSize(object identifire)
    {
        string text                   = "";
        long   folderSize             = 0;
        string folderPath             = DCSiteUrls.GetPath_SubSiteUploadFolder((string)identifire);
        string folderPathPhysicalPath = DCServer.MapPath(folderPath);

        if (Directory.Exists(folderPathPhysicalPath))
        {
            DirectoryInfo dir = new DirectoryInfo(folderPathPhysicalPath);
            DcDirectoryManager.GetDirectorySize(dir, ref folderSize);
            text = DcDirectoryManager.CalculateSizeToRead(folderSize);
        }
        return(text);
    }
Example #6
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);
        }
Example #7
0
        //------------------------------------------
        #endregion

        #region --------------Delete--------------
        /// <summary>
        /// Deletes single ItemCategories object .
        /// <example>[Example]bool status=ItemCategoriesFactory.Delete(categoryID);.</example>
        /// </summary>
        /// <param name="categoryID">The itemCategoriesObject id.</param>
        /// <returns>Status of delete operation.</returns>
        public static bool Delete(int CategoryID)
        {
            Languages            langID   = SiteSettings.GetCurrentLanguage();
            ItemCategoriesEntity category = GetObject(CategoryID, langID, SitesHandler.GetOwnerIDAsGuid());
            bool status = ItemCategoriesSqlDataPrvider.Instance.Delete(CategoryID);

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