Пример #1
0
        public static bool SetEvent(Event1 oEvent, int iUserId, List <TInt> to)
        {
            try
            {
                bool isNew;
                isNew = oEvent.iEventId == 0 ? true : false;
                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(new SqlParameter("iEventId", oEvent.iEventId));
                parameters.Add(new SqlParameter("nvName", oEvent.nvName));
                parameters.Add(new SqlParameter("dtEventDate", oEvent.dtEventDate));
                parameters.Add(new SqlParameter("nvPlace", oEvent.nvPlace));
                parameters.Add(new SqlParameter("nvComments", oEvent.nvComments));
                parameters.Add(new SqlParameter("iUserId", iUserId));
                parameters.Add(new SqlParameter("participantIds", ObjectGenerator <TInt> .GetDataTable(to)));


                if (!isNew)
                {
                    SqlDataAccess.ExecuteDatasetSP("TEvent_INS/UPD", parameters);
                }
                if (isNew)
                {
                    User user             = User.GetUser(iUserId);
                    DataRowCollection drc = SqlDataAccess.ExecuteDatasetSP("TEvent_INS/UPD", parameters).Tables[0].Rows;
                    for (int i = 0; i < drc.Count; i++)
                    {
                        int    iPersonId = int.Parse(drc[i]["iPersonId"].ToString());
                        string nvEmail   = drc[i]["nvEmail"].ToString();
                        string body      = "<b>הנך מוזמן ל" + oEvent.nvName +
                                           "</b><br>שיתקיים ב" + oEvent.nvPlace +
                                           "<br>בתאריך " + oEvent.dtEventDate + "<br>" + oEvent.nvComments +
                                           "<br><br> <b> בברכה </b> <br>" + user.nvFirstName + " " + user.nvLastName +
                                           "<br> עמותת ונתנו ידידים";
                        string from = user.nvEmail;
                        if (user.nvEmail == "" || user.nvEmail == null)
                        {
                            from = ConfigSettings.ReadSetting("Email");
                        }
                        if (SendMessagesHandler.SendEmailOrFax(from, nvEmail, oEvent.nvName, body, null) == true)
                        {
                            List <SqlParameter> param = new List <SqlParameter>();
                            param.Add(new SqlParameter("iEventId", drc[i]["iEventId"]));
                            param.Add(new SqlParameter("iPersonId", iPersonId));
                            param.Add(new SqlParameter("iStatusType", 34));  //סטטוס קיבל הודעה
                            SqlDataAccess.ExecuteDatasetSP("TParticipantsUpdateArrivalStatus_UPD", param);
                        }
                    }
                    //SendMessagesHandler.SendEmailOrFax()
                }


                return(true);
            }
            catch (Exception ex)
            {
                Log.LogError("set event / TEvent_INS/UPD", "ex" + ex);
                return(false);
            }
        }
Пример #2
0
 public bool SendEmailOrFax(string from, string to, string subject, string body, List <Attachment> lAttach)
 {
     return(SendMessagesHandler.SendEmailOrFax(from, to, subject, body, lAttach));
 }