Exemplo n.º 1
0
        public List <DataChoiceItem> GetDataSource()
        {
            if (this.DataSourceName == null || DataSourceName.Trim().Length == 0)
            {
                return(null);
            }
            List <DataCondition> conds = new List <DataCondition>();

            if (this.TranData != null)
            {
                for (int i = 0; i < this.TranData.Count; i++)
                {
                    if (this.NeedUpdateData.Items.ContainsKey(TranData[i].ToDataPoint))
                    {
                        string strval = this.NeedUpdateData.Items[this.TranData[i].ToDataPoint].value;
                        if (strval == null || strval.Trim().Length == 0)
                        {
                            continue;
                        }
                        DataCondition cond = new DataCondition();
                        cond.Datapoint = new DataPoint(TranData[i].ToDataPoint);
                        cond.value     = strval;
                        cond.Logic     = ConditionLogic.And;
                        conds.Add(cond);
                    }
                }
            }
            string  msg     = null;
            bool    isextra = false;
            DataSet ds      = WolfInv.Com.WCS_Process.DataSource.InitDataSource(this.DataSourceName, conds, strUid, out msg, ref isextra);

            if (msg != null || ds == null)
            {
                MessageBox.Show(string.Format("控件{0}无法获得数据!错误:{1}", this.Name, msg));
                return(null);
            }
            DataChoice dc = DataChoice.ConvertFromDataSet(ds, ValueField, TextField, true, ComboItemsSplitString);

            if (dc == null)
            {
                MessageBox.Show(string.Format("无法转换数据选择项{0}", this.Name));
                return(null);
            }
            //DataChoice dcc = GlobalShare.GetGlobalChoice(strUid, DataSourceName);
            if (!GlobalShare.UserAppInfos[strUid].DataChoices.ContainsKey(this.DataSourceName))//不断增加新的datachoice
            {
                GlobalShare.UserAppInfos[strUid].DataChoices.Add(this.DataSourceName, dc);
            }
            return(dc.Options);
        }
Exemplo n.º 2
0
        public List <DataChoiceItem> GetDataSource()
        {
            string     strModel = "runningtime_S_{0}_U_{1}_V_{2}_S_{3}";
            string     strdc    = string.Format(strModel, this.DataSourceName, this.strUid, this.ValueField, this.ComboItemsSplitString);
            DataChoice dc       = null;

            if (GlobalShare.DataChoices.ContainsKey(strdc))//保存默认dc到dc字典中,如果有同样的id+source直接获取
            {
                dc = GlobalShare.DataChoices[strdc];
            }
            else
            {
                if (this.DataSourceName == null || DataSourceName.Trim().Length == 0)
                {
                    return(null);
                }
                List <DataCondition> conds = new List <DataCondition>();
                if (this.TranData != null)
                {
                    for (int i = 0; i < this.TranData.Count; i++)
                    {
                        string checkname = TranData[i].ToDataPoint;
                        string toname    = checkname;
                        if (!this.NeedUpdateData.Items.ContainsKey(checkname))
                        {
                            checkname = TranData[i].FromDataPoint.Name;
                            toname    = TranData[i].ToDataPoint;
                        }
                        if (!this.NeedUpdateData.Items.ContainsKey(checkname))
                        {
                            continue;
                        }
                        string strval = this.NeedUpdateData.Items[checkname].value;
                        if (strval == null || strval.Trim().Length == 0)
                        {
                            continue;
                        }
                        DataCondition cond = new DataCondition();
                        cond.Datapoint = new DataPoint(toname);
                        cond.value     = strval;
                        cond.Logic     = ConditionLogic.And;
                        conds.Add(cond);
                    }
                }
                string  msg     = null;
                bool    isextra = false;
                DataSet ds      = WCS_Process.DataSource.InitDataSource(this.DataSourceName, conds, this.strUid, out msg, ref isextra);
                if (ds == null)
                {
                    MessageBox.Show(string.Format("控件{0}无法获得数据![{1}]", this.Name, msg));
                    return(null);
                }
                dc = DataChoice.ConvertFromDataSet(ds, ValueField, TextField, ComboItemsSplitString);
                if (!GlobalShare.DataChoices.ContainsKey(strdc))
                {
                    GlobalShare.DataChoices.Add(strdc, dc);
                }
            }
            if (dc == null)
            {
                MessageBox.Show(string.Format("无法转换数据选择项{0},这可能是由网络异常引起的,即将退出软件,请重新登录看是否正常!", strdc));


                return(null);
            }
            if (!GlobalShare.DataChoices.ContainsKey(this.DataSourceName))//不断增加新的datachoice
            {
                GlobalShare.DataChoices.Add(this.DataSourceName, dc);
            }
            return(dc.Options);
        }