Пример #1
0
        public override void Remove(long entityId)
        {
            EntityId entity = new IdData(entityId);

            Transaction.remove(this, entity);
            AddRemoveCommand(entityId, null, null);
        }
Пример #2
0
 public IActionResult RejectUserManagement(IdData dataOne /*[FromBody]JObject approvedId*/)
 {
     try
     {
         //if (approvedId["PermissionId"]["Id"] != null)
         //{
         //    string approveId = approvedId["PermissionId"]["Id"].ToString();
         //    // var roles = _roleService.GetAllPermissions();
         //    //roles = roles.Where(x => x.Id == int.Parse(id.ToString())).ToList();
         //    //var parent = roles.Where(x => x.ParentPermissionId == null).Select(c => new RoleNode { value = c.Id.Value, label = c.PermissionName, children = addChild(c.Id, roles) }).ToList();
         //    //var checkedNode = parent.Select(c => c.value).ToList();
         //    List<string> checkedNode = new List<string>();
         //    checkedNode.Add("1");
         //    checkedNode.Add("7");
         //    return Ok(checkedNode);
         //}
         if (dataOne.Permission.Id != null)
         {
             List <string> checkedNode = new List <string>();
             checkedNode.Add("1");
             checkedNode.Add("7");
             return(Ok(checkedNode));
         }
         else
         {
             return(NotFound("Record Not Found"));
         }
     }
     catch (System.Exception ex)
     {
         return(NotFound("Something Went wrong" + ex.Message.ToString()));
     }
 }
Пример #3
0
        public async Task <IActionResult> GetAllByDate([FromBody] IdData model)
        {
            var url     = $"{IDPSettings.Current.LunchAppUrl}Menus/GetAllMenuByDate/{model.CompanyId}/{model.Date}/";
            var results = await _services.GetAsync <GetMenusByDate>(url);

            return(new JsonResult(results));
        }
Пример #4
0
        public IActionResult GetPermisssionsById(IdData dataOne)
        {
            try
            {
                if (dataOne.Permission.Id != null)
                {
                    // var roles = _roleService.GetAllPermissions();
                    //roles = roles.Where(x => x.Id == int.Parse(id.ToString())).ToList();
                    //var parent = roles.Where(x => x.ParentPermissionId == null).Select(c => new RoleNode { value = c.Id.Value, label = c.PermissionName, children = addChild(c.Id, roles) }).ToList();
                    //var checkedNode = parent.Select(c => c.value).ToList();
                    RoleData      roleData    = new RoleData();
                    List <string> checkedNode = new List <string>();
                    checkedNode.Add("1");
                    checkedNode.Add("7");
                    roleData.Permissions      = checkedNode;
                    roleData.Role             = new RoleProperties();
                    roleData.Role.Name        = "Osama";
                    roleData.Role.Description = "This is testing";
                    roleData.Role.Comments    = "helloo you are onn";

                    return(Ok(roleData));
                }
                else
                {
                    return(NotFound("Record Not Found"));
                }
            }
            catch (System.Exception ex)
            {
                return(NotFound("Something Went wrong" + ex.Message.ToString()));
            }
        }
Пример #5
0
        public async Task <IActionResult> GetFoodItems([FromBody] IdData model)
        {
            var url     = $"{IDPSettings.Current.LunchAppUrl}GetAllFoodItem/{model.Id}";
            var results = await _services.GetAsync <IEnumerable <GetFoodItem> >(url);

            return(new JsonResult(results));
        }
    public void OnNetDestroy(SocketIOEvent e)
       {
        IdData data = JsonUtility.FromJson<IdData>(e.data.ToString());
        
        if (Net.objects.ContainsKey(data.id))
        {


            //destroy the object on stage
            if (Net.objects[data.id] != null)
            {
                //is it an avatar thingy
                if (Net.objects[data.id].prefabName == "OtherAvatarPrefab") {
                    //do something when another avatar disconnects
                }

                Destroy(Net.objects[data.id].gameObject);
            }
            //remove the object reference
            Net.objects.Remove(data.id);
        }
        else
        {
            print("Warning OnNetDestroy: I can't find a netobject named "+data.id);
        }
    }
Пример #7
0
        public IActionResult GetUserManagementPermisssionsById(IdData dataOne)
        {
            try
            {
                if (dataOne.Permission.Id != null)
                {
                    // var roles = _roleService.GetAllPermissions();
                    //roles = roles.Where(x => x.Id == int.Parse(id.ToString())).ToList();
                    //var parent = roles.Where(x => x.ParentPermissionId == null).Select(c => new RoleNode { value = c.Id.Value, label = c.PermissionName, children = addChild(c.Id, roles) }).ToList();
                    //var checkedNode = parent.Select(c => c.value).ToList();
                    UserManagementData userData    = new UserManagementData();
                    List <string>      checkedNode = new List <string>();
                    checkedNode.Add("1");
                    checkedNode.Add("3");
                    userData.Permissions              = checkedNode;
                    userData.userManagement           = new UserManagementProperties();
                    userData.userManagement.FirstName = "Osama";
                    userData.userManagement.LastName  = "This is testing";
                    userData.userManagement.Password  = "******";

                    return(Ok(userData));
                }
                else
                {
                    return(NotFound("Record Not Found"));
                }
            }
            catch (System.Exception ex)
            {
                return(NotFound("Something Went wrong" + ex.Message.ToString()));
            }
        }
Пример #8
0
        //Edit Panel
        //==============================================================
        private void btEditNew_Click(object sender, EventArgs e)
        {
            if (Log.ShowMessageModal("Confirm", "Do you want to Create a New ID?") != DialogResult.Yes)
            {
                return;
            }

            string Id = tbEditID.Text;
            string Pw = tbEditPW.Text;
            int    Lv = cbEditLevel.SelectedIndex + 1;

            if (Id == "")
            {
                Log.ShowMessage("Check", "Please Input ID");
                return;
            }

            IdData CrntData = new IdData();

            LoadId(Id, ref CrntData);
            if (CrntData.Level != EN_LEVEL.LogOff)
            {
                Log.ShowMessage("Check", "ID Exist Already!");
                return;
            }

            CrntData.ID       = tbEditID.Text;
            CrntData.Password = tbEditPW.Text;
            CrntData.Level    = (EN_LEVEL)(cbEditLevel.SelectedIndex + 1);
            SaveId(CrntData);
        }
Пример #9
0
        private void btDelete_Click(object sender, EventArgs e)
        {
            if (Log.ShowMessageModal("Confirm", "Do you want to Delete the Id Data?") != DialogResult.Yes)
            {
                return;
            }

            string Id = tbEditID.Text;
            string Pw = tbEditPW.Text;
            int    Lv = cbEditLevel.SelectedIndex + 1;

            if (Id == "")
            {
                Log.ShowMessage("Check", "Please Input ID");
                return;
            }

            IdData CrntData = new IdData();

            LoadId(Id, ref CrntData);
            if (CrntData.Level == EN_LEVEL.LogOff)
            {
                Log.ShowMessage("Check", "ID does not Exist!");
                return;
            }

            DeleteId(CrntData.ID);
        }
Пример #10
0
        //LogOn Panel
        //==============================================================

        private void btLogIn_Click(object sender, EventArgs e)
        {
            //string sText = ((Button)sender).Text;
            string sText = " LOG IN";

            Log.Trace(sFormText + sText + " Button Clicked", ForContext.Frm);

            if (btLogIn.Text == " LOG OUT")
            {
                LogedOnData.Password = "******";
                LogedOnData.Level    = EN_LEVEL.LogOff;
                tbID.Enabled         = true;//tbID에 포커스 올라가는 타이밍이 타이머에서 tbID Enabled 하는 타이밍보다 빠름
                tbID.Focus();
                return;
            }

            string Id = tbID.Text;
            string Pw = tbPassword.Text;

            if (Id == "ID" || Id == "")
            {
                Log.ShowMessage("Check", "Please Input ID");
                return;
            }

            if (Id == ControlId && Pw == ControlPassword)
            {
                LogedOnData.ID       = ControlId;
                LogedOnData.Password = ControlPassword;
                LogedOnData.Level    = EN_LEVEL.Control;
                Log.Trace("LogOn ID : " + LogedOnData.ID + " . Level : " + LogedOnData.Level, ForContext.Frm);
                Hide();
                return;
            }

            IdData CrntData = new IdData();

            LoadId(Id, ref CrntData);

            if (CrntData.Level == EN_LEVEL.LogOff)
            {
                Log.ShowMessage("Check", "ID does not Exist!");
                return;
            }
            else
            {
                Log.Trace("LogOn ID : " + CrntData.ID + " . Level : " + CrntData.Level, ForContext.Frm);
            }
            if (CrntData.Password != Pw)
            {
                Log.ShowMessage("Check", "Wrong Password!");
                tbPassword.Clear();
                return;
            }

            LogedOnData = CrntData;

            Hide();
        }
Пример #11
0
        public override void Remove(long entityId, string key)
        {
            AssertValidKey(key);
            EntityId entity = new IdData(entityId);

            Transaction.remove(this, entity, key);
            AddRemoveCommand(entityId, key, null);
        }
    //Socket disconnection is not immediate so I detect when a client quits  
    void OnApplicationQuit()
    {
        IdData data = new IdData();
        data.id = Net.myId;

        if(socket != null)
            socket.Emit("quit", JsonUtility.ToJson(data));
    }
    public void OnSetAuthority(SocketIOEvent e)
    {
        IdData data = JsonUtility.FromJson<IdData>(e.data.ToString());
        Debug.Log("Authority is set to: " + data.id);
        Net.authorityId = data.id;

        Net.authority = (data.id == Net.myId && data.id != "");
        
        if (Net.authority)
            print("I AM THE AUTHORITY!");
     }
Пример #14
0
        public void SaveId(IdData Data)
        {
            //Make Dir.
            string   sExeFolder = System.AppDomain.CurrentDomain.BaseDirectory;
            string   sPath      = sExeFolder + "Util\\LogOn.ini";
            CIniFile Ini        = new CIniFile(sPath);
            int      iTemp      = 0;

            Ini.Save(Data.ID, "Password", Data.Password);
            iTemp = (int)Data.Level;
            Ini.Save(Data.ID, "Level", iTemp);
        }
    //from the server: a player disconnected
    public void OnPlayerDisconnect(SocketIOEvent e)
    {
        IdData data = JsonUtility.FromJson<IdData>(e.data.ToString());
        Debug.Log("[SocketIO] Player Disconnected: " + data.id);
        
        //remove the reference in the dictionary
        if (Net.players.ContainsKey(data.id))
        {
            Net.players.Remove(data.id);
        }

    }
Пример #16
0
        /// <summary>
        /// See <seealso cref="Index.remove(PropertyContainer, string, object)"/> for more
        /// generic documentation.
        ///
        /// Removes key/value to the {@code entity} in this index. Removed values
        /// are excluded within the transaction, but composite {@code AND}
        /// queries aren't guaranteed to exclude removed values correctly within
        /// that transaction. When the transaction has been committed all such
        /// queries are guaranteed to return correct results.
        /// </summary>
        /// <param name="entityId"> the entity (i.e <seealso cref="Node"/> or <seealso cref="Relationship"/>)
        /// to dissociate the key/value pair from. </param>
        /// <param name="key"> the key in the key/value pair to dissociate from the entity. </param>
        /// <param name="value"> the value in the key/value pair to dissociate from the
        /// entity. </param>
        public override void Remove(long entityId, string key, object value)
        {
            AssertValidKey(key);
            EntityId entity = new IdData(entityId);

            foreach (object oneValue in IoPrimitiveUtils.asArray(value))
            {
                oneValue = GetCorrectValue(oneValue);
                Transaction.remove(this, entity, key, oneValue);
                AddRemoveCommand(entityId, key, oneValue);
            }
        }
Пример #17
0
        void InitializeIdData(GalacticProperties gp)
        {
            foreach (var idd in gp.IdProperties.Values)
            {
                IdData idData = new IdData(idd.IDType,
                                           idd.LastIDAdded,
                                           new HashSet <int>(Enumerable.Range(0, idd.LastIDAdded + 1).Where(i => !idd.ReservedIDs.Contains(i))),
                                           new HashSet <int>(),
                                           idd.ReservedIDs);

                DbIdIoService.SaveIdDataAsync(idData).Wait();
            }
        }
Пример #18
0
        public void LoadId(string _sId, ref IdData Data)
        {
            //Make Dir.
            string   sExeFolder = System.AppDomain.CurrentDomain.BaseDirectory;
            string   sPath      = sExeFolder + "Util\\LogOn.ini";
            CIniFile Ini        = new CIniFile(sPath);
            int      iTemp      = 0;

            //Load Device.

            Ini.Load(_sId, "Password", ref Data.Password);
            Ini.Load(_sId, "Level", ref iTemp); Data.Level = (EN_LEVEL)iTemp;
            Data.ID = _sId;
        }
Пример #19
0
        /// <summary>
        /// See <seealso cref="Index.add(PropertyContainer, string, object)"/> for more generic
        /// documentation.
        ///
        /// Adds key/value to the {@code entity} in this index. Added values are
        /// searchable within the transaction, but composite {@code AND}
        /// queries aren't guaranteed to return added values correctly within that
        /// transaction. When the transaction has been committed all such queries
        /// are guaranteed to return correct results.
        /// </summary>
        /// <param name="key"> the key in the key/value pair to associate with the entity. </param>
        /// <param name="value"> the value in the key/value pair to associate with the
        /// entity. </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void addNode(long entityId, String key, Object value) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
        public override void AddNode(long entityId, string key, object value)
        {
            AssertValidKey(key);
            AssertValidValue(value);
            EntityId entity = new IdData(entityId);

            foreach (object oneValue in IoPrimitiveUtils.asArray(value))
            {
                oneValue = GetCorrectValue(oneValue);
                DataSource.assertValidType(key, oneValue, IdentifierConflict);
                Transaction.add(this, entity, key, oneValue);
                CommandFactory.addNode(IdentifierConflict.indexName, entityId, key, oneValue);
            }
        }
Пример #20
0
        //LogOn Panel
        //==============================================================

        private void btLogIn_Click(object sender, EventArgs e)
        {
            if (btLogIn.Text == "LogOut")
            {
                LogedOnData.Password = "******";
                LogedOnData.Level    = EN_LEVEL.LogOff;
                tbID.Enabled         = true;//tbID에 포커스 올라가는 타이밍이 타이머에서 tbID Enabled 하는 타이밍보다 빠름
                tbID.Focus();
                return;
            }

            string Id = tbID.Text;
            string Pw = tbPassword.Text;

            if (Id == "ID" || Id == "")
            {
                Log.ShowMessage("Check", "Please Input ID");
                return;
            }

            if (Id == ControlId && Pw == ControlPassword)
            {
                LogedOnData.ID       = ControlId;
                LogedOnData.Password = ControlPassword;
                LogedOnData.Level    = EN_LEVEL.Control;
                Hide();
                return;
            }

            IdData CrntData = new IdData();

            LoadId(Id, ref CrntData);

            if (CrntData.Level == EN_LEVEL.LogOff)
            {
                Log.ShowMessage("Check", "ID does not Exist!");
                return;
            }
            if (CrntData.Password != Pw)
            {
                Log.ShowMessage("Check", "Wrong Password!");
                tbPassword.Clear();
                return;
            }

            LogedOnData = CrntData;

            Hide();
        }
Пример #21
0
        public void SetId <TIndex>(TIndex[] data, PrimitiveType primitiveType) where TIndex : struct
        {
            Activate();
            var buffer = RequestBuffer(IdBufferBinding, BufferTarget.ElementArrayBuffer);

            // set buffer data
            buffer.Set(data, BufferUsageHint.StaticDraw);
            //activate for state
            buffer.Activate();
            //cleanup state
            Deactive();
            buffer.Deactive();
            //save data for draw call
            DrawElementsType drawElementsType = GetDrawElementsType(typeof(TIndex));

            _idData = new IdData(primitiveType, data.Length, drawElementsType);
        }
Пример #22
0
    IEnumerator CheckIfSessaoExistsCoroutine(string name)
    {
        WWWForm wwwf = new WWWForm();

        wwwf.AddField("name", name);

        WWW www = new WWW("http://localhost/jogos/checkSectionID.php", wwwf);

        yield return(www);

        if (www.error == null)
        {
            Debug.Log(www.text);
            currentIdData = JsonUtility.FromJson <IdData>(www.text);
            returnMessage = currentIdData.message;
        }
    }
        public void InitializeAsync(IdData kData)
        {
            Source.Clear();
            FoundInVocab.Clear();
            PassedItem         = kData;
            IsKanji            = true;
            IsVocab            = false;
            ComponentsTypeName = "Radicals";
            Item              = KanjiData.Data.Find(x => x.id == int.Parse(kData.Id));
            MainReadingType   = Item.data.readings.First(x => x.primary).type;
            OtherReadings     = Item.data.readings.Where(x => x.reading != kData.MainReading).Select(x => x.reading).ToList();
            OtherReadingsType = string.Join(",", Item.data.readings.Where(x => x.reading != kData.MainReading).Select(x => x.type).ToList());
            string j = string.Join(",", Item.data.meanings.Where(x => x.primary == false).Select(x => x.meaning).ToList());

            altMeaningsL = String.IsNullOrEmpty(j) ? "" : "Alternative: " + j;
            var inst = Item.data.readings;

            Readings = new ReadingCustom
            {
                Kunyomi = inst.Where(x => x.type == "kunyomi").Count() > 0
                ? string.Join(",", inst.Where(x => x.type == "kunyomi").Select(x => x.reading).ToList())
                : "None",
                KunyomiEnabled = inst.Where(x => x.type == "kunyomi").Count() > 0 ? false : true,

                Onyomi = inst.Where(x => x.type == "onyomi").Count() > 0
                ? string.Join(",", inst.Where(x => x.type == "onyomi").Select(x => x.reading).ToList())
                : "None",
                OnyomiEnabled = inst.Where(x => x.type == "onyomi").Count() > 0 ? false : true,

                Nanori = inst.Where(x => x.type == "nanori").Count() > 0
                ? string.Join(",", inst.Where(x => x.type == "nanori").Select(x => x.reading).ToList())
                : "None",
                NanoriEnabled = inst.Where(x => x.type == "nanori").Count() > 0 ? false : true,
            };
            foreach (var c in Item.data.component_subject_ids)
            {
                var k = RadicalData.Ids.First(x => long.Parse(x.Id) == c);
                Source.Add(k);
            }
            foreach (var c in Item.data.amalgamation_subject_ids)
            {
                var k = VocabData.Ids.First(x => long.Parse(x.Id) == c);
                FoundInVocab.Add(k);
            }
        }
Пример #24
0
    IEnumerator CreateSessionCoroutine(string name, int team)
    {
        WWWForm wwwf = new WWWForm();

        wwwf.AddField("name", name);
        wwwf.AddField("team", team);

        using (var w = UnityWebRequest.Post("http://localhost/jogos/createSession.php", wwwf))
        {
            yield return(w.SendWebRequest());

            if (w.isNetworkError || w.isHttpError)
            {
                Debug.LogError(w.error);
            }
            else
            {
                Debug.Log(w.downloadHandler.text);
                currentIdData = JsonUtility.FromJson <IdData>(w.downloadHandler.text);
                returnMessage = currentIdData.message;
            }
        }
    }
Пример #25
0
        void _generateNewIDs(int numIDs)
        {
            lock (IDLOCK)
            {
                try
                {
                    ConsoleManager.WriteLine("Generating new ids of type " + IDType, ConsoleMessageType.Notification);

                    int n = checked (numIDs + _minIDCount);
                    //If this statement throws an exception, congratulations! Freecon has grown
                    //large enough to run out of 32bit galaxy IDs. Now you as the developer
                    //are in line for the pleasure of implementing 64bit galaxy IDs! Have fun,
                    //and try not to kill yourself!

                    for (int i = _lastIdGenerated + 1; i < numIDs + _lastIdGenerated + 1; i++)
                    {
                        if (_reservedIDs.Contains(i))
                        {
                            n = checked (numIDs + _minIDCount); //Throws exception if numIDs + _minIDCount > int.MAX
                            numIDs++;
                            continue;
                        }

                        _freeIDs.Push(i);
                    }
                    _lastIdGenerated = numIDs + _lastIdGenerated;

                    var idData = new IdData(IDType, _lastIdGenerated, new HashSet <int>(_freeIDs), new HashSet <int>(_generatedIDs), new HashSet <int>(_reservedIDs));
                    _dbIdIoService.SaveIdDataAsync(idData);
                }
                catch
                {
                    throw new Exception("Ran out of 32 bit ints for IDs. Time for a 64 bit server!");
                }
            }
        }
Пример #26
0
        /// <summary>
        /// Retrieves the HTML for the current field.
        /// </summary>
        /// <returns>An HTML String.</returns>
        public string GetSearchHTML()
        {
            string retval             = "";
            string fieldId            = "data_" + IdData.ToString();
            string validationFunction = "";

            switch (Kind)
            {
            case Data.SIMPLE_TEXT:
            case Data.YES_NO:
            case Data.OPTIONS:
            case Data.CHECKBOX:
            case Data.TREE:
            case Data.EMAIL:
                retval = GetFieldHTML();
                break;

            case Data.MULTI_TEXT:
                retval = DrawInput.InputTextField(fieldId, SearchValue, "", "", "", "", "");
                break;

            case Data.INTEGER:
            case Data.FLOAT:
                NumberJSON numberJSON = JsonConvert.DeserializeObject <NumberJSON>(AuxValues);
                if ((numberJSON.from == numberJSON.to) && (numberJSON.to == 0))
                {
                    numberJSON.maxLength = "10";
                }
                if (Kind == Data.FLOAT)
                {
                    validationFunction = "validateFloat($(this), event);";
                }
                else
                {
                    validationFunction = "validateInt($(this), event);";
                }
                retval  = Text.Between + "&nbsp";
                retval += DrawInput.InputTextField(fieldId, SearchValue, numberJSON.maxLength, "", validationFunction, "width: 50px;", "title=\"" + Common.StrLang(Text.EnterValueBetweenXandY, numberJSON.from + "," + numberJSON.to) + "\" onKeyUp=\"" + validationFunction + "\"");
                retval += "&nbsp;" + Text.And + "&nbsp;";
                retval += DrawInput.InputTextField(fieldId + "_aux", SearchValueAux, numberJSON.maxLength, "", validationFunction, "width: 50px;", "title=\"" + Common.StrLang(Text.EnterValueBetweenXandY, numberJSON.from + "," + numberJSON.to) + "\" onKeyUp=\"" + validationFunction + "\"");
                break;

            case Data.SLIDER:
                validationFunction = "validateInt($(this), event);";
                retval             = Text.Between + "&nbsp";
                retval            += DrawInput.InputTextField(fieldId, SearchValue, "10", "", validationFunction, "width: 50px;", "onKeyUp=\"" + validationFunction + "\"");
                retval            += "&nbsp;" + Text.And + "&nbsp;";
                retval            += DrawInput.InputTextField(fieldId + "_aux", SearchValueAux, "10", "", validationFunction, "width: 50px;", "onKeyUp=\"" + validationFunction + "\"");
                break;

            case Data.DATE:
                retval  = Text.Between + "&nbsp";
                retval += DrawInput.InputTextField(fieldId, SearchValue, "", "datePicker", "", "width: 85px;", "");
                retval += "&nbsp;" + Text.And + "&nbsp;";
                retval += DrawInput.InputTextField(fieldId + "_aux", SearchValueAux, "", "datePicker", "", "width: 85px;", "");
                break;

            default:
                break;
            }
            return(retval);
        }
Пример #27
0
 public bool Compare(IdData compareId)
 {
     return(this == compareId);
 }
 //destroy a net object
 public void NetDestroy(string uniqueId)
 {
     IdData data = new IdData();
     data.id = uniqueId;
     socket.Emit("destroy", JsonUtility.ToJson(data));
 }
Пример #29
0
            // ReSharper disable UnusedVariable
            private IdData GetData(BinaryReader fileStream)
            {
                var retdata = new IdData();

                // using the official id3 tag documentation
                // http://id3.org/id3v2.3.0#ID3_tag_version_2.3.0

                // read + validate header                                    [10 bytes]
                // skipped for TagID                                         >03 bytes
                byte versionMajor  = fileStream.ReadByte();            //                >01 bytes
                byte version_minor = fileStream.ReadByte();            //               >01 bytes
                byte data_flags    = fileStream.ReadByte();            //                  >01 bytes
                int  tagSize       = fileStream.ReadId3Int();          //                    >04 bytes

                // start at 0, the header is excluded from `tagSize`
                int readCount = 0;

                #region ID3v2
                if (versionMajor == 2)
                {
                    while (readCount < tagSize)
                    {
                        // frame header                                      [06 bytes]
                        int frameId   = fileStream.ReadInt24Be();                       //           >03 bytes
                        int frameSize = fileStream.ReadInt24Be();                       //         >03 bytes
                        readCount += 6;

                        if (readCount + frameSize > tagSize)
                        {
                            throw new FormatException("Frame position+size exceedes header size");
                        }

                        if (frameId == v2_TT2)
                        {
                            var textBuffer = fileStream.ReadBytes(frameSize);
                            retdata.Title = DecodeString(textBuffer[0], textBuffer, 1, frameSize - 1);
                        }
                        else if (frameId == v2_PIC)
                        {
                            var  textEncoding = fileStream.ReadByte();
                            var  imageType    = fileStream.ReadInt24Be();                         // JPG or PNG (or other?)
                            var  pictureType  = fileStream.ReadByte();
                            var  description  = new List <byte>();
                            byte textByte;
                            while ((textByte = fileStream.ReadByte()) != 0)
                            {
                                description.Add(textByte);
                            }

                            retdata.Picture = fileStream.ReadBytes(frameSize - (description.Count + 5));
                        }
                        else if (frameId == 0)
                        {
                            break;
                        }
                        else
                        {
                            fileStream.ReadBytes(frameSize);
                            readCount += frameSize;
                        }
                    }
                }
                #endregion
                #region ID3v3/4
                else if (versionMajor == 3 || versionMajor == 4)
                {
                    while (readCount < tagSize)
                    {
                        // frame header                                        [10 bytes]
                        uint   frameId     = fileStream.ReadUInt32Be();                  //           >04 bytes
                        int    frameSize   = fileStream.ReadId3Int();                    //            >04 bytes
                        ushort frame_flags = fileStream.ReadUInt16Be();                  //     >02 bytes
                        readCount += 10;

                        if (readCount + frameSize > tagSize)
                        {
                            throw new FormatException("Frame position+size exceedes header size");
                        }

                        // content
                        if (frameId == v3_TIT2)
                        {
                            var textBuffer = fileStream.ReadBytes(frameSize);
                            // is a string, so the first byte is a indicator byte
                            retdata.Title = DecodeString(textBuffer[0], textBuffer, 1, frameSize - 1);
                        }
                        else if (frameId == v3_APIC)
                        {
                            var  textEncoding = fileStream.ReadByte();
                            var  mime         = new List <byte>();
                            byte textByte;
                            while ((textByte = fileStream.ReadByte()) != 0)
                            {
                                mime.Add(textByte);
                            }
                            var pictureType = fileStream.ReadByte();
                            var description = new List <byte>();
                            while ((textByte = fileStream.ReadByte()) != 0)
                            {
                                description.Add(textByte);
                            }

                            retdata.Picture = fileStream.ReadBytes(frameSize - (description.Count + mime.Count + 2));
                        }
                        else if (frameId == 0)
                        {
                            break;
                        }
                        else
                        {
                            fileStream.ReadBytes(frameSize);
                        }
                        readCount += frameSize;
                    }
                }
                #endregion
                else
                {
                    throw new FormatException("Major id3 tag version not supported");
                }

                return(retdata);
            }
Пример #30
0
    private string createFakeSerializedJsonString()
    {
        Debug.Log("emptyDataCreation");


        Service humidity = new Service();

        humidity.type    = "Number";
        humidity.value   = "114";
        humidity.mdNames = new int[0];
        humidity.creDate = "1522055622";
        humidity.modDate = "1522227222";

        Service position = new Service();

        position.type    = "position";
        position.value   = "18.677896423339842, 64.59036829080296";
        position.mdNames = new int[0];
        position.creDate = "1522055731";
        position.modDate = "1522055731";

        Service owner = new Service();

        owner.type    = "String";
        owner.value   = "Paul";
        owner.mdNames = new int[0];
        owner.creDate = "1522055731";
        owner.modDate = "1522055731";

        Service environment = new Service();

        environment.type    = "String";
        environment.value   = "Indoor";
        environment.mdNames = new int[0];
        environment.creDate = "1522055731";
        environment.modDate = "1522055731";

        Service visibility = new Service();

        visibility.type    = "String";
        visibility.value   = "Public";
        visibility.mdNames = new int[0];
        visibility.creDate = "1522055731";
        visibility.modDate = "1522055731";

        SensorData _sensorData = new SensorData();
        IdData     idData      = new IdData();

        idData.id                               = "env_virt_5_humid";
        idData.type                             = "test";
        idData.servicePath                      = "/";
        _sensorData._id                         = idData;
        _sensorData.attrNames                   = new string[] { "humidity", "position", "owner", "environment", "visibility" };
        _sensorData.attrs                       = new Service[] { humidity, position, owner, environment, visibility };
        _sensorData.credate                     = 1522055622;
        _sensorData.modDate                     = 1522227222;
        _sensorData.location                    = new Location();
        _sensorData.location.attrName           = "Position";
        _sensorData.location.coords             = new Coords();
        _sensorData.location.coords.coordinates = new float[] { 64.58686932696415f, 18.651374740600584f };


        //Unities standard json solution, is built for small data files and can not cope with lists of objects.
        //https://github.com/SaladLab/Json.Net.Unity3D is a popular solution and even has a link on the asset store
        // got advice to go with https://github.com/jacobdufault/fullserializer

        //http://json2csharp.com/

        SensorData[] batchList = new SensorData[] { _sensorData };
        //string jsonSerializedString = JsonUtility.ToJson(batchList);
        //populateServices();



        //



        string jsonSerializedString = Serialize(batchList.GetType(), batchList);;

        Debug.Log("jsonSerializedString = " + jsonSerializedString);
        return(jsonSerializedString);
    }