예제 #1
0
        private void RemoveExpiredMessages()
        {
            int expiration = PortalConfig.MdsDeleteOlderMoreThan;

            if (expiration > 0)
            {
                SqlScript sqlScript = new SqlScript();

                sqlScript.AppendLine("DELETE FROM [dbo].[cls_Email] WHERE Created < @ExpirationDate");

                sqlScript.AddParameter("@ExpirationDate", DateTime.UtcNow.AddMinutes(-expiration));

                sqlScript.Execute();
            }
        }
        protected override void CopyEntityObjectToMetaObject(EntityObject target, MetaObject metaObject)
        {
            // Base Copy
            base.CopyEntityObjectToMetaObject(target, metaObject);

            // Process not updatable field
            DocumentContentVersionEntity srcVersion = (DocumentContentVersionEntity)target;

            #region Index
            // Only if new object
            if (metaObject.ObjectState == MetaObjectState.Created)
            {
                // Calculate max index
                int maxIndex = 0;
                SqlScript selectMaxIndex = new SqlScript();

                selectMaxIndex.Append("SELECT MAX([Index]) AS [Index] FROM [dbo].[cls_DocumentContentVersion] WHERE [OwnerDocumentId] = @OwnerDocumentId");
                selectMaxIndex.AddParameter("@OwnerDocumentId", (Guid)srcVersion.OwnerDocumentId);

                using (IDataReader reader = SqlHelper.ExecuteReader(SqlContext.Current,
                    CommandType.Text, selectMaxIndex.ToString(), selectMaxIndex.Parameters.ToArray()))
                {
                    if (reader.Read())
                    {
                        object value = reader["Index"];
                        if (value is int)
                        {
                            maxIndex = (int)value;
                        }
                    }
                }

                // update index
                metaObject["Index"] = maxIndex + 1;
            }
            #endregion

            // Update State via Custom Method = UpdateState
        }
예제 #3
0
        protected override void CopyEntityObjectToMetaObject(EntityObject target, MetaObject metaObject)
        {
            // Base Copy
            base.CopyEntityObjectToMetaObject(target, metaObject);

            // Process not updatable field
            DocumentContentVersionEntity srcVersion = (DocumentContentVersionEntity)target;

            #region Index
            // Only if new object
            if (metaObject.ObjectState == MetaObjectState.Created)
            {
                // Calculate max index
                int       maxIndex       = 0;
                SqlScript selectMaxIndex = new SqlScript();

                selectMaxIndex.Append("SELECT MAX([Index]) AS [Index] FROM [dbo].[cls_DocumentContentVersion] WHERE [OwnerDocumentId] = @OwnerDocumentId");
                selectMaxIndex.AddParameter("@OwnerDocumentId", (Guid)srcVersion.OwnerDocumentId);

                using (IDataReader reader = SqlHelper.ExecuteReader(SqlContext.Current,
                                                                    CommandType.Text, selectMaxIndex.ToString(), selectMaxIndex.Parameters.ToArray()))
                {
                    if (reader.Read())
                    {
                        object value = reader["Index"];
                        if (value is int)
                        {
                            maxIndex = (int)value;
                        }
                    }
                }

                // update index
                metaObject["Index"] = maxIndex + 1;
            }
            #endregion

            // Update State via Custom Method = UpdateState
        }
        private void RemoveExpiredMessages()
        {
            int expiration = PortalConfig.MdsDeleteOlderMoreThan;

            if (expiration > 0)
            {
                SqlScript sqlScript = new SqlScript();

                sqlScript.AppendLine("DELETE FROM [dbo].[cls_IbnClientMessage] WHERE Created < @ExpirationDate");

                sqlScript.AddParameter("@ExpirationDate", DateTime.UtcNow.AddMinutes(-expiration));

                sqlScript.Execute();
            }
        }