Setting IsVisible property of FlyOutItem to False results in app crash in iOS 14.5 - xamarin.ios

The following is a snippet of FlyoutItem where the item needs to be shown if the user is logged in. Login process sets ShowAuthorizedRoutes to true if the login process is successful.
<FlyoutItem Title="Benefits Summary" IsVisible="{Binding ShowAuthorizedRoutes}">
<ShellContent Route="BenefitsSummary" ContentTemplate="{DataTemplate local:BenefitsSummaryPage}" />
<FlyoutItem.FlyoutIcon>
<FontImageSource FontFamily="FontAwesome5154Solid"
Glyph="{x:Static fontAwesome:FontAwesomeIcons.DollarSign}"
Color="{x:StaticResource Secondary}"
Size="Medium">
</FontImageSource>
</FlyoutItem.FlyoutIcon>
</FlyoutItem>
The above snippet shows one of the FlyouItems in the Shell. There are total 7 items in the Shell. They are identical except for the icon, route, and template. The last 2 items are not secured. Therefore, they are not bound to ShowAuthorizedRoutes. So, the visibility of 5 items needs to be toggled.
When login is successful, everything works as per the expectations. All items are shown. However, as soon as ShowAuthorizedRoutes is set to FALSE upon Logout, the app crashes in iOS 14.5 when it tries to hide the secured items.
The app center registers the following crash report.
"attempt to delete row 5 from section 0, which only contains 2 rows before the update"
It looks like that the Shell object is trying to delete items already deleted.
If it is iOS 15 or later, this works without issues. It also works in Android (any version).
Is there any suggestion to fix this on iOS 14 or any workaround? Thanks in adv. for any help!

What would happen if trying to move the logic into code behind?
Try the following code , place it into AppShell.
if (ShowAuthorizedRoutes)
{
foreach(ShellItem item in this.Items)
{
item.IsVisible = true;
}
}
else
{
foreach (ShellItem item in this.Items)
{
if (item.Title == "A" || item.Title == "B" ....)
{
item.IsVisible = false;
}
}
}

Related

How I can use Autonumber in new screen multiple users in Acumatica?

I have a custom screen in Acumatica with autonumber, but only one user can use at the same time. How can get screen multiuser?
In Sales Order/Payment and Applications I have a tab('COMPLEMENTOS'), in this tab you can add a new complement in other screen. This screen have a field, 'No. Complemento' is Autonumber, the autonumber is generated correctly but if two person are in the same screen at the same time, one of them is saved correctly but the other try to save with the same number that was already used and send an error 'Another Process has updated the CPSetup record. Your changes will be lost'. How I can work with two or more screens at the same time.
if (cache.GetStatus(row) == PXEntryStatus.Inserted)
{
AutoNumberAttribute.SetLastNumberField<COPago.cOPagoCD>(cache, row,
typeof(CPSetup.returnLastDocRefNbr));
if (row.RefNbrPago != null)
{
AutoNumberAttribute.SetPrefix<COPago.cOPagoCD>(cache, row, "REP");
}
}
The actual error is 'Another Process has updated the CPSetup record. Your changes will be lost'
I would like to kwon how I can generate correctly autonumber with the same screen with two or more users at the same time.
When you generate next nunber probably you store it on a field on Numbering Sequence. We call it LastNumber.
When you update the LastNumber field (with next number) on Numbering Sequence you need to use an SQL transaction
using (PXTransactionScope ts = new
PXTransactionScope())
{
//Update LastNumber with next number
// persist cache
ts.Complete();
}

MFC Edit Control EN_KILLFOCUS issue

I am using Visual Studio 2013 and making MFC Dialog based application. I am running into strange issue with Kill Focus of Edit Control.
Please see below:
==========================================================================
In my application, I have two Edit Controls on Dialog Box.
1st Edit Control -> IDC_EDIT_QUALITY1
2nd Edit Control -> IDC_EDIT_QUALITY2
I have handled both's EN_KILLFOCUS event to validate the value.
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
ON_EN_KILLFOCUS(IDC_EDIT_QUALITY1, &CTestDlg::OnQuality1EditKillFocus)
ON_EN_KILLFOCUS(IDC_EDIT_QUALITY2, &CTestDlg::OnQuality2EditKillFocus)
END_MESSAGE_MAP()
void CTestDlg::OnQuality1EditKillFocus()
{
ValidateQualityParams(IDC_EDIT_QUALITY1);
}
void CTestDlg::OnQuality2EditKillFocus()
{
ValidateQualityParams(IDC_EDIT_QUALITY2);
}
#define MIN_QUALITY_VALUE 1
#define MAX_QUALITY_VALUE 100
void CTestDlg::ValidateQualityParams(int qualityParamID)
{
CString strQuality1;
if (IDC_EDIT_QUALITY1 == qualityParamID)
{
m_ctrlQuality1.GetWindowText(strQuality1);
if ((_ttoi(strQuality1) < MIN_QUALITY_VALUE) || (_ttoi(strQuality1) > MAX_QUALITY_VALUE))
{
CString strMessage;
strMessage.Format(_T("Quality1 value must be between %d to %d."), MIN_QUALITY_VALUE, MAX_QUALITY_VALUE);
**AfxMessageBox(strMessage);**
m_ctrlQuality1.SetSel(0, -1);
m_ctrlQuality1.SetFocus();
return;
}
}
CString strQuality2;
if (IDC_EDIT_QUALITY2 == qualityParamID)
{
m_ctrlQuality2.GetWindowText(strQuality2);
if ((_ttoi(strQuality2) < MIN_QUALITY_VALUE) || (_ttoi(strQuality2) > MAX_QUALITY_VALUE))
{
CString strMessage;
strMessage.Format(_T("Quality2 value must be between %d to %d."), MIN_QUALITY_VALUE, MAX_QUALITY_VALUE);
AfxMessageBox(strMessage);
m_ctrlQuality2.SetSel(0, -1);
m_ctrlQuality2.SetFocus();
return;
}
}
}
Now, the issue happens when, after changing the value in 1st Edit Control (IDC_EDIT_QUALITY1), say entering 0 in it and pressing TAB key, the flow goes as below:
void CTestDlg::OnQuality1EditKillFocus() is called.
It calls ValidateQualityParams(IDC_EDIT_QUALITY1)
Inside ValidateQualityParams, it goes to if (IDC_EDIT_QUALITY1 == qualityParamID) condition.
As the value I entered is less than MIN_QUALITY_VALUE, so it shows the Message by calling AfxMessageBox.
- Now, even from the callstack of AfxMessageBox, it hits void CTestDlg::OnQuality2EditKillFocus() internally.
Although callstack of OnQuality1EditKillFocus is NOT finished yet, OnQuality2EditKillFocus gets called from the callstack of AfxMessageBox.
I don't understand the cause of this issue. Has anyone encountered such issue before?
In my resource.h, I have two distinct values for IDC_EDIT_QUALITY1 and IDC_EDIT_QUALITY2
#define IDC_EDIT_QUALITY1 1018
#define IDC_EDIT_QUALITY2 1020
Please help on this issue.
I believe the EN_KILLFOCUS notification for the IDC_EDIT_QUALITY2 control you are receiving is caused not by the m_ctrlQuality1.SetFocus() call, but instead by the AfxMessageBox() call.
When you press the [Tab] key IDC_EDIT_QUALITY1 loses the focus, and IDC_EDIT_QUALITY2 gets the focus. Then you receive the EN_KILLFOCUS notification for IDC_EDIT_QUALITY1. You display the error-message, which causes the application to "yield" (start processing messages again), while the message-box is displayed. The m_ctrlQuality1.SetFocus() call won't take place before the AfxMessageBox() returns, ie before you close the message-box, and therefore the EN_KILLFOCUS notification for IDC_EDIT_QUALITY2 can't be the result of that call. I guess it's the result of displaying the message-box (IDC_EDIT_QUALITY2 has got the focus, but the message-box makes it lose it).
You may work around it by adding a memeber variable, as Staytuned123 suggested, but in a different setting: name it, say m_bKillFocusProcessing, and set it to TRUE while you are processing ANY EN_KILLFOCUS notification (AfxMessageBox() plus SetFocus()), and to FALSE when you are done processing it; if it's already TRUE exit without doing anything. That is, only one EN_KILLFOCUS notification may be processed at a time.
However, such a user-interface (displaying a message-box on exiting a field) is rather weird. And why reinvent the wheel and not instead use the DDX/DDV feature, which MFC already offers? You can define member variables associated with controls, and perform various checks, including range-check. Call UpdateData(TRUE) to perform the checks (for all controls on the dialog) and transfer the data to the member variables. Or you can put some error-displaying controls (usually in red color), activated when an error is found, like in .net or the web.
When you pressed TAB key, IDC_EDIT_QUALITY2 got focus. But because value entered was out of bound, the program called m_ctrlQuality1.SetFocus(), which in turn caused OnQuality2EditKillFocus() to get called.
Add a member variable says m_bQuality1OutOfBound and set it to true right before calling m_ctrlQuality1.SetFocus(). In OnQuality2EditKillFocus(), when m_bQuality1OutOfBound is true, set it to false and don't call ValidateQualityParams(IDC_EDIT_QUALITY2).

VS2013 Load Test with Multiple Users that requires login

I have a website that I need to perform a Load Test on. I tried this with one user logging in and clicking around then logging out. It worked ok but now I need to try with 50 users. Initial user count is 5, increasing by 5 every 20 seconds up to a max user count of 50.
Sessions are managed so I need 50 unique logins, I do have a set of users with associated passwords. I tried doing some searching and I cannot figure out how to get the test to run with the set of users that I have.
Anyone on here have any experience with it?
Here's some helpful information considering your question: https://msdn.microsoft.com/en-us/library/dn250793.aspx
It's about using load testing in Visual Studio Ultimate to find performance issues before you release your app.
In Visual Studio Ultimate Trial version, the virtual user count is limited to 250.
If you want to use exactly as many virtual users as you have user accounts in your test data, you could use a web test plugin like this:
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.ComponentModel;
namespace Plugins
{
[DisplayName("Lock Data Table Row to Virtual User Id")]
[Description("Makes each virtual user use the same data row as their user id. "
+ "Only works on first table of first data source. \r\n"
+ "LoadTest > Scenario > Percentage of New Users must be set to 0.")]
public class LockDataTableRowToVirtualUserIdWebTestPlugin : WebTestPlugin
{
public override void PreWebTest(object sender, PreWebTestEventArgs e)
{
int id = e.WebTest.Context.WebTestUserId;
// correct discrepancy (WebTests start at id 1, LoadTests start at id 0)
if (!e.WebTest.Context.ContainsKey("$LoadTestUserContext")) id -= 1;
int rows = e.WebTest.GetDataTableRowCount(e.WebTest.DataSources[0].Name, e.WebTest.DataSources[0].Tables[0].Name);
if (id > rows - 1) // not enough rows
throw new WebTestException("Not enough rows to provide all users with unique data; id=" + id + " rows=" + rows);
e.WebTest.MoveDataTableCursor(e.WebTest.DataSources[0].Name, e.WebTest.DataSources[0].Tables[0].Name, id);
}
}
}
Requires "Percentage of New Users" setting in the Load Test Scenario properties be set to 0, which keeps the virtual user ids constant for each virtual user. Otherwise, new virtual users will get new ids that exceed the data rows.
Could easily be enhanced to work on named DataSources/DataTables via properties.

Conditional validation not working for one field

I've 4 fields as shown below:
radioGroup1 is required if comboBox2 value and radioGroup4 & radio1 are blank. The validation message is suppose to go away if only one of 3 radio's is selected
If I select radioGroup1 or radio1 and update page, the validation message does not display.
If I select radioGroup4 and update page, the validation message is still displayed.
Here is a screen shot:
Here is a validation code for radioGroup1:
var comboBox2:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("comboBox2");
var radio1:com.ibm.xsp.component.xp.XspInputRadio = getComponent("radio1");
var radioGroup4:com.ibm.xsp.component.xp.XspSelectOneRadio = getComponent("radioGroup4");
var radioGroup3:com.ibm.xsp.component.xp.XspSelectOneRadio = getComponent("radioGroup3");
if(comboBox2.getValue()!==''){
if(radioGroup3.getValue()==null){
if(radioGroup4.getValue()==null && radio1.getValueAsString()==''){
return true;
}else {
return false;
}
}
}
In second image there is a computed field capturing value of radioGroup4.
What am I doing wrong? When page is refreshed, radioGroup4.getValue() works in computed field but not in the validation script for radioGroup3.
When any one of 3 radio control selected, the other two are disabled thru script and it is working without any issue.
Resolved this issue as follows:
radioGroup4 was executing script and doing full update in the onChange event. Changed it to onClick event
It need two clicks in the radioGroup4 and required message for radioGroup3 vanishes.
This is not a perfect solution but I've to leave with it until I found perfect one.

GetFirstDocTemplatePosition() returns NULL

I have a MFC to display graph data. I created OCX for the same to display graph in another application. in Normal exe I have an right click pop up menu to do some operation. But when I use the OCX in another application, when I do right click application crash. I got the detail by debugging as follows,
POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition();
// here GetFirstDocTemplatePosition() returns NULL so the below line crashes.
CDocTemplate* doc_template = AfxGetApp()->GetNextDocTemplate(pos);
I couldn't understand why GetFirstDocTemplatePosition() returns NULL. I created separate MENU for exe and OCX. separate resource files too.
Eg:
My application is MyGraph then I created MyGraphOCX.sln for OCX and resource_ocx.h, MyGraphOCX.rc for OCX.
POSITION CWinApp::GetFirstDocTemplatePosition() const
{
if (m_pDocManager == NULL)
return NULL;
return m_pDocManager->GetFirstDocTemplatePosition();
}
Here m_pDocManager is NULL. Why this is NULL I don't understand.
Please provide your valuable suggestions

Resources