예제 #1
0
        /// <summary>
        /// Formating of data into text file
        /// </summary>
        /// <param name="str">Output string builder</param>
        /// <param name="df">Requested data format</param>
        public override string formatText(string df)
        {
            GSScript script = new GSScript();

            switch (df)
            {
            case GCDataFormat.PlainText:
                script.readTextTemplate(Properties.Resources.TplTodayPlain);
                break;

            case GCDataFormat.Rtf:
                script.readTextTemplate(Properties.Resources.TplTodayRtf);
                break;

            case GCDataFormat.HTML:
                script.readTextTemplate(Properties.Resources.TplTodayHtml);
                break;

            default:
                break;
            }

            GSExecutor engine = new GSExecutor();

            engine.SetVariable("today", GetCurrentDay());
            engine.SetVariable("location", calendar.m_Location);
            engine.SetVariable("app", GCUserInterface.Shared);
            engine.ExecuteElement(script);

            return(engine.getOutput());
        }
예제 #2
0
        public void OnMenuItem(MNMenuItem mi, MNPage page)
        {
            Executor.SetVariable("page", page);
            GSScript os = new GSScript();

            os.readList(mi.ActionScript);
            Executor.ExecuteElement(os);
        }
예제 #3
0
        public override string formatText(string df)
        {
            GSScript script = new GSScript();

            switch (df)
            {
            case GCDataFormat.PlainText:
                script.readTextTemplate(Properties.Resources.TplCalendarPlain);
                break;

            case GCDataFormat.Rtf:
                script.readTextTemplate(Properties.Resources.TplCalendarRtf);
                break;

            case GCDataFormat.HTML:
                script.readTextTemplate(Properties.Resources.TplCalendarHtml);
                break;

            case GCDataFormat.XML:
                script.readTextTemplate(Properties.Resources.TplCalendarXml);
                break;

            case GCDataFormat.CSV:
                script.readTextTemplate(Properties.Resources.TplCalendarCsv);
                break;

            case GCDataFormat.ICAL:
                script.readTextTemplate(Properties.Resources.TplCalendarICAL);
                break;

            case GCDataFormat.VCAL:
                script.readTextTemplate(Properties.Resources.TplCalendarVCAL);
                break;

            case "htmlTable":
                script.readTextTemplate(Properties.Resources.TplCalendarHtmlTable);
                break;

            case "htmlSadhana":
                script.readTextTemplate(Properties.Resources.TplCalendarSadhana);
                break;

            default:
                break;
            }


            GSExecutor engine = new GSExecutor();

            engine.SetVariable("calendar", this);
            engine.SetVariable("location", this.m_Location);
            engine.SetVariable("app", GCUserInterface.Shared);
            engine.ExecuteElement(script);

            return(engine.getOutput());
        }
예제 #4
0
 /// <summary>
 /// Executing of selected script
 /// Here we respect levels of processing:
 /// - control
 /// - control group
 /// - page
 /// - application (document, book)
 /// </summary>
 /// <param name="areaId"></param>
 /// <param name="area"></param>
 /// <param name="scriptKey"></param>
 private void ExecuteScriptForKey(GSCore obj, GSScript os)
 {
     if (obj is SMControl)
     {
         Executor.SetVariable("control", (SMControl)obj);
     }
     else if (obj is MNPage)
     {
         Executor.SetVariable("control", null);
     }
     Executor.ExecuteElement(os);
 }
예제 #5
0
        /// <summary>
        /// Executes objects in the list and possibly add new objects in succession
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="scheduled"></param>
        private void ExecuteScheduledObjects(GSCore parent)
        {
            if (scheduledScripts != null)
            {
                for (int i = 0; i < scheduledScripts.Count; i++)
                {
                    GSScript go = new GSScript();
                    go.readList(scheduledScripts[i]);
                    ExecuteScriptForKey(parent, go);
                }
            }

            scheduledScripts.Clear();
        }
예제 #6
0
        /// <summary>
        /// If newText is changed during the processing of this method
        /// then running of this method is aborted and new search starts in backSearch_DoWork
        /// by assigning newText value into currentText
        /// </summary>
        private void doSearch(string text, CancellationTokenSource tokenSource)
        {
            TResultCalendar cal = new TResultCalendar();
            string          dayText;

            cal.CalculateCalendar(EarthLocation, new GregorianDateTime(), 700);

            StringBuilder results3 = new StringBuilder();

            GSScript script = new GSScript();

            script.readTextTemplate(TResultCalendar.getPlainDayTemplate());

            GSExecutor exec = new GSExecutor();


            for (int i = 0; i < cal.m_PureCount; i++)
            {
                VAISNAVADAY vd = cal.GetDay(i);

                exec.SetVariable("app", GCUserInterface.Shared);
                exec.SetVariable("location", EarthLocation);
                exec.SetVariable("pvd", vd);

                //dayText = TResultCalendar.formatPlainTextDay(vd);
                exec.resetOutput();
                exec.ExecuteElement(script);
                dayText = exec.getOutput();
                //Debugger.Log(0, "", "SEARCH IN TEXT: " + dayText + "\n\n");
                if (dayText.IndexOf(text, 0, StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    results3.AppendLine();
                    results3.AppendLine(dayText);
                }
                if (tokenSource.IsCancellationRequested)
                {
                    return;
                }
            }

            if (!tokenSource.IsCancellationRequested)
            {
                FinalizeDelegate dlg = new FinalizeDelegate(setRichText);
                richTextBox1.BeginInvoke(dlg, results3.ToString());
                ctTask = null;
                ctPrev = null;
            }
        }
예제 #7
0
        public override string formatText(string templateName)
        {
            GSScript script = new GSScript();

            switch (templateName)
            {
            case GCDataFormat.PlainText:
                script.readTextTemplate(Properties.Resources.TplRatedPlain);
                break;

            case GCDataFormat.Rtf:
                script.readTextTemplate(Properties.Resources.TplRatedRtf);
                break;

            case GCDataFormat.HTML:
                script.readTextTemplate(Properties.Resources.TplRatedHtml);
                break;

            case GCDataFormat.XML:
                script.readTextTemplate(Properties.Resources.TplRatedXml);
                break;

            case GCDataFormat.CSV:
                script.readTextTemplate(Properties.Resources.TplRatedCsv);
                break;

            default:
                break;
            }


            GSExecutor engine = new GSExecutor();

            engine.SetVariable("events", this);
            engine.SetVariable("location", this.EarthLocation);
            engine.SetVariable("app", GCUserInterface.Shared);
            engine.ExecuteElement(script);


            return(engine.getOutput());
        }
예제 #8
0
        /// <summary>
        /// Generates text file based on given data format template
        /// </summary>
        /// <param name="str">Output stream</param>
        /// <param name="df">Requested data format</param>
        /// <returns></returns>
        public override string formatText(string df)
        {
            GSScript script = new GSScript();

            switch (df)
            {
            case GCDataFormat.PlainText:
                script.readTextTemplate(Properties.Resources.TplMasaListPlain);
                break;

            case GCDataFormat.Rtf:
                script.readTextTemplate(Properties.Resources.TplMasaListRtf);
                break;

            case GCDataFormat.HTML:
                script.readTextTemplate(Properties.Resources.TplMasaListHtml);
                break;

            case GCDataFormat.XML:
                script.readTextTemplate(Properties.Resources.TplMasaListXml);
                break;

            case GCDataFormat.CSV:
                script.readTextTemplate(Properties.Resources.TplMasaListCsv);
                break;

            default:
                break;
            }


            GSExecutor engine = new GSExecutor();

            engine.SetVariable("mlist", this);
            engine.SetVariable("location", this.m_location);
            engine.SetVariable("app", GCUserInterface.Shared);
            engine.ExecuteElement(script);

            return(engine.getOutput());
        }
예제 #9
0
        private static void TestScripting1()
        {
            GSExecutor es = new GSExecutor();

            GSScript scr = new GSScript();

            es.SetVariable("alg1", new GSNumber()
            {
                IntegerValue = 67
            });
            es.SetVariable("alg2", new GSString()
            {
                Value = "This is string"
            });
            es.SetVariable("alg3", new GSNumber()
            {
                DoubleValue = 18.29893
            });

            scr.readTextTemplate("[alg1:08d] [alg2:-18s] [alg3:5.3f]");
            es.ExecuteElement(scr);
            scr.Parts.Clear();
        }
        public static void Export(string pszFile, int format)
        {
            String strc;

            using (StreamWriter f = new StreamWriter(pszFile))
            {
                foreach (GCFestivalBook book in GCFestivalBookCollection.Books)
                {
                    switch (format)
                    {
                    case 1:
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("{0}\n\t{1} Tithi,{2} Paksa,{3} Masa\n", pce.Text,
                                                     GCTithi.GetName(pce.nTithi), GCPaksa.GetName(pce.nTithi / 15), GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                                if (pce.FastID != 0)
                                {
                                    strc = string.Format("\t{0}\n", GCStrings.GetFastingName(pce.FastID));
                                    f.Write(strc);
                                }
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write(string.Format("{0}\n\t\t{1} Sankranti, {2}\n", se.Text, GCRasi.GetName(se.RasiOfSun), se.DayOffset));
                            }
                        }

                        break;

                    case 2:
                    {
                        f.Write("<xml>\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t<event>\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("\t\t<name>{0}</name>\n", pce.Text);
                                f.Write(strc);
                                strc = string.Format("\t\t<tithi>{0}</tithi>\n", GCTithi.GetName(pce.nTithi));
                                f.Write(strc);
                                strc = string.Format("\t\t<paksa>{0}</paksa>\n", GCPaksa.GetName(pce.nTithi / 15));
                                f.Write(strc);
                                strc = string.Format("\t\t<masa>{0}</masa>\n", GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t<name>" + se.Text + "</name>\n");
                                f.Write("\t\t<sankranti>" + GCRasi.GetName(se.RasiOfSun) + "</sankranti>\n");
                                f.Write("\t\t<rel>" + se.DayOffset + "</rel>\n");
                            }

                            if (fb.EventsCount > 0)
                            {
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t<relatedEvent>\n");
                                        f.Write("\t\t\t<name>" + rel.Text + "</name>\n");
                                        f.Write("\t\t\t<offset>" + rel.DayOffset + "</offset>\n");
                                        f.Write("\t\t</relatedEvent>\n");
                                    }
                                }
                            }

                            f.Write("\t</event>\n");
                        }

                        f.Write("</xml>\n");
                    }
                    break;

                    case 3:
                        GSScript script = new GSScript();
                        script.Add(new GSToken("book"));
                        script.Add(new GSList(new GSToken("bookId"), new GSNumber(book.CollectionId)));
                        script.Add(new GSList(new GSToken("bookName"), new GSString(book.CollectionName)));
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            script.Add(fb.ExecuteMessage("getScript"));
                        }
                        script.writeScript(f);
                        break;

                    case 15:
                    {
                        f.Write("{\n");
                        f.Write("\tname: \"" + book.CollectionName + "\",\n");
                        f.Write("\tbookid: " + book.CollectionId + ",\n");
                        f.Write("\tevents: [\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t\t{\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                f.Write("\t\t\ttype: \"T\",\n");
                                f.Write("\t\t\tname: \"{0}\",\n", pce.Text);
                                f.Write("\t\t\ttithi: {0},\n", pce.nTithi);
                                f.Write("\t\t\tmasa: {0}\n", pce.nMasa);
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", pce.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", pce.FastID);
                                f.Write("\t\t\tstart: {0},\n", pce.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", pce.DayOffset);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t\ttype:\"S\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tsankranti: " + se.RasiOfSun + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalSpecial)
                            {
                                GCFestivalSpecial spe = fb as GCFestivalSpecial;
                                f.Write("\t\t\ttype: \"X\",\n");
                                f.Write("\t\t\tname: \"" + spe.Text + "\",\n");
                                f.Write("\t\t\tmasa1: " + spe.nMasaMin + ",\n");
                                f.Write("\t\t\tmasa2: " + spe.nMasaMax + ",\n");
                                f.Write("\t\t\tscript: \"" + spe.Script + "\",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalEkadasi)
                            {
                                GCFestivalEkadasi se = fb as GCFestivalEkadasi;
                                f.Write("\t\t\ttype: \"E\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tmasa: " + se.nMasa + ",\n");
                                f.Write("\t\t\tpaksa: " + se.nPaksa + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }

                            if (fb.EventsCount > 0)
                            {
                                f.Write("\t\t\tevents: [\n");
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t\t\t{\n\t\t\t\t\ttype:\"R\",\n");
                                        f.Write("\t\t\t\t\tname: \"" + rel.Text + "\",\n");
                                        f.Write("\t\t\t\t\tfastSubj: \"{0}\",\n", fb2.FastingSubject);
                                        f.Write("\t\t\t\t\tfast: {0},\n", fb2.FastID);
                                        f.Write("\t\t\t\t\tstart: {0},\n", fb2.StartYear);
                                        f.Write("\t\t\t\t\tdayoff: {0},\n", fb2.DayOffset);
                                        f.Write("\t\t\t\t},\n");
                                    }
                                }
                                f.Write("\t\t\t]");
                            }

                            f.Write("\t\t},\n");
                        }

                        f.Write("\t]\n");
                        f.Write("},\n");
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
        public static void Export(string pszFile, int format)
        {
            String strc;

            using (StreamWriter f = new StreamWriter(pszFile))
            {
                foreach (GCFestivalBook book in GCFestivalBookCollection.Books)
                {
                    switch (format)
                    {
                    case 1:
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("{0}\n\t{1} Tithi,{2} Paksa,{3} Masa\n", pce.Text,
                                                     GCTithi.GetName(pce.nTithi), GCPaksa.GetName(pce.nTithi / 15), GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                                if (pce.FastID != 0)
                                {
                                    strc = string.Format("\t{0}\n", GCStrings.GetFastingName(pce.FastID));
                                    f.Write(strc);
                                }
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write(string.Format("{0}\n\t\t{1} Sankranti, {2}\n", se.Text, GCRasi.GetName(se.RasiOfSun), se.DayOffset));
                            }
                        }

                        break;

                    case 2:
                    {
                        f.Write("<xml>\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t<event>\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("\t\t<name>{0}</name>\n", pce.Text);
                                f.Write(strc);
                                strc = string.Format("\t\t<tithi>{0}</tithi>\n", GCTithi.GetName(pce.nTithi));
                                f.Write(strc);
                                strc = string.Format("\t\t<paksa>{0}</paksa>\n", GCPaksa.GetName(pce.nTithi / 15));
                                f.Write(strc);
                                strc = string.Format("\t\t<masa>{0}</masa>\n", GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t<name>" + se.Text + "</name>\n");
                                f.Write("\t\t<sankranti>" + GCRasi.GetName(se.RasiOfSun) + "</sankranti>\n");
                                f.Write("\t\t<rel>" + se.DayOffset + "</rel>\n");
                            }

                            if (fb.EventsCount > 0)
                            {
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t<relatedEvent>\n");
                                        f.Write("\t\t\t<name>" + rel.Text + "</name>\n");
                                        f.Write("\t\t\t<offset>" + rel.DayOffset + "</offset>\n");
                                        f.Write("\t\t</relatedEvent>\n");
                                    }
                                }
                            }

                            f.Write("\t</event>\n");
                        }

                        f.Write("</xml>\n");
                    }
                    break;

                    case 3:
                        GSScript script = new GSScript();
                        script.Add(new GSToken("book"));
                        script.Add(new GSList(new GSToken("bookId"), new GSNumber(book.CollectionId)));
                        script.Add(new GSList(new GSToken("bookName"), new GSString(book.CollectionName)));
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            script.Add(fb.ExecuteMessage("getScript"));
                        }
                        script.writeScript(f);
                        break;

                    default:
                        break;
                    }
                }
            }
        }