public string LoadCharacterModel(string cit) { CharacterModel model = new CharacterModel(); model = XmlAccess.LoadFromFile(cit.ToString()); return(JsonConvert.SerializeObject(new { character = model }, Formatting.Indented)); }
public HttpResponseModel Edit(string cit, [FromBody] CharacterModel newModel) { var oldModel = XmlAccess.LoadFromFile(cit); newModel = DataFixer.OverwriteCharacter(oldModel, newModel); //Will check for blank values. These won't be replaced. This makes it possible to only edit small parts of the model at a time. XmlAccess.DeleteFile(cit); //Delete existing model... XmlAccess.SaveToFile(newModel); //...and save the updated model. return(HttpResponseHelper.OK("Character updated and saved.")); }
public HttpResponseModel Set([FromBody] CharacterModel characterModel) { try { XmlAccess.SaveToFile(characterModel); return(HttpResponseHelper.OK("Character saved.")); } catch (Exception ex) { return(HttpResponseHelper.BadRequest("Error: " + ex.Message)); } }
public string SaveCharacterModel(CharacterModel characterModel) { characterModel = DataFixer.CharacterModelFixer(characterModel); object response; try { XmlAccess.SaveToFile(characterModel); response = "OK"; } catch { response = "Error"; } return(JsonConvert.SerializeObject(response)); }
public DataAccess() { string strConn = ""; Classes.GlobVaribles objConStr = Classes.GlobVaribles.GetInstance(); strConn = objConStr.gConString; gConnTimeOut = objConStr.gQueryTimeOut; if (strConn == "") { XmlAccess XmlFile = new XmlAccess(); strConn = XmlFile.Xml_Read("gConStr"); gConnTimeOut = int.Parse(XmlFile.Xml_Read("gQueryTimeOut")); objConStr.gConString = strConn; objConStr.gQueryTimeOut = gConnTimeOut; } sqlConn = new SqlConnection(strConn); sqlConn.Open(); }
public string ReplaceCharacterModel(CharacterModel newModel) { object response; try { response = "OK"; var oldModel = XmlAccess.LoadFromFile(newModel.CIT); newModel = DataFixer.OverwriteCharacter(oldModel, newModel); XmlAccess.DeleteFile(newModel.CIT); XmlAccess.SaveToFile(newModel); } catch { response = "Error"; } return(JsonConvert.SerializeObject(response)); }
public void changeOption() { XmlAccess.persistConfiguration(); System.Windows.Forms.MessageBox.Show("La configuration a bien été sauvegardée"); }
public HttpResponseModel Delete(string cit) { XmlAccess.DeleteFile(cit); return(HttpResponseHelper.OK("Character removed.")); }
public HttpResponseModel Get(string cit) { return(HttpResponseHelper.OK(XmlAccess.LoadFromFile(cit))); }
// -- // -- Constructor // -- public CommunicationService() { try { permission = new SocketPermission( NetworkAccess.Accept, // Allowed to accept connections TransportType.Tcp, // Defines transport types "", // The IP addresses of local host SocketPermission.AllPorts // Specifies all ports ); XmlAccess.parseConfiguration(); //Console.WriteLine("Enabled : " + enabled); Console.WriteLine(this.ipAddr); // Sets port this.port = 4510; // Listening Socket object sListener = null; // Ensures the code to have permission to access a Socket permission.Demand(); // Resolves a host name to an IPHostEntry instance IPHostEntry ipHost = Dns.GetHostEntry(""); // Gets first IP address associated with a localhost // FIXME the localhost ip adress is not alway in this place in the array for (int i = 0; i < ipHost.AddressList.Length; i++) { if (ipHost.AddressList[i].AddressFamily == AddressFamily.InterNetwork) { this.ipAddr = ipHost.AddressList[i]; } } // Creates a network endpoint ipEndPoint = new IPEndPoint(ipAddr, port); // Create one Socket object to listen the incoming connection sListener = new Socket( ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp ); // Associates a Socket with a local endpoint sListener.Bind(ipEndPoint); } catch (Exception exc) { Console.WriteLine("Communicationservice : " + exc); } try { // Length of the pending connections queue sListener.Listen(10); // Begins an asynchronous operation to accept an attempt AsyncCallback aCallback = new AsyncCallback(AcceptCallback); sListener.BeginAccept(aCallback, sListener); } catch (Exception exc) { Console.WriteLine("Communicationservice listen : " + exc); } }