• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Utils.ProgressBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Utils.ProgressBlock的典型用法代码示例。如果您正苦于以下问题:C# Utils.ProgressBlock类的具体用法?C# Utils.ProgressBlock怎么用?C# Utils.ProgressBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Utils.ProgressBlock类属于命名空间,在下文中一共展示了Utils.ProgressBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ImportMethod

        protected override void ImportMethod()
        {
            int max = _gcList.Count; //caches, waypoints, logs
            int index = 0;
            DateTime nextUpdate = DateTime.Now.AddSeconds(1);
            using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_ASSIGNCITY, STR_ASSIGNCITY, max, 0, true))
            {
                foreach (Framework.Data.Geocache gc in _gcList)
                {
                    if (index>0)
                    {
                        System.Threading.Thread.Sleep(1000); //OSM policy
                    }
                    gc.City = Utils.Geocoder.GetCityName(gc.Lat, gc.Lon);

                    index++;
                    if (DateTime.Now >= nextUpdate)
                    {
                        if (!progress.UpdateProgress(STR_ASSIGNCITY, STR_ASSIGNCITY, max, index))
                        {
                            break;
                        }
                    }
                }
            }
        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:26,代码来源:AssignCity.cs


示例2: ImportMethod

        protected override void ImportMethod()
        {
            try
            {
                using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTINGCACHES, STR_IMPORTINGCACHES, _gcList.Count, 0, true))
                {
                    int gcupdatecount = 1;
                    int max = _gcList.Count;
                    while (_gcList.Count > 0)
                    {
                        List<string> lcs = _gcList.Take(gcupdatecount).ToList();
                        _gcList.RemoveRange(0, lcs.Count);
                        List<OKAPIService.Geocache> caches = OKAPIService.GetGeocaches(SiteManager.Instance.ActiveSite, lcs);
                        Import.AddGeocaches(Core, caches);

                        if (!progress.UpdateProgress(STR_IMPORTINGCACHES, STR_IMPORTINGCACHES, max, max - _gcList.Count))
                        {
                            break;
                        }
                    }

                }
            }
            catch (Exception e)
            {
                _errormessage = e.Message;
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:28,代码来源:ImportByGCCodes.cs


示例3: ImportMethod

 protected override void ImportMethod()
 {
     using (Utils.ProgressBlock fixpr = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGDATA, _filenames.Length, 0))
     {
         for (int fileindex = 0; fileindex < _filenames.Length; fileindex++)
         {
             List<Framework.Data.Geocache> res = ProcessWaymarkComGPXFile(_filenames[fileindex]);
             if (res != null && res.Count > 0)
             {
                 using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGGEOCACHES, res.Count, 0))
                 {
                     int index = 0;
                     int procStep = 0;
                     foreach (Framework.Data.Geocache gc in res)
                     {
                         AddGeocache(gc, Framework.Data.Geocache.V1);
                         index++;
                         procStep++;
                         if (procStep >= 100)
                         {
                             progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGGEOCACHES, res.Count, index);
                             procStep = 0;
                         }
                     }
                 }
             }
             fixpr.UpdateProgress(STR_IMPORTING, STR_IMPORTINGDATA, _filenames.Length, fileindex + 1);
         }
     }
 }
开发者ID:RH-Code,项目名称:GAPP,代码行数:30,代码来源:GpxImport.cs


示例4: ExecuteAsync

        public override async Task ExecuteAsync(object parameter)
        {
            Core.ApplicationData.Instance.BeginActiviy();
            Core.Storage.Database db = Core.ApplicationData.Instance.ActiveDatabase;
            if (db != null)
            {
                using (Utils.DataUpdater upd = new Utils.DataUpdater(db))
                {
                    await Task.Run(() =>
                    {
                        Utils.ProgressBlock prog = null;
                        int max = Core.ApplicationData.Instance.MainWindow.GeocacheSelectionCount;
                        DateTime nextUpdate = DateTime.Now.AddSeconds(1);
                        if (_showProgress)
                        {
                            prog = new Utils.ProgressBlock("PerfomingAction", "PerfomingAction", max, 0, true);
                        }
                        try
                        {
                            int index = 0;
                            foreach (Core.Data.Geocache gc in db.GeocacheCollection)
                            {
                                if (gc.Selected)
                                {
                                    _geocacheAction(gc);

                                    if (prog != null)
                                    {
                                        index++;
                                        if (DateTime.Now >= nextUpdate)
                                        {
                                            if (!prog.Update("PerfomingAction", max, index))
                                            {
                                                break;
                                            }
                                            nextUpdate = DateTime.Now.AddSeconds(1);
                                        }
                                    }
                                }
                            }
                            if (prog != null)
                            {
                                prog.Dispose();
                                prog = null;
                            }
                        }
                        catch(Exception e)
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, e);
                            if (prog!=null)
                            {
                                prog.Dispose();
                                prog = null;
                            }
                        }
                    });
                }
            };
            Core.ApplicationData.Instance.EndActiviy();
        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:60,代码来源:ForSelectedGeocachesCommand.cs


示例5: searchInDescriptionThreadMethod

 private void searchInDescriptionThreadMethod()
 {
     using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_ACTIONTITLE, STR_ACTIONTEXT, _gcSearchList.Count, 0, true))
     {
         try
         {
             int block = 0;
             int index = 0;
             foreach (Framework.Data.Geocache wp in _gcSearchList)
             {
                 wp.Selected = (wp.ShortDescription.IndexOf(_txt, _scType) >= 0 || wp.LongDescription.IndexOf(_txt, _scType) >= 0);
                 block++;
                 index++;
                 if (block > 1000)
                 {
                     block = 0;
                     if (!progress.UpdateProgress(STR_ACTIONTITLE, STR_ACTIONTEXT, _gcSearchList.Count, index))
                     {
                         break;
                     }
                 }
             }
         }
         catch
         {
         }
         //signal finished
     }
     _actionReady.Set();
 }
开发者ID:RH-Code,项目名称:GAPP,代码行数:30,代码来源:GeocacheTextSearch.cs


示例6: ImportMethod

        protected override void ImportMethod()
        {
            using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORT, STR_DOWNLOAD, 1, 0))
            {
                using (System.IO.TemporaryFile tmp = new System.IO.TemporaryFile(true))
                using (System.Net.WebClient wc = new System.Net.WebClient())
                {
                    wc.DownloadFile("http://www.globalcaching.eu/service/cachedistance.aspx?country=Netherlands&prefix=GC", tmp.Path);

                    using (var fs = System.IO.File.OpenRead(tmp.Path))
                    using (ZipInputStream s = new ZipInputStream(fs))
                    {
                        ZipEntry theEntry = s.GetNextEntry();
                        byte[] data = new byte[1024];
                        if (theEntry != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            while (true)
                            {
                                int size = s.Read(data, 0, data.Length);
                                if (size > 0)
                                {
                                    if (sb.Length == 0 && data[0] == 0xEF && size > 2)
                                    {
                                        sb.Append(System.Text.ASCIIEncoding.UTF8.GetString(data, 3, size - 3));
                                    }
                                    else
                                    {
                                        sb.Append(System.Text.ASCIIEncoding.UTF8.GetString(data, 0, size));
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }

                            XmlDocument doc = new XmlDocument();
                            doc.LoadXml(sb.ToString());
                            XmlElement root = doc.DocumentElement;
                            XmlNodeList nl = root.SelectNodes("wp");
                            if (nl != null)
                            {
                                Core.Geocaches.AddCustomAttribute(CUSTOM_ATTRIBUTE);
                                foreach (XmlNode n in nl)
                                {
                                    var gc = Utils.DataAccess.GetGeocache(Core.Geocaches, n.Attributes["code"].InnerText);
                                    if (gc != null)
                                    {
                                        string dist = Utils.Conversion.StringToDouble(n.Attributes["dist"].InnerText).ToString("000.0");
                                        gc.SetCustomAttribute(CUSTOM_ATTRIBUTE, dist);
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:60,代码来源:GeocacheDistance.cs


示例7: ImportMethod

        protected override void ImportMethod()
        {
            //for now, we just use the active site
            //howver, in the future it is better to automatically switcg according geocode prefix
            //at this moment, the user is responsible for selecting the geocaches and the active site
            try
            {
                //first get a list of geocache codes
                using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_UPDATINGGEOCACHES, STR_UPDATINGGEOCACHES, _gcList.Count, 0, true))
                {
                    int gcupdatecount = 1;
                    int max = _gcList.Count;
                    while (_gcList.Count > 0)
                    {
                        List<string> lcs = (from Framework.Data.Geocache g in _gcList select g.Code).Take(gcupdatecount).ToList();
                        _gcList.RemoveRange(0, lcs.Count);
                        List<OKAPIService.Geocache> caches = OKAPIService.GetGeocaches(SiteManager.Instance.ActiveSite, lcs);
                        Import.AddGeocaches(Core, caches);

                        if (!progress.UpdateProgress(STR_UPDATINGGEOCACHES, STR_UPDATINGGEOCACHES, max, max - _gcList.Count))
                        {
                            break;
                        }
                    }

                }
            }
            catch (Exception e)
            {
                _errormessage = e.Message;
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:32,代码来源:Updater.cs


示例8: ImportMethod

        protected override void ImportMethod()
        {
            using (Utils.ProgressBlock blockprogress = new Utils.ProgressBlock(this, STR_IMPORTINGCACHES, STR_IMPORTINGCACHES, 1, 0))
            {
                try
                {
                    //first get a list of geocache codes
                    List<string> gcList = OKAPIService.GetGeocachesWithinRadius(SiteManager.Instance.ActiveSite, _centerLoc, _radiusKm, _filter);
                    using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTINGCACHES, STR_IMPORTINGCACHES, gcList.Count, 0, true))
                    {
                        int gcupdatecount = 1;
                        int max = gcList.Count;
                        while (gcList.Count > 0)
                        {
                            List<string> lcs = gcList.Take(gcupdatecount).ToList();
                            gcList.RemoveRange(0, lcs.Count);
                            List<OKAPIService.Geocache> caches = OKAPIService.GetGeocaches(SiteManager.Instance.ActiveSite, lcs);
                            Import.AddGeocaches(Core, caches);

                            if (!progress.UpdateProgress(STR_IMPORTINGCACHES, STR_IMPORTINGCACHES, max, max - gcList.Count))
                            {
                                break;
                            }
                        }

                    }
                }
                catch (Exception e)
                {
                    _errormessage = e.Message;
                }
            }
        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:33,代码来源:ImportByRadius.cs


示例9: ImportMethod

        protected override void ImportMethod()
        {
            int max = _gcList.Count;
            int gcupdatecount = 50;
            int index = 0;
            TimeSpan interval = new TimeSpan(0, 0, 0, 2, 100);
            DateTime prevCall = DateTime.MinValue;
            bool dodelay = (_gcList.Count > 30);
            using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTING, max, 0, true))
            {
                try
                {
                    using (Utils.API.GeocachingLiveV6 client = new Utils.API.GeocachingLiveV6(Core, string.IsNullOrEmpty(Core.GeocachingComAccount.APIToken)))
                    {
                        while (_gcList.Count > 0)
                        {
                            if (dodelay)
                            {
                                TimeSpan ts = DateTime.Now - prevCall;
                                if (ts < interval)
                                {
                                    Thread.Sleep(interval - ts);
                                }
                            }

                            Utils.API.LiveV6.SearchForGeocachesRequest req = new Utils.API.LiveV6.SearchForGeocachesRequest();
                            req.IsLite = Core.GeocachingComAccount.MemberTypeId == 1;
                            req.AccessToken = client.Token;
                            req.CacheCode = new Utils.API.LiveV6.CacheCodeFilter();
                            req.CacheCode.CacheCodes = _gcList.Take(gcupdatecount).ToArray();
                            req.MaxPerPage = gcupdatecount;
                            req.GeocacheLogCount = 5;
                            index += req.CacheCode.CacheCodes.Length;
                            _gcList.RemoveRange(0, req.CacheCode.CacheCodes.Length);
                            prevCall = DateTime.Now;
                            var resp = client.Client.SearchForGeocaches(req);
                            if (resp.Status.StatusCode == 0 && resp.Geocaches != null)
                            {
                                Utils.API.Import.AddGeocaches(Core, resp.Geocaches);
                            }
                            else
                            {
                                _errormessage = resp.Status.StatusMessage;
                                break;
                            }
                            if (!progress.UpdateProgress(STR_IMPORTING, STR_IMPORTING, max, index))
                            {
                                break;
                            }
                        }
                    }
                }
                catch(Exception e)
                {
                    _errormessage = e.Message;
                }
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:58,代码来源:Import.cs


示例10: AddOwnTrackables

        public void AddOwnTrackables(TrackableGroup grp)
        {
            bool canceled = false;
            using (Utils.ProgressBlock progr = new Utils.ProgressBlock("GetTrackableData", "GetTrackableData", 1, 0, true))
            using (var api = new LiveAPI.GeocachingLiveV6())
            {
                List<string> trkCodes = new List<string>();

                var req = new LiveAPI.LiveV6.GetTrackablesByOwnerRequest();
                req.AccessToken = api.Token;
                req.TrackableLogsCount = 0;
                req.StartIndex = 0;
                req.MaxPerPage = Core.Settings.Default.LiveAPIGetOwnedTrackablesBatchSize;
                int total = 0;
                while (true)
                {
                    var resp = api.Client.GetOwnedTrackables(req);
                    if (resp.Status.StatusCode == 0)
                    {
                        if (resp.Trackables != null)
                        {
                            foreach (var t in resp.Trackables)
                            {
                                trkCodes.Add(t.Code);
                                Core.Settings.Default.AddUpdateTrackable(grp, GetTrackableItemFromLiveAPI(t));
                                total++;
                            }
                            if (!progr.Update("GetTrackableData", total, 2 * total))
                            {
                                canceled = true;
                                break;
                            }
                        }
                        if (resp.Trackables.Count() < req.MaxPerPage)
                        {
                            break;
                        }
                        else
                        {
                            req.StartIndex = total;
                            System.Threading.Thread.Sleep(Core.Settings.Default.LiveAPIDelayGetOwnedTrackables);
                        }
                    }
                    else
                    {
                        Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Error, resp.Status.StatusMessage);
                        break;
                    }
                }

                if (!canceled)
                {
                    progr.Update("GetTrackableData", total, total);
                    AddUpdateTrackables(grp, trkCodes);
                }
            }
        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:57,代码来源:Import.cs


示例11: assignRegionsThreadMethod

 private void assignRegionsThreadMethod()
 {
     try
     {
         using (Utils.ProgressBlock prog = new Utils.ProgressBlock(_plugin, STR_ASSIGNINGREGION, STR_ASSIGNINGREGION, _gcList.Count, 0, true))
         {
             List<Framework.Data.AreaInfo> areasFilter = Utils.GeometrySupport.Instance.GetAreasByLevel(_level);
             if (areasFilter != null && areasFilter.Count > 0)
             {
                 int index = 0;
                 foreach (var gc in _gcList)
                 {
                     List<Framework.Data.AreaInfo> areas = Utils.GeometrySupport.Instance.GetAreasOfLocation(new Framework.Data.Location(gc.Lat, gc.Lon), areasFilter);
                     if (areas != null && areas.Count > 0)
                     {
                         Framework.Data.AreaInfo ai = areas[0];
                         if (_prefix.Length > 0)
                         {
                             ai = (from g in areas where g.Name.StartsWith(_prefix) select g).FirstOrDefault();
                         }
                         if (ai != null)
                         {
                             switch (_level)
                             {
                                 case Framework.Data.AreaType.Country:
                                     gc.Country = ai.Name;
                                     break;
                                 case Framework.Data.AreaType.State:
                                     gc.State = ai.Name;
                                     break;
                                 case Framework.Data.AreaType.Municipality:
                                     gc.Municipality = ai.Name;
                                     break;
                                 case Framework.Data.AreaType.City:
                                     gc.City = ai.Name;
                                     break;
                             }
                         }
                     }
                     index++;
                     if (index % 50 == 0)
                     {
                         if (!prog.UpdateProgress(STR_ASSIGNINGREGION, STR_ASSIGNINGREGION, _gcList.Count, index))
                         {
                             break;
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
     _actionReady.Set();
 }
开发者ID:RH-Code,项目名称:GAPP,代码行数:56,代码来源:AssignRegionForm.cs


示例12: DeleteImagesFromFolder

        public async Task DeleteImagesFromFolder(List<Core.Data.Geocache> gcList, string folder)
        {
            await Task.Run(() =>
            {
                try
                {
                    DateTime nextUpdate = DateTime.Now.AddSeconds(1);
                    using (Utils.ProgressBlock progress = new Utils.ProgressBlock("DeletingImages", "DeletingImages", gcList.Count, 0, true))
                    {
                        string imgFolder;
                        string checkFolder = Path.Combine(folder, "GeocachePhotos");
                        if (Directory.Exists(checkFolder))
                        {
                            imgFolder = checkFolder;
                        }
                        else
                        {
                            imgFolder = folder;
                        }

                        int index = 0;
                        foreach (var gc in gcList)
                        {
                            string cacheFolder = Path.Combine(imgFolder, gc.Code[gc.Code.Length - 1].ToString());
                            if (Directory.Exists(cacheFolder))
                            {
                                cacheFolder = Path.Combine(cacheFolder, gc.Code[gc.Code.Length - 2].ToString());
                                if (Directory.Exists(cacheFolder))
                                {
                                    cacheFolder = Path.Combine(cacheFolder, gc.Code);
                                    if (Directory.Exists(cacheFolder))
                                    {
                                        Directory.Delete(cacheFolder, true);
                                    }
                                }
                            }


                            index++;
                            if (DateTime.Now >= nextUpdate)
                            {
                                if (!progress.Update("DeletingImages", gcList.Count, index))
                                {
                                    break;
                                }
                                nextUpdate = DateTime.Now.AddSeconds(1);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Core.ApplicationData.Instance.Logger.AddLog(this, e);
                }
            });
        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:56,代码来源:Export.cs


示例13: LogGeocachesAsync

        public async Task<List<LogInfo>> LogGeocachesAsync(List<LogInfo> logInfos)
        {
            List<LogInfo> result = new List<LogInfo>();
            Utils.DataUpdater upd = null;
            if (Core.ApplicationData.Instance.ActiveDatabase != null)
            {
                upd = new Utils.DataUpdater(Core.ApplicationData.Instance.ActiveDatabase);
            }
            using (Utils.ProgressBlock prog = new Utils.ProgressBlock("LogGeocache", "Logging", logInfos.Count, 0, true))
            {
                using (var api = new LiveAPI.GeocachingLiveV6())
                {
                    foreach (LogInfo li in logInfos)
                    {
                        int index = 0;
                        List<LiveAPI.LiveV6.Trackable> dropTbs = null;
                        List<string> retrieveTbs = null;

                        //todo: check if trackable dialog is needed
                        //fetch in background

                        bool ok = false;
                        await Task.Run(() =>
                        {
                            if (index > 0 && dropTbs == null && retrieveTbs == null)
                            {
                                System.Threading.Thread.Sleep(Core.Settings.Default.LiveAPIDelayCreateFieldNoteAndPublish);
                            }
                            ok = LogGeocache(api, li, dropTbs, retrieveTbs);
                        });
                        if (ok)
                        {
                            result.Add(li);
                            index++;
                            if (!prog.Update("Logging", logInfos.Count, index))
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            if (upd!=null)
            {
                upd.Dispose();
                upd = null;
            }
            return result;
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:53,代码来源:Logger.cs


示例14: Action

        public override bool Action(string action)
        {
            bool result = base.Action(action);
            if (result && action == ACTION_SHOW)
            {
                try
                {
                    var logs = new List<Utils.API.LiveV6.GeocacheLog>();

                    using (var api = new Utils.API.GeocachingLiveV6(Core))
                    {
                        using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, "Importing logs", "Importing logs...", 100, 0, true))
                        {
                            var req = new Utils.API.LiveV6.GetUsersGeocacheLogsRequest();
                            req.AccessToken = api.Token;
                            req.Username = "SKAMS";
                            req.ExcludeArchived = true;
                            req.MaxPerPage = 100;
                            req.StartIndex = 0;
                            req.LogTypes = (from a in Core.LogTypes where a.AsFound select (long)a.ID).ToArray();
                            var resp = api.Client.GetUsersGeocacheLogs(req);
                            while (resp.Status.StatusCode == 0)
                            {
                                logs.AddRange(resp.Logs);

                                if (resp.Logs.Count() >= req.MaxPerPage)
                                {
                                    req.StartIndex = logs.Count;
                                    if (!progress.UpdateProgress("Importing logs", "Importing logs...", logs.Count + req.MaxPerPage, logs.Count))
                                    {
                                        break;
                                    }
                                    resp = api.Client.GetUsersGeocacheLogs(req);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            if (resp.Status.StatusCode != 0)
                            {
                                //_errormessage = resp.Status.StatusMessage;
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            return result;
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:52,代码来源:GetOtherUserLogs.cs


示例15: DownloadAllLogImages

        public void DownloadAllLogImages()
        {
            try
            {
                _logImagesToGrab = (from Framework.Data.LogImage li in Core.LogImages select li).ToList();

                using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_GRABBING_IMAGES, STR_GRABBING_IMAGES, _logImagesToGrab.Count, 0, true))
                {
                    int cnt = _logImagesToGrab.Count;
                    int orgListCount = cnt;
                    Thread[] thrd = new Thread[6];
                    for (int i = 0; i < thrd.Length; i++)
                    {
                        thrd[i] = new Thread(new ThreadStart(this.getImagesThreadMethod));
                        thrd[i].Start();
                    }
                    while (cnt > 0)
                    {
                        Thread.Sleep(500);
                        System.Windows.Forms.Application.DoEvents();
                        lock (_logImagesToGrab)
                        {
                            cnt = _logImagesToGrab.Count;
                        }
                        if (!progress.UpdateProgress(STR_GRABBING_IMAGES, STR_GRABBING_IMAGES, orgListCount, orgListCount - cnt))
                        {
                            lock (_logImagesToGrab)
                            {
                                _logImagesToGrab.Clear();
                                cnt = 0;
                            }
                        }
                    }
                    for (int i = 0; i < thrd.Length; i++)
                    {
                        thrd[i].Join();
                    }
                }

            }
            catch
            {
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:44,代码来源:Viewer.cs


示例16: GetLogsOfUser

 public List<LiveAPI.LiveV6.GeocacheLog> GetLogsOfUser(string userName, List<Core.Data.LogType> logTypes)
 {
     List<LiveAPI.LiveV6.GeocacheLog> result = new List<LiveAPI.LiveV6.GeocacheLog>();
     using (var api = new LiveAPI.GeocachingLiveV6())
     {
         using (Utils.ProgressBlock progress = new Utils.ProgressBlock("ImportingLogs", "ImportingLogs", 100, 0, true))
         {
             var req = new LiveAPI.LiveV6.GetUsersGeocacheLogsRequest();
             req.AccessToken = api.Token;
             req.ExcludeArchived = false;
             req.MaxPerPage = Core.Settings.Default.LiveAPIGetUsersGeocacheLogsBatchSize;
             req.StartIndex = 0;
             req.LogTypes = (from a in logTypes select (long)a.ID).ToArray();
             var resp = api.Client.GetUsersGeocacheLogs(req);
             while (resp.Status.StatusCode == 0)
             {
                 //logs.AddRange(resp.Logs);
                 //if (resp.Logs.Count() >= req.MaxPerPage)
                 if (resp.Logs.Count() > 0)
                 {
                     result.AddRange(resp.Logs);
                     req.StartIndex = result.Count;
                     if (!progress.Update("ImportingLogs", result.Count + req.MaxPerPage, result.Count))
                     {
                         _cancelled = true;
                         break;
                     }
                     System.Threading.Thread.Sleep(Core.Settings.Default.LiveAPIDelayGetUsersGeocacheLogs);
                     resp = api.Client.GetUsersGeocacheLogs(req);
                 }
                 else
                 {
                     break;
                 }
             }
             if (resp.Status.StatusCode != 0)
             {
                 Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Error, resp.Status.StatusMessage);
                 _cancelled = true;
             }
         }
     }
     return result;
 }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:44,代码来源:ImportLiveAPI.cs


示例17: ImporGCVotes

        public void ImporGCVotes(List<Core.Data.Geocache> gcList)
        {
            try
            {
                int max = gcList.Count;
                int pos = 0;
                int batch;
                StringBuilder wpList = new StringBuilder();
                string usrName = null;

                var ai = Core.ApplicationData.Instance.AccountInfos.GetAccountInfo("GC");
                if (ai != null)
                {
                    usrName = ai.AccountName;
                }
                if (string.IsNullOrEmpty(usrName))
                {
                    usrName = "uglyDUMMYusernamesolution";
                }
                using (Utils.ProgressBlock prog = new Utils.ProgressBlock("ImportingGCVotes", "ImportingGCVotes", max, pos, true))
                {
                    while (gcList.Count > 0)
                    {
                        wpList.Length = 0;
                        batch = 0;
                        while (batch < 200 && gcList.Count > 0)
                        {
                            if (batch > 0)
                            {
                                wpList.Append(",");
                            }
                            wpList.Append(gcList[0].Code);
                            gcList.RemoveAt(0);
                            pos++;
                            batch++;
                        }
                        string postData = String.Format("version=3.1b&userName={0}&waypoints={1}&password={2}", HttpUtility.UrlEncode(usrName), wpList.ToString(), ""); //"" => password: todo
                        System.Net.WebRequest webRequest = System.Net.WebRequest.Create("http://gcvote.com/getVotes.php") as System.Net.HttpWebRequest;
                        webRequest.Method = "POST";
                        webRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";

                        string doc;
                        using (System.IO.StreamWriter requestWriter = new System.IO.StreamWriter(webRequest.GetRequestStream()))
                        {
                            requestWriter.Write(postData);
                        }
                        using (System.IO.StreamReader responseReader = new System.IO.StreamReader(webRequest.GetResponse().GetResponseStream()))
                        {
                            // and read the response
                            doc = responseReader.ReadToEnd();
                        }
                        /*
                            <votes userName='...' currentVersion='2.0c' securityState='locked' loggedIn='true'>
                            <vote userName='...' cacheId='26984595-b3a1-4aa2-9638-7612a3bf3d5f' voteMedian='4' voteAvg='3.75' voteCnt='4' voteUser='0' waypoint='GC12RBN' vote1='0' vote2='1' vote3='0' vote4='2' vote5='1' rawVotes='(2.0:1)(4.0:2)(5.0:1)'/>
                            <vote userName='...' cacheId='55d02838-01f6-4181-a080-517a3339ad40' voteMedian='4.5' voteAvg='4.0555555555556' voteCnt='9' voteUser='0' waypoint='GC12YQJ' vote1='1' vote2='0' vote3='1' vote4='3' vote5='4' rawVotes='(1.0:1)(3.0:1)(4.0:2)(4.5:1)(5.0:4)'/>
                            <vote userName='...' cacheId='562829a6-a111-4ccb-a511-76370b8005d2' voteMedian='3' voteAvg='2.7777777777778' voteCnt='9' voteUser='0' waypoint='GC135AX' vote1='1' vote2='1' vote3='7' vote4='0' vote5='0' rawVotes='(1.0:1)(2.5:1)(3.0:6)(3.5:1)'/>

                            <errorstring></errorstring>
                            </votes>
                         */
                        if (doc != null)
                        {
                                StringBuilder sb = new StringBuilder();
                                sb.AppendLine("<?xml version=\"1.0\"?>");
                                sb.Append(doc);

                                XmlDocument xmlDoc = new XmlDocument();
                                xmlDoc.LoadXml(sb.ToString());
                                XmlElement root = xmlDoc.DocumentElement;

                                XmlNodeList wpt = root.SelectNodes("vote");
                                if (wpt != null)
                                {
                                    foreach (XmlNode n in wpt)
                                    {
                                        double avg = Utils.Conversion.StringToDouble(n.Attributes["voteAvg"].Value);
                                        double median = Utils.Conversion.StringToDouble(n.Attributes["voteMedian"].Value);
                                        double? usrVote = Utils.Conversion.StringToDouble(n.Attributes["voteUser"].Value);
                                        int cnt = int.Parse(n.Attributes["voteCnt"].Value);
                                        string wp = n.Attributes["waypoint"].Value;
                                        if (usrVote <= 0.1)
                                        {
                                            usrVote = null;
                                        }

                                        Core.Settings.Default.SetGCVote(wp, median, avg, cnt, usrVote);
                                    }
                                }
                        }
                        else
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Error, "UnableToGetTheDataFromGCVoteCom");
                            break;
                        }
                        if (!prog.Update("ImportingGCVotes", max, pos))
                        {
                            break;
                        }
                        if (gcList.Count > 0)
                        {
//.........这里部分代码省略.........
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:101,代码来源:Import.cs


示例18: ExportMethod

        protected override void ExportMethod()
        {
            try
            {
                using (Utils.ProgressBlock fixscr = new Utils.ProgressBlock(this, STR_EXPORTINGGPX, STR_CREATINGFILE, 1, 0))
                {
                    System.Collections.Hashtable logTypes = new System.Collections.Hashtable();
                    logTypes.Add(2, "Found it");
                    logTypes.Add(3, "Didn't find it");
                    logTypes.Add(4, "Write note");
                    logTypes.Add(5, "Archive");
                    logTypes.Add(7, "Needs Archived");
                    logTypes.Add(9, "Will Attend");
                    logTypes.Add(10, "Attended");
                    logTypes.Add(11, "Webcam Photo Taken");
                    logTypes.Add(12, "Unarchive");
                    logTypes.Add(22, "Temporarily Disable Listing");
                    logTypes.Add(23, "Enable Listing");
                    logTypes.Add(24, "Publish Listing");
                    logTypes.Add(25, "Retract Listing");
                    logTypes.Add(45, "Needs Maintenance");
                    logTypes.Add(46, "Owner Maintenance");
                    logTypes.Add(47, "Update Coordinates");
                    logTypes.Add(68, "Post Reviewer Note");
                    logTypes.Add(74, "Announcement");

                    if (System.IO.File.Exists(_filename))
 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VBAParser类代码示例发布时间:2022-05-24
下一篇:
C# Utils类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap