public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { m_request = context.Request; m_response = context.Response; m_cookieCollection = context.Request.Cookies; m_asyncResult = new NuxleusAsyncResult(cb, extraData); HttpCookie sessionid = m_cookieCollection["sessionid"]; HttpCookie userid = m_cookieCollection["userid"]; HttpCookie username = m_cookieCollection["username"]; HttpCookie name = m_cookieCollection["name"]; HttpCookie uservalidated = m_cookieCollection["uservalidated"]; string ip = m_request.UserHostAddress.ToString(); NameValueCollection form = m_request.Form; m_returnLocation = form.Get("return-url"); //string collection_id = form.Get("collection-id"); string collection_name = form.Get("collection-name"); string collection_id = Guid.NewGuid().ToString(); string path = m_request.MapPath(String.Format("/member/{0}/media/{1}", userid.Value, collection_id)); if (!Directory.Exists(path)) { DirectoryInfo directory = Directory.CreateDirectory(path); } List<AwsSdbModel.Attribute> attributes = new List<AwsSdbModel.Attribute>(); attributes.Add(new AwsSdbModel.Attribute { Name = "CollectionName", Value = collection_name }); attributes.Add(new AwsSdbModel.Attribute { Name = "CollectionOwner", Value = userid.Value }); PutAttributesTask task = new PutAttributesTask { DomainName = new Domain { Name = "collections" }, Item = new Item { ItemName = collection_id, Attribute = attributes } }; IResponse response = task.Invoke(); PutAttributesResult result = (PutAttributesResult)response.Result; foreach (string header in response.Headers) { m_response.Write(String.Format("ResponseHeader: {0}: {1}", header, response.Headers[header])); } //m_response.Write(result.Metadata.RequestId); WriteDebugXmlToOutputStream(attributes); m_asyncResult.CompleteCall(); return m_asyncResult; }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { m_request = context.Request; m_response = context.Response; m_cookieCollection = context.Request.Cookies; m_asyncResult = new NuxleusAsyncResult(cb, extraData); HttpCookie sessionid = m_cookieCollection["sessionid"]; HttpCookie userid = m_cookieCollection["userid"]; HttpCookie username = m_cookieCollection["username"]; HttpCookie name = m_cookieCollection["name"]; HttpCookie uservalidated = m_cookieCollection["uservalidated"]; string ip = m_request.UserHostAddress.ToString(); NameValueCollection form = m_request.Form; m_returnLocation = form.Get("return_url"); string eventname = form.Get("name"); string description = form.Get("description"); //string location = form.Get("location"); string venue = form.Get("venue"); string genre = form.Get("genre"); string startdate = form.Get("startdate"); string starttime = form.Get("starttime"); string endtime = form.Get("endtime"); string tags = form.Get("tags"); string eventid = Guid.NewGuid().ToString(); List<AwsSdbModel.Attribute> attributes = new List<AwsSdbModel.Attribute>(); attributes.Add(new AwsSdbModel.Attribute { Name = "name", Value = eventname }); attributes.Add(new AwsSdbModel.Attribute { Name = "description", Value = description }); attributes.Add(new AwsSdbModel.Attribute { Name = "venue", Value = venue }); attributes.Add(new AwsSdbModel.Attribute { Name = "genre", Value = genre }); attributes.Add(new AwsSdbModel.Attribute { Name = "startdate", Value = startdate }); attributes.Add(new AwsSdbModel.Attribute { Name = "starttime", Value = starttime }); attributes.Add(new AwsSdbModel.Attribute { Name = "endtime", Value = endtime }); attributes.Add(new AwsSdbModel.Attribute { Name = "tags", Value = tags }); attributes.Add(new AwsSdbModel.Attribute { Name = "eventid", Value = eventid }); attributes.Add(new AwsSdbModel.Attribute { Name = "eventcreator", Value = userid.Value }); PutAttributesTask task = new PutAttributesTask { DomainName = new Domain { Name = "event" }, Item = new Item { ItemName = eventid, Attribute = attributes } }; IResponse response = task.Invoke(); PutAttributesResult result = (PutAttributesResult)response.Result; WriteDebugXmlToOutputStream(attributes); m_asyncResult.CompleteCall(); return m_asyncResult; }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { m_request = context.Request; m_response = context.Response; m_cookieCollection = context.Response.Cookies; m_asyncResult = new NuxleusAsyncResult(cb, extraData); HttpCookie c_sessionid = new HttpCookie("sessionid"); HttpCookie c_userid = new HttpCookie("userid"); HttpCookie c_username = new HttpCookie("username"); HttpCookie c_name = new HttpCookie("name"); HttpCookie c_validated = new HttpCookie("uservalidated"); DateTime expires = DateTime.Now.AddDays(1); c_sessionid.Expires = expires; c_userid.Expires = expires; c_username.Expires = expires; c_name.Expires = expires; c_validated.Expires = expires; string ip = m_request.UserHostAddress.ToString(); NameValueCollection form = m_request.Form; m_returnLocation = form.Get("return_url"); string name = form.Get("name"); string userid = form.Get("email").GetHashCode().ToString(); string username = form.Get("username"); string password = form.Get("password"); string email = form.Get("email"); string user_time_zone = form.Get("user[time_zone]"); string user_url = form.Get("user[url]"); string user_description = form.Get("user[description]"); string user_location = form.Get("user[location]"); string user_lang = form.Get("user[lang]"); string sessionid = Guid.NewGuid().ToString(); string myuserid = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(String.Format("{0}:{1}:{2}", name, Guid.NewGuid(), email).ToCharArray())).ToString(); c_sessionid.Value = sessionid; c_userid.Value = userid; c_username.Value = username; c_name.Value = name; c_validated.Value = "true"; m_cookieCollection.Add(c_sessionid); m_cookieCollection.Add(c_userid); m_cookieCollection.Add(c_username); m_cookieCollection.Add(c_name); m_cookieCollection.Add(c_validated); List<AwsSdbModel.Attribute> attributes = new List<AwsSdbModel.Attribute>(); attributes.Add(new AwsSdbModel.Attribute { Name = "name", Value = name }); attributes.Add(new AwsSdbModel.Attribute { Name = "username", Value = username }); attributes.Add(new AwsSdbModel.Attribute { Name = "password", Value = password }); attributes.Add(new AwsSdbModel.Attribute { Name = "email", Value = email }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_time_zone", Value = user_time_zone }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_url", Value = user_url }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_description", Value = user_description }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_location", Value = user_location }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_lang", Value = user_lang }); attributes.Add(new AwsSdbModel.Attribute { Name = "session_id", Value = sessionid }); PutAttributesTask task = new PutAttributesTask { DomainName = new Domain { Name = "account" }, Item = new Item { ItemName = myuserid, Attribute = attributes } }; IResponse response = task.Invoke(); m_asyncResult.CompleteCall(); return m_asyncResult; }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { HttpRequest request = context.Request; m_response = context.Response; m_response.ContentType = "text/xml"; m_asyncResult = new NuxleusAsyncResult(cb, extraData); NameValueCollection form = request.Form; m_returnLocation = form.Get("return_url"); string name = form.Get("name"); string slug = form.Get("slug"); string base_uri = form.Get("base_uri"); string base_path = form.Get("base_path"); string title = form.Get("title"); string ip = context.Request.UserHostAddress.ToString(); string item = context.Request.Cookies["userid"].Value; string username = form.Get("username"); string email = form.Get("email"); string user_time_zone = form.Get("user[time_zone]"); string user_url = form.Get("user[url]"); string user_description = form.Get("user[description]"); string user_location = form.Get("user[location]"); string user_lang = form.Get("user[lang]"); List<AwsSdbModel.Attribute> attributes = new List<AwsSdbModel.Attribute>(); attributes.Add(new AwsSdbModel.Attribute { Name = "name", Value = name }); attributes.Add(new AwsSdbModel.Attribute { Name = "username", Value = username }); attributes.Add(new AwsSdbModel.Attribute { Name = "email", Value = email }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_time_zone", Value = user_time_zone }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_url", Value = user_url }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_description", Value = user_description }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_location", Value = user_location }); attributes.Add(new AwsSdbModel.Attribute { Name = "user_lang", Value = user_lang }); PutAttributesTask task = new PutAttributesTask { DomainName = new Domain { Name = "account" }, Item = new Item { ItemName = item, Attribute = attributes } }; IResponse response = task.Invoke(); //var paragraphs = from line in ReadParagraphsFromContent(HttpUtility.HtmlDecode(form.Get("suggestion"))) // select GetXmlFromHtmlString(line); XDocument doc = new XDocument( new XElement(h + "div", new XElement(h + "div", name), new XElement(h + "div", username), new XElement(h + "div", email), new XElement(h + "div", user_time_zone), new XElement(h + "div", user_url), new XElement(h + "div", user_description), new XElement(h + "div", user_location), new XElement(h + "div", user_lang), new XElement(h + "div", (PutAttributesResponse)response) ) ); string xmlOutput = null; using (TextWriter writer = new StringWriter()) { doc.Save(writer); xmlOutput = writer.ToString(); m_response.Write(xmlOutput); } byte[] output = m_encoding.GetBytes(xmlOutput); char[] chars = m_encoding.GetChars(output, 0, output.Length); lock (m_lock) { string basePath = request.MapPath(String.Format("~{0}", base_path)); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } m_file = new FileStream(String.Format("{0}/{1}.xml", basePath, Guid.NewGuid()), FileMode.Create, FileAccess.Write, FileShare.ReadWrite, 1024, true); m_file.Seek(0, 0); return m_file.BeginWrite(output, 0, output.Length, cb, extraData); } //m_asyncResult.CompleteCall(); //return m_asyncResult; }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { m_request = context.Request; m_response = context.Response; m_cookieCollection = context.Request.Cookies; m_asyncResult = new NuxleusAsyncResult(cb, extraData); HttpCookie sessionid = m_cookieCollection["sessionid"]; HttpCookie userid = m_cookieCollection["userid"]; HttpCookie username = m_cookieCollection["username"]; HttpCookie name = m_cookieCollection["name"]; HttpCookie uservalidated = m_cookieCollection["uservalidated"]; string ip = m_request.UserHostAddress.ToString(); NameValueCollection form = m_request.Form; HttpFileCollection files = m_request.Files; m_response.Write(files.Count); m_returnLocation = form.Get("return-url"); string medianame = form.Get("name"); string description = form.Get("description"); string collection_name = form.Get("collection-name"); string collection_id = form.Get("collection-id"); string tags = form.Get("tags"); string mediaid = Guid.NewGuid().ToString(); string virtualPath = String.Format("/member/{0}/media/{1}", userid.Value, collection_id); string path = m_request.MapPath(virtualPath); for (int i = 0; i < files.Count; i++) { HttpPostedFile postedFile = files[i]; string localFilePath = String.Empty; try { if (!Directory.Exists(path)) { DirectoryInfo directory = Directory.CreateDirectory(path); } Stream fileStream = postedFile.InputStream; string hash = new HashcodeGenerator(fileStream).GetHashCode().ToString(); string fileName = String.Format("{0}{1}", hash, Path.GetExtension(postedFile.FileName)); localFilePath = String.Format("{0}\\{1}", path, fileName); postedFile.SaveAs(localFilePath); string uri = String.Format("{0}{1}/{2}", m_baseMediaDomain, virtualPath, fileName); List<AwsSdbModel.Attribute> attributes = new List<AwsSdbModel.Attribute>(); attributes.Add(new AwsSdbModel.Attribute { Name = "medianame", Value = medianame }); attributes.Add(new AwsSdbModel.Attribute { Name = "description", Value = description }); attributes.Add(new AwsSdbModel.Attribute { Name = "tags", Value = tags }); attributes.Add(new AwsSdbModel.Attribute { Name = "CollectionName", Value = collection_name }); attributes.Add(new AwsSdbModel.Attribute { Name = "CollectionId", Value = collection_id }); attributes.Add(new AwsSdbModel.Attribute { Name = "mediaid", Value = mediaid }); attributes.Add(new AwsSdbModel.Attribute { Name = "uri", Value = uri }); attributes.Add(new AwsSdbModel.Attribute { Name = "mediacreator", Value = userid.Value }); PutAttributesTask task = new PutAttributesTask { DomainName = new Domain { Name = "media" }, Item = new Item { ItemName = mediaid, Attribute = attributes } }; IResponse response = task.Invoke(); PutAttributesResult result = (PutAttributesResult)response.Result; foreach (string header in response.Headers) { m_response.Write(String.Format("ResponseHeader: {0}: {1}", header, response.Headers[header])); } WriteDebugXmlToOutputStream(attributes); } catch (Exception e) { m_response.Write(e.Message); } } m_asyncResult.CompleteCall(); return m_asyncResult; }