public DataCollection GetDataSource() { DataCollection dt = new DataCollection(); if (GetSourceEvent != null) { GetSourceEvent(ref dt, WebPart.BlockKey); } else { string sql = WebPart.RepeatDataDataSql; sql = sql.Replace("[UserId]", UserId); /*ISession sess = ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(typeof(ActiveRecordBase)); * * // Now you can use sess.DbConnection * //sess.Connection.CreateCommand(); * SqlDataAdapter sda = new SqlDataAdapter(sql, sess.Connection.ConnectionString); * DataSet ds = new DataSet(); * sda.Fill(ds); * ActiveRecordMediator.GetSessionFactoryHolder().ReleaseSession(sess); * dt = CommonDataHelper.DataTableToDataCollection(ds.Tables[0]); * sda.Dispose(); * ds.Dispose();*/ dt = CommonDataHelper.DataTableToDataCollection(DataHelper.QueryDataTable(sql)); } return(dt); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { CommonDataHelper.SetGlobalInstance(new CarGoDbDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)); kernel.Bind <CarGoDbDataContext>().ToMethod(c => new CarGoDbDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)); kernel.Bind <IRepository>().To <SqlRepository>().InRequestScope(); kernel.Bind <IMapper>().To <CommonMapper>().InSingletonScope(); kernel.Bind <IAuthentication>().To <CustomAuthentication>().InRequestScope(); kernel.Bind <IConfig>().To <Config>().InSingletonScope(); }
//获取所有版块 public static string GetAllBlockNames(string userId, string blockType, string templateId, string isManage, string DBName) { string temp = @"<div align='left' class='panelcon'> <img src='{2}' align='absmiddle' class='panelicon'>{1} <img src='/Modules/WebPart/add2.gif' align='absmiddle' class='paneladdimg' onclick=addBlock('{0}','{1}');> </div> " ; string tempDept = @"<div align='left' class='panelcon'> <img src='{2}' align='absmiddle' class='panelicon'><font color='blue'>{1}</font> <img src='/Modules/WebPart/add2.gif' align='absmiddle' class='paneladdimg' onclick=addBlock('{0}','{1}');> </div> " ; string html = ""; /*string sql = "select Id,BlockTitle,BlockImage,BlockType from DoorBlock where IsHidden='F' and BlockType='"+blockType+"'"; * if ( blockType == "Dept" ) * sql = "select Id,BlockTitle,BlockImage,BlockType from DoorBlock where IsHidden='F' and (BlockType='Portal' OR (BlockType='"+blockType+"' and TemplateId = '"+templateId+"'))"; */ /*string sql = "SELECT Id,BlockTitle,BlockImage,BlockType FROM DoorBlock DB WHERE IsHidden='F' AND BlockType='Portal' OR "+ * "EXISTS( SELECT * FROM " + DBName + "..NewsType PIC WHERE DB.BlockKey = PIC.Id AND ( PIC.AllowQueryId IS NULL OR PIC.AllowQueryId = '' OR PIC.AllowQueryId LIKE '%" + userId + "%' OR " + * "EXISTS( SELECT * FROM OgUserProperty WHERE PATINDEX ( '%,'+Property+',%' , ','+REPLACE(PIC.AllowQueryId,'_',',')+',' ) > 0 AND LEN(Property)>0 AND UserId = '"+userId+"') ) ) ORDER BY BlockType DESC,BlockTitle";*/ string sql = "SELECT Id,BlockTitle,BlockImage,BlockType FROM WebPart where isHidden=0"; if (blockType != null && blockType.Trim() != "") { sql = "SELECT Id,BlockTitle,BlockImage,BlockType FROM WebPart where isHidden=0 and BlockType='" + blockType + "'"; } if (HttpContext.Current.Request["DeptId"] != null && HttpContext.Current.Request["DeptId"].Trim() != "") { sql = "SELECT Id,BlockTitle,BlockImage,BlockType FROM WebPart where isHidden=0 "; sql += " and (DeptId like '%" + HttpContext.Current.Request["DeptId"] + "%' or isnull(DeptId,'')='')"; } /* ISession sess = ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(typeof(ActiveRecordBase)); * SqlDataAdapter sda = new SqlDataAdapter(sql, sess.Connection.ConnectionString); * DataTable ds = new DataTable(); * sda.Fill(ds); * ActiveRecordMediator.GetSessionFactoryHolder().ReleaseSession(sess);*/ DataTable ds = DataHelper.QueryDataTable(sql); DataCollection list = CommonDataHelper.DataTableToDataCollection(ds); ds.Dispose(); //sda.Dispose(); foreach (DataElement item in list.GetElements("")) { if (item.GetAttr("BlockType") == "Dept") { html += string.Format(tempDept, item.GetAttr("Id"), item.GetAttr("BlockTitle"), item.GetAttr("BlockImage")); } else { html += string.Format(temp, item.GetAttr("Id"), item.GetAttr("BlockTitle"), item.GetAttr("BlockImage")); } } return(html); }
private void ParseArticles(XmlNode articleListNode) { XmlNodeList nodeList = articleListNode.SelectNodes("//Stockpile"); if (nodeList == null) { return; } List <int> existing = new List <int>(5000); for (int i = 0; i < nodeList.Count; ++i) { XmlNode node = nodeList[i]; ArticleData articleData = new ArticleData(); int externalId; if (!int.TryParse(node.Attributes["Id"].Value, out externalId)) { throw new ArticleNotValidException(GetType()); } if (existing.Contains(externalId)) { continue; } existing.Add(externalId); string name = GetArticleElementValue(node, "Name"); string typeStr = GetArticleElementValue(node, "Type"); string code = GetArticleElementValue(node, "Code"); string specialCode = GetArticleElementValue(node, "SpecialCode"); string countStr = GetArticleElementValue(node, "Count"); string internalStorage = GetArticleElementValue(node, "InternalStorage"); string purchPriceStr = GetArticleElementValue(node, "PurchasingPrice"); string sellPriceStr = GetArticleElementValue(node, "SellingPrice"); ArticleType articleType = CommonDataHelper.ConvertArticleType(typeStr); double count = GetDoubleValue(countStr); double purchPrice = GetDoubleValue(purchPriceStr); double sellPrice = GetDoubleValue(sellPriceStr); articleData.ExternalId = externalId; articleData.Name = name; articleData.Type = (int)articleType; articleData.Code = code; articleData.SpecialCode = specialCode; articleData.OriginalCount = count; articleData.InternalStorage = internalStorage; articleData.PurchasingPrice = purchPrice; articleData.SellingPrice = sellPrice; articleData.OrderCount = 0; if (articleType == ArticleType.Card) { articleData.OrderName = GetArticleElementValue(node, "OrderName"); string orderedCountStr = GetArticleElementValue(node, "OrderedCount"); articleData.OrderCount = GetDoubleValue(orderedCountStr); } _parsedArticles.Add(articleData); if (articleType == ArticleType.Product) { XmlNodeList itemList = node.SelectNodes("Items/Item"); if (itemList != null) { for (int j = 0; j < itemList.Count; ++j) { XmlNode itemNode = itemList[j]; int itemId = 0; double quantity = 0.0; string itemStorage = string.Empty; string itemCode = string.Empty; if (itemNode.Attributes != null) { if (!int.TryParse(itemNode.Attributes["Id"].Value, out itemId)) { throw new ArticleNotValidException(GetType()); } itemCode = itemNode.Attributes["Code"].Value; itemStorage = itemNode.Attributes["InternalStorage"].Value; quantity = GetDoubleValue(itemNode.Attributes["Quantity"].Value); } _parsedItems.Add(new ArticleItemData { ArticleDataId = articleData.Id, ExternalId = itemId, Code = itemCode, InternalStorage = itemStorage, Quantity = quantity }); } } } } }