public int Duplicate(int atcEntry)
        {
            int absEntry = 0;

            DAO.AttachmentDAO attachmentDAO = new DAO.AttachmentDAO();

            List <Model.AttachmentModel> attachmentList = Get(atcEntry);

            attachmentList.Select(r => r.AbsEntry = 0).ToList();

            for (int line = 0; line < attachmentList.Count; line++)
            {
                Model.AttachmentModel attachmentModel = attachmentList[line];
                attachmentModel.AbsEntry = absEntry;

                attachmentDAO.Insert(attachmentModel);

                if (line == 0)
                {
                    absEntry = attachmentModel.AbsEntry;
                }
            }

            return(absEntry);
        }
        public int Save(string file)
        {
            Model.AttachmentModel attachmentModel = new Model.AttachmentModel();
            attachmentModel.Path = file;

            new DAO.AttachmentDAO().Insert(attachmentModel);

            return(attachmentModel.AbsEntry);
        }
Example #3
0
        public void Insert(Model.AttachmentModel attachmentModel)
        {
            Attachments2 attachment = (Attachments2)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oAttachments2);

            try
            {
                if (attachment.GetByKey(attachmentModel.AbsEntry))
                {
                    attachment.Lines.Add();

                    attachment.Lines.SetCurrentLine(attachment.Lines.Count - 1);

                    attachment.Lines.SourcePath    = Path.GetDirectoryName(attachmentModel.Path);
                    attachment.Lines.FileName      = Path.GetFileNameWithoutExtension(attachmentModel.Path);
                    attachment.Lines.FileExtension = Path.GetExtension(attachmentModel.Path).Replace(".", "");
                    attachment.Lines.Override      = BoYesNoEnum.tYES;

                    foreach (KeyValuePair <string, dynamic> userField in attachmentModel.UserFields)
                    {
                        attachment.Lines.UserFields.Fields.Item(userField.Key).Value = userField.Value;
                    }

                    attachment.Update();

                    Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();
                }
                else
                {
                    attachment.Lines.SourcePath    = Path.GetDirectoryName(attachmentModel.Path);
                    attachment.Lines.FileName      = Path.GetFileNameWithoutExtension(attachmentModel.Path);
                    attachment.Lines.FileExtension = Path.GetExtension(attachmentModel.Path).Replace(".", "");
                    attachment.Lines.Override      = BoYesNoEnum.tYES;

                    foreach (KeyValuePair <string, dynamic> userField in attachmentModel.UserFields)
                    {
                        attachment.Lines.UserFields.Fields.Item(userField.Key).Value = userField.Value;
                    }

                    attachment.Add();

                    Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();

                    attachmentModel.AbsEntry = Convert.ToInt32(Controller.ConnectionController.Instance.Company.GetNewObjectKey());
                }
            }
            finally
            {
                Marshal.ReleaseComObject(attachment);
            }
        }
Example #4
0
        public Model.AttachmentModel Get(int atcEntry, int line)
        {
            Model.AttachmentModel result = new Model.AttachmentModel();

            Attachments2 attachment = (Attachments2)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oAttachments2);

            try
            {
                if (attachment.GetByKey(atcEntry))
                {
                    attachment.Lines.SetCurrentLine(line - 1);

                    result.AbsEntry = attachment.AbsoluteEntry;
                    result.Line     = line;
                    result.Path     = Path.ChangeExtension(Path.Combine(GetAttachmentFolder(), attachment.Lines.FileName), attachment.Lines.FileExtension);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(attachment);
            }

            return(result);
        }
Example #5
0
        public void Delete(Model.AttachmentModel attachmentModel)
        {
            Attachments2 attachment = (Attachments2)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oAttachments2);

            try
            {
                if (attachment.GetByKey(attachmentModel.AbsEntry))
                {
                    attachment.Lines.SetCurrentLine(attachmentModel.Line - 1);

                    attachment.Lines.SourcePath    = string.Empty;
                    attachment.Lines.FileName      = string.Empty;
                    attachment.Lines.FileExtension = string.Empty;

                    attachment.Update();

                    Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess();
                }
            }
            finally
            {
                Marshal.ReleaseComObject(attachment);
            }
        }