public JournalDetails(User user, int journalID) : base(user, "Journal:" + journalID) { InitializeComponent(); Journal model = null; if (journalID >= 0) { var service = new SupportService(user); model = service.GetJournal(journalID); } else { model = new Journal(); model.JournalID = -1; model.FullName = "<New Journal>"; } _viewModel = new JournalViewModel(model); _traits = tabJournal.AddTabItem("Traits", new TraitControl(user, TraitCategoryType.Journal, _viewModel)); _notes = tabJournal.AddTabItem("Notes", new NotesControl(user, TraitCategoryType.Journal, _viewModel)); tabJournal.AddTabItem("Ownership", new OwnershipDetails(model)); if (_viewModel.JournalID >= 0) { _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); } else { Loaded += new RoutedEventHandler(JournalDetails_Loaded); _traits.IsEnabled = false; _notes.IsEnabled = false; } ChangesCommitted += new PendingChangesCommittedHandler(JournalDetails_ChangesCommitted); this.DataContext = _viewModel; }
void DistributionRegionTooltipContent_Loaded(object sender, RoutedEventArgs e) { var service = new SupportService(User); var fullPath = service.GetDistributionFullPath(DistRegionID); var icon = ImageCache.GetImage("pack://application:,,,/BioLink.Client.Extensibility;component/images/DistributionRegion.png"); imgIcon.Source = icon; if (fullPath != null) { var regions = fullPath.Split('\\'); for (int i = 0; i < regions.Length; ++i) { var region = regions[i]; var parentPanel = new StackPanel() { Orientation = Orientation.Horizontal, Margin = new Thickness(i * 15, i * 25, 0, 0) }; var parentIcon = new Image() { VerticalAlignment = System.Windows.VerticalAlignment.Top, UseLayoutRounding = true, SnapsToDevicePixels = true, Stretch = Stretch.None, Margin = new Thickness(6, 0, 6, 0) }; parentIcon.Source = icon; parentPanel.Children.Add(parentIcon); var weight = FontWeights.Normal; if (i == regions.Length - 1) { weight = FontWeights.Bold; lblHeader.Content = region; } var txt = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Top, Text = region, FontWeight = weight }; parentPanel.Children.Add(txt); grdAncestry.Children.Add(parentPanel); } } lblSystem.Content = String.Format("Distribution Region ID: {0}", DistRegionID); }
public MultimediaReportOptions() { InitializeComponent(); var user = PluginManager.Instance.User; var service = new SupportService(user); _extensions = service.GetMultimediaExtensions(); var types = service.GetMultimediaTypes(); _extensions.Insert(0, "(All)"); _multimediaTypes = new List<string>(); _multimediaTypes.Add("(All)"); foreach (MultimediaType type in types) { if (!string.IsNullOrWhiteSpace(type.Name)) { _multimediaTypes.Add(type.Name); } } cmbExtension.ItemsSource = _extensions; cmbExtension.SelectedIndex = 0; cmbType.ItemsSource = _multimediaTypes; cmbType.SelectedIndex = 0; }
public QueryTool(User user, ToolsPlugin owner) { CommandBindings.Add(new CommandBinding(AddCriteria, ExecutedAddCriteria, CanExecuteAddCriteria)); CommandBindings.Add(new CommandBinding(RemoveCriteria, ExecutedRemoveCriteria, CanExecuteRemoveCriteria)); CommandBindings.Add(new CommandBinding(RemoveAllCriteria, ExecutedRemoveAllCriteria, CanExecuteRemoveAllCriteria)); CommandBindings.Add(new CommandBinding(MoveCriteriaUp, ExecutedMoveCriteriaUp, CanExecuteMoveCriteriaUp)); CommandBindings.Add(new CommandBinding(MoveCriteriaDown, ExecutedMoveCriteriaDown, CanExecuteMoveCriteriaDown)); CommandBindings.Add(new CommandBinding(NewQuery, ExecutedNewQuery, CanExecuteNewQuery)); CommandBindings.Add(new CommandBinding(OpenQuery, ExecutedOpenQuery, CanExecuteOpenQuery)); CommandBindings.Add(new CommandBinding(SaveQuery, ExecutedSaveQuery, CanExecuteSaveQuery)); CommandBindings.Add(new CommandBinding(ShowSQL, ExecutedShowSQL, CanExecuteShowSQL)); CommandBindings.Add(new CommandBinding(ExecuteQuery, ExecutedExecuteQuery, CanExecuteExecuteQuery)); ExecuteQuery.InputGestures.Add(new KeyGesture(Key.F5, ModifierKeys.Control)); InitializeComponent(); User = user; Owner = owner; var service = new SupportService(user); _fields = service.GetFieldMappings(); lvwFields.ItemsSource = _fields; var myView = (CollectionView)CollectionViewSource.GetDefaultView(lvwFields.ItemsSource); var groupDescription = new PropertyGroupDescription("Category"); if (myView.GroupDescriptions != null) { myView.GroupDescriptions.Add(groupDescription); } _model = new ObservableCollection<QueryCriteria>(); criteriaGrid.ItemsSource = _model; var sortItems = new List<String>(new[] { CriteriaSortConverter.NOT_SORTED, "Ascending", "Descending" }); sortColumn.ItemsSource = sortItems; }
public TaxaForDistributionRegionReport(User user, DistributionRegion distRegion, int taxonId = -1) : base(user) { this.TaxonID = taxonId; this.DistributionRegion = distRegion; RegisterViewer(new RTFReportViewerSource()); var service = new SupportService(user); }
private void DoImport() { if (String.IsNullOrEmpty(txtFilename.Text)) { ErrorMessage.Show("You must select a file before proceeding!"); return; } int rowCount = 0; var service = new SupportService(User); using (var parser = new GenericParserAdapter(txtFilename.Text)) { parser.ColumnDelimiter = ','; parser.FirstRowHasHeader = chkFirstRowHeaders.IsChecked.GetValueOrDefault(false); parser.TextQualifier = '\"'; parser.FirstRowSetsExpectedColumnCount = true; var columnNames = new List<String>(); var values = new List<string>(); while (parser.Read()) { if (rowCount == 0) { for (int i = 0; i < parser.ColumnCount; ++i) { if (parser.FirstRowHasHeader) { columnNames.Add(parser.GetColumnName(i)); } else { columnNames.Add("Column" + i); } } } values.Clear(); for (int i = 0; i < parser.ColumnCount; ++i) { values.Add(parser[i]); } String strFullPath = null; if (values.Count == 0) { strFullPath = values[0]; } else { strFullPath = values.Join("\\"); } if (!String.IsNullOrWhiteSpace(strFullPath)) { service.GetDistributionIdFromPath(strFullPath); lblProgress.InvokeIfRequired(() => { lblProgress.Content = strFullPath; lblProgress.UpdateLayout(); }); rowCount++; } } } lblProgress.InvokeIfRequired(() => { lblProgress.Content = String.Format("{0} rows processed.", rowCount); }); btnCancel.Content = "_Close"; }
private void ShowSQLImpl() { var service = new SupportService(User); var sql = service.GenerateQuerySQL(_model, IsDistinct); var frm = new SQLViewer(sql) { Owner = this.FindParentWindow() }; frm.ShowDialog(); }
public override FileInfo GenerateLoanForm(Multimedia template, Loan loan, List <LoanMaterial> material, List <Trait> traits, Contact originator, Contact requestor, Contact receiver) { var tempFile = TempFileManager.NewTempFilename(".docx"); var bytes = SupportService.GetMultimediaBytes(template.MultimediaID); Func <String, String> fieldDataFunc = (String fieldName) => { return(base.SubstitutePlaceHolder(NormaliseFieldName(fieldName), loan, material, traits, originator, requestor, receiver)); }; Merge(fieldDataFunc, bytes, tempFile); return(new FileInfo(tempFile)); }
public LinkedMultimediaItemsControl(MultimediaLinkViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; this.MultimediaID = viewModel.MultimediaID; var service = new SupportService(User); var mm = service.GetMultimedia(MultimediaID); var items = service.ListItemsLinkedToMultimedia(MultimediaID); var model = new ObservableCollection<ViewModelBase>(); foreach (MultimediaLinkedItem item in items) { if ( !string.IsNullOrWhiteSpace(item.CategoryName)) { LookupType t; if (Enum.TryParse<LookupType>(item.CategoryName, out t)) { var vm = PluginManager.Instance.GetViewModel(t, item.IntraCatID); if (vm!= null) { model.Add(vm); vm.Tag = t; } } } } lvw.MouseRightButtonUp += new MouseButtonEventHandler(lvw_MouseRightButtonUp); ListViewDragHelper.Bind(lvw, (dragged) => { if (dragged.Tag is LookupType) { var lookupType = (LookupType) dragged.Tag; var plugin = PluginManager.Instance.GetLookupTypeOwner(lookupType); if (plugin != null) { var data = new DataObject("Pinnable", dragged); var pinnable = new PinnableObject(plugin.Name, lookupType, dragged.ObjectID.Value); data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable); data.SetData(DataFormats.Text, dragged.DisplayLabel); return data; } } return null; }); lvw.ItemsSource = model; CollectionView myView = (CollectionView)CollectionViewSource.GetDefaultView(lvw.ItemsSource); myView.SortDescriptions.Add(new SortDescription("Tag", ListSortDirection.Ascending)); myView.SortDescriptions.Add(new SortDescription("DisplayLabel", ListSortDirection.Ascending)); myView.GroupDescriptions.Add(new LinkedItemGroupDescription()); }
public JsonResult OnDelete(int pId = 0) { var mSupportType = SupportService.LaySupportTypeTheoId(pId); if (mSupportType != null) { MpStartEntities.DeleteObject(mSupportType); MpStartEntities.SaveChanges(); return(Json(new { code = 1, message = "Xóa thành công!" })); } return(Json(new { code = 0, message = "Không tìm thấy kiểu cần xóa." })); }
public bool HasBiotaPermission(int taxonId, PERMISSION_MASK mask) { if (taxonId == 0) { return(true); } // system administrator has full rights to all. if (IsSysAdmin) { return(true); } // Ensure the permissions set at the user group level take precendence to the individual taxon based permissions. if (mask != PERMISSION_MASK.OWNER) { if (!HasPermission(PermissionCategory.SPIN_TAXON, mask)) { return(false); } } if (taxonId < 0) { // new items are automatically approved! return(true); } var service = new SupportService(this); //if (service.HasBiotaPermission(taxonId, mask)) { // return true; //} var perms = service.GetBiotaPermissions(Username, taxonId); if (perms == null) { return(false); } else { if (perms.PermMask1 == 0) { // If there are owners of this taxa then the user needs permissions... return(perms.NumOwners == 0); } else { return((perms.PermMask1 & (int)mask) != 0); } } }
public override List <ViewModelBase> LoadModel() { var service = new SupportService(User); var list = service.GetLabelSets(); var sets = new List <ViewModelBase>(list.Select((model) => { return(new LabelSetViewModel(model)); })); _allItems = service.GetLabelSetItems(); return(sets); }
private bool DoFind(string filter) { if (string.IsNullOrEmpty(filter)) { return(false); } _validate = false; var service = new SupportService(User); var lookupResults = service.LookupSearch(filter, LookupType); _validate = true; if (lookupResults != null) { if (lookupResults.Count > 1) { if (!PluginManager.Instance.CheckSearchResults(lookupResults)) { return(false); } GeneralTransform transform = txt.TransformToAncestor(this); var rootPoint = txt.PointToScreen(transform.Transform(new Point(0, 0))); var frm = new LookupResults(lookupResults) { Owner = this.FindParentWindow(), Top = rootPoint.Y + txt.ActualHeight, Left = rootPoint.X, Width = txt.ActualWidth, Height = 250 }; if (frm.ShowDialog().GetValueOrDefault(false)) { _manualSet = true; Text = frm.SelectedItem.Label; ObjectID = frm.SelectedItem.ObjectID; SelectedObject = frm.SelectedItem; _manualSet = false; return(true); } } else if (lookupResults.Count == 1) { _manualSet = true; Text = lookupResults[0].Label; ObjectID = lookupResults[0].ObjectID; SelectedObject = lookupResults[0]; _manualSet = false; return(true); } } return(false); }
public MaterialByUserWindow(Action<List<LabelSetItem>> successAction = null) { InitializeComponent(); this.SuccessAction = successAction; var service = new SupportService(User); var list = service.GetUsers(); var model = new List<string>(list.Select((user) => { return user.Username; })); model.Insert(0, "<All Users>"); cmbUser.ItemsSource = model; Loaded += new RoutedEventHandler(MaterialByUserWindow_Loaded); }
private void AddMaterialRowsForTaxon(DataMatrix results, Taxon taxon) { var ids = XMLIOService.GetMaterialForTaxon(taxon.TaxaID.Value); foreach (XMLIOMaterialID id in ids) { var links = SupportService.GetMultimediaItems(TraitCategoryType.Material.ToString(), id.MaterialID); foreach (MultimediaLink link in links) { AddTaxonRow(results, taxon, link, "Material", id.MaterialID); } } }
public MaterialByUserWindow(Action <List <LabelSetItem> > successAction = null) { InitializeComponent(); this.SuccessAction = successAction; var service = new SupportService(User); var list = service.GetUsers(); var model = new List <string>(list.Select((user) => { return(user.Username); })); model.Insert(0, "<All Users>"); cmbUser.ItemsSource = model; Loaded += new RoutedEventHandler(MaterialByUserWindow_Loaded); }
private void RenameSelectedGroup() { var selected = tvwGroups.SelectedItem as GroupViewModel; if (selected != null) { InputBox.Show(this.FindParentWindow(), "Rename group '" + selected.GroupName + "'", "Enter the new name for this group", selected.GroupName, (newName) => { var service = new SupportService(User); service.RenameGroup(selected.GroupID, newName); ReloadModel(); SelectGroup(newName); }); } }
private void DeleteSelectedGroup() { var selected = tvwGroups.SelectedItem as GroupViewModel; if (selected != null) { if (this.Question("Are you sure you wish to permanently delete group '" + selected.GroupName + "'", "Delete group '" + selected.GroupName + "'?")) { var service = new SupportService(User); service.DeleteGroup(selected.GroupID); ReloadModel(); } } }
private void DeleteSelectedUser() { var selected = lvwUsers.SelectedItem as UserSearchResultViewModel; if (selected != null) { if (this.Question("Are you sure you wish to permanently delete the user '" + selected.Username + "'?", "Delete " + selected.Username)) { var service = new SupportService(User); service.DeleteUser(selected.Username); ReloadModel(); } } }
private void DoFind() { using (new OverrideCursor(Cursors.Wait)) { var service = new SupportService(User); var extension = cmbExtension.Text == "(All)" ? "" : cmbExtension.Text; var category = cmbType.Text == "(All)" ? "" : cmbType.Text; var model = service.FindMultimedia(extension, category, txtCriteria.Text); _model = new ObservableCollection <MultimediaLinkViewModel>(model.Select((m) => { return(new MultimediaLinkViewModel(m)); })); lvw.ItemsSource = _model; } }
public JsonResult OnEdit(int pId, string pTieuDe, int?pUuTien) { var mSupportType = SupportService.LaySupportTypeTheoId(pId); if (mSupportType != null) { mSupportType.Name = pTieuDe; mSupportType.Date = DateTime.Now; mSupportType.Number = pUuTien; MpStartEntities.SaveChanges(); return(Json(new { code = 1, message = "Sủa thể loại hỗ trợ thành công." })); } return(Json(new { code = 0, message = "Không tìm thấy hỗ trợ để sửa." })); }
protected List <ReferencesReportViewModel> GenerateModel() { var service = new SupportService(User); var model = new List <ReferencesReportViewModel>(); foreach (Int32 refId in ReferenceIDs) { var reference = service.GetReference(refId); if (reference != null) { model.Add(new ReferencesReportViewModel(reference)); } } return(model); }
public ActionResult Edit(int pId = 0) { SupportPage mSupportPage = new SupportPage(); var mSupportType = SupportService.LaySupportTypeTheoId(pId); if (mSupportType != null) { mSupportPage.pSupportType = mSupportType; } else { mSupportPage.Html = "Không tìm thấy tin tức cần sửa."; } return(View("Edit", mSupportPage)); }
protected override void ProcessImpl(User user) { var service = new SupportService(user); var reflink = new RefLink(); reflink.RefLinkID = Model.RefLinkID; reflink.IntraCatID = Model.BiotaID; reflink.RefID = Model.RefID; reflink.RefPage = Model.RefPage; reflink.RefQual = Model.RefQual; reflink.RefLinkType = Model.RefLink; reflink.UseInReport = Model.UseInReports; Model.RefLinkID = service.InsertRefLink(reflink, TraitCategoryType.Taxon.ToString()); }
private void LoadNotesPanel(NoteViewModel selected = null) { using (new OverrideCursor(Cursors.Wait)) { var service = new SupportService(User); var list = service.GetNotes(TraitCategory.ToString(), Owner.ObjectID.Value); _model = new ObservableCollection <NoteViewModel>(list.ConvertAll((model) => { var viewModel = new NoteViewModel(model); viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); return(viewModel); })); RedrawNotes(selected); IsPopulated = true; } }
protected override List <RefLink> SelectReferences(IProgressObserver progress) { var service = new SupportService(User); var taxaService = new TaxaService(User); if (progress != null) { progress.ProgressMessage("Retrieving Reference links..."); } var reflinks = service.GetReferenceLinks(TraitCategoryType.Taxon.ToString(), Taxon.TaxaID.Value); if (Options.IncludeChildReferences == true) { var children = taxaService.GetExpandFullTree(Taxon.TaxaID.Value); var elementCount = 0; int total = children.Count; if (progress != null) { progress.ProgressStart("Extracting references for children..."); } foreach (Taxon child in children) { if (progress != null) { double percent = (((double)elementCount) / ((double)total)) * 100.0; progress.ProgressMessage(string.Format("Processing {0}", child.TaxaFullName), percent); } elementCount++; var links = service.GetReferenceLinks(TraitCategoryType.Taxon.ToString(), child.TaxaID.Value); foreach (RefLink link in links) { reflinks.Add(link); } } if (progress != null) { progress.ProgressEnd(""); } } return(reflinks); }
public void LoadPlugins(PluginAction pluginAction) { var path1 = string.Format("{0}|^BioLink[.].*[.]dll$", AppDomain.CurrentDomain.BaseDirectory); var path2 = string.Format("{0}/plugins", AppDomain.CurrentDomain.BaseDirectory); LoadPlugins(pluginAction, path1, path2); NotifyProgress("Loading html...", 99, ProgressEventType.Update); var service = new SupportService(User); var links = service.GetMultimediaItems(TraitCategoryType.Biolink.ToString(), SupportService.BIOLINK_HTML_INTRA_CAT_ID); if (links.Count > 0) { var directory = new DirectoryInfo(Path.Combine(SystemUtils.GetUserDataPath(), ".BioLink")); if (directory.Exists) { directory.Delete(true); } directory.Create(); string htmlfile = ""; foreach (MultimediaLink link in links) { var filename = Path.Combine(directory.FullName, link.Name + "." + link.Extension); var bytes = service.GetMultimediaBytes(link.MultimediaID); File.WriteAllBytes(filename, bytes); if (link.Extension.StartsWith("html", StringComparison.CurrentCultureIgnoreCase)) { htmlfile = filename; } } if (!string.IsNullOrWhiteSpace(htmlfile)) { BioLinkCorePlugin core = GetExtensionsOfType <BioLinkCorePlugin>()[0]; var browser = new WebBrowser(); AddDocumentContent(core, browser, new DockableContentOptions { Title = "Welcome" }); browser.Navigate(string.Format("file:///{0}", htmlfile)); } } }
public JsonResult OnEdit(int pId, string pTieuDe, int?pUuTien, int?pGroupId, string pNick, string pMobile, string pEmail) { var mSupport = SupportService.LayTheoId(pId); if (mSupport != null) { mSupport.Name = pTieuDe; mSupport.Date = DateTime.Now; mSupport.TypeID = pGroupId; mSupport.Nick = pNick; mSupport.Phone = pMobile; mSupport.Email = pEmail; MpStartEntities.SaveChanges(); return(Json(new { code = 1, message = "Sủa thể hỗ trợ thành công." })); } return(Json(new { code = 0, message = "Không tìm thấy hỗ trợ để sửa." })); }
public ActionResult Edit(int pId = 0) { SupportPage mSupportPage = new SupportPage(); var mSupport = SupportService.LayTheoId(pId); if (mSupport != null) { var mSupportType = SupportService.LaySupportTypeAll(); mSupportPage.HtmlNhom = V308HTMLHELPER.TaoDanhSachSupportType3(mSupportType, (int)mSupport.TypeID); mSupportPage.pSupport = mSupport; } else { mSupportPage.Html = "Không tìm thấy tin tức cần sửa."; } return(View("Edit", mSupportPage)); }
public static string ShowDistinctList(User user, string table, string field, string filter, Control ownerControl = null, Control ownerAncestor = null) { var service = new SupportService(user); Func <IEnumerable <string> > itemsFunc = () => { return(service.GetDistinctValues(table, field)); }; PickListWindow frm = new PickListWindow(user, String.Format("Distinct values for {0}_{1}", table, field), itemsFunc, null, filter, ownerControl, ownerAncestor); if (frm.ShowDialog().GetValueOrDefault(false)) { return(frm.SelectedValue as string); } ; return(null); }
private void txtFind_TypingPaused(string text) { if (string.IsNullOrEmpty(text)) { _findModel = null; } else { var service = new SupportService(User); var list = service.FindJournals(text); _findModel = new ObservableCollection <JournalViewModel>(list.ConvertAll((model) => { return(new JournalViewModel(model)); })); } lstResults.ItemsSource = _findModel; }
private string BuildHierCriteria(string pstrCriteria, string pstrTable, string pstrFieldName) { // // If the field is hierarchical, the 'ONLY' keyword at the end means only that item. If the keyword is // missing, all elements under the hierarchy are included. // string strCriteria = pstrCriteria.Trim(); // Determine if the 'ONLY' keyword is visible. if (strCriteria.EndsWith(" only'", StringComparison.CurrentCultureIgnoreCase)) { // We have the 'ONLY' keyword. return(GetTableAlias(pstrTable) + "." + pstrFieldName + " " + strCriteria.Substring(0, strCriteria.Length - 5) + "'"); } else if (strCriteria.EndsWith(" only", StringComparison.CurrentCultureIgnoreCase)) { return(GetTableAlias(pstrTable) + "." + pstrFieldName + " " + strCriteria.Substring(0, strCriteria.Length - 4)); } // Change the criteria for one that determines the Parentage paths of all the relevant data and produces // a 'x like <parentage path 1>% or x like <parentage path 2>%' type structure. var service = new SupportService(User); var criteria = "("; service.StoredProcReaderForEach("spQueryHierLookup", (reader) => { // ReSharper disable AccessToModifiedClosure if (criteria != "(") { criteria += " OR "; } criteria += GetTableAlias(pstrTable) + ".vchrParentage LIKE '" + reader["vchrParentage"].ToString().Trim() + "%'"; // ReSharper restore AccessToModifiedClosure }, service._P("vchrTableName", pstrTable), service._P("txtCriteria", pstrFieldName + " " + pstrCriteria)); criteria += ")"; if (criteria == "()") { criteria = GetTableAlias(pstrTable) + ".vchrParentage LIKE ''"; } return(criteria); }
public bool ImportMultimedia(XMLImportMultimedia media) { media.ID = -1; StoredProcReaderFirst("spXMLImportMultimedia", (reader) => { media.ID = reader.GetIdentityValue(); }, _P("GUID", media.GUID), _P("txtInsertClause", media.InsertClause), _P("txtUpdateClause", media.UpdateClause)); if (media.ID > 0) { var service = new SupportService(User); service.UpdateMultimediaBytes(media.ID, media.ImageData); } else { Logger.Debug("Failed to import multimedia: {0}. Stored proc did not return a recognizable media id", media.GUID); } return(media.ID >= 0); }
public MultimediaManager(ToolsPlugin plugin, User user) : base(user, "MultimediaManager") { InitializeComponent(); this.Plugin = plugin; var service = new SupportService(user); _extensions = service.GetMultimediaExtensions(); var types = service.GetMultimediaTypes(); _extensions.Insert(0, "(All)"); _multimediaTypes = new List <string>(); _multimediaTypes.Add("(All)"); foreach (MultimediaType type in types) { if (!string.IsNullOrWhiteSpace(type.Name)) { _multimediaTypes.Add(type.Name); } } cmbExtension.ItemsSource = _extensions; cmbExtension.SelectedIndex = 0; cmbType.ItemsSource = _multimediaTypes; cmbType.SelectedIndex = 0; _tempFileManager = new KeyedObjectTempFileManager <int?>((mmId) => { if (mmId.HasValue) { byte[] bytes = service.GetMultimediaBytes(mmId.Value); if (bytes != null) { return(new MemoryStream(bytes)); } } return(null); }); txtCriteria.KeyUp += new KeyEventHandler(txtCriteria_KeyUp); lvw.MouseRightButtonUp += new MouseButtonEventHandler(lvw_MouseRightButtonUp); lvw.KeyUp += new KeyEventHandler(lvw_KeyUp); ListViewDragHelper.Bind(lvw, CreateDragData); }
public UserStatsReportOptions(User user) { InitializeComponent(); this.User = user; UserSearchResult allUsers = new UserSearchResult { Username = "******", FullName = "", UserID = -1 }; var service = new SupportService(user); var model = service.GetUsers(); model.Insert(0, allUsers); cmbUser.ItemsSource = model; cmbUser.SelectedIndex = 0; StartDate = DateTime.Now; EndDate = DateTime.Now; this.DataContext = this; }
private void CopySelectedGroup() { var selected = tvwGroups.SelectedItem as GroupViewModel; if (selected != null) { InputBox.Show(this.FindParentWindow(), "Copy group '" + selected.GroupName + "'", "Enter the new name for the new group", selected.GroupName, (newName) => { var service = new SupportService(User); // Create the new group var newGroupID = service.InsertGroup(newName); // and copy over the existing permissions... service.CopyGroupPermissions(selected.GroupID, newGroupID); // reload ReloadModel(); SelectGroup(newName); }); } }
public bool GenerateNumber() { var autoNum = cmbCategories.SelectedItem as AutoNumberViewModel; if (autoNum != null) { var service = new SupportService(User); int seed = txtNumber.HasValue ? txtNumber.Number : -1; var newAutoNumber = service.GetNextAutoNumber(autoNum.AutoNumberCatID, seed, autoNum.EnsureUnique, AutoNumberTable, AutoNumberField); if (newAutoNumber != null) { this.AutoNumber = newAutoNumber.FormattedNumber; return(true); } } return(false); }
private void UpdatePreview() { var format = FormatSpecifier; if (string.IsNullOrWhiteSpace(format)) { format = SupportService.COORD_FORMAT_DMS; } double value = 35.33333; if (CoordinateType == Utilities.CoordinateType.Longitude) { value = 149.0333; } lblPreview.Content = String.Format("Preview: {0}", SupportService.FormatCoordinate(value, format, CoordinateType)); }
public MultimediaThumbnailViewer(IBioLinkReport report, Data.DataMatrix reportData, Utilities.IProgressObserver progress) { InitializeComponent(); this.Report = report; this.ReportData = reportData; this.Progress = progress; var service = new SupportService(PluginManager.Instance.User); _tempFileManager = new KeyedObjectTempFileManager<int?>((mmId) => { if (mmId.HasValue) { byte[] bytes = service.GetMultimediaBytes(mmId.Value); if (bytes != null) { return new MemoryStream(bytes); } } return null; }); Loaded += new RoutedEventHandler(MultimediaThumbnailViewer_Loaded); }
public FindMultimediaDialog(User user) { InitializeComponent(); User = user; var service = new SupportService(user); _extensions = service.GetMultimediaExtensions(); var types = service.GetMultimediaTypes(); _extensions.Insert(0, "(All)"); _multimediaTypes = new List<string>(); _multimediaTypes.Add("(All)"); foreach (MultimediaType type in types) { if (!string.IsNullOrWhiteSpace(type.Name)) { _multimediaTypes.Add(type.Name); } } cmbExtension.ItemsSource = _extensions; cmbExtension.SelectedIndex = 0; cmbType.ItemsSource = _multimediaTypes; cmbType.SelectedIndex = 0; _tempFileManager = new KeyedObjectTempFileManager<int?>((mmId) => { if (mmId.HasValue) { byte[] bytes = service.GetMultimediaBytes(mmId.Value); return new MemoryStream(bytes); } return null; }); txtCriteria.KeyUp +=new KeyEventHandler(txtCriteria_KeyUp); this.Loaded += new RoutedEventHandler(FindMultimediaDialog_Loaded); SelectedMultimedia = new List<MultimediaLinkViewModel>(); }
private bool CreatePhraseCategory() { var category = txtCategory.Text; if (String.IsNullOrWhiteSpace(category)) { ErrorMessage.Show("You must supply a category name!"); return false; } var supportService = new SupportService(PluginManager.Instance.User); var existingId = supportService.GetPhraseCategoryId(category, false); if (existingId > 0) { ErrorMessage.Show("A Phrase Category already exists with this name!"); return false; } var newId = supportService.InsertPhraseCategory(category, false); if (newId <= 0) { ErrorMessage.Show("Failed to create new category!"); return false; } return true; }
private void GenerateLoanForm(int mmID) { var service = new LoanService(User); var loan = service.GetLoan(LoanID); var loanMaterial = service.GetLoanMaterial(LoanID); // var loanCorrespondence = service.GetLoanCorrespondence(LoanID); var supportSevice = new SupportService(User); var loanTraits = supportSevice.GetTraits(TraitCategoryType.Loan.ToString(), LoanID); var originator = loan.OriginatorID != 0 ? service.GetContact(loan.OriginatorID) : null; var requestor = loan.RequestorID != 0 ? service.GetContact(loan.RequestorID) : null; var receiver = loan.ReceiverID != 0 ? service.GetContact(loan.ReceiverID) : null; var template = supportSevice.GetMultimedia(mmID); var generator = LoanFormGeneratorFactory.GetLoanFormGenerator(template); if (generator != null) { var outputFile = generator.GenerateLoanForm(template, loan, loanMaterial, loanTraits, originator, requestor, receiver); if (outputFile != null) { var filename = ChooseFilename(loan, template); if (!string.IsNullOrWhiteSpace(filename)) { outputFile.CopyTo(filename, true); SystemUtils.ShellExecute(filename); Close(); } } } else { ErrorMessage.Show("Unable to generate loan form - unrecognized template extension: {0}", template.FileExtension); } }
private void LoadMaterialTemplate(int templateId) { var supportService = new SupportService(User); var service = new MaterialService(User); var list = service.GetRDEMaterial(new[] { templateId }); if (list != null && list.Count > 0) { _materialTemplate = new RDEMaterialViewModel(list[0]); _materialTemplate.Traits = supportService.GetTraits(TraitCategoryType.Material.ToString(), _materialTemplate.MaterialID); // need to get associates and subparts... var subparts = service.GetMaterialParts(templateId); var associates = supportService.GetAssociates(TraitCategoryType.Material.ToString(), templateId); foreach (Associate assoc in associates) { var vm = new AssociateViewModel(assoc); _materialTemplate.Associates.Add(vm); } foreach (MaterialPart part in subparts) { var vm = new MaterialPartViewModel(part); _materialTemplate.SubParts.Add(vm); } } if (_materialTemplate != null) { mnuSetMaterialTemplate.Header = String.Format("Set _Material Template ({0}) ...", _materialTemplate.MaterialName); Config.SetProfile(User, ConfigMaterialTemplateId, templateId); } else { mnuSetMaterialTemplate.Header = "Set _Material Template..."; Config.SetProfile(User, ConfigMaterialTemplateId, -1); } }
private void btnLoad_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(ctlStartDate.Date)) { ErrorMessage.Show("Please supply a start date"); return; } if (string.IsNullOrEmpty(ctlEndDate.Date)) { ErrorMessage.Show("Please supply a end date"); return; } StatusMessage("Searching for items..."); using (new OverrideCursor(Cursors.Wait)) { var service = new SupportService(User); var results = service.ListLabelSetItemsForUser(cmbUser.SelectedItem as string, ctlStartDate.GetDateAsDateTime(), ctlEndDate.GetDateAsDateTime()); if (results.Count > 0) { if (SuccessAction != null) { StatusMessage("Add " + results.Count + " items to list..."); SuccessAction(results); StatusMessage("Done."); } this.DialogResult = true; this.Close(); } else { InfoBox.Show("No matching items found.", "No results", this); } } }
void BiotaPermissions_Loaded(object sender, RoutedEventArgs e) { var service = new SupportService(User); var groups = service.GetGroups(); var model = new ObservableCollection<UserEntityViewModel>(); foreach (Group g in groups) { model.Add(new UserEntityViewModel(g)); } var users = service.GetUsers(); foreach (UserSearchResult u in users) { model.Add(new UserEntityViewModel(u)); } lvw.ItemsSource = model; }
private void ShowSQLImpl() { var service = new SupportService(User); var sql = service.GenerateQuerySQL(_model, IsDistinct); var frm = new SQLViewer(sql) {Owner = this.FindParentWindow()}; frm.ShowDialog(); }
private ObservableCollection<ViewModelBase> CreateMaterialViewModels(IEnumerable<RDEMaterial> material, RDESiteVisitViewModel siteVisit) { var supportService = new SupportService(User); siteVisit.Material.Clear(); return new ObservableCollection<ViewModelBase>(material.Select(m => { var vm = new RDEMaterialViewModel(m); vm.Traits = supportService.GetTraits(TraitCategoryType.Material.ToString(), vm.MaterialID); vm.Multimedia = supportService.GetMultimediaItems(TraitCategoryType.Material.ToString(), vm.MaterialID); vm.DataChanged += MaterialViewModelDataChanged; vm.SiteVisit = siteVisit; vm.SiteVisitID = siteVisit.SiteVisitID; siteVisit.Material.Add(vm); vm.Locked = !User.HasPermission(PermissionCategory.SPARC_MATERIAL, PERMISSION_MASK.UPDATE) || _startLockMode; return (ViewModelBase)vm; })); }
public override DataMatrix ExtractReportData(IProgressObserver progress) { var matrix = new DataMatrix(); var service = new SupportService(User); matrix.Columns.Add(new MatrixColumn { Name = IntraCategoryIdColumnName, IsHidden = true }); matrix.Columns.Add(new MatrixColumn { Name = "RefID", IsHidden = true }); matrix.Columns.Add(new MatrixColumn { Name = "RefCode" }); matrix.Columns.Add(new MatrixColumn { Name = "RefType" }); matrix.Columns.Add(new MatrixColumn { Name = "LinkPage" }); matrix.Columns.Add(new MatrixColumn { Name = "LinkQualification" }); matrix.Columns.Add(new MatrixColumn { Name = "LinkQualificationRTF", IsHidden = true }); matrix.Columns.Add(new MatrixColumn { Name = "Title" }); matrix.Columns.Add(new MatrixColumn { Name = "Author" }); matrix.Columns.Add(new MatrixColumn { Name = "BookTitle" }); matrix.Columns.Add(new MatrixColumn { Name = "Edition" }); matrix.Columns.Add(new MatrixColumn { Name = "Editor" }); matrix.Columns.Add(new MatrixColumn { Name = "StartPage" }); matrix.Columns.Add(new MatrixColumn { Name = "EndPage" }); matrix.Columns.Add(new MatrixColumn { Name = "ActualDate" }); matrix.Columns.Add(new MatrixColumn { Name = "ISBN" }); matrix.Columns.Add(new MatrixColumn { Name = "ISSN" }); matrix.Columns.Add(new MatrixColumn { Name = "JournalID", IsHidden = true }); matrix.Columns.Add(new MatrixColumn { Name = "PartNo" }); matrix.Columns.Add(new MatrixColumn { Name = "Place" }); matrix.Columns.Add(new MatrixColumn { Name = "Possess" }); matrix.Columns.Add(new MatrixColumn { Name = "Publisher" }); matrix.Columns.Add(new MatrixColumn { Name = "RefType" }); matrix.Columns.Add(new MatrixColumn { Name = "Series" }); matrix.Columns.Add(new MatrixColumn { Name = "Source" }); matrix.Columns.Add(new MatrixColumn { Name = "FullText" }); matrix.Columns.Add(new MatrixColumn { Name = "FullRTF", IsHidden = true }); matrix.Columns.Add(new MatrixColumn { Name = "JournalAbbrevName" }); matrix.Columns.Add(new MatrixColumn { Name = "JournalAbbrevName2" }); matrix.Columns.Add(new MatrixColumn { Name = "JournalAlias" }); matrix.Columns.Add(new MatrixColumn { Name = "JournalFullName" }); matrix.Columns.Add(new MatrixColumn { Name = "JournalNotes" }); var reflinks = SelectReferences(progress); progress.ProgressMessage("Preparing view model..."); foreach (RefLink link in reflinks) { if (Options.HonourIncludeInReportsFlag) { if (!link.UseInReport.HasValue || !link.UseInReport.Value) { // skip this one as it hasn't got the use in reports flag set. continue; } } var reference = service.GetReference(link.RefID); if (reference != null) { int i = 0; var row = matrix.AddRow(); row[i++] = link.IntraCatID.Value; row[i++] = link.RefID; row[i++] = reference.RefCode; row[i++] = link.RefLinkType; row[i++] = link.RefPage; row[i++] = RTFUtils.StripMarkup(link.RefQual); row[i++] = link.RefQual; row[i++] = RTFUtils.StripMarkup(reference.Title); row[i++] = reference.Author; row[i++] = RTFUtils.StripMarkup(reference.BookTitle); row[i++] = reference.Edition; row[i++] = reference.Editor; row[i++] = reference.StartPage; row[i++] = reference.EndPage; row[i++] = SupportService.FormatDate(reference.ActualDate, "yyyy-MM-dd"); row[i++] = reference.ISBN; row[i++] = reference.ISSN; row[i++] = reference.JournalID; row[i++] = reference.PartNo; row[i++] = reference.Place; row[i++] = reference.Possess; row[i++] = reference.Publisher; row[i++] = reference.RefType; row[i++] = reference.Series; row[i++] = reference.Source; row[i++] = reference.FullText; row[i++] = reference.FullRTF; if (reference.JournalID.HasValue && reference.JournalID.Value > 0) { var journal = service.GetJournal(reference.JournalID.Value); row[i++] = journal.AbbrevName; row[i++] = journal.AbbrevName2; row[i++] = journal.Alias; row[i++] = journal.FullName; row[i++] = journal.Notes; } } } progress.ProgressMessage(""); return matrix; }
public bool HasBiotaPermission(int taxonId, PERMISSION_MASK mask) { if (taxonId == 0) { return true; } // system administrator has full rights to all. if (IsSysAdmin) { return true; } // Ensure the permissions set at the user group level take precendence to the individual taxon based permissions. if (mask != PERMISSION_MASK.OWNER) { if (!HasPermission(PermissionCategory.SPIN_TAXON, mask)) { return false; } } if (taxonId < 0) { // new items are automatically approved! return true; } var service = new SupportService(this); //if (service.HasBiotaPermission(taxonId, mask)) { // return true; //} var perms = service.GetBiotaPermissions(Username, taxonId); if (perms == null) { return false; } else { if (perms.PermMask1 == 0) { // If there are owners of this taxa then the user needs permissions... return perms.NumOwners == 0; } else { return (perms.PermMask1 & (int) mask) != 0; } } }
public bool Authenticate(out String message) { DbConnection connection = null; try { Logger.Debug("Attemping to connect to {0} (Database {1}) with username '{2}'...", ConnectionProfile.Server, ConnectionProfile.Database, Username); using (GetConnection()) { message = "Ok"; // Load permissions.... Logger.Debug("Retrieving User permissions"); var service = new SupportService(this); var user = service.GetUser(Username); if (user != null) { var permissions = service.GetPermissions(user.GroupID); _permissions = permissions.ToDictionary(p => (PermissionCategory)p.PermissionID); if (user.CanCreateUsers) { _permissions[PermissionCategory.USERMANAGER_USER] = new Permission { Mask1 = 199 }; } } return true; } } catch (DbException sqlex) { message = sqlex.Message; Logger.Warn("SQL Exception: {0}", sqlex.Message); } catch (Exception ex) { message = ex.Message; Logger.Error("Unexpected error connecting to database!", ex); } finally { if (connection != null) { connection.Close(); connection.Dispose(); } } return false; }
private RDESiteViewModel CreateSiteViewModel(RDESite site, bool addChangedHandler = true) { var supportService = new SupportService(User); var vm = new RDESiteViewModel(site) { Locked = !User.HasPermission(PermissionCategory.SPARC_SITE, PERMISSION_MASK.UPDATE) || _startLockMode }; if (site.SiteID >= 0) { vm.Traits = supportService.GetTraits(TraitCategoryType.Site.ToString(), site.SiteID); } if (addChangedHandler) { vm.DataChanged += SiteViewModelDataChanged; } return vm; }
void GenerateLoanFormControl_Loaded(object sender, RoutedEventArgs e) { var service = new SupportService(User); var forms = service.GetMultimediaItems(TraitCategoryType.Biolink.ToString(), SupportService.BIOLINK_INTRA_CAT_ID); var model = new ObservableCollection<LoanFormTemplateViewModel>(forms.Select(m => new LoanFormTemplateViewModel(m))); lvw.ItemsSource = model; }
void AddToLabelSet_Loaded(object sender, RoutedEventArgs e) { var service = new MaterialService(User); this.Material = service.GetMaterial(MaterialID); txtItem.Text = Material.MaterialName; var supportService = new SupportService(User); var sets = supportService.GetLabelSets(); cmbLabelSets.ItemsSource = sets; if (sets.Count > 0) { cmbLabelSets.SelectedIndex = 0; optExisting.IsChecked = true; } else { optExisting.IsEnabled = false; optNewLabelSet.IsChecked = true; } }
public override DataMatrix ExtractReportData(IProgressObserver progress) { var service = new SupportService(User); return service.ExecuteQuery(Criteria, Distinct); }
public ReferenceDetail(User user, int referenceID, bool readOnly) : base(user, "Reference:" + referenceID) { InitializeComponent(); this.IsReadOnly = readOnly; var refTypeList = new List<RefTypeMapping>(); foreach (string reftypecode in SupportService.RefTypeMap.Keys) { refTypeList.Add(SupportService.RefTypeMap[reftypecode]); } Reference model = null; if (referenceID >= 0) { var service = new SupportService(user); model = service.GetReference(referenceID); } else { model = new Reference(); model.RefID = -1; txtRefCode.IsReadOnly = false; Loaded += new RoutedEventHandler(ReferenceDetail_Loaded); model.RefType = refTypeList[0].RefTypeCode; } _viewModel = new ReferenceViewModel(model); _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); this.DataContext = _viewModel; cmbRefType.ItemsSource = refTypeList; cmbRefType.DisplayMemberPath = "RefTypeName"; txtPossess.BindUser(User, PickListType.Phrase, "Reference Possess", TraitCategoryType.Reference); txtSource.BindUser(User, PickListType.Phrase, "Reference Source", TraitCategoryType.Reference); _traitsTab = tabRef.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Reference, _viewModel) { IsReadOnly = readOnly }); _notesTab = tabRef.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Reference, _viewModel) { IsReadOnly = readOnly }); _mmTab = tabRef.AddTabItem("Multimedia", new MultimediaControl(User, TraitCategoryType.Reference, _viewModel) { IsReadOnly = readOnly }); _linksTab = tabRef.AddTabItem("Taxon Links", new OneToManyControl(new TaxonRefLinksControl(User, _viewModel.RefID)) { IsReadOnly = readOnly }); _viewModel.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_viewModel_PropertyChanged); tabRef.AddTabItem("Ownership", new OwnershipDetails(_viewModel.Model)); cmbRefType.SelectionChanged += new SelectionChangedEventHandler(cmbRefType_SelectionChanged); this.ChangesCommitted += new PendingChangesCommittedHandler(ReferenceDetail_ChangesCommitted); }
private string BuildBiotaDistCriteria(string pstrCriteria) { // // If the field is Biota Distribution, the 'ONLY' keyword at the end means only that item. If the 'only' keyword is // missing, all elements under the Distribution as well as above are included. // var strCriteria = pstrCriteria.Trim(); // Determine if the 'ONLY' keyword is visible. if (strCriteria.EndsWith(" only", StringComparison.CurrentCultureIgnoreCase)) { // We have the 'ONLY' keyword. return strTABLE_DIST_REGION_ABBREV + ".vchrName " + strCriteria.Substring(0, strCriteria.Length - 4); } // Change the criteria for one that determines the Parentage paths of all the relevant data and produces // a 'x like <parentage path 1>% or x like <parentage path 2>%' type structure. strCriteria = "("; var service = new SupportService(User); service.StoredProcReaderForEach("spQueryBiotaDistLookup", (reader) => { // Extract the components var strID = reader["intDistributionRegionID"].ToString().Trim(); var strParentage = reader["vchrParentage"].ToString().Trim(); var regex = new Regex(string.Format(@"^[\\](.*?)[\\]*{0}$", strID)); var match = regex.Match(strParentage); if (match.Success && match.Groups.Count > 1) { strParentage = match.Groups[1].Value; if (!string.IsNullOrEmpty(strParentage)) { strParentage = strParentage.Replace("\\", ","); // Perform the join for multiple selectors // ReSharper disable AccessToModifiedClosure if (strCriteria != "(") { strCriteria += " OR "; // ReSharper restore AccessToModifiedClosure } strCriteria += "((" + strTABLE_BIOTA_DIST_ABBREV + ".intDistributionRegionID IN (" + strParentage + ") AND " + strTABLE_BIOTA_DIST_ABBREV + ".bitThroughoutRegion = 1) OR " + strTABLE_BIOTA_DIST_ABBREV + ".intDistributionRegionID = " + strID + " OR " + strTABLE_DIST_REGION_ABBREV + ".vchrParentage LIKE '" + reader["vchrParentage"].ToString().Trim() + "\\%')"; } } }, service._P("txtCriteria", pstrCriteria)); strCriteria += ")"; if (strCriteria == "()") { strCriteria = strTABLE_DIST_REGION_ABBREV + ".vchrParentage LIKE ''"; } return strCriteria; }
void DistributionControl_Drop(object sender, DragEventArgs e) { var pinnable = e.Data.GetData(PinnableObject.DRAG_FORMAT_NAME) as PinnableObject; e.Effects = DragDropEffects.None; if (pinnable != null && pinnable.LookupType == LookupType.DistributionRegion) { var service = new SupportService(User); var parentage = service.GetDistributionFullPath(pinnable.ObjectID); if (!string.IsNullOrEmpty(parentage)) { var dist = new TaxonDistribution { BiotaDistID = -1, DistRegionFullPath = parentage, TaxonID = Taxon.TaxaID.Value, DistRegionID = pinnable.ObjectID }; AddViewModelByPath(_model, dist); RegisterUniquePendingChange(new SaveDistributionRegionsCommand(Taxon.Taxon, _model)); } } }
protected override void ProcessImpl(User user) { var service = new SupportService(user); service.UpdateBiotaPermission(GroupID, UserID, Taxon.TaxaID.Value, Mask); }
private string BuildHierCriteria(string pstrCriteria, string pstrTable, string pstrFieldName) { // // If the field is hierarchical, the 'ONLY' keyword at the end means only that item. If the keyword is // missing, all elements under the hierarchy are included. // string strCriteria = pstrCriteria.Trim(); // Determine if the 'ONLY' keyword is visible. if (strCriteria.EndsWith(" only'", StringComparison.CurrentCultureIgnoreCase)) { // We have the 'ONLY' keyword. return GetTableAlias(pstrTable) + "." + pstrFieldName + " " + strCriteria.Substring(0, strCriteria.Length - 5) + "'"; } else if (strCriteria.EndsWith(" only", StringComparison.CurrentCultureIgnoreCase)) { return GetTableAlias(pstrTable) + "." + pstrFieldName + " " + strCriteria.Substring(0, strCriteria.Length - 4); } // Change the criteria for one that determines the Parentage paths of all the relevant data and produces // a 'x like <parentage path 1>% or x like <parentage path 2>%' type structure. var service = new SupportService(User); var criteria = "("; service.StoredProcReaderForEach("spQueryHierLookup", (reader) => { // ReSharper disable AccessToModifiedClosure if (criteria != "(") { criteria += " OR "; } criteria += GetTableAlias(pstrTable) + ".vchrParentage LIKE '" + reader["vchrParentage"].ToString().Trim() + "%'"; // ReSharper restore AccessToModifiedClosure }, service._P("vchrTableName", pstrTable), service._P("txtCriteria", pstrFieldName + " " + pstrCriteria)); criteria += ")"; if (criteria == "()") { criteria = GetTableAlias(pstrTable) + ".vchrParentage LIKE ''"; } return criteria; }