public ConversationController()
        {
            EfDbContext dbContext = new EfDbContext();

            _userRepository      = new UserRepository(dbContext);
            _conversationManager = new ConversationManager(_userRepository);
        }
Exemplo n.º 2
0
        public ChatServiceManager(IClientManager clientManager, IConversationManager conversationManager)
        {
            if (clientManager == null)
            {
                throw new ArgumentNullException("clientManager");
            }

            if (conversationManager == null)
            {
                throw new ArgumentNullException("conversationManager");
            }

            this.clientManager = clientManager;

            this.conversationManager = conversationManager;

            this.clientManager.ClientLeave += c => conversationManager.EndConversation(c);

            conversationManager.ConversationStart += (x, y) =>
            {
                clientManager.SetNotFreeClient(x);
                clientManager.SetNotFreeClient(y);
            };

            conversationManager.ConversationEnd += (x, y) =>
            {
                clientManager.SetFreeClient(x);
                clientManager.SetFreeClient(y);
            };
        }
Exemplo n.º 3
0
        void context_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            if (HttpContext.Current.Handler is Page)
            {
                Page page = (Page)HttpContext.Current.Handler;
                page.Unload += new EventHandler(page_Unload);

                if (HttpContext.Current.Session != null)
                {
                    if (LOG.IsDebugEnabled)
                    {
                        LOG.Debug("context_PreRequestHandlerExecute: Processing HttpContext.Current.Session");
                    }
                    foreach (String convMngName in this.ConversationManagerNameList)
                    {
                        if (LOG.IsDebugEnabled)
                        {
                            LOG.Debug(string.Format("context_PreRequestHandlerExecute: Processing ConversationManager: {0}", convMngName));
                        }
                        IConversationManager convMng = (IConversationManager)this.applicationContext.GetObject(convMngName);
                        convMng.EndOnTimeOut();
                        convMng.FreeEnded();
                    }
                }
                else
                {
                    if (LOG.IsDebugEnabled)
                    {
                        LOG.Debug("context_PreRequestHandlerExecute: no HttpContext.Current.Session found.");
                    }
                }
            }
        }
Exemplo n.º 4
0
        private async Task PublishNotificationAndEmails(IConversationManager securityRule, ConversationKey key, string comment)
        {
            var participants = await securityRule.GetParticipants(key.EntityId);

            var users            = participants.Participants.SelectMany(t => t.Users);
            var userParticipants = users.DistinctBy(a => a.Id).ToList();

            var link = securityRule.Link(key.EntityId).GetUrl();

            foreach (var user in userParticipants)
            {
                if (user.Id.ToString() != this.userContext.User.UserId)
                {
                    var model = new CommentAddedEmail.Model(this.appConfig.Value, comment, user.Username, user.Email, link);
                    await this.emailSender.SendEmail(user.Email, model);

                    this.notificationsDbContext.Add(
                        new Notification(
                            new EntityReference(NotificationRecipientType.UserId.Value, user.Id.ToString()),
                            new EntityReference(key.EntityType, key.EntityId.ToString()),
                            $"New comment posted for {key.EntityType.Split('.').Last()} #{key.EntityId}",
                            null));
                }
            }

            await this.notificationsDbContext.SaveChangesAsync();
        }
Exemplo n.º 5
0
        public App(IContacts contactManager, IConversationManager conversationManager)
        {
            ConversationManager = conversationManager;
            ContactManager      = contactManager;

            InitApp();
        }
Exemplo n.º 6
0
 public BotActivityHandler(
     IConversationManager conversationManager,
     ConversationState conversationState)
 {
     _conversationManager = conversationManager;
     _conversationState   = conversationState;
 }
Exemplo n.º 7
0
 public ExportMultipleDialogModel(IConversationManager conversationManager, IDisplayOptionsReadOnly displayOptions, IFileSystem exportFileSystem,
                                  ExportErrorFormatter exportErrorFormatter)
 {
     _conversationManager  = conversationManager;
     _displayOptions       = displayOptions;
     _exportFileSystem     = exportFileSystem;
     _exportErrorFormatter = exportErrorFormatter;
 }
Exemplo n.º 8
0
 public ConversationDTOManager(IConversationManager conversationManager,
                               IMapper mapper,
                               IUserFinder userFinder)
 {
     this.conversationManager = conversationManager;
     this.mapper     = mapper;
     this.userFinder = userFinder;
 }
 public ExportMultipleDialogModel(IConversationManager conversationManager, IDisplayOptionsReadOnly displayOptions, IFileSystem exportFileSystem,
     ExportErrorFormatter exportErrorFormatter)
 {
     _conversationManager = conversationManager;
     _displayOptions = displayOptions;
     _exportFileSystem = exportFileSystem;
     _exportErrorFormatter = exportErrorFormatter;
 }
Exemplo n.º 10
0
        private ConversationWindowModel GetPopulatedConversationWindowModel()
        {
            IDisplayOptions         displayOptions     = new MockDisplayOptions();
            IPhoneSelectOptions     phoneSelectOptions = new MockPhoneSelectOptions();
            ConversationWindowModel model = new ConversationWindowModel(displayOptions, phoneSelectOptions);
            IConversationManager    conversationManager = GetConversationManager(displayOptions);

            model.ConversationManager = conversationManager;

            return(model);
        }
Exemplo n.º 11
0
 public FriendshipManager(
     IFriendshipRepository friendshipRepo,
     IUserRepository userRepo,
     IConversationManager conversationMgr,
     IHubContext <FriendsHub, IFriendsClient> friendsHub)
 {
     _friendshipRepo  = friendshipRepo;
     _userRepo        = userRepo;
     _conversationMgr = conversationMgr;
     _friendsHub      = friendsHub;
 }
        public ExportMultipleDialogView(IConversationManager conversationManager, IDisplayOptionsReadOnly displayOptions)
        {
            InitializeComponent();

            IFileSystem exportFileSystem = new OsFileSystem();

            ExportErrorFormatter exportErrorFormatter = new ExportErrorFormatter();

            _model = new ExportMultipleDialogModel(conversationManager, displayOptions, exportFileSystem, exportErrorFormatter);
            _progressCallback = null;

            Loaded += delegate
            {
                folderPathTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            };
        }
Exemplo n.º 13
0
 public FriendshipController(
     IUserRepository userRepo,
     IFriendshipRepository friendshipRepo,
     IFriendshipManager friendshipMgr,
     IConversationRepository conversationRepo,
     IConversationManager conversationMgr,
     IHubContext <FriendsHub, IFriendsClient> friendsHub,
     StupidLoader stupidLoader)
 {
     _userRepo        = userRepo;
     _friendshipRepo  = friendshipRepo;
     _friendshipMgr   = friendshipMgr;
     _conversationMgr = conversationMgr;
     _friendsHub      = friendsHub;
     _stupidloader    = stupidLoader;
 }
        public ExportMultipleDialogView(IConversationManager conversationManager, IDisplayOptionsReadOnly displayOptions)
        {
            InitializeComponent();

            IFileSystem exportFileSystem = new OsFileSystem();

            ExportErrorFormatter exportErrorFormatter = new ExportErrorFormatter();

            _model            = new ExportMultipleDialogModel(conversationManager, displayOptions, exportFileSystem, exportErrorFormatter);
            _progressCallback = null;

            Loaded += delegate
            {
                folderPathTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            };
        }
Exemplo n.º 15
0
 /// <summary>
 /// Handles the Unload event of the page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>
 /// Necessary for Redirect or Abort for any reason.
 /// </remarks>
 void page_Unload(object sender, EventArgs e)
 {
     if (LOG.IsDebugEnabled)
     {
         LOG.Debug("page_Unload HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null));
     }
     foreach (String convMngName in this.ConversationManagerNameList)
     {
         if (LOG.IsDebugEnabled)
         {
             LOG.Debug(string.Format("page_Unload: Processing ConversationManager: {0}", convMngName));
         }
         IConversationManager convMng = (IConversationManager)this.applicationContext.GetObject(convMngName);
         convMng.EndOnTimeOut();
         convMng.FreeEnded();
         convMng.PauseConversations();
     }
 }
Exemplo n.º 16
0
        private static void OnDoWork(object sender, DoWorkEventArgs e)
        {
            AsyncLoadingProgressParams workParams       = (AsyncLoadingProgressParams)e.Argument;
            ILoadingProgressCallback   progressCallback = workParams.LoadingProgressCallback;
            bool             mergeConversations         = workParams.MergeConversations;
            IPhoneDeviceInfo deviceInfo = workParams.DeviceInfo;

            try
            {
                IConversationManager conversationManager = MainWindowModelBase.LoadConversationManager(progressCallback, deviceInfo, mergeConversations);

                progressCallback.End();

                e.Result = conversationManager;
            }
            catch (OperationCanceledException)
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 17
0
        public MainWindow()
        {
            InitializeComponent();

            _currentView = DefaultApplicationView;
            _conversationManager = null;
            DisplayOptions options = new DisplayOptions();
            _displayOptions = options as IDisplayOptions;
            _displayOptions.TimeDisplayFormatPropertyChanged += OnTimeDisplayFormatPropertyChanged;
            _displayOptions.HideEmptyConversationsPropertyChanged += OnHideEmptyConversationsPropertyChanged;
            _displayOptions.MergeContactsPropertyChanged += OnMergeContactsPropertyChanged;
            _displayOptions.LoadMmsAttachmentsPropertyChanged += OnLoadMmsAttachmentsPropertyChanged;
            _displayOptions.ConversationSortingPropertyChanged += OnConversationSortingPropertyChanged;
            _phoneSelectOptions = options as IPhoneSelectOptions;

            _deviceInfo = null;

            conversationRenderControl.DisplayOptions = _displayOptions;
            conversationRenderControl.findBar.FindModel = new FindDialogModel(this);

            Loaded += OnLoaded;
        }
Exemplo n.º 18
0
        public MainWindow()
        {
            InitializeComponent();

            _currentView         = DefaultApplicationView;
            _conversationManager = null;
            DisplayOptions options = new DisplayOptions();

            _displayOptions = options as IDisplayOptions;
            _displayOptions.TimeDisplayFormatPropertyChanged      += OnTimeDisplayFormatPropertyChanged;
            _displayOptions.HideEmptyConversationsPropertyChanged += OnHideEmptyConversationsPropertyChanged;
            _displayOptions.MergeContactsPropertyChanged          += OnMergeContactsPropertyChanged;
            _displayOptions.LoadMmsAttachmentsPropertyChanged     += OnLoadMmsAttachmentsPropertyChanged;
            _displayOptions.ConversationSortingPropertyChanged    += OnConversationSortingPropertyChanged;
            _phoneSelectOptions = options as IPhoneSelectOptions;

            _deviceInfo = null;

            conversationRenderControl.DisplayOptions    = _displayOptions;
            conversationRenderControl.findBar.FindModel = new FindDialogModel(this);

            Loaded += OnLoaded;
        }
Exemplo n.º 19
0
    private void alreadyHasAnotherManagerRaise()
    {
        Regex msgErrorRx = new Regex(".*already.*has.*another.*manager.*");
        IConversationManager otherConversationManager = null;

        //Raise error
        try
        {
            otherConversationManager = new WebConversationManager();
            otherConversationManager.AddConversation(this.ConversationA);
            this.Session["testResult"] = "NOT OK";
        }
        catch (InvalidOperationException ioe)
        {
            if (msgErrorRx.IsMatch(ioe.Message))
            {
                this.Session["testResult"] = "OK";
            }
            else
            {
                this.Session["testResult"] = "NOT OK " + ioe.Message;
            }
        }
    }
Exemplo n.º 20
0
        public static IConversationManager LoadConversationManager(ILoadingProgressCallback progressCallback, IPhoneDeviceInfo deviceInfo, bool mergeConversations)
        {
            IConversationManager conversationManager = null;

            using (DatabaseReader contactDatabaseReader = new DatabaseReader(DatabaseFinder.FindContactDatabasePath(deviceInfo.BackupPath)))
            {
                ContactReader contactReader = new ContactReader();
                contactReader.ParseDatabase(contactDatabaseReader);

                using (DatabaseReader textDatabaseReader = new DatabaseReader(DatabaseFinder.FindTextMessageDatabasePath(deviceInfo.BackupPath)))
                {
                    TextMessageReaderBase             textMessageReader;
                    IEnumerable <ChatRoomInformation> chatReader;
                    IEnumerable <MessageAttachment>   attachments;
                    int chatWorkEstimate;

                    if ((deviceInfo.OsVersion == null) || (deviceInfo.OsVersion.MajorVersion >= 6))
                    {
                        try
                        {
                            textMessageReader = new TextMessageReaderiOS6(deviceInfo.BackupPath);
                            textMessageReader.ParseDatabase(textDatabaseReader);
                            ChatRoomInformationReaderiOS6 chatRoomInfoReader = new ChatRoomInformationReaderiOS6();
                            chatRoomInfoReader.ParseDatabase(textDatabaseReader);
                            chatReader       = chatRoomInfoReader;
                            attachments      = new List <MessageAttachment>();
                            chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate;
                        }
                        catch (DatabaseQueryException)
                        {
                            textMessageReader = new TextMessageReader(deviceInfo.BackupPath);
                            textMessageReader.ParseDatabase(textDatabaseReader);
                            chatReader       = new List <ChatRoomInformation>();
                            attachments      = new List <MessageAttachment>();
                            chatWorkEstimate = 0;
                        }
                    }
                    else if (deviceInfo.OsVersion.MajorVersion == 5)
                    {
                        textMessageReader = new TextMessageReader2(deviceInfo.BackupPath);
                        textMessageReader.ParseDatabase(textDatabaseReader);
                        ChatRoomInformationReader chatRoomInfoReader = new ChatRoomInformationReader();
                        chatRoomInfoReader.ParseDatabase(textDatabaseReader);
                        chatReader       = chatRoomInfoReader;
                        attachments      = new List <MessageAttachment>();
                        chatWorkEstimate = chatRoomInfoReader.ItemCountEstimate;
                    }
                    else
                    {
                        textMessageReader = new TextMessageReader(deviceInfo.BackupPath);
                        textMessageReader.ParseDatabase(textDatabaseReader);
                        chatReader       = new List <ChatRoomInformation>();
                        attachments      = new List <MessageAttachment>();
                        chatWorkEstimate = 0;
                    }

                    int workEstimate = AllYourTextsLib.Conversation.ConversationManager.GetWorkEstimate(contactReader.ItemCountEstimate,
                                                                                                        textMessageReader.ItemCountEstimate,
                                                                                                        chatWorkEstimate,
                                                                                                        0);
                    if (mergeConversations)
                    {
                        workEstimate += MergingConversationManager.GetWorkEstimateByContacts(contactReader.ItemCountEstimate);
                    }
                    progressCallback.Begin(workEstimate);

                    conversationManager = new ConversationManager(contactReader,
                                                                  textMessageReader,
                                                                  chatReader,
                                                                  attachments,
                                                                  progressCallback);
                    if (mergeConversations)
                    {
                        conversationManager = new MergingConversationManager(conversationManager, progressCallback);
                    }
                }
            }

            return(conversationManager);
        }
Exemplo n.º 21
0
        private void OnWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                if (_conversationManager == null)
                {
                    Application.Current.Shutdown();
                }
                else if (_progressDialog != null)
                {
                    _progressDialog.Close();
                }
            }
            else if (e.Error != null)
            {
                _progressDialog.Close();

                //
                // If the database file is unreadable, don't auto-open it.
                //

                if (_displayOptions != null)
                {
                    _phoneSelectOptions.PhoneDataPath = "";
                    _phoneSelectOptions.Save();
                }

                if (e.Error is DirectoryNotFoundException)
                {
                    ShowDatabaseErrorDialog(new MissingBackupPathException());
                }
                else if (e.Error is FileNotFoundException)
                {
                    FileNotFoundException ex = (FileNotFoundException)e.Error;
                    ShowDatabaseErrorDialog(new MissingBackupFileException(ex.FileName, ex));
                }
                else if (e.Error is UnreadableDatabaseFileException)
                {
                    UnreadableDatabaseFileException ex = (UnreadableDatabaseFileException)e.Error;
                    ShowDatabaseErrorDialog(ex);
                }
                else
                {
                    FailHandler.HandleUnrecoverableFailure(e.Error);
                }

                Application.Current.Shutdown();
            }
            else
            {
                _conversationManager = (IConversationManager)e.Result;

                UpdateModels();

                PopulateConversationList();

                Update();

                _progressDialog.Close();

                _progressCallback = null;
                _progressDialog = null;

                ShowTextsOutOfDateWarningIfNeeded();
            }
        }
Exemplo n.º 22
0
        private void OnWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                if (_conversationManager == null)
                {
                    Application.Current.Shutdown();
                }
                else if (_progressDialog != null)
                {
                    _progressDialog.Close();
                }
            }
            else if (e.Error != null)
            {
                _progressDialog.Close();

                //
                // If the database file is unreadable, don't auto-open it.
                //

                if (_displayOptions != null)
                {
                    _phoneSelectOptions.PhoneDataPath = "";
                    _phoneSelectOptions.Save();
                }

                if (e.Error is DirectoryNotFoundException)
                {
                    ShowDatabaseErrorDialog(new MissingBackupPathException());
                }
                else if (e.Error is FileNotFoundException)
                {
                    FileNotFoundException ex = (FileNotFoundException)e.Error;
                    ShowDatabaseErrorDialog(new MissingBackupFileException(ex.FileName, ex));
                }
                else if (e.Error is UnreadableDatabaseFileException)
                {
                    UnreadableDatabaseFileException ex = (UnreadableDatabaseFileException)e.Error;
                    ShowDatabaseErrorDialog(ex);
                }
                else
                {
                    FailHandler.HandleUnrecoverableFailure(e.Error);
                }

                Application.Current.Shutdown();
            }
            else
            {
                _conversationManager = (IConversationManager)e.Result;

                UpdateModels();

                PopulateConversationList();

                Update();

                _progressDialog.Close();

                _progressCallback = null;
                _progressDialog   = null;

                ShowTextsOutOfDateWarningIfNeeded();
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebConversationScope"/> class.
 /// </summary>
 /// <param name="conversationManager">The conversation manager.</param>
 /// <param name="sessionScope">The session context.</param>
 public WebConversationScope(IConversationManager conversationManager, ISessionScope sessionScope)
 {
     _conversationManager = conversationManager;
     _sessionScope = sessionScope;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NHibernateConversation"/> class.
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="sessionProvider">The session provider.</param>
 /// Implementors should take notice:
 internal NHibernateConversation(IConversationManager manager, ISessionFactory sessionProvider)
 {
     this.manager = manager;
     sessionFactory = sessionProvider;
     BeginSession();
 }