Beispiel #1
0
        protected void Application_Error(object src, EventArgs e)
        {
            Log.log("Application Error... ");

            HttpContext context = HttpContext.Current;

            Exception exception = Server.GetLastError();

            Log.log(" Error: " + exception.Message);

            try {
                if (null == exception)
                {
                    throw new AlnitakException("A excepção recebida em Application_Error é null");
                }

                if (exception is HttpUnhandledException)
                {
                    ExceptionInfo info = (ExceptionInfo)context.Cache[OrionGlobals.SessionId + "AlnitakException"];
                    endRequest(info, null);
                }

                ExceptionLog.log(exception);
                Log.log("... Done!");

                Log.log("Going transfer...");
                context.Server.Transfer(OrionGlobals.resolveBase(OrionGlobals.getConfigurationValue("pagePath", "globalError")));
            } catch (System.Threading.ThreadAbortException) {
                Log.log("$$$$$$$ Thread Abort");
            } catch (Exception ex) {
                Log.log("... Exception: " + ex.Message);
                ExceptionInfo info = (ExceptionInfo)context.Cache[OrionGlobals.SessionId + "AlnitakException"];
                endRequest(info, new ExceptionInfo(ex));
            }
        }
Beispiel #2
0
        protected override void OnError(EventArgs e)
        {
            base.OnError(e);
            Log.log("Error...");
            releaseLock();

            Exception exp = Server.GetLastError();

            if (exp != null)
            {
                if (null != HttpContext.Current.Cache[OrionGlobals.SessionId + "ExceptionNumber"])
                {
                    HttpContext.Current.Response.Redirect(OrionGlobals.resolveBase(OrionGlobals.getConfigurationValue("pagePath", "globalError")));
                }
                HttpContext.Current.Cache[OrionGlobals.SessionId + "ExceptionNumber"] = 1;
                ExceptionLog.log(exp);
                HttpContext.Current.Response.Redirect(OrionGlobals.resolveBase("orionsbelterror.aspx"));
            }
            HttpContext.Current.Cache[OrionGlobals.SessionId + "ExceptionNumber"] = 1;
            exp = Server.GetLastError();
            if (exp == null)
            {
                Log.log("\tError: {0}", "null");
                return;
            }
            else
            {
                Log.log("\tError: {0}", exp.ToString());
            }
            ExceptionLog.log(exp);
            HttpContext.Current.Response.Redirect(OrionGlobals.resolveBase("orionsbelterror.aspx"));
        }
Beispiel #3
0
        /// <summary>
        /// obtm uma NamedPageCollection com todas as namedPages
        /// </summary>
        /// <returns>a collections com as NamedPages</returns>
        public static UtilityCollection getAllNamedPages()
        {
            HttpContext       context             = HttpContext.Current;
            UtilityCollection namedPageCollection = (UtilityCollection)context.Cache["NamedPages"];

            if (namedPageCollection == null)
            {
                string value = OrionGlobals.getConfigurationValue("utilities", NamedPageUtilityBase.getNamedPageUtilityKey());

                NamedPageUtilityBase namedPageUtilityBase =
                    (NamedPageUtilityBase)Activator.CreateInstance(Type.GetType(value, true));
                namedPageCollection = namedPageUtilityBase.getAllNamedPagesFromDB();

#if DEBUG
                Log.log("---- NamedPages ----");
                IDictionaryEnumerator it = namedPageCollection.GetEnumerator();
                while (it.MoveNext())
                {
                    PageInfo info = (PageInfo)it.Value;
                    Log.log("{0} - {1}", it.Key, info.pageName);
                }
#endif

                context.Cache["NamedPages"] = namedPageCollection;
            }
            return(namedPageCollection);
        }
Beispiel #4
0
        protected override void OnError(EventArgs e)
        {
            base.OnError(e);
            Exception exception = Server.GetLastError();

            ExceptionLog.log(exception);
            HttpContext.Current.Response.Redirect(OrionGlobals.resolveBase(OrionGlobals.getConfigurationValue("pagePath", "globalError")));
        }
Beispiel #5
0
        /// <summary>Escreve este controlo em html</summary>
        protected override void Render(HtmlTextWriter writer)
        {
            string url = OrionGlobals.getConfigurationValue("alnitak", "url");

            writer.WriteLine("<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">");
            writer.WriteLine("\t<channel>");
            writer.WriteLine("\t<title>Orion's Belt</title>");
            writer.WriteLine("\t<link>{0}</link>", url);
            writer.WriteLine("\t<description>Orion's Belt :: Notícias</description>");
            writer.WriteLine("\t<dc:language>pt-PT</dc:language>");
            writer.WriteLine("\t<generator>Alnitak.RssFeed</generator>");
            writer.WriteLine("\t</channel>");
            writeEntries(writer, url);
            writer.WriteLine("</rss>");
        }
Beispiel #6
0
        /// <summary>Constrói todo o conteúdo do controlo</summary>
        private void buildControlTree()
        {
            ILanguageInfo info = CultureModule.getLanguage();

            User user = (User)Page.User;

            if (user.IsInRole("ruler"))
            {
                Information.AddError(info.getContent("addruler_already-ruler"));
                hide();
                return;
            }

            int count = int.Parse(OrionGlobals.getConfigurationValue("alnitak", "userCount"));

            if (Universe.instance.canAddRuler() && Universe.instance.rulers.Count < count)
            {
                string status = info.getContent("addruler_status-goodnews");
                string m      = string.Format(info.getContent("addruler_intro"), status);
                Information.AddInformation(m);
            }
            else
            {
                string status = info.getContent("addruler_status-badnews");
                string m      = string.Format(info.getContent("addruler_intro"), status);
                Information.AddInformation(m);
                hide();
                return;
            }

            EventHandler click = new EventHandler(this.onClick);

            insertPlanetName.Text = info.getContent("addruler_home-planet");
            planet.TextChanged   += click;

            registerRuler.Text   = info.getContent("register");
            registerRuler.Click += click;

            onlyTextValidator.ErrorMessage      = info.getContent("addruler_planet-only-text") + "<p/>";
            requiredFieldValidator.ErrorMessage = info.getContent("addruler_planet-required") + "<p/>";
            charCountValidator.ErrorMessage     = info.getContent("addruler_planet-tolong");
        }
Beispiel #7
0
        public static UtilityCollection getAllMasterSkins()
        {
            HttpContext context = HttpContext.Current;

            UtilityCollection masterSkinCollection = (UtilityCollection)context.Cache["masterSkins"];

            lock ( lockObj ) {
                if (masterSkinCollection == null)
                {
                    string value = OrionGlobals.getConfigurationValue("utilities", MasterSkinUtilityBase.getMasterSkinUtilityKey());

                    MasterSkinUtilityBase masterSkinUtilityBase =
                        (MasterSkinUtilityBase)Activator.CreateInstance(Type.GetType(value, true));
                    masterSkinCollection         = masterSkinUtilityBase.getAllMasterSkinsFromDB();
                    context.Cache["masterSkins"] = masterSkinCollection;
                }
            }

            return(masterSkinCollection);
        }
Beispiel #8
0
        /// <summary>
        /// Obtm todas as seccoes existentes na base de dados
        /// </summary>
        /// <returns>um objecto do tipo SectionCollection com todas as collections</returns>
        public static UtilityCollection getAllSections()
        {
            HttpContext context = HttpContext.Current;

            UtilityCollection sectionCollection = null;

            //SectionCollection sectionCollection = null;
            lock ( lockObj ) {
                sectionCollection = (UtilityCollection)context.Cache["sections"];
                if (sectionCollection == null)
                {
                    string             value = OrionGlobals.getConfigurationValue("utilities", SectionUtilityBase.getSectionUtilityKey());
                    SectionUtilityBase sectionUtilityBase =
                        (SectionUtilityBase)Activator.CreateInstance(Type.GetType(value, true));
                    sectionCollection         = sectionUtilityBase.getAllSectionsFromDB();
                    context.Cache["sections"] = sectionCollection;
                }
            }
            return(sectionCollection);
        }
Beispiel #9
0
        private bool isSectionAvailable(string section)
        {
            User user = Page.User as User;

            if (user == null || Page.Request.QueryString.Get("id") == null)
            {
                return(true);
            }

            string url = Page.Request.RawUrl.ToLower();

            Planet planet = Universe.instance.getRuler(user.RulerId).getPlanet(Int32.Parse(Page.Request.QueryString["id"]));

            object obj = Available[section];

            if (obj != null)
            {
                IsAvailable available = (IsAvailable)obj;
                return(available(planet));
            }

            if (Page.Request.QueryString.Count != 0 && url.IndexOf("/planet/") != -1 && url.IndexOf("default.aspx") != -1)
            {
                string resourceType = OrionGlobals.getConfigurationValue("sectionResourceTypes", section, false);
                if (null == resourceType)
                {
                    return(true);
                }
                if (!planet.Resources.ContainsKey(resourceType))
                {
                    return(true);
                }
                ResourceInfo info = planet.getResourceInfo(resourceType);
                return(info.AvailableFactories.Count > 0);
            }

            return(false);
        }
Beispiel #10
0
        /// <summary>regista um user</summary>
        private void onClick(object sender, EventArgs args)
        {
            int count = int.Parse(OrionGlobals.getConfigurationValue("alnitak", "userCount"));

            if (Universe.instance.rulers.Count < count)
            {
                User user = (User)Page.User;
                Page.Validate();
                if (Page.IsValid)
                {
                    int id = Universe.instance.addRulerToUniverse(user.Nick, planet.Text);
                    user.RulerId = id;
                    Ruler ruler = Universe.instance.getRuler(id);
                    ruler.ForeignId    = user.UserId;
                    ruler.AllianceId   = user.AllianceId;
                    ruler.AllianceRank = user.AllianceRank;
                    UserUtility.bd.saveUser(user, "");
                    Page.Application["LatestRuler"] = user;
                    Chronos.Utils.Log.log("Registado o " + user.Mail + " com o planeta " + planet.Text);
                    Page.Response.Redirect(OrionGlobals.calculatePath("ruler/default.aspx"));
                }
            }
        }
Beispiel #11
0
        /// <summary>Prepara os controlos</summary>
        protected void setFields()
        {
            User user = (User)Page.User;

            userMail.Text = user.Mail;
            nick.Text     = user.Nick;
            website.Text  = user.Website;

            vacation.Enabled = user.IsInRole("ruler");
            if (vacation.Enabled)
            {
                Ruler ruler = Universe.instance.getRuler(user.RulerId);
                vacation.Checked = ruler.InVacation;
            }

            string avatarUrl = user.Avatar;

            avatar.Text = avatarUrl;
            if (avatarUrl == string.Empty)
            {
                avatarImg.ImageUrl = User.DefaultAvatar;
            }
            else
            {
                avatarImg.ImageUrl = avatarUrl;
            }

            imagesDirText.Text = string.Format(info.getContent("profile_imagesDirText"), OrionGlobals.getConfigurationValue("alnitak", "imagesFile"));
            imagesDir.Text     = user.ImagesDir;

            msn.Text    = user.Msn;
            icq.Text    = user.Icq;
            jabber.Text = user.Jabber;
            aim.Text    = user.Aim;
            yahoo.Text  = user.Yahoo;

            signature.Text = user.Signature;
        }
Beispiel #12
0
        private void Application_BeginRequest(Object source, EventArgs e)
        {
            //obter o HttpContext
            HttpContext Context = HttpContext.Current;

            // verificar o wiki
            string path = CheckWiki(Context.Request.Path);

            // obter os paths do ficheiro e da base
            string requestPath     = OrionGlobals.removePathInfo(path);
            string requestBasePath = OrionGlobals.getSectionPath(requestPath);

            Log.log("Request to: {0}", requestPath);

            try {
                //Descobrir qual a seco pedida e adiciona-la ao Items
                Log.log("Checking for {0} section... ", requestPath);
                SectionInfo sectionInfo = SectionUtility.getSectionInfoFromFullPath(requestPath);
                if (sectionInfo == null)
                {
                    Log.log("\tsectionInfo is null");
                    //normalmente acontece quando e named page
                    sectionInfo = SectionUtility.getSectionInfoFromBasePath(requestBasePath);
                }
                else
                {
                    Log.log("\tsectionInfo ok");
                }

                //quando  imagem cai aqui ou outra coisa qq que n seja seco
                if (sectionInfo == null)
                {
                    Log.log("\tsectionInfo is null");
                    return;
                }

                //adiciona aos items a Items
                Context.Items["SectionInfo"] = sectionInfo;
                Log.log("\tSectionInfo: {0}", sectionInfo.sectionName);

                //Descobrir qual a skin corrente
                MasterSkinInfo masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId(sectionInfo.sectionSkinId);
                if (masterSkinInfo == null)
                {
                    masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId(1);
                }

                //adiciona o nmero da skin (Caso a skin tenha vrios esquemas de cor)
                storeSkinNumber(masterSkinInfo.masterSkinCount);

                //adiciona aos items a Items
                Context.Items["MasterSkinInfo"] = masterSkinInfo;

                PageInfo pageInfo = getPageInfo(sectionInfo, masterSkinInfo, requestPath);
                if (pageInfo != null)
                {
                    Context.Items["PageInfo"] = pageInfo;
                    Chronos.Utils.Log.log("Request: " + requestPath);

                    Log.log("Rewriting Path to '{0}'...", OrionGlobals.UrlBasePage);
                    if (requestPath.IndexOf(".aspx") >= 0)
                    {
                        Log.log("\tDone!");
                        Context.RewritePath(OrionGlobals.UrlBasePage);
                    }
                    else
                    {
                        Log.log("\tNot rewrited! '{0}' isn't aspx", requestPath);
                    }
                }
                else
                {
                    Log.log("PageInfo is null for '{0}'", requestPath);
                }
            } catch (Exception exception) {
                try {
                    ExceptionLog.log(exception);
                } catch (Exception exp) {
                    HttpContext.Current.Cache[OrionGlobals.SessionId + "AlnitakException"] = new ExceptionInfo(exp);;
                }

                //mostrar a pgina de erro global
                HttpContext.Current.Server.Transfer(OrionGlobals.resolveBase(OrionGlobals.getConfigurationValue("pagePath", "globalError")));
            }
        }
Beispiel #13
0
        private static ExceptionLogUtility getInstance()
        {
            string value = OrionGlobals.getConfigurationValue("utilities", ExceptionLogUtility.getExceptionLogKey());

            return((ExceptionLogUtility)Activator.CreateInstance(Type.GetType(value, true)));
        }
Beispiel #14
0
        static UserUtility()
        {
            string value = OrionGlobals.getConfigurationValue("utilities", getKey());

            bd = (UserUtility)Activator.CreateInstance(Type.GetType(value, true));
        }
Beispiel #15
0
 /// <summary>retorna o valor associado a uma key no OrionGroup/language</summary>
 private string getValue(string key)
 {
     return(OrionGlobals.getConfigurationValue("language", key));
 }