private void UpdateMessage(EPActivity message)
            {
                var emailType = message.GetType();
                var cache     = _graph.Caches[emailType];

                message = (EPActivity)cache.Update(message);
                _graph.EnshureCachePersistance(emailType);
                var cached = _graph.Caches[message.GetType()].Locate(message);

                _graph.Persist();
                _graph.SelectTimeStamp();
                message = (EPActivity)cache.CreateCopy(cached);
            }
            private void CreateFile(long noteId, Guid newFileId, string name, byte[] content)
            {
                var noteDocCache = _graph.Caches[typeof(NoteDoc)];
                var noteDoc      = (NoteDoc)noteDocCache.CreateInstance();

                noteDoc.NoteID = noteId;
                noteDoc.FileID = newFileId;
                noteDocCache.Insert(noteDoc);
                _graph.EnshureCachePersistance(typeof(NoteDoc));

                var uploadFileCache = _graph.Caches[typeof(UploadFile)];
                var uploadFile      = (UploadFile)uploadFileCache.CreateInstance();

                uploadFile.FileID         = newFileId;
                uploadFile.LastRevisionID = 1;
                uploadFile.Versioned      = true;
                uploadFile.IsPublic       = false;
                if (name.Length > 200)
                {
                    name = name.Substring(0, 200);
                }
                uploadFile.Name            = newFileId + @"\" + name;
                uploadFile.PrimaryScreenID = "CR306015";                 //TODO: need review
                uploadFileCache.Insert(uploadFile);
                _graph.EnshureCachePersistance(typeof(UploadFile));

                var fileRevisionCache = _graph.Caches[typeof(UploadFileRevision)];
                var fileRevision      = (UploadFileRevision)fileRevisionCache.CreateInstance();

                fileRevision.FileID         = newFileId;
                fileRevision.FileRevisionID = 1;
                fileRevision.Data           = content;
                fileRevision.Size           = content.Length;
                fileRevisionCache.Insert(fileRevision);
                _graph.EnshureCachePersistance(typeof(UploadFileRevision));
            }
Ejemplo n.º 3
0
        private void SendCopyMessage(PXGraph graph, EMailAccount account, EPActivity message, string email)
        {
            var cache = graph.Caches[message.GetType()];
            var copy  = (EPActivity)cache.CreateCopy(message);

            copy.TaskID       = null;
            copy.IsIncome     = false;
            copy.ParentTaskID = message.TaskID;
            copy.MailTo       = email;       //TODO: need add address description
            copy.MailCc       = null;
            copy.MailBcc      = null;
            copy.MPStatus     = MailStatusListAttribute.PreProcess;
            copy.ClassID      = CRActivityClass.EmailRouting;
            new AddInfoEmailProcessor().Process(new EmailProcessEventArgs(graph, account, copy));
            copy.RefNoteID       = null;
            copy.ParentRefNoteID = null;
            copy.Pop3UID         = null;
            copy.ImapUID         = null;
            var imcUid = Guid.NewGuid();

            copy.ImcUID    = imcUid;
            copy.MessageId = this.GetType().Name + "_" + imcUid.ToString().Replace("-", string.Empty);
            copy.Owner     = null;
            copy           = (EPActivity)cache.CreateCopy(cache.Insert(copy));
            //Update owner and reset owner if employee not found
            copy.Owner = message.Owner;
            try
            {
                cache.Update(copy);
            }
            catch (PXSetPropertyException)
            {
                copy.Owner = null;
                copy       = (EPActivity)cache.CreateCopy(cache.Update(copy));
            }
            var noteFiles = PXNoteAttribute.GetFileNotes(cache, message);

            if (noteFiles != null)
            {
                PXNoteAttribute.SetFileNotes(cache, copy, noteFiles);
            }
            graph.EnshureCachePersistance(copy.GetType());
        }
		private void SendCopyMessage(PXGraph graph, EMailAccount account, EPActivity message, string email)
		{
			var cache = graph.Caches[message.GetType()];
			var copy = (EPActivity)cache.CreateCopy(message);
			copy.TaskID = null;
			copy.IsIncome = false;
			copy.ParentTaskID = message.TaskID;
			copy.MailTo = email; //TODO: need add address description
			copy.MailCc = null;
			copy.MailBcc = null;
			copy.MPStatus = MailStatusListAttribute.PreProcess;
			copy.ClassID = CRActivityClass.EmailRouting;
			new AddInfoEmailProcessor().Process(new EmailProcessEventArgs(graph, account, copy));
			copy.RefNoteID = null;
			copy.ParentRefNoteID = null;
			copy.Pop3UID = null;
			copy.ImapUID = null;
			var imcUid = Guid.NewGuid();
			copy.ImcUID = imcUid;
			copy.MessageId = this.GetType().Name + "_" + imcUid.ToString().Replace("-", string.Empty);
			copy.Owner = null;
			copy = (EPActivity)cache.CreateCopy(cache.Insert(copy));
			//Update owner and reset owner if employee not found
			copy.Owner = message.Owner;
			try
			{
				cache.Update(copy);
			}
			catch (PXSetPropertyException)
			{
				copy.Owner = null;
				copy =  (EPActivity)cache.CreateCopy(cache.Update(copy));
			}
			var noteFiles = PXNoteAttribute.GetFileNotes(cache, message);
			if (noteFiles != null)
				PXNoteAttribute.SetFileNotes(cache, copy, noteFiles);
			graph.EnshureCachePersistance(copy.GetType());
		}