/// <summary>
        /// 缩略图的生成
        /// </summary>
        private void PushThumbnail()
        {
            //根据ID查询出缩略的方式
            Int32  ItemID    = WebHelper.GetIntParam(Request, "ID", 0);
            Int32  Width     = WebHelper.GetIntParam(Request, "width", 200);
            Int32  height    = WebHelper.GetIntParam(Request, "height", 200);
            String Mode      = WebHelper.GetStringParam(Request, "mode", "AUTO");
            String PhotoType = WebHelper.GetStringParam(Request, "Type", "p").ToLower();

            String ImagePath = MapPath(String.Format("{0}/Resource/images/no_image.png", TemplateSourceDirectory));



            //if (ItemID > 0)
            //{
            //    DNNGo_LayerGallery_Content ContentItem = DNNGo_LayerGallery_Content.FindByID(ItemID);
            //    if (ContentItem != null && ContentItem.ID > 0)
            //    {


            //        if (PhotoType == "p")
            //            ImagePath = ViewLinkUrl(ContentItem.Picture, ContentItem.PortalId);
            //        else
            //            ImagePath = ViewLinkUrl(ContentItem.Thumbnails, ContentItem.PortalId);

            //    }
            //}
            GenerateThumbnail.PushThumbnail(Server.UrlDecode(ImagePath), Width, height, Mode);
        }
        // Upload file to the server
        private void UploadFile(HttpContext context)
        {
            var statuses = new List <Resource_FilesStatus>();
            var headers  = context.Request.Headers;

            String a = WebHelper.GetStringParam(context.Request, "type", "");

            if (!String.IsNullOrEmpty(a) && a == "DELETE")
            {
                DeleteFile(context);
            }
            else
            {
                if (string.IsNullOrEmpty(headers["X-File-Name"]))
                {
                    UploadWholeFile(context, statuses);
                }
                else
                {
                    UploadPartialFile(headers["X-File-Name"], context, statuses);
                }

                WriteJsonIframeSafe(context, statuses);
            }
        }
        /// <summary>
        /// 获取Form传值
        /// </summary>
        /// <param name="fieldItem"></param>
        /// <returns></returns>
        public String GetWebFormValue(SettingEntity fieldItem)
        {
            String WebFormValue = String.Empty;

            //创建控件的Name和ID
            ControlHelper ControlItem = new ControlHelper(ModuleId);
            String        ControlName = ControlItem.ViewControlName(fieldItem);
            String        ControlID   = ControlItem.ViewControlID(fieldItem);


            if (fieldItem.ControlType == EnumControlType.CheckBox.ToString())
            {
                WebFormValue = WebHelper.GetStringParam(Request, ControlName, "");
                WebFormValue = !String.IsNullOrEmpty(WebFormValue) && WebFormValue == "on" ? "true" : "false";
            }
            else if (fieldItem.ControlType == EnumControlType.FileUpload.ToString())
            {
                HttpPostedFile hpFile = Request.Files[ControlName];
                if (hpFile != null && hpFile.ContentLength > 0)
                {
                    WebFormValue = String.Format("Url://{0}", FileSystemUtils.UploadFile(hpFile, this));                                                            //存放到目录中,并返回
                }
            }
            else
            {
                WebFormValue = WebHelper.GetStringParam(Request, ControlName, "");
            }

            return(WebFormValue);
        }
        public string xUrl(string KeyName, string KeyValue, string ControlKey, params string[] AdditionalParameters)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            String language = WebHelper.GetStringParam(Request, "language", PortalSettings.DefaultLanguage);

            sb.AppendFormat("{0}Index_Manager.aspx?PortalId={1}&TabId={2}&ModuleId={3}&language={4}", ModulePath, PortalId, TabId, ModuleId, language);

            string key = ControlKey;

            if (string.IsNullOrEmpty(key))
            {
                sb.AppendFormat("&Token={0}", xUrlToken());
            }
            else
            {
                sb.AppendFormat("&Token={0}", key);
            }
            if (!string.IsNullOrEmpty(KeyName) && !string.IsNullOrEmpty(KeyValue))
            {
                sb.AppendFormat("&{0}={1}", KeyName, KeyValue);
            }

            if (AdditionalParameters != null && AdditionalParameters.Length > 0)
            {
                foreach (String parameter in AdditionalParameters)
                {
                    sb.AppendFormat("&{0}", parameter);
                }
            }
            return(sb.ToString());
        }
        /// <summary>
        /// 绑定左边子菜单
        /// </summary>
        public String BindLeftMenuBySubmenu(List <MenuTabItem> TokenItems, out Boolean is_active)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            is_active = false;
            sb.Append("<ul class=\"sub-menu\">").AppendLine();
            foreach (MenuTabItem item in TokenItems)
            {
                String active_class = String.Empty;
                if (item.Token.ToLower() == Token.ToLower() || (!String.IsNullOrEmpty(item.Link) && item.Link.ToLower() == Token.ToLower()))
                {
                    is_active    = true;
                    active_class = "active open";
                }

                if (item.Visible)
                {
                    if (!item.IsAdministrator || IsAdministrator)
                    {
                        String language  = WebHelper.GetStringParam(Request, "language", PortalSettings.DefaultLanguage);
                        String item_url  = String.Format("{0}Index_Manager.aspx?PortalId={1}&TabId={2}&ModuleId={3}&Token={4}&language={5}{6}", ModulePath, PortalId, TabId, ModuleId, item.Token, language, ConvertParameter(item.Parameter));;
                        String item_icon = string.IsNullOrEmpty(item.Icon) ? "" : String.Format("<i class=\"{0}\"></i>", item.Icon);

                        sb.AppendFormat("<li class=\"{0}\">", active_class).AppendLine();

                        sb.AppendFormat("<a href=\"{0}\">{1} <span class=\"title\"> {2} </span> </a>", item_url, item_icon, ViewMenuText(item)).AppendLine();

                        sb.Append("</li>").AppendLine();
                    }
                }
            }
            sb.Append("</ul>").AppendLine();

            return(sb.ToString());
        }
Example #6
0
        /// <summary>
        /// 状态应用按钮事件
        /// </summary>
        protected void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 Status = WebHelper.GetIntParam(Request, ddlStatus.UniqueID, -1);

                if (Status >= 0)
                {
                    string   Checkbox_Value       = WebHelper.GetStringParam(Request, "Checkbox", "");
                    string[] Checkbox_Value_Array = Checkbox_Value.Split(',');
                    Int32    IDX = 0;
                    mTips.IsPostBack = true;
                    for (int i = 0; i < Checkbox_Value_Array.Length; i++)
                    {
                        if (Int32.TryParse(Checkbox_Value_Array[i], out IDX))
                        {
                            DNNGo_LayerGallery_Files Multimedia = DNNGo_LayerGallery_Files.FindByKeyForEdit(IDX);
                            if (Multimedia != null && Multimedia.ID > 0)
                            {
                                //if (Multimedia.Status == (Int32)EnumFileStatus.Recycle && Status == (Int32)EnumFileStatus.Recycle)
                                //{
                                //要删除实际的文件
                                String DeletePath = Server.MapPath(GetPhotoPath(Multimedia.FilePath));
                                if (Multimedia.Delete() > 0)
                                {
                                    //删除文件
                                    if (File.Exists(DeletePath))
                                    {
                                        File.Delete(DeletePath);
                                    }

                                    //操作成功
                                    mTips.LoadMessage("DeleteMediaLibrarySuccess", EnumTips.Success, this, new String[] { Multimedia.FileName });
                                }
                                else
                                {
                                    //操作失败
                                    mTips.LoadMessage("DeleteMediaLibraryError", EnumTips.Success, this, new String[] { Multimedia.FileName });
                                }

                                //}
                                //else
                                //{
                                //    Multimedia.Status = Status;
                                //    if (Multimedia.Update() > 0)
                                //    {
                                //    }
                                //}
                            }
                        }
                    }
                    BindDataList();
                }
            }
            catch (Exception ex)
            {
                ProcessModuleLoadException(ex);
            }
        }
 /// <summary>
 /// 返回
 /// </summary>
 protected void cmdReturn_Click(object sender, EventArgs e)
 {
     try
     {
         String ReturnUrl = WebHelper.GetStringParam(Request, "ReturnUrl", "");
         Response.Redirect(ReturnUrl, false);
     }
     catch (Exception exc)
     {
     }
 }
        /// <summary>
        /// 绑定左菜单
        /// </summary>
        public void BindLeftMenu()
        {
            if (InitMenuTabCollection != null && InitMenuTabCollection.Count > 0)
            {
                List <MenuTabItem> TokenItems = InitMenuTabCollection.ToList();

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                for (int i = 0; i < TokenItems.Count; i++)
                {
                    if (String.IsNullOrEmpty(TokenItems[i].Parent) && TokenItems[i].Visible)
                    {
                        MenuTabItem item = TokenItems[i];

                        if (!item.IsAdministrator || IsAdministrator)
                        {
                            String ChildHtml = String.Empty;
                            bool   is_active = false;
                            bool   is_Child  = false;

                            List <MenuTabItem> ChildList = InitMenuTabCollection.FindByParent(TokenItems[i].Token);
                            if (ChildList.Count > 0)
                            {
                                ChildHtml = BindLeftMenuBySubmenu(ChildList, out is_active);
                                is_Child  = true;
                            }

                            if (item.Token.ToLower() == Token.ToLower())
                            {
                                is_active = true;
                            }

                            String active_class = is_active ? "active open" : "";
                            String language     = WebHelper.GetStringParam(Request, "language", PortalSettings.DefaultLanguage);
                            String item_url     = (ChildList != null && ChildList.Count > 0) || String.IsNullOrEmpty(item.Src) ? "javascript:;" : String.Format("{0}Index_Manager.aspx?PortalId={1}&TabId={2}&ModuleId={3}&Token={4}&language={5}{6}", ModulePath, PortalId, TabId, ModuleId, item.Token, language, ConvertParameter(item.Parameter));;
                            String item_icon    = string.IsNullOrEmpty(item.Icon) ? "" : String.Format("<i class=\"{0}\"></i>", item.Icon);

                            sb.AppendFormat("<li class=\"{0}\">", active_class).AppendLine();

                            sb.AppendFormat("<a href=\"{0}\">{1} <span class=\"{2}\"> {2} </span> <span class=\"selected\"></span>", item_url, item_icon, ViewMenuText(item));
                            if (is_Child)
                            {
                                sb.Append("<i class=\"icon-arrow\"></i> ");
                            }

                            sb.Append("</a>").AppendLine();
                            sb.Append(ChildHtml).AppendLine();

                            sb.Append("</li>").AppendLine();
                        }
                    }
                }
                liLeftMenu.Text = sb.ToString();
            }
        }
        /// <summary>
        /// 错误捕获
        /// </summary>
        /// <param name="exc">错误</param>
        public void ProcessModuleLoadException(Exception exc)
        {
            if (HttpContext.Current.Session["Exception"] != null)
            {
                HttpContext.Current.Session.Remove("Exception");
            }
            //增加当前序列化的内容到Session
            HttpContext.Current.Session.Add("Exception", exc);

            if (WebHelper.GetStringParam(Request, "Token", "").ToLower() != "error")
            {
                Response.Redirect(xUrl("ReturnUrl", HttpUtility.UrlEncode(WebHelper.GetScriptUrl), "Error"), false);
            }
        }
        private void DeliverFile(HttpContext context)
        {
            DNNGo_LayerGallery_Files DataItem = DNNGo_LayerGallery_Files.FindByKeyForEdit(WebHelper.GetStringParam(context.Request, "PhotoID", "0"));

            if (DataItem != null && DataItem.ID > 0)
            {
                String Picture = GetPhotoPath(DataItem);

                if (!String.IsNullOrEmpty(Picture) && File.Exists(context.Server.MapPath(Picture)))
                {
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + DataItem.FileName + "\"");
                    context.Response.ContentType = "application/octet-stream";
                    context.Response.ClearContent();
                    context.Response.WriteFile(context.Server.MapPath(Picture));
                }
                else
                {
                    context.Response.StatusCode = 404;
                }
            }
            else
            {
                context.Response.StatusCode = 404;
            }



            //var filename = context.Request["PhotoID"];
            //var filePath = StorageRoot + filename;

            //if (File.Exists(filePath)) {
            //    context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
            //    context.Response.ContentType = "application/octet-stream";
            //    context.Response.ClearContent();
            //    context.Response.WriteFile(filePath);
            //} else
            //    context.Response.StatusCode = 404;
        }