public new SorentoLib.Ajax.Respons Process(SorentoLib.Session Session, string Fullname, string Method) { SorentoLib.Ajax.Respons result = new SorentoLib.Ajax.Respons (); SorentoLib.Ajax.Request request = new SorentoLib.Ajax.Request (Session.Request.QueryJar.Get ("data").Value); switch (Fullname.ToLower ()) { #region SorentoLib.User case "sorentolib.user": { switch (Method.ToLower ()) { // if (Session.AccessLevel < SorentoLib.Enums.Accesslevel.Administrator) throw new Exception (string.Format (sCMS.Strings.Exception.AjaxSessionPriviliges, "template.new")); case "new": { result.Add (new SorentoLib.User (request.getValue<string> ("username"), request.getValue<string> ("email"))); break; } case "load": { result.Add (SorentoLib.User.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<SorentoLib.User> ("sorentolib.user").Save (); break; } case "delete": { SorentoLib.User.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (SorentoLib.User.List ()); break; } case "changepassword": { if (request.getValue<Guid> ("userid") == Session.User.Id) { if (request.xPathExists ("oldpassword")) { string oldpassword = request.getValue<string> ("oldpassword"); string newpassword = request.getValue<string> ("newpassword"); if (Session.User.Authenticate (oldpassword)) { Session.User.Password = newpassword; Session.User.Save (); } } } else { string newpassword = request.getValue<string> ("newpassword"); SorentoLib.User user = SorentoLib.User.Load (request.getValue<Guid> ("userid")); user.Password = newpassword; user.Save (); } // string oldpassword = SorentoLib.Tools.StringHelper.ASCIIBytesToString (SorentoLib.Services.Crypto.Decrypt (SorentoLib.Tools.StringHelper.HexStringToBytes (request.Key<string> ("oldpassword")))); // string newpassword = SorentoLib.Tools.StringHelper.ASCIIBytesToString (SorentoLib.Services.Crypto.Decrypt (SorentoLib.Tools.StringHelper.HexStringToBytes (request.Key<string> ("newpassword")))); // SorentoLib.User user = new SorentoLib.User (); // if (user.Load (new Guid (request.Data<string> ("id")))) // { // if (user.Authenticate (oldpassword)) // { // user.Password = newpassword; // // if (user.Save ()) // { // result.Data.Add ("success", "true"); // } // } // } break; } case "isusernameinuse": { if (request.xPathExists ("id")) { result.Add ("result", SorentoLib.User.IsUsernameInUse (request.getValue<string> ("username"), new Guid (request.Key<string>("id")))); // result.Add ("result", SorentoLib.User.IsUsernameInUse (request.Key<string>("username"), new Guid (request.Key<string>("id")))); } else { result.Add ("result", SorentoLib.User.IsUsernameInUse (request.getValue<string> ("username"))); // result.Add ("result", SorentoLib.User.IsUsernameInUse (request.Key<string>("username"))); } break; } case "isemailinuse": { if (request.xPathExists ("id")) { result.Add ("result", SorentoLib.User.IsEmailInUse (request.getValue<string>("email"), new Guid (request.getValue<string>("id")))); } else { result.Add ("result", SorentoLib.User.IsEmailInUse (request.getValue<string>("email"))); } break; } default: break; } break; } #endregion #region SorentoLib.Usergroup case "sorentolib.usergroup": { switch (Method.ToLower ()) { case "new": { result.Add (new SorentoLib.Usergroup ()); break; } case "load": { result.Add (SorentoLib.Usergroup.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<SorentoLib.Usergroup> ("sorentolib.usergroup").Save (); break; } case "delete": { SorentoLib.Usergroup.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (SorentoLib.Usergroup.List ()); break; } case "accesslevels": { List<SorentoLib.Enums.Accesslevel> test1 = new List<SorentoLib.Enums.Accesslevel> (); foreach (SorentoLib.Enums.Accesslevel accesslevel in Enum.GetValues(typeof(SorentoLib.Enums.Accesslevel))) { // Hashtable test2 = new Hashtable (); // test2.Add ("name", accesslevel.ToString ()); // test2.Add ("value", (int)accesslevel); test1.Add (accesslevel); } result.Add (test1); break; } } break; } #endregion #region SorentoLib.Session case "sorentolib.session": { switch (Method.ToLower ()) { case "getcurrent": { // result.Data = Session.ToItem (); break; } case "logout": { result.Add (Session.Logout ()); break; } } break; } #endregion #region SorentoLib.Media case "sorentolib.media": { switch (Method.ToLower ()) { case "load": { SorentoLib.Media media = SorentoLib.Media.Load (new Guid (request.Key<string> ("id"))); // result.Data.Add ("id", media.Id); // result.Data.Add ("createtimestamp", media.CreateTimestamp); // result.Data.Add ("updatetimestamp", media.UpdateTimestamp); // result.Data.Add ("path", media.Path); // result.Data.Add ("directoryname", media.DirectoryName); // result.Data.Add ("filename", media.FileName); // result.Data.Add ("mimetype", media.Mimetype); // result.Data.Add ("size", media.Size); // result.Data.Add ("accesslevel", media.Accesslevel); // result.Data.Add ("status", media.Status); break; } } break; } #endregion #region SorentoLib.Transformation case "sorentolib.mediatransformation": { switch (Method.ToLower ()) { case "new": { MediaTransformation mediatransformation = MediaTransformation.FromAjaxRequest (request); mediatransformation.Save (); mediatransformation.ToAjaxRespons (result); break; } case "load": { MediaTransformation mediatransformation = MediaTransformation.Load (new Guid (request.Key<string> ("id"))); mediatransformation.ToAjaxRespons (result); break; } case "save": { MediaTransformation mediatransformation = MediaTransformation.FromAjaxRequest (request); mediatransformation.Save (); break; } case "delete": { MediaTransformation.Delete (new Guid (request.Key<string> ("id"))); break; } case "list": { List<Hashtable> mediatransformations = new List<Hashtable> (); foreach (SorentoLib.MediaTransformation mediatransformation in SorentoLib.MediaTransformation.List ()) { mediatransformations.Add (mediatransformation.ToAjaxItem ()); } // result.Data.Add ("mediatransformations", mediatransformations); break; } default: break; } break; } #endregion #region SorentoLib.Services.Config case "sorentolib.services.config": { switch (Method.ToLower ()) { case "get": { if (request.Data.ContainsKey ("keys")) { Hashtable data = new Hashtable (); foreach (string key in ((Hashtable)request.Data["keys"]).Keys) { data.Add (((Hashtable)request.Data["keys"])[key], SorentoLib.Services.Config.Get<string> (((Hashtable)request.Data["keys"])[key])); } // result.Data.Add ("data", data); } else { // result.Data.Add ("value", SorentoLib.Services.Config.Get<string> (request.Key<string> ("module"), request.Key<string> ("key"))); } break; } case "set": { if (request.Data.ContainsKey ("keys")) { foreach (string key in ((Hashtable)request.Data["keys"]).Keys) { SorentoLib.Services.Config.Set (key, ((Hashtable)request.Data["keys"])[key]); } } else { SorentoLib.Services.Config.Set (request.Key<string> ("module"), request.Key<string> ("key"), request.Key<string> ("value")); } break; } } break; } #endregion #region SorentoLib.Serivces.Snapshot case "sorentolib.services.snapshot": { switch (Method.ToLower ()) { case "new": { SorentoLib.Services.Snapshot.Take (); break; } case "load": { SorentoLib.Services.Snapshot snapshot = SorentoLib.Services.Snapshot.Load (request.Key<string> ("id")); snapshot.ToAjaxRespons (result); break; } case "develop": { SorentoLib.Services.Snapshot.Develop (SorentoLib.Services.Snapshot.Load (request.Key<string> ("id"))); break; } case "delete": { SorentoLib.Services.Snapshot.Delete (request.Key<string> ("id")); break; } case "list": { List<Hashtable> snapshots = new List<Hashtable> (); foreach (SorentoLib.Services.Snapshot snapshot in SorentoLib.Services.Snapshot.List ()) { snapshots.Add (snapshot.ToAjaxItem ()); } // result.Data.Add ("snapshots", snapshots); break; } default: break; } break; } #endregion } return result; }
public new SorentoLib.Ajax.Respons Process(SorentoLib.Session Session, string Fullname, string Method) { SorentoLib.Ajax.Respons result = new SorentoLib.Ajax.Respons (); SorentoLib.Ajax.Request request = new SorentoLib.Ajax.Request (Session.Request.QueryJar.Get ("data").Value); switch (Fullname.ToLower ()) { #region Didius.Customer case "didius.customer": { switch (Method.ToLower ()) { case "create": { result.Add (new Customer ()); break; } case "load": { if (request.ContainsXPath ("id")) { result.Add (Customer.Load (request.getValue<Guid>("id"))); } else if (request.ContainsXPath ("userid")) { result.Add (Customer.Load (SorentoLib.User.Load (request.getValue<Guid>("userid")))); } break; } case "save": { request.getValue<Customer> ("didius.customer").Save (); break; } case "destroy": { Customer.Delete (request.getValue<Guid> ("id")); break; } case "list": { if (request.ContainsXPath ("customergroupid")) { result.Add (Customer.List (request.getValue<Guid> ("customergroupid"))); } else { result.Add (Customer.List ()); } break; } } break; } #endregion #region Didius.CustomerGroup case "didius.customergroup": { switch (Method.ToLower ()) { case "create": { result.Add (new CustomerGroup ()); break; } case "load": { result.Add (CustomerGroup.Load (request.getValue<Guid>("id"))); break; } case "save": { request.getValue<CustomerGroup> ("didius.customergroup").Save (); break; } case "destroy": { CustomerGroup.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (CustomerGroup.List ()); break; } } break; } #endregion #region Didius.Case case "didius.case": { switch (Method.ToLower ()) { case "create": { result.Add (new Case (Auction.Load (request.getValue<Guid>("auctionid")), Customer.Load (request.getValue<Guid>("customerid")))); break; } case "load": { result.Add (Case.Load (request.getValue<Guid>("id"))); break; } case "save": { request.getValue<Case> ("didius.case").Save (); break; } case "destroy": { Case.Delete (request.getValue<Guid> ("id")); break; } case "list": { if (request.ContainsXPath ("customerid")) { result.Add (Case.List (request.getValue<Guid> ("customerid"))); } else if (request.ContainsXPath ("auctionid")) { result.Add (Case.List (request.getValue<Guid> ("auctionid"))); } else { result.Add (Case.List ()); } break; } } break; } #endregion #region Didius.Item case "didius.item": { switch (Method.ToLower ()) { case "create": { result.Add (new Item (Case.Load (request.getValue<Guid>("caseid")))); break; } case "load": { result.Add (Item.Load (request.getValue<Guid>("id"))); break; } case "save": { result.Add (request.getValue<Item> ("didius.item").Save ()); break; } case "destroy": { Item.Delete (request.getValue<Guid> ("id")); break; } case "bid": { decimal amount = 0; if (request.ContainsXPath ("amount")) { amount = decimal.Parse (request.getValue<string> ("amount")); } if (Session.User != null) { Item.Bid (Customer.Load (Session.User), Item.Load (request.getValue<Guid> ("itemid")), amount); } else { Item.Bid (Customer.Load (new Guid ("be829dbb-1f7b-47ca-85ae-6874541b74f8")), Item.Load (request.getValue<Guid> ("itemid")), amount); } break; } case "list": { if (request.ContainsXPath ("auctionid")) { result.Add (Item.List (Auction.Load (request.getValue<Guid> ("auctionid")))); } else if (request.ContainsXPath ("caseid")) { result.Add (Item.List (Case.Load (request.getValue<Guid> ("caseid")))); } else { result.Add (Item.List ()); } break; } } break; } #endregion #region Didius.Auction case "didius.auction": { switch (Method.ToLower ()) { case "create": { result.Add (new Auction ()); break; } case "load": { result.Add (Auction.Load (request.getValue<Guid>("id"))); break; } case "save": { request.getValue<Auction> ("didius.auction").Save (); break; } case "destroy": { Auction.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (Auction.List ()); break; } } break; } #endregion #region Didius.Bid case "didius.bid": { switch (Method.ToLower ()) { case "create": { result.Add (new Bid (Customer.Load (request.getValue<Guid> ("customerid")), Item.Load (request.getValue<Guid> ("itemid")), decimal.Parse (request.getValue<string> ("amount")))); break; } case "load": { result.Add (Bid.Load (request.getValue<Guid>("id"))); break; } case "save": { request.getValue<Bid> ("didius.bid").Save (); break; } case "destroy": { Bid.Delete (request.getValue<Guid> ("id")); break; } case "list": { if (request.ContainsXPath ("itemid")) { result.Add (Bid.List (request.getValue<Guid> ("itemid"))); } else if (request.ContainsXPath ("customerid")) { result.Add (Bid.List (Customer.Load (request.getValue<Guid> ("customerid")))); } else { result.Add (Bid.List ()); } break; } } break; } #endregion #region Didius.AutoBid case "didius.autobid": { switch (Method.ToLower ()) { case "load": { result.Add (AutoBid.Load (request.getValue<Guid>("id"))); break; } case "list": { if (request.ContainsXPath ("itemid")) { result.Add (AutoBid.List (request.getValue<Guid> ("itemid"))); } else if (request.ContainsXPath ("customerid")) { result.Add (AutoBid.List (Customer.Load (request.getValue<Guid> ("customerid")))); } else { result.Add (AutoBid.List ()); } break; } } break; } #endregion #region Didius.Settlement case "didius.settlement": { switch (Method.ToLower ()) { case "create": { bool simulate = false; if (request.ContainsXPath ("simulate")) { simulate = request.getValue<bool> ("simulate"); } result.Add (Settlement.Create (Case.Load (request.getValue<Guid> ("caseid")), simulate)); break; } case "load": { result.Add (Settlement.Load (request.getValue<Guid> ("id"))); break; } case "list": { if (request.ContainsXPath ("caseid")) { result.Add (Settlement.List (Case.Load (request.getValue<Guid> ("caseid")))); } else if (request.ContainsXPath ("auctionid")) { result.Add (Settlement.List (Auction.Load (request.getValue<Guid> ("auctionid")))); } else if (request.ContainsXPath ("customerid")) { result.Add (Settlement.List (Customer.Load (request.getValue<Guid> ("customerid")))); } else { result.Add (Settlement.List ()); } break; } } break; } #endregion #region Didius.Invoice case "didius.invoice": { switch (Method.ToLower ()) { case "create": { result.Add (Invoice.Create (Auction.Load (request.getValue<Guid> ("auctionid")), Customer.Load (request.getValue<Guid> ("customerid")), request.getValue<bool> ("simulate"))); break; } case "load": { result.Add (Invoice.Load (request.getValue<Guid>("id"))); break; } case "list": { if (request.ContainsXPath ("auctionid")) { result.Add (Invoice.List (Auction.Load (request.getValue<Guid> ("auctionid")))); } if (request.ContainsXPath ("customerid")) { result.Add (Invoice.List (Customer.Load (request.getValue<Guid> ("customerid")))); } else { result.Add (Invoice.List ()); } break; } } break; } #endregion #region Didius.Creditnote case "didius.creditnote": { switch (Method.ToLower ()) { case "create": { if (request.ContainsXPath ("invoiceid")) { result.Add (Creditnote.Create (Invoice.Load (request.getValue<Guid> ("invoiceid")), request.getValue<bool> ("simulate"))); } else if (request.ContainsXPath ("item")) { result.Add (Creditnote.Create (Customer.Load (request.getValue<Guid> ("customerid")), request.getValue<Item> ("item"), request.getValue<bool> ("simulate"))); } break; } case "load": { result.Add (Creditnote.Load (request.getValue<Guid>("id"))); break; } case "list": { if (request.ContainsXPath ("customerid")) { result.Add (Creditnote.List (Customer.Load (request.getValue<Guid> ("customerid")))); } else { result.Add (Creditnote.List ()); } break; } } break; } #endregion #region Didius.Helpers case "didius.helpers": { switch (Method.ToLower ()) { case "createturnoverreport": { result.Add (TurnoverReport.Create (Auction.Load (request.getValue<Guid> ("auctionid")))); break; } case "createprofile": { Customer customer = Didius.Helpers.CreateProfile (request.getValue<string> ("name"), request.getValue<string> ("email")); customer.User.Password = request.getValue<string> ("password"); if (request.xPathExists ("address1")) customer.Address1 = request.getValue<string> ("address1"); if (request.xPathExists ("postcode")) customer.PostCode = request.getValue<string> ("postcode"); if (request.xPathExists ("city")) customer.City = request.getValue<string> ("city"); if (request.xPathExists ("phone")) customer.Phone = request.getValue<string> ("phone"); if (request.xPathExists ("mobile")) customer.Mobile = request.getValue<string> ("mobile"); customer.Save (); if (request.xPathExists ("password")) { User user = User.Load (customer.UserId); user.Password = request.getValue<string> ("password"); user.Save (); } break; } case "verifyprofile": { result.Add (Didius.Helpers.VerifiyProfile (request.getValue<Guid> ("id"))); break; } case "sendnewpassword": { result.Add (Didius.Helpers.SendNewPassword (SorentoLib.User.Load (request.getValue<string> ("email")).Id)); break; } case "sendconsignment": { Didius.Helpers.SendConsignment (request.getValue<string> ("data")); break; } case "sendsms": { Didius.Helpers.SendSMS (request.getValue<string> ("message")); break; } case "bugreport": { Didius.Helpers.BugReport (request.getValue<string> ("sender"), request.getValue<string> ("description")); break; } case "newcatalogno": { if (request.ContainsXPath ("mincatalogno")) { result.Add (Helpers.NewCatalogNo (Auction.Load (request.getValue<Guid> ("auctionid")), int.Parse (request.getValue<string> ("mincatalogno")))); } else { result.Add (Helpers.NewCatalogNo (Auction.Load (request.getValue<Guid> ("auctionid")))); } break; } case "iscatalognotaken": { result.Add ( Helpers.IsCatalogNoTaken (Auction.Load (request.getValue<Guid> ("auctionid")), int.Parse (request.getValue<string> ("catalogno")))); break; } case "mailbidwon": { Helpers.MailItemWon (Item.Load (request.getValue<Guid> ("itemid"))); break; } } break; } #endregion #region Didius.EventListener case "didius.eventlistener": { switch (Method.ToLower ()) { case "attach": { result.Add (EventListener.Attach ()); break; } case "detach": { EventListener.Detach (request.getValue<Guid> ("eventlistenerid")); break; } case "update": { if (request.ContainsXPath ("eventid")) { EventListener.Update (request.getValue<Guid> ("eventlistenerid"), request.getValue<string> ("eventid"), request.getValue<string> ("eventdata")); } else { result.Add (EventListener.Update (request.getValue<Guid> ("eventlistenerid"))); } break; } } break; } #endregion #region Didius.Newsletter case "didius.newsletter": { switch (Method.ToLower ()) { case "create": { result.Add (new Newsletter ()); break; } case "load": { result.Add (Newsletter.Load (request.getValue<Guid>("id"))); break; } case "save": { request.getValue<Newsletter> ("didius.newsletter").Save (); break; } case "destroy": { Newsletter.Delete (request.getValue<Guid> ("id")); break; } case "send": { Newsletter.Load (request.getValue<Guid>("id")).Send (); break; } case "list": { result.Add (Newsletter.List ()); break; } } break; } #endregion } return result; }
public new SorentoLib.Ajax.Respons Process(SorentoLib.Session Session, string Fullname, string Method) { SorentoLib.Ajax.Respons result = new SorentoLib.Ajax.Respons (); SorentoLib.Ajax.Request request = new SorentoLib.Ajax.Request (Session.Request.QueryJar.Get ("data").Value); switch (Fullname.ToLower ()) { #region qnax.runtime case "qnax.runtime": { switch (Method.ToLower ()) { case "getmenuxml": { result.Add ("menuxml", qnax.Runtime.GetMenuXML (Session).OuterXml); break; } } break; } #endregion #region qnaxlib.customer case "qnaxlib.customer": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.Customer ()); break; } case "load": { result.Add (qnaxLib.Customer.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.Customer> ("qnaxlib.customer").Save (); break; } case "delete": { qnaxLib.Customer.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.Customer.List ()); break; } } break; } #endregion #region qnaxlib.subscription case "qnaxlib.subscription": { switch (Method.ToLower ()) { case "new": { // result.Add (new qnaxLib.Subscription (Customer.Load (request.getValue<Guid> ("customerid")), request.getValue<qnaxLib.Enums.SubscriptionType>("type"))); break; } case "load": { result.Add (qnaxLib.Subscription.Load (request.getValue<Guid> ("id"))); break; } case "save": { qnaxLib.Subscription.FromXmlDocument (request.GetXml ("qnaxlib.customer")).Save (); break; } case "delete": { qnaxLib.Subscription.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.Subscription.List (Customer.Load (request.getValue<Guid>("customerid")))); break; } } break; } #endregion #region qnaxlib.voip.sipaccount case "qnaxlib.voip.sipaccount": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.voip.SIPAccount ()); break; } case "load": { result.Add (qnaxLib.voip.SIPAccount.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.voip.SIPAccount> ("qnaxlib.voip.sipaccount").Save (); break; } case "delete": { qnaxLib.voip.SIPAccount.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.voip.SIPAccount.List ()); break; } case "getusagereport": { result.Add (qnaxLib.voip.SIPAccount.GetUsageReports (qnaxLib.voip.SIPAccount.Load (request.getValue<Guid> ("id")), DateTime.ParseExact (request.getValue<string> ("from"), "dd-MM-yyyy", null), DateTime.ParseExact (request.getValue<string> ("to"), "dd-MM-yyyy", null))); break; } } break; } #endregion #region qnaxlib.voip.countrycode case "qnaxlib.voip.countrycode": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.voip.CountryCode ()); break; } case "load": { result.Add (qnaxLib.voip.CountryCode.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.voip.CountryCode> ("qnaxlib.voip.countrycode").Save (); break; } case "delete": { qnaxLib.voip.CountryCode.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.voip.CountryCode.List ()); break; } } break; } #endregion #region qnaxlib.voip.range case "qnaxlib.voip.range": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.voip.Range ()); break; } case "load": { result.Add (qnaxLib.voip.Range.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.voip.Range> ("qnaxlib.voip.range").Save (); break; } case "delete": { qnaxLib.voip.Range.Delete (request.getValue<Guid> ("id")); break; } case "list": { if (request.xPathExists ("countrycodeid")) { result.Add (qnaxLib.voip.Range.List ( qnaxLib.voip.CountryCode.Load (request.getValue<Guid>("countrycodeid")))); } else { result.Add (qnaxLib.voip.Range.List ()); } break; } } break; } #endregion #region qnaxlib.voip.rangegroup case "qnaxlib.voip.rangegroup": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.voip.RangeGroup ()); break; } case "load": { result.Add (qnaxLib.voip.RangeGroup.Load (request.getValue<Guid> ("id"))); break; } case "save": { try { request.getValue<qnaxLib.voip.RangeGroup> ("qnaxlib.voip.rangegroup").Save (); } catch (Exception e) { Console.WriteLine (e); } break; } case "delete": { qnaxLib.voip.RangeGroup.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.voip.RangeGroup.List ()); break; } } break; } #endregion #region qnaxlib.voip.rangeprice case "qnaxlib.voip.rangeprice": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.voip.RangePrice ()); break; } case "load": { result.Add (qnaxLib.voip.RangePrice.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.voip.RangePrice> ("qnaxlib.voip.rangeprice").Save (); break; } case "delete": { qnaxLib.voip.RangePrice.Delete (request.getValue<Guid> ("id")); break; } case "list": { // result.Add (qnaxLib.voip.RangePrice.List ()); break; } } break; } #endregion #region qnaxlib.management.server case "qnaxlib.management.server": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.Management.Server (qnaxLib.Management.Location.Load (request.getValue<Guid> ("locationid")))); break; } case "load": { result.Add (qnaxLib.Management.Server.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.Management.Server> ("qnaxlib.management.server").Save (); break; } case "delete": { qnaxLib.Management.Server.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.Management.Server.List ()); break; } } break; } #endregion #region qnaxlib.management.location case "qnaxlib.management.location": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.Management.Location ()); break; } case "load": { result.Add (qnaxLib.Management.Location.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.Management.Location> ("qnaxlib.management.location").Save (); break; } case "delete": { qnaxLib.Management.Location.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.Management.Location.List ()); break; } } break; } #endregion #region qnaxlib.management.serveros case "qnaxlib.management.serveros": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.Management.ServerOS ()); break; } case "load": { result.Add (qnaxLib.Management.ServerOS.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.Management.ServerOS> ("qnaxlib.management.serveros").Save (); break; } case "delete": { qnaxLib.Management.ServerOS.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.Management.ServerOS.List ()); break; } } break; } #endregion #region qnaxlib.management.serverservice case "qnaxlib.management.serverservice": { switch (Method.ToLower ()) { case "new": { result.Add (new qnaxLib.Management.ServerService ()); break; } case "load": { result.Add (qnaxLib.Management.ServerService.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<qnaxLib.Management.ServerService> ("qnaxlib.management.serverservice").Save (); break; } case "delete": { qnaxLib.Management.ServerService.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (qnaxLib.Management.ServerService.List ()); break; } } break; } #endregion } return result; }
public override SorentoLib.Ajax.Respons Process(SorentoLib.Session Session, string Fullname, string Method) { SorentoLib.Ajax.Respons result = new SorentoLib.Ajax.Respons (); SorentoLib.Ajax.Request request = new SorentoLib.Ajax.Request (Session.Request.QueryJar.Get ("data").Value); switch (Fullname.ToLower ()) { #region SorentoLib.User case "sorentolib.user": { switch (Method.ToLower ()) { // if (Session.AccessLevel < SorentoLib.Enums.Accesslevel.Administrator) throw new Exception (string.Format (sCMS.Strings.Exception.AjaxSessionPriviliges, "template.new")); case "new": { result.Add (new SorentoLib.User (request.getValue<string> ("username"))); break; } case "load": { result.Add (SorentoLib.User.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<SorentoLib.User> ("sorentolib.user").Save (); break; } case "delete": { SorentoLib.User.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (SorentoLib.User.List ()); break; } case "changepassword": { if (request.getValue<Guid> ("userid") == Session.User.Id) { if (request.xPathExists ("oldpassword")) { string oldpassword = request.getValue<string> ("oldpassword"); string newpassword = request.getValue<string> ("newpassword"); if (Session.User.Authenticate (oldpassword)) { Session.User.Password = newpassword; Session.User.Save (); result.Add ("result", true); } else { result.Add ("result", false); } } else { result.Add ("result", false); } } else { string newpassword = request.getValue<string> ("newpassword"); SorentoLib.User user = SorentoLib.User.Load (request.getValue<Guid> ("userid")); user.Password = newpassword; user.Save (); result.Add ("result", true); } // string oldpassword = SorentoLib.Tools.StringHelper.ASCIIBytesToString (SorentoLib.Services.Crypto.Decrypt (SorentoLib.Tools.StringHelper.HexStringToBytes (request.Key<string> ("oldpassword")))); // string newpassword = SorentoLib.Tools.StringHelper.ASCIIBytesToString (SorentoLib.Services.Crypto.Decrypt (SorentoLib.Tools.StringHelper.HexStringToBytes (request.Key<string> ("newpassword")))); // SorentoLib.User user = new SorentoLib.User (); // if (user.Load (new Guid (request.Data<string> ("id")))) // { // if (user.Authenticate (oldpassword)) // { // user.Password = newpassword; // // if (user.Save ()) // { // result.Data.Add ("success", "true"); // } // } // } break; } case "isusernameinuse": { if (request.xPathExists ("id")) { result.Add ("result", SorentoLib.User.IsUsernameInUse (request.getValue<string> ("username"), new Guid (request.Key<string>("id")))); // result.Add ("result", SorentoLib.User.IsUsernameInUse (request.Key<string>("username"), new Guid (request.Key<string>("id")))); } else { result.Add ("result", SorentoLib.User.IsUsernameInUse (request.getValue<string> ("username"))); // result.Add ("result", SorentoLib.User.IsUsernameInUse (request.Key<string>("username"))); } break; } case "isemailinuse": { if (request.xPathExists ("id")) { result.Add ("result", SorentoLib.User.IsEmailInUse (request.getValue<string>("email"), new Guid (request.getValue<string>("id")))); } else { result.Add ("result", SorentoLib.User.IsEmailInUse (request.getValue<string>("email"))); } break; } default: break; } break; } #endregion #region SorentoLib.Usergroup case "sorentolib.usergroup": { switch (Method.ToLower ()) { case "new": { result.Add (new SorentoLib.Usergroup ()); break; } case "load": { result.Add (SorentoLib.Usergroup.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<SorentoLib.Usergroup> ("sorentolib.usergroup").Save (); break; } case "delete": { SorentoLib.Usergroup.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (SorentoLib.Usergroup.List ()); break; } case "accesslevels": { List<SorentoLib.Enums.Accesslevel> test1 = new List<SorentoLib.Enums.Accesslevel> (); foreach (SorentoLib.Enums.Accesslevel accesslevel in Enum.GetValues(typeof(SorentoLib.Enums.Accesslevel))) { // Hashtable test2 = new Hashtable (); // test2.Add ("name", accesslevel.ToString ()); // test2.Add ("value", (int)accesslevel); test1.Add (accesslevel); } result.Add (test1); break; } } break; } #endregion #region SorentoLib.Session case "sorentolib.session": { switch (Method.ToLower ()) { case "getcurrent": { result.Add (Session); break; } case "loggedin": { result.Add (Session.LoggedIn); break; } case "login": { result.Add (Session.SignIn (request.getValue<string> ("username"), request.getValue<string> ("password"))); break; } case "logout": { result.Add (Session.SignOut ()); break; } } break; } #endregion #region SorentoLib.Media case "sorentolib.media": { switch (Method.ToLower ()) { case "load": { result.Add (SorentoLib.Media.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<SorentoLib.Media> ("sorentolib.media").Save (); break; } } break; } #endregion #region SorentoLib.Transformation case "sorentolib.mediatransformation": { switch (Method.ToLower ()) { case "new": { result.Add (new SorentoLib.MediaTransformation ()); break; } case "load": { result.Add (SorentoLib.MediaTransformation.Load (request.getValue<Guid> ("id"))); break; } case "save": { request.getValue<SorentoLib.MediaTransformation> ("sorentolib.mediatransformation").Save (); break; } case "delete": { SorentoLib.MediaTransformation.Delete (request.getValue<Guid> ("id")); break; } case "list": { result.Add (SorentoLib.MediaTransformation.List ()); break; } } break; } #endregion #region SorentoLib.Services.Config case "sorentolib.services.config": { switch (Method.ToLower ()) { case "get": { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (request.XmlDocument); List<Hashtable> test = new List<Hashtable> (); foreach (XmlDocument key in (List<XmlDocument>)item["config"]) { string keyname = (string)((Hashtable)SNDK.Convert.FromXmlDocument (key))["value"]; Hashtable val = new Hashtable (); val.Add (keyname, SorentoLib.Services.Config.Get<string> (keyname)); test.Add (val); } result.Add ("config", test); break; } case "set": { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (request.XmlDocument); foreach (XmlDocument xml in (List<XmlDocument>)item["config"]) { Hashtable conf = (Hashtable)SNDK.Convert.FromXmlDocument (xml); // SorentoLib.Services.Config.Set (conf["module"], conf["key"], (object)conf["value"]); SorentoLib.Services.Config.Set (conf["key"], conf["value"]); // Console.WriteLine (conf["module"] +" "+ conf["key"] +" "+ conf["value"]); } // foreach (string key in item.Keys) // { // Console.WriteLine (item[key].GetType ()); // } //Console.WriteLine (request.GetXml ("config").OuterXml); // foreach (XmlDocument usergroup in (List<XmlDocument>)item["usergroups"]) // { // result._usergroups.Add (Usergroup.FromXmlDocument (usergroup)); // } // foreach (XmlDocument config in request.getValue<List<XmlDocument>> ("config")) // { // //result._usergroups.Add (Usergroup.FromXmlDocument (usergroup)); // } // if (request.Data.ContainsKey ("keys")) // { // foreach (string key in ((Hashtable)request.Data["keys"]).Keys) // { // SorentoLib.Services.Config.Set (key, ((Hashtable)request.Data["keys"])[key]); // } // } // else // { // SorentoLib.Services.Config.Set (request.Key<string> ("module"), request.Key<string> ("key"), request.Key<string> ("value")); // } break; } } break; } #endregion #region SorentoLib.Services.Settings case "sorentolib.services.settings": { switch (Method.ToLower ()) { case "get": { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (request.XmlDocument); List<Hashtable> test = new List<Hashtable> (); foreach (XmlDocument key in (List<XmlDocument>)item["settings"]) { string keyname = (string)((Hashtable)SNDK.Convert.FromXmlDocument (key))["value"]; Hashtable val = new Hashtable (); val.Add (keyname, SorentoLib.Services.Settings.Get<string> (keyname)); test.Add (val); } result.Add ("settings", test); break; } case "set": { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (request.XmlDocument); foreach (XmlDocument xml in (List<XmlDocument>)item["settings"]) { Hashtable conf = (Hashtable)SNDK.Convert.FromXmlDocument (xml); SorentoLib.Services.Settings.Set (conf["key"], conf["value"]); } break; } } break; } #endregion #region SorentoLib.Services.Addins case "sorentolib.services.addins": { switch (Method.ToLower ()) { case "enableaddin": { SorentoLib.Services.Addins.EnableAddin (request.getValue<string> ("id")); break; } case "disableaddin": { SorentoLib.Services.Addins.DisableAddin (request.getValue<string> ("id")); break; } case "list": { List<Hashtable> addins = new List<Hashtable> (); foreach (Mono.Addins.Addin addin in SorentoLib.Services.Addins.List ()) { Hashtable item = new Hashtable (); item.Add ("id", addin.Id); item.Add ("enabled", addin.Enabled); item.Add ("name", addin.LocalId); item.Add ("version", addin.Version); item.Add ("author", addin.Description.Author); item.Add ("description", addin.Description.Description); item.Add ("url", addin.Description.Url); item.Add ("candisable", addin.Description.CanDisable); addins.Add (item); } result.Add ("sorentolib.services.addins", addins); break; } default: break; } break; } #endregion #region SorentoLib.Serivces.Snapshot case "sorentolib.services.snapshot": { switch (Method.ToLower ()) { case "new": { SorentoLib.Services.Snapshot.Take (); break; } case "load": { SorentoLib.Services.Snapshot snapshot = SorentoLib.Services.Snapshot.Load (request.Key<string> ("id")); snapshot.ToAjaxRespons (result); break; } case "develop": { SorentoLib.Services.Snapshot.Develop (SorentoLib.Services.Snapshot.Load (request.Key<string> ("id"))); break; } case "delete": { SorentoLib.Services.Snapshot.Delete (request.Key<string> ("id")); break; } case "list": { List<Hashtable> snapshots = new List<Hashtable> (); foreach (SorentoLib.Services.Snapshot snapshot in SorentoLib.Services.Snapshot.List ()) { snapshots.Add (snapshot.ToAjaxItem ()); } // result.Data.Add ("snapshots", snapshots); break; } default: break; } break; } #endregion } return result; }