public static int WriteXML_Naksatra(StringBuilder doc, GPLocationProvider loc, GPGregorianTime vc, int nDaysCount) { doc.Append("<xml>\n"); doc.Append("\t<request name=\"Naksatra\" version=\"" + GPFileHelper.FileVersion + "\">\n"); doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.GetLongitudeEastPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.GetLatitudeNorthPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getTimeZone().OffsetSeconds / 60 + "\" />\n"); doc.Append("\t\t<arg name=\"startdate\" val=\"" + vc + "\" />\n"); doc.Append("\t\t<arg name=\"daycount\" val=\"" + nDaysCount + "\" />\n"); doc.Append("\t</request>\n"); doc.Append("\t<result name=\"Naksatra\">\n"); GPGregorianTime d = new GPGregorianTime(vc); GPGregorianTime dn = new GPGregorianTime(loc); GPSun sun = new GPSun(); int nak; for (int i = 0; i < 30; i++) { nak = GPNaksatra.GetNextNaksatra(d, out dn); d.Copy(dn); doc.Append("\t\t<day date=\"" + d + "\">\n"); //str = string.Format("{}.{}.{}", d.day, d.month, d.year); //n = m_list.InsertItem(50, GPNaksatra.GetName(nak)); //m_list.SetItemText(n, 1, str); doc.Append("\t\t\t<naksatra id=\"" + nak + "\" name=\"" + GPNaksatra.getName(nak) + "\"\n"); //dt.SetDegTime(d.getDayHours() * 360); //time_print(str, dt); doc.Append("\t\t\t\tstarttime=\"" + d.getShortTimeString() + "\" />\n"); //m_list.SetItemText(n, 2, str); // sunrise time get sun.SunCalc(d, loc); //time_print(str, sun.rise); //m_list.SetItemText(n, 3, str); doc.Append("\t\t\t<sunrise time=\"" + sun.rise + "\" />\n"); doc.Append("\t\t</day>\n"); // increment for non-duplication of naksatra d.Copy(dn); d.setDayHours(d.getDayHours() + 1.0 / 8.0); } doc.Append("\t</result>\n"); doc.Append("</xml>\n"); return(1); }
public static int WriteXML_GaurabdaNextTithi(StringBuilder doc, GPLocationProvider loc, GPGregorianTime vcStart, GPVedicTime vaStart) { int gmasa, gpaksa, gtithi; gmasa = vaStart.masa; gpaksa = vaStart.tithi / 15; gtithi = vaStart.tithi % 15; doc.Append("<xml>\n"); doc.Append("\t<request name=\"Tithi\" version=\"" + GPFileHelper.FileVersion + "\">\n"); doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.GetLongitudeEastPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.GetLatitudeNorthPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getTimeZone().OffsetSeconds / 60 + "\" />\n"); doc.Append("\t\t<arg name=\"start date\" val=\"" + vcStart + "\" />\n"); doc.Append("\t\t<arg name=\"masa\" val=\"" + gmasa + "\" />\n"); doc.Append("\t\t<arg name=\"paksa\" val=\"" + gpaksa + "\" />\n"); doc.Append("\t\t<arg name=\"tithi\" val=\"" + gtithi + "\" />\n"); doc.Append("\t</request>\n"); doc.Append("\t<result name=\"Tithi\">\n"); GPGregorianTime vcs = new GPGregorianTime(loc); GPGregorianTime vce = new GPGregorianTime(loc); GPGregorianTime today = new GPGregorianTime(loc); GPSun sun = new GPSun(); int A; double sunrise; GPAstroData day = new GPAstroData(); int oTithi, oPaksa, oMasa, oYear; today.Copy(vcStart); today.PreviousDay(); vcStart.SubDays(15); for (A = 0; A <= 3; A++) { vcs = GPTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, loc, out vce); if (!vcs.IsBeforeThis(today)) { oTithi = gpaksa * 15 + gtithi; oMasa = gmasa; oPaksa = gpaksa; oYear = 0; doc.Append("\t<celebration\n"); // doc.Append( "\t\t<tithi\n"); doc.Append("\t\trtithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\trmasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\trpaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); // test ci je ksaya today.Copy(vcs); today.setDayHours(0.5); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vcs.getDayHours()) { today.Copy(vce); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vce.getDayHours()) { // normal type vcs.NextDay(); doc.Append("\t\ttype=\"normal\"\n"); } else { // ksaya vcs.NextDay(); day.calculateDayData(vcs, loc); oTithi = day.nTithi; oPaksa = day.nPaksa; oMasa = day.determineMasa(vcs, out oYear); doc.Append("\t\ttype=\"ksaya\"\n"); } } else { // normal, alebo prvy den vriddhi today.Copy(vce); sun.SunCalc(today, loc); if (sun.getSunriseDayHours() < vce.getDayHours()) { // first day of vriddhi type doc.Append("\t\ttype=\"vriddhi\"\n"); } else { // normal doc.Append("\t\ttype=\"normal\"\n"); } } doc.Append("\t\tdate=\"" + vcs + "\"\n"); doc.Append("\t\totithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\tomasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\topaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); doc.Append("\t/>\n"); break; } else { vcStart.Copy(vcs); vcs.NextDay(); } } doc.Append("\t</result>\n"); doc.Append("</xml>\n"); return(1); }
public static XmlDocument GetSankrantiXml(GPLocationProvider loc, GPGregorianTime vcStart, GPGregorianTime vcEnd) { XmlDocument doc = new XmlDocument(); XmlElement e1, e2, e3, eday, e5, e6; GPGregorianTime d = new GPGregorianTime(loc); int zodiac; d.Copy(vcStart); e1 = doc.CreateElement("xml"); doc.AppendChild(e1); e2 = doc.CreateElement("request"); e1.AppendChild(e2); e2.SetAttribute("name", "Sankranti"); e2.SetAttribute("version", GPFileHelper.FileVersion); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "longitude"); e3.SetAttribute("val", loc.GetLongitudeEastPositive().ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "latitude"); e3.SetAttribute("val", loc.GetLatitudeNorthPositive().ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "timezone"); e3.SetAttribute("val", (loc.getTimeZone().OffsetSeconds / 60).ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "startdate"); e3.SetAttribute("val", vcStart.ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "enddate"); e3.SetAttribute("val", vcEnd.ToString()); e2 = doc.CreateElement("result"); e1.AppendChild(e2); e2.SetAttribute("name", "SankrantiList"); while (d.IsBeforeThis(vcEnd)) { d = GPSankranti.GetNextSankranti(d, out zodiac); eday = doc.CreateElement("sank"); e2.AppendChild(eday); eday.SetAttribute("date", d.getLongDateString()); eday.SetAttribute("time", d.getLongTimeString()); eday.SetAttribute("dayweekid", d.getDayOfWeek().ToString()); eday.SetAttribute("dayweek", getSharedStringHtml(d.getDayOfWeek())); e5 = doc.CreateElement("zodiac"); eday.AppendChild(e5); e5.SetAttribute("sans", GPSankranti.GetNameSan(zodiac)); e5.SetAttribute("eng", GPSankranti.GetNameEng(zodiac)); e5.SetAttribute("id", zodiac.ToString()); d.NextDay(); d.NextDay(); } return(doc); }