protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (fUpload.HasFile && fUpload.PostedFile.ContentType.IndexOf("image") > -1)
            {
                string fileName  = HttpUtility.UrlDecode(fUpload.FileName);
                string directory = HttpUtility.UrlDecode(Server.MapPath(PrefixURL + DateTime.Now.ToString("yyyy/MM/dd/")));
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                fUpload.SaveAs(directory + fileName);

                PortalDefinition.Module module = new PortalDefinition.Module();
                module.reference = ModuleRef;
                module.type      = ModuleType;
                module.LoadRuntimeProperties();
                string oldValue = module.moduleRuntimeSettings.GetRuntimePropertyValue(true, "pictureurl");
                if (string.IsNullOrEmpty(oldValue))
                {
                    module.moduleRuntimeSettings.SetRuntimePropertyValue(true, "pictureurl", DateTime.Now.ToString("yyyy/MM/dd/") + fileName);
                }
                else
                {
                    module.moduleRuntimeSettings.SetRuntimePropertyValue(true, "pictureurl", oldValue + seprator + DateTime.Now.ToString("yyyy/MM/dd/") + fileName);
                }
                module.SaveRuntimeSettings();
            }
            bindForm();
            ((Portal.GUI.EditoralOffice.MainOffce.editnews.editModule) this.Page).loadPresentationModule(ModuleType, ModuleRef);
        }
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            LoadRuntimeSettings();
            object runtimesetting = ReadRuntimeConfig(true, "pictureurl");

            if (runtimesetting != null && runtimesetting.ToString() != string.Empty)
            {
                string strRuntimeSetting = runtimesetting.ToString();
                string arg = ((Button)sender).CommandArgument;
                strRuntimeSetting = strRuntimeSetting.Replace(arg, string.Empty);
                if (strRuntimeSetting.StartsWith(seprator))
                {
                    strRuntimeSetting = strRuntimeSetting.Substring(seprator.Length);
                }
                if (strRuntimeSetting.EndsWith(seprator))
                {
                    strRuntimeSetting = strRuntimeSetting.Substring(0, strRuntimeSetting.Length - seprator.Length);
                }
                strRuntimeSetting = strRuntimeSetting.Replace(seprator + seprator, string.Empty);

                string[]  pictureurls = strRuntimeSetting.Split(new string[] { seprator }, StringSplitOptions.RemoveEmptyEntries);
                DataTable tbl         = new DataTable();
                DataRow   row;
                tbl.Columns.Add("PictureURL");
                for (int i = 0; i < pictureurls.Length; i++)
                {
                    row    = tbl.NewRow();
                    row[0] = pictureurls.GetValue(i);
                    tbl.Rows.Add(row);
                }
                rptSlideshow.DataSource = tbl;
                rptSlideshow.DataBind();



                PortalDefinition.Module module = new PortalDefinition.Module();
                module.reference = ModuleRef;
                module.type      = ModuleType;
                module.LoadRuntimeProperties();
                module.moduleRuntimeSettings.SetRuntimePropertyValue(true, "pictureurl", strRuntimeSetting);
                module.SaveRuntimeSettings();

                // delete file
                if (File.Exists(Server.MapPath(PrefixURL + arg)))
                {
                    try
                    {
                        File.Delete(Server.MapPath(PrefixURL + arg));
                    }
                    catch { }
                }
            }
            ((Portal.GUI.EditoralOffice.MainOffce.editnews.editModule) this.Page).loadPresentationModule(ModuleType, ModuleRef);
        }
Esempio n. 3
0
        /// <summary>
        /// Lưu các thiết lập của Module
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnSave(object sender, EventArgs args)
        {
            try
            {
                if (Page.IsValid)
                {
                    // Nạp cấu trúc Portal
                    PortalDefinition     pd = PortalDefinition.Load();
                    PortalDefinition.Tab t  = pd.GetTab(CurrentTabReference);
                    // Truy xuất đến cấu trúc Module hiện thời
                    PortalDefinition.Module m = t.GetModule(CurrentReference);

                    // Thay đổi các thông số tương ứng
                    m.reference = txtReference.Text;
                    m.title     = HttpUtility.HtmlEncode(txtTitle.Text);
                    m.type      = cboPath.SelectedValue + "/" + cbType.SelectedItem.Value;
                    m.roles     = RolesCtrl.GetData();
                    m.CacheTime = Convert.ToInt32(txtCacheTime.Text);

                    // Lưu các thông số và cấu trúc
                    pd.Save();

                    // Lưu các thông số khi thực thi của module
                    m.LoadModuleSettings();
                    m.LoadRuntimeProperties();
                    for (int _intPropertyCount = 0; _intPropertyCount < rptRuntimeProperties.Items.Count; _intPropertyCount++)
                    {
                        HtmlInputHidden _hihPropertyName   = rptRuntimeProperties.Items[_intPropertyCount].FindControl("lblPropertyName") as HtmlInputHidden;
                        TextBox         _txtPropertyValue  = rptRuntimeProperties.Items[_intPropertyCount].FindControl("txtPropertyValue") as TextBox;
                        DropDownList    _drdAvaiableValues = rptRuntimeProperties.Items[_intPropertyCount].FindControl("drdAvaiableValues") as DropDownList;

                        if (_hihPropertyName != null && _txtPropertyValue != null)
                        {
                            string _strPropertyValue = _txtPropertyValue.Visible ? _txtPropertyValue.Text : _drdAvaiableValues.SelectedValue;
                            m.moduleRuntimeSettings.SetRuntimePropertyValue(true, _hihPropertyName.Value, _strPropertyValue);
                        }
                    }
                    m.SaveRuntimeSettings();

                    CurrentReference = m.reference;

                    // Phát sinh sự kiện lưu thông tin thành công
                    if (Save != null)
                    {
                        Save(this, new EventArgs());
                    }
                }
            }
            catch (Exception e)
            {
                lbError.Text = e.Message;
            }
        }
        protected void btnSaveModule_Click(object sender, EventArgs e)
        {
            string tab = (string)ViewState["TabReference"];

            PortalDefinition.Module module;

            string arg         = Request.Form["pageArg"];
            string moduleRef   = string.Empty;
            string moduleType  = string.Empty;
            string moduleTitle = string.Empty;
            string columnRef   = string.Empty;

            if (arg.Split("$".ToCharArray()).Length == 4)
            {
                moduleRef   = arg.Split("$".ToCharArray())[0];
                moduleType  = arg.Split("$".ToCharArray())[1];
                moduleTitle = arg.Split("$".ToCharArray())[2];
                columnRef   = arg.Split("$".ToCharArray())[3];
            }
            else
            {
                return;
            }

            if (string.IsNullOrEmpty(moduleRef))
            {
                return;
            }

            module           = new PortalDefinition.Module();
            module.reference = moduleRef;
            module.type      = moduleType;

            if (module != null)
            {
                // Lưu các thông số khi thực thi của module
                module.LoadModuleSettings();
                module.LoadRuntimeProperties();
                for (int _intPropertyCount = 0; _intPropertyCount < rptRuntimeProperties.Items.Count; _intPropertyCount++)
                {
                    HtmlInputHidden _hihPropertyName   = rptRuntimeProperties.Items[_intPropertyCount].FindControl("lblPropertyName") as HtmlInputHidden;
                    TextBox         _txtPropertyValue  = rptRuntimeProperties.Items[_intPropertyCount].FindControl("txtPropertyValue") as TextBox;
                    DropDownList    _drdAvaiableValues = rptRuntimeProperties.Items[_intPropertyCount].FindControl("drdAvaiableValues") as DropDownList;

                    if (_hihPropertyName != null && _txtPropertyValue != null)
                    {
                        string _strPropertyValue = _txtPropertyValue.Visible ? _txtPropertyValue.Text : _drdAvaiableValues.SelectedValue;
                        module.moduleRuntimeSettings.SetRuntimePropertyValue(true, _hihPropertyName.Value, _strPropertyValue);
                    }
                }
                module.SaveRuntimeSettings();
            }
        }