Esempio n. 1
0
        public static long GetCommentLikesDislikesCount(Guid applicationId, Guid?CommentID, bool Like)
        {
            string spName = GetFullyQualifiedName("GetCommentLikesDislikesCount");

            try
            {
                return(ProviderUtil.succeed_long(ProviderUtil.execute_reader(spName, applicationId, CommentID, Like)));
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.SH);
                return(-1);
            }
        }
Esempio n. 2
0
        public static long GetUserPostsCount(Guid applicationId, Guid?UserID, int PostTypeID)
        {
            string spName = GetFullyQualifiedName("GetUserPostsCount");

            try
            {
                return(ProviderUtil.succeed_long(ProviderUtil.execute_reader(spName, applicationId, UserID, PostTypeID)));
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.SH);
                return(-1);
            }
        }
Esempio n. 3
0
        public static int GetUserNotificationsCount(Guid applicationId, Guid userId, bool?seen)
        {
            string spName = GetFullyQualifiedName("GetUserNotificationsCount");

            try
            {
                return((int)ProviderUtil.succeed_long(ProviderUtil.execute_reader(spName, applicationId, userId, seen)));
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.NTFN);
                return(0);
            }
        }
Esempio n. 4
0
        public static bool ArithmeticDeleteRelatedUser(Guid applicationId,
                                                       Guid eventId, Guid userId, ref bool calenderDeleted)
        {
            string spName = GetFullyQualifiedName("ArithmeticDeleteRelatedUser");

            try
            {
                int result = (int)ProviderUtil.succeed_long(ProviderUtil.execute_reader(spName, applicationId,
                                                                                        eventId, userId));

                calenderDeleted = result == 2 ? true : false;
                return(result > 0 ? true : false);
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.EVT);
                return(false);
            }
        }
Esempio n. 5
0
        public static long GetCommentsCount(Guid applicationId, Guid?postId, Guid?senderUserId)
        {
            string spName = GetFullyQualifiedName("GetCommentsCount");

            try
            {
                if (postId == Guid.Empty)
                {
                    postId = null;
                }
                if (senderUserId == Guid.Empty)
                {
                    senderUserId = null;
                }

                return(ProviderUtil.succeed_long(ProviderUtil.execute_reader(spName, applicationId, postId, senderUserId)));
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.SH);
                return(-1);
            }
        }
Esempio n. 6
0
        public static long SendMessage(Guid applicationId, Guid messageId, Guid?forwardedFrom, Guid userId,
                                       string title, string messageText, bool isGroup, List <Guid> receiverUserIds, Guid?threadId,
                                       List <DocFileInfo> attachedFiles)
        {
            if (forwardedFrom == Guid.Empty)
            {
                forwardedFrom = null;
            }
            if (threadId == Guid.Empty)
            {
                threadId = null;
            }

            SqlConnection con = new SqlConnection(ProviderUtil.ConnectionString);
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection = con;

            //Add Receivers
            DataTable receiversTable = new DataTable();

            receiversTable.Columns.Add("Value", typeof(Guid));

            foreach (Guid uId in receiverUserIds)
            {
                receiversTable.Rows.Add(uId);
            }

            SqlParameter receiversParam = new SqlParameter("@Receivers", SqlDbType.Structured);

            receiversParam.TypeName = "[dbo].[GuidTableType]";
            receiversParam.Value    = receiversTable;
            //end of Add Receivers

            //Add Attachments
            DataTable attachmentsTable = new DataTable();

            attachmentsTable.Columns.Add("FileID", typeof(Guid));
            attachmentsTable.Columns.Add("FileName", typeof(string));
            attachmentsTable.Columns.Add("Extension", typeof(string));
            attachmentsTable.Columns.Add("MIME", typeof(string));
            attachmentsTable.Columns.Add("Size", typeof(long));
            attachmentsTable.Columns.Add("OwnerID", typeof(Guid));
            attachmentsTable.Columns.Add("OwnerType", typeof(string));

            foreach (DocFileInfo _att in attachedFiles)
            {
                attachmentsTable.Rows.Add(_att.FileID, _att.FileName,
                                          _att.Extension, _att.MIME(), _att.Size, _att.OwnerID, _att.OwnerType);
            }

            SqlParameter attachmentsParam = new SqlParameter("@Attachments", SqlDbType.Structured);

            attachmentsParam.TypeName = "[dbo].[DocFileInfoTableType]";
            attachmentsParam.Value    = attachmentsTable;
            //end of Add Attachments

            cmd.Parameters.AddWithValue("@ApplicationID", applicationId);
            cmd.Parameters.AddWithValue("@UserID", userId);
            if (threadId.HasValue)
            {
                cmd.Parameters.AddWithValue("@ThreadID", threadId.Value);
            }
            cmd.Parameters.AddWithValue("@MessageID", messageId);
            if (forwardedFrom.HasValue)
            {
                cmd.Parameters.AddWithValue("@ForwardedFrom", forwardedFrom.Value);
            }
            if (!string.IsNullOrEmpty(title))
            {
                cmd.Parameters.AddWithValue("@Title", title);
            }
            cmd.Parameters.AddWithValue("@MessageText", messageText);
            cmd.Parameters.AddWithValue("@IsGroup", isGroup);
            cmd.Parameters.AddWithValue("@Now", DateTime.Now);
            cmd.Parameters.Add(receiversParam);
            cmd.Parameters.Add(attachmentsParam);

            string spName = GetFullyQualifiedName("SendNewMessage");

            string sep       = ", ";
            string arguments = "@ApplicationID" + sep + "@UserID" + sep +
                               (threadId.HasValue ? "@ThreadID" : "null") + sep + "@MessageID" + sep +
                               (forwardedFrom.HasValue ? "@ForwardedFrom" : "null") + sep +
                               (!string.IsNullOrEmpty(title) ? "@Title" : "null") + sep +
                               "@MessageText" + sep + "@IsGroup" + sep + "@Now" + sep + "@Receivers" + sep + "@Attachments";

            cmd.CommandText = ("EXEC" + " " + spName + " " + arguments);

            con.Open();
            try { return(ProviderUtil.succeed_long((IDataReader)cmd.ExecuteReader())); }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.MSG);
                return(0);
            }
            finally { con.Close(); }
        }