コード例 #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);
        }