Exemplo n.º 1
0
       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");

       }
Exemplo n.º 2
0
        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");
            }


        }