Getting PidLidEndRecurrenceDate value using Ews - exchangewebservices

What is the correct way of getting PidLidEndRecurrenceDate values using Ews. below code does not give proper result. property details that i am looking is https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxprops/816378cf-07ef-4926-b7d2-53475792403d
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("X#X.com", "XXX");
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
ItemView view = new ItemView(10);
Guid MyPropertySetId = new Guid("{6ED8DA90-450B-101B-98DA-00AA003F1305}");
int intValue = Convert.ToInt32("0x0000000F", 16);
ExtendedPropertyDefinition extendedPropertyDefinition =
new ExtendedPropertyDefinition(MyPropertySetId, intValue, MapiPropertyType.Integer);
view.PropertySet =
new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, extendedPropertyDefinition);
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Calendar, view);
foreach (Item item in findResults.Items)
{
Console.WriteLine(item.Subject);
if (item.ExtendedProperties.Count > 0)
{
// Display the extended name and value of the extended property.
foreach (ExtendedProperty extendedProperty in item.ExtendedProperties)
{
Console.WriteLine(" Extended Property Name: " + extendedProperty.PropertyDefinition.Name);
Console.WriteLine(" Extended Property Value: " + extendedProperty.Value);
}
}
}

That property is set on the Meeting invite messages only not on the Master instance of the Calendar Appointments which is what you seem to be looking at. For the Master instances you should just be able to use the strongly typed property https://learn.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.recurrence.enddate?redirectedfrom=MSDN&view=exchange-ews-api#Microsoft_Exchange_WebServices_Data_Recurrence_EndDate
It you wanted to view the property you have above search the SentItems Folder for invites with recurrences (with Enddates) and that's where you will see it. Or probably easier just look at the messages with a Mapi editor like OutlookSpy or MFCMAPI and you will see the properties available.

Related

Search for Alarm with name in Cloudwatch

Is it possible to search for an alarm or to check if alarm already exists in CloudWatch using Java api?
I am currently doing this way but it doesnt look promising to me.
long offsetInMilliseconds = 1000 * 60 * 60 * 24;
Dimension instanceDimension = new Dimension();
instanceDimension.setName("InstanceId");
instanceDimension.setValue("i-201cb891");
//Check is Alarms with name exist.
GetMetricStatisticsRequest getMetricStatisticsRequest = new GetMetricStatisticsRequest()
.withStartTime(new Date(new Date().getTime() - offsetInMilliseconds))
.withNamespace("AWS/EC2")
.withPeriod(60 * 60)
.withMetricName("StatusCheckFailed")
.withStatistics("Average")
.withDimensions(Arrays.asList(instanceDimension))
.withEndTime(new Date());
GetMetricStatisticsResult getMetricStatisticsResult = cloudWatch.getMetricStatistics(getMetricStatisticsRequest);
System.out.println("" + getMetricStatisticsResult.getDatapoints().size());
if(getMetricStatisticsResult.getDatapoints().size() == 0) {
PutMetricAlarmRequest request = new PutMetricAlarmRequest()
.withActionsEnabled(true).withAlarmName("i-201cb891")
.withComparisonOperator(ComparisonOperator.GreaterThanOrEqualToThreshold)
.withDimensions(Arrays.asList(instanceDimension))
// .withAlarmActions(getTopicARN())
.withEvaluationPeriods(1)
.withPeriod(60)
.withThreshold(60.0D)
.withStatistic(Statistic.Average)
.withMetricName("StatusCheckFailed")
.withNamespace("AWS/EC2");
cloudWatch.putMetricAlarm(request);
System.out.println("Alarm created for Instance with ID : " + "i-201cb891");
}else{
System.out.println("Alarm exists with name : " + "i-201cb891");
}
You can use AmazonCloudWatch interface to query for your alarms.
From AmazonCloudWatch API:
DescribeAlarmsResult describeAlarms(DescribeAlarmsRequest describeAlarmsRequest)
You can use this method to query for your alarms by name or by prefix, for instance.
The following code snippet shows how to use the API:
...
AmazonCloudWatch client = new AmazonCloudWatchClient(new ProfileCredentialsProvider());
DescribeAlarmsRequest request = new DescribeAlarmsRequest();
List<String> alarmNames = new ArrayList<String>();
alarmNames.add("alarmName1");
alarmNames.add("alarmName2");
request.setAlarmNames(alarmNames);
DescribeAlarmsResult result = client.describeAlarms(request);
List<MetricAlarm> alarms = result.getMetricAlarms();
for (MetricAlarm alarm : alarms) {
System.out.println(alarm.getAlarmName());
}
...
AWS SDK for Java API Reference - 1.10.43

F#: DataContractJsonSerializer.WriteObject method

I am new to programming and F# is my first language.
Here are the relevant parts of my code:
let internal saveJsonToFile<'t> (someObject:'t) (filePath: string) =
use fileStream = new FileStream(filePath, FileMode.OpenOrCreate)
(new DataContractJsonSerializer(typeof<'t>)).WriteObject(fileStream, someObject)
let dummyFighter1 = { id = 1; name = "Dummy1"; location = "Here"; nationality = "Somalia"; heightInMeters = 2.0; weightInKgs = 220.0; weightClass = "Too fat"}
let dummyFighter2 = { id = 2; name = "Dummy2"; location = "There"; nationality = "Afghanistan"; heightInMeters = 1.8; weightInKgs = 80.0; weightClass = "Just Nice"}
let filePath = #"G:\User\Fighters.json"
saveJsonToFile dummyFighter1 filePath
saveJsonToFile dummyFighter2 filePath
When I run "saveJsonToFile dummyFighter1 filePath", the information is successfully saved. My problem is this: Once I run "saveJsonToFile dummyFighter2 filePath", it immediately replaces all the contents that are already in the file, i.e., all the information about dummyFighter1.
What changes should I make so that information about dummyFighter2 is appended to the file, instead of replacing information about dummyFighter1?
Change the way you open a file setting FileMode.OpenOrCreate to FileMode.Append. Append means "create or append" :
use fileStream = new FileStream(filePath, FileMode.Append)
From MSDN (https://msdn.microsoft.com/fr-fr/library/system.io.filemode%28v=vs.110%29.aspx) :
FileMode.Append opens the file if it exists and seeks to the end of the file, or
creates a new file. This requires FileIOPermissionAccess.Append
permission. FileMode.Append can be used only in conjunction with
FileAccess.Write. Trying to seek to a position before the end of the
file throws an IOException exception, and any attempt to read fails
and throws a NotSupportedException exception.

Get Row Count for Data Transferred using EzAPI SSIS

I am transferring some data from one table to another using SSIS with EzAPI. How can I get the number of rows that were transferred?
My setup is as follows
EzPackage package = new EzPackage();
EzOleDbConnectionManager srcConn;
EzOleDbSource src;
EzOleDbConnectionManager destConn;
EzOleDbDestination dest;
EzDataFlow dataFlow;
destConn = new EzOleDbConnectionManager(package); //set connection string
srcConn = new EzOleDbConnectionManager(package);
dataFlow = new EzDataFlow(package);
src = Activator.CreateInstance(typeof(EzOleDbSource), new object[] { dataFlow }) as EzOleDbSource;
src.Connection = srcConn;
src.SqlCommand = odbcImport.Query;
dest = Activator.CreateInstance(typeof(EzOleDbDestination), new object[] { dataFlow }) as EzOleDbDestination;
dest.Connection = destConn;
dest.AttachTo(src, 0, 0);
dest.AccessMode = AccessMode.AM_OPENROWSET_FASTLOAD;
DTSExecResult result = package.Execute();
Where in this can I add something to get the number of rows? For all versions of SQL server 2008r2 and up
The quick answer is that the Row Count Transformation isn't included out of the box. I had a brief post about that: Row Count with EzAPI
I downloaded the source project from CodePlex and then edited EzComponents.cs (in EzAPI\src) and added the following code
[CompID("{150E6007-7C6A-4CC3-8FF3-FC73783A972E}")]
public class EzRowCountTransform : EzComponent
{
public EzRowCountTransform(EzDataFlow dataFlow) : base(dataFlow) { }
public EzRowCountTransform(EzDataFlow parent, IDTSComponentMetaData100 meta) : base(parent, meta) { }
public string VariableName
{
get { return (string)Meta.CustomPropertyCollection["VariableName"].Value; }
set { Comp.SetComponentProperty("VariableName", value); }
}
}
The component id above is only for 2008.
For 2012, it's going to be E26997D8C-70DA-42B2-8208-A19CE3A9FE41 I don't have a 2012 installation at the moment to confirm I didn't transpose a value there but drop a Row Count component onto a data flow, right click and look at the properties. The component/class id is what that value needs to be. Similar story if you're dealing with 2005.
So, once you have the ability to use EzRowCountTransform, you can simply patch it into your existing script.
// Create an instance of our transform
EzRowCountTransform newRC = null;
// Create a variable to use it
Variable newRCVariable = null;
newRCVariable = package.Variables.Add("RowCountNew", false, "User", 0);
// ...
src.SqlCommand = odbcImport.Query;
// New code here too
newRC = new EzRowCountTransform(dataFlow);
newRC.AttachTo(src);
newRC.Name = "RC New Rows";
newRC.VariableName = newRCVariable.QualifiedName;
// Continue old code
I have a presentation on various approaches I've used over time and what I like/don't like about them. Type more, click less: a programmatic approach to building SSIS. It contains sample code for creating the EzRowCountTransform and usage.

Html e-mail not being updated fast enough for smtp

Is there a known issue with SMTP and timing? I have included some code below that basically sends a birthday greeting to someone, along with a horoscope and other people that share their birthday (for fun).
I use Regex replace to get both elements, horoscope and other people, from other methods and insert them into the HTML document between a pair of "p" tags. I am positive that those methods work, and I am positive that the HTML document is being properly reformatted (according to the console, which prints out my new HTML document in another test of mine). I am thinking that maybe my problem is that the e-mail is sent off before the replacement has a chance to happen, but I could very easily be was off base. If anyone has had this issue before or knows the cause of it, I would be very appreciative. TIA.
public void formatHTMLTest()
{ using (StreamReader reader = File.OpenText("../../BirthdayMessage.htm"))
{
//Format the body
//Format the Famous People
string html = reader.ReadToEnd();
string replacePattern1 = "<!--INJECT FAMOUS PEOPLE HERE-->";
List<string> famousPeople = new List<string>();
famousPeople.Add("test1");
famousPeople.Add("test2");
famousPeople.Add("test3");
StringBuilder famousSB = new StringBuilder();
foreach (string person in famousPeople)
{
famousSB.Append(person + ", ");
}
int length = famousSB.Length;
famousSB.Remove(length - 2, 2);
string famousString = famousSB.ToString();
string html1 = Regex.Replace(html, replacePattern1, famousString);
//Format the Horoscope
string horoscope = "FOO.";
string replacePattern2 = "<!--INJECT HOROSCOPE HERE-->";
string html2 = Regex.Replace(html1, replacePattern2, horoscope);
//Configuring the SMTP client
SmtpClient smtp = new SmtpClient();
smtp.Port = 25;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("barfoo#sender.com", "senderPass");
smtp.Host = "mysmtp";
//Set up email that is sent to the client
MailMessage clientEmail = new MailMessage();
clientEmail.From = new System.Net.Mail.MailAddress("barfoo#sender.com");
clientEmail.To.Add(new MailAddress("foobar#recipient.com"));
clientEmail.Subject = "Happy Birthday!";
clientEmail.IsBodyHtml = true;
clientEmail.Body = html;
//using (smtp as IDisposable)
{
smtp.Send(clientEmail);
clientEmail.Dispose();
}
}
}
I guess this goes without saying since I was able to get an e-mail, but just for clarity's sake, the SMTP has no issues also. I am fully able to receieve e-mails. The issue is that they do not contain the replaced html that appears in my console for other tests.
Also, any other things you see wrong with this code (optimizations, etc), don't hesitate to comment. I'm always willing to learn! Thanks
You are injecting the string html into the body. It should be html2?

Linq-to-SQL with a table valued UDF user defined function

I am new to Linq and trying to get a handle on how to bind a drop down to a SQL user defined function.
//Populate the Pledge dropdown
var db = new App_Data.MyDBDataContext();
int? partnerID = Convert.ToInt32(Request.QueryString["PartnerID"]);
var pledges =
from p in db.ufn_AvailablePledgesByPartner(partnerID)
select new
{
PledgeAndPartnerName = p.PledgeAndPartnerName,
PledgeID = p.PledgeID
};
DropDownList ddlPledgeID = (DropDownList)DetailsViewContribution.FindControl("DropDownListPledgeID");
ddlPledgeID.DataSource = pledges;
ddlPledgeID.DataTextField = pledges.PledgeAndPartnerName;
ddlPledgeID.DataValueField = pledges.PledgeID;
The current problem is the last 2 lines where I'm trying to reference properties of the anonymous class. "'System.Linq.IQueryable' does not contain a definition for 'PledgeAndPartnerName' and no extension method..." I naively thought the compiler was supposed to figure this out, but obviously I'm assuming C# is now more dynamic than it really is.
Thanks for any input.
Try this:
ddlPledgeID.DataTextField = "PledgeAndPartnerName";
ddlPledgeID.DataValueField = "PledgeID";