コード例 #1
0
ファイル: SqliteStorage.cs プロジェクト: imustardsoft/rhodes
        public boolean isTableExists(string strName)
        {
            Object[]  vals = { strName };
            IDBResult res  = executeSQL("SELECT name FROM sqlite_master WHERE type='table' AND name=?", vals, false, false);
            boolean   bRes = !res.isEnd();

            res.close();

            return(bRes);
        }
コード例 #2
0
ファイル: SyncSource.cs プロジェクト: joelbm24/rhodes
        //{"source_name":"SampleAdapter","client_id":1,"create":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}}}
        //{"source_name":"SampleAdapter","client_id":1,"update":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}}}
        //{"source_name":"SampleAdapter","client_id":1,"delete":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}}}
        //{"source_name":"SampleAdapter","client_id":1,"delete":{"3":{"brand":"HTC","name":"Fuze","price":"299.99"}},"create":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}},"update":{"2":{"brand":"Android","name":"G2","price":"99.99"}}}
        String makePushBody_Ver3(String strUpdateType, boolean isSync)
        {
            String strBody = "";

            getDB().Lock();

            if (isSync)
            {
                getDB().updateAllAttribChanges();
            }

            IDBResult res = getDB().executeSQL("SELECT attrib, object, value, attrib_type " +
                                               "FROM changed_values where source_id=? and update_type =? and sent<=1 ORDER BY object", getID(), strUpdateType);

            if (res.isEnd())
            {
                res.close();
                getDB().Unlock();
                return(strBody);
            }

            String  strCurObject = "";
            boolean bFirst       = true;

            for ( ; !res.isEnd(); res.next())
            {
                String strAttrib  = res.getStringByIdx(0);
                String strObject  = res.getStringByIdx(1);
                String value      = res.getStringByIdx(2);
                String attribType = res.getStringByIdx(3);

                if (attribType.compareTo("blob.file") == 0)
                {
                    NetRequest.MultipartItem oItem = new NetRequest.MultipartItem();
                    oItem.m_strFilePath    = RHODESAPP().resolveDBFilesPath(value);
                    oItem.m_strContentType = "application/octet-stream";
                    oItem.m_strName        = strAttrib + "-" + strObject;

                    m_arBlobAttrs.addElement(strAttrib);
                    m_arMultipartItems.addElement(oItem);
                }

                if (strBody.length() == 0)
                {
                    if (!isSync)
                    {
                        strBody += "{";
                    }
                    else
                    {
                        strBody += "\"" + strUpdateType + "\":{";
                    }
                }

                if (strObject.compareTo(strCurObject) != 0)
                {
                    if (strCurObject.length() > 0)
                    {
                        if (!bFirst)
                        {
                            strBody += "}";
                        }
                        strBody += ",";
                    }

                    bFirst       = true;
                    strBody     += JSONEntry.quoteValue(strObject);
                    strCurObject = strObject;
                }

                if (!bFirst)
                {
                    strBody += ",";
                }

                if (strAttrib.length() > 0)
                {
                    if (bFirst)
                    {
                        strBody += ":{";
                    }

                    strBody += JSONEntry.quoteValue(strAttrib) + ":" + JSONEntry.quoteValue(value);
                    bFirst   = false;
                }
            }

            if (strBody.length() > 0)
            {
                if (!bFirst)
                {
                    strBody += "}";
                }

                strBody += "}";
            }

            if (isSync)
            {
                getDB().executeSQL("UPDATE changed_values SET sent=1 WHERE source_id=? and update_type=? and sent=0", getID(), strUpdateType);
            }

            getDB().Unlock();

            return(strBody);
        }