Beispiel #1
0
        private static void SendNotification(decimal submissionId)
        {
            var submission = DBReadManager.GeFileSubmissionById(submissionId);

            if (submission == null)
            {
                return;
            }
            var files = DBReadManager.GetFilesPerSubmission(submissionId.ToString(CultureInfo.InvariantCulture));
            var roles = DbReader.GetRolesToNotify();

            if (roles.HasRows)
            {
                var x = (from s in roles.Tables[0].Rows.OfType <DataRow>()
                         select s["EmailAddress"].ToString()).ToArray();

                var fileList = new StringBuilder();
                //fileList.Append("<ul>");
                foreach (DataRow file in files.Tables[0].Rows)
                {
                    fileList.AppendFormat("<li>{0} - {1}</li>", file["Category"], file["Classification"]);
                }

                //fileList.Append("</ul>");

                var messageBody = string.Format(
                    File.ReadAllText("FileArrivalNotification.htm")
                    , submission.TaxRefNo
                    , submission.Year
                    , fileList
                    , SARSDataSettings.Settings.ApplicationName);
                FdrCommon.SendEmail(x, messageBody, "CBC Declaration");
            }
        }
        private static void NotifyFdrUsers(string taxRefNo, string year)
        {
            var body =
                string.Format(
                    "Good day, </br> this is to inform you about new file submission that just arrived for {0} for year {1}",
                    taxRefNo, year);
            const string subject        = "Files arriving";
            var          users          = DbReader.GetUsersInARole(AppConfig.NotifyRole);
            var          emailAddresses = users.Select(u => u.EmailAddress).ToArray();

            FdrCommon.SendEmail(emailAddresses, body, subject);
        }
Beispiel #3
0
        private static void SaveIncomingCbcDeclaration(string message)
        {
            var properXml = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(message);

            using (var data = new RecordSet()){
                data.ReadXml(new StringReader(properXml));
                var messageIdentification = data.Tables["MessageIdentification"];
                var messageSpec           = data.Tables["MessageSpec"];
                var contactDetails        = data.Tables["ContactDetails"];

                if (!data.Tables.Contains("MessageIdentification") || !data.Tables.Contains("MessageSpec") ||
                    !data.Tables.Contains("ContactDetails"))
                {
                    FdrCommon.LogEvent("MessageIdentification OR  FormInfo OR ContactDetails is not in this XML");
                    return;
                }
                if (messageIdentification.Rows.Count == 0)
                {
                    FdrCommon.LogEvent("MessageIdentification has no data");
                    return;
                }

                if (messageSpec.Rows.Count == 0)
                {
                    FdrCommon.LogEvent("FormInfo has no data");
                    return;
                }

                if (contactDetails.Rows.Count == 0)
                {
                    FdrCommon.LogEvent("ContactDetails has no data");
                    return;
                }
                var reportingYear = messageSpec.Rows[0]["ReportingPeriod"].ToString().Trim();

                var taxRefNo     = messageIdentification.Rows[0]["externalReferenceID"].ToString().Trim();
                var taxYear      = Convert.ToInt32(reportingYear.Length > 4 ? reportingYear.Substring(0, 4) : reportingYear);
                var surname      = contactDetails.Rows[0]["Surname"].ToString().Trim();
                var firstNames   = contactDetails.Rows[0]["FirstNames"].ToString().Trim();
                var busTelNo1    = contactDetails.Rows[0]["BusTelNo1"].ToString().Trim();
                var cellNo       = contactDetails.Rows[0]["CellNo"].ToString().Trim();
                var emailAddress = contactDetails.Rows[0]["EmailAddress"].ToString().Trim();
                //string postalAddress = null;
                DbReader.SaveCBCRequest(properXml,
                                        taxRefNo,
                                        taxYear,
                                        surname,
                                        firstNames,
                                        busTelNo1,
                                        cellNo,
                                        emailAddress,
                                        null);

                var roles = DbReader.GetRolesToNotify();
                if (roles.HasRows)
                {
                    var x = (from s in roles.Tables[0].Rows.OfType <DataRow>()
                             select s["EmailAddress"].ToString()).ToArray();

                    var messageBody = string.Format(
                        File.ReadAllText("CBCArrivalNotification.htm")
                        , taxRefNo
                        , reportingYear
                        , SARSDataSettings.Settings.ApplicationName);
                    FdrCommon.SendEmail(x, messageBody, "CBC Declaration");
                }
            }
        }