///<summary>
        /// Calls MarkResolved on the server and waits for a response (synchronous).
        /// This should not be called on a UI thread
        ///</summary>
        public void MarkResolved(UserLogEntry entry)
        {
            IAsyncResult result = BeginMarkResolved(entry, null, null);

            result.AsyncWaitHandle.WaitOne();

            EndMarkResolved(result);
        }
        ///<summary>
        /// Returns the result of calling MarkResolved on the server as an async Task.
        ///</summary>
        public Task MarkResolvedAsync(UserLogEntry entry)
        {
            var taskSource = new TaskCompletionSource <object>();

            BeginMarkResolved(entry, asyncResult =>
            {
                try
                {
                    EndMarkResolved(asyncResult); var result = new object();
                    taskSource.SetResult(result);
                }
                catch (Exception exception)
                {
                    taskSource.SetException(exception);
                }
            }, null);
            return(taskSource.Task);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the specified number of log entries, starting with the latest one.
        /// </summary>
        /// <param name="maxItems">The maximum number of items returned (-1 for "all").</param>
        /// <returns>A list of LogEntrys or null.</returns>
        public static List <UserLogEntry> GetUserLogEntries(int maxItems, DateTime startTime, DateTime endTime)
        {
            Exception ex;
            DataTable dtEntries = CsvHandler.ReadCSVFile(Environment.CurrentDirectory + @"\Logs\nUserLog.csv", out ex);

            if (dtEntries == null || ex != null)
            {
                return(null);
            }

            List <UserLogEntry> entriesToReturn = new List <UserLogEntry>();

            for (int i = dtEntries.Rows.Count - 1; i >= 0; i--) //iterate the table from bottom to top (new to old)
            {
                DateTime entryTime;

                if (!DateTime.TryParse(dtEntries.Rows[i].ItemArray[0].ToString(), out entryTime))
                {
                    entryTime = endTime;
                }

                if (entryTime >= startTime && entryTime <= endTime)
                {
                    UserLogEntry newLogEntry = new UserLogEntry()
                    {
                        Time = entryTime, Category = dtEntries.Rows[i].ItemArray[1].ToString(), Message = dtEntries.Rows[i].ItemArray[2].ToString(), ExceptionText = dtEntries.Rows[i].ItemArray[3].ToString()
                    };
                    entriesToReturn.Add(newLogEntry);
                }

                if (maxItems > 0 && entriesToReturn.Count == maxItems)
                {
                    break;
                }
            }

            return(entriesToReturn);
        }
Exemplo n.º 4
0
        private int btnOkClicked()
        {
            //User clicked 'Create album'. Create the new album and return the new album ID.
            TreeViewNode selectedNode  = tvUC.SelectedNode;
            int          parentAlbumID = Int32.Parse(selectedNode.Value, CultureInfo.InvariantCulture);
            IAlbum       parentAlbum   = Factory.LoadAlbumInstance(parentAlbumID, false);

            this.CheckUserSecurity(SecurityActions.AddChildAlbum, parentAlbum);

            int newAlbumID;

            if (parentAlbumID > 0)
            {
                IAlbum newAlbum = Factory.CreateEmptyAlbumInstance(parentAlbum.GalleryId);
                newAlbum.Title = GetAlbumTitle();
                //newAlbum.ThumbnailMediaObjectId = 0; // not needed
                newAlbum.Parent    = parentAlbum;
                newAlbum.IsPrivate = (parentAlbum.IsPrivate ? true : chkIsPrivate.Checked);
                GalleryObjectController.SaveGalleryObject(newAlbum);
                newAlbumID = newAlbum.Id;


                // Sueetie Modified - Save New Album to Sueetie_Content, Sueetie_gs_Album and log it in User Activity Log

                string grpString = string.Empty;
                if (SueetieApplications.Current.IsGroup)
                {
                    grpString = "/" + SueetieApplications.Current.GroupKey;
                }
                string albumUrl = grpString + "/" + SueetieApplications.Current.ApplicationKey + "/" + CurrentSueetieGallery.GalleryKey + ".aspx?aid=" + newAlbumID.ToString();

                SueetieContent sueetieContent = new SueetieContent
                {
                    SourceID      = newAlbumID,
                    ContentTypeID = int.Parse(ddSueetieAlbumType.SelectedValue),
                    ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                    UserID        = CurrentSueetieUserID,
                    IsRestricted  = newAlbum.IsPrivate,
                    Permalink     = albumUrl,
                };
                int contentID = SueetieCommon.AddSueetieContent(sueetieContent);

                var albumLogCategory = SueetieMedia.GetAlbumContentTypeDescriptionList().Single(contentDescription => contentDescription.ContentTypeID.Equals(sueetieContent.ContentTypeID));

                UserLogEntry entry = new UserLogEntry
                {
                    UserLogCategoryID = albumLogCategory.UserLogCategoryID,
                    ItemID            = contentID,
                    UserID            = CurrentSueetieUserID,
                };
                if (CurrentSueetieGallery.IsLogged)
                {
                    SueetieLogs.LogUserEntry(entry);
                }

                string albumPath = SueetieMedia.CreateSueetieAlbumPath(newAlbum.FullPhysicalPath);
                SueetieMedia.CreateSueetieAlbum(newAlbumID, albumPath, sueetieContent.ContentTypeID);
                SueetieMedia.ClearSueetieMediaAlbumListCache(CurrentSueetieGalleryID);
                SueetieMedia.ClearSueetieMediaGalleryListCache();

                HelperFunctions.PurgeCache();
            }
            else
            {
                throw new GalleryServerPro.ErrorHandler.CustomExceptions.InvalidAlbumException(parentAlbumID);
            }

            return(newAlbumID);
        }
 /// <summary>
 /// Marks the provided log entry as resolved.
 /// </summary>
 public IAsyncResult BeginMarkResolved(UserLogEntry entry, System.AsyncCallback callback, object asyncState)
 {
     return(base.Channel.BeginMarkResolved(entry, callback, asyncState));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Marks the provided log entry as resolved.
 /// </summary>
 public void MarkResolved(UserLogEntry entry)
 {
     Channel.MarkResolved(entry);
 }