|
That's reading all the images and making one big array of bytes of it; may be a bit much for the memorymanager.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
insert or update and insert or replace doesnt work with autoincrement fields [^] so i guess again i'm stuck in generating my own guid and use them,
or i should run insertorupdate if the database already exist while manually giving the id's starting from Id 1. guid sounds better idea
|
|
|
|
|
Nothing against Guids; and the order in which the inserts are done is usually not guaranteed, so an autoincrement-assignment may not always be in the exact same order.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
what is usually the correct way to check first and then only create data if it is necessary? i have read somewhere that you can see if the table exist, or the table count, but this approach seems so poor to me, what do you say , what is the best way?
|
|
|
|
|
I usually perform a select (on the pk) to verify if it exists, and if it doesn't, execute an insert; whether that's the "best" idea is debatable. I'm trying to stay away from parts of SQL that aren't part of the SQL92 spec, making it easier to move queries between different types of databases. Another little benefit is that I can use most databases to test any queries, since most support the SQL92 standard.
If your code is designed specifically for SQLite, then it makes little sense to limit yourself and not use the options that the database gives you. There's an "upsert" command for example (SQLite Query Language: upsert[^]), combining insert and update (in a somwhat similar way to "insert or replace").
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Great friend, with your help im executing a transaction and if it is completed i save this state somewhere. and to check if db exist and not to recreated i have made this code that works great,im also saving the current database version as int in order to easily do more updates in the future.
Now all i have to do is call GetTemplateById or GetAllTemplates and if any creation is required will happen
public bool FirstRun { get; set; } = true;
public int DatabaseCreatedVersionOf { get; set; } = -1;
public override void OnCreate()
{
base.OnCreate();
}
public void UpdateDatabaseCreatedVersion()
{
DatabaseCreatedVersionOf = Preferences.Get(Settings.DatabaseCreatedVersionOfKey,
Settings.DatabaseCreatedVersionOfDefault);
}
public void CreateTemplateDB()
{
UpdateDatabaseCreatedVersion();
if (DatabaseCreatedVersionOf == -1)
TemplateDB.CreateDB();
FirstRun = false;
}
public Template GetTemplateById(int id)
{
if (FirstRun)
{
CreateTemplateDB();
FirstRun = false;
}
return TemplateDB.GetTemplate(id);
}
public List<Template> GetAllTemplates()
{
if (FirstRun)
{
CreateTemplateDB();
FirstRun = false;
}
return TemplateDB.GetAllTemplates();
}
|
|
|
|
|
Good to hear it works; you're welcome, and I'll be more careful in the future to make sure I understand the question
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Exoskeletor wrote: Im starting thinking that this is a very silly idea because i guess the Resource id is generated every time i compile a new version of my app, so im trying to create a unique hash of something that is not unique You don't want to hash it's id, but the data that represents the image You want to compare those to each other, not the Id's that identify the image.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
i think i have an idea of how im going to do it, i can do something like this:
public static string GetMD5Hash(string text)
{
using ( var md5 = MD5.Create() )
{
byte[] computedHash = md5.ComputeHash( Encoding.UTF8.GetBytes(text) );
return new System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary(computedHash).ToString();
}
}
var nums = new List<int> {1, 2, 3};
var result = string.Join(", ", nums);
var hash = GetMD5Hash(result);
|
|
|
|
|
There is this code that have a name in the table data and I have been asked to make that data red. Right now it is bold (strong). I need to add code to also make it appear read. How do I do this?
Here is the code in C#
<ItemTemplate>
<%#
Eval("AttorneyPartyID").ToString() != Eval("PartyID").ToString() ?
"<table><tr><td>" + Eval("AttorneyFullName") + "</td></tr>"
:
"Pro Se"
%>
</ItemTemplate>
|
|
|
|
|
Why are you inserting a single-cell table? Just wrap the value in a <span> or a <div> , and set a suitable CSS class on it.
You'll also need to HTML encode the value from the database, just in case.
<ItemTemplate>
<%#
Eval("AttorneyPartyID", "{0}") != Eval("PartyID", "{0}")
? "<div class=\"attorney-full-name\">" + HttpUtility.HtmlEncode(Eval("AttorneyFullName", "{0}")) + "</div>"
: "Pro Se"
%>
</ItemTemplate>
.attorney-full-name {
color: #a00;
font-weight: bold;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It is not a single-cell. I did not paste the whole table (ItemTemplate). The table has 5 rows and each row has a single (cell)
Here is the whole table
<asp:TemplateField HeaderText="Attorney" HeaderStyle-HorizontalAlign="Justify" ItemStyle-Width="25%" >
<ItemTemplate>
<%#
Eval("AttorneyPartyID").ToString() != Eval("PartyID").ToString() ?
"<table><tr><td>" + Eval("AttorneyFullName") + "</td></tr>"
:
"Pro Se"
%>
<%#
Eval("AttorneyPartyID").ToString() != Eval("PartyID").ToString() && Eval("AttorneyPhoneNumber") != "" && Eval("AttorneyPhoneNumber") != null ?
"<tr><td>Phone:" + ' ' + Eval("AttorneyPhoneNumber") + "</td></tr>"
:
string.Empty
%>
<%#
Eval("AttorneyPartyID").ToString() != Eval("PartyID").ToString() && Eval("AttorneyEmail") != "" && Eval("AttorneyEmail") != null ?
"<tr><td>Email:" + Eval("AttorneyEmail") + "</td></tr>"
:
string.Empty
%>
<%#
Eval("AttorneyPartyID").ToString() != Eval("PartyID").ToString() ?
"</table>"
:
string.Empty
%>
</ItemTemplate>
</asp:TemplateField>
|
|
|
|
|
You still need to HTML-encode the database values. And the solution to your original question is still the same: add a CSS class to the parent element of the text you want to style.
I also think you can tidy that code up somewhat, and avoid having to build the HTML as a string:
<asp:TemplateField HeaderText="Attorney" HeaderStyle-HorizontalAlign="Justify" ItemStyle-Width="25%">
<ItemTemplate>
<asp:MultiView runat="server" ActiveViewIndex='<%# Eval("AttorneyPartyID", "{0}") != Eval("PartyID", "{0}") ? 0 : 1 %>'>
<asp:View runat="server">
<table>
<tr>
<td class="attorney-full-name"><%#: Eval("AttorneyFullName") %></td>
</tr>
<asp:Placeholder runat="server" visible='<%# !string.IsNullOrEmpty(Eval("AttorneyPhoneNumber", "{0}")) %>'>
<tr>
<td class="attorney-phone-number">Phone: <%#: Eval("AttorneyPhoneNumber") %></td>
</tr>
</asp:Placeholder>
<asp:Placeholder runat="server" visible='<%# !string.IsNullOrEmpty(Eval("AttorneyEmail", "{0}")) %>'>
<tr>
<td class="attorney-email">Email: <%#: Eval("AttorneyEmail") %></td>
</tr>
</asp:Placeholder>
</table>
</asp:View>
<asp:View runat="server">
Pro Se
</asp:View>
</asp:MultiView>
</ItemTemplate>
</asp:TemplateField> NB: Using <%#: ... %> instead of <%# ... %> - note the extra : at the start - will automatically HTML-encode the output for you.
MultiView Class (System.Web.UI.WebControls) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank for your help on trying to figure this out. I did add css class to existing css file.
.inactiveAttorney
{
color: #AD0000;
font-weight:bold
}
The product owner have asked me to only make the attorney name red when fActive = 0 (false). The code behind have this code
private bool _fActive;
public bool fActive
{
get { return this._fActive; }
set { this._fActive = value; }
}
this._fActive = parsefActive == true ? true : false;
I have successfully been able to use css class to make attorney name red. However, I need help to add a condition so that the name is red only when fActive =false (0).
Here is my code which is working and needs adding condition
"<table><tr><td class='inactiveAttorney'>" + Eval("AttorneyFullName") + "</td></tr></table>"
The fActive is a Boolean and else where in the code I see something done when a Boolean is true. I need to do something similar but I do not know how.
Here is that example.
<tr><td><%# (bool)Eval("PartyConfidentialHomePhone") == true ? "<img src=\"../../Images/YellowLock_16x16.png\" alt=\"Home Phone Secured\" />":"" %><%#Eval("PartyHomePhone").ToString() != "" && Eval("PartyHomePhone") != null ? "" + Eval("PartyHomePhone") + "":string.Empty%></td></tr>
modified 9-Mar-20 13:29pm.
|
|
|
|
|
Try:
"<table><tr><td class='" + (fActive ? "activeAttorney" : "inactiveAttorney") + "'>" + Eval("AttorneyFullName") + "</td></tr></table>"
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Homer,
Thanks for your reply. When I tried the code you gave me, I am getting an error The name "fActive" does not exist in the current context
|
|
|
|
|
Then the code-behind of the page or user control where the data-binding is taking place doesn't have the property you showed in your previous message.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Here is the code behind that have the fActive
private bool _fActive;
public bool fActive
{
get { return this._fActive; }
set { this._fActive = value; }
}
bool parsefActive = false;Boolean.TryParse(row["fActive"].ToString(), out parsefActive);
this._fActive = parsefActive == true ? true : false;
|
|
|
|
|
As I said, that doesn't tally with the error message:
The name "fActive" does not exist in the current context
That property does not exist in the code-behind for the page or user control where your data-binding is taking place.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi everybody who tried to help me on this problem. I wanted to thank you for trying to help. However after hours of try and error, I found a solution that works. Just wanted to let you know this is now fixed. Here is my solution. Looks pretty simple! So the logic is, if AttorneyPartyID = PartyID that is Pro Se, else if fActive is false that means the attorney is inactive. Use inactiveAttorney css class to display attorney name with red font
else the attorney is active and no need to display name in red font. Display in bold font.
<%#
Eval("AttorneyPartyID").ToString() == Eval("PartyID").ToString()
? "Pro Se"
: (bool) Eval("fActive") == false
? "<table><tr><td class='inactiveAttorney'>" + Eval("AttorneyFullName") + "</td></tr>"
:"<table><tr><td>" + Eval("AttorneyFullName") + "</td></tr>"
%>
modified 12-Mar-20 10:22am.
|
|
|
|
|
Hi Experts,
I have a requirement to access a connected printer device through their embedded web server.
The device had an option to secure its details using username and password.
Once it is set, we can only communicate through "https" to that device.
Also there is windows credentials popup will come from UWP app once we initiate communication through https and wait for the user to enter the correct username and password as in web server.
My requirement is we need to pass those credentials as authorization header for a POST request to that device.
eg:-
Authorization: Basic YWRtaW46MTIzNDU2Nzg5
How to access those Windows credentials in UWP app. Without this authorization token, i am getting HTTP:401 unauthorized error for the POST request.
Please guide me to resolve this issue.
What I have tried:
I tried hard coding the username and password entered in the web server.
var username = usrName;
var password = pwd;
var base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"));
_httpClient.AuthorizationHeader = new KeyValuePair<string, string>("Basic", base64String);
then in this case the POST request is successful.
Also tried the same in a separate test application. In that case after entering the credentials in the windows credentials popup the same POST request is again sending automatically with those credentials as Basic auth token.
Regards
Spk
|
|
|
|
|
|
Ok. Sorry it's under the new tab. My mistake.
|
|
|
|
|
Hello experts
I have this behavior that I cannot figure it out. The following code loops through and extracts some firewall settings. It is triggered by a button
try
{
Type typeFWPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
INetFwPolicy2 fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(typeFWPolicy2);
foreach (INetFwRule rule in fwPolicy2.Rules)
{
lvItems.RuleName = rule.Name; ;
lvItems.RemoteAddress = rule.RemoteAddresses;
lvItems.Protocol = rule.Protocol.ToString();
lvItems.LocalPort = rule.LocalPorts;
dataGrid1.Items.Add(lvItems);
}
}
catch (Exception ex)
{
MessageBox.Show("something went wrong");
}
When I run it, the datagrid is populated with the same record (only the first) entry that is repeated several times.
then I added a MessageBox to troubleshoot, then Datagrid is populated correctly but I need to acknowledge each Messagebox !!!!. It is like it just needs that extra mouse click.
any help is greatly appreciated
|
|
|
|
|
You are overwriting the lvItems instance each time you go through the loop. You should move the instantiation of lvItems inside the loop so you have a new instance created each time.
|
|
|
|