Example #1
0
        public virtual void ImportPlugin()
        {
            AddTabs();
            PluginClientId = Guid.NewGuid().ToString();
            XmlSetting     = PlugHelper.RenderXml(this);
            XmlDocument doc  = new XmlDocument();
            XmlNode     root = doc.CreateNode(XmlNodeType.XmlDeclaration, null, null);

            doc.AppendChild(root);
            doc.AppendChild(doc.ImportNode(XmlSetting, true));
            XmlDocSetting = doc;
        }
Example #2
0
        public static string updatePlug(string layplug, string ilist, string plugtype)
        {
            XmlDocument doc  = new XmlDocument();
            XmlNode     node = doc.ImportNode(PlugHelper.RenderXml(toList(ilist), plugtype), true);

            doc.AppendChild(node);
            UserFunction itemUpdate = UserFunctionDal.SelectById(Convert.ToInt32(layplug));

            itemUpdate.Doc = linh.common.Lib.GetXmlString(doc);
            itemUpdate     = UserFunctionDal.Update(itemUpdate);
            return(PlugHelper.RenderHtml(doc));
        }
Example #3
0
        public virtual void ImportPlugin(string _title, string _pluginId, bool _isCp, bool _isInvisible)
        {
            AddTabs();
            PluginClientId = Guid.NewGuid().ToString();
            PluginId       = _PluginId;
            IsCp           = _isCp;
            IsInvisible    = _isInvisible;
            XmlSetting     = PlugHelper.RenderXml(this);
            XmlDocument doc  = new XmlDocument();
            XmlNode     root = doc.CreateNode(XmlNodeType.XmlDeclaration, null, null);

            doc.AppendChild(root);
            doc.AppendChild(doc.ImportNode(XmlSetting, true));
            XmlDocSetting = doc;
        }
        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sb              = new StringBuilder();
            string        act             = context.Request["act"];
            string        rqPlug          = context.Request["rqPlug"];
            string        imgSaveLoc      = context.Server.MapPath("~/lib/up/i/");
            string        imgTemp         = context.Server.MapPath("~/lib/up/temp/");
            string        docTemp         = context.Server.MapPath("~/lib/up/d/");
            string        imgSaveTintuc   = context.Server.MapPath("~/lib/up/tintuc/");
            string        imgSaveSanPham  = context.Server.MapPath("~/lib/up/sanpham/");
            string        imgSaveQuangCao = context.Server.MapPath("~/lib/up/quangcao/");
            string        imgSaveKTNN     = context.Server.MapPath("~/lib/up/KTNN/");

            string _height   = context.Request["height"];
            string _width    = context.Request["width"];
            string _PRowIdSP = context.Request["PRowIdSP"];

            switch (act)
            {
            case "loadPlug":
                #region loadPlug: nap plug
                if (rqPlug != null)
                {
                    sb.Append(PlugHelper.RenderHtml(rqPlug));
                }
                rendertext(sb);
                break;

                #endregion
            case "upload":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, imgten);
                    context.Request.Files[0].SaveAs(imgSaveLoc + imgten + "full" + img.Ext);

                    img.Crop(420, 560);
                    img.Save(imgSaveLoc + imgten + "420x560" + img.Ext);

                    img.Crop(240, 180);
                    img.Save(imgSaveLoc + imgten + "240x180" + img.Ext);

                    img.Crop(100, 100);
                    img.Save(imgSaveLoc + imgten + "100x100" + img.Ext);

                    img.Crop(50, 50);
                    img.Save(imgSaveLoc + imgten + img.Ext);

                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadQuangCao":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveQuangCao + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveQuangCao + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveQuangCao + imgten + "source" + img.Ext);
                    img.Crop(int.Parse(_width), int.Parse(_height));
                    img.Save(imgSaveQuangCao + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadSanPham":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveSanPham + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveSanPham + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(400, 400);
                    img.Save(imgSaveSanPham + imgten + "400x400" + img.Ext);
                    img.Crop(400, 300);
                    img.Save(imgSaveSanPham + imgten + "400x300" + img.Ext);
                    img.Crop(200, 200);
                    img.Save(imgSaveSanPham + imgten + "200x200" + img.Ext);
                    img.Crop(90, 90);
                    img.Save(imgSaveSanPham + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadTintuc":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveTintuc + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveTintuc + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        context.Request.Files[0].SaveAs(imgSaveTintuc + imgten + "full" + img.Ext);
                        img.Crop(180, 120);
                        img.Save(imgSaveTintuc + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadKTNN":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveKTNN + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveKTNN + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(730, 600);
                        img.Save(imgSaveKTNN + imgten + "730x600" + img.Ext);
                        img.Crop(420, 280);
                        img.Save(imgSaveKTNN + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveKTNN + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadFlash":
                #region upload flash
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".swf")
                    {
                        string flash = Guid.NewGuid().ToString();

                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + flash + Path.GetExtension(context.Request.Files[0].FileName));
                        rendertext(flash + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                    else
                    {
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(420, 280);
                        img.Save(imgSaveLoc + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveLoc + imgten + img.Ext);
                        img.Crop(370, 90);
                        img.Save(imgSaveLoc + imgten + "370x90" + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }

                break;

                #endregion
            case "uploadFull":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
                break;

                #endregion
            case "uploadfileDkLuong":
                #region upload tài li?u
                //if (!loggedIn) rendertext("403");
                if (context.Request.Files[0] != null)
                {
                    string foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string filename   = Path.GetFileNameWithoutExtension(context.Request.Files[0].FileName);
                    string fileType   = Path.GetExtension(context.Request.Files[0].FileName);
                    Directory.CreateDirectory(docTemp + foldername);
                    context.Request.Files[0].SaveAs(docTemp + foldername + "/" + filename + fileType);
                    //context.Request.Files[0].SaveAs(docTemp +  filename + fileType);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = fileType;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = filename;
                    item.PID      = Guid.NewGuid();
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = filename;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(item.ID.ToString());
                }
                break;

                #endregion
            case "download":
                string _F_ID = context.Request["ID"];
                if (!string.IsNullOrEmpty(_F_ID))
                {
                    Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                    context.Response.Buffer = true;
                    context.Response.Clear();
                    context.Response.AddHeader("content-disposition", "attachment; filename=\"" + item.Ten + item.MimeType + "\"");
                    context.Response.ContentType = "octet/stream";
                    //Response.ContentType = "application/ms-word";
                    context.Response.WriteFile(context.Server.MapPath("~/lib/up/d/") + item.ThuMuc + "/" + item.Path + item.MimeType);
                }
                break;

            case "uploadvideo":
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten         = Guid.NewGuid().ToString();
                        string strVideoRender = "";
                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        string _hinhanh = "";
                        string fWmv     = "";
                        if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".flv")
                        {
                            fWmv = WMV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");
                            context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + fWmv);
                            _hinhanh = CreatImg(context, fWmv, imgten + Path.GetExtension(context.Request.Files[0].FileName));
                            System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + fWmv);
                        }
                        else
                        {
                            fWmv = FLV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");

                            fWmv     = context.Request.Files[0].FileName;
                            _hinhanh = CreatImg(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        }
                        rendertext(_hinhanh + ";" + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                }

                break;

            case "DelOldFlash":
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + Path.GetExtension(context.Request.Files[0].FileName));
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/i/") + Path.GetExtension(context.Request.Files[0].FileName));
                break;

            case "MultiuploadImg":
                #region UploadAnh
                if (context.Request.Files[0] != null)
                {
                    ImageProcess img        = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    string       foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string       imgten     = Guid.NewGuid().ToString();
                    Directory.CreateDirectory(imgSaveSanPham + foldername);

                    context.Request.Files[0].SaveAs(imgSaveSanPham + foldername + "/" + imgten + "full" + img.Ext);
                    img.Crop(400, 400);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + "400x400" + img.Ext);
                    img.Crop(75, 75);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + img.Ext);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = img.Ext;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = imgten + img.Ext;
                    item.PID      = new Guid(_PRowIdSP);
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = imgten;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item)));
                }
                break;

                #endregion
            case "loadPlugDirect":
                if (!string.IsNullOrEmpty(rqPlug))
                {
                    string _IPlugType = rqPlug;
                    Type   type       = Type.GetType(_IPlugType);
                    IPlug  _IPlug     = (IPlug)(Activator.CreateInstance(type));
                    _IPlug.ImportPlugin();
                    UserControl uc   = (UserControl)(_IPlug);
                    Page        page = new Page();
                    page.EnableViewState = false;
                    HtmlForm form = new HtmlForm();
                    form.ID = "__t";
                    page.Controls.Add(form);
                    form.Controls.Add(uc);
                    StringWriter tw = new StringWriter();
                    HttpContext.Current.Server.Execute(page, tw, true);
                }
                break;

            case "capcha":
                #region capcha
                string _capchaCode = CaptchaImage.GenerateRandomCode(CaptchaType.AlphaNumeric, 3);
                context.Session["capcha"] = _capchaCode;
                CaptchaImage c = new CaptchaImage(_capchaCode, 200, 50, "Tahoma", Color.White, Color.Orange);
                context.Response.ClearContent();
                context.Response.ContentType = "image/jpeg";
                MemoryStream ms = new MemoryStream();
                c.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                context.Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length));
                ms.Close();
                context.Response.End();
                break;

                #endregion
            default:
                #region macdinh
                context.Response.Write(DateTime.Now.ToString("hh:mm"));
                break;
                #endregion
            }
        }
Example #5
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            string _ID             = Request["ID"];
            string _PID            = Request["PID"];
            string _Ten            = Request["Ten"];
            string _Mota           = Request["Mota"];
            string _Ma             = Request["Ma"];
            string _Url            = Request["Url"];
            string _GiaTriMacDinh  = Request["GiaTriMacDinh"];
            string _Loai           = Request["Loai"];
            string _ThuTu          = Request["ThuTu"];
            string _Publish        = Request["Publish"];
            string _Anh            = Request["Anh"];
            string _Desk           = Request["Desk"];
            string _DeskMacDinh    = Request["DeskMacDinh"];

            switch (subAct)
            {
            case "get":
                #region lấy danh sách
                List <Function> ListGet = getTree(FunctionDal.SelectTree(Request["q"]));
                List <jgridRow> ListRow = new List <jgridRow>();
                foreach (Function item in ListGet)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                        item.ID.ToString()
                        , item.Ten
                        , item.Loai != 3 ? string.Format("<img class=\"adm-fn-icon\" src=\"../up/i/{0}\" />", string.IsNullOrEmpty(item.Anh) ? "fn-icon.jpg" :item.Anh) : ""
                        , item.Ma
                        , item.Url
                        , item.ThuTu.ToString()
                        , item.Loai.ToString()
                        , item.Publish.ToString()
                        , item.GiaTriMacDinh.ToString()
                        , item.Level.ToString(), item.PID.ToString(), "true", "false"
                    }));
                }
                jgrid grid = new jgrid("1", "1", ListGet.Count.ToString(), ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(grid));
                break;

                #endregion
            case "getPid":
                #region danh sách chọn sẵn
                FunctionCollection ListGetPid = FunctionDal.SelectTree(Request["q"]);
                sb.Append(JavaScriptConvert.SerializeObject(ListGetPid));
                break;

                #endregion
            case "del":
                #region Xóa
                if (!string.IsNullOrEmpty(_ID))
                {
                    FunctionDal.DeleteById(Convert.ToInt32(_ID));
                }
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(_ID))
                {
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(FunctionDal.SelectById(Convert.ToInt32(_ID))));
                }
                break;

                #endregion
            case "save":
                #region lưu dữ liệu
                Function ItemSave = new Function();
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = FunctionDal.SelectById(Convert.ToInt32(_ID));
                }
                ItemSave.NgayCapNhat = DateTime.Now;
                ItemSave.Ten         = _Ten;
                ItemSave.MoTa        = _Mota;
                ItemSave.Loai        = Convert.ToInt16(_Loai);
                ItemSave.Ma          = _Ma;
                ItemSave.Anh         = string.Empty;
                int ThuTu = 0;
                if (!string.IsNullOrEmpty(_ThuTu))
                {
                    ThuTu = Convert.ToInt32(_ThuTu);
                }
                ItemSave.Publish       = Convert.ToBoolean(_Publish);
                ItemSave.PID           = string.IsNullOrEmpty(_PID) ? 0 : Convert.ToInt32(_PID);
                ItemSave.ThuTu         = ThuTu;
                ItemSave.Url           = _Url;
                ItemSave.NguoiTao      = Security.Username;
                ItemSave.GiaTriMacDinh = Convert.ToBoolean(_GiaTriMacDinh);
                ItemSave.Anh           = _Anh;
                ItemSave.Desk          = Convert.ToBoolean(_Desk);
                ItemSave.DeskMacDinh   = Convert.ToBoolean(_DeskMacDinh);
                if (ItemSave.Desk)
                {
                    try
                    {
                        //ItemSave.Doc = ;
                        XmlDocument doc  = new XmlDocument();
                        XmlNode     node = doc.ImportNode(PlugHelper.RenderXml(ItemSave.Url), true);
                        doc.AppendChild(node);
                        string _DocValue = linh.common.Lib.GetXmlString(doc);
                        ItemSave.Doc = _DocValue;
                    }
                    catch (Exception ex)
                    {
                        ItemSave.Doc  = string.Empty;
                        ItemSave.Desk = false;
                        sb.Append("Loi + " + ex.Message);
                    }
                }
                else
                {
                    ItemSave.Doc = string.Empty;
                }
                if (!string.IsNullOrEmpty(_ID))
                {
                    ItemSave = FunctionDal.Update(ItemSave);
                }
                else
                {
                    ItemSave.NgayTao = DateTime.Now;
                    ItemSave.Level   = 0;
                    ItemSave.PIDList = string.Empty;
                    ItemSave.RowId   = Guid.NewGuid();
                    ItemSave         = FunctionDal.Insert(ItemSave);
                }
                sb.Append("1");
                break;

                #endregion
            default:
                #region nạp
                FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                //<input type=""text"" class=""mdl-head-txt mdl-head-search"" />
                sb.Append(@"<div class=""mdl-head"">
<span class=""mdl-head-searchPnl ui-state-default ui-corner-all"">
<a href=""javascript:;"" class=""mdl-head-clearSearch""></a>
<input type=""text"" class=""mdl-head-txt mdl-head-search mdl-head-search-functions"" />
</span>
<a class=""mdl-head-btn mdl-head-add"" id=""functionsmdl-addBtn"" href=""javascript:functions.add();"">Thêm</a>
<a class=""mdl-head-btn mdl-head-edit"" id=""functionsmdl-editBtn"" href=""javascript:functions.edit();"">Sửa</a>
<a class=""mdl-head-btn mdl-head-del"" id=""functionsmdl-delBtn"" href=""javascript:functions.del();"">Xóa</a>
</div>
<table id=""functionsmdl-List"" class=""mdl-list"">
</table>
<div id=""functionsmdl-Pager""></div>");
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.hethong.functions.JScript1.js")
                                , "{functions.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();

        string imgSaveLoc    = Server.MapPath("~/lib/up/i/");
        string imgSaveTintuc = Server.MapPath("~/lib/up/tintuc/");
        string imgTemp       = Server.MapPath("~/lib/up/temp/");
        string docTemp       = Server.MapPath("~/lib/up/d/");
        bool   loggedIn      = Security.IsAuthenticated();

        insertLog("0", Security.Username, Request.UserHostAddress, Request.Url.PathAndQuery);
        switch (act)
        {
        case "loadPlug":
            if (rqPlug != null)
            {
                sb.Append(PlugHelper.RenderHtml(rqPlug));
            }
            rendertext(sb);
            break;

        case "upload":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(730, 600);
                    img.Save(imgSaveLoc + imgten + "730x600" + img.Ext);
                    img.Crop(420, 280);
                    img.Save(imgSaveLoc + imgten + "420x280" + img.Ext);
                    img.Crop(130, 100);
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadTintuc":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(730, 600);
                    img.Save(imgSaveTintuc + imgten + "730x600" + img.Ext);
                    img.Crop(420, 280);
                    img.Save(imgSaveTintuc + imgten + "420x280" + img.Ext);
                    img.Crop(130, 100);
                    img.Save(imgSaveTintuc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadFull":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadfileDkLuong":
            #region upload tài liệu
            if (!loggedIn)
            {
                rendertext("403");
            }
            if (Request.Files[0] != null)
            {
                string foldername = Guid.NewGuid().ToString().Replace("-", "");
                string filename   = Path.GetFileNameWithoutExtension(Request.Files[0].FileName);
                string fileType   = Path.GetExtension(Request.Files[0].FileName);
                Directory.CreateDirectory(docTemp + foldername);
                Request.Files[0].SaveAs(docTemp + foldername + "/" + filename + fileType);
                Files item = new Files();
                item.Download = 0;
                item.MimeType = fileType;
                item.NgayTao  = DateTime.Now;
                item.NguoiTao = Security.Username;
                item.Path     = filename;
                item.PID      = Guid.NewGuid();
                item.RowId    = Guid.NewGuid();
                item.Size     = Request.Files[0].ContentLength;
                item.Ten      = filename;
                item.ThuMuc   = foldername;
                item.VB_ID    = 0;
                item          = FilesDal.Insert(item);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "download":
            string _F_ID = Request["ID"];
            if (!string.IsNullOrEmpty(_F_ID))
            {
                Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                Response.Buffer = true;
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment; filename=\"" + item.Ten + item.MimeType + "\"");
                Response.ContentType = "octet/stream";
                //Response.ContentType = "application/ms-word";
                Response.WriteFile(Server.MapPath("~/lib/up/d/") + item.ThuMuc + "/" + item.Path + item.MimeType);
            }
            break;

        case "loadPlugDirect":
            if (!string.IsNullOrEmpty(rqPlug))
            {
                string _IPlugType = rqPlug;
                Type   type       = Type.GetType(_IPlugType);
                IPlug  _IPlug     = (IPlug)(Activator.CreateInstance(type));
                _IPlug.ImportPlugin();
                Page        pageHolder = new Page();
                UserControl uc         = (UserControl)(_IPlug);
                this.Controls.Add(uc);
            }
            break;

        case "uploadvideo":

            break;

        default:
            string d = "12/9/2010";
            //DateTime da = Convert.ToDateTime(d, new System.Globalization.CultureInfo("vi-Vn"));
            //Response.Write(da.Month.ToString());
            Response.Write(maHoa.EncryptString("111", "phatcd"));
            break;
        }
    }
Example #7
0
 public virtual void LoadSetting(object[] obj)
 {
     PlugHelper.LoadSettings(obj, this);
 }
Example #8
0
 public virtual void LoadSetting(XmlNode SettingNode)
 {
     TargetPage = GetSetting("TargetPage", SettingNode);
     PlugHelper.LoadSettings(SettingNode, this);
 }
Example #9
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder       sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            string subAct          = Request["subAct"];

            switch (subAct)
            {
            case "menu":
                //List<Function> MenuList = getTree(FunctionDal.SelectByUser(Security.Username));
                //List<jgridRow> ListRow = new List<jgridRow>();
                //foreach (Function fn in MenuList)
                //{
                //    if (fn.Loai != 3)
                //    {
                //        ListRow.Add(new jgridRow(fn.ID.ToString(), new string[] { fn.ID.ToString(), fn.Ten, fn.Url, fn.Level.ToString(), fn.PID.ToString(), fn.Level == 1 ? "false" : "true", "false" }));
                //    }
                //}
                //jgrid grid = new jgrid("1", "1", MenuList.Count.ToString(), ListRow);
                //sb.Append(JavaScriptConvert.SerializeObject(grid));
                sb.AppendFormat(getTop(getTree(FunctionDal.SelectByUser(Security.Username, "0"))));
                break;

            case "desk":
                sb.AppendFormat(@"<script src=""{0}"" type=""text/javascript""></script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.plugManager.admin.js"));
                sb.AppendFormat(@"<div id=""desktopMdl-content-head"">
                    <a href=""javascript:;"" id=""desktopMdl-content-head-showbtn"">
                    <span id=""desktopMdl-content-head-showbtn-title"" class=""ui-widget-content ui-corner-top"">
                    Thêm Module
                    </span>
                    <span id=""desktopMdl-content-head-showbtn-box"">
                        <span class=""ui-widget-content ui-corner-all"" id=""desktopMdl-content-head-showbtn-boxPnl"">
                            <span class=""ui-widget-content ui-corner-all"" id=""desktopMdl-content-head-showbtn-boxPnl-content"">");

                FunctionCollection UFC = FunctionDal.SelectByUser(Security.Username, "1");
                foreach (Function ufcItem in UFC)
                {
                    sb.AppendFormat(@"<span onclick=""myModule.add('{0}','{1}')"" class=""desktopMdl-content-head-showbtn-boxPnl-content-item""><span onclick=""myModule.add('{0}','{1}')"" class=""desktopMdl-content-button-add"">Add</span>{2}</span>", ufcItem.ID, ufcItem.Url, ufcItem.Ten);
                }
                sb.AppendFormat(@"</span>
                        </span>
                    </span>
                    </a>");
                Member mMember = MemberDal.SelectAllByUserName(Security.Username);

                sb.AppendFormat(@"<b id=""desktopMdl-content-head-title"">Phiên làm việc: {0} <span id=""desktopMdl-content-head-date"">{1}</span></b>
                </div>", mMember.Ten.ToString(), string.Format("{0:dd/MM/yyyy}", DateTime.Now));
                sb.AppendFormat(@"<div id=""desktopMdl-content-body"">");
                sb.Append("</div>");
                break;

            case "Update":
                if (!string.IsNullOrEmpty(Request["layplug"]))
                {
                    string      layplug = Request["layplug"];
                    XmlDocument doc     = new XmlDocument();
                    XmlNode     node    = doc.ImportNode(PlugHelper.RenderXml(toList(Request["iList"]), Request["plugtype"]), true);
                    doc.AppendChild(node);
                    UserFunction itemUpdate = UserFunctionDal.SelectById(Convert.ToInt32(layplug));
                    itemUpdate.Doc = linh.common.Lib.GetXmlString(doc);
                    itemUpdate     = UserFunctionDal.Update(itemUpdate);
                    sb.Append(PlugHelper.RenderHtml(doc));
                }
                break;

            case "ReOrder":
                if (!string.IsNullOrEmpty(Request["NewZoneIndex"]))
                {
                    string       layplug    = Request["layplug"];
                    string       layid      = Request["NewZoneIndex"];
                    UserFunction itemUpdate = UserFunctionDal.SelectById(Convert.ToInt32(layplug));
                    itemUpdate.LAY_ID = Convert.ToInt32(layid);
                    itemUpdate.ThuTu  = Convert.ToInt32(Request["NewModuleIndex"]);
                    itemUpdate        = UserFunctionDal.Update(itemUpdate);
                    UserFunctionDal.UpdateReorder(Request["NewZoneOrderList"]);
                }
                break;

            case "Remove":
                if (!string.IsNullOrEmpty(Request["layplug"]))
                {
                    string       layplug    = Request["layplug"];
                    UserFunction itemRemove = UserFunctionDal.SelectById(Convert.ToInt32(layplug));
                    UserFunctionDal.DeleteById(itemRemove.ID);
                }
                break;

            case "Add":
                string _FN_ID    = Request["FN_ID"];
                string _Url      = Request["Url"];
                string _LayID    = Request["LayID"];
                string _DocValue = "";
                try
                {
                    XmlDocument doc  = new XmlDocument();
                    XmlNode     node = doc.ImportNode(PlugHelper.RenderXml(_Url), true);
                    doc.AppendChild(node);
                    _DocValue = linh.common.Lib.GetXmlString(doc);
                    UserFunction ItemSave = new UserFunction();
                    ItemSave.FN_ID    = Convert.ToInt32(_FN_ID);
                    ItemSave.FN_Url   = _Url;
                    ItemSave.LAY_ID   = Convert.ToInt32(_LayID);
                    ItemSave.NgayTao  = DateTime.Now;
                    ItemSave.NguoiTao = Security.Username;
                    ItemSave.Username = Security.Username;
                    ItemSave.ThuTu    = 1;
                    ItemSave.RowId    = Guid.NewGuid();
                    ItemSave.Doc      = _DocValue;
                    ItemSave          = UserFunctionDal.Insert(ItemSave);

                    sb.Append(PlugHelper.RenderHtml(doc.LastChild, ItemSave.ID));
                }
                catch (Exception ex)
                {
                }
                break;

            default:
                break;
            }
            sb.AppendFormat(@"<script src=""{0}"" type=""text/javascript""></script>"
                            , cs.GetWebResourceUrl(typeof(Class1), "docsoft.plugin.plugManager.admin.js"));
            writer.Write(sb.ToString());
            base.Render(writer);
        }