public void SendReminder(SendReminderParameterObject param) { Employee sender = Session.GetObjectByKey <Employee>(SecuritySystem.CurrentUserId); ViewShortcut shortcut = new ViewShortcut("Task_DetailView", Oid.ToString()); string url = "http://rnd.ntmarein.local/Default.aspx" + "?Shortcut" + shortcut.ToString(); string mSubject = string.Format("Reminder: {0}", this.Subject); string mSendTo = AssignedTo.CorporateEmail; string mBody = string.Format("Dear {0},<br/>", AssignedTo.FullName); mBody += string.Format("<p>This is a reminder from {0} for your task <strong><a href='{1}'>{2}</a></strong>.</p>", sender.FullName, url, Subject); mBody += string.Format("<p>The task will due on {0}. Please review detailed task information from Marbid system and complete the task immediately.</p>", DueDate); mBody += string.Format("<p>Bellow is an additional comment from {0}:</p>", sender.FullName); mBody += string.Format("<quote>{0}</quote>", param.AdditionalMessage); mBody += string.Format("<p>To review the task please click following URL:<br/><a href='{0}'>{0}</a>", url); Mailer sMailer = new Mailer("*****@*****.**", AssignedTo.CorporateEmail, mSubject, mBody); if (param.SendCopyToMySelf) { sMailer.CC = sender.CorporateEmail; } sMailer.SendMail(); Session session = this.Session; TaskNote tnote = new TaskNote(session); tnote.CreateDate = DateTime.Now; tnote.Note = string.Format("<strong>Reminder is sent:</strong><br/>{0}", param.AdditionalMessage); tnote.IsSystemNote = true; TaskNotes.Add(tnote); tnote.Save(); Session.CommitTransaction(); Session.Save(this); }
private void ShowNavigationItemController_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e) { ViewShortcut shortcut = e.ActionArguments.SelectedChoiceActionItem.Data as ViewShortcut; if (shortcut != null) { oldListView = Application.ProcessShortcut(shortcut) as ListView; if (oldListView != null) { e.Handled = true; NonPersistentObjectSpace nonPersistentObjectSpace = (NonPersistentObjectSpace)Application.CreateObjectSpace(typeof(ViewFilterContainer)); IObjectSpace persistentObjectSpace = Application.CreateObjectSpace(typeof(ViewFilterObject)); nonPersistentObjectSpace.AdditionalObjectSpaces.Add(persistentObjectSpace); ViewFilterContainer newViewFilterContainer = nonPersistentObjectSpace.CreateObject <ViewFilterContainer>(); newViewFilterContainer.ObjectType = oldListView.ObjectTypeInfo.Type; newViewFilterContainer.Filter = GetFilterObject(persistentObjectSpace, ((IModelListViewAdditionalCriteria)oldListView.Model).AdditionalCriteria, newViewFilterContainer.ObjectType); DetailView filterDetailView = Application.CreateDetailView(nonPersistentObjectSpace, newViewFilterContainer); filterDetailView.Caption = String.Format("Filter for the {0} ListView", oldListView.Caption); filterDetailView.ViewEditMode = ViewEditMode.Edit; e.ActionArguments.ShowViewParameters.CreatedView = filterDetailView; e.ActionArguments.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow; DialogController dialogCotnroller = Application.CreateController <DialogController>(); dialogCotnroller.Accepting += new EventHandler <DialogControllerAcceptingEventArgs>(dialogCotnroller_Accepting); dialogCotnroller.Cancelling += dialogCotnroller_Cancelling; dialogCotnroller.ViewClosed += dialogCotnroller_ViewClosed; e.ActionArguments.ShowViewParameters.Controllers.Add(dialogCotnroller); } } }
public override string GetQueryString(ViewShortcut viewShortcut) { if (viewShortcut != null && !IsNewObjectView(viewShortcut)) { if (IsListView(viewShortcut.ViewId) && reductions.TryGetValue(viewShortcut.ToString(), out string str)) { return(str); } if (IsDetailView(viewShortcut.ViewId)) { IModelViewFriendlyUrl modelView = (IModelViewFriendlyUrl)WebApplication.Instance.Model.Views[viewShortcut.ViewId]; var objectKey = ObjectKey(viewShortcut, modelView); string strmode = viewShortcut.TryGetValue("mode", out string mode) ? string.Format("&mode={0}", mode) : ""; string strView = string.Empty; if (objectKey != null) { strView = strmode == "" ? viewShortcut.ToString().Replace(objectKey, "{0}") : viewShortcut.ToString().Replace(objectKey, "{0}").Replace(strmode, ""); } else { strView = strmode == "" ? viewShortcut.ToString() : viewShortcut.ToString().Replace(strmode, ""); } if (reductions.TryGetValue(strView, out str)) { return(string.Format("{0}?{1}={2}{3}", str, ((IModelDetailViewFriendlyUrl)modelView).Url.ValueMemberName, objectKey, strmode)); } } } return(base.GetQueryString(viewShortcut)); }
void navigationItemCreated(object sender, NavigationItemCreatedEventArgs e) { ChoiceActionItem navigationItem = e.NavigationItem; IModelObjectView viewNode = ((IModelNavigationItem)e.NavigationItem.Model).View as IModelObjectView; if (viewNode != null) { ITypeInfo objectTypeInfo = XafTypesInfo.Instance.FindTypeInfo(viewNode.ModelClass.Name); if (objectTypeInfo != null) { CriteriaOperator docCriteria = CriteriaOperator.Parse("ObjectType == ?", objectTypeInfo.Type); IObjectSpace myObjectSpace = Application.CreateObjectSpace(typeof(HelpDocument)); IList <HelpDocument> docs = myObjectSpace.GetObjects <HelpDocument>(docCriteria); if (docs.Count > 0) { ChoiceActionItem docsGroup = new ChoiceActionItem("CustomDocuments", "Task-Based Help", null) { ImageName = "BO_Report" }; navigationItem.Items.Add(docsGroup); foreach (HelpDocument doc in docs) { ViewShortcut shortcut = new ViewShortcut(typeof(HelpDocument), doc.Oid.ToString(), "HelpDocument_DetailView_FewColumns"); ChoiceActionItem docItem = new ChoiceActionItem(doc.Oid.ToString(), doc.Title, shortcut) { ImageName = "Navigation_Item_Report" }; docsGroup.Items.Add(docItem); } } } } }
protected void ProcessItemNew(IModelNavigationItem item, ChoiceActionItemCollection choiceActionItems) { ChoiceActionItem item2; if (item.View != null) { var viewShortcut = new ViewShortcut(item.View.Id, item.ObjectKey); var lvcni = item as IListViewCriteriaNavigationItem; if (lvcni != null) { viewShortcut.Add("Criteria", lvcni.Criteria + ""); } item2 = new ChoiceActionItem(item, viewShortcut); item2.Active["HasRights"] = this.HasRights(item2, item.Application.Views); } else { item2 = new ChoiceActionItem(item) { ActiveItemsBehavior = ActiveItemsBehavior.RequireActiveItems }; } item2.Active["Visible"] = item.Visible; choiceActionItems.Add(item2); foreach (IModelNavigationItem item3 in item.Items) { this.ProcessItemNew(item3, item2.Items); } this.OnNavigationItemCreated(item, item2); }
string ObjectKey(ViewShortcut currentShortcut, IModelViewFriendlyUrl modelView) { if (!string.IsNullOrEmpty(currentShortcut.ObjectKey)) { var objectByKey = GetObjectByKey(currentShortcut.ObjectKey, modelView.AsObjectView); return GetFriendlyObjectKey(modelView, objectByKey); } return null; }
object GetObjectKey(ViewShortcut shortcut, Type type, IObjectSpace objectSpace) { var objectKey = GetObjectKey(objectSpace, type, shortcut); if (objectKey != null) return objectKey; return shortcut.ObjectKey.StartsWith("@") ? ParametersFactory.CreateParameter(shortcut.ObjectKey.Substring(1)).CurrentValue : CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(shortcut.ObjectKey, type); }
protected virtual string GetDetailViewUrl() { ViewShortcut shortcut = new ViewShortcut(View.Model.DetailView.Id, UrlKeyPlaceholder); IHttpRequestManager requestManager = ((WebApplication)Application).RequestManager; string url = string.Format("{0}#{1}", WebApplication.DefaultPage, requestManager.GetQueryString(shortcut)); return(url); }
string ObjectKey(ViewShortcut currentShortcut, IModelViewFriendlyUrl modelView) { if (!string.IsNullOrEmpty(currentShortcut.ObjectKey)) { var objectByKey = GetObjectByKey(currentShortcut.ObjectKey, modelView.AsObjectView); return(GetFriendlyObjectKey(modelView, objectByKey)); } return(null); }
string EditModeFriendlyUrl(ViewShortcut currentShortcut, string friendlyUrl, IModelDetailViewFriendlyUrl modelDetailViewFriendlyUrl) { return(modelDetailViewFriendlyUrl != null && !string.IsNullOrEmpty(modelDetailViewFriendlyUrl.Url.EditMode) ? currentShortcut.Keys.ToList().Where( (key, i) => key == "mode" && currentShortcut.Values.ToList()[i] == "Edit").Aggregate( friendlyUrl, (current, key) => (modelDetailViewFriendlyUrl).Url.EditMode + "-" + current) : friendlyUrl); }
public override void WriteShortcutTo(ViewShortcut currentShortcut, NameValueCollection queryString) { base.WriteShortcutTo(currentShortcut, queryString); if (!IsNewObjectView(currentShortcut)) { queryString.Clear(); var modelView = (IModelViewFriendlyUrl)WebApplication.Instance.Model.Views[currentShortcut.ViewId]; var objectKey = ObjectKey(currentShortcut, modelView); var friendlyUrl = EditModeFriendlyUrl(currentShortcut, modelView.FriendlyUrl, modelView as IModelDetailViewFriendlyUrl); queryString.Add(friendlyUrl, objectKey); } }
public override ViewShortcut GetViewShortcut(string queryString) { string shortcut; if (queryString != null && expansions.TryGetValue(queryString, out shortcut)) { return(ViewShortcut.FromString(shortcut)); } return(base.GetViewShortcut(queryString)); }
private void OnCustomProcessSelectedItem(object sender, CustomProcessListViewSelectedItemEventArgs e) { e.Handled = true; var shortcut = new ViewShortcut(GetViewId(e.InnerArgs.CurrentObject), ObjectSpace.GetKeyValueAsString(e.InnerArgs.CurrentObject)); var requestManager = ((WebApplication)Application).RequestManager; string hashUrl = requestManager.GetQueryString(shortcut); var script = $"window.open('{HttpContext.Current.Request.Url}#{hashUrl}','_blank');"; WebWindow.CurrentRequestWindow.RegisterStartupScript($"WindowOpen{View.ObjectTypeInfo.FullName}-{ObjectSpace.GetKeyValue(e.InnerArgs.CurrentObject)}", script, true); }
private ChoiceActionItem CreateImagesLibraryObjectNavigationItem(string caption, string imageSourceName, string imageName) { IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(ImageSourceBrowserBase)); ImageSourceBrowserBase browserObject = objectSpace.FindObject <ImageSourceBrowserBase>(new BinaryOperator("ImageSourceName", imageSourceName), false); string objectKey = objectSpace.GetKeyValueAsString(browserObject); ViewShortcut viewShortcut = new ViewShortcut(typeof(ImageSourceBrowserBase), objectKey, Application.GetDetailViewId(typeof(ImageSourceBrowserBase))); ChoiceActionItem newItem = new ChoiceActionItem(caption, caption, viewShortcut); newItem.ImageName = imageName; return(newItem); }
object GetObjectKey(IObjectSpace objectSpace, Type type, ViewShortcut shortcut) { object objectKey = null; if (string.IsNullOrEmpty(shortcut.ObjectKey)) return null; try { objectKey = objectSpace.GetObjectKey(type, shortcut.ObjectKey); } catch { } return objectKey; }
void ViewStrategy_CustomCanProcessDocumentControlDescription(object sender, CustomCanProcessDocumentControlDescriptionEventArgs e) { var viewShortcut = ViewShortcut.FromString(e.DocumentControlDescription.SerializedControl); var modelView = ((IModelViewSerializable)Application.FindModelView(viewShortcut.ViewId)); if (modelView.SerializableView.HasValue) { e.Result = modelView.SerializableView.Value; e.Handled = true; } }
protected override void OnParametersSet() { ViewShortcut viewShortcut = GetViewShortcut(); if (!string.IsNullOrEmpty(viewShortcut.ViewId)) { View view = Application.ProcessShortcut(viewShortcut); Application.MainWindow.SetView(view); } base.OnParametersSet(); }
public ViewShortcut GetViewShortcut() { ViewShortcut shortcut = innerUrlManager.GetViewShortcut(); IModelView modelView = application.Model.Views.SingleOrDefault(m => ((IModelViewWebExtender)m).ViewUrlAlias == shortcut.ViewId); if (modelView != null) { shortcut.ViewId = modelView.Id; } return(shortcut); }
void navigationController_NavigationItemCreated(object sender, NavigationItemCreatedEventArgs e) { if (e.NavigationItem.Id == "MyDetails") { ViewShortcut shortcut = e.NavigationItem.Data as ViewShortcut; if (shortcut != null) { shortcut["ObjectKey"] = SecuritySystem.CurrentUserId.ToString(); } } }
public void OpenNavigationItem(XafApplication app, IObjectSpace os, ShowViewParameters svp, Type objType) { var obj = os.FindObject(objType, null); var objKey = os.GetKeyValueAsString(obj); var viewId = app.GetListViewId(objType); var shortcut = new ViewShortcut(objType, objKey, viewId); svp.CreatedView = app.ProcessShortcut(shortcut); svp.TargetWindow = TargetWindow.NewWindow; }
object GetObjectKey(ViewShortcut shortcut, Type type, IObjectSpace objectSpace) { var objectKey = GetObjectKey(objectSpace, type, shortcut); if (objectKey != null) { return(objectKey); } return(shortcut.ObjectKey.StartsWith("@") ? ParametersFactory.CreateParameter(shortcut.ObjectKey.Substring(1)).CurrentValue : CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(shortcut.ObjectKey, type)); }
private void AddSkinNavigationItemsToGroup(ChoiceActionItemCollection items, ChoiceActionItem group) { foreach (ChoiceActionItem item in items) { ViewShortcut viewShortcut = new ViewShortcut(typeof(SkinDemoObject), null, Application.GetListViewId(typeof(SkinDemoObject))); viewShortcut.Add("SkinID", item.Id); ChoiceActionItem newItem = new ChoiceActionItem(item.Caption, item.Caption, viewShortcut); newItem.ImageName = ChooseSkinAction.ImageName; group.Items.Add(newItem); AddSkinNavigationItemsToGroup(item.Items, newItem); } }
object GetObjectKey(ViewShortcut shortcut, IModelDetailView modelDetailView, IObjectSpace objectSpace) { var type = modelDetailView.ModelClass.TypeInfo.Type; var objectKeyString = shortcut.ObjectKey; if (shortcut.ContainsKey("Criteria")) objectKeyString = shortcut["Criteria"]; if (objectKeyString.StartsWith("@")) { var modelReadOnlyParameter = ((IModelApplicationReadonlyParameters)modelDetailView.Application).ReadOnlyParameters[objectKeyString.Substring(1)]; var readOnlyParameter = (ReadOnlyParameter) modelReadOnlyParameter.Type.CreateInstance(); objectKeyString = readOnlyParameter.CurrentValue.ToString(); } return string.IsNullOrEmpty(objectKeyString) ? null : GetObjectKeyCore(objectSpace, type, objectKeyString); }
void MdiShowViewStrategyNP_CustomCanProcessDocumentControlDescription(object sender, CustomCanProcessDocumentControlDescriptionEventArgs e) { var viewShortcut = ViewShortcut.FromString(e.DocumentControlDescription.SerializedControl); Debug.Print(viewShortcut["Tag"]); var modelView = base.Application.FindModelView(viewShortcut.ViewId); e.Result = IsTaskResultSerialisableListView(e.Result, modelView); e.Handled = true; }
private void NavigationController_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e) { ViewShortcut shortcut = e.ActionArguments.SelectedChoiceActionItem.Data as ViewShortcut; if (shortcut != null) { ChoiceActionItem skinItem = ChooseSkinAction.Items.Find(shortcut["SkinID"], ChoiceActionItemFindType.Recursive, ChoiceActionItemFindTarget.Any); if (skinItem != null) { ChooseSkinAction.DoExecute(skinItem); } } }
// Если установлен Detail View, то Custom не срабатывает, поскольку видимо перехватывается внутренним обработчиком, // который просто создает новый объект void navigationController_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e) { if (e.ActionArguments.SelectedChoiceActionItem.Id == "ERMCurrentUser") { // ChoiceActionItem parent = // e.ActionArguments.SelectedChoiceActionItem.ParentItem; IObjectSpace objectSpace = Application.CreateObjectSpace(); ViewShortcut shortcut = e.ActionArguments.SelectedChoiceActionItem.Data as ViewShortcut; View view = Application.CreateDetailView(objectSpace, "csCSecurityUser_DetailView", true, objectSpace.GetObject <csCSecurityUser>(SecuritySystem.CurrentUser as csCSecurityUser)); e.ActionArguments.ShowViewParameters.CreatedView = view; e.Handled = true; } }
private void UpdateCultureChoiceActionItem(string languageAspect, string formattingAspect, string id, string imageName) { ChoiceActionItem item = localizationNavBarGroup.Items.Find(id, ChoiceActionItemFindType.Recursive, ChoiceActionItemFindTarget.Any); if (item != null) { ViewShortcut viewShortcut = new ViewShortcut(typeof(LocalizationObject), null, Application.GetListViewId(typeof(LocalizationObject))); viewShortcut.Add(languageShortcutKey, languageAspect); viewShortcut.Add(formattingCultureShortcutKey, formattingAspect); item.Data = viewShortcut; item.ImageName = imageName; } }
public void WriteShortcutTo(ViewShortcut currentShortcut, NameValueCollection queryString) { if (WebApplication.Instance.SupportsFriendlyUrl()) { if (!IsNewObjectView(currentShortcut)){ var windowId = queryString["WindowId"]; queryString.Clear(); var modelView = (IModelViewFriendlyUrl)WebApplication.Instance.Model.Views[currentShortcut.ViewId]; var objectKey = ObjectKey(currentShortcut, modelView); var friendlyUrl = EditModeFriendlyUrl(currentShortcut, modelView.FriendlyUrl, modelView as IModelDetailViewFriendlyUrl); queryString.Add(friendlyUrl, objectKey); if (!string.IsNullOrEmpty(windowId)) queryString.Add("WindowId",windowId); } } }
public ViewMenuItem(IModelMenuViewItem info, SingleChoiceAction menuItemsAction, string prefixId = "") : base(info, menuItemsAction, prefixId) { base.Caption = base.RemoveAmpersand(info.Caption); base.ImageName = info.ImageName; base.ToolTip = info.ToolTip; string objectKey = info.ObjectKey; IModelView view = info.View; if (view != null) { this.shortcut = new ViewShortcut(view.Id, objectKey); base.Enabled["HasRights"] = this.HasRights; } }
private bool MailReassignNewTask() { ViewShortcut shortcut = new ViewShortcut("Task_DetailView", Oid.ToString()); string url = "http://rnd.ntmarein.local/Default.aspx" + "?Shortcut" + shortcut.ToString(); string mSubject = string.Format("A task from {0} is reasign to to you", Owner.FullName); string mSendTo = AssignedTo.CorporateEmail; string mBody = string.Format("Dear {0}, \r\n{1} have reassigned a task you with following information:\r\n\r\nSubject: {2}\r\nDue Date: {3:dddd, dd MMMM yyyy}\r\nPriority: {4}\r\n\r\nTask Description:\r\n{5}\r\n", AssignedTo.FullName, Owner.FullName, Subject, DueDate, Priority, Description); mBody = mBody + string.Format("\r\n \r\nPlease log in to Marbid for additional infomation by clicking the following URL: \r\n {0}\r\n \r\n \r\n ", url); mBody = mBody + "This is automated message, please do not reply."; Mailer sMailer = new Mailer("*****@*****.**", mSendTo, mSubject, mBody); return(sMailer.SendMail()); }
protected internal virtual void DoNavigate(ViewShortcut shortcut) { SecuritySystem.ReloadPermissions(); isNavigating = true; try { Window.SetView(Application.ProcessShortcut(shortcut), null); } finally { isNavigating = false; } RefreshActionsState(); }
object GetObjectKey(IObjectSpace objectSpace, Type type, ViewShortcut shortcut) { object objectKey = null; if (string.IsNullOrEmpty(shortcut.ObjectKey)) { return(objectKey); } try { objectKey = objectSpace.GetObjectKey(type, shortcut.ObjectKey); } catch { } return(objectKey); }
private IModelView RemoveVariantNode(string viewId) { ViewShortcut viewShortcut = View.CreateShortcut(); IModelView modelView = Application.Model.Views[viewShortcut.ViewId]; IModelVariants modelVariants = ((IModelViewVariants)modelView).Variants; IModelVariant modelVariant = modelVariants.Where(variant => variant.View.Id == viewId).Single(); modelVariant.Remove(); if (modelVariants.Count > 0) { modelVariants.Current = modelVariants[0]; return(modelVariants.Current.View); } return(Application.Model.Views[viewShortcut.ViewId]); }
public override string GetQueryString(ViewShortcut viewShortcut) { var queryString = base.GetQueryString(viewShortcut); if (WebApplication.Instance.SupportsQueryStringParameter()) { var startIndex = queryString.IndexOf("#", System.StringComparison.Ordinal) + 1; var substring = queryString.Substring(startIndex); var nameValueCollection = HttpUtility.ParseQueryString(substring); var queryStringParameters = ((IModelOptionsQueryStringParameter) WebApplication.Instance.Model.Options).QueryStringParameters; foreach (var queryStringParameter in queryStringParameters) { var readOnlyParameter = (ReadOnlyParameter) queryStringParameter.ReadOnlyParameter.Type.CreateInstance(); nameValueCollection.Add(queryStringParameter.Key,readOnlyParameter.CurrentValue+""); } return queryString.Substring(0,startIndex)+ ToQueryString(nameValueCollection); } return queryString; }
private void SplitLayoutDirection_Execute(object sender, SimpleActionExecuteEventArgs e) { IModelListViewSplitLayout SplitLayout = ((ListView)View).Model.SplitLayout; ViewShortcut shortcut = Frame.View.CreateShortcut(); Frame.SetView(null); if (SplitLayout.Direction == FlowDirection.Horizontal) { SplitLayout.Direction = FlowDirection.Vertical; } else { SplitLayout.Direction = FlowDirection.Horizontal; } Frame.SetView(Application.ProcessShortcut(shortcut), true, Frame); }
private void navigationController_CustomUpdateSelectedItem(object sender, CustomUpdateSelectedItemEventArgs e) { if (e.ProposedSelectedItem != null && localizationNavBarGroup != null && localizationNavBarGroup.Items.Contains(e.ProposedSelectedItem)) { if (currentNavigationItemShortcut != null && ((ViewShortcut)e.ProposedSelectedItem.Data) != currentNavigationItemShortcut) { ChoiceActionItem correctSelectedItem = localizationNavBarGroup.Items.Find(currentNavigationItemShortcut); if (correctSelectedItem != null) { e.ProposedSelectedItem = correctSelectedItem; e.Handled = true; } currentNavigationItemShortcut = null; } } }
protected override void OnAfterRender() { base.OnAfterRender(); ViewShortcut viewShortcut = GetViewShortcut(); if (string.IsNullOrEmpty(viewShortcut.ViewId) && string.IsNullOrEmpty(viewShortcut.ObjectKey)) { ViewShortcut startupViewShortcut = GetStartupViewShortcut(); if (startupViewShortcut == null) { throw new Exception("Startup view is not found"); } ViewUrlHelper.NavigateToView(startupViewShortcut.ViewId); } ViewID = null; }
public string GetUrl(ViewShortcut shortcut, IDictionary <string, string> additionalParams = null) { ViewShortcut localShortcut = new ViewShortcut(); for (int i = 0; i < shortcut.Count; i++) { localShortcut[shortcut.GetKey(i)] = shortcut[i]; } IModelView modelView = application.FindModelView(localShortcut.ViewId); if (modelView != null) { localShortcut.ViewId = ((IModelViewWebExtender)modelView).ViewUrlAlias; } return(innerUrlManager.GetUrl(localShortcut, additionalParams)); }
private void SwitchAction_Execute(object sender, SimpleActionExecuteEventArgs e) { IModelListView model = ((ListView)View).Model; ViewShortcut shortcut = Frame.View.CreateShortcut(); Frame.SetView(null); if (model.MasterDetailMode == MasterDetailMode.ListViewAndDetailView) { model.MasterDetailMode = MasterDetailMode.ListViewOnly; } else { model.MasterDetailMode = MasterDetailMode.ListViewAndDetailView; } Frame.SetView(Application.ProcessShortcut(shortcut), true, Frame); }
private void SaveAndCloseAction_Execute(object sender, SimpleActionExecuteEventArgs e) { ViewNavigationController navi = Frame.GetController<ViewNavigationController>(); try { DevExpress.Persistent.Validation.Validator.RuleSet.Validate(View.CurrentObject, new DevExpress.Persistent.Validation.ContextIdentifiers("Save")); //((DevExpress.ExpressApp.DC.DCBaseObject)View.CurrentObject).Save(); ((DevExpress.ExpressApp.Xpo.XPObjectSpace)View.ObjectSpace).Session.LockingOption = DevExpress.Xpo.LockingOption.Optimistic; View.ObjectSpace.CommitChanges(); ViewShortcut workspace = new ViewShortcut("Workspace", ""); ChoiceActionItem choiceItem = new ChoiceActionItem("workSpaceShortCut", workspace); navi.NavigateBackAction.Items.Add(choiceItem); try { navi.NavigateBackAction.DoExecute(navi.NavigateBackAction.Items.FirstActiveItem); } catch (Exception ex) { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace mainViewObjectSpace = Application.CreateObjectSpace(); DashboardView mainView = Application.CreateDashboardView(mainViewObjectSpace, "Workspace", true); svp.CreatedView = mainView; svp.TargetWindow = TargetWindow.Default; svp.Context = TemplateContext.ApplicationWindow; Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } } catch (Exception ex) { if (ex is DevExpress.Persistent.Validation.ValidationException) { throw; } }; }
object GetObject(ViewShortcut shortcut, IModelDetailView modelDetailView, IObjectSpace objectSpace) { object objectKey = GetObjectKey(shortcut, modelDetailView.ModelClass.TypeInfo.Type, objectSpace); return GetObjectCore(modelDetailView, objectKey, objectSpace); }
IModelDetailView GetModelDetailView(ViewShortcut shortcut) { return _application.Model.Views.OfType<IModelDetailView>().FirstOrDefault(v => v.Id == shortcut.ViewId); }
private void UpdateMainForm() { if (Application.MainWindow.View.Id == "Workspace") { DevExpress.ExpressApp.ListView ExaminationListView = (Application.MainWindow.View as DashboardView).Items .Where(i => (i as DashboardViewItem).InnerView.ObjectTypeInfo.Type == typeof(IExamination)) .Select(i => (i as DashboardViewItem).InnerView) .FirstOrDefault() as DevExpress.ExpressApp.ListView; IExamination examination = ExaminationListView.CurrentObject as IExamination; DevExpress.ExpressApp.ListView PatientListView = (Application.MainWindow.View as DashboardView).Items .Where(i => (i as DashboardViewItem).InnerView.ObjectTypeInfo.Type == typeof(IPatient)) .Select(i => (i as DashboardViewItem).InnerView) .FirstOrDefault() as DevExpress.ExpressApp.ListView; IPatient patient = PatientListView.CurrentObject as IPatient; ViewShortcut shortcut = new ViewShortcut("Workspace", String.Empty); Application.MainWindow.SetView(Application.ProcessShortcut(shortcut)); PatientListView = (Application.MainWindow.View as DashboardView).Items .Where(i => (i as DashboardViewItem).InnerView.ObjectTypeInfo.Type == typeof(IPatient)) .Select(i => (i as DashboardViewItem).InnerView) .FirstOrDefault() as DevExpress.ExpressApp.ListView; if (patient != null) PatientListView.CurrentObject = PatientListView.ObjectSpace.GetObject<IPatient>(patient); ExaminationListView = (Application.MainWindow.View as DashboardView).Items .Where(i => (i as DashboardViewItem).InnerView.ObjectTypeInfo.Type == typeof(IExamination)) .Select(i => (i as DashboardViewItem).InnerView) .FirstOrDefault() as DevExpress.ExpressApp.ListView; if (examination != null) ExaminationListView.CurrentObject = ExaminationListView.ObjectSpace.GetObject<IExamination>(examination); } else if (Application.MainWindow.View.Id == "IExamination_ListView") { IExamination examination = Application.MainWindow.View.CurrentObject as IExamination; ViewShortcut shortcut = new ViewShortcut("IExamination_ListView", String.Empty); Application.MainWindow.SetView(Application.ProcessShortcut(shortcut)); if (examination != null) Application.MainWindow.View.CurrentObject = Application.MainWindow.View.ObjectSpace.GetObject<IExamination>(examination); } }
private void CreateWorkspaceNavigationAction() { //IModelView workspace = Application.Model.Views["Workspace"]; SimpleAction action = new SimpleAction(this.Container) { Id = "Workspace_NavigationActionId", Category = ToolBarCustomizer.MainNavigationObjectsContainerId, //"ViewsHistoryNavigation",// }; action.Execute += (o, a) => { ViewShortcut shortcut = new ViewShortcut("Workspace", String.Empty); Application.MainWindow.SetView(Application.ProcessShortcut(shortcut)); }; Actions.Add(action); }
string EditModeFriendlyUrl(ViewShortcut currentShortcut, string friendlyUrl, IModelDetailViewFriendlyUrl modelDetailViewFriendlyUrl) { return modelDetailViewFriendlyUrl != null && !string.IsNullOrEmpty(modelDetailViewFriendlyUrl.Url.EditMode) ? currentShortcut.Keys.ToList().Where( (key, i) => key == "mode" && currentShortcut.Values.ToList()[i] == "Edit").Aggregate( friendlyUrl, (current, key) => (modelDetailViewFriendlyUrl).Url.EditMode + "-" + current) : friendlyUrl; }
protected void NavigateTo(ViewShortcut shortcut) { if (shortcut.ViewId != "RuleSetValidationResult_ByTarget_Error_DetailView" & shortcut.ViewId != "AboutInfo_DetailView" & shortcut.ViewId != "IInsurance_DetailView") { DeleteLastItemIfItNeeds(); navigationHistory.SetCurrentPosition(shortcut); DoNavigate(shortcut); } }
private void navigationController_CustomUpdateSelectedItem(object sender, CustomUpdateSelectedItemEventArgs e) { if (e.ProposedSelectedItem != null && localizationNavBarGroup != null && localizationNavBarGroup.Items.Contains(e.ProposedSelectedItem)) { if (currentNavigationItemShortcut != null && ((ViewShortcut)e.ProposedSelectedItem.Data) != currentNavigationItemShortcut) { ChoiceActionItem correctSelectedItem = localizationNavBarGroup.Items.Find(currentNavigationItemShortcut); if (correctSelectedItem != null) { e.ProposedSelectedItem = correctSelectedItem; e.Handled = true; } currentNavigationItemShortcut = null; } } }
bool IsNewObjectView(ViewShortcut currentShortcut) { string shortcutNewObject; return currentShortcut.TryGetValue("NewObject", out shortcutNewObject) && shortcutNewObject == true.ToString(CultureInfo.InvariantCulture).ToLower(); }
private void SyncContextUpdateView(View view) { if (view == null) return; IObjectSpace os = null; try { os = view.ObjectSpace; if (os.IsModified == true) os.CommitChanges(); os.Refresh(); if (view is DetailView) {// если находимся на детальном представлении, проверяем сущестует ли еще данный объект object o = view.CurrentObject; if (o == null) {// если объект был удален переходим на главное представление ViewShortcut shortcut = new ViewShortcut("Workspace", String.Empty); Application.MainWindow.SetView(Application.ProcessShortcut(shortcut)); } } } catch (Exception exception) { if (os != null) os.Rollback(); Tracing.Tracer.LogError(exception); } }
public override void WriteShortcutTo(ViewShortcut currentShortcut, NameValueCollection queryString) { base.WriteShortcutTo(currentShortcut, queryString); _friendlyUrlHelper.WriteShortcutTo(currentShortcut, queryString); }
protected void ProcessItemNew(IModelNavigationItem item, ChoiceActionItemCollection choiceActionItems) { ChoiceActionItem item2; if (item.View != null) { var viewShortcut = new ViewShortcut(item.View.Id, item.ObjectKey); var lvcni = item as IListViewCriteriaNavigationItem; if (lvcni != null) { viewShortcut.Add("Criteria", lvcni.Criteria + ""); } item2 = new ChoiceActionItem(item, viewShortcut); item2.Active["HasRights"] = this.HasRights(item2, item.Application.Views); } else { item2 = new ChoiceActionItem(item) { ActiveItemsBehavior = ActiveItemsBehavior.RequireActiveItems }; } item2.Active["Visible"] = item.Visible; choiceActionItems.Add(item2); foreach (IModelNavigationItem item3 in item.Items) { this.ProcessItemNew(item3, item2.Items); } this.OnNavigationItemCreated(item, item2); }
private void UpdateView(View view) { // Событие генерится в другом потоке поэтому обновляем инвоком (view.Control as WinForms.Control).Invoke(new WinForms.MethodInvoker(() => { IObjectSpace os = null; try { os = view.ObjectSpace; if (os.IsModified == true) os.CommitChanges(); os.Refresh(); if (view is DetailView) {// если находимся на детельном представлении, проверяем сущестует ли еще данный объект object o = view.CurrentObject; if (o == null) {// если объект был удален переходим на главное представление ViewShortcut shortcut = new ViewShortcut("Workspace", String.Empty); Application.MainWindow.SetView(Application.ProcessShortcut(shortcut)); } } } catch (Exception) { if (os != null) os.Rollback(); } })); }
private void RemoveShortcutFromStack(ViewShortcut shortcut) { string savedMode = shortcut[DetailView.ViewEditModeKeyName]; shortcut[DetailView.ViewEditModeKeyName] = ViewEditMode.Edit.ToString(); while (navigationStack.Remove(shortcut)); shortcut[DetailView.ViewEditModeKeyName] = ViewEditMode.View.ToString(); while (navigationStack.Remove(shortcut)); shortcut[DetailView.ViewEditModeKeyName] = savedMode; }
protected void UpdateCurrentHistoryItem(string caption, string imageName, ViewShortcut currentShortcut) { if (IsNavigationAllowed()) { if (navigationHistory.CurrentPosition.Item != null) { if (currentShortcut.HasViewParameters && navigationHistory.CurrentPosition.Item.Equals(currentShortcut) || !navigationHistory.CurrentPosition.Item.HasViewParameters) { navigationHistory.UpdateCurrentItem(caption, imageName, currentShortcut); navigationStack.Pop(); navigationStack.Push(currentShortcut); } if (!navigationHistory.CurrentPosition.Item.HasViewParameters) { navigationHistory.DeleteCurrentItem(); navigationStack.Pop(); } } } }
public CachedViewShortcut(ViewShortcut shortcut, IParameter parameter) { Shortcut = shortcut; Parameter = parameter; }
private void ChangeLanguageController_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e) { ViewShortcut shortcut = e.ActionArguments.SelectedChoiceActionItem.Data as ViewShortcut; if (shortcut != null) { if (shortcut.Keys.Contains(languageShortcutKey) && shortcut.Keys.Contains(formattingCultureShortcutKey)) { currentNavigationItemShortcut = shortcut; ChoiceActionItem languageItem = ChooseLanguageAction.Items.Find(shortcut[languageShortcutKey]); if (languageItem != null) { ChooseLanguageAction.DoExecute(languageItem); } if ((Window.View is ObjectView)) { e.Handled = true; } } } }