private void AddExistingUsers() { try { System.Data.DataSet dsUserInfo = ClsCalender.getAllUsersInfo(); foreach (DataRow dr in dsUserInfo.Tables[0].Rows) { ListBoxItem lstItem = new ListBoxItem(); Int64 myid = Int64.Parse(dr["ID"].ToString()); if (myid != userID) { lstItem.Content = dr["DisplayName"]; lstItem.Tag = dr["EMail"]; lstItem.Tag += ":" + dr["ID"]; lstItem.ToolTip = dr["EMail"]; lstExistingUserList.Items.Add(lstItem); } } } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "AddExistingUsers()", "ctlAddEvent.xaml.cs"); } }
//StringBuilder sb1 = CreateTressInfo(); public ctlAddEvent() { try { InitializeComponent(); userID = VMuktiAPI.VMuktiInfo.CurrentPeer.ID; AddExistingUsers(); ///// Populates the Country list for timezone dsTimeZone = ClsCalender.getCountry_Timezone(); //foreach (DataRow drTimeZone in dsTimeZone.Tables[0].Rows) //{ // if (!cmbCountryTimeZone.Items.Contains(drTimeZone["Country"])) // cmbCountryTimeZone.Items.Add(drTimeZone["Country"]); //} //cmbCountryTimeZone.SelectedIndex = 0; } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "ctlAddEvent()", "ctlAddEvent.xaml.cs"); } }
private Int64 CreateNewUser(string username, string email) { string userName = username; string Email = email; string newUserId = ""; string password = ""; string[] userNameSplit = userName.Trim().Split(' '); try { if (userNameSplit.Length == 1) { newUserId = userName.Trim().ToLower(); } else if (userNameSplit.Length == 2) { if (userNameSplit[0].Trim().Length > 1) newUserId = userNameSplit[0].Trim().ToLower() + "." + userNameSplit[1].Trim().ToLower(); else newUserId = userNameSplit[0].Trim().ToLower() + userNameSplit[1].Trim().ToLower(); } else if (userNameSplit.Length == 3) { if (userNameSplit[0].Trim().Length > 1 && userNameSplit[1].Trim().Length >= 1) newUserId = userNameSplit[0].Trim().ToLower() + "." + userNameSplit[2].Trim().ToLower(); else if (userNameSplit[1].Trim().Length == 1) newUserId = userNameSplit[0].Trim().ToLower() + userNameSplit[1].Trim().ToLower() + userNameSplit[2].Trim().ToLower(); } newUserId = newUserId.ToLower(); password = GetPassword(); string userIdFinal = newUserId + GenerateRandomNumber(); bool UserIDExists = true; while (UserIDExists == true) { if (ClsCalender.IsUserIDExist(userIdFinal)) { userIdFinal = newUserId + GenerateRandomNumber(); UserIDExists = true; } else { UserIDExists = false; return ClsCalender.addNewUser(userName, userIdFinal, password, Email); } } return -1; } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "CreateNewUser()", "ctlAddEvent.xaml.cs"); return -1; } }
public void sendInvitesToAll() { ClsCalender objCal = new ClsCalender(); DataRow drConf = ClsCalender.getConferenceDetails(confID).Tables[0].Rows[0]; for (int i = 0; i < lstInvitedUserList.Items.Count; i++) { ListBoxItem lstItem = new ListBoxItem(); lstItem = (ListBoxItem)lstInvitedUserList.Items.GetItemAt(i); string guestname = lstItem.Content.ToString(); string[] tagSplit = lstItem.Tag.ToString().Split(':'); Int64 guestID = Int64.Parse(tagSplit[1]); string email = tagSplit[0]; objCal.ConferenceID = confID; objCal.Email = email; objCal.CreatedBy = userID; objCal.ModifiedBy = userID; if (guestID == -99) { try { Int64 uid = CreateNewUser(guestname, email); DataRow drUinfo = ClsCalender.getUserInfoForMail(uid).Tables[0].Rows[0]; string newuserid = drUinfo["DisplayName"].ToString(); string pwd = drUinfo["Password"].ToString(); objCal.GuestName = newuserid; string[] stotaltimeSplit = drConf["StartDateTime"].ToString().Split(' '); string sdate1 = stotaltimeSplit[0]; string stime1 = stotaltimeSplit[1] + " " + stotaltimeSplit[2]; string[] etotaltimeSplit = drConf["EndDateTime"].ToString().Split(' '); string edate1 = etotaltimeSplit[0]; string etime1 = etotaltimeSplit[1] + " " + etotaltimeSplit[2]; string strUri = VMuktiAPI.VMuktiInfo.ZipFileDownloadLink.ToString(); if (dtpStartDate.Text.Equals(dtpendate.Text)) SendEmailTo(email, "VMukti Meeting/Conference Invitation: " + drConf["ConfTitle"].ToString(), "<br/><br/>You are invited for the following Conference/Meeting. <br/><br/><br/><b>Title:</b> " + drConf["ConfTitle"].ToString() + "<br/><br/>" + "<b>Description:</b> " + drConf["ConferenceDetail"].ToString() + "<br/><br/><b>Location:</b> " + drConf["ConferenceLocation"].ToString() + "<br/><br/><b>Meeting/Conference Type:</b> " + drConf["ConferenceType"].ToString() + "<br/><br/><br/><br/><b>Date:</b> " + sdate1 + "<br/><br/><b>Start Time:</b> " + stime1 + "<br/><br/><b>End Time:</b> " + etime1 + " <br/><br/><b>Default TimeZone:</b> " + drConf["Timezone"] + "<br/><br/><b>Your Login Information is as follows:</b><br/><b>Username:</b> " + newuserid + "<br><b>Password:</b> " + pwd + "<br><br><b>URI:</b> "+strUri+"<br><br><br>"); else SendEmailTo(email, "VMukti Meeting/Conference Invitation: " + drConf["ConfTitle"].ToString(), "<br/><br/>You are invited for the following Conference/Meeting. <br/><br/><br/><b>Title:</b> " + drConf["ConfTitle"].ToString() + "<br/><br/>" + "<b>Description:</b> " + drConf["ConferenceDetail"].ToString() + "<br/><br/><b>Location:</b> " + drConf["ConferenceLocation"].ToString() + "<br/><br/><b>Meeting/Conference Type:</b> " + drConf["ConferenceType"].ToString() + "<br/><br/><br/><br/><b>Start Date:</b> " + sdate1 + "<br/><br/><b>Start Time:</b> " + stime1 + "<br/><br/><br/><b>End Date:</b> " + edate1 + "<br/><br/><b>End Time:</b> " + etime1 + " <br/><br/><b>Default TimeZone:</b> " + drConf["Timezone"] + "<br/><br/><b>Your Login Information is as follows:</b><br/><b>Username:</b> " + newuserid + "<br><b>Password:</b> " + pwd + "<br><br><b>URI:</b> " + strUri + "<br><br><br>"); ClsCalender.setEmailStatusOfConferenceGuest(newuserid, email, "Sent"); // if (guestID != -99) ClsCalender.addConferenceUsers(confID, uid); objCal.SaveGuest(confID); } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "sendInvitesToAll()--if--", "ctlAddEvent.xaml.cs"); } } else { objCal.GuestName = guestname; objCal.SaveGuest(confID); DataRow drConfGuest = ClsCalender.getConferenceGuest(guestname, email).Tables[0].Rows[0]; string emailStatus = drConfGuest["EmailStatus"].ToString(); try { objCal.GuestName = guestname; string[] stotaltimeSplit = drConf["StartDateTime"].ToString().Split(' '); string sdate1 = stotaltimeSplit[0]; string stime1 = stotaltimeSplit[1] + " " + stotaltimeSplit[2]; string[] etotaltimeSplit = drConf["EndDateTime"].ToString().Split(' '); string edate1 = etotaltimeSplit[0]; string etime1 = etotaltimeSplit[1] + " " + etotaltimeSplit[2]; string strUri = VMuktiAPI.VMuktiInfo.ZipFileDownloadLink.ToString(); if (dtpStartDate.Text.Equals(dtpendate.Text)) //Email sended to invited users(email, ConfTitle) SendEmailTo(email, "VMukti Meeting/Conference Invitation: " + drConf["ConfTitle"].ToString(), "<br/><br/>You are invited for the following Conference/Meeting. <br/><br/><br/><b>Title:</b> " + drConf["ConfTitle"].ToString() + "<br/><br/>" + "<b>Description:</b> " + drConf["ConferenceDetail"].ToString() + "<br/><br/><b>Location:</b> " + drConf["ConferenceLocation"].ToString() + "<br/><br/><b>Meeting/Conference Type:</b> " + drConf["ConferenceType"].ToString() + "<br/><br/><br/><br/><b>Date:</b> " + sdate1 + "<br/><br/><b>Start Time:</b> " + stime1 + "<br/><br/><b>End Time:</b> " + etime1 + "<br/><br/><b>Default TimeZone:</b> " + drConf["Timezone"] + "<br><br><b>URI:</b> " + strUri + "<br/><br/><br/>"); else SendEmailTo(email, "VMukti Meeting/Conference Invitation: " + drConf["ConfTitle"].ToString(), "<br/><br/>You are invited for the following Conference/Meeting. <br/><br/><br/><b>Title:</b> " + drConf["ConfTitle"].ToString() + "<br/><br/>" + "<b>Description:</b> " + drConf["ConferenceDetail"].ToString() + "<br/><br/><b>Location:</b> " + drConf["ConferenceLocation"].ToString() + "<br/><br/><b>Meeting/Conference Type:</b> " + drConf["ConferenceType"].ToString() + "<br/><br/><br/><br/><b>Start Date:</b> " + sdate1 + "<br/><br/><b>Start Time:</b> " + stime1 + "<br/><br/><br/><b>End Date:</b> " + edate1 + "<br/><br/><b>End Time:</b> " + etime1 + "<br/><br/><b>Default TimeZone:</b> " + drConf["Timezone"] + "<br><br><b>URI:</b> " + strUri + "<br/><br/><br/>"); ClsCalender.setEmailStatusOfConferenceGuest(guestname, email, "Sent"); // if (guestID != -99) ClsCalender.addConferenceUsers(confID, guestID); objCal.SaveGuest(confID); } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "sendInvitesToAll()--else--", "ctlAddEvent.xaml.cs"); } } } for (int j = 0; j < lstExistingUserList.Items.Count; j++) { ListBoxItem lstItem1 = new ListBoxItem(); lstItem1 = (ListBoxItem)lstExistingUserList.Items.GetItemAt(j); string guestname1 = lstItem1.Content.ToString(); string[] tagSplit1 = lstItem1.Tag.ToString().Split(':'); Int64 guestID1 = Int64.Parse(tagSplit1[1]); string email1 = tagSplit1[0]; ClsCalender.deleteUnInvitedConferenceGuest(guestname1, email1); // if (guestID != -99) // { ClsCalender.deleteConferenceUsers(confID, guestID1); // } } MessageBox.Show("Mail has been sent to all the invited users"); }
public void SendEmailTo(string To, string Subject, string msg) { try { ClsException.WriteToLogFile("Calender: User sending Email"); ClsException.WriteToLogFile("Email Sending," + To + "," + Subject + "," + msg); if (SMTPServer.Equals("") || SMTPPort != -1 || SMTPUserName.Equals("") || SMTPPassword.Equals("")) { DataSet dsSMTP = ClsCalender.getSMTPCredentials(); foreach (DataRow drSMTP in dsSMTP.Tables[0].Rows) { string fieldName = drSMTP["FieldName"].ToString(); switch (fieldName) { case "SMTPServer": { SMTPServer = drSMTP["FieldValue"].ToString(); break; } case "SMTPPort": { SMTPPort = int.Parse(drSMTP["FieldValue"].ToString()); break; } case "SMTPUserName": { SMTPUserName = drSMTP["FieldValue"].ToString(); break; } case "SMTPPassword": { SMTPPassword = drSMTP["FieldValue"].ToString(); break; } default: break; } } } if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithHttp) { clsMailInfo objMail = new clsMailInfo(); objMail.strFrom = SMTPUserName; objMail.strTo = To; objMail.strSubject = Subject; objMail.strMsg = msg; objMail.strServer = SMTPServer; objMail.intPort = SMTPPort; objMail.strPwd = SMTPPassword; clsMailDBClient.chHttpMailDBService.svcSendMail(objMail); } else { System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage(); mailMsg.From = new System.Net.Mail.MailAddress(SMTPUserName); mailMsg.To.Add(To); mailMsg.Subject = Subject; mailMsg.SubjectEncoding = System.Text.Encoding.UTF8; mailMsg.Body = msg; mailMsg.BodyEncoding = System.Text.Encoding.UTF8; mailMsg.Priority = System.Net.Mail.MailPriority.High; mailMsg.IsBodyHtml = true; System.Net.Mail.SmtpClient SmtpMail = new System.Net.Mail.SmtpClient(SMTPServer, SMTPPort); SmtpMail.Credentials = new System.Net.NetworkCredential(SMTPUserName, SMTPPassword); SmtpMail.EnableSsl = true; SmtpMail.Send(mailMsg); } } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "SendEmailTo()", "ctlAddEvent.xaml.cs"); } }
private void button1_Click(object sender, RoutedEventArgs e) { try { if (isvalidate()) { // DateTime dsStart = new DateTime(int.Parse(dtpStartDate.Value.Value.Year.ToString()), int.Parse(dtpStartDate.Value.Value.Month.ToString()), int.Parse(dtpStartDate.Value.Value.Day.ToString()), int.Parse(cmbstarttimeh.Text), int.Parse(cmbstarttimem.Text), 0); // DateTime dsEnd = new DateTime(int.Parse(dtpendate.Value.Value.Year.ToString()), int.Parse(dtpendate.Value.Value.Month.ToString()), int.Parse(dtpendate.Value.Value.Day.ToString()), int.Parse(cmbendtimeh.Text), int.Parse(cmbendtimem.Text), 0); ClsCalender objCal = new ClsCalender(); objCal.ID = -1; objCal.ConfTitle = txtWhat.Text; // MessageBox.Show(dtpStartDate.Text); string tmpDate = dtpStartDate.Text; string[] splittmpDate = tmpDate.Split('/'); tmpDate = splittmpDate[1] + "/" + splittmpDate[0] + "/" + splittmpDate[2]; objCal.StartDateTime = DateTime.Parse(tmpDate + " " + cmbstarttimeh.Text + ":" + cmbstarttimem.Text + " " + cmbstartap.Text); // objCal.StartDateTime = dsStart; DateTime dsStart = objCal.StartDateTime; tmpDate = dtpendate.Text; splittmpDate = tmpDate.Split('/'); tmpDate = splittmpDate[1] + "/" + splittmpDate[0] + "/" + splittmpDate[2]; objCal.EndDateTime = DateTime.Parse(tmpDate + " " + cmbendtimeh.Text + ":" + cmbendtimem.Text + " " + cmbendtimeap.Text); DateTime dsEnd = objCal.EndDateTime; // objCal.EndDateTime = dsEnd; DataTable dtMeetingBetween = ClsCalender.getMeetingsBetween(userID, dsStart, dsEnd).Tables[0]; if (dtMeetingBetween.Rows.Count == 0) { if (chkallday.IsChecked == true) { objCal.IsAllDay = true; } else objCal.IsAllDay = false; objCal.RepeatType = cmbrepeats.Text; objCal.HostId = userID; objCal.ConferenceLocation = txtwhere.Text; objCal.ConferenceDetail = txtdescription.Text; //objCal.Country = cmbCountryTimeZone.SelectedValue.ToString().Trim(); objCal.Timezone = cmbTimeZone.SelectedValue.ToString().Trim(); objCal.ModifiedBy = userID; objCal.CreatedBy = userID; objCal.IsDeleted = false; // objCal.TimeBeforeConf = cmbremindertime.Text; // objCal.ReminderType = cmbremindertype.Text; if (rbndefault.IsChecked == true) { //objCal.ReminderType = "Default"; objCal.ConferenceType = "Default"; MCType = "Default"; } else if (rbnprivate.IsChecked == true) { //objCal.ReminderType = "Private"; objCal.ConferenceType = "Private"; MCType = "Private"; } else if (rbnpublic.IsChecked == true) { //objCal.ReminderType = "Public"; objCal.ConferenceType = "Public"; MCType = "Public"; } objCal.ConfResponse = "Yes"; confID = objCal.Save(); string myDisplayName = ClsCalender.getUserInfo(userID); string myEmail = ClsCalender.getUserInfoEmail(userID); objCal.GuestName = myDisplayName; objCal.Email = myEmail; objCal.SaveGuest(confID); ClsCalender.setEmailStatusOfConferenceGuest(myDisplayName, myEmail, "Organized"); ClsCalender.addConferenceUsers(confID, userID); ClsCalender.updateConferenceUsers(confID, userID, "Yes"); sendInvitesToAll(); MessageBox.Show("Event Created Successfully"); //txtWhat.Text = ""; //dtpStartDate.Value = null; //cmbstarttimeh.SelectedIndex = 0; //cmbstarttimem.SelectedIndex = 0; //cmbstartap.SelectedIndex = 0; //dtpendate.Value = null; //cmbendtimeh.SelectedIndex = 0; //cmbendtimem.SelectedIndex = 0; //cmbendtimeap.SelectedIndex = 0; //cmbrepeats.SelectedIndex = 0; //txtwhere.Text = ""; //txtdescription.Text = ""; //// cmbremindertype.SelectedIndex = 0; //// cmbremindertime.SelectedIndex = 0; //rbnprivate.IsChecked = true; //txtUserName.Text = ""; //txtEmail.Text = ""; //lstInvitedUserList.Items.Clear(); //lstExistingUserList.Items.Clear(); //AddExistingUsers(); ((ctlCalContainer)this.Tag).objAddEvent.Visibility = Visibility.Collapsed; ((ctlCalContainer)this.Tag).objConfCalander.Visibility = Visibility.Visible; ((ctlCalContainer)this.Tag).objAddEvent = null; ((Grid)this.Parent).Children.Remove(this); } else { int countRows = dtMeetingBetween.Rows.Count; string msg = ""; int i =0; foreach (DataRow drMeetingBetween in dtMeetingBetween.Rows) { DateTime ds = DateTime.Parse(drMeetingBetween["StartDateTime"].ToString()); DateTime de = DateTime.Parse(drMeetingBetween["EndDateTime"].ToString()); string[] startDateTimeSplit = ds.ToString().Split(' '); string[] endDateTimeSplit = de.ToString().Split(' '); string confTitle = drMeetingBetween["ConfTitle"].ToString(); string[] stSplit = startDateTimeSplit[1].Split(':'); string[] etSplit = endDateTimeSplit[1].Split(':'); startDateTimeSplit[1] = stSplit[0] + ":" + stSplit[1]; endDateTimeSplit[1] = etSplit[0] + ":" + etSplit[1]; if(startDateTimeSplit[0].Equals(endDateTimeSplit[0])) { msg += ++i + ". " + confTitle +" " + startDateTimeSplit[0] + " - " + startDateTimeSplit[1]+" "+startDateTimeSplit[2]+" To "+endDateTimeSplit[1]+" "+endDateTimeSplit[2] +"\n"; } else msg += ++i + ". " + confTitle +" " + startDateTimeSplit[0] + " - " + startDateTimeSplit[1]+" "+startDateTimeSplit[2]+" To "+ startDateTimeSplit[0] + " - " +endDateTimeSplit[1]+" "+endDateTimeSplit[2] +"\n"; } MessageBox.Show(countRows + " Meetings between the selected time already exist. Please select different time. \n\n"+msg); } } } catch (Exception exp) { VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "button1_Click()", "ctlAddEvent.xaml.cs"); } }
//public static StringBuilder CreateTressInfo() //{ // StringBuilder sb = new StringBuilder(); // sb.Append("User Is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName); // sb.AppendLine(); // sb.Append("Peer Type is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType.ToString()); // sb.AppendLine(); // sb.Append("User's SuperNode is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP); // sb.AppendLine(); // sb.Append("User's Machine Ip Address : " + VMuktiAPI.GetIPAddress.ClsGetIP4Address.GetIP4Address()); // sb.AppendLine(); // sb.AppendLine("----------------------------------------------------------------------------------------"); // return sb; //} public ctlEditEventReadOnly() { InitializeComponent(); System.Data.DataSet dsUserInfo = ClsCalender.getConferenceDetails(GlobalVariables.ConferenceID); confID = GlobalVariables.ConferenceID; DataTable table = dsUserInfo.Tables[0]; DataRow dr = table.Rows[0]; txtWhat.Content = dr["ConfTitle"].ToString(); txtStartDate.Content = dr["StartDateTime"].ToString(); txtEndDate.Content = dr["EndDateTime"].ToString(); txtAllDay.Content = dr["IsAllDay"].ToString(); txtCreatedBy.Content = ClsCalender.getUserInfo(Int64.Parse((dr["CreatedBy"].ToString()))); txtTimezone.Content = dr["Timezone"].ToString(); txtRepeatType.Content = dr["RepeatType"].ToString(); txtwhere.Content = dr["ConferenceLocation"].ToString(); txtdescription.AppendText(dr["ConferenceDetail"].ToString()); txtdescription.IsReadOnly = true; // txtReminderType.Content = dr["ReminderType"].ToString(); System.Data.DataSet dsConferenceReminder = ClsCalender.getConferenceReminder(GlobalVariables.ConferenceID); DataRow drConferenceReminder = dsConferenceReminder.Tables[0].Rows[0]; // txtReminderTime.Content = drConferenceReminder["TimeBeforeConf"].ToString(); string conferenceType = dr["ConferenceType"].ToString(); if (conferenceType.Equals("Default")) { txtPrivacy.Content = "Default"; } else if (conferenceType.Equals("Public")) { txtPrivacy.Content = "Public"; } else if (conferenceType.Equals("Private")) { txtPrivacy.Content = "Private"; } DataSet dsUsers = ClsCalender.getConferenceUsers(GlobalVariables.ConferenceID); int countUsersAttendingConference = 0; foreach (DataRow drUsers in dsUsers.Tables[0].Rows) { try { string response = drUsers["Attendence"].ToString().Trim(); if (response.Equals("Yes")) { countUsersAttendingConference++; } else if (response.Equals("MayBe")) { countUsersAttendingConference++; } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "ctlEditEventReadOnly()", "ctlEditEventReadOnly.xaml.cs"); } } txtGuestsNo.Content = countUsersAttendingConference.ToString(); }