Exemplo n.º 1
0
        internal static void Process(string targetpath, HP.Rfg.tasks.DailyTasksRoutine.IMessageCallback msg)
        {
            string ll, cc, ucc, ull;
            List<CountryLanguageDto> countryLanguages = HpFramesFacade.GetListOfCountryLanguages();

            int prevMsgIndex = msg.ToString().Length;

            //do a fresh load if necessary by uncommenting below lines
            //run in debug mode only as public method "cache_hpframes" uses private variable (should be passed to method )
            //and this variable needs to be set properly in debug mode
            //(in other calling methods this is take from utility.getParameter("path_to_temp"))
            //DailyTasksRoutine dc = new DailyTasksRoutine();
            //dc.cache_hpframes(msg, false);
                    
            foreach (CountryLanguageDto item in countryLanguages)
            {

                ll = item.LanguageFK;
                cc = item.CountryFK;
                ull = ll.ToUpper();
                ucc = cc.ToUpper();

                msg.AppendLine("#### Handling (" + cc + "-" + ll + ") ####");

                try
                {
                    HpFramesDto frames = HpFramesFacade.GetHpFramesFromCache(cc, ll, true);
                

                    string headerFile = string.Format("{0}frameparts/header_{1}_{2}.txt", targetpath, ucc, ull);
                    string footerFile = string.Format("{0}frameparts/footer_{1}_{2}.txt", targetpath, ucc, ull);
                    string scriptFile = string.Format("{0}scriptparts/scripts_{1}_{2}.txt", targetpath, ucc, ull);

                    string header = CleanUp(msg, frames.HeaderFrame);
                    string footer = CleanUp(msg, frames.FooterFrame);
                    string script = Create(msg, cc, ll);

                    DailyTasksRoutine.createDir(Path.GetDirectoryName(headerFile));
                    DailyTasksRoutine.createDir(Path.GetDirectoryName(footerFile));
                    DailyTasksRoutine.createDir(Path.GetDirectoryName(scriptFile));

                    Encoding encoding = Encoding.UTF8;

                    if (header != null)
                        File.WriteAllText(headerFile, header, encoding);
                    else
                        msg.AppendLine(headerFile + " was not created: no data!");
                    
                    if (footer != null)
                        File.WriteAllText(footerFile, footer, encoding);
                    else
                        msg.AppendLine(footerFile + " was not created: no data!");

                    if (script != null)
                        File.WriteAllText(scriptFile, script, encoding);
                    else
                        msg.AppendLine(scriptFile + " was not created: no data!");
                }
                catch (Exception e)
                {
                    msg.AppendLine("!! " + e.Message);
                    continue;
                }
            }

        }