public static List<ClassifiedsListing> GetListings(Item item, ListingProperties props, 
			OrderType orderType)
        {
            VersatileIO.Info("Searching bp.tf classifieds for {0}...", props.ToString(item));
            List<ClassifiedsListing> all = ClassifiedsScraper.GetClassifieds(item, props);

            List<ClassifiedsListing> res = new List<ClassifiedsListing>();
            foreach (ClassifiedsListing c in all)
            {
                if (c.ItemInstance.Item.IsSkin())
                {
                    continue;
                }

                if (c.OrderType == orderType)
                {
                    res.Add(c);
                }
            }

            if (res.IsNullOrEmpty())
            {
                VersatileIO.Warning("No classifieds found for {0}.", props.ToString(item));
                return res.EmptyIfNull().ToList();
            }

            VersatileIO.Info("{0} listings found.", res.Count);
            return res;
        }
        private async Task GroupSearchResults(List<SearchHint> items)
        {
            if (items.IsNullOrEmpty())
            {
                return;
            }

            await TaskEx.Run(() =>
            {
                var emptyGroups = new List<Group<SearchHint>>();

                var types = items.Select(x => x.Type).Distinct().ToList();

                types.ForEach(type => emptyGroups.Add(new Group<SearchHint>(type, new List<SearchHint>())));

                var groupedItems = (from t in items
                    group t by t.Type
                    into grp
                    orderby grp.Key
                    select new Group<SearchHint>(grp.Key, grp)).ToList();

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    SearchResults = (from g in groupedItems.Union(emptyGroups)
#if WP8
                        where g.Count > 0
#else
                                     where g.HasItems

#endif
                        orderby g.Title
                        select g).ToList();
                });
            });
        }
Example #3
0
        /// <summary>
        /// 给某个角色分配权限
        /// </summary>
        /// <param name="roleNum"></param>
        /// <param name="resItems"></param>
        /// <returns></returns>
        public int AllotPower(string roleNum, List<string> resItems)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                int line = 0;
                if (!resItems.IsNullOrEmpty())
                {
                    SysRelationEntity entity = new SysRelationEntity();
                    entity.Where(a => a.RoleNum == roleNum);
                    line = this.SysRelation.Delete(entity);

                    SysResourceProvider provider = new SysResourceProvider();

                    List<SysRelationEntity> list = new List<SysRelationEntity>();
                    foreach (string resNum in resItems)
                    {
                        SysResourceEntity resource = provider.GetResource(resNum);
                        short ResType = resource != null ? resource.ResType : (short)EResourceType.Page;
                        entity = new SysRelationEntity() { RoleNum = roleNum, ResNum = resNum, ResType = ResType };
                        entity.IncludeAll();
                        list.Add(entity);
                    }
                    line += this.SysRelation.Add(list);
                }
                ts.Complete();
                if (line > 0)
                {
                    CacheHelper.Remove(string.Format(CacheKey.JOOSHOW_ROLEPOWER_CACHE, roleNum));
                    CacheHelper.Remove(CacheKey.JOOSHOW_ALLOTPOWER_CACHE);
                }
                return line;
            }
        }
Example #4
0
        /// <summary>
        /// 创建报表文件格式
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public int Create(ReportsEntity entity,List<ReportParamsEntity> list)
        {
            if (!entity.ReportNum.IsEmpty())
            {
                return Update(entity,list);
            }
            int line = 0;
            using (TransactionScope ts = new TransactionScope())
            {
                entity.ReportNum = entity.ReportNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReportsEntity)) : entity.ReportNum;
                entity.IncludeAll();
                line += this.Reports.Add(entity);

                if (!list.IsNullOrEmpty())
                {
                    foreach (ReportParamsEntity item in list)
                    {
                        item.ParamNum = item.ParamNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReportParamsEntity)) : item.ParamNum;
                        item.ReportNum = entity.ReportNum;
                        item.IncludeAll();
                    }
                    this.ReportParams.Add(list);
                }
                ts.Complete();
            }

            return line;
        }
            public void ReturnsTrueWhenValueIsHasZeroElements()
            {
                var emptyString = new List<string>();
                var emptyInt = new List<int>();

                emptyString.IsNullOrEmpty().Should().BeTrue();
                emptyInt.IsNullOrEmpty().Should().BeTrue();
            }
            public void WhenHasElements_ShouldReturnFalse()
            {
                var enumerable = new List<object>();
                enumerable.Add(new { });
                var actual = enumerable.IsNullOrEmpty();

                Assert.False(actual);
            }
            public void ReturnsFalseWhenValueHasElements()
            {
                var enumerableString = new List<string> { "a", "b" };
                var enumerableInt = new List<int> { 1, 2 };

                enumerableString.IsNullOrEmpty().Should().BeFalse();
                enumerableInt.IsNullOrEmpty().Should().BeFalse();
            }
Example #8
0
 public void Remove(List<TagEntity> tags)
 {
     if (tags.IsNullOrEmpty())
     {
         return;
     }
     tags.Iter(x => _tags.Remove(x.EntityId));
     _tagRepository.Remove(tags);
 }
Example #9
0
        public static void CurrentBindDynamicRow(
			this DbDataReader reader, 
			List<DynamicColumn> columns,
			ref DynamicRow row)
        {
            if(null == reader) { return; }
            if(columns.IsNullOrEmpty()) { return; }

            var dbValues = new object[columns.Count];
            reader.GetValues(dbValues);

            var flatValues = new List<Any>();
            var values = new List<Any>();
            var hashCodes = new List<Any>();
            var dbNulls = new List<string>();
            var columnIndex = -1;

            foreach(var column in columns) {
                columnIndex++;
                var value = dbValues[columnIndex];
                if(DBNull.Value == value) {
                    dbNulls.Add(column.BaseColumnName);
                    value = null;
                }
                flatValues.SafeAdd(column.ColumnName, value);
                flatValues.SafeAdd(column.BaseColumnName, value);
                values.Add(column.BaseColumnName, value);

                if(null != value) {
                    int hashCode = value.GetHashCode();
                    hashCodes.Add(
                        column.BaseColumnName, hashCode
                    );
                }
            }

            row.__ReturnAny = true;
            row.__DatabaseFirst = true;
            row.__DynamicColumns = columns;
            row.__FlatValues = flatValues;
            row.__DynamicValues = values;
            row.__DynamicOriginalValues = values;
            row.__OriginalHashCodes = hashCodes;
            row.__DynamicDbNulls = dbNulls;
            row.__OriginalHashCode = row.GetHashCode();

            if(dbNulls.Any()) {
                foreach(var dbNull in dbNulls) {
                    hashCodes.Add(
                        dbNull,
                        row.__OriginalHashCode
                    );
                }
            }
            row.__OriginalHashCodes = hashCodes;
        }
 /// <summary>
 /// Method searches for a random location on the map. Give true for a list of availible points and false for all points.
 /// </summary>
 /// <param name="searchForFreePoints"></param>
 /// <returns></returns>
 public Vector2 GetRandomLocation(bool searchForFreePoints, List<SpawnPoint> points, bool setTaken)
 {
     if (points.IsNullOrEmpty())
     {
         return Vector2.zero;
     }
     SpawnPoint temp = points[(Random.Range(0, points.Count - 1))];
     temp.taken = setTaken;
     return temp.location;
 }
        public void IsNullOrEmpty_OneItemEnumerable_ReturnsFalse()
        {
            // arrange
            IEnumerable<object> oneItemEnumerable = new List<object> {new object()};

            // act

            // assert
            Assert.False(oneItemEnumerable.IsNullOrEmpty());
        }
        public void IsNullOrEmpty_EmptyEnumerable_ReturnsTrue()
        {
            // arrange
            IEnumerable<object> emptyEnumerable = new List<object>();

            // act

            // assert
            Assert.True(emptyEnumerable.IsNullOrEmpty());
        }
Example #13
0
        public ActionResult CreatePackage(string newPkgName, string newFunctions, string newMaterials, string newCompanies)
        {
            try
            {
                Package newPkg = new Package {PackageName = newPkgName};
                StringToCollections(newPkg, newMaterials, newFunctions, newCompanies);

                //check for repeated functions in packages
                List<string> repeatedPackageNames = new List<string>();
                List<string> repeatedFunctionNames = new List<string>();
                IEnumerable<Employee_Function> tmpFunctionsInt;
                foreach (Package aPackage in DB.Packages)
                {
                    tmpFunctionsInt = aPackage.Functions.Intersect(newPkg.Functions);
                    if (tmpFunctionsInt.Any())
                    {
                        repeatedPackageNames.Add(aPackage.PackageName);
                        foreach (Employee_Function aFunction in tmpFunctionsInt)
                        {
                            if (!repeatedFunctionNames.Contains(aFunction.Label))
                            {
                                repeatedFunctionNames.Add(aFunction.Label);
                            }
                        }
                    }
                }

                if (!repeatedPackageNames.IsNullOrEmpty())
                {
                    return new HttpStatusCodeResult(HttpStatusCode.Conflict, "Packages " + String.Join(", ", repeatedPackageNames)
                        + " already have the following functions: " + String.Join(", ", repeatedFunctionNames));
                }

                newPkg.CreatedDate = DateTime.Now;
                DB.Packages.Add(newPkg);
                DB.SaveChanges();

                Dictionary<string, string> rowInfo = new Dictionary<string, string>();
                rowInfo.Add("id", newPkg.PackageId.ToString());
                rowInfo.Add("pkgName", newPkg.PackageName);
                rowInfo.Add("materials", String.Join(" | ", newPkg.GenericMaterials.ToDictionary(mat => mat.GenericMaterialId, mat => mat.Label).Values));
                rowInfo.Add("functions", String.Join(" | ", newPkg.Functions.ToDictionary(fun => fun.FunctionId, fun => fun.Label).Values));
                rowInfo.Add("companies", newPkg.Companies.Any() ? String.Join(" | ", newPkg.Companies.ToDictionary(com => com.ID, com => com.CompanyCodeName).Values) : "All Companies");
                rowInfo.Add("deleteLink", Url.Action("Delete", "Package"));
                rowInfo.Add("editLink", Url.Action("GetPackageDetails", "Package"));

                return Json(rowInfo);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message);
            }
        }
	public void GainItem(List<string> args)
	{
		if(args.IsNullOrEmpty())
			throw new ArgumentNullException("GainItem requires a list containing the item to gain, and the quantity.");

		string itemName = args[0];
		int quantity = Convert.ToInt32(args[1]);

		InventoryItem item = _itemDatabase.FindItemWithName(itemName);
		if(item != default(InventoryItem))
			_inventory.GainItem(item, quantity);

		DebugMessage("Could not find item " + itemName + " in the inventory database.", LogLevel.LogicError);
	}
        public static string GenerateFilterLocationRequest(List<ILocation> locations)
        {
            if (locations.IsNullOrEmpty())
            {
                return String.Empty;
            }

            StringBuilder queryBuilder = new StringBuilder();
            // queryBuilder.Append("locations=");
            for (int i = 0; i < locations.Count - 1; ++i)
            {
                queryBuilder.Append(GenerateLocationParameters(locations[i], false));
            }

            queryBuilder.Append(GenerateLocationParameters(locations[locations.Count - 1], true));

            return String.Format("locations={0}", StringFormater.UrlEncode(queryBuilder.ToString()));
        }
Example #16
0
 /// <summary>
 /// 获得数据类型
 /// </summary>
 /// <param name="dbType"></param>
 /// <returns></returns>
 public static string GetDataType(string dbType)
 {
     List<string> list = new List<string>()
     {
         "varchar","nvarchar","text","datetime","int"
     };
     StringBuilder sb = new StringBuilder();
     string menuTemplate = "<option value='{0}' {1}>{2}</option>";
     sb.AppendFormat(menuTemplate, "", "", "请选择");
     if (!list.IsNullOrEmpty())
     {
         foreach (string item in list)
         {
             sb.AppendFormat(menuTemplate, item, item == dbType ? "selected='selected'" : string.Empty, item);
         }
     }
     return sb.ToString();
 }
        public static string GenerateFilterTrackRequest(List<string> tracks)
        {
            if (tracks.IsNullOrEmpty())
            {
                return String.Empty;
            }

            StringBuilder queryBuilder = new StringBuilder();
            queryBuilder.Append("track=");
            for (int i = 0; i < tracks.Count - 1; ++i)
            {
                queryBuilder.Append(Uri.EscapeDataString(String.Format("{0},", tracks.ElementAt(i))));
            }

            queryBuilder.Append(Uri.EscapeDataString(tracks.ElementAt(tracks.Count - 1)));

            return queryBuilder.ToString();
        }
        public static string GenerateFilterFollowRequest(List<long?> followUserIds)
        {
            if (followUserIds.IsNullOrEmpty())
            {
                return String.Empty;
            }

            StringBuilder queryBuilder = new StringBuilder();
            queryBuilder.Append("follow=");
            for (int i = 0; i < followUserIds.Count - 1; ++i)
            {
                queryBuilder.Append(Uri.EscapeDataString(String.Format("{0},", followUserIds.ElementAt(i))));
            }

            queryBuilder.Append(followUserIds.ElementAt(followUserIds.Count - 1));

            return queryBuilder.ToString();
        }
Example #19
0
        /// <summary>
        /// 添加客户信息
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public int AddCustomer(CustomerEntity entity, List<CusAddressEntity> list)
        {
            entity.IncludeAll();
            int line = this.Customer.Add(entity);
            if (!list.IsNullOrEmpty())
            {
                list.ForEach(a =>
                {
                    a.CusNum = entity.CusNum;
                    a.IncludeAll();
                });
                line += this.CusAddress.Add(list);

            }
            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_CUSADDRESS_CACHE);
            }
            return line;
        }
Example #20
0
        public void SaveOrUpdate(List<ImageEntity> images)
        {
            if (images.IsNullOrEmpty())
            {
                return;
            }
            foreach (ImageEntity image in images)
            {
                if (image.Tags.IsEmpty() && image.New)
                {
                    continue;
                }
                TagCache.Instance.SaveOrUpdate(image.Tags);
            }

            List<ImageEntity> forRemove = images.Where(x => x.Tags.IsEmpty() && x.New == false).ToList();
            List<ImageEntity> forAddOrUpdate = images.Where(x => x.Tags.IsNotEmpty()).ToList();

            Database.Remove(forRemove);
            Database.AddOrUpdate(forAddOrUpdate);
        }
Example #21
0
        /// <summary>
        /// Gets the chart path with ma selective period or frame
        /// </summary>     
        private string GetChartPath(string contractCode, Period periodSize, FrameSize frameSize, List<int> movingAverages)
        {
            var period = string.Empty;
            var indicatorString = string.Empty;
            switch (periodSize)
            {
                case Period.Daily: period = "DO"; break;
                case Period.Weekly: period = "WN"; break;
                case Period.Monthly: period = "MN"; break;
            }
            if (!string.IsNullOrEmpty(period)) period = "&p=" + period;
            var indexes = new[] {string.Empty, "L", "O", "M", "H", "X" };
            var selectedValue = (int) frameSize;
            var frame = "&d=" +indexes[selectedValue];

            if (!movingAverages.IsNullOrEmpty())
            {
                indicatorString += "&indicators=";
                indicatorString = movingAverages.Where(indicatorSma => indicatorSma > 1).Aggregate(indicatorString, (current, indicatorSma) => current + string.Format("SMA({0},11650);", indicatorSma));
            }
            if (string.IsNullOrEmpty(contractCode)) return string.Empty;
            var address = string.Format("http://www.barchart.com/chart.php?sym={0}&style=technical{1}{3}&sd=&ed=&size=M&log=0&t=BAR&v=2&g=1&evnt=1&late=1&sh=100{2}&txtDate=#jump", contractCode.ToUpper(), period, indicatorString,frame);
            return address;
        }
Example #22
0
 /// <summary>
 /// 批量删除
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public int Delete(List<string> list)
 {
     if (!list.IsNullOrEmpty())
     {
         ReportsEntity entity = new ReportsEntity();
         entity.IsDelete = (int)EIsDelete.Deleted;
         entity.IncludeIsDelete(true);
         entity.Where("ReportNum", ECondition.In, list.ToArray());
         int line = this.Reports.Update(entity);
         return line;
     }
     return 0;
 }
Example #23
0
        /// <summary>
        /// 修改报表格式
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public int Update(ReportsEntity entity, List<ReportParamsEntity> list)
        {
            int line = 0;
            using (TransactionScope ts = new TransactionScope())
            {
                ReportParamsEntity param = new ReportParamsEntity();
                param.Where(a => a.ReportNum == entity.ReportNum);
                line += this.ReportParams.Delete(param);

                entity.Include(a => new { a.ReportName, a.ReportType, a.Remark, a.DataSource, a.DsType, a.FileName });
                entity.Where(a => a.ReportNum == entity.ReportNum);
                line += this.Reports.Update(entity);

                if (!list.IsNullOrEmpty())
                {
                    foreach (ReportParamsEntity item in list)
                    {
                        item.ParamNum = item.ParamNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReportParamsEntity)) : item.ParamNum;
                        item.ReportNum = entity.ReportNum;
                        item.IncludeAll();
                    }
                    this.ReportParams.Add(list);
                }
                ts.Complete();
            }

            return line;
        }
Example #24
0
 private static void UpdatePhone(int contactId, List<string> mobiles)
 {
     if (mobiles.IsNullOrEmpty()) return;
     var listPhones = PhoneRepository.GetByContact(contactId) ?? new List<PhoneInfo>();
     foreach (var mobile in mobiles
         .Where(c => !c.IsStringNullOrEmpty())
         .Where(c => !listPhones.Exists(p => p.PhoneNumber.Equals(c))))
     {
         if (!listPhones.Exists(c => c.PhoneType.ToInt32() == (int)PhoneType.HomePhone))
         {
             var phone = new PhoneInfo
                             {
                                 IsPrimary = 0,
                                 PhoneNumber = mobile,
                                 ContactId = contactId,
                                 PhoneType = ((int)PhoneType.HomePhone).ToString(),
                             };
             PhoneRepository.Create(phone);
             listPhones.Add(phone);
         }
         if (!listPhones.Exists(c => c.PhoneType.ToInt32() == (int)PhoneType.MobilePhone))
         {
             var phone = new PhoneInfo
             {
                 IsPrimary = 0,
                 PhoneNumber = mobile,
                 ContactId = contactId,
                 PhoneType = ((int)PhoneType.MobilePhone).ToString(),
             };
             PhoneRepository.Create(phone);
             listPhones.Add(phone);
         }
         if (!listPhones.Exists(c => c.PhoneType.ToInt32() == (int)PhoneType.Tel))
         {
             var phone = new PhoneInfo
             {
                 IsPrimary = 0,
                 PhoneNumber = mobile,
                 ContactId = contactId,
                 PhoneType = ((int)PhoneType.Tel).ToString(),
             };
             PhoneRepository.Create(phone);
             listPhones.Add(phone);
         }
     }
 }
 public void SwitchSpouses(List<Guid> marriageIds)
 {
     if (!marriageIds.IsNullOrEmpty())
         _marriagesDll.SwapSpouses(marriageIds);
 }
 public void IsNullOrEmptyTest()
 {
     List<int> Temp = new List<int>();
     Assert.True(Temp.IsNullOrEmpty());
     Temp = null;
     Assert.True(Temp.IsNullOrEmpty());
     Temp = new int[] { 1, 2, 3 }.ToList();
     Assert.False(Temp.IsNullOrEmpty());
 }
Example #27
0
        private void UploadAppBits(string name, DirectoryInfo path)
        {
            /*
             * Before creating the app, ensure we can build resource list
             */
            string uploadFile = Path.GetTempFileName();
            DirectoryInfo explodeDir = Utility.GetTempDirectory();

            ProcessPath(path, explodeDir);

            try
            {
                var resources = new List<Resource>();
                ulong totalSize = AddDirectoryToResources(resources, explodeDir, explodeDir.FullName);

                if (false == resources.IsNullOrEmpty())
                {
                    Resource[] appcloudResources = null;
                    if (totalSize > (64*1024))
                    {
                        appcloudResources = CheckResources(resources.ToArray());
                    }
                    if (appcloudResources.IsNullOrEmpty())
                    {
                        appcloudResources = resources.ToArrayOrNull();
                    }
                    else
                    {
                        foreach (Resource r in appcloudResources)
                        {
                            string localPath = Path.Combine(explodeDir.FullName, r.FN);
                            var localFileInfo = new FileInfo(localPath);
                            localFileInfo.Delete();
                            resources.Remove(r);
                        }
                    }
                    if (resources.IsNullOrEmpty())
                    {
                        /*
                            If no resource needs to be sent, add an empty file to ensure we have
                            a multi-part request that is expected by nginx fronting the CC.
                         */
                        File.WriteAllText(Path.Combine(explodeDir.FullName, ".__empty__"), String.Empty);
                    }

                    var zipper = new FastZip();
                    zipper.CreateZip(uploadFile, explodeDir.FullName, true, String.Empty);
                    VcapJsonRequest request = base.BuildVcapJsonRequest(Method.PUT, Constants.AppsResource, name,
                                                                        "application");
                    request.AddFile("application", uploadFile);
                    request.AddParameter("resources", JsonConvert.SerializeObject(appcloudResources.ToArrayOrNull()));
                    IRestResponse response = request.Execute();
                }
            }
            finally
            {
                Directory.Delete(explodeDir.FullName, true);
                File.Delete(uploadFile);
            }
        }
		/// <summary>
		/// Removes the specified nodes from the tree view.
		/// </summary>
		/// <remarks>
		/// The user is asked to confirm the removal.
		/// </remarks>
		/// <param name="p_lstNodes">The nodes to remove.</param>
		public void RemoveNodes(IList<TreeNode> p_lstNodes)
		{
			//make a copy in case removing nodes changes the given p_lstNodes
			List<TreeNode> lstNodesToRemove = new List<TreeNode>(p_lstNodes);
			if (lstNodesToRemove.IsNullOrEmpty())
				return;
			string strMessage = null;
			if (lstNodesToRemove.Count == 1)
				strMessage = String.Format("Are you sure you want to removed '{0}?'", lstNodesToRemove[0].Text);
			else
				strMessage = String.Format("Are you sure you want to removed the {0} selected nodes?", lstNodesToRemove.Count);
			if (MessageBox.Show(this.FindForm(), strMessage, "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
			{
				FileSystemTreeNode tndNode = null;
				for (Int32 i = lstNodesToRemove.Count - 1; i >= 0; i--)
				{
					tndNode = (FileSystemTreeNode)lstNodesToRemove[i];
					tndNode.Remove();
					OnNodeRemoved(new NodesChangedEventArgs(tndNode));
				}
			}
		}
        public static TemplateTree.StandardValidTerm ToStandardValidTerm(List<aim4_dotnet.iso_21090.CD> codes)
        {
            if (codes.IsNullOrEmpty())
                return null;

            var firstCode = codes.First();
            return new TemplateTree.StandardValidTerm(
                ToStandardCodeSequence(firstCode),
                new List<TemplateTree.StandardValidTerm>
                    {
                        ToStandardValidTerm(codes.Where(code => !Equals(code, firstCode)).ToList())
                    });
        }
        private static bool IsNullCodeList(List<aim4_dotnet.iso_21090.CD> codeList)
        {
            if (codeList.IsNullOrEmpty())
                return false;

            return AimTemplateTreeUtilities.IsNullCodeSequence(ToStandardCodeSequence(codeList.First()));
        }