Umbraco 7 Upload File - Check if remove file is ticked - umbraco

I have an Upload file option in Umbraco 7, the problem I have is if the remove checkbox is ticked and you click publish to remove the file, my code below catches the upload field as empty and display my custom error message.
if (string.IsNullOrEmpty(urlForFileUpload))
{
e.CancelOperation(new EventMessage("Error", "Please select an Excel file before publishing",EventMessageType.Error));
}
Does anyone know what gets passed to the server so that I can check for it and not display my error message if the checkbox is ticked?
--------------------CancelOperation---------------

You don't need an event handler to check that. Just make the field mandatory:

Related

Use Applescript to pull PDF attachments out of a note

I am adding several PDF documents to a note using the scan documents feature in Notes on my iPhone. I want to pull those attachments to a folder on my mac. I have the notes on iCloud so the note attachments are available. I can drag and drop, of course, but I want to automate the process. I tried to record my activity through automater and Scropt Editor, but they didn't pick up the drag and drops. I have moved to writing my own apple script.
I tried a number of approaches to the duplicate. I am able to get the path to the destination folder and can reference the items in the folder. The usage of the duplicate verb in Notes eludes me.
tell application "Finder"
set FWsimple to front window
set FW to (POSIX path of (target of front window as alias))
end tell
tell application "Notes"
set theAttachment to attachment id "x-coredata://EDDBBF66-DC2A-4A84-8913- 4548B5AA5D6C/ICAttachment/p2176"
set allAttachments to get every attachment of note "Patients 5/17/22"
duplicate the attachment to FW
end tell
{FWsimple, FW, theAttachment, allAttachments}
Running the above with the duplicate statement commented out gives me the following, so I know I am getting the objects. The front window target will be changed later, but it works for now to get the correct folder.
{Finder window id 2573 of application "Finder",
"/Users/sholland/Desktop/Applescript of Notes/",
attachment id "x-coredata://EDDBBF66-DC2A-4A84-8913-4548B5AA5D6C/ICAttachment/p2176" of application "Notes",
{attachment id "x-coredata:...p2034" of application "Notes"}
}
When I run I get: error "Notes got an error: Can’t make "/Users/sholland/Desktop/Applescript of Notes/" into type location specifier." number -1700 from "/Users/sholland/Desktop/Applescript of Notes/" to location specifier. I've tried using FWsimple and FW as the location specifier.
Please tell me how to use duplicate to copy the PDF to a folder.

Ability to prevent/stop loading 'Page load' in Cypress when clicked a hyperlink

In my Cypress test,
I need to test a link which downloads a .txt, .xlsx and a .zip file when clicked, but when I use "click()" to click the hyperlink, it starts a page load and expects a new action to happen as a result of clicking a link.
As an alternative to this I tried using the cy.downloadFile() to download the files directly through the link but the link I am using is dynamically generated hence I am unable to use that as well. Hence I want to store the newly generated link in the variable and then use it in cy.downloadFile() every time I run the test.
Are there any other ways to test a hyperlink or how to store the dynamically generated link every time the test is run?
Hi there i been through this problem before.
I think it is the same scenario where the cypress test runner just keep waiting page load event and not go to the next test command while file are successfully downloaded.
Add custom cy.window event to listen the click event and add timeout to "force" reload current page, you need to tweak the timeout value so it suitable for your test.
it.only('tes button download', ()=> {
// visit url
cy.visit("/spmb/list_nilaiseleksi");
cy.get('#wrap-button > .btn').click()
//download
cy.window().document().then(function (doc) {
doc.addEventListener('click', () => {
setTimeout(function () { doc.location.reload() }, 5000)
})
cy.get(':nth-child(9) > .col-md-12 > .btn').click()
})
})
More details and discussion available here on cypress github issue :
https://github.com/cypress-io/cypress/issues/14857
I found a way to store the link of the element I want to click. Since I am able to store the link, I am able to solve the requirement by using cy.downloadFile().
cy.get('#selector', {timeout: 15000}).then(($input) => {
cy.downloadFile($input.attr('href'),'cypress/downloads','filename.csv')
});
For me, the problem was resolved after I added the download attribute to the link, This is changing the element in the DOM, but it keeps the solution simple:
cy.get('[href="download?type=php"]')
.then((el) => {
el.attr('download', '');
})
.click();

FlutterIcon error: Invalid params: - data.config is required (undefined)

I tried to "Download" data from FlutterIcon (https://www.fluttericon.com/).
What I had tried to do:
Select Icons
Write "AppIcons" in "MyFlutterApp"
Press button "Download".
Then I got this message: "Invalid params: - data.config is required (undefined)"
you can use this service to convert svg to font
https://icomoon.io/app/#/select/font
click on +import icon
and after that converted
create dart file that contain class with attribute of
IconData(int,fontName), the int take it from the site
or in setting icon on right of download button you can check generate dart class for flutter

How to set a icon for this right click menu?

I can add a new item for the folders right click menu using registry:
HKEY_CLASSES_ROOT\folder\shell\Your item name
But i don't know how to set a icon for created item like this :
May somebody help me?
To create a custom context menu with an icon when clicking on a folder follow these steps:
Under HKEY_CLASSES_ROOT\folder\shell\ create a new key: "MyContextMenu"
Under HKEY_CLASSES_ROOT\folder\shell\MyContextMenu edit the (Default) key to specify the text to show in the context menu: MyMenu
To execute a command when the menu is chosen add a new key name "Command" and set the commmand to execute in it's (Default) value. For instance: cmd.exe
Now to set the icon you add a new string value name Icon and set it's value to the *.ico you want to show or you can reference an ico that is embedded in a dll using [name of the dll],[icon number] A lot of the default windows icons are in imageres.dll. So for this example set the value to: c:\windows\system32\imageres.dll,10
There is a nice tool called iconviewer that you can use to examine icons in dlls. After you install it you can right click a dll, open it's properties and an extra tab with it's icons will be added to the propery pages
You should to add iconpath in this key for showing when the user clicked right button.
Try to write key OpenWithProgIds, and then create value with name (path) of your application.
Example for recycle:
TRegistry *key=new TRegistry(KEY_ALL_ACCESS);
key->RootKey=HKEY_LOCAL_MACHINE;
key->OpenKey("Software\\Classes\\CLSID\\{645FF040-5081-101B-9F08-00AA002F954E}\\shell", false);
key->OpenKey("Prog_name", true);
key->WriteString("Icon", ExtractFileDir(Application->ExeName)+"\\icon_prog.ico");
key->OpenKey("command", true);
key->WriteString("", ExtractFileDir(Application->ExeName)+"\\Program.exe");
key->CloseKey();

Use WatiN for automation upload file on the website

I need upload file on the website.
But Have a problem, i can't choose file automatic in code. Always browser show me choose file window.
What wrong in my code?
IE ie = new IE("https://www.xxxx.com/WFrmlogin.aspx");
FileUploadDialogHandler uploadHandler = new FileUploadDialogHandler(#"D:\065-6405_URGENT.xls");
ie.WaitForComplete();
ie.TextField(Find.ById("txtUser")).TypeText("login");
ie.TextField(Find.ById("txtPassWord")).TypeText("***");
ie.Button(Find.ById("btnok")).Click();
ie.WaitForComplete();
ie.GoTo("https://www.orientspareparts.com/inq/WFrmUpOption.aspx");
ie.WaitForComplete();
ie.DialogWatcher.Clear();
ie.AddDialogHandler(uploadHandler);
// This code show choose file dialog
ie.FileUpload(Find.ById("FilUpload")).ClickNoWait();
ie.Button(Find.ById("butUpload")).Click();
ie.WaitForComplete();
I had the same problem. I'm using a GMail-like upload process, so I wanted to test actual use-cases. Just setting the Text property on my hidden file input wasn't an option.
I ended up using SendKeys to type the path to my file, then sent "{ENTER}" to submit the dialog.
SetForegroundWindow(browser.hWnd);
SendKeys.SendWait("{ENTER}");
Thread.Sleep(500); // An unfortunate necessity, to give the dialog time to pop up.
SendKeys.SendWait(#"C:\myfile.jpg{ENTER}")
I don't love this solution, especially not the sleep, but it was the best I could do in under 30 mins.
If anyone has a better option, let me know!
Why do you need to select from the Dialog? Try to just set the Text:
ie.FileUpload(Find.ById("profile_file")).Text = "C:/Desktop/image.jpg";
I guess you might talk to the fellow who asked this question:
WatiN File Upload

Resources