Пример #1
0
        public static int InsertEvent(Guid OrgID, int DeptId, int CreatedByUserId, NotificationRules.TicketEvent tktEvent, string ObjectStateNew, string ObjectStateOld, FileItem[] EventFiles, int ScheduledTicketId, DateTime RunTime)
        {
            SqlParameter _pId = new SqlParameter("@Id", SqlDbType.Int);

            _pId.Direction = ParameterDirection.InputOutput;
            _pId.Value     = DBNull.Value;
            SqlParameter _pObjectStateNew = new SqlParameter("@ObjectStateNew", SqlDbType.NText);

            if (ObjectStateNew.Length > 0)
            {
                _pObjectStateNew.Value = ObjectStateNew;
            }
            else
            {
                _pObjectStateNew.Value = DBNull.Value;
            }
            SqlParameter _pObjectStateOld = new SqlParameter("@ObjectStateOld", SqlDbType.NText);

            if (ObjectStateOld.Length > 0)
            {
                _pObjectStateOld.Value = ObjectStateOld;
            }
            else
            {
                _pObjectStateOld.Value = DBNull.Value;
            }
            SqlParameter _pScheduledTicketId = new SqlParameter("@ScheduledTicketId", SqlDbType.Int);

            if (ScheduledTicketId != 0)
            {
                _pScheduledTicketId.Value = ScheduledTicketId;
            }
            else
            {
                _pScheduledTicketId.Value = DBNull.Value;
            }
            SqlParameter _pRunTime = new SqlParameter("@RunTime", SqlDbType.SmallDateTime);

            if (RunTime == DateTime.MinValue)
            {
                _pRunTime.Value = DBNull.Value;
            }
            else
            {
                _pRunTime.Value = RunTime;
            }
            UpdateData("sp_UpdateNotificationEventsQueue", new SqlParameter[] { _pId, new SqlParameter("@DId", DeptId), new SqlParameter("@CreatedByUserId", CreatedByUserId), new SqlParameter("@EventType", (int)tktEvent), _pObjectStateNew, _pObjectStateOld, _pScheduledTicketId, _pRunTime }, OrgID);
            int _id = (int)_pId.Value;

            if (EventFiles == null)
            {
                return(_id);
            }
            foreach (FileItem _file in EventFiles)
            {
                InsertFile(OrgID, DeptId, _id, _file);
            }
            return(_id);
        }
Пример #2
0
        public string Commit(UseSendMailEngine mail_engine, bool IsBodyHtml)
        {
            string _result = string.Empty;

            try
            {
                switch (mail_engine)
                {
                case UseSendMailEngine.SystemWebMail:
                    Functions.SendEmail(_from, string.Empty, _to, string.Empty, null, _subject, _body, _files, IsBodyHtml);
                    break;

                case UseSendMailEngine.NotificationService:
                    XmlSerializer _serializer = new XmlSerializer(typeof(MailNotification));
                    TextWriter    _stream     = new StringWriter();
                    _serializer.Serialize(_stream, this);
                    string _object_state = _stream.ToString();
                    _stream.Close();
                    NotificationRules.TicketEvent _event = IsBodyHtml ? NotificationRules.TicketEvent.DirectMailAsHTML : NotificationRules.TicketEvent.DirectMail;
                    int _operation_result = NotificationEventsQueue.InsertEvent(_org_id, _department_id, _user_id, _event, _object_state, _files);
                    if (_operation_result <= 0)
                    {
                        _result = "Can't add mass mailes to NotificationEventsQueue.";
                    }

                    break;
                }
                ;
            }
            catch (Exception ex)
            {
                _result = ex.Message;
            };

            return(_result);
        }
Пример #3
0
 public static int InsertEvent(Guid OrgID, int DeptId, int CreatedByUserId, NotificationRules.TicketEvent tktEvent, string ObjectState, FileItem[] EventFiles)
 {
     return(InsertEvent(OrgID, DeptId, CreatedByUserId, tktEvent, ObjectState, string.Empty, EventFiles, 0, DateTime.MinValue));
 }
Пример #4
0
 public static int InsertEvent(int DeptId, int CreatedByUserId, NotificationRules.TicketEvent tktEvent, string ObjectState, FileItem[] EventFiles)
 {
     return(InsertEvent(Guid.Empty, DeptId, CreatedByUserId, tktEvent, ObjectState, EventFiles));
 }
Пример #5
0
 public static int InsertEvent(int DeptId, int CreatedByUserId, NotificationRules.TicketEvent tktEvent, string ObjectState)
 {
     return(InsertEvent(Guid.Empty, DeptId, CreatedByUserId, tktEvent, ObjectState, string.Empty, null, 0, DateTime.MinValue));
 }