Exemple #1
0
        public ActionResult EditMetadata()
        {
            List <ReportParamsEntity> list = WebUtil.GetFormObject <List <ReportParamsEntity> >("list", null);

            list = list.IsNull() ? new List <ReportParamsEntity>() : list;
            List <ReportParamsEntity> listSource = Session[CacheKey.JOOSHOW_REPORTPARAM_CACHE] as List <ReportParamsEntity>;

            listSource = listSource.IsNull() ? new List <ReportParamsEntity>() : listSource;

            foreach (ReportParamsEntity item in list)
            {
                if (listSource.Exists(a => a.ParamNum == item.ParamNum))
                {
                    ReportParamsEntity entity = listSource.First(a => a.ParamNum == item.ParamNum);
                    entity.ParamData    = item.ParamData;
                    entity.DefaultValue = item.DefaultValue;
                    entity.ParamElement = item.ParamElement;
                    entity.ShowName     = item.ShowName;
                }
            }
            Session[CacheKey.JOOSHOW_REPORTPARAM_CACHE] = listSource;
            this.ReturnJson.AddProperty("Key", "1000");
            this.ReturnJson.AddProperty("Value", "编辑成功");
            return(Content(this.ReturnJson.ToString()));
        }
        public ActionResult Print()
        {
            string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty);
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();

            entity.OrderNum = orderNum;
            entity          = bill.GetOrder(entity);
            entity          = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity  = entity;

            OutStoDetailEntity detail = new OutStoDetailEntity();

            detail.OrderNum = orderNum;
            List <OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);

            listResult = listResult.IsNull() ? new List <OutStoDetailEntity>() : listResult;
            OrderProvider orderProvider = new OrderProvider();

            foreach (OutStoDetailEntity item in listResult)
            {
                OrderDetailEntity orderDetail = new OrderDetailEntity();
                orderDetail.Where(a => a.SnNum == item.ContractSn).And(a => a.OrderNum == item.ContractOrder);
                orderDetail = orderProvider.GetOrderDetail(orderDetail);
                if (orderDetail != null)
                {
                    item.Qty = orderDetail.Num;
                }
            }
            ViewBag.Detail = listResult;
            return(View());
        }
        public ActionResult AddProduct()
        {
            List <InventoryDetailEntity> listDetail = Session[SessionKey.SESSION_CHECK_DETAIL] as List <InventoryDetailEntity>;

            listDetail = listDetail.IsNull() ? new List <InventoryDetailEntity>() : listDetail;

            List <InventoryDetailEntity> list = WebUtil.GetFormObject <List <InventoryDetailEntity> >("List");

            if (!list.IsNullOrEmpty())
            {
                foreach (InventoryDetailEntity item in list)
                {
                    item.SnNum = item.SnNum.IsEmpty() ? ConvertHelper.NewGuid() : item.SnNum;
                    if (!listDetail.Exists(a => a.TargetNum == item.TargetNum))
                    {
                        item.StorageNum = this.DefaultStorageNum;
                        item.CreateTime = DateTime.Now;
                        item.CompanyID  = this.CompanyID;
                        listDetail.Add(item);
                    }
                }
            }
            Session[SessionKey.SESSION_CHECK_DETAIL] = listDetail;
            DataResult dataResult = new DataResult()
            {
                Code    = (int)EResponseCode.Success,
                Message = "响应成功"
            };

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Exemple #4
0
    public static void CreateTextureArray()
    {
        GameObject[] objSelectArray = Selection.gameObjects;
        if (objSelectArray.IsNull())
        {
            return;
        }
        List <Texture2D> listTex = new List <Texture2D>();

        foreach (var itemData in objSelectArray)
        {
            Texture2D tex2D = itemData.GetComponent <Texture2D>();
            if (tex2D != null)
            {
                listTex.Add(tex2D);
            }
        }
        if (listTex.IsNull())
        {
            return;
        }
        Texture2DArray texture2DArray = new Texture2DArray(
            listTex[0].width,
            listTex[0].height,
            listTex.Count,
            TextureFormat.RGBA32,
            true,
            false);
    }
Exemple #5
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (rtbSourceText.Text.IsNullOrEmpty())
            {
                WinFormControlHelper.AddLog(rtbLog, "请输入文本!!!", "");
            }

            WinFormControlHelper.AddLog(rtbLog, "开始分词", "");
            List <string> lsStrResult = PanGuSegmentHelper.SegmentToStringList(rtbSourceText.Text);

            if (lsStrResult.IsNull())
            {
                WinFormControlHelper.AddLog(rtbLog, "无分词结果!!!", "");
                return;
            }

            WinFormControlHelper.AddLog(rtbLog, "分词数", lsStrResult.Count.ToString());
            HashSet <string> hsStrResult = new HashSet <string>();

            foreach (string str in lsStrResult)
            {
                hsStrResult.Add(str);
            }

            WinFormControlHelper.AddLog(rtbLog, "不重复数", hsStrResult.Count.ToString());
            string strResult = "";

            foreach (string str in hsStrResult)
            {
                strResult += str + "\r\n";
            }
            rtbResultText.Text = strResult;
        }
        public ActionResult Auto(string cusName)
        {
            CustomerProvider      provider = new CustomerProvider();
            List <CustomerEntity> list     = provider.GetList();

            if (!list.IsNullOrEmpty() && !cusName.IsEmpty())
            {
                list = list.Where(a => a.CusNum.Contains(cusName) || a.CusName.Contains(cusName)).ToList();
            }
            list = list.IsNull() ? new List <CustomerEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (CustomerEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("CusNum", t.CusNum);
                jsonObject.AddProperty("CusName", t.CusName);
                //jsonObject.AddProperty("Phone", t.Phone);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
Exemple #7
0
        public void SaveActivityLogToCache(ActivityLog activityLog)
        {
            string cacheKey = string.Format("UserSessionActivity.{0}.{1}", WebHelper.GetUserName(), HttpContext.Current.Session.SessionID);

            Dictionary <string, object> cachedObject = this.cacheManager.Get(cacheKey) as Dictionary <string, object>;

            if (cachedObject.IsNull())
            {
                this.logger.Error("The session summary data could not be found from cache");

                return;
            }

            List <ActivityLog> activityLogs = new List <ActivityLog>();

            if (cachedObject.ContainsKey("ActivityLogs"))
            {
                activityLogs = cachedObject["ActivityLogs"] as List <ActivityLog>;

                if (activityLogs.IsNull())
                {
                    this.logger.Error("The activity logs could not be found from cached session summary");

                    return;
                }

                activityLog.ActivityLogType = this.FindActivityTypeById(activityLog.ActivityLogTypeId);
                activityLogs.Add(activityLog);
            }
        }
        public ClsRelevantObject Get(string objname, bool AllowEverything, out int FoundIDX, List <ClsRelevantObject> ObjList = null)
        {
            if (ObjList.IsNull())
            {
                ObjList = this.ObjectList;
            }

            FoundIDX = -1;
            //Get only by label name
            for (int i = 0; i < ObjList.Count; i++)
            {
                if (ObjList[i].Name.EqualsIgnoreCase(objname))
                {
                    FoundIDX = i;
                    return(ObjList[i]);
                }
            }

            if (AllowEverything)
            {
                for (int i = 0; i < ObjList.Count; i++)
                {
                    if (ObjList[i].Name.EqualsIgnoreCase("everything"))
                    {
                        FoundIDX = i;
                        return(ObjList[i]);
                    }
                }
            }

            return(null);
        }
Exemple #9
0
        public override StringBuilder CreateDelete <T>(List <T> models)
        {
            if (models.IsNull())
            {
                throw new ArgumentNullException("param is null");
            }
            var model = models.FirstOrDefault();

            if (model.IsNull())
            {
                throw new ArgumentNullException("param is null");
            }
            var type  = model.GetType();;
            var field = type.GetFieldByKey();
            var r     = new StringBuilder();

            r.Append($@"DELETE FORM {type.SelectTableName()} WHERE");
            r.Append($@"{(field.GetCustomAttributes(typeof(FieldAttribute), false)[0] as FieldAttribute).FieldName}");
            r.Append("in(");
            models.ForEach(f =>
            {
                r.Append($"'{type.GetProperty(field.Name).GetValue(f, null) ?? ""}',");
            });
            r = new StringBuilder(r.ToString().TrimEnd(',')).Append(")");
            return(r);
        }
        public async Task <IActionResult> Edit(List <string> Photos, List <string> DeletePhotos, int ClientId, string Name)
        {
            Client client = await _context.Clients.Where(w => w.Id == ClientId).FirstOrDefaultAsync();

            if (!DeletePhotos.IsNull() && !DeletePhotos.IsNullOrEmpty())
            {
                foreach (string deletePhoto in DeletePhotos)
                {
                    if (client.Logo == deletePhoto)
                    {
                        string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Uploads", "Clients", deletePhoto);
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                        client.Logo = null;
                    }
                }
            }

            if (!Photos.IsNull() && !Photos.IsNullOrEmpty())
            {
                foreach (string addPhoto in Photos)
                {
                    client.Logo = addPhoto;
                }
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemple #11
0
        public static bool SilmeYetkisi(List <UserPerm> permList, string formName, params object[] kontroller)
        {
            bool sonuc = false;

            if (permList.IsNull())
            {
                sonuc = false;
            }

            if (permList.Any(x => x.PermName == formName && x.Deleting == true))
            {
                sonuc = true;
            }
            else
            {
                sonuc = false;
            }

            foreach (var kontrol in kontroller)
            {
                if (kontrol is BarItem)
                {
                    (kontrol as BarItem).Enabled = sonuc;
                }
                else if (kontrol is Control)
                {
                    (kontrol as Control).Enabled = sonuc;
                }
                else if (kontrol is ToolStripMenuItem)
                {
                    (kontrol as ToolStripMenuItem).Enabled = sonuc;
                }
            }
            return(sonuc);
        }
Exemple #12
0
        public static bool OkumaYetkisi(List <UserPerm> permList, string formName, params object[] kontroller)
        {
            bool sonuc = false;

            if (permList.IsNull())
            {
                sonuc = false;
            }

            if (permList.Any(x => x.PermName == formName && x.Reading == true))
            {
                sonuc = true;
            }
            else
            {
                sonuc = false;
            }

            foreach (var kontrol in kontroller)
            {
                if (kontrol is BarItem)
                {
                    (kontrol as BarItem).Visibility = sonuc ? BarItemVisibility.Always : BarItemVisibility.Never;
                }
                else if (kontrol is Control)
                {
                    (kontrol as Control).Visible = sonuc;
                }
                else if (kontrol is ToolStripMenuItem)
                {
                    (kontrol as ToolStripMenuItem).Visible = sonuc;
                }
            }
            return(sonuc);
        }
        public ClsRelevantObject Get(ClsRelevantObject roobj, bool AllowEverything, out int FoundIDX, bool ExactMatchOnly, List <ClsRelevantObject> ObjList = null)
        {
            if (ObjList.IsNull())
            {
                ObjList = this.ObjectList;
            }

            //look for exact hashcode first
            FoundIDX = ObjList.IndexOf(roobj);

            if (FoundIDX > -1)
            {
                return(ObjList[FoundIDX]);
            }

            //search for the last hashcode in case the object has changed
            for (int i = 0; i < ObjList.Count; i++)
            {
                if (ObjList[i].LastHashCode != 0 && ObjList[i].LastHashCode == roobj.LastHashCode && !roobj.Name.EqualsIgnoreCase("new object"))
                {
                    FoundIDX = i;
                    return(ObjList[i]);
                }
            }

            //fall back to name only search
            if (!ExactMatchOnly)
            {
                return(this.Get(roobj.Name, AllowEverything, out FoundIDX, ObjList));
            }

            return(null);
        }
Exemple #14
0
        public static IOutcome <List <PlayerMod> > GetModsFromIdList(ZelusDbContext db, List <int> modIds)
        {
            //Only allow saving of exactly 6 mods for a modset
            if (modIds.IsNull() || modIds.Count != 6)
            {
                return(Outcomes.Failure <List <PlayerMod> >()
                       .WithMessage("Can only save 6 mods to a mod set."));
            }

            var mods = db.PlayerMods
                       .Where(pm => modIds.Contains(pm.Id))
                       .ToList();

            //Only allow 1 of each slot of mods
            if (mods.Count(pm => pm.SlotId == (int)ModSlots.Square) != 1 ||
                mods.Count(pm => pm.SlotId == (int)ModSlots.Arrow) != 1 ||
                mods.Count(pm => pm.SlotId == (int)ModSlots.Diamond) != 1 ||
                mods.Count(pm => pm.SlotId == (int)ModSlots.Triangle) != 1 ||
                mods.Count(pm => pm.SlotId == (int)ModSlots.Circle) != 1 ||
                mods.Count(pm => pm.SlotId == (int)ModSlots.Cross) != 1)
            {
                return(Outcomes.Failure <List <PlayerMod> >()
                       .WithMessage("Can only save 1 mod per slot."));
            }

            return(Outcomes.Success <List <PlayerMod> >()
                   .WithValue(mods));
        }
Exemple #15
0
        public ActionResult AutoProduct(string productName)
        {
            ProductProvider      provider = new ProductProvider();
            List <ProductEntity> list     = provider.GetListByCache();

            if (!list.IsNullOrEmpty() && !productName.IsEmpty())
            {
                list = list.Where(a => a.ProductName.Contains(productName) || a.BarCode.Contains(productName) || a.SnNum.Contains(productName)).ToList();
            }
            list = list.IsNull() ? new List <ProductEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (ProductEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("BarCode", t.BarCode);
                jsonObject.AddProperty("ProductName", t.ProductName);
                jsonObject.AddProperty("SnNum", t.SnNum);
                jsonObject.AddProperty("CateNum", t.CateNum);
                jsonObject.AddProperty("CateName", t.CateName);
                jsonObject.AddProperty("InPrice", t.InPrice);
                jsonObject.AddProperty("Unit", t.UnitNum);
                jsonObject.AddProperty("UnitName", t.UnitName);
                jsonObject.AddProperty("Size", t.Size);
                jsonObject.AddProperty("Num", t.Num);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
        public ActionResult CateList()
        {
            string cateName  = WebUtil.GetFormValue <string>("cateName", string.Empty);
            int    pageIndex = WebUtil.GetFormValue <int>("pageIndex", 0);
            int    pageSize  = WebUtil.GetFormValue <int>("pageSize", 0);
            ProductCategoryProvider provider = new ProductCategoryProvider();
            ProductCategoryEntity   entity   = new ProductCategoryEntity();

            if (!cateName.IsEmpty())
            {
                entity.Begin <ProductCategoryEntity>()
                .Where <ProductCategoryEntity>("CateNum", ECondition.Like, "%" + cateName + "%")
                .Or <ProductCategoryEntity>("CateName", ECondition.Like, "%" + cateName + "%")
                .End <ProductCategoryEntity>()
                ;
            }
            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            List <ProductCategoryEntity> list = provider.GetList(entity, ref pageInfo);

            list = list.IsNull() ? new List <ProductCategoryEntity>() : list;
            string     json       = ConvertJson.ListToJson <ProductCategoryEntity>(list, "data");
            JsonObject jsonObject = new JsonObject(json);

            this.ReturnJson.AddProperty("list", jsonObject);
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
        /// <summary>
        /// Installs the updates by calling the updater app and shutting down this application.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        private void LaunchUpdaterApp(List <GitHubFileInfo> updates)
        {
            if (updates.IsNull())
            {
                throw new ArgumentNullException(nameof(updates));
            }
            if (updates.Count == 0)
            {
                this.OnUpToDate();
                return;
            }

            if (!this.OnUpdatesAvailable($"{updates.Count} updates found.{Environment.NewLine}Proceed with download?"))
            {
                return;
            }

            try
            {
                var instructions = this.MakeLocalCopies(updates); // OperationFailedException.
                var server       = new UpdaterServer();
                if (!server.Run("UpdaterApp.exe", instructions))
                {
                    this.OnFailed($"Updater error: {server.LastErrorMessage}.");
                    return;
                }
                App.Current.Shutdown();
            }
            catch (OperationFailedException e)
            {
                var message = e.InnerException.IsNull() ? e.Message : e.InnerException.Message;
                this.OnFailed($"Updater error: {message}.");
            }
        }
Exemple #18
0
        /// <summary>
        /// 获得某个角色的权限
        /// </summary>
        /// <param name="RoleNum"></param>
        /// <returns></returns>
        public List <SysResourceEntity> GetRoleResource(string RoleNum)
        {
            List <SysResourceEntity> ListResult = CacheHelper.Get(string.Format(CacheKey.JOOSHOW_ROLEPOWER_CACHE, RoleNum)) as List <SysResourceEntity>;

            if (ListResult.IsNullOrEmpty())
            {
                SysResourceProvider      provider   = new SysResourceProvider();
                List <SysResourceEntity> ListSource = provider.GetList();
                ListSource = ListSource.IsNull() ? new List <SysResourceEntity>() : ListSource;

                ListSource = JsonConvert.DeserializeObject <List <SysResourceEntity> >(JsonConvert.SerializeObject(ListSource));

                List <SysRelationEntity> ListRole = GetList(RoleNum);
                ListRole = ListRole.IsNull() ? new List <SysRelationEntity>() : ListRole;

                ListResult = ListSource.Where(a => ListRole.Exists(b => b.ResNum == a.ResNum)).ToList();

                //超级管理员权限
                if (RoleNum == ResourceManager.GetSettingEntity("Super_AdminRole").Value)
                {
                    ListResult = ListSource;
                }

                if (!ListResult.IsNullOrEmpty())
                {
                    CacheHelper.Insert(string.Format(CacheKey.JOOSHOW_ROLEPOWER_CACHE, RoleNum), ListResult, null, DateTime.Now.AddDays(1));
                }
            }
            return(ListResult);
        }
Exemple #19
0
 /// <summary>
 ///
 /// </summary>
 public void InitControl()
 {
     if (controlTrades.IsNull())
     {
         controlTrades = new List <long>();
     }
 }
        public List<PropertyMatch> GetPropertyMatches(List<PropertyMatchCriteria> propertyMatchCriteria)
        {
            var propertyMatches = new List<PropertyMatch>();
            foreach (var criterion in propertyMatchCriteria)
            {
                var date = new DateTime();
                DateTime.TryParse(criterion.DateCreated, out date);
                var newApplications =
                    _propertyCaselistRepository.GetApplicationsWhereRequirementsMatchProperty(
                        criterion.Area, criterion.Beds, criterion.Price,
                        criterion.PropertyReference, date);

                foreach (var application in newApplications)
                {
                    application.GeneratePropertyCaselistStatus(_propertyCaselistStatusGenererator, criterion.PropertyReference);
                }

                propertyMatches.Add(new PropertyMatch
                {
                    Applications = newApplications.ToList(),
                    Property = new Property
                    {
                        PropertyReference = criterion.PropertyReference
                    }
                });
            }

            if(propertyMatches.IsNull() || propertyMatches.IsEmpty())
                return new List<PropertyMatch>();

            return propertyMatches;
        }
Exemple #21
0
        public void Save()
        {
            if (cached.IsNullOrEmpty() || _fileLocation.IsNullOrEmpty())
            {
                return;
            }

            //Write image file to disk
            foreach (var cache in cached)
            {
                if (_saved.IsNull())
                {
                    _saved = new List <Texture2DCacheData>();
                }

                if (cache.IsNull() || cache.data.IsNull() || _saved.Contains(cache))
                {
                    continue;
                }

                SaveCacheFile(cache);
                _saved.Add(cache);
            }

            //Save Json File
            (var json, var exception) = this.ToJson();
            if (!json.IsNullOrEmpty())
            {
                json.WriteToFile(_fileLocation);
            }

            onSaved?.Invoke(this);
        }
Exemple #22
0
        public bool SaveSalesOrderDetail(List <OrderDetailDto> listDto)
        {
            if (listDto.IsNull())
            {
                return(false);
            }

            List <IOBalanceEntity.SalesOrderDetail> entity = new List <SalesOrderDetail>();

            foreach (var details in listDto)
            {
                entity.Add(new SalesOrderDetail()
                {
                    SalesOrderDetailID = details.SalesOrderDetailId,
                    SalesOrderID       = details.SalesOrderId,
                    ProductID          = (long)details.ProductId,
                    Quantity           = details.Quantity,
                    UnitID             = details.UnitId,
                    UnitPrice          = details.UnitPrice,
                    OverrideDisplay    = details.OverrideDisplay,
                    OverrideExtDisplay = details.OverrideExtDisplay
                });
            }


            if (entity.Count == 0 || !this._salesOrderDetail.BulkInsert(entity))
            {
                return(false);
            }



            return(true);
        }
        public ActionResult LoadDetail()
        {
            List <MoveOrderDetailEntity> listDetail = Session[SessionKey.SESSION_MOVE_DETAIL] as List <MoveOrderDetailEntity>;

            listDetail = listDetail.IsNull() ? new List <MoveOrderDetailEntity>() : listDetail;

            int      PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int      PageSize  = WebUtil.GetFormValue <int>("PageSize", 5);
            PageInfo pageInfo  = new PageInfo()
            {
                PageIndex = PageIndex, PageSize = PageSize
            };
            List <MoveOrderDetailEntity> listResult = listDetail.Skip((pageInfo.PageIndex - 1) * pageInfo.PageSize).Take(pageInfo.PageSize).ToList();

            pageInfo.RowCount = listDetail.Count;
            DataListResult <MoveOrderDetailEntity> dataResult = new DataListResult <MoveOrderDetailEntity>()
            {
                Code     = (int)EResponseCode.Success,
                Message  = "响应成功",
                Result   = listResult,
                PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
        /// <summary>
        /// Returns the previous business day
        /// </summary>
        /// <param name="DateTime">The @this to act on.</param>
        /// <param name="holidays">holiday calendar list</param>
        /// <returns></returns>
        public static DateTime PreviousBusinessDay(this DateTime @DateTime, List <DateTime> holidays = null)
        {
            if (holidays.IsNull())
            {
                while (true)
                {
                    if (@DateTime.IsWeekend())
                    {
                        @DateTime = @DateTime.AddDays(-1);
                    }
                    else
                    {
                        break;
                    }
                }

                return(@DateTime);
            }
            else
            {
                while (true)
                {
                    if (@DateTime.IsWeekend() || holidays.Exists(h => h.Equals(@DateTime)))
                    {
                        @DateTime = @DateTime.AddDays(-1);
                    }
                    else
                    {
                        break;
                    }
                }

                return(@DateTime);
            }
        }
Exemple #25
0
        /// <summary>
        /// 获得打印单据的数据源
        /// </summary>
        /// <param name="argOrderNum"></param>
        /// <returns></returns>
        public override DataSet GetPrint(string argOrderNum)
        {
            DataSet         ds     = new DataSet();
            InStorageEntity entity = new InStorageEntity();

            entity.SnNum = argOrderNum;
            entity       = GetOrder(entity);
            if (entity != null)
            {
                List <InStorageEntity> list = new List <InStorageEntity>();
                list.Add(entity);
                DataTable tableOrder = list.ToDataTable();
                ds.Tables.Add(tableOrder);

                InStorDetailEntity detail = new InStorDetailEntity();
                detail.OrderSnNum = argOrderNum;
                List <InStorDetailEntity> listDetail = GetOrderDetail(detail);
                listDetail = listDetail.IsNull() ? new List <InStorDetailEntity>() : listDetail;
                DataTable tableDetail = listDetail.ToDataTable();
                ds.Tables.Add(tableDetail);
            }
            else
            {
                List <InStorageEntity>    list       = new List <InStorageEntity>();
                List <InStorDetailEntity> listDetail = new List <InStorDetailEntity>();
                DataTable tableOrder = list.ToDataTable();
                ds.Tables.Add(tableOrder);

                DataTable tableDetail = listDetail.ToDataTable();
                ds.Tables.Add(tableDetail);
            }
            return(ds);
        }
        public ActionResult AddProduct()
        {
            List <MoveOrderDetailEntity> listDetail = Session[SessionKey.SESSION_MOVE_DETAIL] as List <MoveOrderDetailEntity>;

            listDetail = listDetail.IsNull() ? new List <MoveOrderDetailEntity>() : listDetail;

            List <MoveOrderDetailEntity> list = WebUtil.GetFormObject <List <MoveOrderDetailEntity> >("List");

            if (!list.IsNullOrEmpty())
            {
                list.ForEach(a =>
                {
                    a.SnNum     = ConvertHelper.NewGuid();
                    a.Amount    = a.InPrice * a.Num;
                    a.CompanyID = this.CompanyID;
                    listDetail.Add(a);
                });
            }
            Session[SessionKey.SESSION_MOVE_DETAIL] = listDetail;
            DataResult dataResult = new DataResult()
            {
                Code    = (int)EResponseCode.Success,
                Message = "响应成功"
            };

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Exemple #27
0
        /// <summary>
        /// 新增部门
        /// </summary>
        /// <returns></returns>
        public int Add(SysDepartEntity entity)
        {
            string Key = string.Format(CacheKey.JOOSHOW_SYSDEPART_CACHE, this.CompanyID);

            if (entity.ParentNum.IsEmpty())
            {
                SysDepartEntity parent = GetRoot();
                entity.ParentNum = GetRoot().SnNum;
            }
            List <SysDepartEntity> listSource = GetList();

            listSource = listSource.IsNull() ? new List <SysDepartEntity>() : listSource;
            using (TransactionScope ts = new TransactionScope())
            {
                //查询新增节点的上一个节点
                SysDepartEntity parent     = listSource.FirstOrDefault(item => item.SnNum == entity.ParentNum);
                int             rightValue = parent.Right;

                List <SysDepartEntity> listNodes = listSource.Where(item => item.Right >= rightValue).ToList();
                if (!listNodes.IsNullOrEmpty())
                {
                    foreach (SysDepartEntity item in listNodes)
                    {
                        item.Right += 2;
                        item.IncludeRight(true);
                        item.Where(b => b.SnNum == item.SnNum).And(b => item.CompanyID == this.CompanyID);
                        this.SysDepart.Update(item);
                    }
                }

                listNodes = listSource.Where(item => item.Left >= rightValue).ToList();
                if (!listNodes.IsNullOrEmpty())
                {
                    foreach (SysDepartEntity item in listNodes)
                    {
                        item.Left += 2;
                        item.IncludeLeft(true);
                        item.Where(b => b.SnNum == item.SnNum).And(b => item.CompanyID == this.CompanyID);
                        this.SysDepart.Update(item);
                    }
                }

                entity.SnNum      = ConvertHelper.NewGuid();
                entity.DepartNum  = entity.DepartNum.IsEmpty() ? new TNumProvider(this.CompanyID).GetSwiftNum(typeof(SysDepartEntity), 5) : string.Empty;
                entity.CompanyID  = this.CompanyID;
                entity.IsDelete   = (int)EIsDelete.NotDelete;
                entity.CreateTime = DateTime.Now;
                entity.Left       = rightValue;
                entity.Right      = rightValue + 1;
                entity.IncludeAll();

                int line = this.SysDepart.Add(entity);
                if (line > 0)
                {
                    CacheHelper.Remove(Key);
                }
                ts.Complete();
                return(line);
            }
        }
Exemple #28
0
        private List <Assets> HierarchyMapToAssets(List <Assets> assetList, AssetsViewModel assetViewModel)
        {
            if (assetViewModel.IsNull() || assetList.IsNull())
            {
                return(assetList);
            }

            Assets parent = assetViewModel.Map <AssetsViewModel, Assets>();

            if (!assetList.Exists(x => x.AssetsId == parent.AssetsId))
            {
                assetList.Add(parent);
            }

            var children = assetViewModel.children ?? new List <AssetsViewModel>();

            children.ForEach(v =>
            {
                var child      = v.Map <AssetsViewModel, Assets>();
                child.ParentId = parent.AssetsId;
                assetList.Add(child);

                HierarchyMapToAssets(assetList, v);
            });

            return(assetList);
        }
Exemple #29
0
 private void NullCheck()
 {
     if (_m_list.IsNull())
     {
         _m_list = new List <T>();
     }
 }
        /// <summary>
        /// Gets list of CloudTable on the account
        /// </summary>
        /// <param name="tablePrefix">table prefix to filter tables</param>
        /// <returns>List of tables</returns>
        public IList <CloudTable> GetTables(string tablePrefix = "")
        {
            List <CloudTable>      tables            = null;
            TableContinuationToken continuationToken = null;

            try
            {
                do
                {
                    var azureTables = TableClient.ListTablesSegmented(continuationToken);
                    continuationToken = azureTables.ContinuationToken;

                    if (tables.IsNull())
                    {
                        tables = new List <CloudTable>();
                    }

                    tables.AddRange(azureTables.Results);
                } while (!continuationToken.IsNull());
            }
            catch (Exception ex)
            {
                //TODO: Log exception
                throw;
            }

            return(tables);
        }
Exemple #31
0
        /// <summary>
        /// Move an item within the generic list
        /// </summary>
        /// <param name="List">The value.</param>
        /// <param name="oldIndex">Old Index</param>
        /// <param name="newIndex">New Index</param>
        public static void Move <T>(this List <T> @List, int oldIndex, int newIndex)
        {
            if (@List.IsNull() || (oldIndex == newIndex) || (0 > oldIndex) || (oldIndex >= @List.Count) || (0 > newIndex) || (newIndex >= @List.Count))
            {
                return;
            }

            var i   = 0;
            T   tmp = @List[oldIndex];

            if (oldIndex < newIndex)
            {
                for (i = oldIndex; i < newIndex; i++)
                {
                    @List[i] = @List[i + 1];
                }
            }
            else
            {
                for (i = oldIndex; i > newIndex; i--)
                {
                    @List[i] = @List[i - 1];
                }
            }

            @List[newIndex] = tmp;
        }
        private UserReportInfoModel GetUserReportParameters(UserReportViewModel userReportConfig, List<Argument> arguments = null)
        {
            try
            {
                if (!arguments.IsNull())
                    arguments = arguments.Where(arg => !arg.IsNull()).ToList();

                var reportParameters = userReportConfig.Parameters.ToList();

                //Recovering default parameters from ReportConfig
                var defaultParams = userReportConfig.ParamsDefaultConfiguration.Split(',');

                var argsResult = new List<Argument>();

                for (var i = 0; i < reportParameters.Count; i++)
                {
                    var reportParameter = reportParameters[i];

                    if (!arguments.IsNull() && arguments.Any(x => !x.IsNull()))
                    {
                        var argument = arguments.FirstOrDefault(arg => !arg.Param.IsNull() && arg.Param.Name == reportParameter.Name);

                        Argument newArg;

                        if (!argument.IsNull() && !argument.Value.IsNull())
                            newArg = argument;

                        //Check if the parameter is ID type and there is no other parameter with the same name in the Args
                        else if (reportParameter.Name.IsIdParameter())
                        {
                            var argumentId = arguments.FirstOrDefault(arg => !arg.Param.IsNull() && arg.Param.Name.IsIdParameter());

                            newArg = new Argument
                            {
                                Param = reportParameters[i],
                                Value = !argumentId.IsNull() && !argumentId.Value.IsNull() ? argumentId.Value : GetLoggedUserId()
                            };
                        }
                        else
                        {
                            newArg = new Argument
                            {
                                Param = reportParameter,
                                Value = defaultParams.TryGetValue(i)
                            };
                        }
                        argsResult.Add(newArg);
                    }
                    //Check if the parameter is ID type and there is no other parameter with the same name in the Args
                    else if (reportParameter.Name.IsIdParameter())
                    {
                        argsResult.Add(new Argument
                        {
                            Param = reportParameters[i],
                            Value = GetLoggedUserId()
                        });
                    }
                    else
                    {
                        argsResult.Add(new Argument
                        {
                            Param = reportParameter,
                            Value = defaultParams.TryGetValue(i)
                        });
                    }
                }
                return new UserReportInfoModel
                {
                    Args = argsResult,
                    ReportId = userReportConfig.ReportId,
                    UserId = userReportConfig.UserId
                };
            }
            catch (Exception exception)
            {

                return null;
            }
        }
Exemple #33
0
 /// <summary>
 /// 多线程调用 new ThreadPool().Execute(maxThreads, tasks);
 /// </summary>
 /// <param name="maxThreads"></param>
 /// <param name="tasks"></param>
 public void Execute(int maxThreads, List<ThreadStart> tasks) {
     if ((tasks.IsNull()) || (tasks.Count == 0)) return;
     _tasks = tasks;
     if (tasks.Count < maxThreads) maxThreads = tasks.Count;
     ManualResetEvent[] resetEvents = new ManualResetEvent[maxThreads];
     for (int i = 0; i < maxThreads; i++) {
         resetEvents[i] = new ManualResetEvent(false);
         new Thread(WorkerThreadProc).Start(resetEvents[i]);
     }
     WaitHandle.WaitAll(resetEvents);
 }
Exemple #34
0
 public void IsObjectNullTest()
 {
     var testObject = new List<object>();
     
     Assert.IsFalse(testObject.IsNull());
     Assert.IsTrue(nullObject.IsNull());
 }