Jump to content

Mark Williams

Members
  • Content Count

    274
  • Joined

  • Last visited

Posts posted by Mark Williams


  1. I create/open a TFileStream in non-exclusive mode with the following code:

     

    if not FileExists(FileName) then //have to create it first and close it otherwise the share mode does not work!!
          begin
            Result := TFileStream.Create(FileName, fmCreate, fmShareExclusive);
            Result.free;
          end;
    
        Result := TFileStream.Create(FileName, fmOpenReadWrite, fmShareDenyNone);

    By my reckoning I should be able to open  the file in read only mode:

     

    fs := TFileStream.Create(FileName, fmOpenRead, fmShareDenyNone);

    But it throws up an EFOpenError ie file in use by another process.

     

    I have looked online and found old posts which suggest that the share modes do not function for fmCreate mode ie always created exclusively and that is why I create, then close and then open.

     

    There was a post around 2010 which suggested the issue had been reported to Embarcadero and that it had been closed as fixed.

     

    Couldnt find anything much later than this.

     

    However as you can see , my problem is not with fmCreate, it is with fmOpenReadWrite. 

     

    is there a bug with TFileStream or am I handling this in the wrong way?

     

    If there is a bug, does anyone know a work around?

     


  2. 1 hour ago, Lajos Juhász said:

    I wonder who thinks that those sliding topics at https://blogs.embarcadero.com/ is useful! I

    Well I've not seen that site before today! Yes, it is annoying and pointless.

     

    I have made a note of the site for future reference. Of course, by the time I get around to looking at it, it will probably have moved somewhere else with n forwarding link.


  3. It seems to me that the Embarcadero web site(s) are a complete mess.

     

    I manage to find a resource one day and it's gone the next.

     

    As examples, I was advised to use https://idera.secure.force.com/CG/ to get to Quality Portal. I managed to get in to the Portal earlier this year and make a feature request, I returned to view it today and when I click on the Quality Portal link, it wants my username and password again, but not the same one. It wants the username and password for the Registered Product Page. Incidentally, this page also has a link for Registered Product, which takes a lifetime to load and is out of date! I use this link https://members.embarcadero.com/Login.aspx?returnurl=http%3a%2f%2fcc.embarcadero.com%2fmyreg to access Registered Product, which works. However, the username and password I use to access Registered Product does not work for Quality Portal because it won't accept an email as a username it wants your "real" username and I have no idea what that is. Tried a couple of options and none of them work. 

     

    Is it just me or is this a complete mess?

     

    And is it beyond the wit of man to put links for all resources we need on one consistent web page with one username and password?
     


  4. It's a bit frustrating and I have also posted on Stackoverflow, but nothing has come back.

     

    I have logged a feature request at Quality Portal. I would give you the link, but for some reason my log in details no longer work. If you could comment on that to lend support that would be great. That's assuming you know how to get in to it.

     

    I tried today, but my details no longer work!


  5. 17 hours ago, Kas Ob. said:

    I wouldn't depend on date to filter emails,

    It's not for filtering purposes. It is for a system that will store documents/resources including emails. When users are examining email threads I simply want to highlight that there may be something suspicious about one of the emails in the thread not exclude it from the thread.

     

    So if in 99% of the cases a Date header later than the Received header is suspicious that works for me. 

     

    Perhaps my original question was unclear and answers have been given on the basis that I was looking to exclude such emails. Far from it, I am looking to highlight them. With that in mind perhaps I can ask my original question again. 

     

    What sort of time difference by which the Date header is greater than the first Received header would you consider suspicious? I have opted for 30 minutes, but presumably there is an argument to say any difference is suspicious as I would expect most users' computers' and servers' clocks are automatically set.


  6. Thanks for the responses. Hadn't though of delayed sends. What I'm trying to catch is someone setting the date on their computer to a date in the past and sending an email to make it appear as though it was sent earlier than it in fact was. 

     

    21 hours ago, Attila Kovacs said:

    Date could also be in the future and not only in the past.

    I haven't come across this, but surely if the Date header is later than the Received header someone's clock someone is showing the wrong time?


  7. Apologies in advance as this isn't really an Indy question, but not sure where else to ask it.

     

    I have written functions to batch parse information from emails. I would also like to be able to flag up possible suspicious activity such as date tampering.

     

    One of the things I am looking at is the difference between the date time in the Date header and the date time of the first Received header. If there is a significant difference between the two then I will flag the item as suspicious.

     

    However, I am not sure what would be a significant time difference to warrant flagging. Anything more than a few minutes strikes me as too long and my initial view is to opt for about 30 minutes. Views as to whether that sounds sensible would be appreciated.


  8. 1 minute ago, emailx45 said:

    his because NONE ERRORS OCCURS.

    OK. As mentioned in original post if RowsAffected is less than the number of inserted rows I would expect I rollback the transaction (and handle it as an error).

     

    It is only if the RowsAffected = the number of inserted rows expected that I would use the approach in my original post.

     

    Taking that into account, do you think it is safe to do so?


  9. 22 minutes ago, emailx45 said:

    the number of successful executions, not the total number of affected rows by all executions.
     

    But for an insert procedure would not the number of successful executions be the number of new rows inserted?

     

    That certainly seems to to be the case from the testing I have carried out so far.


  10. FireDAC Array DML doesn't seem to be usable in any practical sense with Returning clauses FireDAC Array DML returning values from inserted records.

     

    That being so, I am trying to work out whether there is an efficient way I can retrieve data from inserted records using Array DML.

     

    The following seems a possibility and is lightening fast, but I am concerned that I may be missing something critical:

     

    1. Insert required no of new records using Array DML within a StartTransaction/Commit section.
    2. Check the number of affected rows to make sure that all required records have been inserted. If not, then rollback.
    3. Obtain the last insert id for the target table for the current session.
    4. Work backwards through the array of inserted data in my app and assign the id by decrementing the last id.

     

    My initial testing suggests that this works. But it depends on the following assumptions being correct (which I believe they are):

     

    1. The RowsAffected property of TFDQuery is wholly reliable.
    2. My DB (in this case PostgreSQL) will always reliably return the correct last insert id for my table in my current session.
    3. My DB will insert all my records in the same order as they are added to the TFDQuery params list.
    4. My DB will insert the records in an unbroken sequence of IDs.

     

    So my questions

    1. Are my assumptions sound? 
    2. Am I missing something else?

     

     

     

     


  11. Using a Postgre database.

     

    If I run an insert query with the following code:

    #

    With FDQuery Do
      begin        
        SQL.Text:='INSERT INTO temptab(email, name) '
         +'VALUES (''email1'', ''name1''), '
    	 +'(''email2'', ''name2'') '
    	 +'returning id';
    	Open;
      end;
        

    The query returns two records containing the id for the newly inserted records.

     

    However, for larger inserts I want to use Array DML, but I also want to be get the returned data. Example code:

     With FDQuery Do
       begin
         SQL.Text:='INSERT INTO temptab(email, name) '
          +'VALUES (:EMAIL, :NAME) returning id';
          Params.BindMode:=pbByNumber; 
          Params[0].DataType:=ftString;
          Params[0].DataType:=ftString;
          Params.ArraySize:=2;
    
          Params[0].AsStrings[0]:='Email1';
          Params[1].AsStrings[0]:='Name1';
           
          Params[0].AsStrings[1]:='Email2';
          Params[1].AsStrings[1]:='Name2';
            
          Execute(params.ArraySize);
      end;

    This returns no records. Not unsurprisingly as I am using the Execute command.

     

    If I change the Execute command to Open, it inserts just the first record from the array and returns the id for that new record. 

     

    The Open function does not allow you to specify the ArraySize.

     

    I have tried to find some other procedure/property that will achieve this, but have drawn a blank.

     

    Does anyone know whether it is possible to return data from all inserted records using Array DML? 

     

    If it is not possible can anyone suggest an efficient way for returning the inserted data?

     

     There seems to be two alternatives to me, neither of which is particularly attractive:

     

    1.  Run a query to return all records that match the email and name and then extract the relevant ids. In large tables this would doubtless result in a significant overhead.
    2. Add an integer field to the table eg "temp_id". When inserting the data set this field  to a unique value for all records inserted for the DML Array transaction and then retrieve the newly inserted data using "temp_id". Again, this doesn't appear to me to be an attractive solution.

     

    @Dmitry Arefiev If this is not currently possible with Array DML would you please consider including it for later versions?


  12. Currently on 10.4, but have had this problem right back to 10.1.

     

    If I change a text property, caption, name, hint etc in the object inspector it does not stick when you click away on to some other IDE control such as say the form. You have to click on some other property in the object inspector and even then there is no guarantee that your change has been accepted.

     

    It's an absolute pain in the butt. Does anyone else have this issue and has anyone got any workarounds?


  13. 6 minutes ago, Lars Fosdal said:

    If you want it to always run elevated, you can specify that in the manifest.

    No. I just need to know if user has run my app in elevated mode.  My App launches Outlook and if one is running elevated and the other isn't then you get an OLE error. I just want to be able to advise user which is doing which so they can correct.


  14. Is there a simple way to check if my app is running elevated?

     

    I can see a few oldish posts on this on Google, but nothing recent. I was just wondering if newer Delphi has introduced a simple function for it, although I couldn't find anything in help or likely units. Or  perhaps there is a new Windows API procedure?

×