/UniqueStudio.ComContent/BLL/AutoSaveManager.cs
http://uniquestudiocms.googlecode.com/ · C# · 144 lines · 107 code · 12 blank · 25 comment · 12 complexity · f07796dcd92971d56be51ac30f5bcf36 MD5 · raw file
- using System;
- using System.Data.Common;
-
- using UniqueStudio.ComContent.DAL;
- using UniqueStudio.ComContent.Model;
- using UniqueStudio.Common.ErrorLogging;
- using UniqueStudio.Common.Exceptions;
- using UniqueStudio.Common.Utilities;
-
- namespace UniqueStudio.ComContent.BLL
- {
- public class AutoSaveManager
- {
- //
- // !!! ??????????
- //
-
- private static AutoSaveProvider provider = new AutoSaveProvider();
-
- public AutoSaveManager()
- {
-
- }
-
- /// <summary>
- /// ??????
- /// </summary>
- /// <param name="userID">??ID</param>
- /// <param name="post">????</param>
- /// <returns>????????</returns>
- public bool AutoSavePost(Guid userID, PostInfo post)
- {
- if (post.Title == null)
- {
- post.Title = string.Empty;
- }
- if (post.SubTitle == null)
- {
- post.SubTitle = string.Empty;
- }
- if (post.Author == null)
- {
- post.Author = string.Empty;
- }
- if (post.AddUserName == null)
- {
- post.AddUserName = string.Empty;
- }
- if (post.Summary == null)
- {
- post.Summary = string.Empty;
- }
- if (post.Content.Trim().ToString() == "")
- {
- return false;
- }
-
- try
- {
- long userUri = Convert.ToInt64("6" + DateTime.Now.ToString("yyyyMMddHHmmss"));
- return provider.AutoSaveFile(userID, post, userUri);
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError(ex);
- return false;
- }
- }
-
- /// <summary>
- /// ????????????????????
- /// </summary>
- /// <param name="userID">??ID</param>
- /// <returns>?????????</returns>
- public PostInfo GetAutoSavedPost(Guid userID)
- {
- Validator.CheckGuid(userID, "userID");
-
- try
- {
- return provider.GetAutoSavedPost(userID);
- }
- catch (DbException ex)
- {
- ErrorLogger.LogError(ex);
- throw new DatabaseException();
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError(ex);
- throw new UnhandledException();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="userId"></param>
- /// <returns></returns>
- public bool IsPostSaved(Guid userId)
- {
- Validator.CheckGuid(userId, "userId");
-
- try
- {
- return provider.IsPostSaved(userId);
- }
- catch (DbException ex)
- {
- ErrorLogger.LogError(ex);
- throw new DatabaseException();
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError(ex);
- throw new UnhandledException();
- }
- }
-
- /// <summary>
- /// ????????????
- /// </summary>
- /// <param name="userID">??ID</param>
- /// <param name="isEffictive">????</param>
- /// <returns>??????</returns>
- public bool SetAutoSaveFileEft(Guid userID, bool isEffictive)
- {
- try
- {
- return provider.SetAutoSavePostEft(userID, isEffictive);
- }
- catch (DbException ex)
- {
- ErrorLogger.LogError(ex);
- throw new DatabaseException();
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError(ex);
- throw new UnhandledException();
- }
- }
- }
- }