Esempio n. 1
0
 public void Logout(bool isForced = false)
 {
     IMHelper.LogoutFromIM();
     VMGlobal.CleanUserData();
     if (LogoutEvent != null)
     {
         LogoutEvent(isForced);
     }
 }
Esempio n. 2
0
        public OPResult Delete(ViewProduct product)
        {
            var distlp = VMGlobal.DistributionQuery.LinqOP;
            var manulp = VMGlobal.ManufacturingQuery.LinqOP;
            var syslp  = VMGlobal.SysProcessQuery.LinqOP;
            var pid    = product.ProductID;

            if (distlp.Any <BillStoringDetails>(o => o.ProductID == pid))
            {
                return new OPResult {
                           IsSucceed = false, Message = "删除失败,该SKU已有入库记录."
                }
            }
            ;
            if (distlp.Any <BillStocktakeDetails>(o => o.ProductID == pid))
            {
                return new OPResult {
                           IsSucceed = false, Message = "删除失败,该SKU已有盘点记录."
                }
            }
            ;

            string         changeMsg = string.Format("SKU码{0}被删除.", product.ProductCode);
            ProStyleChange change    = new ProStyleChange
            {
                CreateTime  = DateTime.Now,
                CreatorID   = VMGlobal.CurrentUser.ID,
                Description = changeMsg,
                StyleID     = product.StyleID
            };
            OPResult result = new OPResult {
                IsSucceed = false, Message = "删除失败!"
            };

            using (ChannelFactory <IBillService> channelFactory = new ChannelFactory <IBillService>("BillSVC"))
            {
                IBillService service = channelFactory.CreateChannel();

                result = service.DeleteSKU(product.ProductID, change);
            }
            if (result.IsSucceed)
            {
                ObservableCollection <ViewProduct> products = (ObservableCollection <ViewProduct>)Entities;
                products.Remove(product);
                IMHelper.AsyncSendMessageTo(IMHelper.OnlineUsers, new IMessage
                {
                    Message = changeMsg
                }, IMReceiveAccessEnum.成品资料变动);
            }
            return(result);
        }
    }
}
Esempio n. 3
0
        public OPResult Login(string userCode, string password)
        {
            OPResult result = new OPResult {
                IsSucceed = false, Message = "登录失败."
            };
            var user = UserLogic.GetUserWhenLogin(userCode, password);

            if (user != null)
            {
                VMGlobal.CurrentUser = new SysUserBO(user);
                IMHelper.RegisterToIM();
                //IMHelper.StartService();
                WelcomeMessage = string.Format("当前登录用户: [{0}]{1}", user.Code, user.Name);
                OnPropertyChanged("WelcomeMessage");
                _menuTreeVM = new MenuTreeVM();
                OnPropertyChanged("MenuTreeVM");
                result.IsSucceed = true;
            }
            if (CustomerInfo == null || !CustomerInfo.Name.Contains("tx"))
            {
                throw new Exception("非授权客户");
            }
            return(result);
        }
Esempio n. 4
0
        private OPResult Update(ProStyleBO style)
        {
            SetStyleBYQ(style);
            ProStyle       orginStyle    = LinqOP.GetById <ProStyle>(style.ID);
            List <Product> productsExist = LinqOP.Search <Product>(p => p.StyleID == style.ID).ToList();
            List <Product> products      = new List <Product>();

            foreach (var color in style.Colors)
            {
                foreach (var size in style.Sizes)
                {
                    var     pcode   = style.Code + color.Code + size.Code;
                    Product product = productsExist.FirstOrDefault(p => p.ColorID == color.ID && p.SizeID == size.ID);
                    if (product != null)
                    {
                        if (orginStyle.Code != style.Code)
                        {
                            product.Code = pcode;
                            products.Add(product);
                        }
                    }
                    else
                    {
                        product = new Product
                        {
                            Code      = pcode,
                            StyleID   = style.ID,
                            ColorID   = color.ID,
                            SizeID    = size.ID,
                            CreatorID = VMGlobal.CurrentUser.ID
                        };
                        products.Add(product);
                    }
                }
            }

            string changeMsg = "";

            if (orginStyle.Price != style.Price)
            {
                changeMsg += string.Format("单价从{0}变动为{1},", orginStyle.Price, style.Price);
            }
            if (orginStyle.Code != style.Code)
            {
                changeMsg += string.Format("款号从{0}变动为{1},", orginStyle.Code, style.Code);
            }
            if (products.Count > 0)
            {
                changeMsg += "增加了SKU码:";
                products.ForEach(o =>
                {
                    changeMsg += (o.Code + ",");
                });
            }
            changeMsg = changeMsg.TrimEnd(',');

            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Update <ProStyle>(style);
                    LinqOP.AddOrUpdate <Product>(products);
                    if (!string.IsNullOrEmpty(changeMsg))
                    {
                        ProStyleChange change = new ProStyleChange
                        {
                            CreateTime  = DateTime.Now,
                            CreatorID   = VMGlobal.CurrentUser.ID,
                            Description = changeMsg,
                            StyleID     = style.ID
                        };
                        LinqOP.Add <ProStyleChange>(change);
                        style.Changes.Insert(0, change);
                    }
                    result = new OPResult {
                        IsSucceed = true, Message = "更新成功!"
                    };
                    scope.Complete();
                }
                catch (Exception e)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message
                    };
                }
            }
            if (result.IsSucceed && !string.IsNullOrEmpty(changeMsg))
            {
                IMHelper.AsyncSendMessageTo(IMHelper.OnlineUsers, new IMessage
                {
                    Message = changeMsg
                }, IMReceiveAccessEnum.成品资料变动);
            }
            return(result);
        }
Esempio n. 5
0
 public void WindowClosing()
 {
     IMHelper.LogoutFromIM();
     IMHelper.CloseService();//这步貌似挺花时间的,要给予用户提示
 }