|
Fantastic that is exactly what the doctor ordered.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi Gurus, I'm using VS2005, In that I've the following WebService code
What I need is I want to write a log to a Textfile. Just give me a suggestion how to write a log entry on the code as follows:
1) Class: ValidateImageAuthorization.cs
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
//using System.Web.Services.Configuration;
[WebService(Namespace = "http://webservice.imaging.yellowbook.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//added for testing
//[WebMethod(1,Random,10,10)]
public class ValidateImageAuthorization : System.Web.Services.WebService
{
public ValidateImageAuthorization()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
#region User accessable function
// Gets user info(userid,roles,displayname,application type)
// Returns session unique identifier to requested user
[WebMethod(EnableSession = true)]
public Response CreateAuthorization(Request UserInfo)
{
string _SessionIdentifier;
string _DbReturnMessage;
Response objReturn = new Response();
try
{
// create new session identifier
_SessionIdentifier = Guid.NewGuid().ToString();
// Submits data (user id,unique session id,roles info,Display Name) into imaging database
_DbReturnMessage = IsUserInfoAddedIntoDB(UserInfo,_SessionIdentifier);
// Check user info successfully submitted to imaging database or not
if (_DbReturnMessage == "Success")
{
//In case of successful database submission, returns unique session id with return code(0).
objReturn.SessionIdentifier = _SessionIdentifier;
objReturn.Message = "Success";
objReturn.Returncode = 0;
}
else
{
//any issue with database updation, returns blank session identifier with appropriate return code(-1) & appropriate error message
objReturn.SessionIdentifier = "";
objReturn.Message = _DbReturnMessage;
objReturn.Returncode = -1;
}
return objReturn;
}
catch (Exception ex)
{
// returns error message to the user while facing any issue with Web Service itself
objReturn.SessionIdentifier = "";
objReturn.Message = ex.Message;
objReturn.Returncode = -1;
return objReturn;
}
}
#endregion
#region function to submits user information into YB imaging database
// Gets session unique identifier,userid,roles and display name as input parameters
public string IsUserInfoAddedIntoDB(Request UserInfo, string SessionID)
{
string IsDataValid;
int CCRole = 0, SSNRole = 0;
SqlCommand cmd = null;
SqlConnection connection = null;
SqlDataReader reader = null;
//Check whether input parameters for database updation is valid or not
IsDataValid=IsInputDataValid(UserInfo);
//In case of all invalid input parameters, returns appropriate error message.
if (IsDataValid != "InputDataValid") return IsDataValid;
//Code commented for updating DB(i.e UniqueSessionID table) for SSN & CC information
////In case of all valid input parameters
////filter Roles fields and search for ImageCC & ImageSSN roles info out of that.
//for (int i = 0; i < UserInfo.Roles.Length; i++)
//{
// //setting CCRole=1 if user has got access to view Credit card information out of contract images
// if (UserInfo.Roles[i].ToLower() == "imagecc")
// {
// CCRole = 1;
// SSNRole = 0;
// i = UserInfo.Roles.Length - 1;
// }
// //setting SSNRole=1 if user has got access to view SSN information out of contract images
// else if (UserInfo.Roles[i].ToLower() == "imagessn")
// {
// CCRole = 0;
// SSNRole = 1;
// i = UserInfo.Roles.Length - 1;
// }
// //setting CCRole=0 and SSNRole = 0, if user has got access to view SSN information out of contract images
// else
// {
// CCRole = 0;
// SSNRole = 0;
// }
//}
//Comment Ends
//Code Added by Prasanna on 1-Aug-2007 for updating DB(i.e UniqueSessionID)for SSN & CC information
//Code Starts
//In case of all valid input parameters
//filter Roles fields and search for ImageCC & ImageSSN roles info out of that.
object objcc = "imagecc";
object objssn = "imagessn";
// converting all elements to lower case
for (int i = 0; i < UserInfo.Roles.Length; i++)
{
UserInfo.Roles[i] = UserInfo.Roles[i].ToLower().Trim();
}
// Sorting all elements of Roles Array
Array.Sort(UserInfo.Roles);
// Searching for imagecc and imagessn in Roles array.(If array has both elements)
//ImageCC, ImageSSN
if (Array.BinarySearch(UserInfo.Roles, objcc) > -1 && Array.BinarySearch(UserInfo.Roles, objssn) > -1)
{
CCRole = 1; SSNRole = 1;
}
else
{
//Searching for imagecc in Roles array.
//If array has imagecc and other elements and not imagessn
if (Array.BinarySearch(UserInfo.Roles, objcc) > -1)
{
CCRole = 1; SSNRole = 0;
}
//Searching for imagessn in Roles array.
//If array has imagessn and other elements and not imagecc
else if (Array.BinarySearch(UserInfo.Roles, objssn) > -1)
{
CCRole = 0; SSNRole = 1;
}
//If array has other than imagecc and imagessn elements
else
{
CCRole = 0; SSNRole = 0;
}
}
//Code Ends
//gets Stored procedure name from Web.Config file
string cmdString = ConfigurationManager.AppSettings["SPDetails"];
//gets SQL Connection string from Web.Config file
string connectionInfo = ConfigurationManager.AppSettings["DbConstr"];
connection = new SqlConnection(connectionInfo);
try
{
connection.Open();
cmd = new SqlCommand(cmdString, connection);
cmd.CommandType = CommandType.StoredProcedure;
//passing i/p parameters to Stored procedure for database submission
cmd.Parameters.Add("@USID", SqlDbType.VarChar).Value = SessionID;
cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = UserInfo.UserId;
cmd.Parameters.Add("@DISPLAYNAME", SqlDbType.NVarChar).Value = UserInfo.DisplayName;
cmd.Parameters.Add("@SSROLE", SqlDbType.Bit).Value = SSNRole;
cmd.Parameters.Add("@CCROLE", SqlDbType.Bit).Value = CCRole;
reader = cmd.ExecuteReader();
reader.Read();
//check whether stored procedure face any issue while inserting/updating data to imaging database
//Returns Errorcode=-1 in case of issues else returns 0
if (reader["ERRORCODE"].ToString() == "-1")
{
return reader["MESSAGE"].ToString();
}
else
{
return "Success";
}
}
catch (Exception e)
{
return e.Message;
}
finally
{
//Close the database connection
if (connection != null)
{
connection.Close();
}
//close the reader
if (reader != null)
{
reader.Close();
}
}
}
//Function validates input parameters for database submission
private string IsInputDataValid(Request UserInfo)
{
//check if Web service is not supplied any input parameters
if (
UserInfo.Roles.Length == 0 &&
UserInfo.UserId.Length == 0 &&
UserInfo.DisplayName.Length == 0 &&
UserInfo.ApplicationType.Length == 0
)
{
//return error message
return "Web Service is not supplied with any single input parameters";
}
//check length of Userid whether valid or not
if (UserInfo.UserId.Trim().Length == 0)
{
return "Input Parameter - Invalid UserID";
}
//check length of Display name whether valid or not
if (UserInfo.DisplayName.Trim().Length == 0)
{
return "Input Parameter - Invalid Display Name";
}
//check length of Roles info whether valid or not
if (UserInfo.Roles.Length == 0)
{
return "Input Parameter- Invalid Roles info";
}
else
{
//Check whether Array has not got string with space value
bool HasValue = false;
for (int counter = 0; counter < UserInfo.Roles.Length; counter++)
{
if (UserInfo.Roles[counter].Trim().Length != 0)
{
HasValue = true;
counter = UserInfo.Roles.Length - 1;
}
}
if (HasValue == false) return "Input Parameter - Roles must have least one value";
}
//check length of Application Type whether valid or not
if (UserInfo.ApplicationType.Trim().Length == 0)
{
return "Input Parameter - Invalid Application Type";
}
return "InputDataValid";
}
#endregion
#region web service input and output information structure
public class Request
{
public string UserId;
public string[] Roles;
public string DisplayName;
public string ApplicationType;
}
public class Response
{
public string SessionIdentifier;
public string Message;
public int Returncode;
}
#endregion
}
2) ASMX : ValidateImageAuthorization.asmx
]]>;
Raaj
|
|
|
|
|
Hey
There many way write log file.
So You must decide what i want to include within log file, then select a way.and write log file.
1.must use simple object
2.u must close file or stream immediately when u written
3.don't put garbage within log file
4.use the simple phrases.
that's all.
|
|
|
|
|
buddy,
try log4net.
******************************
I just want to
know everything
|
|
|
|
|
|
I'm hoping there's a more streamlined approach to this. In a form, I have 7 textboxes and a button. When the button is clicked, each textbox needs to be looked at to ensure it contains something. If the textbox is blank, I have a label on the forum to alert the user of such. Then I direct focus to the blank textbox. So far I've been doing it like this:
if (txt1.text == "")<br />
{<br />
ErrorLabel.text = "Enter something in txt1";<br />
txt1.focus();<br />
}<br />
else if (txt2.text == "")<br />
{<br />
ErrorLabel.text = "Enter something in txt2";<br />
txt2.focus();<br />
}<br />
else if (txt3.text == "")<br />
{<br />
ErrorLabel.text = "Enter something in txt3";<br />
txt3.focus();<br />
}<br />
else if (... and so on, and so on for all 7 textboxes)
Is there a way to do it with less code?
|
|
|
|
|
Realistically you should create a class that implements the data that you want, and then put a binding against the textbox. With a bit of the magic listed here[^] you can save yourself a lot of work keeping validation and items in sync.
|
|
|
|
|
Pete O'Hanlon wrote: With a bit of the magic listed here[^] you can save yourself a lot of work keeping validation and items in sync.
That's a great article. Do you know any similar approach available for web application ?
|
|
|
|
|
You could adapt it using techniques described in this[^] article.
|
|
|
|
|
if you don't want to go with databinding which is a good option, you can combine all the if statements:
if(txt1.Text=="" OR txt2.text=="" OR txt3.text="" OR ...)
{
ErrorLabel.text="All fields must be entered to continue";
}
Their still may be better options though.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Why dont you just use required field validators?
|
|
|
|
|
*Clicks the Back Button2*
"Please fill in all the fields to continue" >
The reason I've stopped using RequiredFieldValidators....
|
|
|
|
|
How about this:
<br />
<br />
foreach (var tb in new TextBox[] { txt1, txt2, txt3, txt4, txt5, txt6, txt7 }) {<br />
if (tb.Text == "") {<br />
ErrorLabel.text = string.format("Enter something in {0}", tb.Name);<br />
tb.Focus();<br />
break;<br />
}<br />
}<br />
<br />
It aint pretty, and I'd prefer data binding, but it'd work?
|
|
|
|
|
If you set required field validators when tabbing to each textbox it instantly does validation i dont see the issue perhaps ive misinterperted your query
A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty I am a Optimist
|
|
|
|
|
That's what I would do too... so it must be wrong somehow.
|
|
|
|
|
I'll give this a shot .. looks interesting
I'd do databinding, but not sure how. I'm still new at this. If I created the DB within Visual Studio I'd be able to do it, but it's created at runtime (SQL CE)
EDIT: I just tried it, and it worked great. Thanks!!!
modified on Friday, April 4, 2008 1:36 PM
|
|
|
|
|
Or set the Button's Enabled property
btn.Enabled = ( txt1.Text.Length > 0 ) && ... ;
|
|
|
|
|
i know this is quite the inapropriate place to ask but i am not getting any answers from the truevision site concerning the 6.5 and it's mousepick train of code. i tried it but the mouse keeps on picking the wall behind the meshes i had set to rotate.
what i am trying to say is i set a wall and three meshes before it to rotate that way if you click on one of the meshes an event will occur but the event keeps on happening to the wall instead. what should i do?
help please
|
|
|
|
|
anarchi23 wrote: what should i do?
sounds like A) you have not bitmasked your picking objects B) you have not cleared your events so they stay on the event stack C) you are unfamiliar with the environment and the confusion runs deeper D) you are unfamiliar with the language and the confusion runs even deeper still.
If you are not getting answers at the truevision forums, the answer may be at the core language, C#. Since I see you recently joined only to cross post, you aren't likely to get many answers, but you might if you phrased it better.
The process you are describing is a 3D problem, but the code that it is uses is obvious a language issue. Not understanding either means you aren't likely to even know which problem is which or where it should be. That is bad news. Brush up on your C# related to the activities being used to narrow this down to a 3D issue not a language use issue. Once you have that down, someone, though there are few of us here, may be able to help. There are very few 3D graphics programmers here and fewer still in C#.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hello everybody
I have created a table in a data base and I want to use a DataSet to insert in this table while using the TableAdapter.
Normally that this fact grace has the method Insert but that doesn't work. The primary key of the table increments itself automatically.
And when I execute the request to the level of the DataSet that walks very well. You have some ideas.
Thank you for advance
|
|
|
|
|
hi
i have asked this question before as i dint got any answer i am repostingwu it with a clear format
i have a tree view in my form
i want to get the key value of the node
e.node.name returns the key value but it appears under few events
i want to get the key value any where in the form where i need it
please please do reply
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
simple...
TV.Nodes[XX].Name
XX is index
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
it will return the name not the key value or key string
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
key??? what do you mean by key
you can use Text property for value...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
ALT + F4 wrote: hi
i have asked this question before as i dint got any answer i am repostingwu it with a clear format
Well. Aren't you the little liar? You posted this a few posts below and you did get an answer - just because it wasn't exactly right, you shouldn't post porkies here - you will be found out. It's polite to continue on the original thread, and not to cross or multiple post.
|
|
|
|