Esempio n. 1
0
        //public ActionResult GetListAuto(string key, string keword, int showLimit, int agencyId, int type)
        //{
        //    var obj = key != Keyapi ? new List<SuggestionsProduct>() : _da.GetListAuto(keword, showLimit, agencyId, type);
        //    return Json(obj, JsonRequestBehavior.AllowGet);
        //}
        public ActionResult Add(string key, string codeLogin)
        {
            var model = new StorageProduct();

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                UpdateModel(model);
                model.Note = HttpUtility.UrlDecode(model.Note);
                var dateCreated = Request["DateCreated_"];
                var date        = dateCreated.StringToDate();
                //model.DN_ImportProduct = GetListImportItem(codeLogin, date,Agencyid());
                model.DateImport  = DateTime.Now.TotalSeconds();
                model.DateCreated = DateTime.Now.TotalSeconds();
                model.Code        = DateTime.Now.ToString("yyMMddHHmm");
                model.AgencyId    = Agencyid();
                model.IsDelete    = false;
                _da.Add(model);
                _da.Save();
                return(Json(model.ID, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 2
0
        public async Task <StorageProduct> AddStorageProductAsync(StorageProduct model)
        {
            var query = await _context.StorageProducts
                        .AddAsync(model);

            return(query.Entity);
        }
Esempio n. 3
0
        public async Task <ActionResult <StorageProduct> > AddStorageProduct(StorageProduct model)
        {
            var query = await _repository.AddStorageProductAsync(model);

            if (query != null)
            {
                await _repository.CommitAsync();
            }

            return(query);
        }
Esempio n. 4
0
        public async Task <ActionResult <StorageProduct> > UpdateStorageProduct(StorageProduct model)
        {
            var query = await _repository.UpdateStorageProductAsync(model);

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

            await _repository.CommitAsync();

            return(query);
        }
Esempio n. 5
0
        public async Task <StorageProduct> UpdateStorageProductAsync(StorageProduct model)
        {
            var query = await _context.StorageProducts
                        .FirstOrDefaultAsync(s => s.Id == model.Id);

            if (query != null)
            {
                query.ProductId = model.ProductId;
                query.Date      = model.Date;
                query.Quantity  = model.Quantity;
                query.Type      = model.Type;
                query.FromTo    = model.FromTo;
            }

            return(query);
        }
Esempio n. 6
0
        private static void PushJobDownload(string domain)
        {
            ProducerBasic producer = new ProducerBasic(RabbitMQManager.GetRabbitMQServer(ConfigStatic.KeyRabbitMqCrlProductProperties),
                                                       ConfigStatic.GetQueueWaitDownloadHtml(domain));
            IStorageProduct storageProduct = new StorageProduct();
            int             i         = 0;
            string          DetailUrl = "";
            Regex           regex     = new Regex(@"http://www.+html");

            storageProduct.ProcessProduct(domain, (sender, product) =>
            {
                if (domain == "lazada.vn")
                {
                    string urlencode        = product.DetailUrl;
                    string urldecode        = HttpUtility.UrlDecode(HttpUtility.UrlDecode(urlencode));
                    MatchCollection matches = regex.Matches(urldecode);

                    DetailUrl = matches[0].Value.ToString();

                    ////string urlencode = product.DetailUrl;
                    ////string urldecode = HttpUtility.UrlDecode(product.DetailUrl);
                    ////char charRange = '?';
                    ////int startIndex = urldecode.IndexOf(charRange) + 1;
                    ////int endIndex = urldecode.LastIndexOf(charRange) - 1;
                    ////int length = endIndex - startIndex + 1;
                    ////DetailUrl = urldecode.Substring(startIndex, length).Replace("url=", "");
                }
                else
                {
                    DetailUrl = product.DetailUrl;
                }
                producer.PublishString(new JobCrlProperties()
                {
                    ProductId        = product.Id,
                    DetailUrl        = UtilCrl.GetUrl(DetailUrl, domain),
                    Domain           = domain,
                    ClassificationId = product.ClassificationId,
                    Classification   = product.Classification
                }.GetJson());
                i++;
                //log.Info(string.Format("{0} {1}", i, product.Id));
                log.InfoFormat("{0}: {1}", i, product.Id);
            });
        }
Esempio n. 7
0
        public ActionResult AddStorage(string key, string json, Guid userId)
        {
            var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công.");

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                var ncc           = _da.GetbyId(ItemId);
                var totalquantity = 0;
                var stt           = ConvertUtil.ToInt32(Request["do_stt"]);
                for (var i = 1; i <= stt; i++)
                {
                    var name = Request["SalaryType_" + i];
                    if (!string.IsNullOrEmpty(name))
                    {
                        var quantity = ConvertUtil.ToInt32(Request["QuantityActive_add_" + i] ?? "0");
                        var price    = ConvertUtil.ToDecimal(Request["Price_add_" + i] ?? "0");
                        var supId    = ConvertUtil.ToInt32(Request["DNSupplie_" + i] ?? "0");
                        var today    = ConvertUtil.ToDecimal(Request["today"] ?? "0");
                        var hours    = ConvertUtil.ToInt32(Request["hourstoday"] ?? "0");
                        var cateId   = ConvertUtil.ToInt32(Request["CateId"] ?? "0");
                        var hourI    = Request["Hours_add_" + i] ?? "0";
                        var dateI    = ConvertUtil.ToDateTime(Request["Date_add_" + i]).TotalSeconds();
                        totalquantity += quantity;
                        var obj = new StorageProduct
                        {
                            UserID      = userId,
                            AgencyId    = Agencyid(),
                            IsDelete    = false,
                            DateCreated = DateTime.Now.TotalSeconds(),
                            Code        = DateTime.Now.Millisecond.ToString(),
                            Quantity    = quantity,
                            Price       = price,
                            SupID       = supId,
                            Today       = today,
                            Hour        = hours,
                            TotalID     = ncc.ID,
                            CateID      = cateId,
                            DateImport  = dateI,
                            HoursImport = int.Parse(hourI)
                        };
                        _da.AddStora(obj);
                    }
                }
                if (totalquantity > (ncc.Quantity - ncc.QuantityOut))
                {
                    msg = new JsonMessage
                    {
                        Erros   = true,
                        Message = "Bạn đã xuất quá số lượng thực tế.!"
                    };
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ncc.QuantityOut += totalquantity;
                    _da.Save();
                }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được cập nhật.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Esempio n. 8
0
 public void AddStoragePrudct(StorageProduct item)
 {
     FDIDB.StorageProducts.Add(item);
 }
        public ActionResult Actions()
        {
            var msg = new JsonMessage()
            {
                Erros = false, Message = "Cập nhập dữ liệu thành công.!"
            };

            //var url = Request.Form.ToString();
            //url = HttpUtility.UrlDecode(url);
            try
            {
                //msg = _api.AddStorage(url, UserItem.AgencyID, UserItem.UserId);
                var stora         = _da.GetListStorabyId(ArrId.FirstOrDefault());
                var ncc           = _da.GetbyId(ArrId.FirstOrDefault());
                var lst           = new List <StorageProduct>();
                var totalquantity = 0;
                var stt           = ConvertUtil.ToInt32(Request["do_stt"]);
                //sua
                foreach (var item in stora)
                {
                    var sup = Request["DNSupplie_old" + item.ID];
                    if (string.IsNullOrEmpty(sup))
                    {
                        lst.Add(item);
                    }
                    else
                    {
                        var quantity = Request["QuantityActive_old_" + item.ID];
                        var tmp      = Math.Ceiling(decimal.Parse(quantity ?? "0"));
                        var hourI    = Request["HourImport_old" + item.ID] ?? "0";
                        var dateI    = ConvertUtil.ToDateTime(Request["today_old" + item.ID]).TotalSeconds();
                        item.SupID       = int.Parse(sup);
                        item.Quantity    = (int)tmp;
                        item.DateImport  = dateI;
                        item.HoursImport = int.Parse(hourI);
                        totalquantity   += (int)tmp;
                    }
                }
                //xoa
                foreach (var item in lst)
                {
                    _da.DeleteStora(item);
                }
                //them moi
                for (var i = 1; i <= stt; i++)
                {
                    var supId = ConvertUtil.ToInt32(Request["DNSupplie_add_" + i] ?? "0");
                    if (supId > 0)
                    {
                        var test = Request["QuantityActive_add_" + i];
                        var tmp  = Math.Ceiling(decimal.Parse(test ?? "0"));
                        //var quantity = ConvertUtil.ToInt32(test ?? "0");
                        var hourI = Request["Hours_add_" + i] ?? "0";
                        var dateI = ConvertUtil.ToDateTime(Request["Date_add_" + i]).TotalSeconds();
                        totalquantity += (int)tmp;
                        var obj = new StorageProduct
                        {
                            UserID      = UserItem.UserId,
                            AgencyId    = UserItem.AgencyID,
                            IsDelete    = false,
                            DateCreated = DateTime.Now.TotalSeconds(),
                            Code        = DateTime.Now.ToString("yyMMddHHmm"),
                            Quantity    = (int)tmp,
                            Price       = ncc.Category.Price,
                            SupID       = supId,
                            Today       = ncc.Today,
                            Hour        = ncc.Hour,
                            TotalPrice  = tmp * (ncc.Category.Price ?? 0),
                            TotalID     = ncc.ID,
                            CateID      = ncc.CateID,
                            DateImport  = dateI,
                            HoursImport = int.Parse(hourI),
                            AreaID      = UserItem.AreaID
                        };
                        _da.AddStora(obj);
                    }
                    else
                    {
                        msg = new JsonMessage
                        {
                            Erros   = true,
                            Message = "Bạn Chưa chọn nhà cung cấp.!"
                        };
                        return(Json(msg, JsonRequestBehavior.AllowGet));
                    }
                }
                var dem = (double)(totalquantity - (ncc.Quantity));
                if (dem > 0.5)
                {
                    msg = new JsonMessage
                    {
                        Erros   = true,
                        Message = "Bạn đã xuất quá số lượng thực tế.!"
                    };
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ncc.QuantityOut = totalquantity;
                    _da.Save();
                }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được cập nhật.";
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Esempio n. 10
0
 public void DeleteStora(StorageProduct item)
 {
     FDIDB.StorageProducts.Remove(item);
 }