Exemple #1
0
        public async Task <ActionResult> _ViewSpecification()
        {
            SystemConfig config = await YummyOnlineManager.GetSystemConfig();

            Dictionary <string, List <FileInfo> > dirFiles = new Dictionary <string, List <FileInfo> >();

            string[] dirs = Directory.GetDirectories(config.SpecificationDir);

            foreach (string dir in dirs)
            {
                string[] files = Directory.GetFiles(dir);

                string dirStr = dir.Split('\\').Last();
                dirFiles.Add(dirStr, new List <FileInfo>());

                foreach (string file in files)
                {
                    dirFiles[dirStr].Add(new FileInfo(file));
                }
            }

            ViewBag.DirFiles = dirFiles;

            return(View());
        }
        public async Task <ActionResult> _ViewMonitor()
        {
            var config = await YummyOnlineManager.GetSystemConfig();

            ViewBag.WebSocketLocation = $"ws://{config.TcpServerIp}:{config.WebSocketPort}";
            return(View());
        }
        /// <summary>
        /// 收银员台支付
        /// </summary>
        public async Task <ActionResult> ManagerPay(Cart cart, ManagerCartAddition cartAddition)
        {
            SystemConfig system = await YummyOnlineManager.GetSystemConfig();

            if (system.Token != cartAddition.Token)
            {
                return(Json(new JsonError("身份验证失败")));
            }

            var hotel = await YummyOnlineManager.GetHotelById(cartAddition.HotelId);

            CurrHotel = new CurrHotelInfo(hotel.Id, hotel.ConnectionString);

            if (!hotel.Usable)
            {
                return(RedirectToAction("HotelUnavailable", "Error"));
            }

            cart.PayKindId = await new HotelManager(CurrHotel.ConnectionString).GetOtherPayKindId();
            CartAddition addition = new CartAddition {
                WaiterId     = cartAddition.WaiterId,
                DineType     = cartAddition.DineType,
                Discount     = cartAddition.Discount,
                DiscountName = cartAddition.DiscountName,
                GiftMenus    = cartAddition.GiftMenus,
                From         = DineFrom.Manager
            };

            User user = await UserManager.FindByIdAsync(cartAddition.UserId);

            addition.UserId = user?.Id;

            // 创建新订单
            FunctionResult result = await OrderManager.CreateDine(cart, addition);

            if (!result.Succeeded)
            {
                if (await UserManager.IsInRoleAsync(user.Id, Role.Nemo))
                {
                    await UserManager.DeleteAsync(user);

                    await YummyOnlineManager.RecordLog(YummyOnlineDAO.Models.Log.LogProgram.Identity, YummyOnlineDAO.Models.Log.LogLevel.Warning, $"Anonymous User Deleted {user.Id}, Via Manager");
                }
                await HotelManager.RecordLog(HotelDAO.Models.Log.LogLevel.Error, $"{result.Detail}, Host:{Request.UserHostAddress}", HttpPost.GetPostData(Request));

                return(Json(new JsonError(result.Message)));
            }

            Dine dine = ((Dine)result.Data);

            await newDineInform(dine, "Manager");

            return(Json(new JsonSuccess {
                Data = dine.Id
            }));
        }
Exemple #4
0
        public async Task <JsonResult> Backup(bool isYummyOnline, List <int> hotelIds)
        {
            SystemConfig config = await YummyOnlineManager.GetSystemConfig();

            string path = $"{config.SpecificationDir}\\Database";

            StringBuilder sb = new StringBuilder();

            if (isYummyOnline)
            {
                OriginSql      originSql = new OriginSql(YummyOnlineManager.ConnectionString);
                FunctionResult result    = await originSql.Backup(path);

                if (!result.Succeeded)
                {
                    sb.Append($"YummyOnlineDB Error, {result.Message}</br>");
                    await YummyOnlineManager.RecordLog(Log.LogProgram.System, Log.LogLevel.Error, "Backup YummyOnlineDB Failed", result.Message);
                }
                else
                {
                    await YummyOnlineManager.RecordLog(Log.LogProgram.System, Log.LogLevel.Success, "Backup YummyOnlineDB Successfully");
                }
            }

            foreach (int id in hotelIds)
            {
                Hotel hotel = await YummyOnlineManager.GetHotelById(id);

                OriginSql      originSql = new OriginSql(hotel.AdminConnectionString);
                FunctionResult result    = await originSql.Backup(path);

                if (!result.Succeeded)
                {
                    sb.Append($"{hotel.Name}({hotel.Id}) Error, {result.Message}</br>");
                    await YummyOnlineManager.RecordLog(Log.LogProgram.System, Log.LogLevel.Error, $"Backup {hotel.Name}({hotel.Id}) Failed", result.Message);
                }
                else
                {
                    await YummyOnlineManager.RecordLog(Log.LogProgram.System, Log.LogLevel.Success, $"Backup {hotel.Name}({hotel.Id}) Successfully");
                }
            }
            if (sb.Length != 0)
            {
                return(Json(new JsonError(sb.ToString())));
            }
            return(Json(new JsonSuccess()));
        }
Exemple #5
0
        public async Task <ActionResult> GetFile(string dir, string name)
        {
            User user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            SystemConfig config = await YummyOnlineManager.GetSystemConfig();

            string path = $"{config.SpecificationDir}\\{dir}\\{name}";

            if (name.EndsWith(".html") || name.EndsWith(".htm"))
            {
                await YummyOnlineManager.RecordLog(Log.LogProgram.System, Log.LogLevel.Info, $"{user.Id}({user.UserName}) Reads {dir}\\{name}");

                return(File(path, "text/html"));
            }
            await YummyOnlineManager.RecordLog(Log.LogProgram.System, Log.LogLevel.Info, $"{user.Id}({user.UserName}) Downloads {dir}\\{name}");

            return(File(path, "application/octet-stream", name));
        }
Exemple #6
0
        public async Task <JsonResult> WeixinNotify(int hotelId, string dineId)
        {
            NetworkNotifyViewModels model = new NetworkNotifyViewModels {
                HotelId  = hotelId,
                DineId   = dineId,
                RecordId = $"SystemTestNotify{DateTime.Now.ToString("yyyyMMddHHmmssffff")}"
            };
            string notifyInfo    = Newtonsoft.Json.JsonConvert.SerializeObject(model);
            string encryptedInfo = DesCryptography.DesEncrypt(notifyInfo);

            string url    = (await YummyOnlineManager.GetSystemConfig()).OrderSystemUrl;
            string result = await HttpPost.PostAsync($"{url}/Payment/OnlineNotify", new {
                EncryptedInfo = encryptedInfo
            });

            if (result == null)
            {
                return(Json(new JsonError()));
            }

            return(Json(new JsonSuccess()));
        }
Exemple #7
0
        public async Task <JsonResult> GetBackups()
        {
            SystemConfig config = await YummyOnlineManager.GetSystemConfig();

            string path = $"{config.SpecificationDir}\\Database";

            string[] files = Directory.GetFiles(path, "*.bak");

            List <dynamic> fileInfos = new List <dynamic>();

            foreach (string file in files)
            {
                FileInfo fileInfo = new FileInfo(file);
                fileInfos.Add(new {
                    fileInfo.Name,
                    fileInfo.LastWriteTime,
                    fileInfo.Length
                });
            }

            return(Json(fileInfos));
        }