예제 #1
0
    public bool EditArticleByArticleId(string requestParam,out string OutCurrentPageNo,out string OutCurrentMenuCategory,out string OutCurrentTagNids)
    {
        bool RetVal = false;
        string[] Params;
        CMSHelper Helper = new CMSHelper();
        string ContentSummary = string.Empty;
        string ContentTitle = string.Empty;
        string ContentDate = string.Empty;
        string ContentImgUrl = string.Empty;
        string UserEmailID = string.Empty;
        string DatabaseLanguage = string.Empty;
        string UserName = string.Empty;
        string CurrentDbLangCode = string.Empty;
        string ArticleTags = string.Empty;
        string MenuCategory = string.Empty;
        string ContentDescription = string.Empty;
        string ContentTag = string.Empty;
        DataContent RetValContent = null;
        int ContentId = 0;
        int ContentTagNid = 0;
        int ExistingTagNid = 0;
        string ContentPdfFileUrl = string.Empty;
        CMSHelper ObjCMSHelper = null;
        SqlDateTime SqlDtTime;
        bool IsContentUpdated = false;
        try
        {
            SqlDtTime = new SqlDateTime();
            ObjCMSHelper = new CMSHelper();
            // Check if session is having nid for loggedin Admin
            if (!string.IsNullOrEmpty(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUserNId].ToString()))
            {// get user email
                UserEmailID = Global.Get_User_EmailId_ByAdaptationURL(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUserNId].ToString());
            }
            // Check if session is having username for loggedin Admin
            if (!string.IsNullOrEmpty(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUser].ToString()))
            { // get user name from session
                UserName = HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUser].ToString();
            }
            // split Input Params
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);

            // Initlize RetValContent Object
            RetValContent = new DataContent();
            ContentId = Convert.ToInt32(Params[0].ToString());
            ContentTitle = Params[1].ToString();
            ContentDate = Params[2].ToString();
            ContentSummary = Params[3].ToString();
            ContentSummary=ContentSummary.Replace("\n","<br/>");
            ContentDescription = Params[4].ToString().Trim().Replace("diorg/images", "../libraries/aspx/diorg/images");

            //remove changes in script tag for ckeditor
            ContentDescription = ContentDescription.Replace("<scrpt", "<script");
            ContentDescription = ContentDescription.Replace("</scrpt", "</script");

            ContentPdfFileUrl = Params[5].ToString().Replace("diorg/", "../libraries/aspx/diorg/"); ;
            MenuCategory = Params[6].ToString();
            ContentImgUrl = Params[7].ToString().Trim().Replace( "diorg/","../libraries/aspx/diorg/");
            if (Params.Length > 8)
            {
                ContentTag = Params[8].ToString().Trim();
            }
            OutCurrentMenuCategory = MenuCategory;
            OutCurrentPageNo = Params[10].ToString().Trim();

            if (Params.Length > 11)
            {
                OutCurrentTagNids = Params[11].ToString().Trim();
            }
            else
            {
                OutCurrentTagNids = string.Empty;
            }

            ExistingTagNid = Convert.ToInt32(Params[9].ToString().Trim());
            // Check if existing tagid exists
            if (ExistingTagNid > 0)
            {
                // Delete existing Tag from mapping table
                DeleteTagsMappingsByTagId(ExistingTagNid);
            }

            UserEmailID = UserName + " [" + UserEmailID + " ]";

            //// Create Countent Url From Title
            //CountentUrl = ObjCMSHelper.CreateUrlFromInputString(ContentTitle);
            // Getb current database language
            CurrentDbLangCode = Global.GetDefaultLanguageCode();

            //Get Tag Nid-- add new tags to database and get nid
            if (!string.IsNullOrEmpty(ContentTag))
            {
                ContentTagNid = ObjCMSHelper.CreateAndGetTagNid(ContentTag);
            }
            //Convert Date to sql date time
            SqlDtTime = ObjCMSHelper.ConvertDataTimeToSQLDateTime(ContentDate);

            // innitlize of members of class Content
            RetValContent.ContentId = ContentId;
            RetValContent.MenuCategory = MenuCategory;
            RetValContent.Date = SqlDtTime;
            RetValContent.DateAdded = new SqlDateTime(DateTime.Now);
            RetValContent.DateModified = new SqlDateTime(DateTime.Now);
            RetValContent.Description = ContentDescription;
            RetValContent.Title = ContentTitle;
            RetValContent.PDFUpload = ContentPdfFileUrl;
            RetValContent.Summary = ContentSummary;
            RetValContent.Thumbnail = ContentImgUrl;
            RetValContent.Archived = false;
            // Username email filed is combination of username and email
            RetValContent.UserNameEmail = UserName + " " + UserEmailID;
            RetValContent.LngCode = CurrentDbLangCode;
            RetValContent.ArticleTagID = ContentTagNid;

          IsContentUpdated= this.UpdateCMSContent(RetValContent);
          if (IsContentUpdated)
          {
              RetVal = true;
              // set session varibles to maintain page no
          }
        }
        catch (Exception Ex)
        {
            OutCurrentMenuCategory = string.Empty;
            OutCurrentPageNo = string.Empty;
            OutCurrentTagNids = string.Empty;
            RetVal = false;
            Global.CreateExceptionString(Ex, null);
        }

        finally
        {
            RetValContent = null;
        }
        return RetVal;
    }