Ejemplo n.º 1
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     Radius = prop_set.getPropInt("I_Radius").get();
     ParticleName = EbDataMgr.Instance.getData<TbDataParticle>(prop_set.getPropInt("I_ParticleName").get());
 }
Ejemplo n.º 2
0
        public int AddBytes(byte[] bytes, int offset, int length)
        {
            int counter;

            for (counter = 0; counter < length; ++counter)
            {
                switch (_currentState)
                {
                    case DataState.WaitingForCr:
                        if (bytes[offset + counter] == '\r')
                        {
                            _currentState = DataState.WaitingForLf;
                        }
                        break;
                    case DataState.WaitingForLf:
                        _currentState = bytes[offset + counter] == '\n' ? DataState.Done : DataState.WaitingForCr;
                        break;
                    case DataState.Done:
                        return counter;
                }
                _finalString += ((char) bytes[offset + counter]);
            }

            return counter;
        }
Ejemplo n.º 3
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     EffectIndex = prop_set.getPropInt("I_EffectIndex").get();
     EffectTypeEnum = EbDataMgr.Instance.getData<TbDataEffectName>(prop_set.getPropInt("I_EffectTypeEnum").get());
 }
Ejemplo n.º 4
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     LastTime = prop_set.getPropInt("I_LastTime").get();
 }
Ejemplo n.º 5
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     Size = prop_set.getPropInt("I_Size").get();
     ParticlePrefabName = prop_set.getPropString("T_ParticlePrefabName").get();
 }
Ejemplo n.º 6
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     BulletCount = prop_set.getPropInt("I_BulletCount").get();
     Bullet = EbDataMgr.Instance.getData<TbDataBullet>(prop_set.getPropInt("I_Bullet").get());
 }
Ejemplo n.º 7
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     PlayerHeadNum = prop_set.getPropInt("I_PlayerHeadNum").get();
     PlayerHeadName = prop_set.getPropString("T_PlayerHeadName").get();
 }
Ejemplo n.º 8
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     Fish = EbDataMgr.Instance.getData<TbDataFish>(prop_set.getPropInt("I_Fish").get());
     FishAmount = prop_set.getPropInt("I_FishAmount").get();
     ShoalType = (_eShoalType)prop_set.getPropInt("I_ShoalType").get();
 }
Ejemplo n.º 9
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     AudioName = prop_set.getPropString("T_AudioName").get();
     LoopType = (AudioLoopTypeEnum)prop_set.getPropInt("I_LoopType").get();
     AudioType = (AudioTypeEnum)prop_set.getPropInt("I_AudioType").get();
 }
Ejemplo n.º 10
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     AnimationName = prop_set.getPropString("T_AnimationName").get();
     SpritePixelHeight = prop_set.getPropInt("I_SpritePixelHeight").get();
     SpriteLogicHeight = prop_set.getPropInt("I_SpriteLogicHeight").get();
 }
Ejemplo n.º 11
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     PropName = prop_set.getPropString("T_PropName").get();
     PropDesn = prop_set.getPropString("T_PropDesn").get();
     PropDisableTexName = prop_set.getPropString("T_PropDisableTexName").get();
     PropAvailableTexName = prop_set.getPropString("T_PropAvailableTexName").get();
 }
Ejemplo n.º 12
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     CoinCount = prop_set.getPropInt("I_CoinCount").get();
     var prop_coin = prop_set.getPropInt("I_CoinType");
     CoinType = prop_coin == null ? CoinTypeEnum.Default : (CoinTypeEnum)prop_coin.get();
     CoinScore = prop_set.getPropInt("I_CoinScore").get();
 }
Ejemplo n.º 13
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     NormalFish = EbDataMgr.Instance.getData<TbDataFish>(prop_set.getPropInt("I_NormalFish").get());
     RedFish = EbDataMgr.Instance.getData<TbDataFish>(prop_set.getPropInt("I_RedFish").get());
     RedFishDouble = EbDataMgr.Instance.getData<TbDataFish>(prop_set.getPropInt("I_RedFishDouble").get());
     LastTime = prop_set.getPropInt("I_LastTime").get();
 }
Ejemplo n.º 14
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     SourceName = prop_set.getPropString("T_SourceName").get();
     SwordCount = prop_set.getPropInt("I_SwordCount").get();
     LastTime = prop_set.getPropInt("I_LastTime").get();
     SwordSpeed = prop_set.getPropInt("I_SwordSpeed").get();
     var prop_spread = prop_set.getPropInt("I_SpreadType");
     SpreadType = prop_spread == null ? SpreadTypeEnum.Default : (SpreadTypeEnum)prop_spread.get();
 }
Ejemplo n.º 15
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     NormalFish = EbDataMgr.Instance.getData<TbDataFish>(prop_set.getPropInt("I_NormalFish").get());
     RedFish = EbDataMgr.Instance.getData<TbDataFish>(prop_set.getPropInt("I_RedFish").get());
     SpreadCount = prop_set.getPropInt("I_SpreadCount").get();
     GapTime = prop_set.getPropInt("I_GapTime").get();
     FishCount = prop_set.getPropInt("I_FishCount").get();
     Speed = prop_set.getPropFloat("R_Speed").get();
 }
Ejemplo n.º 16
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     RoomType = (_eRoomType)prop_set.getPropInt("I_RoomType").get();
     RoomNum = prop_set.getPropInt("I_RoomNum").get();
     RoomEnterGoldLimit = prop_set.getPropInt("I_RoomEnterGoldLimit").get();
     RoomSingleFireGoldLimit = prop_set.getPropInt("I_RoomSingleFireGoldLimit").get();
     RoomRate = prop_set.getPropString("T_RoomRate").get();
     RoomDesktopNum = prop_set.getPropInt("I_RoomDesktopNum").get();
 }
Ejemplo n.º 17
0
 public static EntityState ConvertState(DataState state)
 {
     switch (state)
     {
         case DataState.Added:
             return EntityState.Added;
         case DataState.Modified:
             return EntityState.Modified;
         case DataState.Deleted:
             return EntityState.Deleted;
         default:
             return EntityState.Unchanged;
     }
 }
Ejemplo n.º 18
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     BackGroundAniName = prop_set.getPropString("T_BackGroundAniName").get();
     BackGroundAnimationScale = prop_set.getPropInt("I_BackGroundAnimationScale").get();
     FishComposes = new List<TbDataFishEachCompose>();
     string strFishComposes = prop_set.getPropString("T_FishComposes").get();
     string[] arrayFishcomposes = strFishComposes.Split(';');
     foreach (string fishCompose in arrayFishcomposes)
     {
         FishComposes.Add(EbDataMgr.Instance.getData<TbDataFishEachCompose>(int.Parse(fishCompose)));
     }
 }
Ejemplo n.º 19
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     ListFishIdAndScale = new List<TbDataFish.FishIdAndScaleStruct>();
     for (int i = 1; i <= 5; ++i)
     {
         string strFishIdAndScales = prop_set.getPropString("T_FishIdAndScale" + i.ToString()).get();
         string[] arrayStrFishIdAndScales = strFishIdAndScales.Split(';');
         TbDataFish.FishIdAndScaleStruct fishIdAndScaleStruct = new TbDataFish.FishIdAndScaleStruct();
         fishIdAndScaleStruct.FishId = int.Parse(arrayStrFishIdAndScales[0]);
         fishIdAndScaleStruct.Scale = int.Parse(arrayStrFishIdAndScales[1]);
         ListFishIdAndScale.Add(fishIdAndScaleStruct);
     }
 }
Ejemplo n.º 20
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     FishColumns = new List<FormationElementStruct>();
     for (int i = 1; i <= 10; ++i)
     {
         string strFishColumns = prop_set.getPropString("T_FishColumns" + i.ToString()).get();
         string[] arrayFishColumns = strFishColumns.Split(';');
         FormationElementStruct formationElementStruct = new FormationElementStruct();
         formationElementStruct.Fish = EbDataMgr.Instance.getData<TbDataFish>(int.Parse(arrayFishColumns[0]));
         formationElementStruct.ColumnNumber = int.Parse(arrayFishColumns[1]);
         formationElementStruct.Amount = int.Parse(arrayFishColumns[2]);
         FishColumns.Add(formationElementStruct);
     }
 }
Ejemplo n.º 21
0
        public Indicator AnalyzeData(DataState state)
        {
            double[] highPrices  = _analyseRepo.LoadHighPriceBySymbol(state.Symbol, true).ToArray();
            double[] lowPrices   = _analyseRepo.LoadLowPriceBySymbol(state.Symbol, true).ToArray();
            double[] closePrices = _analyseRepo.LoadClosePriceBySymbol(state.Symbol, true).ToArray();
            double[] adxValues   = ADXCalculator.CalculateADX(ADXCalculator.Period, highPrices, lowPrices, closePrices);
            if (adxValues.Length == 0)
            {
                return(null);
            }

            ADX value = new ADX();

            value.Symbol = state.Symbol;
            value.Date   = state.Last.Value;
            value.ADX14  = AlgorithmHelper.GetLast(adxValues);
            return(value.ToIndicator());
        }
Ejemplo n.º 22
0
        /// <inheritdoc/>
        protected override async Task OnExecuteAsync(CommandLineApplication app)
        {
            if (string.IsNullOrEmpty(Program.Environment))
            {
                Console.WriteLine("Please set the environment context before using this command.");
                Console.WriteLine("Update environment using cmd: settings update -e [environment] \n ");
                return;
            }

            if (string.IsNullOrEmpty(InstanceId) && string.IsNullOrEmpty(InstanceGuid))
            {
                Console.WriteLine("Please provide an instanceId or instanceGuid");
                return;
            }

            if ((DataState.Equals("deleted") || DataState.Equals("all")) && (string.IsNullOrEmpty(Org) || string.IsNullOrEmpty(App)))
            {
                Console.WriteLine("Please provide org and app when listing deleted data elements.");
                return;
            }

            string instanceGuid = InstanceGuid ?? InstanceId.Split('/')[1];

            switch (DataState.ToLower())
            {
            case "deleted":
                await ListDataElements(Org, App, instanceGuid, ElementState.Deleted);

                break;

            case "all":
                await ListDataElements(Org, App, instanceGuid, ElementState.All);

                break;

            case "active":
            default:
                await ListActiveDataElements(instanceGuid);

                break;
            }

            CleanUp();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Update Selling Price Tab
        /// </summary>
        /// <param name="dataState">Read data from or write data to form</param>
        private void UpdateSellingPriceTabPage(DataState dataState)
        {
            switch (dataState)
            {
            case DataState.ReadFromUI:
                decimal decimalValue;

                _sellingPriceDataModel.Price = null;
                if (decimal.TryParse(txtSellingPrice.Text, out decimalValue))
                {
                    _sellingPriceDataModel.Price = decimalValue;
                }
                _sellingPriceDataModel.Transport = null;
                if (decimal.TryParse(txtSellingPriceTransport.Text, out decimalValue))
                {
                    _sellingPriceDataModel.Transport = decimalValue;
                }
                _sellingPriceDataModel.Other1 = null;
                if (decimal.TryParse(txtPurchaseOther1.Text, out decimalValue))
                {
                    _sellingPriceDataModel.Other1 = decimalValue;
                }
                _sellingPriceDataModel.Other2 = null;
                if (decimal.TryParse(txtPurchaseOther2.Text, out decimalValue))
                {
                    _sellingPriceDataModel.Other2 = decimalValue;
                }
                _sellingPriceDataModel.TotalSelling = null;
                if (decimal.TryParse(lblSellingTotal.Text, out decimalValue))
                {
                    _sellingPriceDataModel.TotalSelling = decimalValue;
                }
                break;

            case DataState.WriteToUI:
                txtSellingPrice.Text          = _sellingPriceDataModel.Price.ToString();
                txtSellingPriceTransport.Text = _sellingPriceDataModel.Transport.ToString();
                txtSellingOther1.Text         = _sellingPriceDataModel.Other1.ToString();
                txtSellingOther2.Text         = _sellingPriceDataModel.Other2.ToString();
                lblSellingTotal.Text          = _sellingPriceDataModel.TotalSelling.ToString();
                break;
            }
        }
Ejemplo n.º 24
0
        // Start is called before the first frame update
        void Start()
        {
            LocalizationState lcd = LocalizationSave.LoadData();

            if (lcd == null)
            {
                lc.LoadLocalizeText("en_EN.json");
            }
            else
            {
                lc.LoadLocalizeText(lcd.LocalizationFileName);
            }

            DataState loadedData = SaveState.LoadData();

            if (loadedData != null)
            {
                PhotonNetwork.AuthValues.UserId = loadedData.UserId;
                //Debug.Log(PhotonNetwork.AuthValues.UserId);
                PhotonNetwork.NickName = loadedData.NickName;

                StartCoroutine(LoadRole());

                if (loadedData.IsInMenu)
                {
                    PhotonNetwork.LeaveLobby();
                    launchServerList();
                }
                else if (loadedData.endGame)
                {
                    launchMainMenu();
                }

                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
            }
            else
            {
                launchLoginMenu();
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
            }
        }
Ejemplo n.º 25
0
 private void OnFeaturedQueried(List <string> videoGuidList)
 {
     if (this.dataState != DataState.Loading)
     {
         return;
     }
     this.dataState = DataState.Loaded;
     if (videoGuidList == null)
     {
         this.CreateMessage(VideoSummaryStyle.FeaturedError);
         return;
     }
     if (videoGuidList.Count == 0)
     {
         this.CreateMessage(VideoSummaryStyle.FeaturedEmpty);
         return;
     }
     this.CreateVideoSummary(videoGuidList);
     this.sourceTypeHelper.QueryStart();
 }
Ejemplo n.º 26
0
 public void OnGetPaywalls(PaywallModel[] paywalls, ProductModel[] products, DataState state, AdaptyError error)
 {
     if (error != null)
     {
         Debug.Log("Error message: " + error.message + ", code: " + error.code);
     }
     else
     {
         Debug.Log("State: " + state);
         foreach (PaywallModel paywall in paywalls)
         {
             Debug.Log("Paywall developerId: " + paywall.developerId + ", products: " + paywall.products.Length);
         }
         foreach (ProductModel product in products)
         {
             retrievedProducts.Add(product);
             Debug.Log("Product price: " + product.localizedPrice + ", vendorProductId: " + product.vendorProductId + ", skuId: " + product.skuId);
         }
     }
 }
Ejemplo n.º 27
0
        //-------------------------------------------------------------------------
        public override void load(EbPropSet prop_set)
        {
            Name = prop_set.getPropString("T_Name").get();
            Note = prop_set.getPropString("T_Note").get();
            var prop_state = prop_set.getPropInt("I_State");
            State = prop_state == null ? DataState.Default : (DataState)prop_state.get();

            EffectElements = new List<EffectElementStruct>();
            for (int i = 1; i <= 6; ++i)
            {
                string strElements = prop_set.getPropString("T_EffectElement" + i.ToString()).get();
                string[] ArrayElements = strElements.Split(';');
                EffectElementStruct effectElementStruct = new EffectElementStruct();
                effectElementStruct.EffectName = EbDataMgr.Instance.getData<TbDataEffectName>(int.Parse(ArrayElements[0]));
                effectElementStruct.EffectId = int.Parse(ArrayElements[1]);
                effectElementStruct.EffectType = string.IsNullOrEmpty(ArrayElements[2]) ? EffectElementStruct.EffectTypeEnum.Default : (EffectElementStruct.EffectTypeEnum)int.Parse(ArrayElements[2]);
                effectElementStruct.EffectDelayTime = int.Parse(ArrayElements[3]);
                EffectElements.Add(effectElementStruct);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Update payments tab
        /// </summary>
        /// <param name="dataState">Read data from or write data to form</param>
        private void UpdatePaymentsTabPage(DataState dataState)
        {
            switch (dataState)
            {
            case DataState.ReadFromUI:
                var dataTable = ConvertToDataTable(paymenetUnitsDataGridView);
                _salesManagement.Payment.PaymentTotal = (long)CalculateTotalPayments();
                break;

            case DataState.WriteToUI:
                lblPaymentsTotal.Text = _salesManagement.Payment.PaymentTotal.ToString();
                lblDueAmount.Text     = CalculateDueAmount().ToString();
                // Data grid view column setting
                paymenetUnitsDataGridView.DataSource = _salesManagement.Payment.PaymentUnits;
                paymenetUnitsDataGridView.Columns["PaymentUnitID"].Visible = false;
                paymenetUnitsDataGridView.Columns["PaymentID"].Visible     = false;
                paymenetUnitsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
                break;
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 根据Id获取实体对象
 /// </summary>
 /// <param name="id"></param>
 /// <param name="queryState">默认返回正常数据,数据状态支持enum Flags位标志</param>
 /// <returns></returns>
 public TEntity GetById(object id, DataState queryState = DataState.Normal)
 {
     try
     {
         if (_Conn.State == ConnectionState.Closed)
         {
             _Conn.Open();
         }
         var item = _Conn.Get <TEntity>(id);
         if (item == null)
         {
             return(null);
         }
         return(item); //使用Flags位运算
     }
     finally
     {
         _Conn.Close();
     }
 }
Ejemplo n.º 30
0
    public void SetCardData(int stateNum)
    {
        DataState            state           = (DataState)stateNum;
        CardScriptableObject csvSOFile       = csvReader.GetCSVData();
        List <CardData>      csvCardDataList = csvSOFile.cardDataList;
        //CardScriptableObject saveSOFile = scriptableObjectUtility.GetAssetData<CardScriptableObject>();
        CardScriptableObject saveSOFile       = jsonController.LoadJsonFile <CardScriptableObject>(jsonFilePath, jsonFileName);
        List <CardData>      saveCardDataList = null;

        if (saveSOFile != null)
        {
            saveCardDataList = saveSOFile.cardDataList;
        }
        else
        {
            state = DataState.State_NewData;
        }


        switch (state)
        {
        case DataState.State_NewData:
            cardDataList = csvCardDataList;
            break;

        case DataState.State_SaveData:
            cardDataList = csvCardDataList;
            foreach (var saveCardData in saveCardDataList)
            {
                foreach (var cardData in cardDataList)
                {
                    if (cardData.cardName == saveCardData.cardName)
                    {
                        cardData.cardPos  = saveCardData.cardPos;
                        cardData.usedTime = saveCardData.usedTime;
                    }
                }
            }
            break;
        }
    }
Ejemplo n.º 31
0
        public void CanAnalyzeSMA()
        {
            var repo  = new MocAnalyseRepository();
            var task  = new AnalyzeSMATask(repo);
            var state = new DataState {
                Symbol = "AAPL", Last = new DateTime(2012, 4, 4)
            };
            var result = task.AnalyzeData(state);

            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Symbol == "AAPL");
            Assert.IsTrue(result.Name == SMA.Name);
            Assert.IsTrue(result.Date.Year == 2012 && result.Date.Month == 4 && result.Date.Day == 4);

            /*
             * <Data>
             * <SMA50>114.55</SMA50>
             * <SMA200>102.95</SMA200>
             * </Data>
             */
        }
        private string BuildDmlSql(EntityExplain <T> expl, DataState state, ParameterCollection output, ref IDictionary <string, T> incrementEntity)
        {
            //
            string identityFieldName = null;

            if (expl.Increment != null)
            {
                if (incrementEntity == null)
                {
                    incrementEntity = new Dictionary <string, T>();
                }
                identityFieldName = expl.Increment.ColumnName + incrementEntity.Count;
            }
            //
            string innerSql;
            bool   hasIncrement = false;

            switch (state)
            {
            case DataState.New:
                innerSql = EntityToSql.GenerateInsert(expl, output, true, out hasIncrement, identityFieldName);
                break;

            case DataState.Modify:
                innerSql = EntityToSql.GenerateUpdate(expl, output);
                break;

            case DataState.NewOrModify:
                innerSql = EntityToSql.GenerateInsertOrUpdate(expl, output, true, out hasIncrement, identityFieldName);
                break;

            default:
                throw new ArgumentException("不支持枚举:" + expl.OperationState);
            }
            if (hasIncrement)
            {
                incrementEntity.Add(identityFieldName, expl.EntityData);
            }
            return(innerSql);
        }
Ejemplo n.º 33
0
    public IEnumerator DetectData()
    {
        yield return(null);

        FileInfo info = new FileInfo(Application.persistentDataPath + "/" + sceneName + ".unity3d");

        //        WWW www = new WWW(SceneManager.PathURL+sceneName + ".unity3d");
        if (info.Exists || sManager.IsInAvailableScene(sceneName))
        {
            psc.UnDownLoadObj(false);
            psc.DownLoadObj(false);
            if (!SceneManager.sceneDataState.ContainsKey(int.Parse(gameObject.name)))
            {
                dataState = DataState.Downloaded;
                SceneManager.sceneDataState.Add(int.Parse(gameObject.name), dataState);
            }
            else
            {
                dataState = DataState.Downloaded;
                SceneManager.sceneDataState[int.Parse(gameObject.name)] = dataState;
            }
        }
        else
        {
            if (dataState == DataState.Downloading)
            {
                psc.DownLoadObj(true);
                psc.UnDownLoadObj(false);
            }
            else
            {
                psc.UnDownLoadObj(true);
            }
            if (!SceneManager.sceneDataState.ContainsKey(int.Parse(gameObject.name)))
            {
                dataState = DataState.unDownload;
                SceneManager.sceneDataState.Add(int.Parse(gameObject.name), dataState);
            }
        }
    }
Ejemplo n.º 34
0
        /// <summary>
        /// Update the products tab
        /// </summary>
        /// <param name="dataState">Read data from or write data to form</param>
        private void UpdateProductTabPage(DataState dataState)
        {
            switch (dataState)
            {
            case DataState.ReadFromUI:
                decimal decimalValue;
                int     intValue;

                _productDataModel.Brand = txtBrand.Text;
                _productDataModel.Model = txtModel.Text;

                _productDataModel.VIN = null;
                if (decimal.TryParse(txtVIN.Text, out decimalValue))
                {
                    _productDataModel.VIN = decimalValue;
                }

                _productDataModel.EnteriorColour = txtEnteriorColour.Text;
                _productDataModel.ExteriorColour = txtExteriorColour.Text;

                _productDataModel.ModelYear = null;
                if (int.TryParse(txtModelYear.Text, out intValue))
                {
                    _productDataModel.ModelYear = intValue;
                }
                break;

            case DataState.WriteToUI:
                lblProductIDShow.Text  = _productDataModel.ProductID.ToString();
                txtBrand.Text          = _productDataModel.Brand;
                txtModel.Text          = _productDataModel.Model;
                txtVIN.Text            = _productDataModel.VIN.ToString();
                txtEnteriorColour.Text = _productDataModel.EnteriorColour;
                txtExteriorColour.Text = _productDataModel.ExteriorColour;
                txtModelYear.Text      = _productDataModel.ModelYear.ToString();
                txtDLPNetto.Text       = _productDataModel.DLPNetto.ToString();
                txtDLPBrutto.Text      = _productDataModel.DLPBrutto.ToString();
                break;
            }
        }
Ejemplo n.º 35
0
        internal DataState Parse(DataSet data)
        {
            DataState state = new DataState();

            state.RidesMap    = new Map(data);
            state.CurrentTime = 0;
            state.MaxTime     = data.Steps;
            state.VehicleTime = new VehicleTimeState(data);
            state.Vehicles    = new VehicleState[data.Vehicles];
            for (int i = 0; i < state.Vehicles.Length; i++)
            {
                state.Vehicles[i] = new VehicleState()
                {
                    FirstRelevantTime            = 0,
                    TimeLocation                 = new Point(0, 0),
                    RideHistory                  = new System.Collections.Generic.List <Ride>(),
                    PossibleMovesUpToCurrentTime = new System.Collections.Generic.List <System.Collections.Generic.List <Point> >(),
                };
            }

            return(state);
        }
Ejemplo n.º 36
0
        public Indicator AnalyzeData(DataState state)
        {
            double[] closePrices = _analyseRepo.LoadClosePriceBySymbol(state.Symbol, true).ToArray();

            double[] sma5Values   = SMACalculator.CalculateSMA(5, closePrices);
            double[] sma10Values  = SMACalculator.CalculateSMA(10, closePrices);
            double[] sma20Values  = SMACalculator.CalculateSMA(20, closePrices);
            double[] sma50Values  = SMACalculator.CalculateSMA(50, closePrices);
            double[] sma200Values = SMACalculator.CalculateSMA(200, closePrices);

            SMA value = new SMA();

            value.Symbol = state.Symbol;
            value.Date   = state.Last.Value;
            value.SMA5   = AlgorithmHelper.GetLast(sma5Values);
            value.SMA10  = AlgorithmHelper.GetLast(sma10Values);
            value.SMA20  = AlgorithmHelper.GetLast(sma20Values);
            value.SMA50  = AlgorithmHelper.GetLast(sma50Values);
            value.SMA200 = AlgorithmHelper.GetLast(sma200Values);

            return(value.ToIndicator());
        }
Ejemplo n.º 37
0
        //-------------------------------------------------------------------------
        public override void load(EbPropSet prop_set)
        {
            Name = prop_set.getPropString("T_Name").get();
            var prop_state = prop_set.getPropInt("I_State");
            State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
            Duration = prop_set.getPropInt("I_Duration").get();

            FishOut = new List<FishOutStruct>();
            for (int i = 0; i < 100; ++i)
            {
                string strFishOut = prop_set.getPropString("T_FishOut" + i.ToString()).get();
                string[] arrayFishOut = strFishOut.Split(';');
                FishOutStruct fishOutStruct = new FishOutStruct();
                fishOutStruct.BeginTime = int.Parse(arrayFishOut[0]);
                fishOutStruct.EndTime = int.Parse(arrayFishOut[1]);
                fishOutStruct.ShoalAmountMin = int.Parse(arrayFishOut[2]);
                fishOutStruct.ShoalAmountMax = int.Parse(arrayFishOut[3]);
                fishOutStruct.Shoal = EbDataMgr.Instance.getData<TbDataShoal>(int.Parse(arrayFishOut[4] + 1));
                fishOutStruct.Route = EbDataMgr.Instance.getData<TbDataRoute>(int.Parse(arrayFishOut[5]));
                FishOut.Add(fishOutStruct);
            }
        }
Ejemplo n.º 38
0
        public void CanAnalyzeRSIPredict()
        {
            var repo  = new MocAnalyseRepository();
            var task  = new AnalyzeRSIPredictTask(repo);
            var state = new DataState {
                Symbol = "AAPL", Last = new DateTime(2012, 4, 4)
            };
            var result = task.AnalyzeData(state);

            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Symbol == "AAPL");
            Assert.IsTrue(result.Name == RSIPredict.Name);
            Assert.IsTrue(result.Date.Year == 2012 && result.Date.Month == 4 && result.Date.Day == 4);

            /*
             * <Data>
             * <PredictRsi30Price>101.81</PredictRsi30Price>
             * <PredictRsi50Price>120.18</PredictRsi50Price>
             * <PredictRsi70Price>128.06</PredictRsi70Price>
             * </Data>
             */
        }
Ejemplo n.º 39
0
    private void EndReceiveMessage(IAsyncResult asyncResult)
    {
        DataState dataState = (DataState)asyncResult.AsyncState;
        Socket    handler   = dataState.handler;

        byte[] buffer      = dataState.buffer;
        int    messageSize = handler.EndReceive(asyncResult);

        if (messageSize > 0)
        {
            string message = null;
            message = Encoding.ASCII.GetString(buffer, 0, messageSize);

            StartReceiveMessage(handler);
            OnMessageReceived(message);
        }
        else
        {
            handler.Shutdown(SocketShutdown.Both);
            handler.Close();
        }
    }
Ejemplo n.º 40
0
        public void CanAnalyzeGainLoss()
        {
            var repo  = new MocAnalyseRepository();
            var task  = new AnalyzeGainLossTask(repo);
            var state = new DataState {
                Symbol = "AAPL", Last = new DateTime(2012, 4, 4)
            };
            var result = task.AnalyzeData(state);

            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Symbol == "AAPL");
            Assert.IsTrue(result.Name == GainLoss.Name);
            Assert.IsTrue(result.Date.Year == 2012 && result.Date.Month == 4 && result.Date.Day == 4);

            /*
             * <Data>
             * <MaxContGainDays>5</MaxContGainDays>
             * <AvgContGainDays>2.33</AvgContGainDays>
             * <MaxContLossDays>3</MaxContLossDays>
             * <AvgContLossDays>1.22</AvgContLossDays>
             * <LastGLContDays>1</LastGLContDays>
             * </Data>*/
        }
Ejemplo n.º 41
0
        public Indicator AnalyzeData(DataState state)
        {
            List <double> closePrices = _analyseRepo.LoadClosePriceBySymbol(state.Symbol, true).ToList();

            RSIRangeData range = RSICalculator.GetRSIRange(RSICalculator.Period, closePrices);

            if (range == null)
            {
                return(null);
            }
            RSIRange value = new RSIRange();

            value.Symbol = state.Symbol;
            value.Date   = state.Last.Value;
            value.Min    = range.Min;
            value.Max    = range.Max;
            value.L5     = range.L5;
            value.H5     = range.H5;
            value.L10    = range.L10;
            value.H10    = range.H10;
            value.L15    = range.L15;
            value.H15    = range.H15;
            return(value.ToIndicator());
        }
Ejemplo n.º 42
0
        public void CanAnalyzeProfit()
        {
            var repo  = new MocAnalyseRepository();
            var task  = new AnalyzeProfitTask(repo);
            var state = new DataState {
                Symbol = "AAPL", Last = new DateTime(2012, 4, 4)
            };
            var result = task.AnalyzeData(state);

            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Symbol == "AAPL");
            Assert.IsTrue(result.Name == Profit.Name);
            Assert.IsTrue(result.Date.Year == 2012 && result.Date.Month == 4 && result.Date.Day == 4);

            /*
             * <Data>
             * <R20Day>14.62</R20Day>
             * <R50Day>13.48</R50Day>
             * <R100Day>29.36</R100Day>
             * <R150Day>37.14</R150Day>
             * <R200Day>53.04</R200Day>
             * </Data>
             */
        }
Ejemplo n.º 43
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
 }
Ejemplo n.º 44
0
        public static int GetCount(int siteId, DataState state)
        {
            var entries = DataCountManagerCache.GetDataCountsCache(siteId);

            return(entries[state.Value]);
        }
Ejemplo n.º 45
0
 public StateChangeEventArgs(DataState oldVal, DataState newVal)
 {
   OldValue = oldVal;
   NewValue = newVal;
 }
Ejemplo n.º 46
0
 private Data(DataState state, TValue value, IDataContainer <TValue> dataContainer)
 {
     State          = state;
     _dataContainer = dataContainer;
     _value         = value;
 }
Ejemplo n.º 47
0
        /// <summary>
        /// Tokenises a line of text.
        /// </summary>
        /// <param name="command">Command typed by the user.</param>
        /// <returns>List of parsed tokens.</returns>
        public ProgramLine Tokenise(string command)
        {
            int?          lineNumber       = null;
            List <IToken> tokens           = new List <IToken>();
            string        currentTokenText = string.Empty;
            bool          inQuotes         = false;
            bool          lineNumberValid  = true;
            bool          remarkMode       = false;
            bool          dataMode         = false;
            DataState     dataState        = DataState.SearchingForComma;

            foreach (var c in command)
            {
                // Skip white space.
                if (!inQuotes && char.IsWhiteSpace(c))
                {
                    continue;
                }

                // If it's remark mode then keep on going....
                if (remarkMode)
                {
                    currentTokenText += c;
                    inQuotes          = true;
                    continue;
                }

                // If it's data mode then keep on going until we see a colon
                if (dataMode)
                {
                    dataState = GetNextDataState(dataState, c);
                    if ((c != ':') || (dataState == DataState.FoundQuote))
                    {
                        currentTokenText += c;
                        inQuotes          = true;
                        continue;
                    }

                    inQuotes = false;
                    tokens.Add(new Token(currentTokenText, TokenClass.Data));
                    currentTokenText = string.Empty;
                }

                // Deal with line numbers.
                if (char.IsDigit(c) && lineNumberValid)
                {
                    lineNumber = (lineNumber.GetValueOrDefault() * 10) + (c - '0');
                    if (lineNumber > ushort.MaxValue)
                    {
                        throw new Exceptions.SyntaxErrorException();
                    }

                    continue;
                }

                // Not digit or white space so no line number.
                lineNumberValid = false;

                // Got a quote character?
                if (c == '\"')
                {
                    if (inQuotes)
                    {
                        // Found the end of our string
                        inQuotes = false;
                        tokens.Add(new Token(currentTokenText, TokenClass.String));
                    }
                    else
                    {
                        // If we already have text then it should be a variable or number.
                        // So create a token for what we have and turn on quotes mode.
                        inQuotes = true;
                        if (currentTokenText != string.Empty)
                        {
                            tokens.Add(new Token(currentTokenText));
                        }
                    }

                    currentTokenText = string.Empty;
                    continue;
                }

                if (inQuotes)
                {
                    currentTokenText = currentTokenText + c;
                    continue;
                }

                currentTokenText = currentTokenText + char.ToUpper(c);
                var retryMatch = false;

                do
                {
                    retryMatch = false;

                    // Not a quote so maybe it's a token.
                    var matches = _tokensProvider.Tokens.Where(t => t.Text.StartsWith(currentTokenText)).ToArray();

                    // Too many matches, loop and get another character.
                    if (matches.Length > 1)
                    {
                        continue;
                    }

                    // We're matching at the start of the line.
                    if (matches.Length == 1)
                    {
                        if (matches[0].Text == currentTokenText)
                        {
                            if (matches[0].Seperator == TokenType.Print)
                            {
                                tokens.Add(_tokensProvider.Tokens.Where(t => t.Statement == TokenType.Print).First());
                            }
                            else
                            {
                                tokens.Add(matches[0]);
                            }

                            currentTokenText = string.Empty;
                            remarkMode       = matches[0].Statement == TokenType.Remark;
                            dataMode         = matches[0].Statement == TokenType.Data;
                            dataState        = 0;
                        }

                        // Okay don't try the mid match
                        continue;
                    }

                    // Now for the awkward bit we want to turn AFOR in A FOR not AF OR
                    // ACRIGHT$ should be AC RIGHT$ not AC RIGHT $
                    matches = _tokensProvider.Tokens.Where(t => currentTokenText.Contains(t.Text)).OrderByDescending(t => t.Text.Length).ToArray();
                    if (matches.Length > 0)
                    {
                        var start = currentTokenText.IndexOf(matches[0].Text);
                        if (start != 0)
                        {
                            var text = currentTokenText.Substring(0, start);
                            tokens.Add(new Token(text));
                        }

                        tokens.Add(matches[0]);
                        currentTokenText = currentTokenText.Substring(start + matches[0].Text.Length);
                        retryMatch       = currentTokenText != string.Empty;
                    }
                }while (retryMatch);
            }

            // If we're in datamode always create token.
            if (dataMode)
            {
                tokens.Add(new Token(currentTokenText, TokenClass.Data));
            }
            else if (currentTokenText != string.Empty)
            {
                if (remarkMode)
                {
                    tokens.Add(new Token(currentTokenText, TokenClass.Remark));
                }
                else if (inQuotes)
                {
                    tokens.Add(new Token(currentTokenText, TokenClass.String));
                }
                else
                {
                    var matches = _tokensProvider.Tokens.Where(t => currentTokenText.Contains(t.Text)).OrderByDescending(t => t.Text.Length).ToArray();
                    if (matches.Length > 0)
                    {
                        var start = currentTokenText.IndexOf(matches[0].Text);
                        if (start != 0)
                        {
                            var text = currentTokenText.Substring(0, start);
                            tokens.Add(new Token(text));
                        }

                        tokens.Add(matches[0]);
                        currentTokenText = currentTokenText.Substring(start + matches[0].Text.Length);
                    }

                    if (currentTokenText != string.Empty)
                    {
                        tokens.Add(new Token(currentTokenText));
                    }
                }
            }

            return(new ProgramLine(lineNumber, tokens));
        }
Ejemplo n.º 48
0
 /// <summary>
 /// 更改评估记录状态
 /// </summary>
 /// <param name="evaluateNameId"></param>
 /// <param name="state"></param>
 public static void ChangeKPIEvaluateState(string evaluateNameId, DataState state)
 {
     dal.ChangeKPIEvaluateState(evaluateNameId, state);
 }
Ejemplo n.º 49
0
        public static void Run()
        {
            if (State != DataState.Idle)
            {
                return;
            }

            Loaded = 0;

            State = DataState.Starting;
            Directory.CreateDirectory("pages");

            Thread = new Thread(new ThreadStart(delegate()
            {
                if (File.Exists(MainFileName))
                {
                    File.Delete(MainFileName);
                }

                if (File.Exists(ListsFileName))
                {
                    File.Delete(ListsFileName);
                }

                names           = new List <string>();
                ListsTextWriter = new StreamWriter(File.Create(ListsFileName));;
                ListsTextWriter.WriteLine("using System;");
                ListsTextWriter.WriteLine("using System.Collections.Generic;");
                ListsTextWriter.WriteLine("using Tibia.Objects;");
                ListsTextWriter.WriteLine("");
                ListsTextWriter.WriteLine("namespace Tibia.Constants {");
                ListsTextWriter.WriteLine(" public static class ItemDataLists {");
                ListsTextWriter.WriteLine("     #region All Items");
                ListsTextWriter.WriteLine("     public static Dictionary<string, ItemData> AllItems = new Dictionary<string, ItemData> {");

                MainTextWriter = new StreamWriter(File.Create(MainFileName));;
                MainTextWriter.WriteLine("using System;");
                MainTextWriter.WriteLine("using System.Collections.Generic;");
                MainTextWriter.WriteLine("using Tibia.Objects;");
                MainTextWriter.WriteLine("");
                MainTextWriter.WriteLine("namespace Tibia.Constants {");
                MainTextWriter.WriteLine("  public static class ItemsData {");

                Total  = ItemLists.AllItems.Count;
                Loaded = 0;
                Parsed = 0;
                State  = DataState.Downloading;

                foreach (var i in ItemLists.AllItems)
                {
                    if (File.Exists("pages\\" + i.Value.Name.Replace(' ', '_')) && !Reset)
                    {
                        if (++Loaded >= Total)
                        {
                            State = DataState.Waiting;
                        }

                        continue;
                    }

                    WebClient c              = new WebClient();
                    c.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(DownloadCompleted);
                    c.DownloadFileAsync(new Uri("http://tibia.wikia.com/index.php?title=" + i.Value.Name.Replace(' ', '_') + "&printable=yes"), "pages\\" + i.Value.Name.Replace(' ', '_'));
                }

                while (State != DataState.Waiting)
                {
                    Thread.Sleep(100);
                }

                State = DataState.Parsing;

                foreach (var i in ItemLists.AllItems)
                {
                    if (names.Contains(i.Value.Name.Replace(" ", "").Replace("'", "")))
                    {
                        continue;
                    }

                    names.Add(i.Value.Name.Replace(" ", "").Replace("'", ""));
                    MainTextWriter.Write("      public static ItemData " + i.Value.Name.Replace(" ", "").Replace("'", "") + " = new ItemData(\"" + i.Value.Name.Replace('_', ' ') + "\", ");
                    MainTextWriter.Write(i.Value.Id + ", ");
                    StreamReader s = new StreamReader("pages\\" + i.Value.Name.Replace(' ', '_'));
                    ParseItem(s.ReadToEnd());
                    ListsTextWriter.WriteLine("         { ItemsData." + i.Value.Name.Replace(" ", "").Replace("'", "") + ".Name, ItemsData." + i.Value.Name.Replace(" ", "").Replace("'", "") + " },");
                    Parsed++;
                }

                State = DataState.Idle;
                ListsTextWriter.WriteLine("     };");
                ListsTextWriter.WriteLine("     #endregion");
                ListsTextWriter.WriteLine(" }");
                ListsTextWriter.WriteLine("}");
                ListsTextWriter.WriteLine("");

                MainTextWriter.WriteLine("  }");
                MainTextWriter.WriteLine("}");
                MainTextWriter.WriteLine("");

                MainTextWriter.Close();
                ListsTextWriter.Close();
            }));
            Thread.Start();
        }
Ejemplo n.º 50
0
 public AreeData(DataState state)
 {
     State = state;
 }
Ejemplo n.º 51
0
 public OU(object name, object importId, object importParentId, DataState state)
     : this(name, importId, importParentId)
 {
     State = state;
 }
Ejemplo n.º 52
0
 public OU(object name, object importId, object importParentId, DataState state)
     : this(name, importId, importParentId)
 {
     State = state;
 }
Ejemplo n.º 53
0
        //-------------------------------------------------------------------------
        public override void load(EbPropSet prop_set)
        {
            var prop_state = prop_set.getPropInt("I_State");

            State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
        }
Ejemplo n.º 54
0
 public FillRate(TaxonomyInfo taxonomy, IEnumerable <string> filterExpressions, IEnumerable <string> excludeExpressions, DataState dataState, DateTime asOnDate)
 {
     Taxonomy   = taxonomy;
     _dataState = dataState;
     _asOnDate  = asOnDate;
 }
Ejemplo n.º 55
0
 static void Load()
 {
     data = SerializatorBinary.LoadBinary(GetPath());
     Debug.Log("[SaveGame] --> Loading the save file: " + GetPath());
 }
Ejemplo n.º 56
0
 private static void DownloadCompleted(object o, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (++Loaded >= Total)
     {
         State = DataState.Waiting;
     }
 }
Ejemplo n.º 57
0
 /// <summary>
 /// Resets and clears this instance.
 /// </summary>
 public void Reset()
 {
     Payload.Clear();
     Format = DataFormat.Unknown;
     InternalState = DataState.Empty;
 }
Ejemplo n.º 58
0
        public static void Run()
        {
            if (State != DataState.Idle)
                return;

            Loaded = 0;

            State = DataState.Starting;
            Directory.CreateDirectory("pages");

            Thread = new Thread(new ThreadStart(delegate()
            {
                if (File.Exists(MainFileName))
                {
                    File.Delete(MainFileName);
                }

                if (File.Exists(ListsFileName))
                {
                    File.Delete(ListsFileName);
                }

                names = new List<string>();
                ListsTextWriter = new StreamWriter(File.Create(ListsFileName)); ;
                ListsTextWriter.WriteLine("using System;");
                ListsTextWriter.WriteLine("using System.Collections.Generic;");
                ListsTextWriter.WriteLine("using Pokemon.Objects;");
                ListsTextWriter.WriteLine("");
                ListsTextWriter.WriteLine("namespace Pokemon.Constants {");
                ListsTextWriter.WriteLine(" public static class ItemDataLists {");
                ListsTextWriter.WriteLine("     #region All Items");
                ListsTextWriter.WriteLine("     public static Dictionary<string, ItemData> AllItems = new Dictionary<string, ItemData> {");

                MainTextWriter = new StreamWriter(File.Create(MainFileName)); ;
                MainTextWriter.WriteLine("using System;");
                MainTextWriter.WriteLine("using System.Collections.Generic;");
                MainTextWriter.WriteLine("using Pokemon.Objects;");
                MainTextWriter.WriteLine("");
                MainTextWriter.WriteLine("namespace Pokemon.Constants {");
                MainTextWriter.WriteLine("  public static class ItemsData {");

                Total = ItemLists.AllItems.Count;
                Loaded = 0;
                Parsed = 0;
                State = DataState.Downloading;

                foreach (var i in ItemLists.AllItems)
                {
                    if (File.Exists("pages\\" + i.Value.Name.Replace(' ', '_')) && !Reset)
                    {
                        if (++Loaded >= Total)
                        {
                            State = DataState.Waiting;
                        }

                        continue;
                    }

                    WebClient c = new WebClient();
                    c.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(DownloadCompleted);
                    c.DownloadFileAsync(new Uri("http://Pokemon.wikia.com/index.php?title=" + i.Value.Name.Replace(' ', '_') + "&printable=yes"), "pages\\" + i.Value.Name.Replace(' ', '_'));
                }

                while (State != DataState.Waiting)
                {
                    Thread.Sleep(100);
                }

                State = DataState.Parsing;

                foreach (var i in ItemLists.AllItems)
                {
                    if (names.Contains(i.Value.Name.Replace(" ", "").Replace("'", "")))
                    {
                        continue;
                    }

                    names.Add(i.Value.Name.Replace(" ", "").Replace("'", ""));
                    MainTextWriter.Write("      public static ItemData " + i.Value.Name.Replace(" ", "").Replace("'", "") + " = new ItemData(\"" + i.Value.Name.Replace('_', ' ') + "\", ");
                    MainTextWriter.Write(i.Value.Id + ", ");
                    StreamReader s = new StreamReader("pages\\" + i.Value.Name.Replace(' ', '_'));
                    ParseItem(s.ReadToEnd());
                    ListsTextWriter.WriteLine("         { ItemsData." + i.Value.Name.Replace(" ", "").Replace("'", "") + ".Name, ItemsData." + i.Value.Name.Replace(" ", "").Replace("'", "") + " },");
                    Parsed++;
                }

                State = DataState.Idle;
                ListsTextWriter.WriteLine("     };");
                ListsTextWriter.WriteLine("     #endregion");
                ListsTextWriter.WriteLine(" }");
                ListsTextWriter.WriteLine("}");
                ListsTextWriter.WriteLine("");

                MainTextWriter.WriteLine("  }");
                MainTextWriter.WriteLine("}");
                MainTextWriter.WriteLine("");

                MainTextWriter.Close();
                ListsTextWriter.Close();
            }));
            Thread.Start();
        }
Ejemplo n.º 59
0
        public static void Run()
        {
            if (State != DataState.Idle)
            {
                return;
            }

            Loaded = 0;

            foreach (DamageType d in Enum.GetValues(typeof(DamageType)))
            {
                DamageTypes.Add(d.ToString());
            }

            foreach (LootPossibility l in Enum.GetValues(typeof(LootPossibility)))
            {
                LootPossibilities.Add(l.ToString());
            }

            State = DataState.Starting;
            string         url     = "http://tibia.wikia.com/index.php?title=List_of_Creatures&printable=yes";
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

            Directory.CreateDirectory("pages");

            Thread = new Thread(new ThreadStart(delegate()
            {
                if (File.Exists(MainFileName))
                {
                    File.Delete(MainFileName);
                }
                if (File.Exists(ListsFileName))
                {
                    File.Delete(ListsFileName);
                }

                string html = GetHTML(request.GetResponse());

                ListsTextWriter = new StreamWriter(File.Create(ListsFileName));;
                ListsTextWriter.WriteLine("using System;");
                ListsTextWriter.WriteLine("using System.Collections.Generic;");
                ListsTextWriter.WriteLine("using Tibia.Objects;");
                ListsTextWriter.WriteLine("");
                ListsTextWriter.WriteLine("namespace Tibia.Constants {");
                ListsTextWriter.WriteLine(" public static class CreatureLists {");
                ListsTextWriter.WriteLine("     #region All Creatures");
                ListsTextWriter.WriteLine("     public static Dictionary<string, CreatureData> AllCreatures = new Dictionary<string, CreatureData> {");

                MainTextWriter = new StreamWriter(File.Create(MainFileName));;
                MainTextWriter.WriteLine("using System;");
                MainTextWriter.WriteLine("using System.Collections.Generic;");
                MainTextWriter.WriteLine("using Tibia.Objects;");
                MainTextWriter.WriteLine("");
                MainTextWriter.WriteLine("namespace Tibia.Constants {");
                MainTextWriter.WriteLine("  public static class Creatures {");

                ParseCreatures(html);

                ListsTextWriter.WriteLine("     };");
                ListsTextWriter.WriteLine("     #endregion");
                ListsTextWriter.WriteLine(" }");
                ListsTextWriter.WriteLine("}");
                ListsTextWriter.WriteLine("");

                MainTextWriter.WriteLine("  }");
                MainTextWriter.WriteLine("}");
                MainTextWriter.WriteLine("");

                MainTextWriter.Close();
                ListsTextWriter.Close();
            }));
            Thread.Start();
        }
Ejemplo n.º 60
0
 public void Reset()
 {
     _currentState = DataState.WaitingForCr;
     _finalString = "";
 }