internal contractMessage GetContractMessageNO1(long contractId) { DataManager dataMan = new DataManager(); cMsg = new contractMessage(); cMsg.messageRecieverParty =""; cMsg.messageSenderParty = "T1ES1"; PartyType provider = new PartyType(); CompanyData companyData = dataMan.GetCompanyData("T1ES1"); provider.name = companyData.Name; provider.registryCode = companyData.RegCode; provider.address = companyData.Address; provider.contactPhone = companyData.ContactPhone; provider.contactEmail = companyData.ContactEmail; cMsg.ProviderParty = provider; ContractData contractData = dataMan.GetContractData(contractId); cMsg.messageRecieverParty = contractData.AreaNetworkOwner; contractMessageClientParty client = new contractMessageClientParty(); client.name = contractData.ClientName; client.registryCode = contractData.ClientRegNo.ToString(); client.address = contractData.ClientAddress; client.contactPhone = contractData.ClientPhone; client.contactEmail = contractData.ClientEmail; client.facilityId = contractData.FacilityId.ToString(); client.areaId = contractData.AreaId.ToString(); cMsg.ClientParty = client; contractMessageContractInfo contract = new contractMessageContractInfo(); contract.startDateSpecified = true; contract.startDate = contractData.StartDate; contract.contractId = contractData.ContractId.ToString(); cMsg.contractInfo = contract; return cMsg; }
public void SendConsumptionForecast(long contractId) { Trace.WriteLine("SendConsumptionForecast"); try { DataManager dataMan = new DataManager(); electricityProfile ep = new electricityProfile(); Random rn = new Random(); ContractData contractData = dataMan.GetContractData(contractId); ep.areaId = contractData.AreaId.ToString(); ep.amount = rn.Next(100, 200).ToString(); ep.contractId = contractData.ContractId.ToString(); ep.dateStart = contractData.StartDate; ep.dateEnd = DateTime.Now; ep.fromId = "T1ES1"; //send to first krado ep.toId = "T1RK1"; try { ep.messageId = dataMan.SaveComposedMessage(ep).ToString(); t1rk1Client = new KradoServiceSoapClient(); balanceInvoice bi = t1rk1Client.presumableLoadProfile(ep); this.ReceiveBalanceInvoice(bi); } catch (Exception rk1Exc) { Trace.WriteLine("Error sending consumption forecast to T1RK1: " + rk1Exc.Message); } //send to second krado ep.toId = "T1RK2"; try { ep.messageId = dataMan.SaveComposedMessage(ep).ToString(); t1rk2Client = new ReceiveClient(); string tmp = t1rk2Client.ReceiveCfFromEs("some piparkoogid from T1ES1"); } catch (Exception rk2Exc) { Trace.WriteLine("Error sending consumption forecast to T1RK2: " + rk2Exc.Message); } } catch (Exception scfExc) { Trace.WriteLine("Error sending consumption forecast: " + scfExc.Message); } }
public int ReceiveBalanceInvoice(balanceInvoice invoice) { Trace.WriteLine("ReceiveBalanceInvoice"); int result = 0; try { DataManager dataMan = new DataManager(); ContractData cData = dataMan.GetContractData(Int64.Parse(invoice.contractId)); if (cData.EndDate < new DateTime(1990, 1, 1)) { Trace.WriteLine("Contract is not terminated. Message not saved, returning 1, finishing."); return 1; } if (dataMan.SaveInvoice(invoice) == 1) { try { MailMessage mail = new MailMessage("*****@*****.**", cData.ClientEmail); mail.Subject = "T1ES1: Invoice nr." + invoice.invoiceNo; mail.Body = String.Format("Congratulations: you have received invoice nr. {0}, dated by {1}, made by {5}. Please make payment with amount {2} before {3}, or you will be banned with our mighty banhammer!\n You can see your invoices in our User frontend at {4} on the 'Invoices' page.", invoice.invoiceNo, invoice.date.ToString("dd.MM.yyyy"), invoice.amount.ToString("0.00"), invoice.dueDate.ToString("dd.MM.yyyy"), "http://sandstorm.cs.ut.ee/ESI/2011/otido/Frontend/", invoice.kradoId); SmtpClient sc = new SmtpClient("mailhost.ut.ee"); sc.Send(mail); result = 1; } catch (Exception mailSendExc) { Trace.WriteLine("Error sending email: " + mailSendExc.Message); result = 0; } }; } catch (Exception rbiExc) { Trace.WriteLine("Error receiving balance invoice: " + rbiExc.Message); result = 0; } return result; }