Thursday, February 10, 2011

capture windows username in asp.net mvc request

i have an intranet app asp.net mvc site. is there anyway to capture the windows nt login from the user wihtout having a full login system in the site. i dont want permissioning but i would like to do some logging on the server to track requests, etc . .

  • If you set IIS to use Windows Authentication and the site is in the Intranet Zone for your clients then the logins will automatically happen without any prompts at all.

    From blowdart
  • What version of Windows is this mvc app running on?

    You could try the following:

    • Use IIS Manager to disable anonymous access to the site, and make sure digest and/or windows authentication is enabled.
    • Change the mvc app's web.config to use Windows Authentication
    • Access the login name in the controller using User.Identity.Name.

    Would that do?

    From IanT8
  • You can use HttpContext.Current.User.Identity.Name if you set up the site to use Windows Authentication. Many browsers will pass the username on transparently.

    ooo : it seems with firefox, it prompts for a user name / pwd even though IE seems to not require it . . any ideas on why this is happenning
    ooo : Dan Diplo - any ideas ?
    Dan Diplo : FireFox, by default, doesn't pass on the username. However, it can be made to work - see http://markmonica.com/2007/11/20/firefox-and-integrated-windows-authentication/
    From Dan Diplo

NSString converting percentage characters

Hi,

I have an NSString *str = @"T%B3%C3%83";

where %C3 represents A with an umlut (I think), %B3 an m, %83 a superscript 3...

What is the best way to convert these percentages into the actual characters.

Thanks.

  • use -stringByReplacingPercentEscapesUsingEncoding method in NSString.
    P.S. However I don't know what encoding you must use to get results you've mentioned in your question (are you sure they're correct?)

    From Vladimir

decoding base64 encoded string with URL escaped characters

I am currently working on importing contacts from windows live contacts(hotmail addressbook). At one stage, the service posts back some data that i need to my page as a base64 encoded string which, as per microsoft documentation, contains url escaped sequences for '&' and '='. The string is thus not standard base64 encoded. The problem is when I try to convert it back to the original string from coldfusion, coldfusion refuses to recognize this as a valid base64 encoded string. How can I obtain the original string?

string looks something like this: "eact%253D28grLAdrSYSMp6mYbAozFuDqlgk78UZZ%25252F5A%25252Bygx.... (pretty long)" My cfmethod to convert back is simple - tostring(tobinary("ENCODED STRING"))// Thanks to Ben nadel The error obtained is "parameter 1 of tobinary which is is not base64 encoded"

Please help...

How to change the tabbar color in vaadin?

Hi want to change the tab color when the tab get focus in vaadin?can any one help me how to customize tabsheet to achive this..

  • It's a good idea to use a tool like firebug to inspect the DOM structure of the components. For example, when inspecting the DOM structure of the TabSheet example in the Sample, you will see that all tab has the style class v-tabsheet-tabitem. If you select the first tab, it will get the following style class "v-tabsheet-tabitemcell", "v-tabsheet-tabitemcell-first" and "v-tabsheet-tabitemcell-selected-first". If you select the second tab, it will get the following style classes: "v-tabsheet-tabitemcell" and "v-tabsheet-tabitemcell-selected". As you will see, the styles you need to modify are a bit dependent on the tab's position in the tabsheet.

    About changing the color of the tab, let's take a look at the selected tab's css.

    
    .v-tabsheet-tabitemcell-selected {
       background-image:url(common/img/vertical-sprites.png);
       background-position:left -1444px;
    }
    
    

    As you can see, the actual css is not complicated. The technique used in the css is however a not so common, it uses a sort of optimization. All the background images are joined in one single png image and the background image's position is adjusted so that we get the image we want to show as the background. What you need to do, is to create your own theme and modify that image to suite your own needs. Check the Book of Vaadin for more details about creating custom themes.

    From Kim L
  • Actually, you do not need to know the technique (CSS sprites) in order to change the background of the tabs. You will only need to use regular CSS, no magic involved.

    So create a new background image (of a solid color is not enough) and set that to the background of the relevant element. Repeat for all relevant elements that are contained in the tab (they might also specify some background).

    If you wish to modify the original images from the Vaadin Reindeer theme, they can be found from here: http://dev.vaadin.com/browser/versions/6.4/WebContent/VAADIN/themes/reindeer/tabsheet/img

    From Jouni

Stripping MS Word Tags Using Html Agility Pack

Hi Everyone,

I have a DB with some text fields pasted from MS Word, and I'm having trouble to strip just the , and tags, but obviously keeping their innerText.

I've tried using the HAP but I'm not going in the right direction..

Public Function StripHtml(ByVal html As String, ByVal allowHarmlessTags As Boolean) As String
    Dim htmlDoc As New HtmlDocument()
    htmlDoc.LoadHtml(html)
    Dim invalidNodes As HtmlNodeCollection = htmlDoc.DocumentNode.SelectNodes("//div|//font|//span")
    For Each node In invalidNodes
        node.ParentNode.RemoveChild(node, False)
    Next
    Return htmlDoc.DocumentNode.WriteTo()
End Function

This code simply selects the desired elements and removes them... but not keeping their inner text..

Thanks in advance

  • Well... I think I found a solution:

    Public Function StripHtml(ByVal html As String) As String
        Dim htmlDoc As New HtmlDocument()
        htmlDoc.LoadHtml(html)
        Dim invalidNodes As HtmlNodeCollection = htmlDoc.DocumentNode.SelectNodes("//div|//font|//span|//p")
        For Each node In invalidNodes
            node.ParentNode.RemoveChild(node, True)
        Next
        Return htmlDoc.DocumentNode.WriteContentTo
    End Function
    

    I was almost there... :P

    From gjsduarte

Global Variable not incrementing on callback functions

i am using Webclient to upload data using Async call to a server,

    WebClient webClient = new WebClient();
   webClient.UploadDataAsync(uri , "PUT", buffer, userToken);

i've attached DatauploadProgress and DatauploadCompleted Events to appropriate callback functions

        // Upload Date Completed 
        webClient.UploadDataCompleted += new
                UploadDataCompletedEventHandler(UploadDataCallback2);

        // Upload Date Progress
        webClient.UploadProgressChanged += new 
                 UploadProgressChangedEventHandler(UploadProgressCallback);

and in the functions i am trying to show some MessageBoxes:

      // Upload Date Progress
     void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
    {
        MessageBox.Show( this,"Upload Progress  ,x =" +x);
        x++;
        MessageBox.Show(e.BytesSent.ToString());
    }



        // Upload Date Completed 
     void UploadDataCallback2(object sender, UploadDataCompletedEventArgs e)
    {

        MessageBox.Show(this, "Upload Done,x =" +x);
        x++;
        MessageBox.Show(ASCIIEncoding.UTF8.GetString(e.Result));
    }

Where x is a global variable, However for some reason x is not getting incremented, and all the message boxes show x=0..

any explanation would be much appreciated..

  • Oh found the problem, well apparently the problem was a 2-parts problem , and i hope someone would confirm my conclusion :

  • the MessageBox.show on the progress, blocked the function from progressing resulting in x staying at zero until i pressed ok.
  • The files i was uploading were too small, so the datauploadcompleted event was called before i got enough time to click the ok on the messagebox from the progress event
  • Rubens Farias : seems right to me; replace that messabe by `"Upload Progress ,x =" + ++x` and try to upload a larger file to confirm
    Madi D. : Yep, after editing the "messabe" ;) to ++x , and with a bigger file i solved the problem, thamks Rubens :)
    Eclipsed4utoo : The `MessageBox` is a dialog box that stops the execution of the code until it is dismissed.
    From Madi D.

Expecting identifier before object string :(

Hi, I'm trying to format this line correctly but so far, I'm getting no where:

NSString *urlAddress = selectedCell.@"html";

selectedCell is the category chosen,

IBOutlet UILabel *selectedCellText;
NSString *selectedCell;

How do I sort this out?

  • Fixed it,

    NSString *urlAddress = [[NSBundle mainBundle] pathForResource:selectedCell ofType:@"htm"];
    
    From Shamil

Property with Enumerable or list

I'm playing around with LINQ and related subjects and was wondering about the following.

I've 2 methods of getting a Fibonacci sequence. I started with:

public static IEnumerable<int> Fibonacci
    {
        get
        {
            int i = 0;
            int j = 1;
            int temp = 0;

            while (true)
            {
                yield return i;

                temp = i;
                i = j;
                j = temp + i;
            }
        }
    }  

But it got me thinking, why would I choose this over:

public static IList<int> Fibonacci(long to)
    {            
        IList<int> fibList = new List<int>();
        int i = 0;
        int j = 1;
        int temp, index = 0;

        while (index < to)
        {
            fibList.Add(i);

            temp = i;
            i = j;
            j = temp + i;

            index++;
        }
        return fibList;
    }

IList is an Enumerable as well + I might want to add some parametrization to it. I'm not really looking for optimisations or stuff or thing like use < long > because the number gets big fast, its merely a quick example. Just some arguments pro and con each method. Why and when should I use which method?

  • Why would you use a property (static or otherwise). A Fibonacci number generate is a property of what...? Also, as a rule of thumb, a property should never perform any "significant" calculation/processing, thus you definitely want to be using a function here.

    Oxymoron : Yeah, it is part of a utility class with some math functionality, but I kind of got stuck. It didnt feel right using it as a property. Changed it to be a paramterless function.
    From Noldorin
  • If you put the first version in a foreach then it will never terminate unless you specifically break out. Potential source for a bug when using it. Maybe that's what you want, but it's something to be wary of.

  • An important difference between the two is that with your second version you have to know in advance when you want to stop, but in the first version you can start iterating and later decide when to stop. You don't have to know in advance.

    You also don't have to store the entire list in memory at once with the first version. You can handle the data in a streaming manner.

    An advantage of the second is that returning a list allows you to index into the array rather than handling elements one by one from the beginning. You could use the second version if you do know how many elements you want, and you know that the list is small enough to fit in memory.

    Note that these differences have nothing to do with whether you use a property or a function call. You could rewrite the first to be a function call that takes no parameters.

    If you have only the first version available, you could easily emulate the second version by using Fibinocci().Take(20).ToList().

    Joel Coehoorn : Also: with the List, you can't do any work with the results until you've computed all of the numbers. With an IEnumerable, you can start working with results right away and compute the next number as you go. You kinda covered that with "in a streaming manner", but it wasn't as clear.
    Oxymoron : Rewrote the first one to be a function without parameters. Now I can do: var result = Fibonacci().TakeWhile(n => n < 10000).Skip(10); Like I wanted, thanks :)
    Joel Coehoorn : I'd reverse that and put the skip first. Saves you having to make the the n < 10000 check on the first 10 terms.
    From Mark Byers

Opening file from Java

What I need is to instruct OS to open the file with the default program used for that file type. Exactly as if, i.e., that file was double-clicked by user under Windows.

The purpose is, i.e., "your PDF file was generated. Click here to open it".

In platform-independent way, if possible...

I dont know exact terms for what I want, so if someone could update tags, I'd most appreciate that ;)

  • You need the Desktop class, and the open() method in particular.

    Launches the associated application to open the file. If the specified file is a directory, the file manager of the current platform is launched to open it.

  • Since Java 6, we have Desktop.open() for exactly that purpose.

    Nrj : what about 1.5 or before.. any reference ?
    Michael Borgwardt : @Nrj: there was no platform-independant way to do it before Java 6. You could use Runtime.exec() to call platform-specific mechanisms via the shell, such as Windows' *start* command.

How to configure asp.net MVC project in IIS?

When I run project in IIS, after displaying home page it will not allow to redirect on any other page. It gives Page could not found error.

  • On IIS 6 you may need to register a mapping in order to associate the ASP.NET ISAPI module with an extension or if you would like to have extensionless URLs you may take a look at this article.

How can I create a hybrid Silverlight and aspx application

Here is my scenerio..

We have an ASP.Net 2.x web site. We want to migrate it to Silverlight full frame application. However, there is no way we can go away in a corner and redo every web page in SL right off the bat.

What I would like to do is build the chrome of the app (main page, dashboard, login, common system/config screens, main menu) in SL and be able to open existing .aspx pages in the main content SL frame.

From what I see there is no way to do this. I thought the Webbrowser control in SL4 would be the answer, but apparently that only works if your app is run out of browser.

So, what is my best recourse? It seems like I will have to create some type of .aspx page that hosts the .XAP and pass in the page I want it to load?

How would you gurus approach this?

  • I would actually go the opposite route actually. Intead of building the full dashboard, i would begin building the dashboard elements separately as much as you can. This will give you time to refactor your individual applications one by one until you're ready to integrate them all.

    One method we considered on my team was to build our SL rendering engine to render our aspx into SL controls, but when we saw the scope of that we decided it would be easier just to begin developing everything in SL from scratch.

mssql_query doesn't return anything

I am having problems with setting up a system.

We have a SQL Server 2005 running and I want to connect it from another windows machine running php 5.2 and apache.

I can connect to SQL using mssql_connect but I can not retrieve any results from a simple query (SELECT * FROM USERS) mssql_query doesnt return anything nor dies or shows an error.

Same code with same php is working on another machine (client of SQL Server machine) and in the PC running SQL Server.

What could be going on?

  • If the query just hangs, then probably the table is locked.

    Could you please run a query that does not involve any tables (like mere SELECT 1) and see if it works?

    From Quassnoi
  • It may be timing out due to longer time to execute the query? You could try a simpler query like SELECT 1

    If it is a timeout issue, you may have to look into why does it happen to this computer...or you may be able to fix it by having this line in code before the query executes: ini_set('mssql.timeout', seconds) where seconds is a number.

  • I've never worked with MsSQL before but try setting error_reporting(E_ALL) at the top of your file and after calling mssql_query() do a var_dump(mssql_get_last_message()).

    From Alix Axel
  • I would start with configuration. If it's working fine from another machine and this is the only one with an issue then
    1. Compare drivers between the working / non-working machines.
    2. Compare php installations.

    You get the picture.

    Also, I'm not sure what you mean by "(client of SQL Server machine)"...

  • Thanks everybody, I solved it. There was a upper/lowercase mistake on my php code, and I was not treating any rows of the resultset.

    It took me hours to notice this stupid thing!

    From zitronic

Open ldap modify - /usr/bin/modify problem

Can anyone help me out on this? I'am trying to add another attribute on my LDAP, but i don't know much about this. It returns an error after trying the sample i searched on net. This command will be used on my perl program to add new attribute "status" w/ value "yes"..

Help pls?

/usr/bin/ldapmodify -x -D "cn=Test,ou=mygroup.com,o=group2.com" -a "status=yes"??

the -W doesn't work too.

Error: ldap_bind: Can't contact LDAP server (-1)

  • Try -v for detail log and -w should be in lower case. As for excluding the password one way is to use '-w -' which you will be prompt to enter the password. Hope this helps.

    From

image resize befor upload

can we resise image file at client side before uploading to reduce its size to save time of uploading?

  • I don't know, can you?

    Seriously though, it would depend on what technologies you want to be limited to. If you want the classic html upload form then no. If you use heavier client-side technologies (Java/Flash) then it is possible. It would also depend on what image formats you want to support. You may also need to leverage third party libraries in addition to whatever platform you choose.

    Rewrite your question so everyone is clear on what you want to accomplish and what languages/technologies/frameworks you're expecting to use or are already using.

    neenu : Yes, I want to use client side technology and I am trying with Flex Builder using Flash.Got help from article "http://www.codeproject.com/KB/aspnet/FlashUpload.aspx?fid=345104&df=90&mpp=25&sort=Position&tid=3289125" This is to upload files in flash. Now I would like to add resize option by taking filerefernce data to bitmap data and resize and then upload. Please study this code and help if possible,Thanks in advance.
  • There are two free tools (for Windows) that I would recommend depending on your needs:

    TOOL 1: For resizing a batch of images, use the Windows PowerToy "Image Resizer", available for free download from Microsoft.

    After installing, you'll simply select the files you want to resize, right-click, and choose "Resize Pictures". That will bring up a simple Form and give you some common sizes or allow you to choose a custom size. The Resizer will work in batch mode and resize all the selected files, automatically renaming them and putting them into the same directory.

    For simple needs, this is more than adequate.

    TOOL 2: To do this by hand, as well as many other image related actions, try IrfanView, available for free download.

    From AKE
  • Yes. http://www.shift8creative.com/projects/agile-uploader/index.html

    From Tom

Modifying Windows ctrl-alt-del behavior through Gina

Hello I am trying to change the behavior of the windows xp ctrl alt del key in certain scenarios throught Gina. Specifically I want to unhook the custom dialog that appears on ctrl alt del that was implemented in legacy code, and have my task manager back. Would someone point me at the right direction please? 

MySQL - Saving and loading

Hello,

I'm currently working on a game, and just a while ago i started getting start on loading and saving.

I've been thinking, but i really can't decide, since I'm not sure which would be more efficient.

My first option: When a user registers, only the one record is inserted (into 'characters' table). When the user tries to login, and after he/she has done so successfully, the server will try loading all information from the user (which is separate across multiple tables, and combines via mysql 'LEFT JOIN'), it'll run though all the information it has and apply them to the entity instance, if it runs into a NULL (which means the information isn't in the database yet) it'll automatically use a default value. At saving, it'll insert or update, so that any defaults that have been generated at loading will be saved now.

My second option: Simply insert all the required rows at registration (rows are inserted when from website when the registration is finished).

Downsides to first option: useless checks if the user has logged in once already, since all the tables will be generated after first login.

Upsides to first option: if any records from tables are deleted, it would insert default data instead of kicking player off saying it's character information is damaged/lost.

Downsides to second option: it could waste a bit of memory, since all tables are inserted at registration, and there could be spamming bots, and people who don't even manage to get online.

Upsides to first option: We don't have to check for anything in the server.

I also noted that the first option may screw up any search systems (via admincp, if we try looking a specific users).

  • I would go with the second option, add default rows to your user account, and flag the main user table as incomplete. This will maintain data integrity across your database, whereas every user record is complete in it's entirety. If you need to remove the record, you can simply add a cascading delete script to clean house.

    Also, I wouldn't develop your data schema based off of malacious bots creating accounts. If you are concerned about the integrity of your user accounts, add some sort of data validation into your solution or an automated clean-house script to clear out incomplete accounts once the meet a certain criteria, i.e. the date created meeting a certain threshold.

    Phil Wallach : The other advantage is that you do not need to worry about missing records in the rest of your code. With the first aproach you risk having special cases everywhere.
    From George
  • You mention that there's multiple tables of data for each user, with some that can have a default value if none exist in the table. I'm guessing this is set up something like a main "characters" table, with username, password, and email, and a separate table for something like "favorite shortcuts around the site", and if they haven't specified personal preferences, it defaults to a basic list of "profile, games list, games by category" etc.

    Then the question becomes when registering, should an explicit copy of the favorite shortcuts default be added for that user, or have the null value default to a default list?

    I'd suggest that it depends on the nature of the auxiliary data tables; specifically the default value for those tables. How often would the defaults change? If the default changes often, a setup like your first option would result in users with only a 'basic' entry would frequently get new auxiliary data, while those that did specify their own entries would keep their preferences. Using your second option, if the default changed, in order to keep users updated, a search/replace would have to be done to change entries that were the old default to the new default.

    The other suggestion is to take another look at your database structure. You don't mention that your current table layout is set in stone; is there a way to not have all the LEFT JOIN tables, and have just one 'characters' table?

Reports against a single SQL Table

I'm looking for a freeware program that is pretty much BusinessObjects.

We have 1 SQL table which has loads of data in it that users constantly want reports from. Everytime they ask it's an ad hoc query written just for the moment.

It would be much nicer to be able to give users a solution to create there own reports. Kind of like BusinessObjects :), but free and easy to use ofc :D

Where can href attribute appear in HTML document?

In which elements (tags) attribute href is allowed according to the HTML 4.01 standard?

EDIT: An is it commonly used is some other tags (in non-standard ways).

  • primarily the Anchor tag

    <a href="www.url.com">link</a>
    

    Have a look at www.htmlref.com

  • AFAIK only <a> and <base> tags allow the href attr.

  • According to the standard...

    A, AREA, LINK, BASE

    Pekka : +1 the only one who got it completely right in the first go :)
    John Weldon : lol, thanks. w3c is my friend :)
    Lord Torgamus : +1 I was going for the same thing, but I didn't know about that table. Nice.
    JohnM2 : I was looking for exactly such table. Thanks!

Parsing CSV files in C#

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser.

Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a lot of people discourage this due to its "drawbacks." What are these drawbacks?

Ideally, I'm looking for a way through which I can read the CSV by column name, using the first record as the header / field names. Some of the answers given are correct but work to basically deserialize the file into classes.

  • Let a library handle all the nitty-gritty details for you! :-)

    Check out FileHelpers and stay DRY - Don't Repeat Yourself - no need to re-invent the wheel a gazillionth time....

    You basically just need to define that shape of your data - the fields in your individual line in the CSV - by means of a public class (and so well-thought out attributes like default values, replacements for NULL values and so forth), point the FileHelpers engine at a file, and bingo - you get back all the entries from that file. One simple operation - great performance!

    David Pfeffer : Thanks. FileHelpers is what a lot of articles were pointing at also.
    From marc_s
  • If you need only reading csv files then I recommend this library: A Fast CSV Reader
    If you also need to generate csv files then use this one: FileHelpers v 2.0

    Both of them are free and opensource.

    From Giorgi
  • There's no official way I know of, but you should indeed use existing libraries. Here is one I found really useful from CodeProject:

    http://www.codeproject.com/KB/database/CsvReader.aspx

    From VitalyB
  • In a business application, i use the Open Source project on codeproject.com, CSVReader.

    It works well, and has good performance. There is some benchmarking on the link i provided.

    A simple example, copied from the project page:

    using (CsvReader csv = new CsvReader(new StreamReader("data.csv"), true))
    {
        int fieldCount = csv.FieldCount;
        string[] headers = csv.GetFieldHeaders();
    
        while (csv.ReadNextRecord())
        {
            for (int i = 0; i < fieldCount; i++)
                Console.Write(string.Format("{0} = {1};", headers[i], csv[i]));
    
            Console.WriteLine();
        }
    }
    

    As you can see, it's very easy to work with.

    From alexn

ui tab select using variable

Hi

i am having problem when try to change tab

the code below is working

$('#tabs').tabs('select', 1);

WORKING FINE

the code below

var nextTab=$('#nextTab').val();
$('#tabs').tabs('select', nextTab);

IS NOT WORKING

the nextTab vairiable is valid tab index

Its drive me crazy! What am i missing

Thanks

  • Are you sure nextTab holds a valid tab index? If yes, don't know if this makes a difference, but try converting it to a Number:

    var nextTab = Number($('#nextTab').val());
    
    ntan : cross my mind but...Thanks yoy save me
    From Anurag

How to Change init-parameters at Runtime?

If I modify the XML to change the value of init parameter I see the changes only when web-app is redeployed.

My question is cant I get around this by setting the values at run time.Is there any API that allow me to change the values dynamically.

  • It's called init-parameter for a reason. So, you can't.

    But you can change values at runtime, that's no problem.

    1. After reading the init parameters put them as attributes of the ServletContext (ctx.setAttribute("name", value))
    2. Create a small (password-protected) page that lists all attributes of the ServletContext and gives the ability to change them.
    From Bozho
  • Maybe you could use apache commons configuration, specifically have a look at Automatic Reloading...

    From pgras
  • Make use of properties files instead and write code so that it 1) reads the value from it everytime, or 2) can reload the value on command, or 3) reloads the file automatically at certain intervals.

    If you put the properties file somewhere in the webapp's runtime classpath or add its path to the webapp's runtime classpath, then you can easily access/load it as follows:

    Properties properties = new Properties();
    properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("filename.properties"));
    String value = properties.get("key");
    
    From BalusC

Why would System.Xml.Serialization.XmlSerializer be undefined in a SSRS 2005 report?

I'm trying to serialize a data structure and pass it to another report via parameter, and this line of code:

Dim s As New System.Xml.Serialization.XmlSerializer(GetType(System.Collections.HashTable))

Produces this error:

An error occurred during local report processing.
The definition of the report '/myReport' is invalid.
There is an error on line 22 of custom code: [BC30002] Type 'System.Xml.Serialization.XmlSerializer' is not defined.

How can I get around this? I have been able to use fully defined .NET classes in other lines of code, including the following:

Dim outStream As New System.IO.StringWriter()

and

Private colorMapping As New System.Collections.Hashtable()

Any ideas why this would fail? This is SQL Server Reporting Services 2005.

  • So you can close the question out:

    You'll need to add a reference to 'System.Xml' to the project.

    Nathan DeWitt : thanks. it was bugging me...
    From John

PyQt lineEdit with colors

Hi fellows!

I'm trying to format a Qt lineEdit text with colors.

 def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.lineEdit.setText("here be colors")

I searched a lot but only found customized drawing widgets with monstrous amounts of code. Is there any easier way to format the lineEdit box than customizing the whole?

How to make a System.Configuration.Install.Installer to get a variable from the Setup project?

I have 2 projects in my solution

  1. A Windows service

  2. Its Setup project

I need that my ProjectInstaller : System.Configuration.Install.Installer's method called OnAfterInstall to get the ProductName from the Setup Project. How do I do that?

  • Within your setup project right click project and select View ->Custom Actions. Add a custom action. Now select Add Output ,now select your web service project and select ok.

    Now select your custom action and set the CustomActionData property to contain something like /ProductName=[PRODUCTNAME] /whateveryouwant=[Whateveryouwant] (note that these are essentially name value pairs i.e. to access the productname the ProductName is the name and the value is PRODUCTNAME) etc. Note that the CustomActionData is the parameters which will be passed to your installer class. So the "PRODUCTNAME" will be the is the property name which is associated with the user interface dialog so in your case you prompt user for Product Name within yor installer so the label is Product Name and the corresponding property should be set as PRODUCTNAME (obviously you could change this the most important thing to note is that the UI property name must be the same as the property name in the CustomActionData ) for this example to work.

    Now within your installer class you can get product name by doing

    public override void Install(IDictionary stateSaver)
    {
          // If you need to debug this installer class, uncomment the line below
          //System.Diagnostics.Debugger.Break();
    
           string productName = Context.Parameters["ProductName"].Trim();
    
           string whateveryouwant== Context.Parameters["whateveryouwant"].Trim();
    }
    

    note i included the commented code //System.Diagnostics.Debugger.Break(); which you can comment in so that you can debug the installer class.

    hope this helps.

    Jader Dias : Excelent! Thank you!
    Jader Dias : I have run into 2 problems: (1) It isn't working (2) When debugging it says: `Cannot evaluate expression because the code of the current method is optimized.`
    NBrowne : im not sure what the problem is without seeing your code or having more details.the error your getting is an error which happens for numerous regions. if you want you can send me a trimmed down version of your setup project and ill have a look to see if i can see whats wrong with it.
    NBrowne : have you fixed this problem??? did my solution help you??
    From NBrowne

MFmailcomposer works fine in iphone but not in simulator!!

MFMailcomposer works fine in iphone but when run in simulator mails are not sent. and when sent from iphone if image is attached in mail it displays broken image. image is not clear. i am not getting what is the problem. right now i dont have device and from simulator its not sending mails.

  • There is no mail support in the simulator, so you can't send mail. And the broken image from a device is usually just a problem with the iPhone OS, when viewing the email on a desktop computer it should look fine. Nothing you can fix though.

    From crmunro

Trouble compiling or dropping an Oracle package

I was trying to compile a PL/SQL package and I got the following error:

ORA-04043: object SYS_PLSQL_77721_489_1 does not exist

After this, I can no longer recompile or drop the package.

Do you have any suggestions?

  • Hi superdario,

    if you have access to support, this looks like bug #3744836. A similar bug is described here, related to pipelined functions and synonyms.

  • Try to do this:

    DROP TYPE SYS_PLSQL_77721_489_1;
    DROP TYPE SYS_PLSQL_77721_DUMMY_1;
    DROP PACKAGE BODY xxxx;
    DROP PACKAGE xxx;
    

    I've had exactly the same problem and works. Sorry @Vicent but the link you provide does not solve the problem.

    From FerranB
  • One confirmed cause of this problem is the use of pipelined functions with PL/SQL types. It is a bug, and so ought to fixed in more recent or fully patched versions of Oracle. A workaround would be to use SQL types instead (i.e. create type whatever as object ... ).

    If this does not apply in your situation please edit your question to include more details.

    From APC