这是一个非常独特的问题。几小时的谷歌搜索没有得到答案。希望有人可以提供帮助。
我有一个LightSwitch 2013应用程序,它非常适用于具有库存/资产管理的内部票务系统。它使用Windows身份验证(我们有超过900名员工,他们都是能够提交故障单的最终用户,因此表单身份验证是无用的),并且没有问题。使用我从各种博客中获取的代码,它获取当前登录的用户名,并在主屏幕上显示其名称;它还获取用户的权限,并根据这些权限隐藏/显示UI的元素。所有这些都很有效,并且已经有一段时间了。
这里变得奇怪 - 导航到应用程序是成功的。主屏幕加载所有预期的按钮。我可以点击一个按钮来显示另一个屏幕,任何其他屏幕,这很有效。当我单击导航菜单中的应用程序图标返回主页时,它会加载主屏幕,并弹出一个对话框,显示“导航失败,原因不明”我单击确定,然后对话框返回。还可以,它会清除,我可以继续正常使用该应用程序。
我一直在修复小错误,并且我开始在另一个屏幕上实现报告,因此在此之前很久没有对主屏幕进行任何更改。我的测试显示每个屏幕都会出现这种情况,即使是我还没有添加报告的屏幕。
这是我主屏幕的代码:
/// <reference path="~/GeneratedArtifacts/viewModel.js" />
myapp.Home.created = function (screen) {
// Write code here.
$.getJSON("../Perms/UserPermissions/", function (data) {
myapp.permissions = data;
}).then(function () {
if (myapp.permissions["LightSwitchApplication:ViewTechOnlyScreens"]) {
screen.details.displayName = "RCC Help Desk Ticketing & Inventory System";
screen.ScreenName = screen.details.displayName;
screen.findContentItem("ShowBrowseTickets").isVisible = true;
screen.findContentItem("Inventory").isVisible = true;
screen.findContentItem("Users").isVisible = true;
screen.findContentItem("EnterTicket").isVisible = true;
screen.findContentItem("SubmitTicket").isVisible = false;
screen.findContentItem("EnterTicket1").isVisible = true;
screen.findContentItem("SubmitTicket1").isVisible = false;
screen.findContentItem("ShowBrowseMyTickets").isVisible = false;
screen.findContentItem("ShowBrowseOpenTickets").isVisible = true;
screen.findContentItem("ShowBrowseKB").isVisible = true;
} else {
screen.details.displayName = "RCC Help Desk Ticketing System";
screen.ScreenName = screen.details.displayName;
screen.findContentItem("ShowBrowseTickets").isVisible = false;
screen.findContentItem("Inventory").isVisible = false;
screen.findContentItem("Users").isVisible = false;
screen.findContentItem("EnterTicket").isVisible = false;
screen.findContentItem("SubmitTicket").isVisible = true;
screen.findContentItem("EnterTicket1").isVisible = false;
screen.findContentItem("SubmitTicket1").isVisible = true;
screen.findContentItem("ShowBrowseMyTickets").isVisible = true;
screen.findContentItem("ShowBrowseOpenTickets").isVisible = false;
screen.findContentItem("ShowBrowseKB").isVisible = true;
}
if (myapp.permissions["LightSwitchApplication:AddDevice"]) {
screen.findContentItem("ShowAddEditDesktop").isVisible = true;
screen.findContentItem("ShowAddEditLaptop").isVisible = true;
screen.findContentItem("ShowAddEditPrinter").isVisible = true;
screen.findContentItem("ShowAddEditTablet").isVisible = true;
} else {
screen.findContentItem("ShowAddEditDesktop").isVisible = false;
screen.findContentItem("ShowAddEditLaptop").isVisible = false;
screen.findContentItem("ShowAddEditPrinter").isVisible = false;
screen.findContentItem("ShowAddEditTablet").isVisible = false;
}
screen.findContentItem("ShowAddEditEndUser").isVisible = myapp.permissions["LightSwitchApplication:AddEndUser"];
screen.findContentItem("ShowAddEditTech").isVisible = myapp.permissions["LightSwitchApplication:AddTech"];
screen.findContentItem("ShowAddEditDepartment").isVisible = myapp.permissions["LightSwitchApplication:AddDepartment"];
screen.findContentItem("ShowAddEditDeptHead").isVisible = myapp.permissions["LightSwitchApplication:AddDeptHead"];
screen.findContentItem("ShowBrowseHelpFiles").isVisible = myapp.permissions["LightSwitchApplication:AddHelpFile"];
screen.findContentItem("ShowAddEditLocation").isVisible = myapp.permissions["LightSwitchApplication:AddLocation"];
screen.findContentItem("ShowAddEditKBItem").isVisible = myapp.permissions["LightSwitchApplication:AddKnowledgeBase"];
screen.findContentItem("ShowAddEditOperatingSystem").isVisible = myapp.permissions["LightSwitchApplication:AddOS"];
screen.findContentItem("SecurityAdministration").isVisible = myapp.permissions["Microsoft.LightSwitch.Security:SecurityAdministration"];
});
};
myapp.Home.EnterTicket_execute = function (screen) {
// Write code here.
myapp.showAddTicket(null, {
beforeShown: function (TicketScreen) {
var newTicket = new myapp.Ticket();
TicketScreen.Ticket = newTicket;
msls.promiseOperation(CallGetUserName).then(function PromiseSuccess(PromiseResult) {
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.Techs_SingleOrDefault(PromiseResult)
.execute()
.then(function (result) {
newTicket.Tech = result.results[0];
});
});
}, afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
var newTicket = addEditScreen.Ticket;
myapp.showViewTicket(newTicket, "BrowseOpenTickets");
}
}
});
};
function CallGetUserName(operation) {
$.ajax({
type: 'post',
data: {},
url: 'GetUserName.ashx',
success: operation.code(function AjaxSuccess(AjaxResult) {
operation.complete(AjaxResult);
})
});
};
myapp.Home.SubmitTicket_execute = function (screen) {
// Write code here.
myapp.showSubmitTicket(null, {
beforeShown: function (TicketScreen) {
var newTicket = new myapp.Ticket();
TicketScreen.Ticket = newTicket;
msls.promiseOperation(CallGetUserName).then(function PromiseSuccess(PromiseResult) {
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.EndUsers_SingleOrDefault(PromiseResult)
.execute()
.then(function (result) {
newTicket.EndUser = result.results[0];
});
});
}, afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewTicket(addEditScreen.Ticket, "BrowseMyTickets");
}
}
});
};
myapp.Home.ShowAddEditDesktop_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditDesktop(null, {
beforeShown: function (addEditScreen) {
addEditScreen.Desktop = new myapp.Desktop();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewDesktop(addEditScreen.Desktop);
}
}
});
};
myapp.Home.ShowAddEditLaptop_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditLaptop(null, {
beforeShown: function (addEditScreen) {
addEditScreen.Laptop = new myapp.Laptop();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewLaptop(addEditScreen.Laptop);
}
}
});
};
myapp.Home.ShowAddEditPrinter_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditPrinter(null, {
beforeShown: function (addEditScreen) {
addEditScreen.Printer = new myapp.Printer();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewPrinter(addEditScreen.Printer);
}
}
});
};
myapp.Home.ShowAddEditTablet_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditTablet(null, {
beforeShown: function (addEditScreen) {
addEditScreen.Tablet = new myapp.Tablet();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewTablet(addEditScreen.Tablet);
}
}
});
};
myapp.Home.ShowAddEditEndUser_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditEndUser(null, {
beforeShown: function (addEditScreen) {
addEditScreen.EndUser = new myapp.EndUser();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewEndUser(addEditScreen.EndUser);
}
}
});
};
myapp.Home.ShowAddEditTech_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditTech(null, {
beforeShown: function (addEditScreen) {
addEditScreen.Tech = new myapp.Tech();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewTech(addEditScreen.Tech);
}
}
});
};
myapp.Home.Tickets_postRender = function (element, contentItem) {
// Write code here.
msls.promiseOperation(CallGetUserName).then(function PromiseSuccess(PromiseResult) {
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.EndUsers_SingleOrDefault(PromiseResult)
.execute()
.then(function (result) {
$(element).closest("[data-role='page']").find(
".msls-title-area").append(
"<div style='color:dimgray;font-size:15px;'>Welcome, " + result.results[0].UserFirstName + " " + result.results[0].UserLastName + "</div>");
}, function () {
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.EndUsers.addNew();
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.saveChanges();
});
});
msls.promiseOperation(CallGetUserName).then(function PromiseSuccess(PromiseResult) {
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.Techs_SingleOrDefault(PromiseResult)
.execute()
.then(function (result) {
}, function () {
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.Techs.addNew();
myapp.activeDataWorkspace.RCCHelpDeskInventoryData.saveChanges();
});
});
};
myapp.Home.ShowAddEditDepartment_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditDepartment(null, {
beforeShown: function (addEditScreen) {
addEditScreen.Department = new myapp.Department();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewDepartment(addEditScreen.Department);
}
}
});
};
myapp.Home.ShowAddEditDeptHead_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditDeptHead(null, {
beforeShown: function (addEditScreen) {
addEditScreen.DeptHead = new myapp.DeptHead();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewDeptHead(addEditScreen.DeptHead);
}
}
});
};
myapp.Home.ShowHelp_Tap_execute = function (screen) {
// Write code here.
screen.getHelpFile().then(function (helpfile) {
myapp.showHelpDialog(helpfile);
});
};
myapp.Home.ShowAddEditKBItem_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditKBItem(null, {
beforeShown: function (addEditScreen) {
addEditScreen.KnowledgeBase = new myapp.KnowledgeBase();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewKBItem(addEditScreen.KnowledgeBase);
}
}
});
};
myapp.Home.ShowAddEditLocation_Tap_execute = function (screen) {
// Write code here.
myapp.showAddEditLocation(null, {
beforeShown: function (addEditScreen) {
addEditScreen.Location = new myapp.Location();
},
afterClosed: function (addEditScreen, navigationAction) {
if (navigationAction === msls.NavigateBackAction.commit) {
myapp.showViewLocation(addEditScreen.Location);
}
}
});
};
myapp.Home.SecurityAdministration_postRender = function (element, contentItem) {
// Write code here.
$(element).find("div").wrap("<a href='http://myserver/Tickets/desktopclient' target='_blank'></a>");
};
myapp.Home.ShowHelpDialog_Tap_execute = function (screen) {
// Write code here.
screen.getHelpFile().then(function () {
myapp.showHelpDialog(screen.HelpFile);
});
};
这是一大块代码,但大多数都是重复代码来调用各种屏幕(应用程序中共有53个)。