Esempio n. 1
0
        public Configuration GetConfiguration()
        {
            var conf = new GlobalConfiguration
            {
                BasePath = SiteUri.ToString()
            };

            return(conf);
        }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string guid = Request.QueryString[string.Empty];

        if (guid == null || !Regex.IsMatch(guid, "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"))
        {
            Response.StatusCode = 301;
            Response.Status     = "301 Moved Permanently";
            Response.AddHeader("Location", SiteUri.ToString());
            Response.End();
        }

        Meta.SQL.IDatabase       db     = new Meta.SQL.Module().Database;
        Ps2Css.DB.Request.Module module = new Ps2Css.DB.Request.Module(db);
        Ps2Css.DB.Request.Item   item   = module.GetByID(new Guid(guid));
        if (item != null)
        {
            int diff = (int)Math.Ceiling((DateTime.Now - item.Created).TotalSeconds);
            if (diff < InitialDelay)
            {
                this.wait = InitialDelay - diff;
            }
            else
            {
                this.wait = 0;
                try
                {
                    Document doc = new Ps2Css.Xml.Document(Encoding.UTF8.GetString(Zlib.Decompress(item.Data)));
                    this.Styles = doc.Styles.ToArray();
                }
                catch (Ps2Css.Xml.CorruptedXmlException ex)
                {
                    exception = ex.GetType().ToString();
                    base.Log("XML parsing error");
                }
                catch (Exception ex)
                {
                    exception = "System.Exception";
                    base.Log(ex);
                }
            }
        }
        else
        {
            if (Request.UrlReferrer != null)
            {
                exception = "StyleNotFound";
            }
        }
    }
Esempio n. 3
0
 public ClientContext Connect()
 {
     if (UseAppAuthentication == true)
     {
         AuthenticationManager authenticationManager = new AuthenticationManager();
         string realm = TokenHelper.GetRealmFromTargetUrl(new Uri(SiteUri.ToString()));
         return(authenticationManager.GetAppOnlyAuthenticatedContext(SiteUri.ToString(), realm, Login, Password));
     }
     else
     {
         ClientContext context        = new ClientContext(SiteUri.ToString());
         var           securePassword = new SecureString();
         foreach (char c in Password)
         {
             securePassword.AppendChar(c);
         }
         SharePointOnlineCredentials onlineCredentials = new SharePointOnlineCredentials(Login, securePassword);
         context.Credentials        = onlineCredentials;
         context.AuthenticationMode = ClientAuthenticationMode.Default;
         return(context);
     }
 }