Exemplo n.º 1
0
        private static void ObjectModified(object sender, BusinessObjectEventArgs e)
        {
            MetaClass metaClass = e.Object.GetMetaType();

            if (ListManager.MetaClassIsList(metaClass))
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.List_Updated_Data, ListManager.GetListIdByClassName(metaClass.Name));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when [assignment user assigned].
        /// </summary>
        /// <param name="primaryKey">The primary key.</param>
        /// <param name="oldUserId">The old user id.</param>
        /// <param name="newUserId">The new user id.</param>
        private void OnAssignmentUserAssigned(PrimaryKeyId primaryKey, int?oldUserId, int?newUserId)
        {
            if (oldUserId.HasValue)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Participant_Resigned, (Guid)primaryKey, oldUserId.Value);
            }

            if (newUserId.HasValue)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Participant_Assigned, (Guid)primaryKey, newUserId.Value);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when [assignment updated].
        /// </summary>
        /// <param name="primaryKey">The primary key.</param>
        private void OnAssignmentUpdated(AssignmentEntity oldEntity, AssignmentEntity newEntity)
        {
            PrimaryKeyId primaryKey = oldEntity.PrimaryKeyId.Value;

            // Check User
            if (newEntity.UserId != oldEntity.UserId)
            {
                OnAssignmentUserAssigned(primaryKey, oldEntity.UserId, newEntity.UserId);
            }

            // Subject
            if (newEntity.Subject != oldEntity.Subject)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_GeneralInfo, (Guid)primaryKey);
            }

            // Priority
            if (newEntity.Priority != oldEntity.Priority)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Priority, (Guid)primaryKey);
            }

            // State
            if (newEntity.State != oldEntity.State)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Status, (Guid)primaryKey);

                // delete DateTypeValue for closed assignment (we notify about active only)
                if (newEntity.State == (int)AssignmentState.Closed)
                {
                    Schedule.DeleteDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey);
                }
            }

            // Finish Date
            if (newEntity.PlanFinishDate != oldEntity.PlanFinishDate)
            {
                if (oldEntity.PlanFinishDate.HasValue)
                {
                    Schedule.DeleteDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey);
                }

                DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);

                if (newEntity.PlanFinishDate.HasValue && newEntity.PlanFinishDate.Value > dateTimeNow)
                {
                    Schedule.UpdateDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey, DataContext.Current.CurrentUserTimeZone.ToUniversalTime(newEntity.PlanFinishDate.Value));
                }

                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_FinishDate, (Guid)primaryKey);
            }
        }
Exemplo n.º 4
0
        private static void ListSaving(object sender, InfoEventArgs e)
        {
            if (e != null && e.Info != null && e.Info.ObjectState == MetaObjectState.Modified)
            {
                if (e.Info.Properties["Title"].IsChanged || e.Info.Properties["Description"].IsChanged)
                {
                    SystemEvents.AddSystemEvents(SystemEventTypes.List_Updated_GeneralInfo, (int)e.Info.PrimaryKeyId.Value);
                }

                if (e.Info.Properties["Status"].IsChanged)
                {
                    SystemEvents.AddSystemEvents(SystemEventTypes.List_Updated_Status, (int)e.Info.PrimaryKeyId.Value);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called when [assignment created].
        /// </summary>
        /// <param name="primaryKey">The primary key.</param>
        private void OnAssignmentCreated(PrimaryKeyId primaryKey)
        {
            DateTime         dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);
            AssignmentEntity entity      = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, primaryKey);

            SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Created, (Guid)primaryKey);

            if (entity.PlanFinishDate.HasValue && entity.PlanFinishDate.Value > dateTimeNow)
            {
                Schedule.UpdateDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey, DataContext.Current.CurrentUserTimeZone.ToUniversalTime(entity.PlanFinishDate.Value));
            }

            if (entity.UserId.HasValue)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Participant_Assigned, (Guid)primaryKey, entity.UserId.Value);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Called when [assignment deleting].
 /// </summary>
 /// <param name="primaryKey">The primary key.</param>
 private void OnAssignmentDeleting(PrimaryKeyId primaryKey)
 {
     SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Deleted, (Guid)primaryKey);
 }
Exemplo n.º 7
0
        private void OnNewMessage(object sender, EventArgs e)
        {
            if (e is NewPop3MessageEventArgs && sender is EMailRouterPop3BoxMessageLoader)
            {
                EMailRouterPop3Box internalPop3Box = EMailRouterPop3Box.ListInternal();
                if (internalPop3Box != null && !internalPop3Box.Activity.IsActive)
                {
                    internalPop3Box = null;
                }

                UserLight prevUser = Security.CurrentUser;

                Alerts2.SendToCurrentUser = true;

                try
                {
                    using (DbTransaction tran = DbTransaction.Begin())
                    {
                        EMailRouterPop3BoxMessageLoader loader = (EMailRouterPop3BoxMessageLoader)sender;

                        Pop3Message msg = ((NewPop3MessageEventArgs)e).Message;

                        string TicketUID = TicketUidUtil.LoadFromString(msg.Subject == null ? string.Empty : msg.Subject);

                        EMailMessageAntiSpamRuleRusult result = EMailMessageAntiSpamRuleRusult.Deny;

                        if (loader.Owner.IsInternal)
                        {
                            int UserId = DBUser.GetUserByEmail(EMailMessage.GetSenderEmail(msg), false);
                            if (TicketUID != string.Empty && UserId > 0)
                            {
                                result = EMailMessageAntiSpamRuleRusult.Accept;
                            }
                        }
                        else
                        {
                            if (PortalConfig.UseAntiSpamFilter)
                            {
                                result = EMailMessageAntiSpamRule.Check(loader.Owner, msg);
                            }
                            else
                            {
                                result = EMailMessageAntiSpamRuleRusult.Accept;
                            }
                        }

                        int EMailMessageId = -1;

                        // OZ: [2007-01-29] EMailMessageLog
                        if (EmailLogSettings != null)
                        {
                            string from = string.Empty;

                            if (msg.Headers["Reply-To"] != null)
                            {
                                from = msg.Headers["Reply-To"];
                            }
                            //else if (msg.Headers["Sender"] != null)
                            //{
                            //    from = msg.Headers["Sender"];
                            //}
                            else if (msg.Headers["From"] != null)
                            {
                                from = msg.Headers["From"];
                            }

                            EMailMessageLog.Add(from,
                                                msg.Headers["To"] != null ? msg.Headers["To"] : string.Empty,
                                                msg.Headers["Subject"] != null ? msg.Headers["Subject"] : string.Empty,
                                                loader.Owner.EMailRouterPop3BoxId,
                                                result);
                        }
                        //

                        switch (result)
                        {
                        case EMailMessageAntiSpamRuleRusult.Pending:
                            // Register Email Message
                            EMailMessageId = RegisterEmail(loader.Owner.EMailRouterPop3BoxId, msg);
                            // Add to pending email table
                            EMailMessage.MarkAsPendingMessage(EMailMessageId);
                            break;

                        case EMailMessageAntiSpamRuleRusult.Accept:
                            // Register Email Message
                            EMailMessageId = RegisterEmail(loader.Owner.EMailRouterPop3BoxId, msg);


                            if (TicketUID == string.Empty)
                            {
                                int IncidentId = EMailMessage.CreateNewIncident(EMailMessageId, loader.Owner, msg);
                            }
                            else
                            {
                                // Assign By Ticket
                                int IncidentId = FindIncidentByTicket(TicketUID);

                                if (IncidentId != -1)
                                {
                                    int creatorId, issueBoxId;
                                    using (IDataReader reader = DBIncident.GetIncident(IncidentId, 0, 1))
                                    {
                                        reader.Read();

                                        creatorId  = (int)reader["CreatorId"];
                                        issueBoxId = (int)reader["IncidentBoxId"];
                                    }

                                    int       stateId, managerId, responsibleId;
                                    bool      isResposibleGroup;
                                    ArrayList users = new ArrayList();

                                    Issue2.GetIssueBoxSettings(issueBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users);

                                    EMailMessage.LogOnCreator(creatorId, msg);

                                    int ThreadNodeId = EMailMessage.AddToIncidentMessage(loader.Owner.IsInternal, IncidentId, EMailMessageId, msg);

                                    if (EMailMessage.ProcessXIbnHeaders(IncidentId, ThreadNodeId, msg))
                                    {
                                        try
                                        {
                                            ArrayList excludeUsers = EMailRouterOutputMessage.Send(IncidentId, loader.Owner, msg);
                                            SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, IncidentId, -1, excludeUsers);
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Trace.WriteLine(ex);
                                            Log.WriteError(ex.ToString());
                                        }
                                    }
                                }
                                else
                                {
                                    // Add to pending email table
                                    if (!loader.Owner.IsInternal)
                                    {
                                        EMailMessage.MarkAsPendingMessage(EMailMessageId);
                                    }
                                }
                            }
                            break;

                        case EMailMessageAntiSpamRuleRusult.Deny:
                            // Do nothing
                            break;
                        }

                        tran.Commit();
                    }
                }
                finally
                {
                    Alerts2.SendToCurrentUser = false;

                    if (Security.CurrentUser != prevUser)
                    {
                        Security.SetCurrentUser(prevUser);
                    }
                }
            }
        }
Exemplo n.º 8
0
 private static void ListDeleting(object sender, InfoEventArgs e)
 {
     SystemEvents.AddSystemEvents(SystemEventTypes.List_Deleted, (int)e.Info.PrimaryKeyId.Value);
 }
Exemplo n.º 9
0
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            bool withResponse = false;

            if (this.IsPostBack)
            {
                try
                {
                    string sUserLight = "userlight";

                    // check user's name and password here
                    UserLight currentUser = Security.GetUser(Login.Value, Password.Value);
                    if (currentUser == null)
                    {
                        throw new HttpException(405, "Your login or password is invalid.");
                    }

                    // Security Addon [3/2/2004]
                    UserLight retUser = null;
                    if (HttpContext.Current.Items.Contains(sUserLight))
                    {
                        retUser = (UserLight)HttpContext.Current.Items[sUserLight];
                        HttpContext.Current.Items.Remove(sUserLight);
                    }
                    HttpContext.Current.Items.Add(sUserLight, currentUser);
                    // End Security Addon [3/2/2004]

                    // New Folder System Addon [12/27/2005]
                    string ContainerName = "FileLibrary";
                    string ContainerKey  = String.Empty;
                    int    objectId      = Int32.Parse(ObjectId.Value);
                    int    objectTypeId  = Int32.Parse(ObjectTypeId.Value);
                    int    folderId      = 0;

                    switch ((ObjectTypes)objectTypeId)
                    {
                    case ObjectTypes.Project:
                        ContainerKey = "ProjectId_" + objectId.ToString();
                        break;

                    case ObjectTypes.Issue:
                        ContainerKey = string.Empty;
                        break;

                    case ObjectTypes.Task:
                        ContainerKey = "TaskId_" + objectId.ToString();
                        break;

                    case ObjectTypes.CalendarEntry:
                        ContainerKey = "EventId_" + objectId.ToString();
                        break;

                    case ObjectTypes.Folder:
                        ContainerKey = "Workspace";
                        if (objectId != 0)
                        {
                            folderId     = objectId;
                            ContainerKey = Mediachase.IBN.Business.ControlSystem.DirectoryInfo.GetContainerKey(folderId);
                        }
                        break;

                    case ObjectTypes.Document:
                        ContainerKey = "DocumentId_" + objectId.ToString();
                        break;

                    case ObjectTypes.ToDo:
                        ContainerKey = "ToDoId_" + objectId.ToString();
                        break;
                    }
                    if (ContainerKey != String.Empty)
                    {
                        Mediachase.IBN.Business.ControlSystem.BaseIbnContainer bic = Mediachase.IBN.Business.ControlSystem.BaseIbnContainer.Create(ContainerName, ContainerKey);
                        Mediachase.IBN.Business.ControlSystem.FileStorage      fs  = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

                        if (folderId == 0)
                        {
                            folderId = fs.Root.Id;
                        }

                        string fileName = Path.GetFileName(PublishedFile.PostedFile.FileName);
                        if (FileName.Value != string.Empty)
                        {
                            fileName = FileName.Value;
                        }

                        /*int	index = 0;
                         * while (fs.FileExist(fileName, folderId))
                         * {
                         *      fileName = Path.GetFileNameWithoutExtension(PublishedFile.PostedFile.FileName) + (index++).ToString();
                         *      fileName += Path.GetExtension(PublishedFile.PostedFile.FileName);
                         * }*/
                        fs.SaveFile(folderId, fileName, PublishedFile.PostedFile.InputStream);
                    }
                    else if ((ObjectTypes)objectTypeId == ObjectTypes.List)
                    {
                        string xml = SaveNParseExcel(PublishedFile.PostedFile.FileName, PublishedFile.PostedFile.InputStream);

                        Response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(xml));
                        withResponse = true;
                    }
                    else if ((ObjectTypes)objectTypeId == ObjectTypes.Issue)
                    {
                        string fileName = Path.GetFileName(PublishedFile.PostedFile.FileName);
                        if (FileName.Value != string.Empty)
                        {
                            fileName = FileName.Value;
                        }

                        // OZ: 2008-08-19 Add Process Eml Attachments
                        if (Path.GetExtension(fileName).ToLower() == ".eml")
                        {
                            // Calculate email box
                            int emailBoxId = EMailRouterOutputMessage.FindEMailRouterPublicId(objectId);

                            // Save Email to email storage
                            int eMailMessageId = EMailMessage.CreateFromStream(emailBoxId, PublishedFile.PostedFile.InputStream);

                            EMailMessage.AddToIncidentMessage(false, objectId, eMailMessageId);

                            try
                            {
                                ArrayList excludeUsers = EMailRouterOutputMessage.Send(objectId, eMailMessageId);
                                SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, objectId, -1, excludeUsers);
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Trace.WriteLine(ex);
                                //Log.WriteError(ex.ToString());
                            }
                        }
                        // Process Default files
                        else
                        {
                            BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", objectId));
                            ForumStorage     forumStorage  = (ForumStorage)destContainer.LoadControl("ForumStorage");

                            ForumThreadNodeInfo info = forumStorage.CreateForumThreadNode(string.Empty, Security.CurrentUser.UserID, (int)ForumStorage.NodeContentType.TextWithFiles);

                            BaseIbnContainer forumContainer = BaseIbnContainer.Create("FileLibrary", string.Format("ForumNodeId_{0}", info.Id));
                            FileStorage      fs             = (FileStorage)forumContainer.LoadControl("FileStorage");


                            fs.SaveFile(fileName, PublishedFile.PostedFile.InputStream);

                            ForumThreadNodeSettingCollection settings1 = new ForumThreadNodeSettingCollection(info.Id);
                            settings1.Add(ForumThreadNodeSetting.Internal, "1");
                        }
                    }
                    // End New Folder System Addon [12/27/2005]

                    // Security Addon [3/2/2004]
                    HttpContext.Current.Items.Remove(sUserLight);
                    HttpContext.Current.Items.Add(sUserLight, retUser);
                    // End Security Addon [3/2/2004]
                }
                catch (Exception ex)
                {
                    throw new HttpException(405, "Internal Exception", ex);
                }
                if (!withResponse)
                {
                    this.Response.Write("Published Completed");
                }
                this.Response.End();
            }
        }