|
Respected sir,
I've gone through the cryptarithmetic code given in your website. In the description it was given that the starting letter should not be zero(resultantant string one greater than the operand),but in code execution we are getting the initial value as zero. Please explain.
|
|
|
|
|
Sorry but we have no idea what you are referring to. If this is a CodeProject article then please post your question in the form below the article. If it is referring to something else then please provide the link.
|
|
|
|
|
Hi I have a declaration that's as follows, I am looking to initialize this in single statement rather than initializing individually
private IList<MockData<OnlineRegistration, OnlineRegistration, OnlineRegistration>> _registerMocks;
What I want is obj1, obj2, obj3 of the OnlineRegistration Objects to be initialized within one single statement, it can have multiple lines, don't confuse but values of the these objects all should be set within one statement.
Like:
var obj1 = new OnlineRegistration {Id=1, Name="xyz"}
var obj2 = new OnlineRegistration {Id=2, Name="abc"}
var obj3 = new OnlineRegistration {Id=2, Name=".Net Fun"}
these objects should go into one single initialization of the above statement, any ways? please
|
|
|
|
|
simpledeveloper wrote: of the these objects all should be set within one statement. You are wasting time and effort to get them on a single line, while it has no benefit to do so.
Even more, if you make it into a single statement, it will execute and fail as one. If you use multiple statements, you can use breakpoints on each statement, and have them evaluate individually, which makes finding errors a bit simpeler.
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.
|
|
|
|
|
Hello Developers, I am new to ASP.Net core 2.0.1, i studied the architecture of Authentication and identification in core framework,i facing some problems during migration, please help. In the Startup.cs file, I am using this piecce of code in ConfigureServices method
app.use(async (context, next) =>
{
await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme);
await next.Invoke();
}
Now in core, i dont know how to handle these 2 functions for logout
I get NULLREFERENCE Exception
var projectId = context?.Session?.GetInt("Project_Id"); when page is refershed after a while.
Please help me to resolve these issue.
Geetha
modified 25-Mar-19 4:36am.
|
|
|
|
|
Message Closed
modified 9-Mar-19 4:10am.
|
|
|
|
|
Just use MS Power BI for the desktop and be done with it.
Power BI Desktop | Microsoft Power BI
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
|
I sort of got that from his last line. Just wanted to irritate him by stealing his soapbox.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I am building an application in WPF for the first time. The application is intended to track employees who are hired by the company, track the hire type (e.g…assignment category…full time, part time, seasonal, intern). In addition, it will track which department to which an employee is assigned during their tenure with the company. Some employees are exposed to several different departments while employed in order to more fully round out their training or due to work loads.
The backend for this application is built in SQL Server and contains three tables. They are company employees, company departments, and assignment categories. Each obviously has its own primary key.
I have created a datagrid that, via Linq to SQL Classes, displays data from the company employees table. Each of the columns in the datagrid is a DataGridTextColumn except for one which is a DataGridComboBoxColumn. The DataGridTextColumn’s work fine. However, I cannot seem to get the binding correct. The column appears in the datagrid and is a working combobox. The issue is that I cannot find how to populate the combox with values from which the end user will select. This combobox will allow the end user to choose which under which assignment category an employee has been hired.
As an end result, this application will be used by the company owner to keep track of the number of employees that he has on hand and show who will be leaving each month due to being a seasonal worker or an intern.
Below is the code behind and the xaml. Please note that I have spent several days now researching this topic and cannot find anything that I can make work. I am confident that this is because I am just learning xaml and c#.
Can someone help me understand what I am doing wrong, please?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace staff_scheduling_tool.views
{
public partial class employees_new_employee : UserControl
{
assignment_typeDataContext dc = new assignment_typeDataContext(Properties.Settings.Default.db_employee_scheduling_applicationConnectionString);
public employees_new_employee()
{
InitializeComponent();
if (dc.DatabaseExists()) datagrid_search_results.ItemsSource = dc.companyemployees;
}
private void Save_changes_Click(object sender, RoutedEventArgs e)
{
dc.SubmitChanges();
}
}
}
<DataGrid Name="datagrid_search_results" Margin="10,25" Width="1400" Height="350" AlternatingRowBackground="LightGreen" GridLinesVisibility="None" SelectionUnit="Cell" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding employee_id}" Width="Auto" Header=" Employee ID" />
<DataGridTextColumn Binding="{Binding last_name}" Width="Auto" Header=" Last Name" SortDirection="Ascending" />
<DataGridTextColumn Binding="{Binding first_name}" Width="Auto" Header=" First Name"/>
<DataGridTextColumn Binding="{Binding middle_name}" Width="Auto" Header=" Middle Name"/>
<DataGridTextColumn Binding="{Binding company_email}" Width="Auto" Header=" Company Email"/>
<DataGridComboBoxColumn Width="Auto" Header="Assignment Category" />
<DataGridTextColumn Binding="{Binding department_assignment_begin_date, StringFormat=d}" Width="Auto" Header=" Begin Date"/>
<DataGridTextColumn Binding="{Binding department_assignment_end_date, StringFormat=d}" Width="Auto" Header=" End Date"/>
</DataGrid.Columns>
</DataGrid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="45"/>
</Grid.RowDefinitions>
<Button Name="save_changes" Content="Save Updates" Click="Save_changes_Click" Grid.Row="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="250" FontFamily="Sitka Banner" FontSize="24" FontStyle="Italic" FontWeight="ExtraBold"/>
</Grid>
modified 28-Feb-19 17:42pm.
|
|
|
|
|
|
So I was able to get the code below, but the combo box still will not populate. Can someone help me understand what I am still doing wrong, please?
<DataGrid ItemsSource="{Binding db_employee_scheduling_application}"
Name="datagrid_search_results" Margin="10,25" Width="1400"
Height="350" AlternatingRowBackground="LightGreen" GridLinesVisibility="None"
SelectionUnit="Cell" BorderBrush="Transparent" BorderThickness="0"
Background="Transparent" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding employee_id}" Width="Auto" Header=" Employee ID" />
<DataGridTextColumn Binding="{Binding last_name}" Width="Auto" Header=" Last Name" SortDirection="Ascending" />
<DataGridTextColumn Binding="{Binding first_name}" Width="Auto" Header=" First Name"/>
<DataGridTextColumn Binding="{Binding middle_name}" Width="Auto" Header=" Middle Name"/>
<DataGridTextColumn Binding="{Binding company_email}" Width="Auto" Header=" Company Email" />
<DataGridComboBoxColumn Width="Auto" Header="Assignment Category"
ItemsSource="{Binding assignment categories}"
DisplayMemberPath="assignment category name"
SelectedValuePath="assignment category id"
SelectedValueBinding="{Binding assignment category name}"/>
<DataGridTextColumn Binding="{Binding department_assignment_begin_date, StringFormat=d}" Width="Auto" Header=" Begin Date"/>
<DataGridTextColumn Binding="{Binding department_assignment_end_date, StringFormat=d}" Width="Auto" Header=" End Date"/>
</DataGrid.Columns>
</DataGrid>
|
|
|
|
|
Hey Gerry,
I appreciate your responses. However when I tried implementing your advice and the resulting combo box wouldn't even open. That is not to say that you gave bad advice, but to say that I am in need of more detailed instructions, please.
|
|
|
|
|
I have try DataGridComboBoxColumn but it not works.
you can try
DataGridTemplateColumn
such as
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Types}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
if you still want to use DataGridComboBoxColumn see msdn demo for more details
|
|
|
|
|
Hello everybody,
i'm writing here because i've a strange problem and i'd like to know if my idea is doable!!
Everyday I use a program for working that have not been made by me. This program is made by a console with different button and functions that starts other Windows. These Windows are not child window but are processes in fact in my task manager there are a lot of running processes.
The software house who developed this old program allow me to use an SDK/API in Visual Studio for building my own programs.
The original program works using the same DLL i have to import to develop my owns program but it has never been converted in .NET program and it has always been adapted with different tricks.
My main problem is that to have my own program working i always have to use some tricks like pre/post compilation events and above all, i CAN'T compile with latest .NET Framework but i've to use maximum 3.5.
I'd like to insert in my own program dropbox or google drive API but the NuGet packet doesn't support an application compiled with 3.5 Framework and it only wants the latest one.
So, i thought to develop my own class library that import the software house DLL and who is compiled with .NET Framwork 3.5. In my own program i won't add references to the software house DLL but i will reference to my own class library. In this way i could be able to compile my own application with latest Framework bypassing the limit of the software house DLL. The aim of my new Class Libraries si to work like a "bridge" bewteen my program and the older DLL developed by the software house.
What do you think about my idea?
I also used Telerik JustDecompile to watch inside the old DLL and they don't seem to be very complex. I could also post a screen shot of decompiled code but i don't find the function to do it!!!
|
|
|
|
|
Yes, it's called a COM server and is "doable".
COM Server Development using .NET
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thank you Gerry,
i'll study your advice and i'll try to use it!!!
|
|
|
|
|
This is mainly a curiosity question.
I've seen some pretty cool examples written in MSIL, but I've been able to decompile those examples back C#, so it is unclear why MSIL would be a better choice beyond personal preference.
Are there times when C# and other .net Languages simply can't solve a problem, but can be solved in MSIL (ie a workaround\hack), or maybe sometimes coding in MSIL is more efficient when compared to the compiler? Which would not make too much sense if the code can be decompiled into C# and other .net languages.
|
|
|
|
|
|
HI Freinds,
In our Project we are changing some methods synchronous to asynchronous.There is one situation iam using task.run concept we have global error log where we can read entire structure of the error.when i apply task.run global error log is broken.
Here is my code:
try{
Task.Run(() =>
{
SendMailForGSSCQuotes(mDBEntity.QUOTATIONNUMBER.ToString(), Convert.ToInt32(mDBEntity.ThresholdQty), Convert.ToInt32(mDBEntity.ISHAZARDOUSCARGO), Convert.ToInt32(mDBEntity.HASMISSINGCHARGES));
}).ConfigureAwait(false);
}
catch(Exception ex){
LogErrorAsync("api/Quotation", "SendMail", ex.Message.ToString(), ex.StackTrace.ToString());
}
in SendMailForGSSCQuotes intentionally throwing error to see how the global error log works.
protected void LogErrorAsync(string controller, string action, string message, string stacktrace, string user = "")
{
QuotationDBFactory mFactory = new QuotationDBFactory();
mFactory.InsertErrorLog(
user,
controller,
action,
message,
stacktrace
);
SendEmailAysnc(stacktrace, message).ConfigureAwait(false);
}
internal async Task<bool> SendEmailAysnc(string st, string ex)
{
try
{
var Content = string.Empty;
if (this.ActionContext.Request.Method.ToString() == "POST")
{
var d = new StreamReader(await Task.Run(() => this.ActionContext.Request.Content.ReadAsStreamAsync().Result).ConfigureAwait(true));
d.BaseStream.Seek(0, SeekOrigin.Begin);
Content = d.ReadToEnd();
}
var hostdata = ((System.Web.HttpRequestWrapper)this.RequestContext.GetType().Assembly.GetType("System.Web.Http.WebHost.WebHostHttpRequestContext").GetProperty("WebRequest").GetMethod.Invoke(this.RequestContext, null));
var exdata = new ExceptionEmailDto()
{
ActionMethod = this.ActionContext.Request.Method.ToString(),
AppUrl = System.Configuration.ConfigurationManager.AppSettings["APPURL"],
Error = ex,
Headers = this.ActionContext.Request.Headers.ToString(),
ServerName = System.Configuration.ConfigurationManager.AppSettings["ServerName"],
StackTrace = st,
Url = this.ActionContext.Request.RequestUri.ToString(),
UserAgent = hostdata.UserAgent == null ? string.Empty : hostdata.UserAgent.ToString(),
UserHostAddress = hostdata.UserHostAddress == null ? string.Empty : hostdata.UserHostAddress.ToString(),
UserHostName = hostdata.UserHostName == null ? string.Empty : hostdata.UserHostName.ToString(),
UTC = DateTime.UtcNow.ToString(),
Content = Content,
ServerVariables = hostdata.ServerVariables == null ? "undefined" : hostdata.ServerVariables.ToString()
};
FOCiS.SSP.Web.UI.Controllers.APIDynamicClass.SendExceptionEmailV2(
exdata
);
}
catch (Exception exc)
{
FOCiS.SSP.Web.UI.Controllers.APIDynamicClass.SendExceptionEmail(this.ActionContext.Request.Method.ToString(),
exc.Message.ToString(), exc.StackTrace.ToString()
);
return false;
}
return true;
}
Getting error here
var d = new StreamReader(await Task.Run(() => this.ActionContext.Request.Content.ReadAsStreamAsync().Result).ConfigureAwait(true));
Error:
Cannot access a disposed object.
Object name: 'System.Web.Http.WebHost.HttpControllerHandler+LazyStreamContent'.
I tried so many ways if i remove Task.Run its working fine.
Thanks
|
|
|
|
|
Why do you have a task.run inside an sync method when this would be perfectly OK and works as you say:
var d = new StreamReader(await this.ActionContext.Request.Content.ReadAsStreamAsync());
|
|
|
|
|
I tried as you said
var d = new StreamReader(await this.ActionContext.Request.Content.ReadAsStreamAsync());
Quote Selected Text
Still same exception is throwing i guess some where problem with Task
|
|
|
|
|
The formatting is a bit all over the place so it's hard to read, but this should also be async:
protected async Task LogErrorAsync(string controller, string action, string message, string stacktrace, string user = "")
{
QuotationDBFactory mFactory = new QuotationDBFactory();
mFactory.InsertErrorLog(
user,
controller,
action,
message,
stacktrace
);
await SendEmailAysnc(stacktrace, message);
}
and then:
try{
Task.Run(() =>
{
SendMailForGSSCQuotes(mDBEntity.QUOTATIONNUMBER.ToString(), Convert.ToInt32(mDBEntity.ThresholdQty), Convert.ToInt32(mDBEntity.ISHAZARDOUSCARGO), Convert.ToInt32(mDBEntity.HASMISSINGCHARGES));
}).ConfigureAwait(false);
}
catch(Exception ex){
Task.Run(() =>
{
LogErrorAsync("api/Quotation", "SendMail", ex.Message.ToString(), ex.StackTrace.ToString());
});
}
|
|
|
|
|
I tried the same as you mention still no luck.Same error throwing
|
|
|
|
|
Why we choose Task.Run to render the UI First then we will run remaining methods.here chosse task.run its working fine as per requirement when coming back to global error its broken as my guess the object is dispose when UI as render so no where to run the
ReadAsStreamAsync
|
|
|
|
|