I am trying to add appointments fetched from the database. I fetch them "manually". I store them in a datatable called dt. The data is present in the datatable.
foreach (Resource r in schedulerStorage1.Resources.Items)
{
Console.WriteLine(r.Caption + " - " + r.Id);
}
Appointment app;
foreach (DataRow dr in result.DataTable_Result.Rows)
{
Console.WriteLine(dr[0] + " - " + dr[1] + " - " + dr[2]);
app = schedulerControl1.Storage.CreateAppointment(AppointmentType.Normal);
app.ResourceId = dr[0];
app.Start = DateTime.Parse(dr[1].ToString());
app.End = DateTime.Parse(dr[2].ToString());
schedulerControl1.Storage.Appointments.Add(app);
}
Output of the Console.WriteLines:
Room1 - 1
Room2 - 2
1 - 16/01/2013 8:00:00 AM - 16/01/2013 8:05:00 AM
1 - 16/01/2013 9:00:00 AM - 16/01/2013 9:05:00 AM
2 - 16/01/2013 8:00:00 AM - 16/01/2013 8:30:00 AM
Any ideas about why the appointments are not added ?
Alright I managed to find out the source of the problem.
dr[0] is the resource id.
When I added a resource I wrote:
r = new Resource(dr[0], dr[1].ToString());
When I added an appointment I wrote:
app.ResourceId = dr[0];
The following will fix the appointments not showing up.
r = new Resource(dr[0].ToString(), dr[1].ToString());
app.ResourceId = dr[0].ToString();
Now everything works perfectly.
Thank you Aphelion for your help. :D
Related
Here is my code for SharePoint.
Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, fileUrl, bstream, false);
isAlreadyExists = false;
var file = clientContext.Web.GetFileByServerRelativeUrl(fileUrl);
clientContext.Load(file);
clientContext.ExecuteQuery();
DateTime dt = DateTime.Now;
Microsoft.SharePoint.Client.ListItem listItem = file.ListItemAllFields;
listItem[Utility.fieldNameSentReceived] = isSentOrReceived;
listItem[Utility.fieldNameSentBy] = msg.From.ToString();
listItem[Utility.fieldNameReceivedBy] = msg.To.ToString();
listItem[Utility.fieldNameSubject] = ((!msg.Subject.Contains("[" + ListCI.Title + "]")) ? "[" + ListCI.Title + "] " : string.Empty) + msg.Subject.ToString();
listItem[Utility.fieldNameSentReceivedDateTime] = dt;
listItem.Update();
clientContext.ExecuteQuery();
CreateCategoryIfNotExist(emailAddress);
SetCategoryToEmail(emailAddress, id);
I tried to update directory list-item(Header of directory).
but it throws exception "Column 'SentORReceived' does not exist. It may have been deleted by another user."
Are you sure that column SentORReceived really exist?
It should be internal name of a column. If you used different name when creating the column and then renamed, you need to use the original one.
I am building an application that accesses meetings from Exchange. I'm using the code provided by Microsoft in their EWS documentation. The issue is I need to access a specific calendar. Say, I create 2 calendars apart from the default one. When I access meetings using this code, I only get meetings from the default calendar. I want to access meetings from a specific calendar. How can I do this?
Thanks for the help.
// Initialize values for the start and end times, and the number of appointments to retrieve.
DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddDays(30);
const int NUM_APPTS = 5;
// Initialize the calendar folder object with only the folder ID.
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
// Set the start and end time and number of appointments to retrieve.
CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
// Retrieve a collection of appointments by using the calendar view.
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);
Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() +
" to " + endDate.Date.ToShortDateString() + " are: \n");
foreach (Appointment a in appointments)
{
Console.Write("Subject: " + a.Subject.ToString() + " ");
Console.Write("Start: " + a.Start.ToString() + " ");
Console.Write("End: " + a.End.ToString());
Console.WriteLine();
}
I think your problem is that you are using WellKnownFolderName.Calendar:
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
Instead you should use the FolderId of the calendar you have created. To get the id of the folder (calendar) you can use the code similar to this (found in answer: https://stackoverflow.com/a/24133821/1037864)
ExtendedPropertyDefinition PR_Folder_Path = new ExtendedPropertyDefinition(26293, MapiPropertyType.String);
PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
psPropSet.Add(PR_Folder_Path);
FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Root, mbMailboxname);
FolderView fvFolderView = new FolderView(1000);
fvFolderView.Traversal = FolderTraversal.Deep;
fvFolderView.PropertySet = psPropSet;
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.FolderClass, "IPF.Appointment");
FindFoldersResults ffoldres = service.FindFolders(rfRootFolderid, sfSearchFilter, fvFolderView);
if (ffoldres.Folders.Count > 0) {
foreach (Folder fld in ffoldres.Folders) {
Console.WriteLine(fld.Id.ToString() + " " + fld.DisplayName);
}
}
Take the value from fld.Id and use instead of WellKnownFolderName.Calendar.
(I don't have an Exchange server available right now to try this out but I hope you get the idea and that my code i correct.)
I am using EPPlus (http://epplus.codeplex.com/) to create Excel files in my ASP.NET application. I was wondering if anyone knows if it's possible to create a dropdownlist with checkboxes in one cell. I've checked the documentation, but found nothing so far. I've also tried Googling it but haven't found anything in the right direction yet.
This question on their forum is actually a pretty good demonstration of what I'm looking for, but it hasn't received any answers: http://epplus.codeplex.com/discussions/585879
Does anyone happen to have any ideas and can point me in the right direction?
You can use:
var validationCell = sheet.DataValidations.AddListValidation("A1");
validationCell.Formula.Values.Add("a");
validationCell.Formula.Values.Add("b");
validationCell.Formula.Values.Add("c");
...
but you can choose only one single value. I think that multiple values are not supported by excel.
For others reference, here is how I could enable multiple values select:
By inserting VBA Code:
see how to do it in here , using EPPlus you can insert VBA code using something like:
package.Workbook.CreateVBAProject();
worksheet.CodeModule.Code = code;
This following code did the trick:
using (var package = new ExcelPackage(new System.IO.FileInfo("D:\\b.xlsm")))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("11");
var validationCell = worksheet.DataValidations.AddListValidation("A1");
validationCell.Formula.Values.Add("a");
validationCell.Formula.Values.Add("b");
validationCell.Formula.Values.Add("c");
string code = "Private Sub Worksheet_Change(ByVal Target As Range)\n" +
"Dim Oldvalue As String\n" +
"Dim Newvalue As String\n" +
"Application.EnableEvents = True\n" +
"On Error GoTo Exitsub\n" +
"If Target.Address = \"$A$1\" Then\n" +
" If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then\n" +
" GoTo Exitsub\n" +
"Else: If Target.Value = \"\" Then GoTo Exitsub Else\n" +
" Application.EnableEvents = False\n" +
"Newvalue = Target.Value\n" +
"Application.Undo\n" +
"Oldvalue = Target.Value\n" +
" If Oldvalue = \"\" Then\n" +
" Target.Value = Newvalue\n" +
"Else\n" +
" If InStr(1, Oldvalue, Newvalue) = 0 Then\n" +
" Target.Value = Oldvalue & \", \" & Newvalue\n" +
"Else: \n" +
" Target.Value = Oldvalue\n" +
"End If\n" +
"End If\n" +
"End If\n" +
"End If\n" +
"Application.EnableEvents = True\n" +
"Exitsub: \n" +
" Application.EnableEvents = True\n" +
"End Sub";
package.Workbook.CreateVBAProject();
worksheet.CodeModule.Code = code;
package.Save();
}
I am currently developing an app which checks one or more users calendars for appointments/meetings under a specific category.
Being new to working with EWS, i have been trying to find a solution as to get a Calendar item (appointment or meeting) by Category or determine if an appointment has a specific category. I currently have the following code so far (exService = ExchangeService object):
foreach (Appointment a in exService.FindItems(WellKnownFolderName.Calendar, new ItemView(int.MaxValue)))
{
//Need to check if appointment has category f.x.: "SMS"
}
Does anybody know a way to acheive this?
Thanks
When your querying Appointments you want to use FindAppointments and a calender-view rather then using FindItems this will ensure that any recurring appointments are expanded eg see https://msdn.microsoft.com/en-us/library/office/dn495614(v=exchg.150).aspx
to use categories all you need to do is something like
DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddDays(60);
const int NUM_APPTS = 1000;
// Initialize the calendar folder object with only the folder ID.
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
// Set the start and end time and number of appointments to retrieve.
CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End,AppointmentSchema.Categories);
// Retrieve a collection of appointments by using the calendar view.
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);
Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() +
" to " + endDate.Date.ToShortDateString() + " are: \n");
foreach (Appointment a in appointments)
{
if (a.Categories.Contains("Green"))
{
Console.Write("Subject: " + a.Subject.ToString() + " ");
Console.Write("Start: " + a.Start.ToString() + " ");
Console.Write("End: " + a.End.ToString());
}
Console.WriteLine();
}
I am learning jQuery. Here I have a requirement i.e I have to add Week number and Week ranges of a year to DropDown List in ASP.NET3.5. And I have to pass selected week range to database. I am using c#.net. This should be done automatically for every year.
How can I do this using JQUERY?
Regards,
JN
try this
function getDateRangeOfWeek(weekNo){
var d1 = new Date();
numOfdaysPastSinceLastMonday = eval(d1.getDay()- 1);
d1.setDate(d1.getDate() - numOfdaysPastSinceLastMonday);
var weekNoToday = d1.getWeek();
var weeksInTheFuture = eval( weekNo - weekNoToday );
d1.setDate(d1.getDate() + eval( 7 * weeksInTheFuture ));
var rangeIsFrom = eval(d1.getMonth()+1) +"/" + d1.getDate() + "/" + d1.getFullYear();
d1.setDate(d1.getDate() + 6);
var rangeIsTo = eval(d1.getMonth()+1) +"/" + d1.getDate() + "/" + d1.getFullYear() ;
return rangeIsFrom + " to "+rangeIsTo;
};
answer is originally from
http://snipplr.com/view/7540/get-date-range-from-week-number-in-year/