I am trying to send an email to a supervisor when a work order is created
if(TextBox9.Text=="Quality"&&affectedrows==true)
{
boolisLocal=HttpContext.Current.Request.IsLocal;
if(isLocal==true)
{
System.Net.Mail.MailMessagenn=newSystem.Net.Mail.MailMessage();
nn.From=newSystem.Net.Mail.MailAddress("no_reply_workorder#mover.com");//whosend
nn.To.Add(newSystem.Net.Mail.MailAddress("someone.something#mover.com"));
nn.Subject="WorkOrdersTypeQuality";
HttpFileCollectionuploadFiles=Request.Files;
for(inti=0;i<uploadFiles.Count;i++)
{
HttpPostedFileuserpostedfils=uploadFiles[i];
try
{
if(userpostedfils.ContentLength>0)
{
nn.Attachments.Add(newAttachment(userpostedfils.InputStream,Path.GetFileName(userpostedfils.FileName)));
}
}
catch
{
Labelstatusmessage=(Label)DetailsView1.FindControl("lblmessage");
statusmessage.Text="UploadFailedPleaseContactDeveloper";
}
}
nn.Body="DONOTREPLYTOTHISEMAIL"+"<br><br/>"+"WorkOrderNumber"+": "+
""+TextBox13.Text+""+"<-ClickontheWorkOrderNumberForReport"+"<br><br/>"+"WorkOrderNumber"+
": "+""+TextBox13.Text+""+"<-ClickontheWorkOrderNumberToEnterData"+"<br><br/>"+"Requestor"+
": "+TextBoxRequestor.Text+"<br><br/>"+"Date"+": "+
TextBoxDate.Text+"<br><br/>"+"Department"+": "+
TextBox14.Text+"<br><br/>"+"CompletionDate"+": "+
TextBoxCompletionDate.Text+"<br><br/>"+"MachineDescription"+
": "+TextBoxMachineDescription.Text+"<br><br/>"+
"MachineLocation"+": "+TextBoxMachineLocation.Text+
"<br><br/>"+"WorkRequired"+": "+TextBoxWorkRequired.Text+
"<br><br/>"+"Status"+": "+TextBoxStatus.Text;
nn.IsBodyHtml=true;
System.Net.Mail.SmtpClientclient=newSystem.Net.Mail.SmtpClient();
client.Host=ConfigurationManager.AppSettings["smtpServer"];
captureuseremail();
}
}
in the body of the mail I am sending an link to the workorder that just got created, "http://server01/WorkOrder/QualityReport.aspx?WorkOrderNum="TextBox13.Text+"\">" I am working on four different plants so I need to deploy each project to 4 servers and change the link above to server02, server03, and server04 and there are 3 types of workorders so I was thinking of storing each link into a key in web.config:
<add key ="safetylink" value="http://server01/WorkOrderTool/SafetyReport.aspx?WorkOrderNum="/>
Get the value from web.config and store as string and use it in the email I am not sure how to do that:
string safetylink = ConfigurationManager.AppSettings["safetylink"];
mm.Body = "DO NOT REPLY TO THIS EMAIL" + "<br><br/>" + "WorkOrderNumber" + ": " + "<a href=\"safetylink" + TextBox13.Text + "\">"
but that does not work, by doing the above I hope to simple deploy one web application to 4 servers and go into each ones web.config and change the name of the server instead of find and replace.
Thank You in advance coders
thanks to SamIam anytime you want to sent a string as a hyperlink in the body of an email:
use "<a href=\"" + yourstringname"
How to get the linkToTwitter to listen to other account (for example #Bloomberg)?
I've managed to build the full example of listen to twitter, populated the "ScreenName" with #Bloomberg, but for some reason it "listen" only to my account (and react to tweets there) - the account I've created the tokens with.
Is it possible to set a 3rd party twitter account (not me) to listen to (in streaming mode)? an d if not is there other framework you have experience with that does that?
Try including the screenName in the linq query:
var statusTweets = (from strm in twitterContext.Streaming
where strm.Type == StreamingType.User
&& strm.ScreenName == "Bloomberg"
select strm)
.StartAsync(async strm =>
{
string message =
string.IsNullOrEmpty(strm.Content) ?
"Keep-Alive" : strm.Content;
Console.WriteLine(
(count + 1).ToString() +
". " + DateTime.Now +
": " + message + "\n");
});
I'm currently working on a small program that gets data from mongoDB and matches it with other data. My program is currently printing out the data, but it needs to add a <asp:button />with an unique ID to it so I can save the data for each product.
Here is my code:
public void showCoolers_Click(object sender, EventArgs e)
{
var items = "";
var connectionString = "mongodb://localhost:27017/";
var mongoClient = new MongoClient(connectionString);
MongoServer server = mongoClient.GetServer();
MongoDatabase database = server.GetDatabase("mydb");
MongoCollection<cpuCoolers> collection = database.GetCollection<cpuCoolers>("cpucoolers");
foreach (cpuCoolers parts in collection.FindAll())
{
String _id = parts._id.ToString();
items = items + "<tr><td>" + parts.Aanbieder + "</td><td> " + parts.Productnaam + "</td><td>" + parts.Socket + "</td><td> " + parts.Geluidsterkte + "</td><td> " + parts.Prijs +"</td><td><asp:Button ID='x' runat='server' Text='Motherboard' CssClass='btn btn-block btn-primary'/></td></tr>";
}
lblProducts.Text = "<table><thead><tr><th>Provider</th><th>Productname</th><th>Socket</th><th>Sound production</th><th>Price</th><th>Add to MyPc!</th></thead>" + items + "</table>";
}
I print my data via changing the content oflblProduct.Text in my aspx file. If I add a asp:button to this it doesn't show up, however a regular Html button does, why is that and is there a way to print out a asp:button's?
You can't render an asp.net button the way you are trying, you would need to use a regular html button as you found out.
The asp:button is something that asp.net interprets while it is building your page; by the time you _Click function is executed, its too late in the page lifecycle to render asp.net controls - so HTML buttons are your only option at that point in the page execution.
Here is an overview of the asp.net page life cycle that might help you understand it better:
http://msdn.microsoft.com/en-us/library/ms178472%28v=vs.100%29.aspx
Viewing the repository data of TortoiseSVN is done by right click on a file -> TortiseSVN -> Repo-Browser.
I would like to get this data using SharpSVN, in order to retrieve the name of lock owner.
Is it possible? How? Where does this data being saved?
I've tried to get a lock owner name using the following code, however, I get the lock infirmation just in case I'm on the machine where the lock was done from. If I'm another user, I cannot get the lock information.
using (SvnClient client = new SvnClient())
{
client.GetInfo(#"path\to\working\copy\file.xml", out info);
SvnLockInfo lc = info.Lock;
if (lc != null)
{
MessageBox.Show("Owner: " + lc.Owner + "\n" +
"Creation time: " + lc.CreationTime + "\n" +
"Comment: " + lc.Comment + "\n" +
"Expiration time: " + lc.ExpirationTime);
}
}
Even when I set the target as the repository URI- instead of path to the local working copy I get the same result:
Uri target = client.GetUriFromWorkingCopy(#"path\to\working\copy\file.xml");
client.GetInfo(target, out info);
The way I can see the lock owner name from another working copy is, as mentioned, by right click on file -> repo-browser.
Any ideas how to perform it programmatically?
We use ADP for employee information. I had to create a small app that called some web services that ADP has to pull employee information. The app is fairly procedural..not really object orientated in a sense. Basically I go through some web services to pull general information, work information, employee status, etc.
I have most of this data writing out to a text file as a log so I can ensure that everything is working correctly. Finally got it all done, and it works perfect on my local machine. Thought I'd just copy the entire structure onto a server and use windows scheduler to schedule the exe to run nightly (once a day). When it tries to run the app it looks like it is dying when it calls the first web service. The task scheduler log says:
""ADP.job" (ADP.exe)
Started 2/11/2010 2:14:34 PM
"ADP.job" (ADP.exe)
Finished 2/11/2010 2:14:38 PM
Result: The task completed with an exit code of (e0434f4d)."
So I checked the event viewer and it says this:
EventType clr20r3, P1 adp.exe, P2 1.0.0.0, P3 4b745bb9, P4 adp, P5 1.0.0.0, P6 4b745bb9, P7 289, P8 2d, P9 system.io.filenotfoundexception, P10 NIL.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
I put in some console.writelines to see where it is failing...
Here is a simple example of main:
static void Main(string[] args)
{
OpenTextFile();
Console.WriteLine("About to process employee work information...");
tw.WriteLine("About to process employee work information...");
//work info service
EmpWorkInfo();
}
And inside of opentextfile:
public static void OpenTextFile()
{
//used to log data
String sLogName;
Console.WriteLine("Inside of opentextfile");
if (Directory.Exists(logPath))
{
//directory exists
}
else
{
Directory.CreateDirectory(logPath);
}
Console.WriteLine("Inside of opentextfile2");
sLogName = "log_" + DateTime.Today.ToString("MM_dd_yyyy") + ".txt";
tw = new StreamWriter(logPath + sLogName);
}
I see all the console.writelines on the server but as soon as it hits this line from main:
EmpWorkInfo();
Thats when all hell breaks lose (basically it doesn't work). The EmpWorkInfo() is simply a function to get work related information from a web service (as I said this works locally).
static void EmpWorkInfo()
{
Console.Writeline("THIS NEVER PRINTS!!!");
SQLClass s=null;
// Create the web service proxy client.
GetEmployeeWorkInfoService oService = new GetEmployeeWorkInfoService();
oService.Timeout = Int32.MaxValue;
// Serialize the UsernameToken into XML.
// Create the UsernameToken as defined in the WS-I secure profile.
UsernameToken oUsernameToken = new UsernameToken(USERNAME, SECRET);
System.Xml.XmlElement oSecurityHeaderXml =
oUsernameToken.GetXml(new System.Xml.XmlDocument());
ADP.GetEmployeeWorkInfoWebService.SecurityHeaderType oSecurityHeader = new ADP.GetEmployeeWorkInfoWebService.SecurityHeaderType();
oSecurityHeader.Any = new System.Xml.XmlElement[] { oSecurityHeaderXml };
oService.Security = oSecurityHeader;
GetEmployeeWorkInfoRequestFilter oFilter = new GetEmployeeWorkInfoRequestFilter();
//filter by thyssenkrupp company
oFilter.Companies = new String[] { COMPANY_IDENTIFIER };
GetEmployeeWorkInfoRequest oRequest = new GetEmployeeWorkInfoRequest();
oRequest.Filter = oFilter;
try
{
EmployeeWorkInfoType[] arPersonalInfo = oService.GetEmployeeWorkInfo(oRequest);
try
{
s = new SQLClass();
}
catch (Exception e)
{
throw new System.Exception(e.Message.ToString());
}
for (int i = 0; i < arPersonalInfo.Length; i++)
{
String stID = arPersonalInfo[i].EmployeeKey.Identifier.EmployeeId; //employee number
String stEmailAddress = arPersonalInfo[i].WorkInfo.EmailAddress; //employee email address (work)
String stFax = arPersonalInfo[i].WorkInfo.Fax; //employee fax number
DateTime dtHireDate = arPersonalInfo[i].WorkInfo.OriginalHireDate;
String stPhone = arPersonalInfo[i].WorkInfo.Phone; //employee phone number
String stWireless = arPersonalInfo[i].WorkInfo.Wireless; //employee wireless number
tw.WriteLine("Processing ID:" + stID + " Email Work: " + stEmailAddress + " Fax Work: " + stFax + " Hire Date: " + dtHireDate + " Phone Work: " + stPhone + " Wireless Work: " + stWireless + ".");
Console.WriteLine("Processing ID:" + stID + " Email Work: " + stEmailAddress + " Fax Work: " + stFax + " Hire Date: " + dtHireDate + " Phone Work: " + stPhone + " Wireless Work: " + stWireless + ".");
s.SetSQLCommand("dbo.ADP_uiEmployeeWorkInfo");
s.AddSQLCmdParameter("#EmployeeNumber", System.Data.SqlDbType.VarChar, stID);
s.AddSQLCmdParameter("#EmailAddress", System.Data.SqlDbType.VarChar, stEmailAddress);
s.AddSQLCmdParameter("#Fax", System.Data.SqlDbType.VarChar, stFax);
s.AddSQLCmdParameter("#HireDate", System.Data.SqlDbType.DateTime, dtHireDate);
s.AddSQLCmdParameter("#Telephone", System.Data.SqlDbType.VarChar, stPhone);
s.AddSQLCmdParameter("#Mobile", System.Data.SqlDbType.VarChar, stWireless);
s.SQLExecuteNonQuery();
Console.WriteLine("Processed ID:" + stID + " Email Work: " + stEmailAddress + " Fax Work: " + stFax + " Hire Date: " + dtHireDate + " Phone Work: " + stPhone + " Wireless Work: " + stWireless + ".");
Console.WriteLine(Environment.NewLine);
}
s.CloseSQLDB();
s.Dispose();
}
//catch any exception from adp side.
catch (Exception e)
{
throw new System.Exception(e.Message.ToString());
}
}
This functions code is irrelevant (its ugly but do not let that bother you, the code works...). My issue is I cannot even get to the first console.writeline of that function. Is there anything special I need to do when it comes to working with webservices?
Edit
Logpath is defined as simply a static string outside of main:
private static string logPath = Environment.CurrentDirectory + "\\log\\";
I suspect that your application is not able to load the types referenced in that function - EmpWorkInfo.
1) Can you run this application on the target server in a commannd window (cmd.exe) ?
2) Are you using any assemblies from ADP that are installed in the global assembly cache (GAC)? Run "gacutil -l" on your localmachine to see if you are using any assemblies from ADP that are installed in thr gac. If they are, you will need to install these into the machine on which you are running the app.
Does logPath have a trailing backslash? Either way, you ought to use Path.Combine, rather than the string catenation operator (+).
What happens if you comment out all the code in EmpWorkInfo() apart from the first Console.Writeline? Does it still not get written out?
Found out I need the Microsoft.Web.Services3 dll installed on the server.
Continuation on "feroze" answer;
If you want to figure out if the 'loading of dependencies' is causing you grief here, i suggest using the "FUSLOGVW.EXE" tool *(part of .Net). When you run this it will give you a little dialog window with a few options. Create a directory somewhere (like "c:\temp\fusion_logs"), set the mode of FUSLOGVW to "log bind failures only", "custom location->c:\temp\fusion_logs".
Now restart your application and check that it failed. Now look into your fusion_logs directory. This should give you sub directories with different (maybe only 1 for now) application names. Inside each directory you will find the log files. These log files contain the "failed assembly loads" and who (which calling assembly) caused them.
They might help your hunt for a working application,
Hope this helps,
Edit: Posted this after you found the cause. The fuslogvw.exe would have shown you the missing assembly.