Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

            try
            {
                Response.Write(Constants.ERROR_XML);
                return;

                string sfsize = Utils.GetParam("fsize");
                long   fsize  = 0;
                long.TryParse(sfsize, out fsize);

                if (fsize <= 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                string fname = Utils.GetParam("fname");
                if (fname.Trim().Length == 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                string uname = Utils.GetParam("uname");
                if (uname.Trim().Length == 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                FileNameHash_Rep repHash = new FileNameHash_Rep();

                // check for user specific
                FileNameHash        fnh  = null;
                List <FileNameHash> recs = repHash.SearchForUser(uname, fsize, fname);
                if (recs.Count == 0)
                {
                    // check for other users
                    recs = repHash.SearchForAll(fsize, fname);
                    if (recs.Count > 0)
                    {
                        fnh = recs[0];
                    }
                }
                else
                {
                    fnh = recs[0];
                }



                if (fnh == null)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                FileHashResult data = new FileHashResult(fnh.Hash);
                string         ret  = Utils.ConvertToXML(data, typeof(FileHashResult));

                Response.Write(ret);
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
                return;
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

            try
            {
                Response.Write(Constants.ERROR_XML);
                return;

                FileNameHash_Rep repHash = new FileNameHash_Rep();

                StreamReader reader  = new StreamReader(this.Request.InputStream);
                String       xmlData = reader.ReadToEnd();

                XmlDocument docFile = new XmlDocument();
                docFile.LoadXml(xmlData);

                string hash   = Utils.TryGetProperty("FileHashRequest", docFile, "Hash").Trim().ToUpper();
                string fname  = Utils.TryGetProperty("FileHashRequest", docFile, "Fname");
                string uname  = Utils.TryGetProperty("FileHashRequest", docFile, "Uname");
                string sfsize = Utils.TryGetProperty("FileHashRequest", docFile, "Fsize");
                long   fsize  = 0;
                long.TryParse(sfsize, out fsize);

                if (string.IsNullOrEmpty(hash) || string.IsNullOrEmpty(fname) || string.IsNullOrEmpty(uname) || fsize <= 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                FileNameHash        fnh  = null;
                List <FileNameHash> recs = repHash.SearchForUser(uname, fsize, fname);
                if (recs.Count == 1)
                {
                    fnh = recs[0];
                }

                if (recs.Count == 0)
                {
                    fnh = new FileNameHash();
                }

                if (recs.Count > 1)
                {
                    foreach (FileNameHash rec in recs)
                    {
                        repHash.Delete(rec.FileNameHashID);
                    }
                    fnh = new FileNameHash();
                }

                fnh.DateTimeUpdated = DateTime.Now;
                fnh.FileName        = fname;
                fnh.FileSize        = fsize;
                fnh.Hash            = hash;
                fnh.Username        = uname;
                repHash.Save(fnh);
            }
            catch (Exception ex)
            {
                Response.Write(Constants.ERROR_XML);
            }
        }