WPF物料替换源码参考(返回多个数据表)

using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace Midea.MES.Plugin.OnlineRepair.ViewModel
{
    class material_sn_replaceVM : ViewModelPlugin
    {
        public material_sn_replaceVM()
        {
            this.MATERIAL_SN_HEAD = new VM_SFC_DC_MATERIAL_SN_HEAD();
            this.MATERIAL_SN_BODY = new ObservableCollection<VM_SFC_DC_MATERIAL_SN_BODY>();              
            this.MATERIAL_SN_RECORD = new ObservableCollection<VM_SFC_DC_MATERIAL_SN_RECORD>();
            this.MATERIAL_SN_INFO = new MATERIAL_SN_INFO();          //所有信息

            //QueryCommand = new RelayCommand(QueryEvent);
            SaveCommand = new RelayCommand<bool>(SaveEvent);
            //SaveCommand = new RelayCommand(SaveEvent);
        }

        #region 全局变量

        //是否检查物料条码规则
        private string g_p_check_material_sn = "Y";
        //定义当前的操作哪一步 
        //* 0 扫入成品SN 
        //* 1 扫入旧物料 
        //* 2 扫入新物料
        private int g_curroper = 0;

        #endregion

        #region 命令事件-方法
        public RelayCommand QueryCommand { set; get; }
        public RelayCommand<bool> SaveCommand { set; get; }
        //public RelayCommand SaveCommand { set; get; }
        
        //子过程,获取成品SN信息
        private bool GETDATA(string Bardcode) 
        {
            bool retval=false;
            var contract = new MessageContract();
            contract.InvokeMethod = "MATERIAL_SN_HEAD_GETDATA";
            contract.MessageToken = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            contract.Context["p_inv_org_id"] = this.Framework.FrameworkContext[Midea.MES.Platform.Common.FrameworkSymbol.SYS_INFO_KEY_INV_ORG_ID];
            contract.Context["p_sn"] = this.temp_CurrentBardcode;  //"D110001103415626831501";                   ;
            var msgContract = this.Framework.DataService.DoRequest(contract);
            if (msgContract.IsSucess)
            {
                //MATERIAL_SN_INFO = msgContract.GetMessageDataModel<MATERIAL_SN_INFO>();
                MATERIAL_SN_INFO = msgContract.GetMessageDataModelClass<MATERIAL_SN_INFO>();
                if (MATERIAL_SN_INFO != null)
                {
                    //基础信息 
                    this.MATERIAL_SN_HEAD = MATERIAL_SN_INFO.MATERIAL_SN_HEAD;

                    //物料明细信息
                    if (MATERIAL_SN_INFO.MATERIAL_SN_BODY != null)
                    {
                        foreach (var BODY in MATERIAL_SN_INFO.MATERIAL_SN_BODY)
                        {
                            this.MATERIAL_SN_BODY.Add(BODY);
                        }
                    }
                    //物料替换记录
                    if (MATERIAL_SN_INFO.MATERIAL_SN_RECORD != null)
                    {
                        foreach (var RECORD in MATERIAL_SN_INFO.MATERIAL_SN_RECORD)
                        {
                            this.MATERIAL_SN_RECORD.Add(RECORD);
                        }
                    }  
                }

                retval = true;                      
                
             }
            else
            {
                MessageInvoker.ShowError(string.Format("{0}", msgContract.ErrorMessage));
            }

            return retval;
        }

        //设置当前行
        private void SET_CURR_MATERIAL_SN_BODY(string Bardcode) 
        {
            CURR_MATERIAL_SN_BODY = MATERIAL_SN_BODY.FirstOrDefault(p => p.material_sn == Bardcode);
            if (CURR_MATERIAL_SN_BODY != null)
            {
                CURR_MATERIAL_SN_BODY.IsModelSelected = true;
                MessageInvoker.ShowSuccess(string.Format("被替换物料【{0}】匹配成功,请扫描替换后的新物料编码!匹配旧物料【{0}】成功!", Bardcode));
                this.g_curroper = 2;
            }
            else
            {
                MessageInvoker.ShowError(string.Format("扫描物料SN“{0}”与此次替换的成品SN对应的成品SN“{1}”不一致,不允许替换!", Bardcode, this.MATERIAL_SN_HEAD.sn));
                return;
            }
        }

        //条码回车事件
        //* 0 获取成品SN 信息
        //* 1 定位旧物料信息
        //* 2 替换保存物料信息
        private void QueryEvent(string Bardcode) 
        {
            try
            {
                
                if (string.IsNullOrWhiteSpace(Bardcode)) 
                {
                    MessageInvoker.ShowNormal("提示:请输入条码!");
                    return;
                }

                if (g_curroper == 0)          //获取成品SN信息
                {
                    if (GETDATA(Bardcode))
                    {
                        if (this.MATERIAL_SN_HEAD != null)
                        { 
                            MessageInvoker.ShowSuccess(string.Format("加载成品条码【{0}】资料成功!请扫入需要替换的物料条码!", Bardcode));
                            this.g_curroper = 1;
                        }
                    }
                    else
                    {
                        //MessageInvoker.ShowError(string.Format("加载资料出现错误,请重新扫入成品条码进行加载!"));
                        return;
                    }
                    
                }
                else if (g_curroper == 1)      //定位当前旧物料
                {
                    if (this.MATERIAL_SN_BODY != null)
                    {
                        SET_CURR_MATERIAL_SN_BODY(Bardcode);
                        
                    }
                }
                else if (g_curroper == 2)      //扫入新物料 新增一条记录(仅显示)
                {                                   

                    SaveEvent(false);          //扫描提交
                    
                }
                
            }
            catch (Exception ex)
            {
                MessageInvoker.ShowError(ex.Message + Environment.NewLine + ex.StackTrace);
            }
 
        }

        //替换日记增加一条记录
        private void AddRecord(string oldmaterial_sn)
        {

            try
            {
                VM_SFC_DC_MATERIAL_SN_RECORD record = new VM_SFC_DC_MATERIAL_SN_RECORD();
                record.seq = this.MATERIAL_SN_RECORD.Count + 1;
                record.datetime_preview = CURR_MATERIAL_SN_BODY.datetime_modified;
                record.datetime_created = DateTime.Now;
                record.old_material_sn = oldmaterial_sn;
                record.new_material_sn = temp_CurrentBardcode;
                record.mitem_code = CURR_MATERIAL_SN_BODY.mitem_code;
                this.MATERIAL_SN_RECORD.Add(record);                  
            }
            catch
            {
                MessageInvoker.ShowNormal(string.Format("添加替换记录失败!"));
            }

            
        }
        /// <summary>
        /// 保存事件
        /// false - 扫描提交(增加记录)
        /// true  - 按钮提交
        /// </summary>
        /// <param name="Mode"></param>
        private void SaveEvent(bool Mode)
        {
            try
            {
                if (this.MATERIAL_SN_BODY.Count == 0 || this.MATERIAL_SN_BODY == null 
                                                     || (this.g_curroper == 1 && Mode == false))
                {
                    MessageInvoker.ShowNormal("没有需要保存的数据!");
                    return;
                }

                //检查扫描过程中,进行按钮提交
                if (Mode==true)
                {
                    if (g_curroper == 2)      //当前-待扫入替换的物料
                    {
                        MessageInvoker.ShowNormal("请扫入替换的物料后提交!");
                        return;
                    }

                    if (this.g_curroper == 1 && CURR_MATERIAL_SN_BODY==null) //当前-待扫入旧物料
                    {
                        MessageInvoker.ShowNormal("没有数据可以提交!");
                        return;
                    }
                }

                if (CURR_MATERIAL_SN_BODY == null) 
                {
                    MessageInvoker.ShowNormal("请先扫入待替换的物料!");
                    return;
                }

                string oldmaterial_sn = CURR_MATERIAL_SN_BODY.material_sn;
                foreach (var p in MATERIAL_SN_BODY)
                {                                 
                    if (p.material_sn == oldmaterial_sn)
                    {
                        p.material_sn = this.temp_CurrentBardcode;
                        p.IsUpdate = true;  //需更新行
                    }
                }

                //按钮提交
                string strcommit;
                if (Mode)
                {
                    strcommit = "Y";
                }
                else
                {
                    strcommit = this.aotocommit ? "Y" : "N"; 
                }
                
                var contract = new MessageContract();
                contract.InvokeMethod = "MATERIAL_SN_HEAD_SAVEDATA";
                contract.MessageToken = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                contract.Context["p_inv_org_id"] = this.Framework.FrameworkContext[Midea.MES.Platform.Common.FrameworkSymbol.SYS_INFO_KEY_INV_ORG_ID];
                contract.Context["p_commit"] = strcommit;
                contract.Context["p_sn"] = this.MATERIAL_SN_HEAD.sn;
                contract.Context["p_check_material_sn"] = this.g_p_check_material_sn;    //检查条码规则
                contract.Context["p_reason"] = this.reason;

                contract.Context["MATERIAL_SN_BODY"] = Newtonsoft.Json.JsonConvert.SerializeObject(this.MATERIAL_SN_BODY.Where(m => m.IsUpdate == true), 
                                                                                                   Newtonsoft.Json.Formatting.None);
                

                contract.Context["p_user_modified"] = this.Framework.FrameworkContext[FrameworkSymbol.SYS_INFO_KEY_USER_CODE];  //this.framework.FrameworkContext[Midea.MES.Platform.Common.FrameworkSymbol.SYS_INFO_KEY_USER_CODE]
                
                                            
                var msgContract = this.Framework.DataService.DoRequest(contract);
                if (msgContract.IsSucess)
                {

                    //按钮提交不重复增加记录
                    if (!Mode) 
                    {
                        AddRecord(oldmaterial_sn);
                    }

                    //自动提交数据 或 提交按钮提交数据
                    if (this.aotocommit || Mode==true)
                    {
                        ClearMonitor();
                        this.g_curroper = 0;
                        if (Mode)
                        {
                            MessageInvoker.ShowSuccess(string.Format("数据提交成功!"));
                        }
                        else
                        {
                            MessageInvoker.ShowSuccess(string.Format("操作成功!请扫入下一成品条码!"));
                        }
                        
                    }
                    else
                    {
                        this.g_curroper = 1;
                        MessageInvoker.ShowSuccess(string.Format("操作成功,请继续扫描下一个被替换的新物料编码!"));
                        this.aotocommit = false;
                    }       
                     
                }
                else
                {                               
                    MessageInvoker.ShowError(string.Format("{0}", msgContract.ErrorMessage));
                    //如果替换不成功,需要改回物料代码
                    foreach (var p in MATERIAL_SN_BODY)
                    {
                        if (p.material_sn == this.temp_CurrentBardcode)
                        {
                            p.material_sn = oldmaterial_sn;
                            p.IsUpdate = false;  //需更新行
                        }
                    }
                }

 
            }
            catch (Exception ex)
            {
                MessageInvoker.ShowError(ex.Message);
            }
        }

        /// <summary>
        /// 重置页面
        /// </summary>
        public ICommand CmdReset
        {
            get
            {
                return new RelayCommand(() =>
                {
                    try
                    {
                        if (MsgBoxHelper.ShowQuestion(string.Format("即将重置页面!{0}确定要放弃正在操作的数据吗?", Environment.NewLine), System.Windows.MessageBoxButton.OKCancel) == System.Windows.MessageBoxResult.OK)
                        {
                            ClearMonitor();
                            g_curroper = 0;
                            MessageInvoker.ShowNormal("页面被重置!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageInvoker.ShowError(ex.Message);
                    }
                }, () =>
                {
                    return true;
                });
            }
        }

        /// <summary>
        /// 清空所有
        /// </summary>
        public void ClearMonitor()
        {
            try
            {
                this.MATERIAL_SN_HEAD = null;
                this.MATERIAL_SN_BODY.Clear();            
                this.MATERIAL_SN_RECORD.Clear();
                this.MATERIAL_SN_INFO = null;
                this.reason = "";
            }
            catch (Exception ex)
            {
                MessageInvoker.ShowError(ex.Message);
            }
        }

        #endregion       

 
        /// <summary>
        /// 所有信息
        /// </summary>
        private MATERIAL_SN_INFO _MATERIAL_SN_INFO;
        public MATERIAL_SN_INFO MATERIAL_SN_INFO
        {
            get { return _MATERIAL_SN_INFO; }
            set
            {
                if (_MATERIAL_SN_INFO != value)
                {
                    _MATERIAL_SN_INFO = value;
                    NotifyPropertyChanged("MATERIAL_SN_INFO");
                }
            }
        }

        /// <summary>
        /// 基础信息
        /// </summary>
        private VM_SFC_DC_MATERIAL_SN_HEAD _MATERIAL_SN_HEAD;
        public VM_SFC_DC_MATERIAL_SN_HEAD MATERIAL_SN_HEAD
        {
            get
            {
                return _MATERIAL_SN_HEAD;
            }
            set
            {
                if (_MATERIAL_SN_HEAD != value)
                {
                    _MATERIAL_SN_HEAD = value;
                    NotifyPropertyChanged("MATERIAL_SN_HEAD");
                }
            }
        }

        /// <summary>
        /// 当前选定的物料采集信息
        /// </summary>
        private VM_SFC_DC_MATERIAL_SN_BODY _CURR_MATERIAL_SN_BODY;
        public VM_SFC_DC_MATERIAL_SN_BODY CURR_MATERIAL_SN_BODY
        {
            get
            {
                return _CURR_MATERIAL_SN_BODY;
            }
            set
            {
                if (_CURR_MATERIAL_SN_BODY != value)
                {
                    _CURR_MATERIAL_SN_BODY = value;
                    NotifyPropertyChanged("CURR_MATERIAL_SN_BODY");
                }
            }
        }     
    
        /// <summary>
        /// 物料采集信息
        /// </summary>
        private ObservableCollection<VM_SFC_DC_MATERIAL_SN_BODY> _MATERIAL_SN_BODY;
        public ObservableCollection<VM_SFC_DC_MATERIAL_SN_BODY> MATERIAL_SN_BODY
        {
            get
            {
                return _MATERIAL_SN_BODY;
            }
            set
            {
                if (_MATERIAL_SN_BODY != value)
                {
                    _MATERIAL_SN_BODY = value;
                    NotifyPropertyChanged("MATERIAL_SN_BODY");
                }
            }
        }      
        /// <summary>
        /// 物料替换记录
        /// </summary>
        private ObservableCollection<VM_SFC_DC_MATERIAL_SN_RECORD> _MATERIAL_SN_RECORD;
        public ObservableCollection<VM_SFC_DC_MATERIAL_SN_RECORD> MATERIAL_SN_RECORD
        {
            get
            {
                return _MATERIAL_SN_RECORD;
            }
            set
            {
                if (_MATERIAL_SN_RECORD != value)
                {
                    _MATERIAL_SN_RECORD = value;
                    NotifyPropertyChanged("MATERIAL_SN_RECORD");
                }
            }
        }
        /// <summary>
        /// 是否自动提交
        /// </summary>
        private bool _aotocommit;            
        public bool aotocommit
        {
            get
            {
                return _aotocommit;
            }
            set
            {
                _aotocommit = value;
                NotifyPropertyChanged("aotocommit");
            }
        }

        //当前条码的中间变量
        private string temp_CurrentBardcode;
        /// <summary>
        /// 当前输入的成品条码
        /// </summary>
        private string _CurrentBardcode;
        public string CurrentBardcode
        {
            get
            {
                return _CurrentBardcode;
            }
            set
            {
                //_CurrentBardcode = value;
                //NotifyPropertyChanged("CurrentBardcode");
                temp_CurrentBardcode = value;
                QueryEvent(value);          
            }
        }

        /// <summary>
        /// 换料原因
        /// </summary>
        private string _reason;
        public string reason
        {
            get
            {
                return _reason;
            }
            set
            {
                _reason = value;
                NotifyPropertyChanged("reason");
            }
        }

    }
}

//========================================================================

using Midea.MES.Biz.Model;
using Midea.MES.Platform.Common;
using Midea.MES.Platform.Server.BizServiceProvider.DataAccess.Oracle;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Text;

namespace Midea.MES.Platform.Server.BizServiceProvider
{
    public partial class OnlineRepairDomain
    {
        //获取资料,返回多个数据集
        public MessageContract MATERIAL_SN_HEAD_GETDATA(MessageContract msg)
        {
            try
            {
                Params ps = new Params();
                ps.Add("p_inv_org_id", Convert.ToDecimal(msg.Context["p_inv_org_id"]));
                ps.Add("p_sn", msg.Context["p_sn"]);
                ps.Add("x_ret_code", ParamDirection.Output);
                ps.Add("x_ret_msg", ParamDirection.Output);
                ps.Add("x_ret_data_head", ParamDirection.Output);
                ps.Add("x_ret_data_body", ParamDirection.Output);
                ps.Add("x_ret_data_record", ParamDirection.Output);
                using (var context = new BizServiceContext())
                {
                    var ds = DBHelper.ExecProcDS(context.Database.Connection.ConnectionString, "sfc_dc_material_sn_query_pub.main", ps);
                    //var ds = DBHelper.ExecProcEntitys<ObservableCollection<MATERIAL_SN_INFO>>(context.Database.Connection.ConnectionString, "sfc_dc_material_sn_query_pub.main", ps);
                    if (string.Equals(ps["x_ret_code"].Value, "0"))
                    {    
                                                                         
                        MATERIAL_SN_INFO data = new MATERIAL_SN_INFO();

                        //基础资料
                        data.MATERIAL_SN_HEAD = ds.Tables[0].ToEntityList<VM_SFC_DC_MATERIAL_SN_HEAD>().FirstOrDefault();                         
                        

                        //物料采集明细
                        var body = ds.Tables[1].ToEntityList<VM_SFC_DC_MATERIAL_SN_BODY>().ToArray();
                        ObservableCollection<VM_SFC_DC_MATERIAL_SN_BODY> bodyCollection = new ObservableCollection<VM_SFC_DC_MATERIAL_SN_BODY>();
                        foreach (var item in body) 
                        {
                            bodyCollection.Add(item);                              
                        }
                        data.MATERIAL_SN_BODY = bodyCollection;  

                        //物料替换记录
                        var record = ds.Tables[2].ToEntityList<VM_SFC_DC_MATERIAL_SN_RECORD>().ToArray();
                        ObservableCollection<VM_SFC_DC_MATERIAL_SN_RECORD> recordCollection = new ObservableCollection<VM_SFC_DC_MATERIAL_SN_RECORD>();
                        foreach (var item in record)
                        {
                            recordCollection.Add(item);
                        }
                        data.MATERIAL_SN_RECORD = recordCollection;

                        msg.SetMessageDataModel<MATERIAL_SN_INFO>(data);
                        msg.IsSucess = true;
                    }
                    else
                    {
                        msg.ErrorCode = ps["x_ret_code"].Value;
                        msg.ErrorMessage = Convert.ToString(ps["x_ret_msg"].Value);
                        msg.IsSucess = false;
                    }
                }
            }
            catch (Exception ex)
            {
                msg.ErrorMessage = string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace);
                msg.IsSucess = false;
            }
            return msg;
        }

        //提交数据
        public MessageContract MATERIAL_SN_HEAD_SAVEDATA(MessageContract Msg)
        {
            try
            {
                ObservableCollection<VM_SFC_DC_MATERIAL_SN_BODY> body = Newtonsoft.Json.JsonConvert.DeserializeObject<ObservableCollection<VM_SFC_DC_MATERIAL_SN_BODY>>(Msg.Context["MATERIAL_SN_BODY"]);
                decimal InvOrgId = Convert.ToDecimal(Msg.Context["p_inv_org_id"]);
                Params ps = new Params();
                ps.Add("p_inv_org_id", InvOrgId);
                ps.Add("p_commit", Msg.Context["p_commit"]);
                ps.Add("p_sn", Msg.Context["p_sn"]);  
                ps.Add("p_material_sn", body.Select(m => m.material_sn).ToArray());
                ps.Add("p_check_material_sn", Msg.Context["p_check_material_sn"]);
                ps.Add("p_keypart_id", body.Select(m => m.ID).ToArray());
                ps.Add("p_reason", Msg.Context["p_reason"]);
                ps.Add("p_user_modified", Msg.Context["p_user_modified"]);
                ps.Add("x_ret_code", ParamDirection.Output);
                ps.Add("x_ret_msg", ParamDirection.Output);       

                using (var context = new BizServiceContext())
                {
                    var dt = DBHelper.ExecProc(context.Database.Connection.ConnectionString, "sfc_dc_material_sn_save_pub.main", ps);
                    if (string.Equals(ps["x_ret_code"].Value, "0"))
                    {                           
                        Msg.IsSucess = true;
                    }
                    else
                    {
                        Msg.ErrorCode = ps["x_ret_code"].Value;
                        Msg.ErrorMessage = Convert.ToString(ps["x_ret_msg"].Value);
                        Msg.IsSucess = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Msg.ErrorMessage = string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace);
                Msg.IsSucess = false;
            }
            return Msg;
        }
    }
}
时间: 2024-08-26 16:49:31

WPF物料替换源码参考(返回多个数据表)的相关文章

【Spring源码分析】.properties文件读取及占位符${...}替换源码解析

前言 我们在开发中常遇到一种场景,Bean里面有一些参数是比较固定的,这种时候通常会采用配置的方式,将这些参数配置在.properties文件中,然后在Bean实例化的时候通过Spring将这些.properties文件中配置的参数使用占位符"${}"替换的方式读入并设置到Bean的相应参数中. 这种做法最典型的就是JDBC的配置,本文就来研究一下.properties文件读取及占位符"${}"替换的源码,首先从代码入手,定义一个DataSource,模拟一下JDB

redis源码分析4---结构体---跳跃表

redis源码分析4---结构体---跳跃表 跳跃表是一种有序的数据结构,他通过在每个节点中维持多个指向其他节点的指针,从而达到快速访问节点的目的: 跳跃表支持平均O(logN),最坏O(N)复杂度的节点查找,还可以通过顺序性操作来批量处理节点.性能上和平衡树媲美,因为事先简单,常用来代替平衡树. 在redis中,只在两个地方使用了跳跃表,一个是实现有序集合键,另一个是在集群节点中用作内部数据结构. 1 跳跃表节点 1.1 层 层的数量越多,访问其他节点的速度越快: 1.2 前进指针 遍历举例

vector源码(参考STL源码--侯捷)-----空间分配导致迭代器失效

vector源码1(参考STL源码--侯捷) vector源码2(参考STL源码--侯捷) #include<bits/stdc++.h> using namespace std; int main(){ vector<int> v(3,3); vector<int>::iterator it=v.begin(); cout<<v.size()<<" "<<v.capacity()<<endl;//3

Python使用正则表达式替换源码前序号

从博客园或其它地方拷贝代码,经常前面有代码序号,像下面这个样子: 1 wbContent.Navigate(vURL); 2  3     Result:=GetHtml(wbContent); 4  5     while not ContainsText(Result,'共找到') do 6     begin 7       Sleep(100); 8       Application.ProcessMessages; 9       Result:=GetHtml(wbContent)

ABP框架源码学习之修改默认数据库表前缀或表名称

1,源码 1 namespace Abp.Zero.EntityFramework 2 { 3 /// <summary> 4 /// Extension methods for <see cref="DbModelBuilder"/>. 5 /// </summary> 6 public static class AbpZeroDbModelBuilderExtensions 7 { 8 /// <summary> 9 /// Chan

SQL 实验详细源码参考

1 -- ---------------------------------------------------------------------------------- 2 -- 数据库初始化 (实验二 数据描述.定义实验) 3 -- ---------------------------------------------------------------------------------- 4 create database s_13420228; 5 use s_13420228

Fresco源码解析 - DataSource怎样存储数据

datasource是一个独立的 package,与FB导入的guava包都在同一个工程内 - fbcore. datasource的类关系比较简单,一张类图基本就可以描述清楚它们间的关系. DataSource 是一个 interface, 功能与JDK中的Future类似,但是相比于Future,它的先进之处则在于 不仅仅只生产一个单一的结果,而是能够提供系列结果. Unlike Futures, DataSource can issue a series of results, rathe

mapbox.gl源码解析——基本架构与数据渲染流程

加载地图 Mapbox GL JS是一个JavaScript库,使用WebGL渲染交互式矢量瓦片地图和栅格瓦片地图.WebGL渲染意味着高性能,MapboxGL能够渲染大量的地图要素,拥有流畅的交互以及动画效果.可以显示立体地图并且支持移动端,是一款十分优秀的WEB GIS开发框架. 在页面引入MapboxGL脚本库和样式库: <script src='https://api.mapbox.com/mapbox-gl-js/v0.40.0/mapbox-gl.js'></script&g

vector源码1(参考STL源码--侯捷)

vector源码2(参考STL源码--侯捷) vector源码(参考STL源码--侯捷)-----空间分配导致迭代器失效 vector概述 Vector是动态空间,随着元素的加入,它的内部机制会自行扩充空间纳入新元素,vector的使用效率,关键在于其对大小的控制以及重新配置时的元素迁移效率. Vector定义摘要 template <class T,class Alloc=alloc>//alloc是SGI STL的空间配置器 class vector { public: typedef T