예제 #1
0
        protected void btnConnect_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                switch (_module.SelectedValue.ToLower().Trim())
                {
                case "contents":
                    LoadCurrentContentList();
                    LoadRemoteContentList();
                    PopulateRemoteContents();
                    PopulateCurrentContents();
                    break;

                case "resourcegroups":
                    break;

                case "resources":
                    break;
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errorMessage += "<br/>" +
                                    ex.InnerException.Message;
                }
                AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.ERROR, errorMessage);
            }
        }
예제 #2
0
        protected void btnDeleteContentForm__Click(object sender, ImageClickEventArgs e)
        {
            _contentLib.Delete(Convert.ToInt64(_contentId.Text));
            ResetContentControls();
            PopulateFields(Convert.ToInt64(_formFeature_formId.Text), 0);
            PopulateChildContentList(Convert.ToInt64(_formFeature_contentId.Text));

            AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.INFO, "Content has been deleted.");
        }
예제 #3
0
        protected void btnSaveContentForm__Click(object sender, ImageClickEventArgs e)
        {
            long   id          = _contentId.Text.Trim() == "" ? 0 : Convert.ToInt64(_contentId.Text);
            string cultureCode = App_Code.SessionInfo.CurrentSite.cultureCode;

            awContent content    = new awContent();
            bool      newContent = false;

            try
            {
                if (id == 0)    //Add new content
                {
                    newContent = true;
                    id         = AWAPI_Common.library.MiscLibrary.CreateUniqueId();
                }
                else    //update the content
                {
                    content = _contentLib.Get(id);
                    if (content == null)
                    {
                        AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.ERROR, "Content not found.");
                        return;
                    }
                }

                content.siteId = App_Code.SessionInfo.CurrentSite.siteId;
                content.userId = App_Code.SessionInfo.CurrentUser.userId;

                #region SAVE CONTENT STATIC VALUES
                //SAVE THE CONTENT, FIRST (STATIC VALUES ONLY ) ----------------------------------------------
                foreach (GridViewRow gr in _contentFieldList.Rows)
                {
                    Boolean isCustomField           = ((CheckBox)gr.FindControl("_isContentCustomField")).Checked;
                    string  fieldName               = ((Literal)gr.FindControl("_title")).Text.ToLower().Trim();
                    string  fieldType               = ((Literal)gr.FindControl("_fieldType")).Text.ToLower();
                    Literal tmpContentCustomFieldId = (Literal)gr.FindControl("_contentCustomFieldId");
                    long    contentCustomFieldId    = (tmpContentCustomFieldId.Text == "" || tmpContentCustomFieldId.Text == "0") ?
                                                      0 : Convert.ToInt64(tmpContentCustomFieldId.Text);

                    TextBox  txb = (TextBox)gr.FindControl("_editBox");
                    CheckBox cb  = (CheckBox)gr.FindControl("_checkBox");

                    if (!newContent && isCustomField && contentCustomFieldId > 0)
                    {
                        _customLib.UpdateFieldValue(id, contentCustomFieldId, App_Code.SessionInfo.CurrentUser.userId,
                                                    txb.Text, cultureCode);
                    }
                    else
                    {
                        SetContentStaticValues(fieldName, txb.Text, cb.Checked, content);
                    }
                }
                #endregion

                if (content.alias == null || content.alias.Trim() == "")
                {
                    if (content.title.Trim() != "")
                    {
                        content.alias = AWAPI_Common.library.MiscLibrary.FormatAliasName(content.title);
                    }
                    else
                    {
                        content.alias = AWAPI_Common.library.MiscLibrary.FormatAliasName(_formTitle.Text.Trim() + "_" + id.ToString());
                    }
                }


                #region ADD or UPDATE CONTENT
                if (newContent)
                {
                    content.parentContentId = 0;
                    if (_formFeature_applyToSub.Checked && _formFeature_contentId.Text != "")
                    {
                        content.parentContentId = Convert.ToInt64(_formFeature_contentId.Text);
                    }

                    id = _contentLib.Add(id, content.alias, content.title, content.description,
                                         content.contentType, content.siteId, content.userId, content.parentContentId,
                                         content.eventStartDate, content.eventEndDate,
                                         content.link, content.imageurl, content.sortOrder, content.isEnabled, content.isCommentable,
                                         content.pubDate, content.pubEndDate);
                    _contentId.Text = id.ToString();
                }
                else
                {
                    _contentLib.Update(id, content.alias, content.title, content.description,
                                       content.contentType, content.userId, content.parentContentId,
                                       content.eventStartDate, content.eventEndDate,
                                       content.link, content.imageurl, content.sortOrder, content.isEnabled, content.isCommentable,
                                       content.pubDate, content.pubEndDate);
                }
                #endregion

                #region SAVE CONTENT CUSTOM FIELDS
                //SAVE THE CUSTOM FIELDS
                foreach (GridViewRow gr in _contentFieldList.Rows)
                {
                    Boolean isCustomField           = ((CheckBox)gr.FindControl("_isContentCustomField")).Checked;
                    Literal tmpContentCustomFieldId = (Literal)gr.FindControl("_contentCustomFieldId");
                    long    contentCustomFieldId    = (tmpContentCustomFieldId.Text == "" || tmpContentCustomFieldId.Text == "0") ?
                                                      0 : Convert.ToInt64(tmpContentCustomFieldId.Text);

                    if (!isCustomField || contentCustomFieldId <= 0)
                    {
                        continue;
                    }

                    string   fieldType = ((Literal)gr.FindControl("_fieldType")).Text.ToLower();
                    TextBox  txb       = (TextBox)gr.FindControl("_editBox");
                    CheckBox cb        = (CheckBox)gr.FindControl("_checkBox");

                    string value = txb.Text;
                    if (fieldType == "checkbox")
                    {
                        value = cb.Checked.ToString();
                    }

                    _customLib.UpdateFieldValue(id, contentCustomFieldId, App_Code.SessionInfo.CurrentUser.userId,
                                                value, cultureCode);
                }
                #endregion


                PopulateFields(Convert.ToInt64(_formFeature_formId.Text), id);

                if (_formFeature_applyToSub.Checked)
                {
                    PopulateChildContentList(Convert.ToInt64(_formFeature_contentId.Text));
                }

                AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.INFO, "Content has been saved.");
            }
            catch (Exception ex)
            {
                AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.ERROR, ex.Message);
            }
        }