Ejemplo n.º 1
0
        public static Settlement Load(Guid Id)
        {
            Settlement result;

            try
            {
                Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (SorentoLib.Services.Datastore.Get<XmlDocument> (DatastoreAisle, Id.ToString ()).SelectSingleNode ("(//didius.settlement)[1]")));
                result = new Settlement ();

                result._id = new Guid ((string)item["id"]);

                if (item.ContainsKey ("createtimestamp"))
                {
                    result._createtimestamp = int.Parse ((string)item["createtimestamp"]);
                }

                if (item.ContainsKey ("updatetimestamp"))
                {
                    result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]);
                }

                if (item.ContainsKey ("no"))
                {
                    result._no = int.Parse ((string)item["no"]);
                }

                if (item.ContainsKey ("auctionid"))
                {
                    result._auctionid = new Guid ((string)item["auctionid"]);
                }

                if (item.ContainsKey ("caseid"))
                {
                    result._caseid = new Guid ((string)item["caseid"]);
                }

                if (item.ContainsKey ("customerid"))
                {
                    result._customerid = new Guid ((string)item["customerid"]);
                }

                if (item.ContainsKey ("lines"))
                {
                    foreach (XmlDocument settlementline in (List<XmlDocument>)item["lines"])
                    {
                        result._lines.Add (SettlementLine.FromXmlDocument (settlementline));
                    }
                }

                if (item.ContainsKey ("caseno"))
                {
                    result._caseno = (string)item["caseno"];
                }

                if (item.ContainsKey ("reference"))
                {
                    result._reference = (string)item["reference"];
                }
            }
            catch (Exception exception)
            {
                // LOG: LogDebug.ExceptionUnknown
                SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.SETTLEMENT", exception.Message));

                // EXCEPTION: Excpetion.InvoiceLoadGuid
                throw new Exception (string.Format (Strings.Exception.SettlementLoadGuid, Id, exception.Message));
            }

            return result;
        }
Ejemplo n.º 2
0
        public static void MailSettlement(Settlement Settlement, string PdfFilename)
        {
            Customer customer = Customer.Load (Settlement.CustomerId);
            if (customer.Email != string.Empty)
            {

                string _from = SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender);

                string to = customer.Email;

            //			string to = "*****@*****.**";

                string subject = SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_template_settlement_subject);
                subject = ReplacePlaceholders (customer, subject);
                subject = ReplacePlaceholders (Settlement, subject);

                string body = SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_template_settlement_body);
                body = ReplacePlaceholders (customer, body);
                body = ReplacePlaceholders (Settlement, body);

                bool isbodyhtml = SorentoLib.Services.Settings.Get<bool> (Enums.SettingsKey.didius_email_template_settlement_isbodyhtml);

                List<SorentoLib.Tools.Helpers.SendMailAttatchment> attatchments = new List<SorentoLib.Tools.Helpers.SendMailAttatchment> ();
                attatchments.Add (new SorentoLib.Tools.Helpers.SendMailAttatchment (SNDK.IO.FileToByteArray (PdfFilename), "afregning" + Settlement.No + ".pdf", SNDK.IO.GetMimeType (PdfFilename)));

                SorentoLib.Tools.Helpers.SendMail (_from, to, subject, body, isbodyhtml, attatchments);
            }
        }
Ejemplo n.º 3
0
        public static Settlement Create(Case Case, bool Simulate)
        {
            Settlement result = new Settlement (Case);

            List<Item> items = Item.List (Case.Id);

            foreach (Item item in items)
            {
                if (!item.Settled)
                {
                    result.Lines.Add (new SettlementLine (item));
                }
            }

            if (result.Lines.Count == 0)
            {
                // EXCEPTION: Exception.SettlementEmpty
                throw new Exception (string.Format (Strings.Exception.SettlementEmpty));
            }

            if (!Simulate)
            {
                foreach (SettlementLine line in result.Lines)
                {
                    Item item = Item.Load (line.ItemId);
                    item.Settled = true;
                    item.Save ();
                }

                result.Save ();
            }

            return result;
        }