コード例 #1
0
ファイル: ArticleHelper.cs プロジェクト: volkanytu/Portal
        public static MsCrmResultObject GetArticleInfo(Guid articleId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                        A.new_articleId ArticleId
	                                    ,A.new_name Name
	                                    ,A.new_summary Summary
	                                    ,A.new_content [Description]
	                                    ,A.new_imageurl [Image]
	                                    ,CAST({2}.dbo.fn_UTCToTzSpecificLocalTime(A.CreatedOn, us.TimeZoneBias, us.TimeZoneDaylightBias,us.TimeZoneDaylightYear, us.TimeZoneDaylightMonth, us.TimeZoneDaylightDay, us.TimeZoneDaylightHour,us.TimeZoneDaylightMinute, us.TimeZoneDaylightSecond, 0, us.TimeZoneDaylightDayOfWeek,us.TimeZoneStandardBias, us.TimeZoneStandardYear, us.TimeZoneStandardMonth, us.TimeZoneStandardDay,us.TimeZoneStandardHour, us.TimeZoneStandardMinute, us.TimeZoneStandardSecond, 0,us.TimeZoneStandardDayOfWeek) as DATETIME) CreatedOn
                                FROM
	                                new_article A (NoLock)
                                 INNER JOIN 
	                                dbo.UserSettingsBase US (NoLock)
	                                ON 
	                                US.SystemUserId ='{1}'
                                WHERE
	                                A.new_articleId = '{0}'"    ;
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, articleId, Globals.AdminId, Globals.DatabaseName));
                if (dt != null && dt.Rows.Count > 0)
                {
                    Article _article = new Article();
                    _article.ArticleId       = (Guid)dt.Rows[0]["ArticleId"];
                    _article.Name            = dt.Rows[0]["Name"].ToString();
                    _article.Summary         = dt.Rows[0]["Summary"].ToString();
                    _article.Description     = dt.Rows[0]["Description"].ToString();
                    _article.ImagePath       = dt.Rows[0]["Image"] != DBNull.Value ? dt.Rows[0]["Image"].ToString() : "no_image_available.png";
                    _article.CreatedOnString = dt.Rows[0]["CreatedOn"] != DBNull.Value ? ((DateTime)dt.Rows[0]["CreatedOn"]).ToString("dd MMMM yyyy ddddd HH:mm", new CultureInfo("tr-TR", false)) : string.Empty;

                    #region | GET COMMENTS |
                    MsCrmResultObject commentResult = CommentHelper.GetArticleComments(articleId, sda);
                    if (commentResult.Success)
                    {
                        _article.CommentList = (List <Comment>)commentResult.ReturnObject;
                    }
                    #endregion

                    #region | GET ATTACHMENTS |
                    MsCrmResultObject attachmentResult = AttachmentFileHelper.GetArticleAttachmentFiles(articleId, sda);
                    if (attachmentResult.Success)
                    {
                        _article.AttachmentFileList = (List <AttachmentFile>)attachmentResult.ReturnObject;
                    }
                    #endregion

                    returnValue.Success      = true;
                    returnValue.ReturnObject = _article;
                }
                else
                {
                    returnValue.Success = true;
                    returnValue.Result  = "M020"; //"İstenilen makaleye ait detay bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }