Exemple #1
0
        private void sendEmailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var answer = MessageBox.Show("Would you like to send emails to impacted clients?",
                                         "Send email",
                                         MessageBoxButtons.YesNo);

            if (answer != DialogResult.Yes)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            List <Client> listOfClients = new List <Client>();

            // Get file name
            //
            string filePathName = Utils.getFilePathName(
                document.Location,
                document.FileName);

            if (!File.Exists(filePathName))
            {
                MessageBox.Show("File not found. " + filePathName);
                return;
            }


            // Select client to send email and show before send
            //
            var impacted = new ClientDocument();

            // impacted.ListImpacted(document);

            BUSClientDocument.ListImpacted(impacted, document);

            foreach (var doco in impacted.clientDocSetDocLink)
            {
                var response =
                    BUSClientContract.GetValidContractOnDate(doco.clientDocument.FKClientUID, System.DateTime.Today);

                if (response.ReturnCode == 0001 && response.ReasonCode == 0001)
                {
                    //Client client = new Client(HeaderInfo.Instance);
                    //client.UID = doco.clientDocument.FKClientUID;

                    ClientReadRequest crr = new ClientReadRequest();
                    crr.clientUID  = doco.clientDocument.FKClientUID;
                    crr.headerInfo = HeaderInfo.Instance;

                    var busClientResponse = BUSClient.ClientRead(crr);

                    //var busClientResponse = client.Read();

                    listOfClients.Add(busClientResponse.client);
                }
            }

            if (listOfClients.Count <= 0)
            {
                return;
            }

            string subject = "Document updated";
            string body    = "The document " + document.Name + " has been updated.";

            var resp = SendEmailToGroup(
                clientList: listOfClients,
                iSubject: subject,
                iBody: body,
                Attachment: filePathName);

            MessageBox.Show(resp.Message);

            Cursor.Current = Cursors.Arrow;
        }
Exemple #2
0
        private void ListImpact(Document document, int h = 16, int w = 16)
        {
            // Clear nodes
            tvDocumentList.Nodes.Clear();

            var impacted = new ClientDocument();

            // impacted.ListImpacted(document);

            BUSClientDocument.ListImpacted(impacted, document);

            TreeNode rootNode = new TreeNode("Impacted List", FCMConstant.Image.Folder, FCMConstant.Image.Folder);

            rootNode.Name = "Impacted List";
            tvDocumentList.Nodes.Add(rootNode);

            foreach (var doco in impacted.clientDocSetDocLink)
            {
                // string clientName = Client.ReadFieldClient(DBFieldName.Client.Name, doco.clientDocument.FKClientUID);

                var clientField = new Client(HeaderInfo.Instance);

                // string clientName = clientField.ReadFieldClient(DBFieldName.Client.Name, doco.clientDocument.FKClientUID);
                var readFieldClientResponse = new BUSClient().ReadFieldClient(
                    new ReadFieldRequest()
                {
                    clientUID = doco.clientDocument.FKClientUID, field = FCMDBFieldName.Client.Name, headerInfo = HeaderInfo.Instance
                });

                string clientName = readFieldClientResponse.fieldContents;

                // 1) Add client to tree
                //
                // 1.1) Find out current contract information
                // 1.2) Display document version
                // 1.3) Check if document has been further updated
                var response =
                    BUSClientContract.GetValidContractOnDate(doco.clientDocument.FKClientUID, System.DateTime.Today);

                // Successful
                ClientContract clientContractValid = new ClientContract();
                string         validContract       = @";Contract=N/A";
                if (response.ReturnCode == 0001 && response.ReasonCode == 0001)
                {
                    clientContractValid = (ClientContract)response.Contents;
                    validContract       = ";Contract=Valid";
                }

                int imageClient = Utils.GetClientLogoImageSeqNum(doco.clientDocument.FKClientUID);

                string NameToDisplay = clientName + " ==> " +
                                       validContract +
                                       "; Version: " +
                                       doco.clientDocument.ClientIssueNumber.ToString();

                TreeNode clientNode = new TreeNode(NameToDisplay, imageClient, imageClient);
                clientNode.Name = doco.clientDocument.FKClientUID.ToString();
                clientNode.Tag  = doco;
                rootNode.Nodes.Add(clientNode);

                // Add Client Document Set to tree
                //
                TreeNode clientDocumentSetNode = new TreeNode("Set " + doco.clientDocument.FKClientDocumentSetUID.ToString(), FCMConstant.Image.Folder, FCMConstant.Image.Folder);
                clientDocumentSetNode.Name = "Set " + doco.clientDocument.FKClientDocumentSetUID.ToString("0000");
                clientDocumentSetNode.Tag  = doco;
                clientNode.Nodes.Add(clientDocumentSetNode);

                // Add document to tree
                //
                int      image        = Utils.GetFileImage(doco.clientDocument.SourceFilePresent, doco.clientDocument.DestinationFilePresent, doco.clientDocument.DocumentType);
                TreeNode documentNode = new TreeNode(txtDocumentName.Text, image, image);
                documentNode.Name = txtDocumentName.Text;
                documentNode.Tag  = doco;
                clientDocumentSetNode.Nodes.Add(documentNode);
            }

            if (tvDocumentList.Nodes.Count > 0)
            {
                tvDocumentList.Nodes[0].Expand();
            }
        }