/// <summary>
        /// Handles Click event for cmdUpdate button
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try {
                var ctrl = new DocumRollerController ();
                DocumRollerInfo item;

                // determine if we are adding or updating
                // ALT: if (Null.IsNull (itemId))
                if (!itemId.HasValue) {
                    // TODO: populate new object properties with data from controls
                    // to add new record
                    item = new DocumRollerInfo ();
                    item.Content = txtContent.Text;
                    item.ModuleID = this.ModuleId;

                    ctrl.Add<DocumRollerInfo> (item);
                } else {
                    // TODO: update properties of existing object with data from controls
                    // to update existing record
                    item = ctrl.Get<DocumRollerInfo> (itemId.Value, this.ModuleId);
                    item.Content = txtContent.Text;

                    ctrl.Update<DocumRollerInfo> (item);
                }

                Response.Redirect (Globals.NavigateURL (), true);
            } catch (Exception ex) {
                Exceptions.ProcessModuleLoadException (this, ex);
            }
        }
 /// <summary>
 /// Handles Click event for cmdDelete button
 /// </summary>
 /// <param name='sender'>
 /// Sender.
 /// </param>
 /// <param name='e'>
 /// Event args.
 /// </param>
 protected void cmdDelete_Click(object sender, EventArgs e)
 {
     try {
         // ALT: if (!Null.IsNull (itemId))
         if (itemId.HasValue) {
             var ctrl = new DocumRollerController ();
             ctrl.Delete<DocumRollerInfo> (itemId.Value);
             Response.Redirect (Globals.NavigateURL (), true);
         }
     } catch (Exception ex) {
         Exceptions.ProcessModuleLoadException (this, ex);
     }
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //throw (new Exception("I'm working!"));
            if (!IsPostBack)
            {
                #region RSS OPTIONS
                /*
                if (!String.IsNullOrEmpty(Request.QueryString["records"]))
                {
                    records = int.Parse(Request.QueryString["records"]);
                }*/
                // PortalSettings.PortalAlias;
                string title = new ModuleController().GetTabModule(TabModuleId).ModuleTitle;
                string description = "descr";

                var settings = new DocumRollerSettings (this.ModuleId, this.TabModuleId);
                int records = settings.ItemToShow;

            //int.TryParse((string)Settings["rss_records"], out records);

                // определяем язык запроса
                // PortalSettings.CultureCode
                string language = PortalSettings.CultureCode; // язык по-умолчанию - русский
                /*
                if (!String.IsNullOrEmpty(Request.QueryString["language"]))
                    language = Request.QueryString["language"].ToLower();
                */
                #endregion

                if (records > 0)
                {
                    // проверяем, существует ли директория с кешем rss
                    // если нет, создаем
                    //string rss_dname = Path.Combine(PortalSettings.HomeDirectoryMapPath, "Cache");
                    //if (!Directory.Exists(rss_dname))
                    //	Directory.CreateDirectory(rss_dname);

                    //Directory.SetCurrentDirectory(rss_dname);

                    // формируем имя файла кеша rss для нашего модуля
                    /*string rssfile_fullname = Path.Combine(
                        rss_dname,
                        String.Format("Feed_{0}.rss", ModuleId));
            */
                    // устанавливаем, нужно ли обновлять rss канал?
                    // в данном случае время устаревания - cachetime часов
            /*					bool
                        need_regen = !File.Exists(rssfile_fullname);
                    if (!need_regen) need_regen =
                        // актуальность канала - cachetime часов
                        File.GetLastWriteTime(rssfile_fullname) + new TimeSpan(cachetime, 0, 0) < DateTime.Now;

                    // для отладки!!!
                    //need_regen = true;

            */					// если нужна перегенерация, формируем xml-файл в кеше rss
                    //if (true) //need_regen)
                    {
                        var ctrl = new DocumRollerController ();
                        //var items = ctrl.GetList<DocumRollerInfo> (this.ModuleId);
                        var docrollers = ctrl.GetObjects<DocRollerInfo> (System.Data.CommandType.StoredProcedure,
                                                                         "dbo.Aggregator_GetContent" , settings.ItemToShow, settings.SortOrder);

                    string rss_dname = Path.Combine(PortalSettings.HomeDirectoryMapPath, "Cache");
                    if (!Directory.Exists(rss_dname))
                        Directory.CreateDirectory(rss_dname);

                    // формируем имя файла кеша rss для нашего модуля
                    string rssfile_fullname = Path.Combine(
                        rss_dname,
                        String.Format("Feed_{0}.xml", ModuleId));

                        File.WriteAllText(rssfile_fullname, ToRss(docrollers, language, title, description));

                        Response.Redirect("http://" + PortalSettings.PortalAlias.HTTPAlias +
                            "/Portals/"+ PortalId +"/Cache/" + string.Format("Feed_{0}.xml", ModuleId), true);
                        // labe.11st.Text = Server.HtmlEncode(ToRss (language, title, description));
                    /*
                        Response.Clear ();
                        Response.ContentType = "application/rss+xml";
                        Response.Write (ToRss(docrollers, language, title, description));
                        Response.Flush ();
                        Response.Close ();*/

                    }
                }
            }
        }
        /// <summary>
        /// Handles Page_Load event for a control
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                // parse querystring parameters
                int tmpItemId;
                if (int.TryParse (Request.QueryString ["AggregatorID"], out tmpItemId))
                    itemId = tmpItemId;

                if (!IsPostBack) {
                    // load the data into the control the first time we hit this page

                    cmdDelete.Attributes.Add ("onClick", "javascript:return confirm('" + Localization.GetString ("DeleteItem") + "');");

                    // check we have an item to lookup
                    // ALT: if (!Null.IsNull (itemId)
                    if (itemId.HasValue) {
                        // load the item
                        var ctrl = new DocumRollerController ();
                        var item = ctrl.Get<DocumRollerInfo> (itemId.Value, this.ModuleId);

                        if (item != null) {
                            // TODO: Fill controls with data
                            txtContent.Text = item.Content;

                            // setup audit control

                            ctlAudit.CreatedDate = item.CreatedOnDate.ToLongDateString ();
                            ctlAudit.LastModifiedDate = item.LastModifiedOnDate.ToLongDateString ();
                        } else
                            Response.Redirect (Globals.NavigateURL (), true);
                    } else {
                        cmdDelete.Visible = false;
                        ctlAudit.Visible = false;
                    }
                }
            } catch (Exception ex) {
                Exceptions.ProcessModuleLoadException (this, ex);
            }
        }
        /// <summary>
        /// Handles Page_Load event for a control
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                if (!IsPostBack) {

                    linkRss.NavigateUrl = EditUrl("Rss");

                    var ctrl = new DocumRollerController ();
                    //var items = ctrl.GetList<DocumRollerInfo> (this.ModuleId);
                    var settings = new DocumRollerSettings (this.ModuleId, this.TabModuleId);
                    var docrollers = ctrl.GetObjects<DocRollerInfo> (System.Data.CommandType.StoredProcedure,
                               "dbo.Aggregator_GetContent" , settings.ItemToShow, settings.SortOrder);

                    // check if we have some content to display,
                    // otherwise display a sample default content from the resources
                    /*if (items.Count == 0) {
                        var item = new DocumRollerInfo () {
                            ModuleID = this.ModuleId,
                            CreatedByUser = this.UserId,
                            Content = Localization.GetString ("DefaultContent", LocalResourceFile)
                        };

                        items.Add (item);
                    }*/

                    // bind the data
                    lstContent.DataSource = docrollers;
                    lstContent.DataBind ();
                }
            } catch (Exception ex) {
                Exceptions.ProcessModuleLoadException (this, ex);
            }
        }