Ejemplo n.º 1
0
        public bool ConditionIsFullfilled(DataCondition dataCondition, object value)
        {
            string dataConditionValue = dataCondition.Value.ToString();
            string objectValue        = value.ToString();

            return(objectValue.StartsWith(dataConditionValue));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check that data is valid.
        /// </summary>
        public override void CheckData()
        {
            base.CheckData();
            if (DataConversion.IsNotNull())
            {
                throw new ApplicationException("Not yet implemented");
            }
            if (DataLimitation.IsNotNull())
            {
                throw new ApplicationException("Not yet implemented");
            }

            if (DataCondition.IsNull())
            {
                DataConversion.CheckNotNull("DataConversion");
            }
            else
            {
                DataConversion.CheckNull("DataConversion");
            }

            if (DataCondition.IsNotNull())
            {
                DataCondition.CheckData();
            }
            if (DataConversion.IsNotNull())
            {
                DataConversion.CheckData();
            }
            if (DataLimitation.IsNotNull())
            {
                DataLimitation.CheckData();
            }
        }
Ejemplo n.º 3
0
        private void btnAddCondition_Click(object sender, RoutedEventArgs e)
        {
            DataCondition dataCondition = new DataCondition();

            this.dataFilter.DataConditions.Add(dataCondition);
            AddDataCondition(dataCondition);
        }
Ejemplo n.º 4
0
        public virtual List <DataCondition> InitBaseConditions()
        {
            List <DataCondition> conds = new List <DataCondition>();
            DataCondition        ds    = new DataCondition();

            ds.Datapoint = new DataPoint(this.strKey);
            ds.value     = this.strRowId;
            ds.Logic     = ConditionLogic.And;
            if (this.TranData != null)
            {
                foreach (DataTranMapping data in this.TranData)
                {
                    if (GlobalShare.DataPointMappings.ContainsKey(data.FromDataPoint.Name))
                    {
                        continue;
                    }
                    DataCondition datacond = new DataCondition();
                    datacond.value     = data.FromDataPoint.Text;
                    datacond.Datapoint = new DataPoint(data.ToDataPoint);
                    conds.Add(datacond);
                }
            }
            conds.Add(ds);
            return(conds);
        }
        public bool ConditionIsFullfilled(DataCondition dataCondition, object value)
        {
            if (value != null && String.IsNullOrEmpty(value.ToString()) == false && value != DBNull.Value)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
        public virtual void StartDataConditionEntry(DataConditionEntry entry)
        {
            SetCurrentNodeToTopLevelItem(entry.LevelNumber);
            var node = new DataCondition(entry);

            Enter(node);
            if (!node.IsPartOfATypeDef)
            {
                node.SymbolTable.AddVariable(node);
            }
        }
        public DataConditionRow(DataCondition dataCondition, IDatastore datastore, List <AttributeImplementation> dataConditionAttributes)
        {
            InitializeComponent();
            this.datastore = datastore;
            this.dataConditionAttributes = dataConditionAttributes;

            InitializeColumns();


            this.DataContext = dataCondition;
        }
Ejemplo n.º 8
0
        public virtual void StartDataConditionEntry(DataConditionEntry entry)
        {
            SetCurrentNodeToTopLevelItem(entry.LevelNumber);
            var node = new DataCondition(entry);

            if (_CurrentTypeDefinition != null)
            {
                node.ParentTypeDefinition = _CurrentTypeDefinition;
            }
            Enter(node);
            node.SymbolTable.AddVariable(node);
        }
Ejemplo n.º 9
0
 public bool ConditionIsFullfilled(DataCondition dataCondition, object value)
 {
     try
     {
         int dataConditionValue = Convert.ToInt32(dataCondition.Value);
         int objectValue        = Convert.ToInt32(value);
         return(objectValue < dataConditionValue);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            //base.searchbtn_Click(sender, e);
            if (this.comboBox_column.SelectedIndex < 0)
            {
                return;
            }
            List <DataCondition> dcs   = this.comboBox_column.Tag as List <DataCondition>;
            DataCondition        dc    = dcs[this.comboBox_column.SelectedIndex];
            List <DataCondition> conds = InitBaseConditions();

            ////DataCondition ds = new DataCondition();
            ////ds.Datapoint = new DataPoint(this.strKey);
            ////ds.value = this.strRowId;
            ////ds.Logic = ConditionLogic.And;
            dc.Logic = ConditionLogic.And;
            dc.value = this.txt_searchkey.Text;
            ////if (dc.SubConditions == null || dc.SubConditions.Count == 0)
            ////{
            ////    this.RefreshData();
            ////    return;
            ////}
            ////foreach (DataCondition sdc in dc.SubConditions)
            ////{
            ////    sdc.value = txtbox.Text;
            ////    sdc.Logic = ConditionLogic.Or;
            ////}
            ////conds.Add(ds);
            conds.Add(dc);
            if (GridSource == null || GridSource.Trim().Length == 0)
            {
                return;
            }
            string msg     = null;
            bool   isextra = false;

            GridData = DataSource.InitDataSource(GridSource, conds, strUid, out msg, ref isextra);
            if (msg != null)
            {
                MessageBox.Show(msg);
                return;
            }
            if (GridData == null)
            {
                MessageBox.Show("返回结果为空!");
                return;
            }
            FillData(GridData);
            //RefreshData();
        }
Ejemplo n.º 11
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);
        }
        public bool ConditionIsFullfilled(DataCondition dataCondition, object value)
        {
            bool?nullEqualCheck = ConditionCheckHelper.AreObjectsNullEqual(dataCondition.Value, value);

            if (nullEqualCheck != null)
            {
                return((bool)nullEqualCheck);
            }

            string dataConditionValue = dataCondition.Value.ToString();
            string objectValue        = value.ToString();

            return(dataConditionValue.Equals(objectValue));
        }
Ejemplo n.º 13
0
        protected virtual void AddSimpleSearchInToolBar(XmlDocument xmldoc)
        {
            //SearchBox
            XmlNode cmbNode = xmldoc.SelectSingleNode("/root/SearchBox");

            if (cmbNode == null)
            {
                return;
            }
            //toolbarbld.AddToolBarItem(cmbNode, ToolBarItemType.Mix, "simplesearch", frm.SimpleSearch);
            toolbarbld.AddToolBarItem(null, ToolBarItemType.Separator);
            toolbarbld.AddToolBarItem(XmlUtil.GetSubNodeText(cmbNode, "@text"), ToolBarItemType.Label);
            XmlNode       condnodes = cmbNode.SelectSingleNode("./items");
            DataCondition cond      = new DataCondition();

            if (condnodes != null)
            {
                DataCondition.FillCondition(condnodes, ref cond);
            }
            ITag ssearchbox = toolbarbld.AddToolBarItem(XmlUtil.GetSubNodeText(cmbNode, "@name"), condnodes, "", ToolBarItemType.TextBox, frm.SimpleSearch);
            ITag searchbtn  = toolbarbld.AddToolBarItem(XmlUtil.GetSubNodeText(cmbNode, "@name"), null, XmlUtil.GetSubNodeText(cmbNode, "@text"), ToolBarItemType.Button, frm.SimpleSearch);

            ssearchbox.Tag = cond;
            searchbtn.Tag  = ssearchbox;
            #region old code

            /*
             * this.toolStrip1.Items.Add(new ToolStripSeparator());
             * this.toolStrip1.Items.Add(new ToolStripLabel(XmlUtil.GetSubNodeText(cmbNode, "@text")));
             * ToolStripTextBox ssearchbox = new ToolStripTextBox();
             *
             * ToolStripButton searchbtn = new ToolStripButton();
             * (this.TopLevelControl as Form).AcceptButton = searchbtn as IButtonControl;
             * searchbtn.Text = XmlUtil.GetSubNodeText(cmbNode, "btn/@text");
             * searchbtn.Click += ToolBar_OnSimpleSearchClicked;
             * ssearchbox.KeyUp += new KeyEventHandler(ssearchbox_KeyUp);
             * XmlNode condnodes = cmbNode.SelectSingleNode("./items");
             * DataCondition cond = new DataCondition();
             * if (condnodes != null)
             * {
             *  DataCondition.FillCondition(condnodes, ref cond);
             * }
             * ssearchbox.Tag = cond;
             * searchbtn.Tag = ssearchbox;
             * this.toolStrip1.Tag = searchbtn;
             * this.toolStrip1.Items.Add(ssearchbox);
             * this.toolStrip1.Items.Add(searchbtn);*/
            #endregion
        }
Ejemplo n.º 14
0
 public List <Search_SearchByType_Result> SearchByTypeWithDate(DataCondition data)
 {
     if (data.ToTime == "" && data.FromTime == "")
     {
         var query = db.Database.SqlQuery <Search_SearchByType_Result>("Search_SearchByType @LoaiChungTu,@macongty", new SqlParameter("LoaiChungTu", data.GiaTriChungTu), new SqlParameter("macongty", "HOPLONG"));
         result = query.ToList();
     }
     else
     {
         DateTime FromDate = xlnt.Xulydatetime(data.FromTime);
         DateTime ToDate   = xlnt.Xulydatetime(data.ToTime);
         var      query    = db.Database.SqlQuery <Search_SearchByType_Result>("Search_SearchByTypeWithDate @LoaiChungTu,@FromDate,@ToDate, @macongty", new SqlParameter("LoaiChungTu", data.GiaTriChungTu), new SqlParameter("FromDate", FromDate), new SqlParameter("ToDate", ToDate), new SqlParameter("macongty", "HOPLONG"));
         result = query.ToList();
     }
     return(result);
 }
Ejemplo n.º 15
0
        public List <GetChungTuFromDoiTuong_Result> SearchByDoiTuongWithDate(DataCondition data)
        {
            if (data.FromTime == "" && data.ToTime == "")
            {
                var query = db.Database.SqlQuery <GetChungTuFromDoiTuong_Result>("GetChungTuFromDoiTuong @MaDoiTuong,@macongty", new SqlParameter("MaDoiTuong", data.GiaTriChungTu), new SqlParameter("macongty", "HOPLONG"));
                resultDoiTuong = query.ToList();
            }
            else

            {
                DateTime FromDate = xlnt.Xulydatetime(data.FromTime);
                DateTime ToDate   = xlnt.Xulydatetime(data.ToTime);
                var      query    = db.Database.SqlQuery <GetChungTuFromDoiTuong_Result>("GetChungTuFromDoiTuong_WithDate @MaDoiTuong,@FromDate,@ToDate, @macongty", new SqlParameter("MaDoiTuong", data.GiaTriChungTu), new SqlParameter("FromDate", FromDate), new SqlParameter("ToDate", ToDate), new SqlParameter("macongty", "HOPLONG"));
                resultDoiTuong = query.ToList();
            }

            return(resultDoiTuong);
        }
Ejemplo n.º 16
0
        public bool ConditionIsFullfilled(DataCondition dataCondition, object value)
        {
            bool?nullEqualCheck = ConditionCheckHelper.AreObjectsNullEqual(dataCondition.Value, value);

            if (nullEqualCheck != null)
            {
                return((bool)nullEqualCheck);
            }

            try
            {
                int dataConditionValue = Convert.ToInt32(dataCondition.Value);
                int objectValue        = Convert.ToInt32(value);
                return(dataConditionValue == objectValue);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 17
0
        static List <JdGoodSummayInfoItemClass> getInfoBySukIds(List <string> skids)
        {
            //JdUnion_Goods_PromotionGoodsinfo_Class
            string dsName = "JDUnion_PromotionGoodsinfo";
            List <JdGoodSummayInfoItemClass> ret = new List <JdGoodSummayInfoItemClass>();

            if (skids.Count == 0)
            {
                return(ret);
            }
            List <DataCondition> dcs = new List <DataCondition>();
            DataCondition        dc  = new DataCondition();

            dc.Datapoint = new DataPoint("skuIds");
            dc.value     = string.Join(",", skids);
            dcs.Add(dc);
            string  msg     = null;
            bool    isExtra = false;
            DataSet ds      = DataSource.InitDataSource(dsName, dcs, GlobalShare.UserAppInfos.First().Key, out msg, ref isExtra, false);

            if (msg != null)
            {
                return(ret);
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow dr = ds.Tables[0].Rows[i];
                JdGoodSummayInfoItemClass jsiic = new JdGoodSummayInfoItemClass();
                jsiic.skuId       = dr["JGD02"].ToString();
                jsiic.skuName     = dr["JGD03"].ToString();
                jsiic.imgageUrl   = dr["JGD08"].ToString();
                jsiic.materialUrl = dr["JGD09"].ToString();
                jsiic.price       = dr["JGD11"].ToString();
                jsiic.discount    = "";
                jsiic.couponLink  = "";
                ret.Add(jsiic);
            }
            return(ret);
        }
Ejemplo n.º 18
0
        public virtual bool SaveClientData(string DetailSource, UpdateData updata, DataRequestType type = DataRequestType.Update)
        {
            return(true);

            string GridSource = "JdUnion_Client_Goods_Full";
            string strRowId   = "";
            string strKey     = "JGD02";

            updata.keydpt = new DataPoint(strKey);
            //if (!updata.Updated) return true;
            DataSource ds = GlobalShare.mapDataSource[DetailSource];
            //ds.SourceName = DetailSource;
            List <DataCondition> conds = new List <DataCondition>();
            DataCondition        dcond = new DataCondition();

            dcond.Datapoint = new DataPoint(strKey);
            //dcond.value = strRowId;
            conds.Add(dcond);
            //DataRequestType type = DataRequestType.Update;
            if (strRowId == null || strRowId == "")
            {
                type = DataRequestType.Add;
            }
            if (GlobalShare.mapDataSource.ContainsKey(GridSource))
            {
                DataSource grid_source = GlobalShare.mapDataSource[GridSource];
                ds.SubSource = grid_source;
            }
            //updata.SubItems.Where(a=>a.ReqType)
            string msg = GlobalShare.DataCenterClientObj.UpdateDataList(ds, dcond, updata, type);

            if (msg != null)
            {
                //MessageBox.Show(msg);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 19
0
 private void AddDataCondition(DataCondition dataCondition)
 {
     conditionsPanel.Children.Add(new DataConditionRow(dataCondition, this.datastore, this.dataConditionAttributes));
 }
Ejemplo n.º 20
0
 public virtual bool Visit(DataCondition dataCondition)
 {
     return(true);
 }
Ejemplo n.º 21
0
        public BasketballContext(string rootPath,
                                 EditorSelector sectionEditorSelector, EditorSelector unitEditorSelector,
                                 IDataLayer userConnection, IDataLayer fabricConnection,
                                 IDataLayer messageConnection, IDataLayer forumConnection)
        {
            this.rootPath              = rootPath;
            this.imagesPath            = Path.Combine(RootPath, "Images");
            this.userConnection        = userConnection;
            this.fabricConnection      = fabricConnection;
            this.messageConnection     = messageConnection;
            this.forumConnection       = forumConnection;
            this.sectionEditorSelector = sectionEditorSelector;
            this.unitEditorSelector    = unitEditorSelector;

            this.userStorage     = new UserStorage(userConnection);
            this.NewsStorages    = new TopicStorageCache(fabricConnection, messageConnection, NewsType.News);
            this.ArticleStorages = new TopicStorageCache(fabricConnection, messageConnection, ArticleType.Article);
            this.Forum           = new ForumStorageCache(fabricConnection, forumConnection);

            string settingsPath = Path.Combine(rootPath, "SiteSettings.config");

            if (!File.Exists(settingsPath))
            {
                this.siteSettings = new SiteSettings();
            }
            else
            {
                this.siteSettings = XmlSerialization.Load <SiteSettings>(settingsPath);
            }

            this.pull = new TaskPull(
                new ThreadLabel[] { Labels.Service },
                TimeSpan.FromMinutes(15)
                );

            this.newsCache = new Cache <Tuple <ObjectHeadBox, LightHead[]>, long>(
                delegate
            {
                ObjectHeadBox newsBox = new ObjectHeadBox(fabricConnection,
                                                          string.Format("{0} order by act_from desc", DataCondition.ForTypes(NewsType.News))
                                                          );

                int[] allNewsIds = newsBox.AllObjectIds;

                List <LightHead> actualNews = new List <LightHead>();
                for (int i = 0; i < Math.Min(22, allNewsIds.Length); ++i)
                {
                    int newsId = allNewsIds[i];
                    actualNews.Add(new LightHead(newsBox, newsId));
                }

                return(_.Tuple(newsBox, actualNews.ToArray()));
            },
                delegate { return(newsChangeTick); }
                );

            this.articlesCache = new Cache <Tuple <ObjectBox, LightObject[]>, long>(
                delegate
            {
                ObjectBox articleBox = new ObjectBox(fabricConnection,
                                                     string.Format("{0} order by act_from desc", DataCondition.ForTypes(ArticleType.Article))
                                                     );

                int[] allArticleIds = articleBox.AllObjectIds;

                ObjectBox actualBox = new ObjectBox(FabricConnection,
                                                    string.Format("{0} order by act_from desc limit 5", DataCondition.ForTypes(ArticleType.Article))
                                                    );

                List <LightObject> actualArticles = new List <LightObject>();
                foreach (int articleId in actualBox.AllObjectIds)
                {
                    actualArticles.Add(new LightObject(actualBox, articleId));
                }

                return(_.Tuple(articleBox, actualArticles.ToArray()));
            },
                delegate { return(articleChangeTick); }
                );

            this.lightStoreCache = new Cache <IStore, long>(
                delegate
            {
                LightObject contacts = DataBox.LoadOrCreateObject(fabricConnection,
                                                                  ContactsType.Contacts, ContactsType.Kind.CreateXmlIds, "main");

                LightObject seo = DataBox.LoadOrCreateObject(fabricConnection,
                                                             SEOType.SEO, SEOType.Kind.CreateXmlIds, "main");

                SectionStorage sections = SectionStorage.Load(fabricConnection);

                WidgetStorage widgets = WidgetStorage.Load(fabricConnection, siteSettings.DisableScripts);

                RedirectStorage redirects = RedirectStorage.Load(fabricConnection);

                SiteStore store = new SiteStore(sections, null, widgets, redirects, contacts, seo);
                store.Links.AddLink("register", null);
                store.Links.AddLink("passwordreset", null);

                return(store);
            },
                delegate { return(dataChangeTick); }
                );

            this.lastPublicationCommentsCache = new Cache <RowLink[], long>(
                delegate
            {
                DataTable table = messageConnection.GetTable("",
                                                             "Select Distinct article_id From message order by create_time desc limit 10"
                                                             );

                List <RowLink> lastComments = new List <RowLink>(10);
                foreach (DataRow row in table.Rows)
                {
                    int topicId = ConvertHlp.ToInt(row[0]) ?? -1;

                    if (News.ObjectById.Exist(topicId))
                    {
                        TopicStorage topic  = NewsStorages.ForTopic(topicId);
                        RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                        if (lastMessage != null)
                        {
                            lastComments.Add(lastMessage);
                        }
                    }
                    else if (Articles.ObjectById.Exist(topicId))
                    {
                        TopicStorage topic  = ArticleStorages.ForTopic(topicId);
                        RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                        if (lastMessage != null)
                        {
                            lastComments.Add(lastMessage);
                        }
                    }
                }

                return(lastComments.ToArray());
            },
                delegate { return(publicationCommentChangeTick); }
                );

            this.lastForumCommentsCache = new Cache <RowLink[], long>(
                delegate
            {
                DataTable table = forumConnection.GetTable("",
                                                           "Select Distinct article_id From message order by create_time desc limit 7"
                                                           );

                List <RowLink> lastComments = new List <RowLink>(7);
                foreach (DataRow row in table.Rows)
                {
                    int topicId = ConvertHlp.ToInt(row[0]) ?? -1;

                    TopicStorage topic  = Forum.TopicsStorages.ForTopic(topicId);
                    RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                    if (lastMessage != null)
                    {
                        lastComments.Add(lastMessage);
                    }
                }

                return(lastComments.ToArray());
            },
                delegate { return(forumCommentChangeTick); }
                );

            this.tagsCache = new Cache <TagStore, long>(
                delegate
            {
                ObjectHeadBox tagBox = new ObjectHeadBox(fabricConnection, DataCondition.ForTypes(TagType.Tag) + " order by xml_ids asc");

                return(new TagStore(tagBox));
            },
                delegate { return(tagChangeTick); }
                );

            //this.tagsCache = new Cache<Tuple<ObjectHeadBox, Dictionary<string, int>>, long>(
            //  delegate
            //  {
            //    ObjectHeadBox tagBox = new ObjectHeadBox(fabricConnection, DataCondition.ForTypes(TagType.Tag) + " order by xml_ids asc");

            //    Dictionary<string, int> tagIdByKey = new Dictionary<string, int>();
            //    foreach (int tagId in tagBox.AllObjectIds)
            //    {
            //      string tagName = TagType.DisplayName.Get(tagBox, tagId);
            //      if (StringHlp.IsEmpty(tagName))
            //        continue;

            //      string tagKey = tagName.ToLower();
            //      tagIdByKey[tagKey] = tagId;
            //    }

            //    return _.Tuple(tagBox, tagIdByKey);
            //  },
            //  delegate { return tagChangeTick; }
            //);

            this.unreadDialogCache = new Cache <TableLink, long>(
                delegate
            {
                return(DialogueHlp.LoadUnreadLink(forumConnection));
            },
                delegate { return(unreadChangeTick); }
                );

            Pull.StartTask(Labels.Service,
                           SiteTasks.SitemapXmlChecker(this, rootPath,
                                                       delegate(LinkInfo[] sectionlinks)
            {
                List <LightLink> allLinks = new List <LightLink>();
                allLinks.AddRange(
                    ArrayHlp.Convert(sectionlinks, delegate(LinkInfo link)
                {
                    return(new LightLink(link.Directory, null));
                })
                    );

                foreach (int articleId in Articles.AllObjectIds)
                {
                    LightHead article = new LightHead(Articles, articleId);
                    allLinks.Add(
                        new LightLink(UrlHlp.ShopUrl("article", articleId),
                                      article.Get(ObjectType.ActTill) ?? article.Get(ObjectType.ActFrom)
                                      )
                        );
                }

                foreach (int newsId in News.AllObjectIds)
                {
                    LightHead news = new LightHead(News, newsId);
                    allLinks.Add(
                        new LightLink(UrlHlp.ShopUrl("news", newsId),
                                      news.Get(ObjectType.ActTill) ?? news.Get(ObjectType.ActFrom)
                                      )
                        );
                }

                //foreach (int tagId in Tags.AllObjectIds)
                //{
                //  LightHead tag = new LightHead(Tags, tagId);
                //  allLinks.Add(
                //    new LightLink(string.Format("/tags?tag={0}", tagId)
                //    )
                //  );
                //}

                return(allLinks.ToArray());
            }
                                                       )
                           );
        }
Ejemplo n.º 22
0
 public bool ConditionIsFullfilled(DataCondition dataCondition, object value)
 {
     return(value == null || String.IsNullOrEmpty(value.ToString()) || value == DBNull.Value);
 }
        public void downloadData()
        {
            Dictionary <string, UpdateData> newAddRec = new Dictionary <string, UpdateData>();

            try
            {
                UpdateText?.Invoke(string.Format("-------------开始下载 {0}------------", DateTime.Now));
                long?batchId = getCurrBatchNo();
                if (batchId == null)
                {
                    UpdateText?.Invoke(string.Format("无法获取到批次号!"));
                    return;
                }
                if (batchId == null)
                {
                    batchId = 100 * (DateTime.Now.Year * 10000 + DateTime.Now.Month * 100 + DateTime.Now.Day) + 1;
                }
                UpdateText?.Invoke(string.Format("当前批次号:{0}", batchId));
                List <DataCondition> currDayConditions = new List <DataCondition>();
                DataCondition        dcc = new DataCondition();
                dcc.Datapoint = new DataPoint("JGD14");
                dcc.strOpt    = ">";
                dcc.value     = string.Format("{0}", 100 * (batchId / 100));
                currDayConditions.Add(dcc);
                string     msg         = null;
                DataSource dss         = GlobalShare.UserAppInfos.First().Value.mapDataSource["JdUnion_Client_Goods_NoXml"];
                DataSet    currDayData = DataSource.InitDataSource(dss, currDayConditions, out msg);
                if (currDayData == null)
                {
                    UpdateText?.Invoke(string.Format("获取当日数据失败!"));
                    return;
                }
                if (currDayData != null)
                {
                    for (int i = 0; i < currDayData.Tables[0].Rows.Count; i++)
                    {
                        eliteData tmp = new eliteData();
                        DataRow   dr  = currDayData.Tables[0].Rows[i];
                        string    eli = dr["JGD15"].ToString();
                        tmp.eliteId = int.Parse(eli);

                        tmp.data = new List <DataRow>();
                        tmp.data.Add(dr);
                        new Task(receiveData, tmp).Start();
                    }
                }
                //List<int> list = JdUnion_GlbObject.getElites();
                //Dictionary<string, string> cols = null;
                HashSet <string> allExistKeys = loadAllKeys();
                if (allExistKeys == null)
                {
                    allExistKeys = new HashSet <string>();
                }
                List <int> list = JdUnion_GlbObject.getElites();
                UpdateText?.Invoke(string.Format("当前数据库存在记录数{0}条!", allExistKeys.Count));

                int ErrCnt  = 0;
                int SaveCnt = 0;
                try
                {
                    foreach (int elit in list)//遍历每个elite
                    {
                        msg = null;
                        bool isExtra = false;
                        List <DataCondition> dics = new List <DataCondition>();
                        DataCondition        dc   = new DataCondition();
                        dc.Datapoint = new DataPoint("goodsReq/eliteId");
                        dc.value     = elit.ToString();
                        dics.Add(dc);
                        DataSet ds = DataSource.InitDataSource("JdUnion_Goods", dics, Program.UserId, out msg, ref isExtra);
                        //DataSet ds = new DataSet();
                        if (msg != null)
                        {
                            UpdateText?.Invoke(string.Format("获取分类数据{0}时出现错误,内容为{1}", elit, msg));
                            continue;
                        }
                        eliteData ed = new eliteData();
                        ed.eliteId = elit;
                        ed.data    = new List <DataRow>();

                        List <UpdateData> ups = DataSource.DataSet2UpdateData(ds, "jdUnion_BatchLoad", Program.UserId);
                        UpdateText?.Invoke(string.Format("{1}类总共接收到{0}条记录", ups.Count, elit));
                        UpdateData batchData = new UpdateData();
                        batchData.keydpt   = new DataPoint("JBTH1");
                        batchData.keyvalue = batchId.Value.ToString();
                        //batchData.Items.Add("JGD01", null);
                        int batchCnt = 1000;
                        for (int i = 0; i < ups.Count; i++)
                        {
                            string key = ups[i].Items["JGD02"].value;
                            if (allExistKeys.Contains(key))
                            {
                                continue;
                            }
                            ed.data.Add(ds.Tables[0].Rows[i]);
                            ups[i].keydpt   = new DataPoint("JGD02");
                            ups[i].keyvalue = key;
                            ups[i].ReqType  = DataRequestType.Add;
                            if (ups[i].Items.ContainsKey("JGD14"))
                            {
                                ups[i].Items["JGD14"].value = batchData.keyvalue;
                            }
                            else
                            {
                                ups[i].Items.Add("JGD14", new UpdateItem("JGD14", batchData.keyvalue));
                            }
                            batchData.SubItems.Add(ups[i]);
                            if (i == ups.Count - 1 || batchData.SubItems.Count == batchCnt)
                            {
                                bool succ = (SaveClientData == null) ? false : (SaveClientData.Invoke("jdUnion_BatchLoad", batchData, DataRequestType.Add));
                                if (!succ)
                                {
                                    ErrCnt += batchData.SubItems.Count;
                                }
                                else
                                {
                                    SaveCnt += batchData.SubItems.Count;
                                    for (int k = 0; k < ups.Count; k++)
                                    {
                                        string skey = ups[k].Items["JGD02"].value;
                                        if (!allExistKeys.Contains(skey))
                                        {
                                            allExistKeys.Add(skey);
                                        }
                                        if (!newAddRec.ContainsKey(skey))
                                        {
                                            newAddRec.Add(skey, ups[k]);
                                        }
                                    }
                                    UpdateText?.Invoke(string.Format("共计条数为{0}条,实际保存条数为{1}条!", ups.Count, batchData.SubItems.Count));
                                }
                                batchData = new UpdateData();
                            }
                        }
                        if (batchData.SubItems.Count > 0)//最后的不能错过。
                        {
                            bool succ = SaveClientData == null ? false : SaveClientData.Invoke("jdUnion_BatchLoad", batchData, DataRequestType.Add);
                            if (!succ)
                            {
                                //MessageBox.Show(string.Format("商品{0}保存错误!", ups[i].keyvalue));
                                ErrCnt += batchData.SubItems.Count;
                            }
                            else
                            {
                                SaveCnt += batchData.SubItems.Count;
                                for (int k = 0; k < ups.Count; k++)
                                {
                                    string skey = ups[k].Items["JGD02"].value;
                                    if (!allExistKeys.Contains(skey))
                                    {
                                        allExistKeys.Add(skey);
                                    }
                                    if (!newAddRec.ContainsKey(skey))
                                    {
                                        newAddRec.Add(skey, ups[k]);
                                    }
                                }
                                UpdateText?.Invoke(string.Format("共计条数为{0}条,实际保存条数为{1}条!", ups.Count, batchData.SubItems.Count));
                            }
                        }

                        if (ErrCnt > 0)
                        {
                            UpdateText?.Invoke(string.Format("错误条数为{0}条!", ErrCnt));
                        }
                        new Task(receiveData, ed).Start();
                    }
                }
                catch (Exception ce)
                {
                    UpdateText?.Invoke(string.Format("错误条数为{0}条!{1}[{2}]", ErrCnt, ce.Message, ce.StackTrace));
                }
                finally
                {
                    //this.Cursor = Cursors.Default;
                }
            }
            catch (Exception ce)
            {
                UpdateText?.Invoke(string.Format("下载数据错误:{0}[{1}]", ce.Message, ce.StackTrace));
            }
            finally
            {
                onSavedData?.Invoke(newAddRec);
            }
        }
Ejemplo n.º 24
0
 private void EnterDataConditionEntry(DataConditionEntry data)
 {
     SetCurrentNodeToTopLevelItem(data.LevelNumber.Value);
     var node = new DataCondition(data);
     Enter(node);
     if (!node.IsPartOfATypeDef) node.SymbolTable.AddVariable(node);
 }
Ejemplo n.º 25
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);
        }