Example #1
0
 void RemovePickupItem(TrashItem trashItem)
 {
     if (trashItem == pickup_Item)
     {
         pickup_Item = null;
     }
 }
 public void ThrowItem()
 {
     if (HasItem())
     {
         item_CurrentItem.HandleThrow();
         item_CurrentItem = null;
     }
 }
 public void ThrowItem(Vector2 direction, float force, ForceMode2D forceMode)
 {
     if (HasItem())
     {
         item_CurrentItem.HandleThrow(direction, force, forceMode);
         item_CurrentItem = null;
     }
 }
 public void DropItem()
 {
     if (HasItem())
     {
         item_CurrentItem.HandleDrop();
         item_CurrentItem = null;
     }
 }
Example #5
0
    public TrashItem GetNewTrashItem()
    {
        IncrementTrashCount();

        TrashItem t = trashItemEntries[UnityEngine.Random.Range(0, trashItemEntries.Length)];

        return(GameObject.Instantiate(t) as TrashItem);
    }
 public void ThrowItem(Vector2 velocity)
 {
     if (HasItem())
     {
         item_CurrentItem.HandleThrow(velocity);
         item_CurrentItem = null;
     }
 }
Example #7
0
    protected override void ProcessTriggerEnterWithTrashObject(TrashObject trashObject)
    {
        if (trashObject is TrashItem)
        {
            TrashItem item = trashObject as TrashItem;

            if (!item.isBoundToHuman)
            {
                SetPickupItem(item);
            }
        }
    }
Example #8
0
        public TrashItem GetTrashItemFromInventoryMapping(IEnumerable <TrashItem> trashItems, string textileName, string textileColor, IEnumerable <TextileNameMapping> textileNameMappings)
        {
            TextileNameMapping textileNameMapping        = textileNameMappings.ToList().Find(f => f.Inventory.Contains(textileName)) ?? new TextileNameMapping();
            string             accountTextileNameMapping = textileNameMapping.Account == null ? string.Empty : textileNameMapping.Account.FirstOrDefault().Split('*')[0];

            TrashItem trashItem = new TrashItem();

            trashItem = trashItems.Where(w => w.I_03 == string.Concat(accountTextileNameMapping, textileColor)).FirstOrDefault();
            if (accountTextileNameMapping != string.Empty && (trashItem == null || trashItem.I_03 == null))
            {
                trashItem = trashItems.Where(w => w.I_03.Contains(accountTextileNameMapping) && w.I_03.Contains(textileColor)).FirstOrDefault();
            }
            return(trashItem);
        }
    public void PickupItem(TrashItem item)
    {
        if (HasItem())
        {
            DropItem();
        }

        item_CurrentItem = item;

        item.CachedTransform.SetParent(bind_ItemBind, false);
        item.CachedTransform.localPosition = Vector2.zero;
        item.CachedTransform.localRotation = Quaternion.identity;

        item.HandlePickup();
    }
Example #10
0
    void GenerateTrash(int startupTrash)
    {
        for (int i = 0; i < startupTrash; i++)
        {
            Vector2 pos = GetRandomGroundedPosition();

            pos.y += worldHeight - 1f;

            startupPos.Add(pos);

            TrashItem item = GetNewTrashItem();

            item.CachedTransform.position = pos + Vector2.up * 0.5f;
            item.AddRandomTorque();
        }
    }
 public HttpResponseMessage Restore(TrashItem item)
 {
     try
     {
         repository.Restore(item.ObjectType, item.Id);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (UnauthorizedAccessException)
     {
         return(Request.CreateResponse(HttpStatusCode.Unauthorized));
     }
     catch (Exception)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }
    public void HandleHitByItem(TrashItem trashItem)
    {
        Vector2 velocity = trashItem.CachedRigidbody2D.velocity;

        if (velocity.magnitude >= killVelocity)
        {
            velocity *= killVelocityMultiplier;

            velocity += Vector2.up * killUpwardVelocity;

            SetState(HumanState.Dying);

            CachedRigidbody2D.AddTorque(UnityEngine.Random.Range(killTorqueRange.x, killTorqueRange.y), ForceMode2D.Impulse);
        }

        CachedRigidbody2D.AddForce(velocity, ForceMode2D.Impulse);
    }
Example #13
0
 // Update is called once per frame
 void Update()
 {
     if (itemsToDisposeOf.Count > 0)
     {
         foreach (TrashItem trashThing in itemsToDisposeOf)
         {
             if (Time.time - trashThing.timeSubmitted > trashThing.delayUntilDisposal)
             {
                 tempItem = trashThing;
             }
         }
         if (tempItem != null)
         {
             itemsToDisposeOf.Remove(tempItem);
             Destroy(tempItem.item);
             tempItem = null;
         }
     }
 }
    public override void HandleUpdate()
    {
        if (!IsDead() && !HasItem())
        {
            if (TrashWorld.Instance.CanGenerateTrash() && canPickupItem)
            {
                TrashItem item = TrashWorld.Instance.GetNewTrashItem();

                PickupItem(item);

                StartDropTimer();
            }
        }

        if (GetState() == HumanState.Walking)
        {
            MakeMovementDecision();
        }
    }
Example #15
0
        /// <summary>
        /// 以布種取得客戶出貨紀錄
        /// </summary>
        /// <param name="trashItem"></param>
        /// <returns></returns>
        public IEnumerable <TrashCustomerShipped> GetCustomerShippedListByFeature(TrashItem trashItem)
        {
            var sqlCmd = @"SELECT INSub.IN_DATE,INSub.Quantity,INSub.Price,CU.C_Name,INSub.Price FROM INVOSUB.dbf AS INSub
                           INNER JOIN CUST.dbf AS CU ON CU.CARD_NO = INSub.C_01
                           WHERE INSub.F_01 = @F_01 AND INSub.I_01 = @I_01";

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@F_01", SqlDbType.NVarChar)
                {
                    Value = trashItem.F_01
                },
                new SqlParameter("@I_01", SqlDbType.NVarChar)
                {
                    Value = trashItem.I_01
                }
            };
            var result = DapperHelper.QueryDbfCollection <TrashCustomerShipped>(AppSettingConfig.DbfConnectionString(), CommandType.Text, sqlCmd, parameters);

            return(result);
        }
Example #16
0
    void HandleTyreIronHitItem(TrashItem item)
    {
        if (HasItem() && item_CurrentItem == item)
        {
            return;
        }

        if (playerState.GetState() == TrashPlayerState.Hitting && !isSwingRelaxing)
        {
            Vector2 hitDirection = ((Vector2)item.CachedTransform.position - (Vector2)bind_TyreIronLookAt.position).normalized;

            float dot = Vector2.Dot(hitDirection, swing_Direction);

            float hitValue = 0f;

            dot = Mathf.Clamp(dot, 0f, PERFECT_HIT_RATIO);

            dot = dot / PERFECT_HIT_RATIO;

            hitValue = Mathf.Min(dot, current_Power_N);

            if (hitValue > PERFECT_HIT_VALUE)
            {
                hitValue = 1f;

                swing_Force = swing_Direction * (swing_Power * perfectHitPowerMultiplier);
            }
            else
            {
                swing_Force = hitDirection * (swing_Power);
            }


            item.HandleHit(hitValue, color_HitEffect_ItemHit, swing_Force);
        }
    }
Example #17
0
        public async Task <IActionResult> TrashItem(Guid listId, Guid todoId)
        {
            var userEmail = User.FindFirst(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress").Value;

            var list = await _dapperQuery.GetListAsync(listId);

            var todoListAuthorizationValidator = new TodoListAuthorizationValidator(list.Contributors, userEmail);

            if (todoListAuthorizationValidator.IsUserAuthorized())
            {
                var accountId = User.ReadClaimAsGuidValue("urn:codefliptodo:accountid");

                var trashItem = new TrashItem
                {
                    AccountId = accountId,
                    ItemId    = todoId
                };
                await _mediator.Send(trashItem);

                return(Ok());
            }

            return(Forbid());
        }
Example #18
0
        /// <summary>
        /// Get trash list
        /// </summary>
        /// <param name="trashType">Type (post, page, comment)</param>
        /// <param name="take">Take for a page</param>
        /// <param name="skip">Items to sckip</param>
        /// <param name="filter">Filter expression</param>
        /// <param name="order">Sort order</param>
        /// <returns></returns>
        public TrashVM GetTrash(TrashType trashType, int take = 10, int skip = 0, string filter = "1 == 1", string order = "DateCreated descending")
        {
            if (!Security.IsAuthorizedTo(Rights.ViewDashboard))
            {
                throw new UnauthorizedAccessException();
            }

            var trash     = new TrashVM();
            var comments  = new List <Comment>();
            var posts     = new List <Post>();
            var pages     = new List <Page>();
            var trashList = new List <TrashItem>();
            var trashPage = new List <TrashItem>();
            var query     = trashList.AsQueryable().Where(filter);

            // comments
            if (trashType == TrashType.All || trashType == TrashType.Comment)
            {
                foreach (var p in Post.Posts)
                {
                    if (!Security.IsAuthorizedTo(Rights.EditOtherUsersPosts))
                    {
                        if (p.Author.ToLower() != Security.CurrentUser.Identity.Name.ToLower())
                        {
                            continue;
                        }
                    }

                    comments.AddRange(p.DeletedComments);
                }
            }

            if (comments.Count > 0)
            {
                foreach (var c in comments)
                {
                    TrashItem t1 = new TrashItem
                    {
                        Id          = c.Id,
                        Title       = c.Author + ": " + c.Teaser,
                        RelativeUrl = c.RelativeLink,
                        ObjectType  = "Comment",
                        DateCreated = c.DateCreated.ToString("MM/dd/yyyy HH:mm")
                    };

                    trashList.Add(t1);
                }
            }

            // posts
            if (trashType == TrashType.All || trashType == TrashType.Post)
            {
                posts = (from x in Post.DeletedPosts orderby x.DateCreated descending select x).ToList();
            }

            if (posts.Count > 0)
            {
                foreach (var p in posts)
                {
                    if (!Security.IsAuthorizedTo(Rights.EditOtherUsersPosts))
                    {
                        if (p.Author.ToLower() != Security.CurrentUser.Identity.Name.ToLower())
                        {
                            continue;
                        }
                    }

                    TrashItem t2 = new TrashItem
                    {
                        Id          = p.Id,
                        Title       = System.Web.HttpContext.Current.Server.HtmlEncode(p.Title),
                        RelativeUrl = p.RelativeLink,
                        ObjectType  = "Post",
                        DateCreated = p.DateCreated.ToString("MM/dd/yyyy HH:mm")
                    };

                    trashList.Add(t2);
                }
            }

            // pages
            if (trashType == TrashType.All || trashType == TrashType.Page)
            {
                pages = (from x in Page.DeletedPages orderby x.DateCreated descending select x).ToList();
            }

            if (pages.Count > 0)
            {
                foreach (var p in pages)
                {
                    TrashItem t3 = new TrashItem
                    {
                        Id          = p.Id,
                        Title       = System.Web.HttpContext.Current.Server.HtmlEncode(p.Title),
                        RelativeUrl = p.RelativeLink,
                        ObjectType  = "Page",
                        DateCreated = p.DateCreated.ToString("MM/dd/yyyy HH:mm")
                    };

                    trashList.Add(t3);
                }
            }

            trash.TotalCount = trashList.Count;

            // if take passed in as 0, return all
            if (take == 0)
            {
                take = trashList.Count;
            }

            foreach (var item in query.OrderBy(order).Skip(skip).Take(take))
            {
                trashPage.Add(item);
            }

            trash.Items = trashPage;

            return(trash);
        }
 public HttpResponseMessage Restore(TrashItem item)
 {
     repository.Restore(item.ObjectType, item.Id);
     return(Request.CreateResponse(HttpStatusCode.OK));
 }
Example #20
0
 public CustomerOrderHistoryByFeatureDialog(TrashItem trashItem)
 {
     InitializeComponent();
     this.DataContext = new CustomerOrderHistoryByFeatureViewModel(trashItem);
 }
Example #21
0
        public ShipFeatureViewModel(string shipFeatureDate)
        {
            string defaultDate = DateTime.Now.ToString("yyyyMMdd");

            string[] dateNumber = shipFeatureDate.Split('-');

            string fileNameDate = string.Concat(AppSettingConfig.FilePath(), "\\出貨", dateNumber[0].Length > 5 ? dateNumber[0] : defaultDate, "-", dateNumber[0].Length > 5 ? dateNumber[1] : dateNumber[0], ".xlsx");
            //IEnumerable<string> shipFileName = Directory.GetFiles(AppSettingConfig.FilePath(), fileNameDate).Select(System.IO.Path.GetFileName).OrderByDescending(o => o);
            IWorkbook workbook = null;  //新建IWorkbook對象

            using (FileStream fs = new FileStream(fileNameDate, FileMode.Open, FileAccess.Read))
            {
                workbook = new XSSFWorkbook(fs);
            }

            IEnumerable <TrashItem> trashItems = TrashModule.GetTrashItems().Where(w => w.I_03 != null).OrderBy(o => o.I_01);

            ExternalDataHelper externalDataHelper = new ExternalDataHelper();
            IEnumerable <TextileNameMapping> textileNameMappings = externalDataHelper.GetTextileNameMappings();

            for (int sheetCount = 1; sheetCount < workbook.NumberOfSheets; sheetCount++)
            {
                ISheet sheet       = workbook.GetSheetAt(sheetCount); //獲取第i個工作表
                string textileName = null;
                sheet.SetColumnWidth(4, 12200);

                ICell customerCell = sheet.GetRow(4).GetCell(2);
                IEnumerable <TrashCustomer> trashCustomers = TrashModule.GetCustomerList().Where(w => customerCell.StringCellValue.Contains(w.C_NAME));
                if (trashCustomers != null && trashCustomers.FirstOrDefault() != null)
                {
                    customerCell.SetCellValue(string.Concat(customerCell.StringCellValue, "-", trashCustomers.FirstOrDefault().CARD_NO, trashCustomers.FirstOrDefault().C_NAME));
                }

                for (int rowCount = 6; rowCount <= 18; rowCount++)
                {
                    IRow row = sheet.GetRow(rowCount);
                    if (row == null)
                    {
                        break;
                    }
                    ICell textileNameCell = row.GetCell(1);
                    if (textileNameCell != null && textileNameCell.StringCellValue != null && textileNameCell.StringCellValue != "")
                    {
                        textileName = textileNameCell.StringCellValue;
                    }

                    ICell colorCell = row.GetCell(4);
                    if (colorCell == null)
                    {
                        break;
                    }
                    string colorCellValue = colorCell.CellType == CellType.String ? colorCell.StringCellValue : colorCell.NumericCellValue.ToString();
                    if (colorCellValue == null || colorCellValue == "")
                    {
                        break;
                    }

                    string textileColor       = colorCellValue.Split('-')[0];
                    int    textileColorNumber = colorCellValue.Split('-').Length >= 2 ? colorCellValue.Split('-')[1].ToInt() : 0;
                    if (textileColorNumber / 7 >= 1)
                    {
                        rowCount += textileColorNumber / 7;
                    }
                    TrashItem trashItem          = externalDataHelper.GetTrashItemFromInventoryMapping(trashItems, textileName, textileColor, textileNameMappings);
                    string    accountFactoryID   = string.Empty;
                    string    accountTextileID   = string.Empty;
                    string    accountTextileName = string.Empty;
                    if (trashItem == null)
                    {
                    }
                    else
                    {
                        accountFactoryID   = trashItem.F_01;
                        accountTextileID   = trashItem.I_01;
                        accountTextileName = trashItem.I_03;
                    }
                    string shipFeatureString = colorCellValue + "*" + accountFactoryID + "_" + accountTextileID + "-" + accountTextileName;
                    colorCell.SetCellValue(shipFeatureString);
                    IFont font = workbook.CreateFont();
                    font.Color    = HSSFColor.Blue.Index2;
                    font.FontName = "新細明體";
                    font.IsBold   = true;
                    colorCell.RichStringCellValue.ApplyFont(
                        shipFeatureString.Length - 1 - accountTextileID.Length - accountTextileName.Length
                        , shipFeatureString.Length - accountTextileName.Length - 1, font);
                }
            }

            using (FileStream fs = new FileStream(fileNameDate, FileMode.Create, FileAccess.Write))
            {
                workbook.Write(fs);
            }
        }
Example #22
0
 public void SetPickupItem(TrashItem trashItem)
 {
     pickup_Item = trashItem;
 }
Example #23
0
        /// <summary>
        /// 以布種取得客戶出貨紀錄
        /// </summary>
        /// <param name="trashItem"></param>
        /// <returns></returns>
        public IEnumerable <TrashCustomerShipped> GetCustomerShippedListByFeature(TrashItem trashItem)
        {
            IEnumerable <TrashCustomerShipped> trashCustomerShippeds = TrashAdapter.GetCustomerShippedListByFeature(trashItem);

            return(trashCustomerShippeds);
        }
Example #24
0
        private void ExportToExcel()
        {
            //建立Excel 2003檔案
            IWorkbook wb  = new XSSFWorkbook();
            ISheet    ws  = wb.CreateSheet("Class");
            XSSFRow   row = (XSSFRow)ws.CreateRow(0);

            row.Height = 440;

            ws.SetColumnWidth(0, 3000);
            ws.SetColumnWidth(1, 3150);
            ws.SetColumnWidth(2, 1700);
            ws.SetColumnWidth(4, 1700);

            ICellStyle positionStyle = wb.CreateCellStyle();

            positionStyle.WrapText          = true;
            positionStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.Center;
            positionStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;

            ICellStyle greyStyle = wb.CreateCellStyle();

            greyStyle.WrapText            = true;
            greyStyle.Alignment           = NPOI.SS.UserModel.HorizontalAlignment.Center;
            greyStyle.VerticalAlignment   = NPOI.SS.UserModel.VerticalAlignment.Center;
            greyStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
            greyStyle.FillPattern         = FillPattern.SolidForeground;

            ICellStyle lightGreenStyle = wb.CreateCellStyle();

            lightGreenStyle.WrapText            = true;
            lightGreenStyle.Alignment           = NPOI.SS.UserModel.HorizontalAlignment.Center;
            lightGreenStyle.VerticalAlignment   = NPOI.SS.UserModel.VerticalAlignment.Center;
            lightGreenStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightGreen.Index;
            lightGreenStyle.FillPattern         = FillPattern.SolidForeground;

            ICellStyle lightTurquoiseStyle = wb.CreateCellStyle();

            lightTurquoiseStyle.WrapText            = true;
            lightTurquoiseStyle.Alignment           = NPOI.SS.UserModel.HorizontalAlignment.Center;
            lightTurquoiseStyle.VerticalAlignment   = NPOI.SS.UserModel.VerticalAlignment.Center;
            lightTurquoiseStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightTurquoise.Index;
            lightTurquoiseStyle.FillPattern         = FillPattern.SolidForeground;

            ICellStyle coralStyle = wb.CreateCellStyle();

            coralStyle.WrapText            = true;
            coralStyle.Alignment           = NPOI.SS.UserModel.HorizontalAlignment.Center;
            coralStyle.VerticalAlignment   = NPOI.SS.UserModel.VerticalAlignment.Center;
            coralStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Coral.Index;
            coralStyle.FillPattern         = FillPattern.SolidForeground;

            ExcelHelper.CreateCell(row, 0, "布種", positionStyle);
            ExcelHelper.CreateCell(row, 1, "顏色", positionStyle);
            ExcelHelper.CreateCell(row, 2, "織廠", positionStyle);
            ExcelHelper.CreateCell(row, 3, "整理", positionStyle);
            ExcelHelper.CreateCell(row, 4, "出貨量", positionStyle);
            ExcelHelper.CreateCell(row, 5, "計算庫存量", positionStyle);
            ExcelHelper.CreateCell(row, 6, "時間", positionStyle);
            ExcelHelper.CreateCell(row, 7, "10天內", positionStyle);
            ExcelHelper.CreateCell(row, 8, "20天內", positionStyle);
            ExcelHelper.CreateCell(row, 9, "30天內", positionStyle);
            ExcelHelper.CreateCell(row, 10, "60天內", positionStyle);


            int                rowIndex           = 1;
            string             textileName        = string.Empty;
            ExternalDataHelper externalDataHelper = new ExternalDataHelper();
            IEnumerable <TextileNameMapping> textileNameMappings = externalDataHelper.GetTextileNameMappings();
            IEnumerable <TrashItem>          trashItems          = TrashModule.GetTrashItems().Where(w => w.I_03 != null).OrderBy(o => o.I_01);
            DateTime            tenDays                = DateTime.Now.Date.AddDays(-10);
            DateTime            twentyDays             = DateTime.Now.Date.AddDays(-20);
            DateTime            thirtyDays             = DateTime.Now.Date.AddDays(-30);
            List <TrashShipped> xtrashCustomerShippeds = TrashModule.GetTrashShippedList(DateTime.Now.AddDays(-60), DateTime.Now).ToList();

            foreach (StoreData storeData in ShippingHistoryStoreDataList)
            {
                XSSFRow rowTextile = (XSSFRow)ws.CreateRow(rowIndex);

                ExcelHelper.CreateCell(rowTextile, 0, storeData.TextileName, positionStyle);
                if (!string.IsNullOrEmpty(storeData.TextileName))
                {
                    textileName = storeData.TextileName;
                    rowIndex++;
                    continue;
                }
                TrashItem           trashItem     = externalDataHelper.GetTrashItemFromInventoryMapping(trashItems, textileName, storeData.ColorName.Split('-')[0], textileNameMappings);
                List <TrashShipped> trashShippeds = new List <TrashShipped>();
                if (trashItem != null)
                {
                    trashShippeds = xtrashCustomerShippeds.Where(w => w.I_03 == trashItem.I_03).ToList();
                }
                ExcelHelper.CreateCell(rowTextile, 1, storeData.ColorName, positionStyle);
                ExcelHelper.CreateCell(rowTextile, 2, storeData.FabricFactory, positionStyle);
                ExcelHelper.CreateCell(rowTextile, 3, storeData.ClearFactory, positionStyle);
                ExcelHelper.CreateCell(rowTextile, 4, storeData.ShippedCount.ToString(), positionStyle);
                ExcelHelper.CreateCell(rowTextile, 5, storeData.CountInventory, positionStyle);
                ExcelHelper.CreateCell(rowTextile, 6, storeData.CheckDate, positionStyle);
                ExcelHelper.CreateCell(rowTextile, 7, Math.Round(trashShippeds.Where(w => w.IN_DATE.Date >= tenDays).Sum(s => s.Quantity) / 22, 0), greyStyle);
                ExcelHelper.CreateCell(rowTextile, 8, Math.Round(trashShippeds.Where(w => w.IN_DATE.Date >= twentyDays).Sum(s => s.Quantity) / 22, 0), lightGreenStyle);
                ExcelHelper.CreateCell(rowTextile, 9, Math.Round(trashShippeds.Where(w => w.IN_DATE.Date >= thirtyDays).Sum(s => s.Quantity) / 22, 0), lightTurquoiseStyle);
                ExcelHelper.CreateCell(rowTextile, 10, Math.Round(trashShippeds.Sum(s => s.Quantity) / 22, 0), coralStyle);

                rowIndex++;
            }
            var selectedDateTime = ShippingHistoryDate == null?DateTime.Now.ToString("yyyyMMdd") : ShippingHistoryDate.ToString("yyyyMMdd");

            FileStream file = new FileStream(string.Concat(AppSettingConfig.StoreSearchFilePath(), "出貨查詢", selectedDateTime, ".xlsx"), FileMode.Create);//產生檔案

            wb.Write(file);
            file.Close();
        }
Example #25
0
 public CustomerOrderHistoryByFeatureViewModel(TrashItem trashItem)
 {
     TrashItem = trashItem;
     RaisePropertyChanged("TrashItem");
     TrashCustomerShippeds = TrashModule.GetCustomerShippedListByFeature(trashItem).OrderByDescending(o => o.IN_DATE);
 }