示例#1
0
        private void Get()
        {
            // Check if save can be triggered
            var allValid = AreAllDependenciesValid();

            if (!allValid)
            {
                UserMessageService.ShowWarning("Please correct all errors before saving.");
                return;
            }

            try
            {
                GetDependencies(TargetsFileData);
            }
            catch (Exception ex)
            {
                // TODO: DependencyService should only throw well-known exceptions
                UserMessageService.ShowError(String.Format("An fatal error occurred while getting the dependencies. See DependencyManager output window for further information!"));

                Logger.LogMsg("\nFatal error occured while fetching dependencies. Aborting ...");
                Logger.LogMsg(String.Format("Exception message: {0}", ex.Message));
                Logger.LogMsg(String.Format("Stacktrace:\n{0}\n", ex.StackTrace));
                Logger.ShowMessages();
            }
        }
示例#2
0
        public ActionResult AddAnswer(AddAnswerVM model)
        {
            if (model.IsLoad == EditMessageVM.LoadImage)
            {
                model.Message = UserMessageService.GetByPK(model.Message.UserMessageID);
                return(ProcessImage(model));
            }
            var message = new UserMessage {
                ParentMessageID = model.Message.UserMessageID,
                IsActive        = true,
                CreatorUserID   = User.UserID,
                Text            = model.Description
            };
            var parent = UserMessageService.GetAll(x =>
                                                   x.UserMessageID == model.Message.UserMessageID &&
                                                   x.IsAnswered).FirstOrDefault();

            if (parent != null)
            {
                parent.IsAnswered = false;
            }

            InsertAndSubmit(message);

            return(RedirectToAction(() => Details(model.Message.UserMessageID, 1)));
        }
示例#3
0
        void EnsureNoProjectDesignersAreOpen()
        {
            var notified = UserMessageService == null;

            // TODO: Remove this function when NuPattern implements a workaround.
            // The workaround is to close all the project designers, which can cause exceptions in NuPattern's t4 unfold logic.
            // Related NuPattern issue: https://github.com/NuPattern/NuPattern/issues/2
            foreach (var window in Dte.Windows.OfType <Window>().Where(w => w.Type == vsWindowType.vsWindowTypeDocument))
            {
                try
                {
                    // just so this expression compiles
                    var ignore = window.ProjectItem;
                }
                catch (InvalidCastException)
                {
                    if (!notified)
                    {
                        notified = true;

                        UserMessageService.ShowInformation("ServiceMatrix has detected that some Project Designers are open. These designers will now be closed in order to proceed with code generation.");
                    }

                    window.Close();
                }
            }
        }
示例#4
0
        private ActionResult ForumMessages(long?messageID, List <int> sectionIds)
        {
            var messages = (sectionIds.Any()
                                ? UserMessageService.GetAll().Where(um => sectionIds.Contains(um.MessageSectionID.Value))
                                : UserMessageService.GetAll().Where(um => um.ParentMessageID == messageID))
                           .OrderByDescending(m => m.CreateDate)
                           .Take(CommonConst.MessageCount).ToList();
            var title = string.Empty;

            if (sectionIds.Any())
            {
                if (sectionIds.Count == 1)
                {
                    var section = MessageSectionService.GetByPK(sectionIds.First());
                    title = section.Name;
                }
                else
                {
                    title = "Сообщения форума";
                }
            }
            else
            {
                var message = UserMessageService.GetByPK(messageID);
                if (message == null)
                {
                    title = "Сообщение не найдено";
                }
            }
            return(GetFeed(title, messages));
        }
示例#5
0
        private void Save(TargetsFileData targetsFileData)
        {
            // this is where the actual saving is triggered,
            // including a check to see if we can save at all

            // first check if we can save
            var allValid = AreAllDependenciesValid();

            if (!allValid)
            {
                UserMessageService.ShowWarning("Please correct all errors before saving.");
                return;
            }

            try
            {
                SaveDependencies(targetsFileData);
            }
            catch (Exception ex)
            {
                // TODO: this should throw well-known exceptions only

                UserMessageService.ShowError("An error occurred while saving the dependencies file: " + ex.Message);
            }
        }
示例#6
0
        public ActionResult AnsweredToggle(long messageID)
        {
            var message = UserMessageService.GetByPK(messageID);

            message.IsAnswered = !message.IsAnswered;
            UserMessageService.SubmitChanges();
            return(RedirectBack());
        }
 public ActionResult ViewUserMessage(int id)
 {
     if (id > 0)
     {
         var model = new UserMessageService().GetUserMessage(id);
         return(View(model));
     }
     return(View());
 }
示例#8
0
        public ActionResult GroupMessages(string tc)
        {
            var messages = UserMessageService.GetAll(um =>
                                                     um.Parent.Group.Teacher_TC == tc)
                           .OrderByDescending(m => m.CreateDate)
                           .Take(CommonConst.MessageCount).ToList();

            return(GetFeed("Лента преподавателя", messages));
        }
示例#9
0
        public ActionResult MessagesNotAnswered()
        {
            var messages = UserMessageService.GetAll(um => um.ParentMessageID == null &&
                                                     um.MessageSectionID.HasValue &&
                                                     !um.IsAnswered)
                           .OrderByDescending(m => m.CreateDate)
                           .Take(50).ToList();

            return(GetFeed("Не отвеченные сообщения", messages));
        }
示例#10
0
        private List <UserMessage> GetAllSectionsMessages(List <int> sections)
        {
            var messages = UserMessageService.GetAll(um => sections.Contains(um.MessageSectionID.Value))
                           .Union(UserMessageService.GetAll(um =>
                                                            sections.Contains(um.Parent.MessageSectionID.Value)))
                           .OrderByDescending(m => m.CreateDate)
                           .Take(CommonConst.MessageCount).ToList();

            return(messages);
        }
示例#11
0
        public ActionResult Edit(long messageId)
        {
            var message = UserMessageService.GetByPK(messageId);

            CheckPermission(message);

            return(View(ViewNames.AddMessage, new EditMessageVM {
                MessageId = message.UserMessageID,
                Description = message.Text,
                MessageTitle = message.Title,
            }));
        }
示例#12
0
        public ServiceContainer(SynchronizationContext synchronizationContext)
        {
            var tokenStore    = new TokenStore();
            var uri           = new RestServiceUriFactory();
            var loginPersiter = new TokenPersister();

            AuthenticationService = new AuthenticationService(tokenStore, uri, loginPersiter, synchronizationContext);
            RoomService           = new RoomService(tokenStore, uri);
            GlobalRoomService     = new GlobalRoomsService(tokenStore, uri, synchronizationContext);
            UserStateService      = new UserStateService(tokenStore, uri, new AgentTypeProvider(TimeWarpAgent.WindowsTrayClient));
            UserMessageService    = new UserMessageService(tokenStore, uri, synchronizationContext);
        }
示例#13
0
        public ActionResult Section(int?sectionID, int?pageIndex)
        {
            var section = MessageSectionService.GetByPK(sectionID);

            if (section == null)
            {
                return(null);
            }
            if ((section.IsGraduateClubOrChildren) &&
                !User.GetOrDefault(x => x.InRole(Role.GraduateClubAccess)))
            {
                return(BaseView(new PagePart("Доступ только для выпускников")));
            }
            if (section.Children.Any())
            {
                var model2 = new SectionListVM {
                    MessageSections = section.Children
                                      .AsQueryable().IsActive().ToList(),
                    User = User
                };
                foreach (var messageSection in model2.MessageSections)
                {
                    messageSection.MessageCount = MessageSectionService
                                                  .SectionMessageCounts().GetValueOrDefault(messageSection
                                                                                            .MessageSectionID);
                    messageSection.LastMessageDate = MessageSectionService
                                                     .SectionLastMessageDates().GetValueOrDefault(messageSection
                                                                                                  .MessageSectionID);
                }
                return(View(ViewNames.SectionList, model2));
            }
            pageIndex = pageIndex ?? 1;
            var messages = UserMessageService.GetAll()
                           .Where(um => um.MessageSectionID == sectionID && um.IsActive)
                           .OrderByDescending(um =>
                                              um.Children.Max(um2 => (DateTime?)um2.CreateDate)
                                              ?? um.CreateDate)
                           .ToPagedList(pageIndex.Value - 1);
            var messageIds    = messages.Select(x => x.UserMessageID).ToList();
            var messageCounts = UserMessageService
                                .GetAll(x => messageIds.Contains(x.UserMessageID))
                                .Select(x => new { x.UserMessageID, x.Children.Count }).ToList()
                                .ToDictionary(x => x.UserMessageID, x => x.Count);
            var model =
                new SectionMessageListVM {
                Messages      = messages,
                MessageCounts = messageCounts,
                Section       = section,
            };

            return(View(ViewNames.MessageList, model));
        }
示例#14
0
        public ActionResult MessagesForUser(int userId)
        {
            var messages = UserMessageService.GetAll(um =>
                                                     um.CreatorUserID != userId &&
                                                     UserMessageService.GetAll(x => x.CreatorUserID == userId)
                                                     .Select(x => x.ParentMessageID ?? x.UserMessageID)
                                                     .Contains(um.ParentMessageID.Value)
                                                     )
                           .OrderByDescending(m => m.CreateDate)
                           .Take(CommonConst.MessageCount).ToList();

            return(GetFeed("Персональная лента", messages));
        }
示例#15
0
        private List <UserMessage> GetLastMessages(decimal groupID)
        {
            var lastMessages = new List <UserMessage>();
            var rootMessage  = GetGroupRootMessage(groupID);

            if (rootMessage != null)
            {
                lastMessages = UserMessageService.GetAll(x =>
                                                         x.ParentMessageID == rootMessage.UserMessageID).OrderByDescending(x =>
                                                                                                                           x.CreateDate).Take(5).ToList();
            }
            return(lastMessages);
        }
示例#16
0
        public int CreateEditorInstance(
            uint grfCreateDoc,
            string pszMkDocument,
            string pszPhysicalView,
            IVsHierarchy pvHier,
            uint itemid,
            IntPtr punkDocDataExisting,
            out IntPtr ppunkDocView,
            out IntPtr ppunkDocData,
            out string pbstrEditorCaption,
            out Guid pguidCmdUI,
            out int pgrfCDW)
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering {0} CreateEditorInstance()", ToString()));

            // Initialize to null
            ppunkDocView       = IntPtr.Zero;
            ppunkDocData       = IntPtr.Zero;
            pguidCmdUI         = GuidList.guidAIT_DMF_DependencyEditorFactory;
            pgrfCDW            = 0;
            pbstrEditorCaption = null;

            // Validate inputs
            if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
            {
                return(VSConstants.E_INVALIDARG);
            }
            if (punkDocDataExisting != IntPtr.Zero)
            {
                return(VSConstants.VS_E_INCOMPATIBLEDOCDATA);
            }

            // Create the Document (editor)
            VisualEditorPane newEditor;

            try
            {
                newEditor = new VisualEditorPane(pszMkDocument);
            }
            catch (Exception e)
            {
                // Show Error Dialog and return S_OK to not show the visual studio error dialog!
                UserMessageService.ShowError(e.Message);
                return(VSConstants.S_OK);
            }
            ppunkDocView       = Marshal.GetIUnknownForObject(newEditor);
            ppunkDocData       = Marshal.GetIUnknownForObject(newEditor);
            pbstrEditorCaption = string.Empty;

            return(VSConstants.S_OK);
        }
示例#17
0
        public ActionResult AddAnswer(long messageID)
        {
            var userMessage = UserMessageService.GetByPK(messageID);

            if (userMessage == null)
            {
                return(null);
            }
            var model = new AddAnswerVM {
                Message = userMessage,
                CannotAddMessageToClub = CheckCannotAddMessageToClub(userMessage.MessageSection)
            };

            return(View(model));
        }
        public UserMessagePageViewModel(int userId)
        {
            _ds     = new UserMessageService();
            _userId = userId;

            GetData(limitCount);

            LoadMoreCommand = new DelegateCommand();
            LoadMoreCommand.ExecuteAction = new Action <object>(LoadMoreExecute);

            RefreshCommand = new DelegateCommand();
            RefreshCommand.ExecuteAction = new Action <object>(RefreshExecute);

            SubmitCommand = new DelegateCommand();
            SubmitCommand.ExecuteAction = new Action <object>(SubmitExecute);
        }
示例#19
0
        public UserMessage GetOrCreateGroupRootMessage(decimal groupID)
        {
            var rootMessage = GetGroupRootMessage(groupID);

            if (rootMessage == null)
            {
                var text = GetGroupTitle(groupID);
                rootMessage = new UserMessage {
                    CreatorUserID = CommonConst.AdminUserID,
                    Text          = text,
                    Title         = text,
                    GroupID       = groupID,
                };
                UserMessageService.InsertAndSubmit(rootMessage);
            }
            return(rootMessage);
        }
示例#20
0
        public App()
        {
            this.Startup            += this.Application_Startup;
            this.Exit               += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;

            _tokenStore            = new TokenStore();
            _restServiceUriFactory = new RestServiceUriFactory();
            _authenticationService = new AuthenticationService(_tokenStore, _restServiceUriFactory, new NullTokenPersiter(), SynchronizationContext.Current);
            _roomService           = new RoomService(_tokenStore, _restServiceUriFactory);
            _userMessageService    = new UserMessageService(_tokenStore, _restServiceUriFactory,
                                                            SynchronizationContext.Current);
            _authenticationService.LoginCompleted += _authenticationService_LoginCompleted;


            InitializeComponent();
        }
        /// <summary>
        /// Save settings to team foundation registry
        /// </summary>
        private void Save()
        {
            _settings.PathToSevenZipExe      = PathToSevenZipExe;
            _settings.SelectedMultiSiteEntry = SelectedSite;

            try
            {
                _settings.SaveLocalRegistrySettings();
                SaveSettingsFailed = false;
                RaiseNotifyPropertyChanged(() => SaveSettingsFailed);
            }
            catch (Exception exception)
            {
                UserMessageService.ShowError("Failed to save settings to windows registry.");
                Logger.Instance().Log(TraceLevel.Error, "Failed to save settings to windows registry. Error was {0}", exception.ToString());
            }
            finally
            {
                LoadSettings();
            }
        }
示例#22
0
        public ActionResult Delete(long messageID)
        {
            var message = UserMessageService.GetByPK(messageID);

            if (User.InRole(Role.ForumAdmin) || (User.InRole(Role.Trainer) && message.CreatorUserID == User.UserID))
            {
                UserMessageService.DeleteAndSubmit(message);
                if (message.ParentMessageID.HasValue)
                {
                    return(RedirectToAction(() =>
                                            Details(message.ParentMessageID.Value, 1)));
                }
                if (message.MessageSectionID.HasValue)
                {
                    return(RedirectToAction(() =>
                                            Section(message.MessageSectionID.Value, 1)));
                }
            }

            return(RedirectBack());
        }
示例#23
0
        public ActionResult EditPost(EditMessageVM model)
        {
            if (model.IsLoad == EditMessageVM.LoadImage)
            {
                return(ProcessImage(model, ViewNames.AddMessage));
            }

            var message = UserMessageService.GetByPK(model.MessageId);

            CheckPermission(message);
            message.Title = model.MessageTitle;
            message.Text  = model.Description;
            CheckMaxLength(message);
            UserMessageService.SubmitChanges();
            if (message.Parent.GetOrDefault(x => x.GroupID) > 0)
            {
                return(RedirectToAction(() => Group(message.Parent.GroupID.Value)));
            }
            return(RedirectToAction(() => Section(
                                        message.MessageSectionID ?? message.Parent.MessageSectionID, 1)));
        }
示例#24
0
        /// <summary>
        /// Save settings to team foundation registry
        /// </summary>
        private void Save()
        {
            _settings.FetchDependenciesOnLocalSolutionBuild  = FetchDependenciesOnLocalSolutionBuild;
            _settings.ValidDependencyDefinitionFileExtension = FilenameExtension.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            _settings.RelativeOutputPath          = RelativeOutputPath;
            _settings.BinaryRepositoryTeamProject = BinaryRepositoryTeamProject;
            _settings.IsBinaryRepositoryComponentSettingsEnabled = IsBinaryRepositoryComponentSettingsEnabled;
            _settings.BinaryRepositoryTeamProjectCollectionUrl   = BinaryRepositoryTeamProjectCollectionUri;
            _settings.BinaryRepositoryFilterComponentList        = BinaryRepositoryFilterComponentList;
            _settings.IsZippedDependencyAllowed = IsZippedDependencyAllowed;
            _settings.IsMultiSiteAllowed        = IsMultiSiteAllowed;
            _settings.MultiSiteList             = Sites.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            // create a comma separated list of disabled resolvers
            _settings.DisabledResolvers = string.Join(",", ResolverTypes.Where(x => x.IsEnabled == false).Select(x => x.ReferenceName));

            try
            {
                _settings.Save();
                SaveSettingsFailed = false;
                RaiseNotifyPropertyChanged(() => SaveSettingsFailed);
            }
            catch (AccessCheckException)
            {
                Logger.Instance().Log(TraceLevel.Error, "You don't have permission to save to the registry.");
                SaveSettingsFailed = true;
                RaiseNotifyPropertyChanged(() => SaveSettingsFailed);
            }
            catch (Exception exception)
            {
                UserMessageService.ShowError("Failed to save settings to team foundation server registry.");
                Logger.Instance().Log(TraceLevel.Error, "Failed to save settings to team foundation server registry. Error was {0}", exception.ToString());
            }
            finally
            {
                LoadSettings();
            }
        }
示例#25
0
        public ActionResult PrivateList(int receiverID, int?pageIndex)
        {
            pageIndex = pageIndex ?? 1;
            var sender   = AuthService.CurrentUser;
            var receiver = UserService.GetByPK(receiverID);
            var userID   = sender.UserID;
            var messages =
                UserMessageService.GetAll()
                .Where(um => (um.CreatorUserID == userID &&
                              um.ReceiverUserID == receiverID) ||
                       (um.CreatorUserID == receiverID &&
                        um.ReceiverUserID == userID))
                .OrderByDescending(um => um.CreateDate)
                .ToPagedList(pageIndex.Value - 1);
            var model =
                new PrivateMessageListVM {
                Sender   = sender,
                Receiver = receiver,
                Messages = messages,
            };

            return(View(model));
        }
        public JsonResult UserMessages()
        {
            var items = new UserMessageService().GetUserMessages();

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
        public JsonResult UserMessagesByPaging(DataTablesPaging request)
        {
            var view = new UserMessageService().GetUserMessagesByPaging(request);

            return(Json(view, JsonRequestBehavior.AllowGet));
        }
示例#28
0
 private void InsertAndSubmit(UserMessage message)
 {
     CheckMaxLength(message);
     UserMessageService.InsertAndSubmit(message);
 }
 /// <summary>
 /// Initializes <see cref="UserMessageController"/>
 /// </summary>
 /// <param name="userMessageService"></param>
 /// <param name="mapper"></param>
 public UserMessageController(UserMessageService userMessageService,
                              IMapper mapper)
 {
     this.UserMessageService = userMessageService;
     this.Mapper             = mapper;
 }
示例#30
0
 private UserMessage GetGroupRootMessage(decimal groupID)
 {
     return(UserMessageService.GetAll()
            .FirstOrDefault(x => x.GroupID == groupID));
 }