Example #1
0
        public static MsCrmResultObject GetAnnouncementInfo(Guid announcementId, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"SELECT 
	                                A.new_announcementId Id
	                                ,A.new_name Name
	                                ,A.new_content Content
	                                ,A.new_imageurl ImageUrl
                                    ,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_announcement A (NoLock)
                                INNER JOIN
	                                SystemUser SU (NoLock)
	                                ON
	                                SU.SystemUserId = '{1}'
                                INNER JOIN 
	                                dbo.UserSettingsBase US (NoLock)
	                                ON 
	                                US.SystemUserId =SU.SystemUserId
                                WHERE
	                                A.new_announcementId = '{0}'
                                ORDER BY 
	                                A.CreatedOn DESC"    ;
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, announcementId, Globals.AdminId, Globals.DatabaseName));

                if (dt != null && dt.Rows.Count > 0)
                {
                    Announcement _announcement = new Announcement();
                    _announcement.AnnouncementId = (Guid)dt.Rows[0]["Id"];
                    _announcement.Caption        = dt.Rows[0]["Name"] != DBNull.Value ? dt.Rows[0]["Name"].ToString() : string.Empty;
                    _announcement.Description    = dt.Rows[0]["Content"] != DBNull.Value ? dt.Rows[0]["Content"].ToString() : string.Empty;
                    _announcement.ImagePath      = dt.Rows[0]["ImageUrl"] != DBNull.Value ? dt.Rows[0]["ImageUrl"].ToString() : "no_image_available.png";

                    if (dt.Rows[0]["CreatedOn"] != DBNull.Value)
                    {
                        _announcement.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;
                        _announcement.CreatedOn       = (DateTime)dt.Rows[0]["CreatedOn"];
                    }

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

                    returnValue.Success      = true;
                    returnValue.ReturnObject = _announcement;
                }
                else
                {
                    returnValue.Result = "M026"; //"İlgili duyuruya ait bilgiye ulaşılamadı.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }

            return(returnValue);
        }