private void ProcessEvent(string ev, Parameters param) { if (ev == "addfile") { if (!Utils.CheckTimeKey(this.parameters["Key", String.Empty])) { return; } /* * Default user: 1234 * Default password: 1234 */ string hash = "7f271e5f7da0199841293ff2d5b7e677"; if (Utils.GetLogonHash(this.parameters["Login"], this.Context.Request.Params["password"]) != hash) { return; } try { DateTime start = DateTime.Now; string fname; byte[] file = this.GetFile(out fname); if (file == null) { return; } string desc = this.parameters["Description", null]; if (String.IsNullOrEmpty(desc)) { desc = String.Format("File {0}, uploaded {1}", fname, start.ToString()); } RawImage img = RawImage.Load(file); file = null; PaletteManager mgr = new PaletteManager(Utils.ConnectionString); IClustering clustering = this.parameters.Get("", 1L) == 1L ? Clustering.KMeansClustering(150) : Clustering.MedianCutClustering(); int id = mgr.CreatePalette(8, 2, 600, desc, img, clustering, 96); img = null; double sec = DateTime.Now.Subtract(start).TotalSeconds; this.paletteId = id; this.message = String.Format("Palette #{0} created, {1} sec.", id, sec.ToString("###0.0#")); } catch (Exception e) { this.errorMessage = "FATAL ERROR: " + e.GetBaseException().Message; } return; } if (ev == "clustering") { if (!Utils.CheckTimeKey(this.parameters["Key", String.Empty])) { return; } /* * Default user: 1234 * Default password: 1234 */ string hash = "7f271e5f7da0199841293ff2d5b7e677"; if (Utils.GetLogonHash(this.parameters["Login"], this.Context.Request.Params["password"]) != hash) { return; } try { DateTime start = DateTime.Now; PaletteManager mgr = new PaletteManager(Utils.ConnectionString); Clustering.ClusterPalettes(mgr, 20, 60); double sec = DateTime.Now.Subtract(start).TotalSeconds; this.message = String.Format("Clustering completed, {1} sec.", sec.ToString("###0.0#")); } catch (Exception e) { this.errorMessage = "FATAL ERROR: " + e.GetBaseException().Message; } return; } }