Ejemplo n.º 1
0
        private void btnManageThemesOK_Click(object sender, EventArgs e)
        {
            SiteSettings siteSettings = SettingsManager.GetSiteSettings(this.userId);
            string       path         = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/sites/") + siteSettings.UserId.ToString();

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            foreach (DataListItem item in this.dtManageThemes.Items)
            {
                CheckBox box = item.FindControl("rbCheckThemes") as CheckBox;
                if (box.Checked)
                {
                    DisplayThemesImages images = (DisplayThemesImages)item.FindControl("themeImg");
                    string srcPath             = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/library/") + images.ThemeName;
                    string str3 = path + @"\" + images.ThemeName;
                    if (!Directory.Exists(str3))
                    {
                        try
                        {
                            this.CopyDir(srcPath, str3);
                            continue;
                        }
                        catch
                        {
                            this.ShowMsg("修改模板失败", false);
                            continue;
                        }
                    }
                }
            }
            this.ShowMsg("成功修改了店铺模板", true);
            this.GetThemes();
        }
Ejemplo n.º 2
0
        private void btnManageThemesOK_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Context.SiteSettings siteSettings = Hidistro.Membership.Context.SettingsManager.GetSiteSettings(this.userId);
            string text = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/sites/") + siteSettings.UserId.ToString();

            if (!System.IO.Directory.Exists(text))
            {
                System.IO.Directory.CreateDirectory(text);
            }
            foreach (System.Web.UI.WebControls.DataListItem dataListItem in this.dtManageThemes.Items)
            {
                System.Web.UI.WebControls.CheckBox checkBox = dataListItem.FindControl("rbCheckThemes") as System.Web.UI.WebControls.CheckBox;
                if (checkBox.Checked)
                {
                    DisplayThemesImages displayThemesImages = (DisplayThemesImages)dataListItem.FindControl("themeImg");
                    string srcPath = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/library/") + displayThemesImages.ThemeName;
                    string text2   = text + "\\" + displayThemesImages.ThemeName;
                    if (!System.IO.Directory.Exists(text2))
                    {
                        try
                        {
                            this.CopyDir(srcPath, text2);
                        }
                        catch
                        {
                            this.ShowMsg("修改模板失败", false);
                        }
                    }
                }
            }
            this.ShowMsg("成功修改了店铺模板", true);
            this.GetThemes();
        }
Ejemplo n.º 3
0
 private void dtManageThemes_ItemCommand(object sender, System.Web.UI.WebControls.DataListCommandEventArgs e)
 {
     if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem)
     {
         DisplayThemesImages displayThemesImages = (DisplayThemesImages)e.Item.FindControl("themeImg");
         string text  = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/library/" + displayThemesImages.ThemeName);
         string text2 = this.Page.Request.MapPath(string.Concat(new string[]
         {
             Globals.ApplicationPath,
             "/Templates/sites/",
             Hidistro.Membership.Context.HiContext.Current.User.UserId.ToString(),
             "/",
             displayThemesImages.ThemeName
         }));
         if (e.CommandName == "btnUse")
         {
             this.UserTemplate(displayThemesImages.ThemeName);
             this.ShowMsg("成功修改了店铺模板", true);
             this.GetThemes(displayThemesImages.ThemeName);
         }
         if (e.CommandName == "download")
         {
             new System.IO.DirectoryInfo(text);
             System.Text.Encoding uTF = System.Text.Encoding.UTF8;
             using (ZipFile zipFile = new ZipFile())
             {
                 zipFile.CompressionLevel = CompressionLevel.Default;
                 zipFile.AddDirectory(text2);
                 System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                 response.ContentType     = "application/zip";
                 response.ContentEncoding = uTF;
                 response.AddHeader("Content-Disposition", "attachment;filename=" + displayThemesImages.ThemeName + ".zip");
                 response.Clear();
                 zipFile.Save(response.OutputStream);
                 response.Flush();
                 response.Close();
             }
         }
         if (e.CommandName == "back")
         {
             try
             {
                 if (!System.IO.Directory.Exists(text))
                 {
                     this.ShowMsg("主站不存在该模板", false);
                 }
                 else
                 {
                     this.CopyDir(text, text2);
                     this.ShowMsg("恢复店铺模板成功", true);
                 }
             }
             catch
             {
                 this.ShowMsg("恢复店铺模板失败", false);
             }
         }
     }
 }
Ejemplo n.º 4
0
 private void dtManageThemes_ItemCommand(object sender, DataListCommandEventArgs e)
 {
     if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         DisplayThemesImages images = (DisplayThemesImages)e.Item.FindControl("themeImg");
         string path          = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/library/" + images.ThemeName);
         string directoryName = this.Page.Request.MapPath(Globals.ApplicationPath + "/Templates/sites/" + HiContext.Current.User.UserId.ToString() + "/" + images.ThemeName);
         if (e.CommandName == "btnUse")
         {
             this.UserTemplate(images.ThemeName);
             this.ShowMsg("成功修改了店铺模板", true);
             this.GetThemes(images.ThemeName);
         }
         if (e.CommandName == "download")
         {
             new DirectoryInfo(path);
             Encoding encoding = Encoding.UTF8;
             using (ZipFile file = new ZipFile())
             {
                 file.CompressionLevel = CompressionLevel.Default;
                 file.AddDirectory(directoryName);
                 HttpResponse response = HttpContext.Current.Response;
                 response.ContentType     = "application/zip";
                 response.ContentEncoding = encoding;
                 response.AddHeader("Content-Disposition", "attachment;filename=" + images.ThemeName + ".zip");
                 response.Clear();
                 file.Save(response.OutputStream);
                 response.Flush();
                 response.Close();
             }
         }
         if (e.CommandName == "back")
         {
             try
             {
                 if (!Directory.Exists(path))
                 {
                     this.ShowMsg("主站不存在该模板", false);
                 }
                 else
                 {
                     this.CopyDir(path, directoryName);
                     this.ShowMsg("恢复店铺模板成功", true);
                 }
             }
             catch
             {
                 this.ShowMsg("恢复店铺模板失败", false);
             }
         }
     }
 }
Ejemplo n.º 5
0
 private void dtManageThemes_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         DisplayThemesImages displayThemesImages = e.Item.FindControl("themeImg") as DisplayThemesImages;
         string themeName     = displayThemesImages.ThemeName;
         string directoryName = this.Page.Request.MapPath("/Templates/master/") + themeName;
         string text          = this.Page.Request.MapPath("/Templates/master/") + themeName;
         if (e.CommandName == "btnUse")
         {
             this.UserThems(themeName);
             this.ShowMsg("成功修改了商城模板", true);
         }
         if (e.CommandName == "download")
         {
             try
             {
                 DirectoryInfo directoryInfo = new DirectoryInfo(text);
                 Encoding      uTF           = Encoding.UTF8;
                 using (ZipFile zipFile = new ZipFile())
                 {
                     zipFile.CompressionLevel = CompressionLevel.Default;
                     if (Directory.Exists(text))
                     {
                         zipFile.AddDirectory(text);
                     }
                     else
                     {
                         zipFile.AddDirectory(directoryName);
                     }
                     HttpResponse response = HttpContext.Current.Response;
                     response.ContentType     = "application/zip";
                     response.ContentEncoding = uTF;
                     response.AddHeader("Content-Disposition", "attachment;filename=" + themeName + ".zip");
                     response.Clear();
                     zipFile.Save(response.OutputStream);
                     response.Flush();
                     response.Close();
                 }
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 控件事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void dtManageThemes_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            if (((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) && (e.CommandName == "btnUse"))
            {
                SiteSettings siteSettings = SettingsManager.GetSiteSettings(HiContext.Current.User.UserId);

                DisplayThemesImages images = (DisplayThemesImages)e.Item.FindControl("themeImg");

                siteSettings.Theme = images.ThemeName;

                SettingsManager.Save(siteSettings);

                HiCache.Remove(string.Format("AdsFileCache-{0}", HiContext.Current.User.UserId));
                HiCache.Remove(string.Format("ArticleSubjectFileCache-{0}", HiContext.Current.User.UserId));
                HiCache.Remove(string.Format("ProductSubjectFileCache-{0}", HiContext.Current.User.UserId));

                GetThemes(images.ThemeName);

                ShowMsg("成功修改了店铺模板", true);
            }
        }