|
Nah. I would call Matlab from C#; not the other way around.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
my login page code:
if (dr[2].ToString() == "Executive Engineer" || dr[2].ToString() == "Deputy Executive Engineer")
{
if (txtUserId.Text == dr[0].ToString() && txtPassword.Text == dr[1].ToString())
{
Session["id"] = txtUserId.Text;
Response.Redirect("SuperAdminPanel.aspx", false);
}
}
my SupperAdmin page code:
if (Session["id"] != null )
{
//business code something
but when we request some othet page came back on supperAdmin page we got null session
what we do?
sorry for poor language i'm new in dot.Net
thank you
|
|
|
|
|
You are getting session null if you did not landed on those other pages from login page. As you setting
Session["id"] = txtUserId.Text; only on LOGIN page.
modified 20-Sep-20 21:01pm.
|
|
|
|
|
waghniteen wrote: what we do? You figure out why it is null. Did the Session timeout? Do you have code somewhere that resets the session values? Are you testing for session inside a WebMethod? We have no way of knowing since we can't see your code or your environment.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
it's not a session timeout problem we place blow code in config
<sessionstate cookieless="false" regenerateexpiredsessionid="true" timeout="200">
<providers>
<clear>
|
|
|
|
|
You also need to check IIS settings to make sure the app pool is not being recycled. And check event viewer for any problems.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
when we host website on my domain that time we get this problem. not get on localhost
|
|
|
|
|
You're still going to have to troubleshoot on your own.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Downvote countered - I don't think he liked being told the truth...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
if we enter a Marathi decimal value in text-box then how to convert into English
thank you
|
|
|
|
|
What do you mean by "marathi decimal value" here?
modified 20-Sep-20 21:01pm.
|
|
|
|
|
just like we enter a १० in text-box,output as 10
|
|
|
|
|
Exactly how you do it depends on the culture in use on your computer. You need to use a Marathi culture for your inputs, and an English one for outputs. If your user culture is set to accept Marathi, then it's just decimal.TryParse . Otherwise specify the cultures:
string input = "12,12,12,123.45";
string output = "Not recognised as a number";
decimal d;
CultureInfo ciMarathi = CultureInfo.CreateSpecificCulture("mr-IN");
CultureInfo ciEnglishUK = CultureInfo.CreateSpecificCulture("en-GB");
if (decimal.TryParse(input,NumberStyles.Any, ciMarathi, out d))
{
output = d.ToString("#,0.##", ciEnglishUK);
} If you also want to include Marthi Unicode digits such as "४५९", there is an extra step:
string input = "४५,४५९.४५९";
string output = "Not recognised as a number";
decimal d;
input = new string(input.Select(c => char.IsDigit(c) ? (char) (char.GetNumericValue(c) + '0') : c).ToArray());
CultureInfo ciMarathi = CultureInfo.CreateSpecificCulture("mr-IN");
CultureInfo ciEnglishUK = CultureInfo.CreateSpecificCulture("en-GB");
if (decimal.TryParse(input,NumberStyles.Any, ciMarathi, out d))
{
output = d.ToString("#,0.##", ciEnglishUK);
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
I've been working to adapt code by Matthew Proctor. My goal is to remove the prompt, selecting the specific account, and downloading .xls attachments from a specific folder(inbox-attachments).
The program enumerates the email accounts, user selection, enumerates the "inbox's" subfolders, and extracts the .xls files. If anyone can point me in the right direction to accomplish this, I would very much appreciate the help. *I'm sorry that this is so long, but I didn't want to leave anything out that may be relevant.
using System;
using System.Linq;
using System.IO;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace OutlookAttachmentExtractor
{
class Program
{
static string basePath = @"c:\temp\DownloadedEmails\";
static int totalfilesize = 0;
static void Main(string[] args)
{
EnumerateAccounts();
}
static void EnumerateFolders(Outlook.Folder folder)
{
Outlook.Folders childFolders = folder.Folders;
if (childFolders.Count > 0)
{
foreach (Outlook.Folder childFolder in childFolders)
{
if (childFolder.FolderPath.Contains(@"Inbox"))
{
Console.WriteLine(childFolder.FolderPath);
EnumerateFolders(childFolder);
}
}
}
Console.WriteLine("Looking for items in " + folder.FolderPath);
IterateMessages(folder);
}
static void IterateMessages(Outlook.Folder folder)
{
string[] extensionsArray = { ".xls" };
var fi = folder.Items;
if (fi != null)
{
try
{
foreach (Object item in fi)
{
Outlook.MailItem mi = (Outlook.MailItem)item;
var attachments = mi.Attachments;
if (attachments.Count != 0)
{
if (!Directory.Exists(basePath))
{
Directory.CreateDirectory(basePath);
}
for (int i = 1; i <= mi.Attachments.Count; i++)
{
var fn = mi.Attachments[i].FileName.ToLower();
if (extensionsArray.Any(fn.Contains))
{
if (!Directory.Exists(basePath))
{
Directory.CreateDirectory(basePath);
}
totalfilesize = totalfilesize + mi.Attachments[i].Size;
if (!File.Exists(basePath + @"\" + mi.Sender.Address + @"\" + mi.Attachments[i].FileName))
{
Console.WriteLine("Saving " + mi.Attachments[i].FileName);
mi.Attachments[i].SaveAsFile(basePath + @"\" + mi.Attachments[i].FileName);
}
else
{
Console.WriteLine("Already saved " + mi.Attachments[i].FileName);
}
}
}
}
}
}
catch (Exception e)
{
}
}
}
static string EnumerateAccountEmailAddress(Outlook.Account account)
{
try
{
if (string.IsNullOrEmpty(account.SmtpAddress) || string.IsNullOrEmpty(account.UserName))
{
Outlook.AddressEntry oAE = account.CurrentUser.AddressEntry as Outlook.AddressEntry;
if (oAE.Type == "EX")
{
Outlook.ExchangeUser oEU = oAE.GetExchangeUser() as Outlook.ExchangeUser;
return oEU.PrimarySmtpAddress;
}
else
{
return oAE.Address;
}
}
else
{
return account.SmtpAddress;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return "";
}
}
static void EnumerateAccounts()
{
Console.Clear();
Console.WriteLine("Outlook XLS Extractor");
Console.WriteLine("---------------------------------");
int id;
Outlook.Application Application = new Outlook.Application();
Outlook.Accounts accounts = Application.Session.Accounts;
string response = "";
while (true == true)
{
id = 1;
foreach (Outlook.Account account in accounts)
{
Console.WriteLine(id + ":" + EnumerateAccountEmailAddress(account));
id++;
}
Console.WriteLine("Q: Quit Application");
response = Console.ReadLine().ToUpper();
if (response == "Q")
{
Console.WriteLine("Quitting");
return;
}
if (response != "")
{
if (Int32.Parse(response.Trim()) >= 1 && Int32.Parse(response.Trim()) < id)
{
Console.WriteLine("Processing: " + accounts[Int32.Parse(response.Trim())].DisplayName);
Console.WriteLine("Processing: " + EnumerateAccountEmailAddress(accounts[Int32.Parse(response.Trim())]));
Outlook.Folder selectedFolder = Application.Session.DefaultStore.GetRootFolder() as Outlook.Folder;
selectedFolder = GetFolder(@"\\" + accounts[Int32.Parse(response.Trim())].DisplayName);
EnumerateFolders(selectedFolder);
Console.WriteLine("Finished Processing " + accounts[Int32.Parse(response.Trim())].DisplayName);
Console.WriteLine("");
}
else
{
Console.WriteLine("Invalid Account Selected");
}
}
}
}
static Outlook.Folder GetFolder(string folderPath)
{
Console.WriteLine("Looking for: " + folderPath);
Outlook.Folder folder;
string backslash = @"\";
try
{
if (folderPath.StartsWith(@"\\"))
{
folderPath = folderPath.Remove(0, 2);
}
String[] folders = folderPath.Split(backslash.ToCharArray());
Outlook.Application Application = new Outlook.Application();
folder = Application.Session.Folders[folders[0]] as Outlook.Folder;
if (folder != null)
{
for (int i = 1; i <= folders.GetUpperBound(0); i++)
{
Outlook.Folders subFolders = folder.Folders;
folder = subFolders[folders[i]] as Outlook.Folder;
if (folder == null)
{
return null;
}
}
}
return folder;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}
}
}
|
|
|
|
|
If you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I followed your advice, but assumed that anyone with experience with this subject may be able to shed some light. Wasn't really sure how likely I would be to get a response as the article was initially published in 2015.
|
|
|
|
|
That's only two years ago! We have active member that have been here 6 times that long - I've been here for over 7 years, and I'm still plugging away...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
see this class code
public class ShipperFactory
{
private static TShip Create<TShip>()
where TShip : IShip,
new()
{
return new TShip();
}
public static readonly IDictionary<Shipper, Func<IShip>> Creators =
new Dictionary<Shipper, Func<IShip>>()
{
{ Shipper.UPS, () => Create<ShipperUPS>() },
{ Shipper.FedEx, () => Create<ShipperFedEx>() },
{ Shipper.Purolator, () => Create<ShipperPurolator>() }
};
public static IShip CreateInstance(Shipper enumModuleName)
{
return Creators[enumModuleName]();
}
}
specially the below code is not clear where
public static readonly IDictionary<Shipper, Func<IShip>> Creators =
new Dictionary<Shipper, Func<IShip>>()
{
{ Shipper.UPS, () => Create<ShipperUPS>() },
{ Shipper.FedEx, () => Create<ShipperFedEx>() },
{ Shipper.Purolator, () => Create<ShipperPurolator>() }
};
1) see this line whose meaning is not clea. what is the meaning of Func<iship> ?
new Dictionary<shipper, func<iship="">>()
Dictionary usage is not clear. help me to understand the code of Dictionary and as well as ShipperFactory class.
it is required to use both interface and abstract class ? is it not redundant here ?
here giving the full code which show how i am using ShipperFactory class
calling like this way
--------------------------
private void btnUPS_Click(object sender, EventArgs e)
{
ShipperFactory.CreateInstance(Shipper.UPS).Ship();
}
private void btnFedEx_Click(object sender, EventArgs e)
{
ShipperFactory.CreateInstance(Shipper.FedEx).Ship();
}
private void btnPurolator_Click(object sender, EventArgs e)
{
ShipperFactory.CreateInstance(Shipper.Purolator).Ship();
}
public enum Shipper
{
UPS,
FedEx,
Purolator
}
public interface IShip
{
void Ship();
}
public abstract class ShipperBase : IShip
{
public abstract void Ship();
}
public class ShipperUPS : ShipperBase
{
public override void Ship()
{
MessageBox.Show("UPS ship start");
}
}
public class ShipperFedEx : ShipperBase
{
public override void Ship()
{
MessageBox.Show("FedEX ship start");
}
}
public class ShipperPurolator : ShipperBase
{
public override void Ship()
{
MessageBox.Show("Purolator ship start");
}
}
public class ShipperFactory
{
private static TShip Create<TShip>()
where TShip : IShip,
new()
{
return new TShip();
}
public static readonly IDictionary<Shipper, Func<IShip>> Creators =
new Dictionary<Shipper, Func<IShip>>()
{
{ Shipper.UPS, () => Create<ShipperUPS>() },
{ Shipper.FedEx, () => Create<ShipperFedEx>() },
{ Shipper.Purolator, () => Create<ShipperPurolator>() }
};
public static IShip CreateInstance(Shipper enumModuleName)
{
return Creators[enumModuleName]();
}
}
looking for help. thanks
tbhattacharjee
|
|
|
|
|
The dictionary contains a "key" for each carrier and a "function" (value) that is used to create an instance of that carrier.
Over-engineered and pointless indirection (IMO).
(A "carrier" class and a "carrier id / ident" would be simpler).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
DNFTHV *
* Do not feed the Help Vampire
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It's actually passive aggression
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|