Пример #1
0
    public String saveDiagram(Diagram diagram) {
      Hosted.Diagram hostedDiagram = new Hosted.Diagram();

      hostedDiagram.id     = diagram.diagramID;
      hostedDiagram.name   = diagram.name;
      hostedDiagram.descr  = diagram.comment;
      hostedDiagram.width  = diagram.width;
      hostedDiagram.height = diagram.height;
      hostedDiagram.src    = diagram.ADL;
      
      return Hosted.Client.save( hostedDiagram, this.author, this.password );
    }
Пример #2
0
        public String saveDiagram(Diagram diagram)
        {
            Hosted.Diagram hostedDiagram = new Hosted.Diagram();

            hostedDiagram.id     = diagram.diagramID;
            hostedDiagram.name   = diagram.name;
            hostedDiagram.descr  = diagram.comment;
            hostedDiagram.width  = diagram.width;
            hostedDiagram.height = diagram.height;
            hostedDiagram.src    = diagram.ADL;

            return(Hosted.Client.save(hostedDiagram, this.author, this.password));
        }
Пример #3
0
    public static String save( Diagram diagram, 
                               String userId, String password )
    {
      try {
        String url ="http://hosted.umlcanvas.org/";
        String passwordHash = md5(password);

        String msg = userId + passwordHash + diagram.id 
                   + diagram.name + diagram.descr
                   + diagram.width.ToString() + diagram.height.ToString()
                   + diagram.src;

        String signature = md5(msg);

        String postData = 
          "name="       + System.Web.HttpUtility.UrlEncode(diagram.name) + 
          "&descr="     + System.Web.HttpUtility.UrlEncode(diagram.descr) +  
          "&author="    + System.Web.HttpUtility.UrlEncode(userId) +
          "&signature=" + signature + 
          "&width="     + diagram.width.ToString() + 
          "&height="    + diagram.height.ToString() + 
          "&src="       + System.Web.HttpUtility.UrlEncode(diagram.src);

        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        WebRequest request = WebRequest.Create( url + diagram.id );
        request.Method = "POST";
        request.ContentType = "application/x-www-form-urlencoded";
        request.ContentLength = byteArray.Length;
        Stream dataStream = request.GetRequestStream ();
        dataStream.Write (byteArray, 0, byteArray.Length);
        dataStream.Close ();

        WebResponse response = request.GetResponse ();
        dataStream = response.GetResponseStream ();
        StreamReader reader = new StreamReader(dataStream);
        reader.Close();
        dataStream.Close();
        response.Close();
        return url + diagram.id;
      } catch( Exception e ) {
        Console.WriteLine( e );
        return null;
      }
    }