예제 #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);
        }
예제 #2
0
파일: Grid.cs 프로젝트: dftell/WCS
        public static string GetValue(string val, DataGridColumn dc, string uid)
        {
            if (dc.DataType == "date")
            {
                DateTime dt;
                DateTime.TryParse(val, out dt);
                return(dt.ToShortDateString());
            }
            if (dc.ComboName == "")
            {
                dc.ComboName = GlobalShare.DataPointMappings[dc.dpt.Name].ComboName;
            }
            if (dc.DataType == "calcexpr")
            {
                CalcExpr   ce = new CalcExpr();
                HandleBase hb = ce.GetHandleClass(dc.Method, dc.CalcExpr);
                val = hb.Handle();
            }
            if ((dc.DataType == "combo" || dc.DataType == "datacombo") && dc.ComboName != null && dc.ComboName.Trim().Length > 0)
            {
                DataChoice dcc = null;
                if (dc.DataType == "combo")
                {
                    dcc = GlobalShare.GetGlobalChoice(dc.Owner.frmhandle.strUid, dc.ComboName);
                }
                else
                {
                    DataComboBox dcb = new DataComboBox(dc.ComboName, uid);
                    dcb.TextField             = dc.TextField;
                    dcb.ValueField            = dc.ValueField;
                    dcb.ComboItemsSplitString = dc.ComboItemsSplitString;
                    List <DataChoiceItem> dcis = dcb.GetDataSource();
                    dcc = new DataChoice();
                    dcc.Options.AddRange(dcis.ToArray());
                }
                if (dcc != null)
                {
                    DataChoiceItem dci = dcc.FindChoiceByValue(val);
                    if (dci != null)
                    {
                        return(dci.Text);
                    }
                }
            }

            return(val);
        }
예제 #3
0
        static void ForceLogin()//强制登录!
        {
            string    LoginName = UserId;
            CITMSUser user      = new CITMSUser();

            user.LoginName = LoginName;
            UserGlobalShare userinfo = new UserGlobalShare(user.LoginName);

            userinfo.appinfo.UserInfo = new UpdateData();//重新实例化
            DataSet ds = new DataSet();

            ////foreach (DataColumn col in ds.Tables[0].Columns)
            ////{
            ////    string strcol = col.ColumnName;
            ////    UpdateItem ui = new UpdateItem(strcol, dr[strcol].ToString());
            ////    userinfo.appinfo.UserInfo.Items.Add(strcol, ui);
            ////}

            DataSource.GetDataSourceMapping();
            userinfo.mapDataSource = DataSource.GetGlobalSourcesClone();
            userinfo.UpdateSource();//替换datasource
            userinfo.CurrUser = user;
            if (!GlobalShare.UserAppInfos.ContainsKey(LoginName))
            {
                GlobalShare.UserAppInfos.Add(LoginName, userinfo);
            }
            UserPerm uperm = new UserPerm(GlobalShare.SystemAppInfo.PermUserPoint, user.LoginName, userinfo);

            //uperm.ToXml();
            //GlobalShare.DataChoices = ; userinfo.InitDataChoices(

            //
            GlobalShare.DataChoices = DataChoice.InitDataChoiceMappings(null);
            userinfo.DataChoices    = DataChoice.InitDataChoiceMappings(userinfo);

            SystemConts.ToDictionary().Values.ToList().ForEach(a => {
                if (!userinfo.appinfo.UserInfo.Items.ContainsKey(a.datapoint.Name))
                {
                    userinfo.appinfo.UserInfo.Items.Add(a.datapoint.Name, a);
                }
            });
        }
예제 #4
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);
        }