Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="createKeyCodeCount">생성할 건수</param>
        /// <param name="saleType">판매타입</param>
        public static int CreateProductINfo(int createKeyCodeCount, SaleType saleType)
        {
            int        result = createKeyCodeCount;
            DataAccess da     = new SQLServerDB();

            if (!da.IsConnected)
            {
                Connect(ref da);
            }
            try
            {
                ParameterEngine param = ParameterEngine.New(da);
                param.Add("@SALE_TYPE", saleType.ToString().ToUpper());
                param.Add("@KEYCODE_COUNT", createKeyCodeCount);

                string    procedureName = "SP_KEY_CODE_CREATE";
                DbCommand command       = da.GenerateCommand(procedureName, CommandType.StoredProcedure, param);
                da.ExecuteNonQuery(command);
            }
            catch (Exception ex)
            {
                WriteTextLog("CreateProductINfo", ex.Message.ToString());
                result = 0;
            }
            finally
            {
                DisConnect(ref da);
            }

            return(result);
        }
Esempio n. 2
0
 public ItemForSale(string name, string imgPath, double costPerUnit, int quantityInStock, int quantityMin,
                    double price, SaleType itemType, bool isSuitable) : base(name, imgPath, costPerUnit, quantityInStock, quantityMin)
 {
     this.price           = price;
     this.itemType        = itemType;
     this.isSuitableForVM = isSuitable;
 }
Esempio n. 3
0
        /// <summary>
        /// Muestra la ventana detalle en modo edit
        /// </summary>
        /// <history>
        /// [emoguel] 19/04/2016 Created
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            SaleType          saleType          = (SaleType)dgrSaleTypes.SelectedItem;
            frmSaleTypeDetail frmSaleTypeDetail = new frmSaleTypeDetail();

            frmSaleTypeDetail.Owner       = this;
            frmSaleTypeDetail.oldSaleType = saleType;
            frmSaleTypeDetail.enumMode    = EnumMode.Edit;
            if (frmSaleTypeDetail.ShowDialog() == true)
            {
                List <SaleType> lstSaleTypes = (List <SaleType>)dgrSaleTypes.ItemsSource;
                int             nIndex       = 0;
                if (ValidateFilter(frmSaleTypeDetail.saleType))                        //Validamos que cumpla con los filtros actuales
                {
                    ObjectHelper.CopyProperties(saleType, frmSaleTypeDetail.saleType); //Actualizamos los datos del objeto
                    lstSaleTypes.Sort((x, y) => string.Compare(x.stN, y.stN));         //Ordenamos la lista
                    nIndex = lstSaleTypes.IndexOf(saleType);                           //Obtenemos
                }
                else
                {
                    lstSaleTypes.Remove(saleType);                          //Quitamos el registro
                }
                dgrSaleTypes.Items.Refresh();                               //Actualizamos la vista
                GridHelper.SelectRow(dgrSaleTypes, nIndex);                 //Seleccionamos el registro
                StatusBarReg.Content = lstSaleTypes.Count + " Sale Types."; //Actualizamos al contador
            }
        }
        public async Task AddSaleType(SaleTypeInputDto input)
        {
            if (await db.SaleTypes.AnyAsync(m => m.Name == input.SaleTypeName && !m.IsDelete))
            {
                throw new HttpResponseException(new HttpResponseMessage()
                {
                    Content = new StringContent(JsonConvert.SerializeObject(new ResponseApi()
                    {
                        Code = EExceptionType.Implement, Message = input.SaleTypeName + "已存在"
                    }))
                });
            }

            var data = new SaleType()
            {
                Id       = IdentityManager.NewId(),
                IsDelete = false,
                Name     = input.SaleTypeName
            };

            db.SaleTypes.Add(data);

            if (await db.SaveChangesAsync() <= 0)
            {
                throw new HttpResponseException(new HttpResponseMessage()
                {
                    Content = new StringContent(JsonConvert.SerializeObject(new ResponseApi()
                    {
                        Code = EExceptionType.Implement, Message = "添加失败"
                    }))
                });
            }
        }
        public async Task <IActionResult> PutSaleType([FromRoute] int id, [FromBody] SaleType saleType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != saleType.Id)
            {
                return(BadRequest());
            }

            _context.Entry(saleType).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) {
                if (!SaleTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 6
0
        /// <summary>
        /// 사용자 정보를 가져옵니다.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static DataTable GetProductList(SaleType saleType, SearchType searchType, string keyword, string searchCount)
        {
            DataTable  dt = new DataTable();
            DataAccess da = new SQLServerDB();

            if (!da.IsConnected)
            {
                Connect(ref da);
            }
            try
            {
                string          procedureName = "SP_GET_PRODUCT_LIST";
                ParameterEngine param         = ParameterEngine.New(da);
                param.Add("@SEARCH_TYPE", searchType.ToString().ToUpper());
                param.Add("@SALE_TYPE", saleType.ToString().ToUpper());
                param.Add("@KEY_WORD", keyword);
                param.Add("@SEARCH_COUNT", searchCount);


                DbCommand command = da.GenerateCommand(procedureName, CommandType.StoredProcedure, param);
                dt = da.GetData(command);
            }
            catch (Exception ex)
            {
                WriteTextLog("GetUserList", ex.Message.ToString());
            }
            finally
            {
                DisConnect(ref da);
            }

            return(dt);
        }
Esempio n. 7
0
 public ActionResult SaleTypesSettting(SettingModel SettingModel1)
 {
     try
     {
         SaleType SaleType1 = UsersServices1.getSaleTypeById(SettingModel1.Id);
         if (SaleType1 != null)
         {
             SaleType1.Name   = SettingModel1.SaleType;
             SaleType1.Value  = Convert.ToDecimal(SettingModel1.Bonus);
             SaleType1.Active = true;
             UsersServices1.UpdateSaleType(SaleType1);
         }
         else
         {
             SaleType1        = new SaleType();
             SaleType1.Name   = SettingModel1.SaleType;
             SaleType1.Value  = Convert.ToDecimal(SettingModel1.Bonus);
             SaleType1.Active = true;
             UsersServices1.InsertSaleType(SaleType1);
         }
     }
     catch (Exception e)
     {
         e.Message.ToString();
     }
     return(RedirectToAction("DisplaySetting", new { id = 0 }));
 }
Esempio n. 8
0
        public ActionResult DisplaySetting(long Id)
        {
            ViewData["SaleTypes"] = UsersServices1.getAllSaleTypes(false);
            SettingModel SettingModel1 = new SettingModel();
            var          seting        = UsersServices1.PageSettingNumber();

            SettingModel1.PageNumber = seting == null ? "0" : seting.DataValue;
            seting = UsersServices1.getTaxCommissiong();
            SettingModel1.TaxCommistion = seting == null ? "0" : seting.DataValue;

            if (Id == 0)
            {
                return(View(SettingModel1));
            }
            SaleType SaleType1 = UsersServices1.getSaleTypeById(Id);

            if (SaleType1 != null)
            {
                SettingModel1.Id       = SaleType1.Id;
                SettingModel1.SaleType = SaleType1.Name;
                SettingModel1.Bonus    = Convert.ToDouble(SaleType1.Value.Value);
                ViewData["Action"]     = "Update";
            }
            SettingModel1.Id   = -1;
            ViewData["Action"] = "Create";
            return(View(SettingModel1));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SaleType saleType = db.SaleTypes.Find(id);

            db.SaleTypes.Remove(saleType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
 public SaleDetailApiModel(int id, string salesPerson, DateTimeOffset saleDate, SaleType saleType, PaymentType paymentType)
 {
     Id             = id;
     SalesPerson    = salesPerson;
     SaleDate       = saleDate;
     SaleType       = saleType;
     PaymentType    = paymentType;
     ProductsBought = new List <ItemSoldApiModel>();
 }
Esempio n. 11
0
        public IActionResult Update(SaleType saleType)
        {
            var result = _saleTypeService.Update(saleType);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
 public ActionResult Edit([Bind(Include = "idSaleType,type")] SaleType saleType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(saleType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(saleType));
 }
        public ActionResult Create([Bind(Include = "idSaleType,type")] SaleType saleType)
        {
            if (ModelState.IsValid)
            {
                db.SaleTypes.Add(saleType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(saleType));
        }
Esempio n. 14
0
        public ActionResult ActivateSaleType(long Id)
        {
            SaleType SaleType1 = UsersServices1.getSaleTypeById(Id);

            if (SaleType1 != null)
            {
                SaleType1.Active = true;
                UsersServices1.UpdateSaleType(SaleType1);
            }
            return(RedirectToAction("DisplaySetting", new { id = 0 }));
        }
        public async Task <IActionResult> PostSaleType([FromBody] SaleType saleType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SaleTypes.Add(saleType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSaleType", new { id = saleType.Id }, saleType));
        }
        // POST: odata/SaleTypes
        public IHttpActionResult Post(SaleType saleType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SaleTypes.Add(saleType);
            db.SaveChanges();

            return(Created(saleType));
        }
Esempio n. 17
0
        public ActionResult Update(int id, SaleType type)
        {
            var sale = _saleService.GetByID(id);

            sale.Status = type;

            _activityService.Create("status was updated " + type.ToString().AddSpacesToSentence(), AreaType.Sale, User.Identity.Name, sale.ID);

            _saleService.Save(sale);

            TempData.Add("StatusMessage", "Sales converted");
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SaleType saleType = db.SaleTypes.Find(id);

            if (saleType == null)
            {
                return(HttpNotFound());
            }
            return(View(saleType));
        }
Esempio n. 19
0
        void OperateBuyOrReserve(SaleType type)
        {
            int stock  = Convert.ToInt32(stockLabel.Content);
            int number = Convert.ToInt32(numberTextBox.Text);

            if (stock == 0)
            {
                return;
            }

            if (number > stock)
            {
                ColorAnimation anima = new ColorAnimation();
                anima.From           = Colors.White;
                anima.To             = Colors.Red;
                anima.Duration       = new Duration(TimeSpan.FromMilliseconds(200));
                anima.AutoReverse    = true;
                anima.RepeatBehavior = new RepeatBehavior(TimeSpan.FromMilliseconds(1200));
                Storyboard storyBoard = new Storyboard();
                storyBoard.Duration = new Duration(TimeSpan.FromMilliseconds(1200));
                storyBoard.Children.Add(anima);
                Storyboard.SetTarget(anima, numberTextBox);
                Storyboard.SetTargetProperty(anima, new PropertyPath("Background.Color"));
                storyBoard.Begin();

                return;
            }
            else
            {
                int newStock = stock - number;
                stockLabel.Content = newStock;
                stockLabel.Tag     = newStock;
                string cmd = "update commodity set stock='" + newStock +
                             "' where id='" + nameLabel.Tag.ToString() + "'";

                MySqlCommand sqlcmd = new MySqlCommand(cmd, conn);
                sqlcmd.ExecuteNonQuery();

                string mid = ((ComboBoxItem)midComboBox.SelectedItem).Content.ToString();
                if (mid == "Not VIP")
                {
                    mid = "0000-00-00 00:00:00";
                }
                cmd = "insert into sale values('" + DateTime.Now + "', '" + mid + "', '" +
                      nameLabel.Tag.ToString() + "', '" + number + "', '" + (int)type + "')";

                sqlcmd = new MySqlCommand(cmd, conn);
                sqlcmd.ExecuteNonQuery();
            }
        }
        // DELETE: odata/SaleTypes(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            SaleType saleType = db.SaleTypes.Find(key);

            if (saleType == null)
            {
                return(NotFound());
            }

            db.SaleTypes.Remove(saleType);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 21
0
 /// <summary>
 /// Set the properties that are set in an ObjectPropertiesFamily packet
 /// </summary>
 /// <param name="props"><seealso cref="ObjectProperties"/> that has
 /// been partially filled by an ObjectPropertiesFamily packet</param>
 public void SetFamilyProperties(ObjectProperties props)
 {
     ObjectID      = props.ObjectID;
     OwnerID       = props.OwnerID;
     GroupID       = props.GroupID;
     Permissions   = props.Permissions;
     OwnershipCost = props.OwnershipCost;
     SaleType      = props.SaleType;
     SalePrice     = props.SalePrice;
     Category      = props.Category;
     LastOwnerID   = props.LastOwnerID;
     Name          = props.Name;
     Description   = props.Description;
 }
Esempio n. 22
0
        /// <summary>
        /// Abre la ventana detalle en modo Busqueda
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 19/04/2016
        /// </history>
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            frmSaleTypeDetail frmSaleTypeDetail = new frmSaleTypeDetail();

            frmSaleTypeDetail.Owner       = this;
            frmSaleTypeDetail.enumMode    = EnumMode.Search;
            frmSaleTypeDetail.oldSaleType = _saletTypeFilter;
            frmSaleTypeDetail.nStatus     = _nStatus;
            if (frmSaleTypeDetail.ShowDialog() == true)
            {
                _saletTypeFilter = frmSaleTypeDetail.saleType;
                _nStatus         = frmSaleTypeDetail.nStatus;
                LoadSalesTypes();
            }
        }
Esempio n. 23
0
        public static ISale createPromo(SaleType type)
        {
            ISale instance = null;

            switch (type)
            {
            case SaleType.OnePlusOneEqThreeSale:
                instance = new OnePlusOneEqThreeSale();
                break;

            default:
                break;
            }

            return(instance);
        }
Esempio n. 24
0
 /// <summary>
 /// Inventory item ctor
 /// </summary>
 /// <param name="info"></param>
 /// <param name="ctxt"></param>
 public InventoryItem(SerializationInfo info, StreamingContext ctxt)
     : base(info, ctxt)
 {
     AssetUUID     = (UUID)info.GetValue("AssetUUID", typeof(UUID));
     Permissions   = (Permissions)info.GetValue("Permissions", typeof(Permissions));
     AssetType     = (AssetType)info.GetValue("AssetType", typeof(AssetType));
     InventoryType = (InventoryType)info.GetValue("InventoryType", typeof(InventoryType));
     CreatorID     = (UUID)info.GetValue("CreatorID", typeof(UUID));
     Description   = (string)info.GetValue("Description", typeof(string));
     GroupID       = (UUID)info.GetValue("GroupID", typeof(UUID));
     GroupOwned    = (bool)info.GetValue("GroupOwned", typeof(bool));
     SalePrice     = (int)info.GetValue("SalePrice", typeof(int));
     SaleType      = (SaleType)info.GetValue("SaleType", typeof(SaleType));
     Flags         = (uint)info.GetValue("Flags", typeof(uint));
     CreationDate  = (DateTime)info.GetValue("CreationDate", typeof(DateTime));
     LastOwnerID   = (UUID)info.GetValue("LastOwnerID", typeof(UUID));
 }
Esempio n. 25
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 19/04/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmSaleTypeDetail frmSaleTypeDetail = new frmSaleTypeDetail();

            frmSaleTypeDetail.Owner    = this;
            frmSaleTypeDetail.enumMode = EnumMode.Add;
            if (frmSaleTypeDetail.ShowDialog() == true)
            {
                SaleType saleType = frmSaleTypeDetail.saleType;
                if (ValidateFilter(saleType))//Validamos que cumpla con los filtros actuales
                {
                    List <SaleType> lstSaleTypes = (List <SaleType>)dgrSaleTypes.ItemsSource;
                    lstSaleTypes.Add(saleType);                                 //Agregamos el objeto a la lista
                    lstSaleTypes.Sort((x, y) => string.Compare(x.stN, y.stN));  //Ordenamos la lista
                    int nIndex = lstSaleTypes.IndexOf(saleType);                //Obtenemos la posición del registro
                    dgrSaleTypes.Items.Refresh();                               //Actualizamos la vista
                    GridHelper.SelectRow(dgrSaleTypes, nIndex);                 //Seleccionamos el registro
                    StatusBarReg.Content = lstSaleTypes.Count + " Sale Types."; //Actualizamos el contador
                }
            }
        }
Esempio n. 26
0
        public static bool ValidateOrderItem(OrderItem orderItem, SaleType saleType)
        {
            if (orderItem.Id == Guid.Empty)
            {
                return(false);
            }

            switch (saleType)
            {
            case SaleType.Normal:
                return(orderItem.Quantity > 0);

            case SaleType.Return:
                return(orderItem.Quantity < 0);

            case SaleType.Exchange:
                return(!FloatingPointUtility.AreEqual(orderItem.Quantity, 0));

            default:
                return(false);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Obtiene registros del catalogo SaleTypes
        /// </summary>
        /// <param name="nStatus">-1. Todos | 0. Iniactivos  | 1. Activos</param>
        /// <param name="saleType">Objeto con  filtros adicionales</param>
        /// <returns>Lista de tipo SaleType></returns>
        /// <history>
        /// [emoguel] created 19/04/2016
        /// [emoguel] modifies 28/06/2016---> se volvió async
        /// </history>
        public async static Task <List <SaleType> > GetSalesTypes(int nStatus = -1, SaleType saleType = null)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from st in dbContext.SaleTypes
                                select st;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query = query.Where(st => st.stA == blnStatus);
                    }

                    if (saleType != null)
                    {
                        if (!string.IsNullOrWhiteSpace(saleType.stID))//Filtro por ID
                        {
                            query = query.Where(st => st.stID == saleType.stID);
                        }

                        if (!string.IsNullOrWhiteSpace(saleType.stN))//Filtro por descripción
                        {
                            query = query.Where(st => st.stN.Contains(saleType.stN));
                        }

                        if (!string.IsNullOrWhiteSpace(saleType.ststc))//Filtro por categoria
                        {
                            query = query.Where(st => st.ststc == saleType.ststc);
                        }
                    }

                    return query.OrderBy(st => st.stID).ToList();
                }
            }));
        }
Esempio n. 28
0
        /// <summary>
        /// Verifica que un saleType cumpla con los filtros actuales
        /// </summary>
        /// <param name="saleType">Objeto a validar</param>
        /// <returns>True. Si cumple | False. No cumple</returns>
        /// <history>
        /// [emoguel] created 19/040/2016
        /// </history>
        private bool ValidateFilter(SaleType saleType)
        {
            if (_nStatus != -1)//filtro por estatus
            {
                if (saleType.stA != Convert.ToBoolean(_nStatus))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_saletTypeFilter.stID))//Filtro por ID
            {
                if (_saletTypeFilter.stID != saleType.stID)
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_saletTypeFilter.stN))//Filtro por Descripción
            {
                if (!saleType.stN.Contains(_saletTypeFilter.stN, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_saletTypeFilter.ststc))//Filtro por Categoria
            {
                if (saleType.ststc != _saletTypeFilter.ststc)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 29
0
        /// <summary>
        /// Llena el grid de salesTypes
        /// </summary>
        /// <param name="saleType">Objeto a seleccionar</param>
        /// <history>
        /// [emoguel] created 19/04/2016
        /// </history>
        private async void LoadSalesTypes(SaleType saleType = null)
        {
            try
            {
                status.Visibility = Visibility.Visible;
                int             nIndex        = 0;
                List <SaleType> lstSalestypes = await BRSaleTypes.GetSalesTypes(_nStatus, _saletTypeFilter);

                dgrSaleTypes.ItemsSource = lstSalestypes;
                if (lstSalestypes.Count > 0 && saleType != null)
                {
                    saleType = lstSalestypes.Where(st => st.stID == saleType.stID).FirstOrDefault();
                    nIndex   = lstSalestypes.IndexOf(saleType);
                }

                GridHelper.SelectRow(dgrSaleTypes, nIndex);
                StatusBarReg.Content = lstSalestypes.Count + " Sale Types.";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
        public IHttpActionResult Patch([FromODataUri] int key, Delta <SaleType> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            SaleType saleType = db.SaleTypes.Find(key);

            if (saleType == null)
            {
                return(NotFound());
            }

            patch.Patch(saleType);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SaleTypeExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(saleType));
        }
Esempio n. 31
0
        /// <summary>
        /// Attempt to purchase an original object, a copy, or the contents of
        /// an object
        /// </summary>
        /// <param name="simulator">The <see cref="Simulator"/> the object is located</param>        
        /// <param name="localID">The Local ID of the object</param>
        /// <param name="saleType">Whether the original, a copy, or the object
        /// contents are on sale. This is used for verification, if the this
        /// sale type is not valid for the object the purchase will fail</param>
        /// <param name="price">Price of the object. This is used for 
        /// verification, if it does not match the actual price the purchase
        /// will fail</param>
        /// <param name="groupID">Group ID that will be associated with the new
        /// purchase</param>
        /// <param name="categoryID">Inventory folder UUID where the object or objects 
        /// purchased should be placed</param>
        /// <example>
        /// <code>
        ///     BuyObject(Client.Network.CurrentSim, 500, SaleType.Copy, 
        ///         100, UUID.Zero, Client.Self.InventoryRootFolderUUID);
        /// </code> 
        ///</example>
        public void BuyObject(Simulator simulator, uint localID, SaleType saleType, int price, UUID groupID,
            UUID categoryID)
        {
            ObjectBuyPacket buy = new ObjectBuyPacket();

            buy.AgentData.AgentID = Client.Self.AgentID;
            buy.AgentData.SessionID = Client.Self.SessionID;
            buy.AgentData.GroupID = groupID;
            buy.AgentData.CategoryID = categoryID;

            buy.ObjectData = new ObjectBuyPacket.ObjectDataBlock[1];
            buy.ObjectData[0] = new ObjectBuyPacket.ObjectDataBlock();
            buy.ObjectData[0].ObjectLocalID = localID;
            buy.ObjectData[0].SaleType = (byte)saleType;
            buy.ObjectData[0].SalePrice = price;

            Client.Network.SendPacket(buy, simulator);
        }
Esempio n. 32
0
        public override bool Decode()
        {
            int version = -1;
            Permissions = new Permissions();
            string data = Utils.BytesToString(AssetData);

            data = data.Replace("\r", String.Empty);
            string[] lines = data.Split('\n');
            for (int stri = 0; stri < lines.Length; stri++)
            {
                if (stri == 0)
                {
                    string versionstring = lines[stri];
                    version = Int32.Parse(versionstring.Split(' ')[2]);
                    if (version != 22 && version != 18)
                        return false;
                }
                else if (stri == 1)
                {
                    Name = lines[stri];
                }
                else if (stri == 2)
                {
                    Description = lines[stri];
                }
                else
                {
                    string line = lines[stri].Trim();
                    string[] fields = line.Split('\t');

                    if (fields.Length == 1)
                    {
                        fields = line.Split(' ');
                        if (fields[0] == "parameters")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count; )
                            {
                                stri++;
                                line = lines[stri].Trim();
                                fields = line.Split(' ');

                                int id = Int32.Parse(fields[0]);
                                if (fields[1] == ",")
                                    fields[1] = "0";
                                else
                                    fields[1] = fields[1].Replace(',', '.');

                                float weight = float.Parse(fields[1], System.Globalization.NumberStyles.Float,
                                    Utils.EnUsCulture.NumberFormat);

                                Params[id] = weight;
                            }
                        }
                        else if (fields[0] == "textures")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count; )
                            {
                                stri++;
                                line = lines[stri].Trim();
                                fields = line.Split(' ');

                                AppearanceManager.TextureIndex id = (AppearanceManager.TextureIndex)Int32.Parse(fields[0]);
                                UUID texture = new UUID(fields[1]);

                                Textures[id] = texture;
                            }
                        }
                        else if (fields[0] == "type")
                        {
                            WearableType = (WearableType)Int32.Parse(fields[1]);
                        }

                    }
                    else if (fields.Length == 2)
                    {
                        switch (fields[0])
                        {
                            case "creator_mask":
                                // Deprecated, apply this as the base mask
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "base_mask":
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "owner_mask":
                                Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "group_mask":
                                Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "everyone_mask":
                                Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "next_owner_mask":
                                Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "creator_id":
                                Creator = new UUID(fields[1]);
                                break;
                            case "owner_id":
                                Owner = new UUID(fields[1]);
                                break;
                            case "last_owner_id":
                                LastOwner = new UUID(fields[1]);
                                break;
                            case "group_id":
                                Group = new UUID(fields[1]);
                                break;
                            case "group_owned":
                                GroupOwned = (Int32.Parse(fields[1]) != 0);
                                break;
                            case "sale_type":
                                ForSale = InventoryManager.StringToSaleType(fields[1]);
                                break;
                            case "sale_price":
                                SalePrice = Int32.Parse(fields[1]);
                                break;
                            case "sale_info":
                                // Container for sale_type and sale_price, ignore
                                break;
                            default:
                                return false;
                        }
                    }
                }
            }

            return true;
        }
Esempio n. 33
0
 public ItemData(UUID uuid, InventoryType type)
 {
     UUID = uuid;
     InventoryType = type;
     ParentUUID = UUID.Zero;
     Name = String.Empty;
     OwnerID = UUID.Zero;
     AssetUUID = UUID.Zero;
     Permissions = new Permissions();
     AssetType = AssetType.Unknown;
     CreatorID = UUID.Zero;
     Description = String.Empty;
     GroupID = UUID.Zero;
     GroupOwned = false;
     SalePrice = 0;
     SaleType = SaleType.Not;
     Flags = 0;
     CreationDate = DateTime.Now;
 }
Esempio n. 34
0
        /// <summary>
        /// Sets an object's sale information
        /// </summary>
        /// <param name="localID"></param>
        /// <param name="saleType"></param>
        /// <param name="price"></param>
        public void SetSaleInfo(uint localID, SaleType saleType, int price)
        {
            ObjectSaleInfoPacket sale = new ObjectSaleInfoPacket();
            sale.AgentData.AgentID = Network.AgentID;
            sale.AgentData.SessionID = Network.SessionID;
            sale.ObjectData = new ObjectSaleInfoPacket.ObjectDataBlock[1];
            sale.ObjectData[0] = new ObjectSaleInfoPacket.ObjectDataBlock();
            sale.ObjectData[0].LocalID = localID;
            sale.ObjectData[0].SalePrice = price;
            sale.ObjectData[0].SaleType = (byte)saleType;

            Network.SendPacket(sale);
        }
Esempio n. 35
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public InventoryItem(SerializationInfo info, StreamingContext ctxt)
     : base(info, ctxt)
 {
     AssetUUID = (UUID)info.GetValue("AssetUUID", typeof(UUID));
     Permissions = (Permissions)info.GetValue("Permissions", typeof(Permissions));
     AssetType = (AssetType)info.GetValue("AssetType", typeof(AssetType));
     InventoryType = (InventoryType)info.GetValue("InventoryType", typeof(InventoryType));
     CreatorID = (UUID)info.GetValue("CreatorID", typeof(UUID));
     Description = (string)info.GetValue("Description", typeof(string));
     GroupID = (UUID)info.GetValue("GroupID", typeof(UUID));
     GroupOwned = (bool)info.GetValue("GroupOwned", typeof(bool));
     SalePrice = (int)info.GetValue("SalePrice", typeof(int));
     SaleType = (SaleType)info.GetValue("SaleType", typeof(SaleType));
     Flags = (uint)info.GetValue("Flags", typeof(uint));
     CreationDate = (DateTime)info.GetValue("CreationDate", typeof(DateTime));
     LastOwnerID = (UUID)info.GetValue("LastOwnerID", typeof(UUID));
 }
Esempio n. 36
0
        public ActionResult Update(int id, SaleType type)
        {
            var sale = _saleService.GetByID(id);
            sale.Status = type;

            _activityService.Create("status was updated " + type.ToString().AddSpacesToSentence(), AreaType.Sale, User.Identity.Name, sale.ID);

            _saleService.Save(sale);

            TempData.Add("StatusMessage", "Sales converted");
            return RedirectToAction("Index");
        }
Esempio n. 37
0
        /// <summary>
        /// Sets the sale properties of a single object
        /// </summary>
        /// <param name="simulator">The <see cref="Simulator"/> the object is located</param>        
        /// <param name="localID">The Local ID of the object</param>        
        /// <param name="saleType">One of the options from the <see cref="SaleType"/> enum</param>
        /// <param name="price">The price of the object</param>
        public void SetSaleInfo(Simulator simulator, uint localID, SaleType saleType, int price)
        {
            ObjectSaleInfoPacket sale = new ObjectSaleInfoPacket();
            sale.AgentData.AgentID = Client.Self.AgentID;
            sale.AgentData.SessionID = Client.Self.SessionID;
            sale.ObjectData = new ObjectSaleInfoPacket.ObjectDataBlock[1];
            sale.ObjectData[0] = new ObjectSaleInfoPacket.ObjectDataBlock();
            sale.ObjectData[0].LocalID = localID;
            sale.ObjectData[0].SalePrice = price;
            sale.ObjectData[0].SaleType = (byte)saleType;

            Client.Network.SendPacket(sale, simulator);
        }
Esempio n. 38
0
        /// <summary>
        /// Sets the sale properties of multiple objects
        /// </summary>        
        /// <param name="simulator">The <see cref="Simulator"/> the objects are located</param> 
        /// <param name="localIDs">An array containing the Local IDs of the objects</param>
        /// <param name="saleType">One of the options from the <see cref="SaleType"/> enum</param>
        /// <param name="price">The price of the object</param>
        public void SetSaleInfo(Simulator simulator, List<uint> localIDs, SaleType saleType, int price)
        {
            ObjectSaleInfoPacket sale = new ObjectSaleInfoPacket();
            sale.AgentData.AgentID = Client.Self.AgentID;
            sale.AgentData.SessionID = Client.Self.SessionID;
            sale.ObjectData = new ObjectSaleInfoPacket.ObjectDataBlock[localIDs.Count];

            for (int i = 0; i < localIDs.Count; i++)
            {
                sale.ObjectData[i] = new ObjectSaleInfoPacket.ObjectDataBlock();
                sale.ObjectData[i].LocalID = localIDs[i];
                sale.ObjectData[i].SalePrice = price;
                sale.ObjectData[i].SaleType = (byte)saleType;
            }

            Client.Network.SendPacket(sale, simulator);
        }
Esempio n. 39
0
        public override void Decode()
        {
            int version = -1;
            int n = -1;
            string data = Helpers.FieldToUTF8String(AssetData);

            n = data.IndexOf('\n');
            version = Int32.Parse(data.Substring(19, n - 18));
            data = data.Remove(0, n);

            if (version != 22)
                throw new Exception("Wearable asset has unrecognized version " + version);

            n = data.IndexOf('\n');
            Name = data.Substring(0, n);
            data = data.Remove(0, n);

            n = data.IndexOf('\n');
            Description = data.Substring(0, n);
            data = data.Remove(0, n);

            // Split in to an upper and lower half
            string[] parts = data.Split(new string[] { "parameters" }, StringSplitOptions.None);
            parts[1] = "parameters" + parts[1];

            Permissions = new Permissions();

            // Parse the upper half
            string[] lines = parts[0].Split('\n');
            foreach (string thisline in lines)
            {
                string line = thisline.Trim();
                string[] fields = line.Split('\t');

                if (fields.Length == 2)
                {
                    if (fields[0] == "creator_mask")
                    {
                        // Deprecated, apply this as the base mask
                        Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "base_mask")
                    {
                        Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "owner_mask")
                    {
                        Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "group_mask")
                    {
                        Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "everyone_mask")
                    {
                        Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "next_owner_mask")
                    {
                        Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "creator_id")
                    {
                        Creator = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "owner_id")
                    {
                        Owner = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "last_owner_id")
                    {
                        LastOwner = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "group_id")
                    {
                        Group = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "group_owned")
                    {
                        GroupOwned = (Int32.Parse(fields[1]) != 0);
                    }
                    else if (fields[0] == "sale_type")
                    {
                        ForSale = InventoryManager.StringToSaleType(fields[1]);
                    }
                    else if (fields[0] == "sale_price")
                    {
                        SalePrice = Int32.Parse(fields[1]);
                    }
                }
                else if (line.StartsWith("type "))
                {
                    WearableType = (WearableType)Int32.Parse(line.Substring(5));
                    break;
                }
            }

            // Break up the lower half in to parameters and textures
            string[] lowerparts = parts[1].Split(new string[] { "textures" }, StringSplitOptions.None);
            lowerparts[1] = "textures" + lowerparts[1];

            // Parse the parameters
            lines = lowerparts[0].Split('\n');
            foreach (string line in lines)
            {
                string[] fields = line.Split(' ');

                // Use exception handling to deal with all the lines we aren't interested in
                try
                {
                    int id = Int32.Parse(fields[0]);
                    if (fields[1] == ",")
                    {
                        fields[1] = "0";
                    }
                    else
                    {
                        fields[1] = fields[1].Replace(',', '.');
                    }
                    float weight = Single.Parse(fields[1], System.Globalization.NumberStyles.Float,
                        Helpers.EnUsCulture.NumberFormat);

                    Params[id] = weight;
                }
                catch (Exception)
                {
                }
            }

            // Parse the textures
            lines = lowerparts[1].Split('\n');
            foreach (string line in lines)
            {
                string[] fields = line.Split(' ');

                // Use exception handling to deal with all the lines we aren't interested in
                try
                {
                    AppearanceManager.TextureIndex id = (AppearanceManager.TextureIndex)Int32.Parse(fields[0]);
                    LLUUID texture = new LLUUID(fields[1]);

                    Textures[id] = texture;
                }
                catch (Exception)
                {
                }
            }
        }
Esempio n. 40
0
 public static string SaleTypeToString(SaleType type)
 {
     return _SaleTypeNames[(int)type];
 }
Esempio n. 41
0
 public static string StringValueOf(SaleType type)
 {
     string str;
     if (SaleTypeMap.TryGetKey(type, out str))
         return str;
     else
         return "not";
 }