Search Results

Search found 21356 results on 855 pages for 'check digit'.

Page 47/855 | < Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >

  • How to check a bool setting in my iphone app

    - by dusk
    I have a setting in Root.plist with Key = 'latestNews' of type PSToggleSwitchSpecifier and DefaultValue as a boolean that is checked. If I understand that correctly, it should = YES when I pull it in to my code. I'm trying to check that value and set an int var to pass it to my php script. What is happening is that my boolean is either nil or NO and then my int var = 0. What am I doing wrong? int latestFlag; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; BOOL latestNews = [prefs boolForKey:@"latestNews"]; if (latestNews) latestFlag = 1; else latestFlag = 0; NSString *urlstr = [[NSString alloc] initWithFormat:@"http://www.mysite.com/folder/iphone-test.php?latest=%d", latestFlag]; NSURL *url = [[NSURL alloc] initWithString:urlstr]; //these are auto-released NSString *ans = [NSString stringWithContentsOfURL:url]; NSArray *listItems = [ans componentsSeparatedByString:@","]; self.listData = listItems; [urlstr release]; [url release];

    Read the article

  • How to check if an entityset is populated

    - by TheQ
    How can i check if an entityset of a linq-object is populated or not? Example code below. My model have two methods, one joins data, and the other does not: public static Member GetMemberWithSettings(Guid memberId) { using (DataContext db = new DataContext()) { DataLoadOptions dataLoadOptions = new DataLoadOptions(); dataLoadOptions.LoadWith<Member>(x => x.Settings); db.LoadOptions = dataLoadOptions; var query = from x in db.Members where x.MemberId == memberId select x; return query.FirstOrDefault(); } } public static Member GetMember(Guid memberId) { using (DataContext db = new DataContext()) { var query = from x in db.Members where x.MemberId == memberId select x; return query.FirstOrDefault(); } } Then my control have the following code: Member member1 = Member.GetMemberWithSettings(memberId); Member member2 = Member.GetMember(memberId); Debug.WriteLine(member1.Settings.Count); Debug.WriteLine(member2.Settings.Count); The last line will generate a "Cannot access a disposed object" exception. I know that i can get rid of that exception just by not disposing the datacontext, but then the last line will generate a new query to the database, and i don't want that. What i would like is something like: Debug.WriteLine((member1.Settings.IsPopulated()) ? member1.Settings.Count : -1); Debug.WriteLine((member2.Settings.IsPopulated()) ? member2.Settings.Count : -1); Is it possible?

    Read the article

  • Code refactoring c# question around several if statements performing the same check

    - by James Radford
    I have a method that has a load of if statements that seems a bit silly although I'm not sure how to improve the code. Here's an example. This logic was inside the view which is now in the controller which is far better but is there something I'm missing, maybe a design pattern that stops me having to check against panelCount < NumberOfPanelsToShow and handling the panelCount every condition? Maybe not, just feels ugly! Many thanks if (model.Train && panelCount < NumberOfPanelsToShow) { panelTypeList.Add(TheType.Train); panelCount++; } if (model.Car && panelCount < NumberOfPanelsToShow) { panelTypeList.Add(TheType.Car); panelCount++; } if (model.Hotel && panelCount < NumberOfPanelsToShow) { panelTypeList.Add(TheType.Hotel); panelCount++; } ...

    Read the article

  • Need a VB Script to check if service exist

    - by Shorabh Upadhyay
    I want to write a VBS script which will check if specific service is installed/exist or not locally. If it is not installed/exist, script will display message (any text) and disabled the network interface i.e. NIC. If service exist and running, NO Action. Just exit. If service exist but not running, same action, script will display message (any text) and disabled the network interface i.e. NIC. i have below given code which is displaying a message in case one service is stop but it is not - Checking if service exist or not Disabling the NIC strComputer = "." Set objWMIService = Getobject("winmgmts:"_ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colRunningServices = onjWMIService.ExecQuery _ ("select State from Win32_Service where Name = 'dhcp'") For Each objService in colRunningServices If objService.State <> "Running" Then errReturn = msgbox ("Stopped") End If Next Please help. Thanks in advance.

    Read the article

  • How to check Internet status in iPhone

    - by Radix
    Hello; I wanted to check whether internet is connected or not using either the SystemConfiguration or the CFNetwork i am not quite sure which one. Then i want to know that if the internet is connected then is it connected through wifi or not. I tried an example where i used the below code -(IBAction) shownetworkStatus { NSURL *url = [NSURL URLWithString:@"www.google.com"]; if (url!=NULL) { lbl.text = @"Connected"; } else { lbl.text = @"notConnected"; } } some say that its not valid as per apple and you have to use the SystemConfiguration Framework, Please let me know what needs to be done. Also i personally think that what i am doing in the above code is not proper as if one day google may also be down due to maintenance or some other factors. Also if you could provide me a link where i could display the name of the WIFI network then it would be really cool. I searched the internet then i got these Reachability.h code which again is a bouncer as i wana learn the concepts not copy paste them Thanks and Regards Radix

    Read the article

  • How to check user input for correct formatting

    - by Arcadian
    This is what i've come up with so far private void CheckFormatting() { StringReader objReaderf = new StringReader(txtInput.Text); List<String> formatTextList = new List<String>(); do { formatTextList.Add(objReaderf.ReadLine()); } while (objReaderf.Peek() != -1); objReaderf.Close(); for (int i = 0; i < formatTextList.Count; i++) { } } What it is designed to do is check that the user has entered their information in this format Gxx:xx:xx:xx JGxx where "x" can be any integer. As you can see the user inputs their data into a multi-line textbox. i then take that data and enter it into a list. the next part is where i'm stuck. i create a for loop to go through the list line by line, but i guess i will also need to go through each line character by character. How do i do this? or is there a faster way of doing it? thanks in advance

    Read the article

  • How to check if a child-object is populated

    - by TheQ
    How can i check if a child-object of a linq-object is populated or not? Example code below. My model have two methods, one joins data, and the other does not: public static Member GetMemberWithPhoto(Guid memberId) { using (DataContext db = new DataContext()) { DataLoadOptions dataLoadOptions = new DataLoadOptions(); dataLoadOptions.LoadWith<Member>(x => x.UserPhoto); db.LoadOptions = dataLoadOptions; var query = from x in db.Members where x.MemberId == memberId select x; return query.FirstOrDefault(); } } public static Member GetMember(Guid memberId) { using (DataContext db = new DataContext()) { var query = from x in db.Members where x.MemberId == memberId select x; return query.FirstOrDefault(); } } Then my control have the following code: Member member1 = Member.GetMemberWithPhoto(memberId); Member member2 = Member.GetMember(memberId); Debug.WriteLine(member1.UserPhoto.ToString()); Debug.WriteLine(member2.UserPhoto.ToString()); The last line will generate a "Cannot access a disposed object" exception. I know that i can get rid of that exception just by not disposing the datacontext, but then the last line will generate a new query to the database, and i don't want that. What i would like is something like: Debug.WriteLine((member1.UserPhoto.IsPopulated()) ? member1.UserPhoto.ToString() : "none"); Debug.WriteLine((member2.UserPhoto.IsPopulated()) ? member2.UserPhoto.ToString() : "none"); Is it possible?

    Read the article

  • check array against each other, to determine response

    - by Johnny
    So, I have an array that has 6 variables in it that I need to check against each other.. to determine what to return to the script calling the function.. All fields are of the datetime type from the database they are derived from. the fields: in1 out1 in2 out2 in3 out3 Array: Array( 'in1' => '2012-04-02 10:00:00), `out1` => '2012-04-02 14:00:00`, `in2` => '2012-04-02 14:30:00`, `out2` => '2012-04-02 18:00:00`, `in3` => NULL, `out3` => NULL ) the response: clocked_in or clocked_out What I need to figure out is, the best way to determine if the user is clocked in or clocked out by checking against this array.. so, if in1, out1 and in2 are not NULL then the user would be clocked in.. if in1 is not NULL but out1 is NULL then the user would be clocked out, etc.. Anyone have any ideas on the easiest way to achieve this without too many if statements? [WHAT WORKED] for ($i=1; $i <= 3; $i++) { if ($entities["in$i"] != NULL) { $ents = "clocked_in"; if ($entities["out$i"] != NULL) { $ents = "clocked_out"; } if ($entities["out3"] != NULL) { $ents = "day_done"; } } }

    Read the article

  • xslt check for alpha numeric character

    - by Newcoma
    I want to check if a string contains only alphanumeric characters OR '.' This is my code. But it only works if $value matches $allowed-characters exactly. I use xslt 1.0. <xsl:template name="GetLastSegment"> <xsl:param name="value" /> <xsl:param name="separator" select="'.'" /> <xsl:variable name="allowed-characters">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.</xsl:variable> <xsl:choose> <xsl:when test="contains($value, $allowed-characters)"> <xsl:call-template name="GetLastSegment"> <xsl:with-param name="value" select="substring-after($value, $separator)" /> <xsl:with-param name="separator" select="$separator" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$value" /> </xsl:otherwise> </xsl:choose> </xsl:template>

    Read the article

  • How to check the correct radio button.

    - by MrW
    I have a Table containing some information that I need. All these rows also contains a column with a radio button in it so that the user is suppose to be able to check one of the rows as default. When I'm bringing the data back from the DB and want to select the one that's currentlly the default one. <% foreach (var item in (IEnumerable<Locale>) ViewData["Locales"]) { %> <tr> <td> <%= Html.Encode(item.Language.Name) %> </td> <td> <input type="radio" id="defaultLocale" name="defaultLocele" value="on" checked="<%= item.Default == false ? "false" : "true" %>" /> </td> I've also tried to do this: <input type="radio" id="defaultLocale" name="defaultLocele" value="on" checked="<%=item.Default == false ? "" : "checked" %>" /> but nothing seems to do the right thing. I always end up with having the last row in checked, which it isn't for sure.

    Read the article

  • Doing a virus check on a file from a build script

    - by the_mandrill
    I would like to be be able to invoke a virus check as the final stage of the build process (please don't question why a dev machine would get a virus, it's just a belt-and-braces approach to avoid the risk of getting sued by customers...). Also I'd like the option of having AV on a machine but switching the auto file system protection off (at least for the build directories). What I would like is a generic way of scanning a file using whatever AV system is in place. I'm assuming that there's an Windows API to do this, given that Windows detects the presence of an AV system, and browsers such as Firefox invoke a virus scan whenever a file is downloaded. So what's the API that they're using? There's the Microsoft AntiVirus API but that seems to be specific to Office documents. Does the approach involve using WMI? (and if you can detect the AV provider from there, how do you then invoke it to scan a file?) I know that I could write the script to manually call the AV scanner that I know to be installed, but as an intellectual exercise I'm more interested to know how apps like Firefox are doing this.

    Read the article

  • PHP: Check if 0?

    - by tarnfeld
    Hi, I am using a class which returns me the value of a particular row and cell of an excel spreadsheet. To build up an array of one column I am counting the rows and then looping through that number with a for() loop and then using the $array[] = $value to set the incrementing array object's value. This works great if none of the values in a cell are 0. The class returns me a number 0 so it's nothing to do with the class, I think it's the way I am looping through the rows and then assigning them to the array... I want to carry through the 0 value because I am creating graphs with the data afterwards, here is the code I have. // Get Rainfall $rainfall = array(); for($i=1;$i<=$count;$i++) { if($data->val($i,2) != 'Rainfall') // Check if not the column title { $rainfall[] = $data->val($i,2); } } For your info $data is the excel spreadsheet object and the method $data->val(row,col) is what returns me the value. In this case I am getting data from column 2. Screenshot of spreadsheet http://cl.ly/1Dmy Thanks! All help is very much appreciated!

    Read the article

  • Check if NSString exists in custom object in NSArray

    - by Paul Peelen
    I have an NSArray with Store objects. Each Store object has two NSString objects; StoreID and Name. I would like to check quickly if an ID exists in this NSArray with Store objects. Example: Store *s1 = [[Store alloc] init]; s1.name = @"Some Name"; s1.id = @"123ABC"; Store *s2 = [[Store alloc] init]; s2.name = @"Some Other Name"; s2.id = @"ABC123"; NSArray *array = [[NSArray alloc] initWithObjects:s1, s2, nil]; NSString *myIdOne = @"ABCDEF"; NSString *myIdTwo = @"123ABC"; BOOL myIdOneExists = ...? BOOL myIdTwoExists = ...? Its the ...? I need to figure out. I know I can do this using a for loop and break when found... but this seems to me like an nasty approach since the NSArray could contain thousands of objects,... theoretically. So I would like to know about a better solution.

    Read the article

  • How to check Isavailablity in ajax?

    - by udaya
    Hi This is what i have in my view page <td width=""><input type="text" name="txtUserName" id="txtUserName" /></td> <td><input type="button" name="CheckUsername" id="CheckUsername" value="Check Availablity" onclick="Check_User_Name();"/></td> Onclick of the button the Check_User_Name function in my ajax.js loads This is the Check_User_Name function function Check_User_Name(source) { var UserName = document.getElementById('txtUserName').value; if(window.ActiveXObject) User_Name = new ActiveXObject("Microsoft.XMLHTTP"); else if(window.XMLHttpRequest) User_Name = new XMLHttpRequest(); var URL = newURL+"ssit/system/application/views/ssitAjax.php"; URL = URL +"?CheckUsername="+UserName; User_Name.onreadystatechange = User_Name_Fun; User_Name.open("GET",URL,true); User_Name.send(null); } function User_Name_Fun() { document.getElementById('User_div').innerHTML=User_Name.responseText; } Then I can have the value in echo username then the $result has all the user name Hows can i checkIsavailablity of username from here if(($_GET['CheckUsername']!="") || (isset($_GET['CheckUsername']))) { echo $UserName = $_GET['CheckUsername'];//echo username $_SESSION['state'] = $State; $queryres = "SELECT dUser_name FROM tbl_login WHERE dIsDelete='0'"; $result = mysql_query($queryres,$cn) or die("Selection Query Failed !!!");

    Read the article

  • Sanity check on this idea for an Image Viewer in a web app

    - by Charlie Flowers
    I have an approach in mind for an image viewer in a web app, and want to get a sanity check and any thoughts you stackoverflowers might have. Here's the whirlwind nutshell summary: I'm working on an ASP.NET MVC application that will run in my company's retail stores. Even though it is a web application, we own the store machines and have control over them. We have a "windows agent" running on the store machine which we can talk to via http post (it is a WCF service, and our web app has permission to talk to it from the browser). One of the web pages needs to be an "image viewer" page with some common things like Rotate & Zoom. Now, there are some WebForms controls that offer Rotate and Zoom. However, they take up server resources and generate a good bit of traffic between the server and the browser. For example, the Rotate function would cause an ajax call to the server, which would then generate a new image written to a .NET Canvas object, which would then be written to a file on the server, which would then be returned from the ajax call and refreshed inside the browser. Normally, that's a pretty good way of doing things. But in our case, we have code running on the store machine that we can communicate with. This leads me to consider the following approach: When the user asks to view an image, we tell our "windows agent" to download it from our image server to the store machine. We then redirect our browser to our image viewer page, which will pull the image from the local file we just wrote to the store machine. When the user clicks "Rotate", we cause JavaScript code in the browser to call our "windows agent" software, asking it to perform the "Rotate" function. The "windows agent" does the rotation using the same kind of imaging control that would formerly have been used on the server, but it does so now on the store machine. Javascript in the browser then refreshes the image on the page to show the newly rotated image. Zoom and similar features would be implemented the same way. This seems to be much more efficient, scalable, and responsive for the end-users. However, I've never heard of anything like it being done, mostly because it's rare to have this combination of a web app plus a "windows agent" on the client machine. What do you think? Feasible? Reasonable? Any pitfalls I overlooked or improvements / suggestions you can see? Has anyone done anything like this who would like to offer the wisdom of experience? Thanks!

    Read the article

  • check only one checkbox in gridview using jquery

    - by Gurbax Singh Bhangal
    i have a grid view in which i have placed the checkbox in itemtemplate i want only the one checkbox is selected from Gridview to select that perticular row so that i can use that id to edit or delete the row aspx page code is <asp:TemplateField Visible="false"> <ItemTemplate> <asp:Label ID="lblId" runat="server" Text='<%#Eval("id") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Select </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="chkSelect" runat="server"/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Branch Name </HeaderTemplate> <ItemTemplate> <asp:Label ID="lblBranch_Name" runat="server" Text='<%# Bind("Branch") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Address </HeaderTemplate> <ItemTemplate> <asp:Label ID="lblAddress" runat="server" Text='<%# Eval("Address") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> City </HeaderTemplate> <ItemTemplate> <asp:Label ID="lblCity" runat="server" Text='<%# Bind("City") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> and i want when i click on the checkbox which is at first of each row only one check box is selected from all the rows thanks

    Read the article

  • Excel string manipulation to check data consistency

    - by chefsmart
    Background information: - There are nearly 7000 individuals and there is data about their performances in one, two or three tests. Every individual has taken the 1st test (let's call it Test M). Some of those who have taken Test M have also taken Test I, and some of those who have taken Test I have also taken Test B. For the first two tests (M and I), students can score grades I, II, or III. Depending on the grades they are awarded points -- 3 for grade I, 2 for II, 1 for III. The last Test B is just a pass or a fail result with no grades. Those passing this test get 1 point, with no points for failure. (Well actually, grades are awarded, but all grades are given a common 1 point). An amateur has entered data to represent these students and their grades in an Excel file. Problem is, this person has done the worst thing possible - he has developed his own notation and entered all test information in a single cell --- and made my life hell. The file originally had two text columns, one for individual's id, and the second for test info, if one could call it that. It's horrible, I know, and I am suffering. In the image, if you see "M-II-2 I-III-1" it means the person got grade II in Test M for 2 points and grade III in Test I for 1 point. Some have taken only one test, some two, and some three. When the file came to me for processing and analyzing the performance of students, I sent it back with instructions to insert 3 additional columns with only the grades for the three tests. The file now looks as follows. Columns C and D represent grades I, II, and III using 1,2 and 3 respectively. Column C is for Test M, column D for Test I. Column E says BA (B Achieved!) if the individual has passed Test B. Now that you have the above information, let's get to the problem. I don't trust this and want to check whether data in column B matches with data in columns C,D and E. That is, I want to examine the string in column B and find out whether the figures in columns C,D and E are correct. All help is really appreciated. P.S. - I had exported this to MySQL via ODBC and that is why you are seeing those NULLs. I tried doing this in MySQL too, and really will accept a MySQL or an Excel solution, I don't have a preference. Edit : - See file with sample data

    Read the article

  • Jboss logging issue - pl check this

    - by balaji
    I’m Working as deployer and server administrator. We use Jboss 4.0x AS to deploy our applications. The issue I'm facing is, Whenever we redeploy/restart the server, server.log is getting created but after sometime the logging goes off. Yes it is not at all updating the server.log file. Due to this, we could not trace the other critical issues we have. Actually we have two separate nodes and we do deploy/restarting the server separately on two nodes. We are facing the issue in both of our test and production environment. I could not trace out where exactly the issue is. Could you please help me in resolving the issue? If we have any other issues, we can check the log files. If log itself is not getting updated/logged, how can we move further in analyzing the issues without the recent/updated logs? Below are the logs found in the stdout.log: 18:55:50,303 INFO [Server] Core system initialized 18:55:52,296 INFO [WebService] Using RMI server codebase: http://kl121tez.is.klmcorp.net:8083/ 18:55:52,313 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml 18:55:52,860 ERROR [STDERR] LOG0026E The Log Manager cannot create the object AmasRBPFTraceLogger without a class name. 18:55:52,860 ERROR [STDERR] LOG0026E The Log Manager cannot create the object AmasRBPFMessageLogger without a class name. 18:55:54,273 ERROR [STDERR] LOG0026E The Log Manager cannot create the object AmasCacheTraceLogger without a class name. 18:55:54,274 ERROR [STDERR] LOG0026E The Log Manager cannot create the object AmasCacheMessageLogger without a class name. 18:55:54,334 ERROR [STDERR] LOG0026E The Log Manager cannot create the object JACCTraceLogger without a class name. 18:55:54,334 ERROR [STDERR] LOG0026E The Log Manager cannot create the object JACCMessageLogger without a class name. 18:55:56,059 INFO [ServiceEndpointManager] WebServices: jbossws-1.0.3.SP1 (date=200609291417) 18:55:56,635 INFO [Embedded] Catalina naming disabled 18:55:56,671 INFO [ClusterRuleSetFactory] Unable to find a cluster rule set in the classpath. Will load the default rule set. 18:55:56,672 INFO [ClusterRuleSetFactory] Unable to find a cluster rule set in the classpath. Will load the default rule set. 18:55:56,843 INFO [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8180 18:55:56,844 INFO [Catalina] Initialization processed in 172 ms 18:55:56,844 INFO [StandardService] Starting service jboss.web Please help..

    Read the article

  • how to check if internal storage file has any data

    - by user3720291
    public class Save extends Activity { int levels = 2; int data_block = 1024; //char[] data = new char[] {'0', '0'}; String blankval = "0"; String targetval = "0"; String temp; String tempwrite; String string = "null"; TextView tex1; TextView tex2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.save); Intent intent = getIntent(); Bundle b = intent.getExtras(); tex1 = (TextView) findViewById(R.id.textView1); tex2 = (TextView) findViewById(R.id.textView2); if(b!=null) { string =(String) b.get("string"); } loadprev(); save(); } public void save() { if (string.equals("Blank")) blankval = "1"; if (string.equals("Target")) targetval = "1"; temp = blankval + targetval; try { FileOutputStream fos = openFileOutput("data.gds", MODE_PRIVATE); fos.write(temp.getBytes()); fos.close(); } catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} tex1.setText(blankval); tex2.setText(targetval); } public void loadprev() { String final_data = ""; try { FileInputStream fis = openFileInput("data.gds"); InputStreamReader isr = new InputStreamReader(fis); char[] data = new char[data_block]; int size; while((size = isr.read(data))>0) { String read_data = String.copyValueOf(data, 0, size); final_data += read_data; data = new char[data_block]; } } catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} char[] tempread = final_data.toCharArray();; blankval = "" + tempread[0]; targetval = "" + tempread[1]; } } After much tinkering i have finally managed to get my save/load function to work, but it does have an error, pretty much i got it to work then i did a fresh reintall deleting data.gds, afterwards the save/load function crashes because the data.gds file has no previous values. can i use a if statment to check if data.gds has any values in it, if so how do i do it and if not, then what could i use instead?

    Read the article

  • check if directory exists c#

    - by Ant
    I am trying to see if a directory exists based on an input field from the user. When the user types in the path, I want to check if the path actually exists. I have some c# code already. It returns 1 for any local path, but always returns 0 when I am checking a network path. static string checkValidPath(string path) { //Insert your code that runs under the security context of the authenticating user here. using (ImpersonateUser user = new ImpersonateUser(user, "", password)) { //DirectoryInfo d = new DirectoryInfo(quotelessPath); bool doesExist = Directory.Exists(path); //if (d.Exists) if(doesExist) { user.Dispose(); return "1"; } else { user.Dispose(); return "0"; } } } public class ImpersonateUser : IDisposable { [DllImport("advapi32.dll", SetLastError = true)] private static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken); [DllImport("kernel32", SetLastError = true)] private static extern bool CloseHandle(IntPtr hObject); private IntPtr userHandle = IntPtr.Zero; private WindowsImpersonationContext impersonationContext; public ImpersonateUser(string user, string domain, string password) { if (!string.IsNullOrEmpty(user)) { // Call LogonUser to get a token for the user bool loggedOn = LogonUser(user, domain, password, 9 /*(int)LogonType.LOGON32_LOGON_NEW_CREDENTIALS*/, 3 /*(int)LogonProvider.LOGON32_PROVIDER_WINNT50*/, out userHandle); if (!loggedOn) throw new Win32Exception(Marshal.GetLastWin32Error()); // Begin impersonating the user impersonationContext = WindowsIdentity.Impersonate(userHandle); } } public void Dispose() { if (userHandle != IntPtr.Zero) CloseHandle(userHandle); if (impersonationContext != null) impersonationContext.Undo(); } } Any help is appreciated. Thanks! EDIT 3: updated code to use BrokenGlass's impersonation functions. However, I need to initialize "password" to something... EDIT 2: I updated the code to try and use impersonation as suggested below. It still fails everytime. I assume I am using impersonation improperly... EDIT: As requested by ChrisF, here is the function that calls the checkValidPath function. Frontend aspx file... $.get('processor.ashx', { a: '7', path: x }, function(o) { alert(o); if (o=="0") { $("#outputPathDivValid").dialog({ title: 'Output Path is not valid! Please enter a path that exists!', width: 500, modal: true, resizable: false, buttons: { 'Close': function() { $(this).dialog('close'); } } }); } }); Backend ashx file... public void ProcessRequest (HttpContext context) { context.Response.Cache.SetExpires(DateTime.Now); string sSid = context.Request["sid"]; switch (context.Request["a"]) {//a bunch of case statements here... case "7": context.Response.Write(checkValidPath(context.Request["path"].ToString())); break;

    Read the article

  • How to check if a checkbox/ radio button is checked in php

    - by user225269
    I have this html code: <tr> <td><label><input type="text" name="id" class="DEPENDS ON info BEING student" id="example">ID</label></td> </tr> <tr> <td> <label> <input type="checkbox" name="yr" class="DEPENDS ON info BEING student"> Year</label> </td> </tr> But I don't have any idea on how do I check this checkboxes if they are checked using php, and then output the corresponding data based on the values that are checked. Please help, I'm thinking of something like this. But of course it won't work, because I don't know how to equate checkboxes in php if they are checked: <?php $con = mysql_connect("localhost","root","nitoryolai123$%^"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("school", $con); $id = mysql_real_escape_string($_POST['idnum']); if($_POST['id'] == checked & $_POST['yr'] ==checked ){ $result2 = mysql_query("SELECT * FROM student WHERE IDNO='$id'"); echo "<table border='1'> <tr> <th>IDNO</th> <th>YEAR</th> </tr>"; while($row = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td>" . $row['IDNO'] . "</td>"; echo "<td>" . $row['YEAR'] . "</td>"; echo "</tr>"; } echo "</table>"; } mysql_close($con); ?>

    Read the article

  • Check Avaibility of a page before loading using jquery/ajax

    - by overcomer
    Is it possible check the Accessibility of a page before loading it? I have a form, running on mobile device using wireless connection. The problem is: not always this connection is avaible and i would like to alert the user when is doing a submit or an unload of the page. The problem is that the page contains elements doing redirect like this: <input type="button" value="MyText" onClick="script1;script2;...window.location='mylocation" /> If the user click on this button and the server is not achievable, i will recive some undesiderable errors. Also if I want to generalize my script i do not know the value of "mylocation" previously. The page contains elements to submit the Form also: <input type="submit" name="SUBMIT" value="MyValue" onClick="return eval('validationForm()')" /> For the submitting I'm using the ajaxForm plugin and it works quite well. This is a snippet of code: Thanks to your answer I found the solution to the problem. That's the code: function checkConnection(u,s){ $.ajax({ url:u, cache:false, timeout:3000, error: function(jqXHR, textStatus) { alert("Request failed: " + textStatus ); }, success: function() { eval(s); } }); } $(document).ready(function() { // part of the function that checks buttons with redirect // for any input that contain a redirect on onClick attribute ("window.locarion=") $("input[type=button]").each(function(){ var script = $(this).attr("onClick"); var url = ""; var position = script.indexOf("window.location") ; if (position >= 0) { // case of redirect url = script.substring(position+17, script.lenght); url = url.split("\'")[0]; url = "\'"+url+"\'"; // that's my url script = "\""+script+"\""; // that's the complete script $(this).attr("onClick","checkConnection("+url+","+script+")"); } }); // part of the function that checks the submit buttons (using ajaxForm plugin) var is_error = false; var options = { error: function() { if (alert("Error Message")==true) { } is_error = true; }, target: window.document, replaceTarget: is_error, timeout: 3000 }; $("#myForm").ajaxForm(options); }); I hope that this will be usefull.

    Read the article

  • How to make in CLI check for updates to be happening every 4 weeks and install them automatically without going to Software sources?

    - by Kangarooo
    I have a set of custom commands I run on my computers after I install them. How do I make Ubuntu check for updates every 4 weeks and install them automatically on check? I would need this done via command line so I can set it up for usual users when I set up their computers. The first command will make the update manager check for updates every 2 weeks because they not always come so much and to save the bandwidth of the Ubuntu servers. I also need to set it so that users don't need to click to install updates since it's tiring every time I help a friend set up a computer.

    Read the article

  • Check Checkboxes dynamically

    - by Selom
    Hi, ive been dealing with this for some time now and need your help. well I have an array $arrayAmenities which contains a combination of the following data based on what is fetched from the database: Air Conditioned Bar Brunch Party Room Tea Room Terrace Valet I would like the application to dynamically check the following set of checkboxes based on the data contained in the array. With my code only one checkbox is checked based on the first data contained in the array. Can you please tell what Im missing? Thanks for answering. code: //get amenities one by one in order to set the checkboxes $arrayAmenities = explode(',', $rest_amenities ); $i=0; while(count($arrayAmenities) > $i) { var_dump($arrayAmenities[$i]); switch($arrayAmenities[$i]) { case 'Air Conditioned': $checkedAir = 'checked=true'; break; case 'Bar': $checkedBar = 'checked=true'; break; case 'Brunch': $checkedBru = 'checked=true'; break; case 'Party Room'; $checkedPar = 'checked=true'; break; } $i+=1; } } checkboxes <table cellpadding="0" cellspacing="0" style="font-size:10px"> <tr> <td style="border-top:1px solid #CCC;border-right:1px solid #CCC;border-left:1px solid #CCC; padding-left:5px ">Air Conditioned <input type="checkbox" name="air_cond" <?php print $checkedAir;?> value="Air Conditioned"></td> <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC;">Bar <input type="checkbox" name="bar" value="Bar" <?php print $checkedBar;?>></td> <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; ">Brunch <input type="checkbox" name="brunch" value="Brunch" <?php print $checkedBru;?>></td> </tr> <tr> <td style="border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC; border-left:1px solid #CCC; padding-left:5px">Party Room <input <?php print $checkedPar;?> type="checkbox" name="party_room" value="Party Room" ></td> <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC;">Tea Room <input type="checkbox" name="tea_room" value="Tea Room" ></td> <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC;">Terrace <input type="checkbox" name="terrace" value="Terrace"></td> </tr> <tr> <td colspan="3" style="border-bottom:1px solid #CCC; border-left:1px solid #CCC; border-right:1px solid #CCC; padding-left:5px">Valet <input type="checkbox" name="valet" value="Valet" ></td> </tr> </table>

    Read the article

  • Parsing a Directory of files - Check for a String

    - by i.h4d35
    This is my first post here so kindly pardon any mistakes that I have. I'm still learning to find my way around Stack Exchange. I am trying to write a Java program that tries to scan a Directory full of either .txt,.rtf or.doc files(and none other). The aim is to search all the files in the directory, and find out if a particular string exists in the file. If it does, it returns the string and the filename that it found the string in. The aim of this program is, it is a project for school wherein the program scans the personal folders of call center employees to check if they have stored any CC/DC nos and if yes, report the folder name - to reduce CC fraud. The search function was fairly straight forward and works when I individually specify the filename. However, the searching the directory and passing the files to the search function has me stumped. I've posted my code so far, if you guys could look thru it and give me some feedback/suggestions, I'd really appreciate it. Thanks in advance import java.io.*; import java.util.*; public class parse2{ void traverse(String directory) throws FileNotFoundException { File dir = new File(directory); if (dir.isDirectory()) { String[] children = dir.list(); for (int i=0; i<children.length; i++) { //System.out.println("\n" + children[i]); reader(children[i]); } } } void reader(String loc) throws FileNotFoundException { FileReader fr = new FileReader(loc); BufferedReader br = new BufferedReader(fr); Scanner sc = new Scanner(br); char[] chkArray; int chk=1; char ch; while(sc.hasNext()) { String chkStr = sc.next(); chkArray = chkStr.toCharArray(); if ((chkArray[0]=='4')&&(chkStr.length()>13)) { for(int i=0;i<chkArray.length;i++) { ch=chkArray[i]; if((ch=='0')||(ch=='1')||(ch=='2')||(ch=='3')||(ch=='4')||(ch=='5')||(ch=='6')||(ch=='7')||(ch=='8')||(ch=='9')) { chk=0; continue; } else { chk=1; break; } } if(chk==0) System.out.println("\n"+ chkStr); } else if((chkArray[0]=='5')&&(chkStr.length()>13)) { for(int i=0;i<chkArray.length;i++) { ch=chkArray[i]; if((ch=='0')||(ch=='1')||(ch=='2')||(ch=='3')||(ch=='4')||(ch=='5')||(ch=='6')||(ch=='7')||(ch=='8')||(ch=='9')) { chk=0; continue; } else { chk=1; break; } } if(chk==0) System.out.println("\n"+ chkStr); } else if((chkArray[0]=='6')&&(chkStr.length()>13)) { for(int i=0;i<chkArray.length;i++) { ch=chkArray[i]; if((ch=='0')||(ch=='1')||(ch=='2')||(ch=='3')||(ch=='4')||(ch=='5')||(ch=='6')||(ch=='7')||(ch=='8')||(ch=='9')) { chk=0; continue; } else { chk=1; break; } } if(chk==0) System.out.println("\n"+ chkStr); } } } public static void main(String args[]) throws FileNotFoundException { parse2 P = new parse2(); P.traverse("C:/Documents and Settings/h4d35/Desktop/javatest/chk"); } }

    Read the article

< Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >