|
Searching for keywords on Jobs / CVs (Resumes) can never lead to anything but grief. Ask any job applicant or recruiter who has been stung by keyword search systems.
If you are, say, looking for a job application that needs SQL and C#, how would you reject some sentence like "I have never used SQL and I hate C#" or distinguish the relative merits of an applicant who says "I have 20 years experience in C#" from one who says "I have not used C# but I would like to learn it".
|
|
|
|
|
Greetings again dear experts,
Back for more your great assistance.
DateTime runDate = DateTime.Parse(rsRunDate.Text);
When I run my app, I get the following:
The string was not recognized as a valid DateTime. There is an unknown word starting at index 0. This error points to the line code I posted.
I tried changing the code to the following:
DateTime runDate = DateTime.ParseExact(srRunDate.Text,"dd/MM/yyyy", null);
However, I still get same error.
I tried the following:
DateTime _runDate;
string runDate = "";
_runDate = DateTime.Parse(srRunDate.Text);
runDate = _runDate.ToString("dd/MMM/yyyy");
But then, the following produces an error:
if (runDate.Date > DateTime.Now.Date)...
Now, I get the following error:
The name 'runDate' does not exist in the current context
I ran the code in debug mode, it shows runDate with the following value: {1/1/0001 12:00:00 AM} System.DateTime
I am out of ideas.
Any ideas how to fix this?
modified 20-Oct-22 13:04pm.
|
|
|
|
|
You shouldn't be looking at the variable that hold the parsed value. The text hasn't been parsed, so what's the point?
You should be looking at the content of srRunDate.Text . For example, trying to use Parse on an empty string will throw an exception.
You should change your code to use TryParse instead. At least then, you'll get a return value of true or false denoting if the parse operation worked or not.
|
|
|
|
|
Thank you very much Dave.
|
|
|
|
|
"{" is not part of a date. The exception is correct.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I am migrating the .Net Project to .Net core 3.1 and there are loads of dependencies in the project so I cannot create a new .Net core application. How can I add Program.Cs file in my existing .Net api project?
I need this code in my existing .Net api project
<pre>public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseSerilog((hostingContext, loggerConfiguration) =>
{
var connectionString = hostingContext.Configuration.GetSection("Serilog:WriteTo:0:Args:connectionString");
connectionString.Value = connectionString.Value;
loggerConfiguration.ReadFrom.Configuration(hostingContext.Configuration);
});
}
|
|
|
|
|
If you're migrating, you might want to move to something that will be supported for more than two months:
.NET Core 3.1
End of Support: December 13, 2022
Currently, the "long-term support" (LTS) version is .NET 6.0, which is supported until at least November 12, 2024.
Also, you forgot to explain what the problem is with your code. There's nothing obviously wrong with it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a ASP .NET MVC project, inside controller, I call a simple WebAPI using WebClient
e.g.
WebClient client = new WebClient();
client.Headers.Add("cache-control", "no-cache");
client.Headers.Add("accept-encoding", "gzip, deflate");
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.Headers.Add("Accept", "application/json");
client.Headers.Add("Authorization", "Basic xxxxxx");
var respond = client.UploadString(new Uri("https://xxxxxx/"), "POST", "xxxxxx");
there is an exception when call UploadString immediately with error
"The entry '*' has already been added." in webConfig.
If remove the line "<add address="*" maxconnection="500"/>" from webConfig, the
exception is gone. Same thing is also happen when using HttpClient and RestClient.
WebConfig
"...
<connectionManagement>
<add address="*" maxconnection="500"/>
</connectionManagement>
..."
Do anyone know why it happen? Why does WebClient attempt to add the entry to configuration
during runtime and cause the error?
BTW, I have fixed the problem by remove the line from WebConfig, and put it to program StartUp
e.g.
System.Net.ServicePointManager.DefaultConnectionLimit = 500;
|
|
|
|
|
It's likely that the configuration from a higher level already defines the * address. This could be in a config file from a parent application, or the machine-level config file.
The simplest option is to clear or remove the addresses before adding the new one:
<connectionManagement>
<remove address="*" />
<add address="*" maxconnection="500" />
</connectionManagement>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have dynamic data showing on a blazor page
@foreach (var item in DisplayList.OrderBy(i => i.CompanyId))
{
<tr>
<td style="width:300px; color:darkgreen;">@item.Company</td>
<td style="width:250px; color:blue;">@item.FunctionName</td>
<td style="width:250px;">@item.Identifier</td>
<td>@item.SkillsSet</td>
</tr>
}
In my code I do a if..contains..replace on the part item.SkillsSet.
This is a string.
What I'm trying to do is: when this string contains a value I want that value to be surrounded with the "mark" tag so that part is highlighted.
Like: Jo | Lisa | Me | John
But the result is not what I expect. It shows the names and the tag. It doesn't highlight the text
It shows:
Jo | Lisa | <mark>Me</mark> | John
What to do?
|
|
|
|
|
Try using the Html.Raw helper method to indicate that the string should not be HTML-encoded:
@Html.Raw(item.SkillsSet) NB: You'll need to make sure the rest of the string is properly HTML-encoded to ensure it displays correctly and to avoid the potential for a persisted cross-site scripting vulnerability.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
<appSettings>
<add key="FilePath" value="C:\Users\*****\Desktop\Plans_First.xlsx"/>
<add key="SheetName" value="LAVVAGGIO|MANUTENZIONE|Map"/>
<add key="SortColumnName" value="LAVVAGGI_VALUE|MANUTENZIONI_VALUE"/>
<add key="MapColumn" value="NAME|LAVVAGGI_RANK|MANUTENZIONI_RANK"/> <!--ID Column should be present by default-->
<add key="RankColumn" value="LAVVAGGI_RANK|MANUTENZIONI_RANK"/>
</appSettings>
private DataTable SortSheet(string FilePath, string SheetName, string SortColumnName,string RankColumn)
{
try
{
var fileName = FilePath;
if (!File.Exists(FilePath))
{
txtLogger.Text += FilePath + " File Not Found!!!" + Environment.NewLine;
MessageBox.Show(" File Not Found!!!");
new DataTable();
}
#region Reading excel file
var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 12.0;IMEX=0;HDR=YES;TypeGuessRows=0;ImportMixedTypes=Text\""; ;
DataSet ds = new DataSet();
using (var conn = new OleDbConnection(connectionString))
{
try
{
try
{
conn.Open();
}
catch (Exception ex1)
{
txtLogger.Text += " exception : " + ex1.StackTrace + Environment.NewLine;
MessageBox.Show("File is Open, Please close to proceed!!!");
new DataTable();
}
var sheets = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
DataRow[] dr = sheets.Select("[Table_name]= '" + SheetName.ToString() + "$'");
if (dr.Length == 0)
{
MessageBox.Show("SheetName Not Found!!!");
txtLogger.Text += SheetName.ToString() + " : SheetName Not Found!!!" + Environment.NewLine;
new DataTable();
}
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT * FROM [" + SheetName + "$] WHERE [ID] IS NOT NULL ";
var adapter = new OleDbDataAdapter(cmd);
adapter.Fill(ds);
}
}
catch (Exception ex)
{
txtLogger.Text += " exception : " + ex.StackTrace + Environment.NewLine;
MessageBox.Show("Error Occured ,Please check the log!!!");
new DataTable();
}
finally
{
conn.Close();
conn.Dispose();
}
}
#endregion
#region Sorting based on SortColumnName
DataTable dt = ds.Tables[0];
DataView view = dt.DefaultView;
view.Sort = SortColumnName + " ASC";
DataTable sortedData = view.ToTable();
if(sortedData.Columns.Contains(RankColumn))
{
int rank = 1;
foreach (DataRow row in sortedData.Rows)
{
row[RankColumn] = rank;
rank++;
}
}
txtLogger.Text += " Sort Completed : Sheet " + SheetName + Environment.NewLine;
return sortedData;
#endregion
}
catch (Exception)
{
throw;
}
}
private void InsertSheet(string FilePath, DataTable MapDatatable, string MapSheetName, List<string> updatedColumns)
{
try
{
var fileName = FilePath;
if (!File.Exists(FilePath))
{
txtLogger.Text += FilePath + " File Not Found!!!" + Environment.NewLine;
MessageBox.Show(" File Not Found!!!");
return;
}
var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 12.0;IMEX=0;HDR=YES;TypeGuessRows=0;ImportMixedTypes=Text\""; ;
#region Updating Excel
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.Connection = conn;
var sheets = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
int colcount = 0;
System.Type type;
foreach (DataRow row in MapDatatable.Rows)
{
colcount = 0;
StringBuilder commandString = new StringBuilder();
commandString.Append("UPDATE [" + MapSheetName.ToString() + "$"+"] SET ");
foreach (DataColumn c in MapDatatable.Columns)
{
if (updatedColumns.Contains(c.ColumnName))
{
commandString.Append(c.ColumnName);
type = row.ItemArray[colcount].GetType();
if ((type == typeof(string)) || (type == typeof(DateTime)))
{
commandString.Append(" = '").Append(row.ItemArray[colcount]).Append("' ,");
}
else if (row.ItemArray[colcount].ToString().Trim() == string.Empty)
{
commandString.Append(" = ' ").Append(row.ItemArray[colcount]).Append("' ,");
}
else
{
commandString.Append(" = ").Append(row.ItemArray[colcount]).Append(" ,");
}
}
colcount++;
}
commandString.Remove(commandString.Length - 1, 1);
commandString.Append(" where ID = " + row["ID"].ToString() + ";");
cmd.CommandText = commandString.ToString();
cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
txtLogger.Text += " Update exception on Line : " + ex.StackTrace + ": Sheet " + MapSheetName+ Environment.NewLine;
MessageBox.Show("Error Occured ,Please check the log!!!");
return;
}
finally
{
conn.Close();
conn.Dispose();
}
}
#endregion
}
catch (Exception)
{
throw;
}
}
<pre>private void button1_Click(object sender, EventArgs e)
{
#region Full Event
try
{
txtLogger.Text = string.Empty;
string FilePath = System.Configuration.ConfigurationManager.AppSettings["FilePath"];
string SheetName = System.Configuration.ConfigurationManager.AppSettings["SheetName"];
string SortColumnName = System.Configuration.ConfigurationManager.AppSettings["SortColumnName"];
string MapColumn = System.Configuration.ConfigurationManager.AppSettings["MapColumn"];
string RankColumn = System.Configuration.ConfigurationManager.AppSettings["RankColumn"];
string[] Sheets = SheetName.Split('|');
string[] sortColumnName = SortColumnName.Split('|');
string[] mapColumn = MapColumn.Split('|');
string[] rankColumn = RankColumn.Split('|');
int colcount = 0;
List<string> updatedColumns = new List<string>();
foreach (var item in mapColumn)
{
updatedColumns.Add(mapColumn[colcount].ToString());
colcount++;
}
if(DateTime.Now.Year==2023)
{
MessageBox.Show("error");
return;
}
DataTable Sheet1, Sheet2 , Sheet3;
Sheet1 = SortSheet(FilePath, Sheets[0].ToString(), sortColumnName[0].ToString(),rankColumn[0].ToString());
Sheet2 = SortSheet(FilePath, Sheets[1].ToString(), sortColumnName[1].ToString(),rankColumn[1].ToString());
Sheet3 = SortSheet(FilePath, Sheets[2].ToString(), "ID", rankColumn[1].ToString());
if ((Sheet1.Rows.Count>0)&&(Sheet2.Rows.Count > 0))
{
if(!Sheet1.Columns.Contains(mapColumn[0].ToString()))
{
Sheet1.Columns.Add(mapColumn[0].ToString(), typeof(System.String));
foreach (DataRow row in Sheet1.Rows)
{
row[mapColumn[1].ToString()] = string.Empty;
}
}
if (!Sheet1.Columns.Contains(mapColumn[1].ToString()))
{
Sheet1.Columns.Add(mapColumn[1].ToString(), typeof(System.Int32));
foreach (DataRow row in Sheet1.Rows)
{
row[mapColumn[1].ToString()] = 0;
}
}
if (!Sheet1.Columns.Contains(mapColumn[2].ToString()))
{
Sheet1.Columns.Add(mapColumn[2].ToString(), typeof(System.Int32));
foreach (DataRow row in Sheet1.Rows)
{
row[mapColumn[2].ToString()] = 0;
}
}
}
Sheet1.AsEnumerable()
.Join(Sheet2.AsEnumerable(),
dt1_Row => dt1_Row.ItemArray[0],
dt2_Row => dt2_Row.ItemArray[0],
(dt1_Row, dt2_Row) => new { dt1_Row, dt2_Row })
.ToList()
.ForEach(o =>
o.dt1_Row.SetField(7, o.dt2_Row.ItemArray[6]));
InsertSheet(FilePath, Sheet1, Sheets[2].ToString(),updatedColumns);
MessageBox.Show(" Reschedule Completed!!!");
return;
}
catch (Exception ex)
{
txtLogger.Text += " exception : " + ex.StackTrace + Environment.NewLine;
MessageBox.Show("Error Occured ,Please check the log!!!");
return;
}
#endregion
}
modified 4-Oct-22 17:41pm.
|
|
|
|
|
A massive wall of unexplained code is not a question.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So have I have a modal with a updatepanel and a repeater inside it. I have an open another modal on linkbutton click, I would like to update the 2nd modal with a checkboxlist, but the linkbutton click doesn't fire for me to update the 2nd modal data.
|
|
|
|
|
There's a secret error somewhere in your secret code. You should fix that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
bonjour
avec le code ci-dessous je trouve que quelque champ de ma demande, n
le graphique n'affiche que les description de (AA,CC,SS,GG,...) pas de (BB,DD,FF,...)
code source
Me.Chart1.Series("Statistiques").Points.AddXY("AA", 95)
Me.Chart1.Series("Statistiques").Points.AddXY("BB", 90)
Me.Chart1.Series("Statistiques").Points.AddXY("CC", 85)
Me.Chart1.Series("Statistiques").Points.AddXY("DD", 95)
Me.Chart1.Series("Statistiques").Points.AddXY("SS", 93)
Me.Chart1.Series("Statistiques").Points.AddXY("FF", 90)
Me.Chart1.Series("Statistiques").Points.AddXY("GG", 95)
Me.Chart1.Series("Statistiques").Points.AddXY("UU", 95)
Me.Chart1.Series("Statistiques").Points.AddXY("II", 95)
Me.Chart1.Series("Statistiques").Points.AddXY("QQ", 95)
comment je peux afficher la description de reste des champs (BB, DD, ....) et merci d'avance
|
|
|
|
|
document.activeElement.id is not working in safari
|
|
|
|
|
If you wish for help with your problem then you need to edit your question and provide full details. Saying, "not working", tells us nothing.
|
|
|
|
|
Hence, you can change your event handler from:
$('#modalLogout').on('hide.bs.modal', function () {
var activeElement = $(document.activeElement);
to the delegated one:
$('#modalLogout').on('click', '#LogoutOk', function (e) {
var activeElement = $(e.target);
|
|
|
|
|
can anyone provide pointers on how to develop Auto reply chatbot in asp.net site?
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
|
I am developing online learning portal in ASP.NET MVC web-application and I want develop video conference feature inside web-app.
Please help me in creating this application, because I am new in web-development.
|
|
|
|
|
You'll probably want to start with the Media Capture and Streams API[^]. But that's an extremely ambitious project, especially for a beginner.
NB: Asking for help writing something without explaining precisely what help you need, what you have tried, or where you are stuck, will lead people to assume that you want someone to do all the work for you. That's not going to happen.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
maybe you can integrate "BigBlueButton" in your project
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|