Meeskond "H2"

From ICO wiki
Jump to navigationJump to search

Kohviku menüüsüsteem

Projekt

Kohvikute (esialgu ainult IT-Kohviku) menüüsüsteem, mis on jälgitav mobiilseadmetelt. Lisaväärtusena võimaldab anda pakutavale hinnanguid, otsuse langetamise hõlbustamiseks kommentaar:(see viimane funktsioon kipub vist "veebirakenduseks" muutuma)
Sihtplatvormid: Windows Mobile, iOS, Android(kui leiame vabatahtlikud testijad)

Taustinfo

Praegune IT-Kohviku menüü on käsitsi täidetav valge tahvel. Projekti eesmärgiks on parendada IT-Kohviku menüüsüsteemi ja teha see veebi kaudu kättesaadavaks, nii, et menüüsse saab lisada ka karniiri valiku. Standardmenüü puhul saab menüüs olla ka illustreeriv foto. Hetkemenüü ning hinnad ja lahtioleku ajad on samuti jälgitavad võrguühendust eviva mobiilseadme ekraanilt, hõlbustades sellega valikute tegemist.

Liikmed

  • Mailis Toompuu
  • Henri Kroosmann
  • Heiki Tamm

Sisu

XML Data

<?xml version="1.0" encoding="utf-8"?>
<menu>
  <product>
    <name>name1</name>
    <type>
      <id>0</id>
      <name>name1</name>
    </type>
    <extras>
      <item>item1</item>
      <item>item2</item>
      <item>item3</item>
    </extras>
    <price>
      <int>0</int>
      <frac>0</frac>
      <discount>discount1</discount>
    </price>
    <vote>
      <pos>0</pos>
      <neg>0</neg>
    </vote>
    <screenshot>screenshot1</screenshot>
  </product>
  <product>
    <name>name2</name>
    <type>
      <id>255</id>
      <name>name2</name>
    </type>
    <extras>
      <item>item4</item>
      <item>item5</item>
      <item>item6</item>
    </extras>
    <price>
      <int>255</int>
      <frac>255</frac>
      <discount>discount2</discount>
    </price>
    <vote>
      <pos>255</pos>
      <neg>255</neg>
    </vote>
    <screenshot>screenshot2</screenshot>
  </product>
  <product>
    <name>name3</name>
    <type>
      <id>1</id>
      <name>name3</name>
    </type>
    <extras>
      <item>item7</item>
      <item>item8</item>
      <item>item9</item>
    </extras>
    <price>
      <int>1</int>
      <frac>1</frac>
      <discount>discount3</discount>
    </price>
    <vote>
      <pos>1</pos>
      <neg>1</neg>
    </vote>
    <screenshot>screenshot3</screenshot>
  </product>
</menu>

XML Schema

Ülevaade Schema'st.

Ning sellele vastav kood.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="menu">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="product">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="name" type="xs:string" />
              <xs:element name="type">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="id" type="xs:unsignedByte" />
                    <xs:element name="name" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="extras">
                <xs:complexType>
                  <xs:sequence minOccurs="0">
                    <xs:element maxOccurs="unbounded" name="item" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="price">
                <xs:complexType>
                  <xs:sequence minOccurs="0">
                    <xs:element name="int" type="xs:unsignedByte" />
                    <xs:element name="frac" type="xs:unsignedByte" />
                    <xs:element minOccurs="0" name="discount" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="vote">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="pos" type="xs:unsignedByte" />
                    <xs:element name="neg" type="xs:unsignedByte" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="screenshot" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XML Style

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <head>
        <style type="text/css">
          html,body{margin:0;padding:0;font-family:Helvetica,Arial,sans-serif;font-size:14px;line-height:19px;color:#2c2c2c;}
          h1{margin:0;padding:25px 0 0;font-size:22px;line-height:25px;text-align:center;}
          h2{margin:0;padding:5px;font-size:16px;line-height:21px}
          span.discount{padding:0 0 0 5px;color:red;}
          table{margin:20px auto;padding:0;}
          th,td{padding:5px;border:1px solid #2c2c2c;vertical-align:top;text-align:left}
          th{font-weight:bold;background-color:#eee;}
          ul{margin:0;padding:0;list-style-type:none;}
        </style>
      </head>
      <body>
        <h1>Menüü</h1>
        <table width="800">
          <col width="200"/>
          <col width="100"/>
          <col width="*"/>
          <col witdh="*"/>
          <col width="*"/>
          <col width="150"/>
          <tr>
            <th>Nimetus</th>
            <th>Lisandid</th>
            <th>Tüüp</th>
            <th>Hind</th>
            <th>Hinne / Hindajaid</th>
            <th>Pilt</th>
          </tr>

          <xsl:for-each select="menu/product">
            <xsl:sort select="type/id"/>
            <xsl:sort select="name"/>
            <tr>
              <th>
                <xsl:value-of select="name"/>
              </th>

              <xsl:choose>
                <xsl:when test="extras/node()">
                  <td>
                    <ul>
                      <xsl:for-each select="extras/item">
                        <li>
                          <xsl:value-of select="."/>
                        </li>
                      </xsl:for-each>
                    </ul>
                  </td>
                </xsl:when>
                <xsl:otherwise>
                  <td>-</td>
                </xsl:otherwise>
              </xsl:choose>

              <td>
                <xsl:value-of select="type/name"/>
              </td>

              <xsl:choose>
                <xsl:when test="price/node()">
                  <td>
                    €<xsl:value-of select="price/int"/>.<xsl:value-of select="price/frac"/>
                    <xsl:if test="price/discount/text()">
                      <span class="discount">
                        (-<xsl:value-of select="price/discount"/>%)
                      </span>
                    </xsl:if>
                  </td>
                </xsl:when>
                <xsl:otherwise>
                  <td>-</td>
                </xsl:otherwise>
              </xsl:choose>

              <xsl:variable name="p" select="vote/pos"/>
              <xsl:variable name="n" select="vote/neg"/>
              <td>
                <xsl:value-of select="$p - $n"/> / <xsl:value-of select="$p + $n"/>
              </td>

              <xsl:choose>
                <xsl:when test="screenshot/text()">
                  <td>
                    <img src="{screenshot}" alt=""/>
                  </td>
                </xsl:when>
                <xsl:otherwise>
                  <td>
                    <img src="screenshots/default.png" alt="No image"/>
                  </td>
                </xsl:otherwise>
              </xsl:choose>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Sisu ja stiilifaili koostöö http://henri.kroosmann.ee/kool/xml/index.xml

VEEBITEENUSED

8. aprill

Otsustame teha teenused kõikide kohvikute menüüde kohta.

11.-12. aprill

Henri koostab tabelite loogika

13. aprill

Mailis otsustab veebiteenused teha asmx-is [webmethod]-itega

14. aprill

Mailis hakkab veebiteenuseid tegema

17. aprill

Veebiteenused on valmis:

  • AnnaJoogiliikideNimekiri
  • AnnaJoogitabelirida_joogiIDjargi
  • AnnaJookideNimekiri
  • AnnaKohvikuMenyyIDed_kohvikuNimeJargi
  • AnnaKohvikuMenyyRida_kohvikuNimeJargi
  • AnnaKohvikuMenyydeNimekiri_kohvikuNimeJargi
  • AnnaKohvikuNimekiri
  • AnnaMenyyLiikideNimekiri
  • AnnaMenyydeNimekiri
  • AnnaPromillideNimekiri
  • AnnaToiduliikideNimekiri
  • AnnaToitudeNimekiri
  • AnnaToitutabelirida_toiduIDjargi
  • KustutaJookMenyyst
  • KustutaMenyy
  • KustutaToitMenyyst
  • KysiYheKohvikuYheMenyyToitudeIDeed_menyyIDjargi
  • LisaJoogiLiik
  • LisaMenyyLiik
  • LisaPromill
  • LisaToiduLiik
  • TOITJOOKmenyysRida_menyyIDjargi
  • annaArvustusedJoogileMenyys
  • annaArvustusedKohvikule
  • annaArvustusedToiduleMenyys
  • annaJoogiID_nimeJargi
  • annaJoogiKIRJELDUS_IDjargi
  • annaJoogiKOMM_IDjargi
  • annaJoogiLiigiID_joogiIDjargi
  • annaJoogiLiigiID_nimeJargi
  • annaJoogiLiigiNIMI_IDjargi
  • annaJoogiLiigiNIMI_joogiIDjargi
  • annaJoogiNIMI_IDjargi
  • annaKasOnTaimeT_IDjargi
  • annaKohvikuID_nimeJargi
  • annaLinnaID_LinnaNimeJargi
  • annaLinnad_maakonnaNIMEjargi
  • annaMaakonnaID_nimeJargi
  • annaMenyyLiigiID_nimeJargi
  • annaPromill_IDjargi
  • annaPromilliID_promilliNrJargi
  • annaPromilliNR_joogiIDjargi
  • annaToiduID_nimeJargi
  • annaToiduKIRJELDUS_IDjargi
  • annaToiduKOMMENTAAR_IDjargi
  • annaToiduLiigiID_nimeJargi
  • annaToiduLiigiID_toiduIDjargi
  • annaToiduLiigiNIMI_IDjargi
  • annaToiduNIMI_IDjargi
  • annaYheKohvikuMenyyd_kohvikuNIMEjargi
  • k6igiKohvikuteMenyyd
  • lisaArvamusJoogiKohta
  • lisaArvamusKohvikuKohta
  • lisaArvamusToiduKohta
  • lisaJookMenyysse
  • lisaToitMenyysse
  • lisaUusJook
  • lisaUusKohvik
  • lisaUusMenyy
  • lisaUusToit
  • nadalapaevaID

17. aprill

Meetod *k6igiKohvikuteMenyyd kuvab sellise xml struktuuri:

22.aprill

Toimus koosolek

  • Henri lubas meetodite turvamise teha.
  • Heiki lubas statistika teha meetodite kohta.

25. aprill

File:Kohvikute andmetabelid.pdf

Statistika

<source lang="csharp"> using System; using System.Web.Services; using System.Web.Services.Protocols; using System.IO; using System.Net;

// Define a SOAP Extension that traces the SOAP request and SOAP // response for the XML Web service method the SOAP extension is // applied to.

namespace WebASPKohvikud {

   public class TraceExtension : SoapExtension
   {
       Stream oldStream;
       Stream newStream;
       string filename;
       // Save the Stream representing the SOAP request or SOAP response into
       // a local memory buffer.
       public override Stream ChainStream(Stream stream)
       {
           oldStream = stream;
           newStream = new MemoryStream();
           return newStream;
       }
       // When the SOAP extension is accessed for the first time, the XML Web
       // service method it is applied to is accessed to store the file
       // name passed in, using the corresponding SoapExtensionAttribute.	
       public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)
       {
           return ((TraceExtensionAttribute)attribute).Filename;
       }
       // The SOAP extension was configured to run using a configuration file
       // instead of an attribute applied to a specific XML Web service
       // method.
       public override object GetInitializer(Type WebServiceType)
       {
           // Return a file name to log the trace information to, based on the
           // type.
           return "C:\\" + WebServiceType.FullName + ".log";
       }
       // Receive the file name stored by GetInitializer and store it in a
       // member variable for this specific instance.
       public override void Initialize(object initializer)
       {
           filename = (string)initializer;
       }
       //  If the SoapMessageStage is such that the SoapRequest or
       //  SoapResponse is still in the SOAP format to be sent or received,
       //  save it out to a file.
       public override void ProcessMessage(SoapMessage message)
       {
           switch (message.Stage)
           {
               case SoapMessageStage.BeforeSerialize:
                   break;
               case SoapMessageStage.AfterSerialize:
                   WriteOutput(message);
                   break;
               case SoapMessageStage.BeforeDeserialize:
                   WriteInput(message);
                   break;
               case SoapMessageStage.AfterDeserialize:
                   break;
               default:
                   throw new Exception("invalid stage");
           }
       }
       public void WriteOutput(SoapMessage message)
       {
           newStream.Position = 0;
           FileStream fs = new FileStream(filename, FileMode.Append,
               FileAccess.Write);
           StreamWriter w = new StreamWriter(fs);
           string soapString = (message is SoapServerMessage) ? "SoapResponse" : "SoapRequest";
           w.WriteLine("-----" + soapString + " at " + DateTime.Now);
           w.Flush();
           Copy(newStream, fs);
           w.Close();
           newStream.Position = 0;
           Copy(newStream, oldStream);
       }
       public void WriteInput(SoapMessage message)
       {
           Copy(oldStream, newStream);
           FileStream fs = new FileStream(filename, FileMode.Append,
               FileAccess.Write);
           StreamWriter w = new StreamWriter(fs);
           string soapString = (message is SoapServerMessage) ?
               "SoapRequest" : "SoapResponse";
           w.WriteLine("-----" + soapString +
               " at " + DateTime.Now);
           w.Flush();
           newStream.Position = 0;
           Copy(newStream, fs);
           w.Close();
           newStream.Position = 0;
       }
       void Copy(Stream from, Stream to)
       {
           TextReader reader = new StreamReader(from);
           TextWriter writer = new StreamWriter(to);
           writer.WriteLine(reader.ReadToEnd());
           writer.Flush();
       }
   }
   // Create a SoapExtensionAttribute for the SOAP Extension that can be
   // applied to an XML Web service method.
   [AttributeUsage(AttributeTargets.Method)]
   public class TraceExtensionAttribute : SoapExtensionAttribute
   {
       private string filename = @"C:\Users\Heiki Tamm\Documents\Õppematerjalid_2011\WebASPKohvikud\WebASPKohvikud\SoapLog.txt";
       private int priority;
       public override Type ExtensionType
       {
           get { return typeof(TraceExtension); }
       }
       public override int Priority
       {
           get { return priority; }
           set { priority = value; }
       }
       public string Filename
       {
           get
           {
               return filename;
           }
           set
           {
               filename = value;
           }
       }
   }

}


// todo: // from each soap header record query content // (containing client, date, time, query ) into a DB // for later reference for conducting any kind of // applicable statistics and then generate stats :D ! // Proovin selliselt, et on lihtne statistika tabel: // 1) meetod // välja kutsutava meetodi nimi // 2) kuupäev // timestamp // 3) callide arv // meetodi väljakutsimiste hulk