Dynamically Add a Timestamp To Files in Azure Data Flow - azure

I've been working on a azure project, and I want to create a dataflow using a dynamic filename that contains timestamp.
for example , if the output is a file name 'A' --> 'A_YY-mm-dd_hh_mm_ss'
I already did that on a data factory using this link Here
but in this case I don't know how could I use it.
there is my data flow
The input is an extract file( i did it with a copy data)

You can refer this code. I tried to modify the filenamePrefixForWindow method and I was able to achieve this. These were the changes I made -
public String filenamePrefixForWindow(IntervalWindow window) {
Calendar calendar = Calendar.getInstance();
String year = String.valueOf(calendar.get(Calendar.YEAR));
String month = String.format("%02d",(calendar.get(Calendar.MONTH)+1));
String date = String.format("%02d",calendar.get(Calendar.DATE));
int hh = calendar.get(Calendar.HOUR);
String hour = String.format("%02d",(calendar.get(Calendar.AM_PM) == 0) ? hh:hh+12);
String minute = String.format("%02d",calendar.get(Calendar.MINUTE));
String full_date = year+"-"+month+"-"+date+"-"+hour+"-"+minute;
String prefix =
baseFilename.isDirectory() ? "" : baseFilename.getFilename();
return String.format(
"%s/%s/%s/%s/%s/output-%s", prefix,year,month,date,hour,full_date);
}

Related

How to force Azure Storage Table to save DateTime in specified format

I am saving a DateTime value into Azure Table Storage. The DateTime is being parsed from unix milliseconds format like so:
DateTimeOffset.FromUnixTimeMilliseconds(milliseconds).UtcDateTime;
When I look into the table via storage explorer the DateTimes have variable length.
See Image
I was trying find out how to force the table to store the date in the following format but I wasn't able to find a way:
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"
Is there a way to force the desired format? Thanks
I was trying find out how to force the table to store the date in the
following format but I wasn't able to find a way: "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'" Is there a way to force the desired format? Thanks
This is not possible to force on Azure Table Storage. You can apply this type of logic on application code level.
Like application level you can set.
internal class Program
{
static string storageconn = "DefaultEndpointsProtocol=https;AccountName=storageaccount87819573y6;AccountKey=xxxxx;EndpointSuffix=core.windows.net";
static string table = "Datetimetable";
static string partitionkey = "Debasis Saha";
static string rowKey = "userC";
static void Main(string[] args)
{
Microsoft.Azure.Cosmos.Table.CloudStorageAccount storageAcc = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(storageconn);
Microsoft.Azure.Cosmos.Table.CloudTableClient tblclient = storageAcc.CreateCloudTableClient(new TableClientConfiguration());
Microsoft.Azure.Cosmos.Table.CloudTable table1 = tblclient.GetTableReference(table);
Console.ReadKey();
string datetime = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
Console.WriteLine(datetime);
Console.ReadKey();
}
Output :- you can pass this datetime to Azure Table Storage.

How to remove time from date and time

In DOB i am getting date and time but i need only date
foreach (DataRow row in ProfileDt.Rows)
{
UserProfileData.FirstName = row["FirstName"].ToString();
UserProfileData.LastName = row["LastName"].ToString();
UserProfileData.Email = row["Email"].ToString();
UserProfileData.Address = row["HouseNo"].ToString();
UserProfileData.City = row["CityName"].ToString();
UserProfileData.date = row["DOB"].ToString();
}
If your database is giving you a string then you'll need to parse it to a date then back to a string with the desired date format.
string dateFormat = "MM/DD/YYYY HH:mm:ss" // REPLACE WITH THE CORRECT FORMAT
UserProfileData.date = DateTime.ParseExact(row["DOB"].ToString(), dateFormat ,
System.Globalization.CultureInfo.InvariantCulture).ToString("MM/DD/YYYY");
If your database is giving you a datetime directly (which is the better solution) then it becomes even easier.
UserProfileData.date = ((DateTime)row["DOB"]).ToString("MM/DD/YYYY");
Convert your string to DateTime type and use Date property, something like yourDate.Date
You can use DateTime.Parse or DateTime.ParseExact for parsing string to DateTime
It also make sense to return DateTime type directly from database so you do not need any conversions...

how to retrieve multiple properties using #NameLookup in lotus notes

I am using #NameLookUp formula to retrieve internet address by giving a search key and it is working fine.But now i want to retrive not only the internet address but also some other properties like FirstName and LastName.
Here is the formula i am using to #Namelookup internet address by giving search string.
Vector vec=m_session.evaluate("#NameLookup([NoUpdate];\""+ userName + "\"; \"InternetAddress\")");
//username is the String variable(Search Criteria)
Can anyone please help how to retrieve multiple properties(like firstName and lastName along with InternetAddress) by evaluate the formula only once. If it cant be done using #Namelookup is there any other way..?
This is a typical example when using evaluate() to call a Formula is not a good idea.
What you want to do is to get the NotesDocument class and read values from it.
Something like this (disclaimer, I am not a Java developer):
// Open Domino Directory on specified server
Database db = session.getDatabase("YourServer/Domain", "names.nsf");
// Get a view with user name is sorted first column
View view = db.getView("($Users)");
// Get the person document for specified user
Document doc = view.getDocumentByKey(userName, true);
if (doc != null) {
// Get text values from Notes document
String emailAddress = doc.getItemValueString("InternetAddress");
String officePhone = doc.getItemValueString("OfficeNumber");
String officeAddress = doc.getItemValueString("OfficeStreetAddress");
}
I believe this would be faster than multiple lookups using evaluate(), and you also have the added benefit of full error handling, and all being native code.
#NameLookup only returns the value of one item per call.
Assuming your goal is to only have one Evaluate statement, you could chain the calls together and return an array of values in a certain order:
Vector vec=m_session.evaluate("FirstName := #NameLookup([NoUpdate];\""+ userName + "\"; \"FirstName\"); LastName:= #NameLookup([NoUpdate];\""+ userName + "\"; \"LastName\"); InternetAddress :=#NameLookup([NoUpdate];\""+ userName + "\"; \"InternetAddress\"); FirstName:LastName:InternetAddress");
Or possibly:
String firstName = m_session.evaluate("#NameLookup([NoUpdate];\""+ userName + "\"; \"FirstName\")");
String lastName = m_session.evaluate("#NameLookup([NoUpdate];\""+ userName + "\"; \"LastName\")");
String internetAddress = m_session.evaluate("#NameLookup([NoUpdate];\""+ userName + "\"; \"InternetAddress\")");
And then add those three strings in any order into your Vector.
Another approach is to use the DirectoryNavigator class. I believe it's been available since Notes/Domino 8.5 (perhaps even before that). DirectoryNavigator uses some of the same core logic as #NameLookup, so it should perform well.
Here's some sample code. I haven't tested this exact code, but I adapted it from production code that does a similar lookup:
String firstName = null;
String lastName = null;
String inetAddress = null;
Vector<String> lookupItems = new Vector<String>();
lookupItems.addElement("FirstName");
lookupItems.addElement("LastName");
lookupItems.addElement("InternetAddress");
Vector<String> vName = new Vector<String>();
vName.addElement(userName);
Directory dir = session.getDirectory();
DirectoryNavigator dirNav = dir.lookupNames("($Users)", vName, lookupItems, true);
if( dirNav != null && dirNav.getCurrentMatches() != 0 ) {
// Digest the results of the lookup
Vector<String> value = null;
value = dirNav.getFirstItemValue();
firstName = value.elementAt(0);
value = dirNav.getNextItemValue();
lastName = value.elementAt(0);
value = dirNav.getNextItemValue();
inetAddress = value.elementAt(0);
}

CoSign API: Setting Date Format Using DSS Web Service

I'm running into a problem when trying to specify the date format for a signature field using the DSS web service. Here is my code:
Req = new RequestBaseType();
Req.OptionalInputs = new RequestBaseTypeOptionalInputs();
Req.OptionalInputs.SAPISigFieldSettings = new SAPISigFieldSettingsType();
TimeDateFormatType tf = new TimeDateFormatType();
tf.DateFormat = "dd MMM yyyy";
Req.OptionalInputs.SAPISigFieldSettings.TimeFormat = tf;
I attempt to sign the document as follows:
DSS service = new DSS();
service.Url = "https://cosign:8080/sapiws/dss.asmx";
SignRequest sreq = new SignRequest();
sreq.InputDocuments = Req.InputDocuments;
sreq.OptionalInputs = Req.OptionalInputs;
Resp = service.DssSign(sreq);
And I get the following response from the ResponseBaseType object:
urn:oasis:names:tc:dss:1.0:resultmajor:Insufficient Information Error parsing OptionalInput SAPISigFieldSettings
If I don't specify the date format, it works OK. Any ideas?
Even though you want to display just the date and not the time, you need to set TimeFormat to an empty string. It is null by default.

Converting String to datefield / Java Microedition

Using J2ME, netbeans 7.2, Developing a mobile app..
I have converted the Datefield value to a String and Now want to put it back to a Datefield. To do this I need to convert the String back to Datefield, I am using the following code but its not happening.
long myFileTime = dateField.getDate().getTime(); // getting current/set date from the datefield into long
String date = String.valueOf(myFileTime); // converting it to a String to put it back into a different datefield
Date updatedate= stringToDate(date); // passing the string 'date' to the Method stringToDate() to convert it back to date.
dateField1.setDate(updatedate); // updating the date into the new datefield1
public Date stringToDate(String s)
{
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH, Integer.parseInt(s.substring(0, 2)));
c.set(Calendar.MONTH, Integer.parseInt(s.substring(3, 5)) - 1);
c.set(Calendar.YEAR, Integer.parseInt(s.substring(6, 10)));
return c.getTime();
}
Since you have mentioned that you have the long myFileTime around, you should be able to use:
Date updatedate=new Date(myFileTime);
To convert back to your date. If only your String is available, you should modify your function to this:
public Date stringToDate(String s){
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH, Integer.parseInt(s.substring(0, 2)));
c.set(Calendar.MONTH, Integer.parseInt(s.substring(2, 4))-1 );
c.set(Calendar.YEAR, Integer.parseInt(s.substring(4, 8)));
return c.getTime();
}
Note the changed indexes.
In Java SE, you should be able to use the following line, instead of setting each fields separately:
c.setTimeInMillis(Long.parseLong(s));
Since in s you have the dateField.getDate().getTime() that is equal to myFileTime, the number of seconds starting with January 1, 1970, based on your provided code.
Your stringToDate should work only if your string will have the following format: ddMMyyyy. Also note that in this case you should use a SimpleDateFormat to parse, something like:
Date updatedate = new java.text.SimpleDateFormat("ddMMyyyy HH:mm:ss").parse(date);

Resources