예제 #1
0
 /// <summary>
 /// 读取储值卡
 /// </summary>
 /// <param name="InCardNo"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static bool GetCzCard(string inCardNo, out string msg)
 {
     try
     {
         MMessage <MCzCard> mmsg = Converter.Deserialize <MMessage <MCzCard> >(
             TransClass.GetCzCard(inCardNo));
         if (mmsg.Flag)
         {
             PubGlobal.BussinessVar.card = mmsg.Content;
             msg = "储值卡获取成功";
             return(true);
         }
         else
         {
             PubGlobal.BussinessVar.card = null;
             msg = mmsg.Text;
             return(false);
         }
     }
     catch (Exception ex)
     {
         msg = "系统异常:" + ex.Message;
         PubGlobal.BussinessVar.card = null;
         return(false);
     }
 }
예제 #2
0
 /// <summary>
 /// 通过部门获取商品列表
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static bool GetGoods(out string msg)
 {
     try
     {
         string json;
         if (PubGlobal.SysConfig.GetGoodsByDept)
         {
             json = TransClass.GetGoods();
         }
         else
         {
             json = TransClass.GetGoodsByStype(PubGlobal.SysConfig.Stype);
         }
         MMessage <MGoods[]> mmsg = Converter.Deserialize <MMessage <MGoods[]> >(json);
         if (mmsg.Flag)
         {
             PubGlobal.BussinessVar.goodsList = mmsg.Content;
             msg = "读取商品列表成功";
             return(true);
         }
         else
         {
             PubGlobal.BussinessVar.goodsList = null;
             msg = mmsg.Text;
             return(false);
         }
     }
     catch (Exception ex)
     {
         msg = "系统异常:" + ex.Message;
         return(false);
     }
 }
예제 #3
0
        /// <summary>
        /// 保存交易
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool SaveTrade(out string msg)
        {
            if (PubGlobal.BussinessVar.saleFlowList == null || PubGlobal.BussinessVar.payFlowList == null ||
                PubGlobal.BussinessVar.saleFlowList.Count == 0 || PubGlobal.BussinessVar.payFlowList.Count == 0)
            {
                msg = "流水不完整";
                return(false);
            }

            try
            {
                MMessage <MCzCard> mmsg = Converter.Deserialize <MMessage <MCzCard> >(
                    TransClass.SaveTrade(Converter.Serialize(PubGlobal.BussinessVar.saleFlowList),
                                         Converter.Serialize(PubGlobal.BussinessVar.payFlowList)));
                if (mmsg.Flag)
                {
                    PubGlobal.BussinessVar.card = mmsg.Content;
                    msg = "交易成功";
                    return(true);
                }
                else
                {
                    msg = mmsg.Text;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                msg = "系统异常:" + ex.Message;
                return(false);
            }
        }
예제 #4
0
 /// <summary>
 /// 查询当日交易
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static bool QueryTrade(out decimal total, out string msg)
 {
     try
     {
         string json = TransClass.QueryTrade();
         MMessage <MSaleFlow[]> mmsg = Converter.Deserialize <MMessage <MSaleFlow[]> >(json);
         if (mmsg.Flag)
         {
             PubGlobal.BussinessVar.QuerySaleFlows.Clear();
             PubGlobal.BussinessVar.QuerySaleFlows.AddRange(mmsg.Content);
             msg   = mmsg.Text;
             total = 0;
             foreach (MSaleFlow saleFlow in mmsg.Content)
             {
                 total += saleFlow.Total;
             }
             return(true);
         }
         else
         {
             msg   = mmsg.Text;
             total = 0;
             return(false);
         }
     }
     catch (Exception ex)
     {
         msg   = "系统异常:" + ex.Message;
         total = 0;
         return(false);
     }
 }
예제 #5
0
        /// <summary>
        /// 查询是否有更新
        /// </summary>
        /// <param name="msg"></param>
        /// <returns>0 不需要更新 1 需要更新 -1 异常</returns>
        public static int CheckUpdate(out string msg)
        {
            MDownloadfile[]   updateFileList = null;
            string            json           = TransClass.CheckUpdate(PubGlobal.Envionment.APPVersion, ref updateFileList);
            MMessage <string> mmsg           = Converter.Deserialize <MMessage <string> >(json);

            if (mmsg.Flag && updateFileList != null && updateFileList.Length > 0)
            {
                string path = PubGlobal.Envionment.UpdateFolderPath;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                foreach (MDownloadfile file in updateFileList)
                {
                    try
                    {
                        ZipClass.UnzipBytesToFile(file.FileContent, path + @"\" + file.FileName);
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                        return(-1);
                    }
                }
                msg = string.Empty;
                return(1);
            }
            else
            {
                msg = "不需要更新";
                return(0);
            }
        }
        public async Task SubmitAsync()
        {
            string content = await editor.GetHTML();

            if (content == "<p><br></p>")
            {
                message = "You cannot send empty message";
                return;
            }
            message = null;

            isLoading = true;
            Message.Replies.Add(new MMessageReply()
            {
                Content = await editor.GetHTML()
            });

            var response = await HttpClient.PostAsJsonAsync("api/messages", Message);

            var msg = await response.Content.ReadFromJsonAsync <MMessage>();

            Message = defaultMessage;
            NavigationManager.NavigateTo($"/messages/{msg.Id}");
            isLoading = false;
        }
예제 #7
0
 /// <summary>
 /// 登陆
 /// </summary>
 /// <returns></returns>
 public static bool Logon(out string msg)
 {
     try
     {
         string           json = TransClass.Logon();
         MMessage <MUser> mmsg = Converter.Deserialize <MMessage <MUser> >(json);
         if (mmsg.Flag)
         {
             PubGlobal.SysConfig.User = mmsg.Content;
             msg = "登陆成功";
             return(true);
         }
         else
         {
             PubGlobal.SysConfig.User = null;
             msg = mmsg.Text;
             return(false);
         }
     }
     catch (Exception ex)
     {
         msg = "系统异常:" + ex.Message;
         return(false);
     }
 }
예제 #8
0
        public string HelloWorld()
        {
            MMessage <string> msg = new MMessage <string>();

            msg.Flag = true;
            msg.Text = "测试通过";
            return(Converter.Serialize(msg));
        }
예제 #9
0
        protected override async Task OnParametersSetAsync()
        {
            var response = await HttpClient.GetAsync("api/messages/" + MessageId);

            statusCode = response.StatusCode;
            if (statusCode == HttpStatusCode.OK)
            {
                Message = await response.Content.ReadFromJsonAsync <MMessage>();
            }
        }
예제 #10
0
        public string GetGoodsByStype(string stype)
        {
            MMessage <ICollection <MGoods> > msg = new MMessage <ICollection <MGoods> >();

            msg.Flag = isValid(soapHeader, out msg.Text);
            if (msg.Flag)
            {
                msg.Flag = GoodsDAL.GetGoodsByStype(stype, out msg.Content, out msg.Text);
            }
            if (!msg.Flag)
            {
                WriteLog("GetGoodsByStype", msg.Flag, msg.Text);
            }
            return(Converter.Serialize(msg));
        }
예제 #11
0
        public string GetConfig()
        {
            MMessage <ICollection <MConfig> > msg = new MMessage <ICollection <MConfig> >();

            msg.Flag = isValid(soapHeader, out msg.Text);
            if (msg.Flag)
            {
                msg.Flag = ConfigDAL.GetConfig(soapHeader.PosNO, out msg.Content, out msg.Text);
            }
            if (!msg.Flag)
            {
                WriteLog("GetConfig", msg.Flag, msg.Text);
            }
            return(Converter.Serialize(msg));
        }
예제 #12
0
        public string GetCzCard(string inCardNo)
        {
            MMessage <MCzCard> msg = new MMessage <MCzCard>();

            msg.Flag = isValid(soapHeader, out msg.Text);
            if (msg.Flag)
            {
                msg.Flag = CzkDAL.GetCzCard(inCardNo, out msg.Content, out msg.Text);
            }
            if (!msg.Flag)
            {
                WriteLog("GetCzCard", msg.Flag, msg.Text);
            }
            return(Converter.Serialize(msg));
        }
예제 #13
0
        public string Logon()
        {
            MMessage <MUser> msg = new MMessage <MUser>();

            msg.Flag = isValid(soapHeader, out msg.Text);
            if (msg.Flag)
            {
                msg.Flag = UserDAL.GetUser(soapHeader.UserCode, out msg.Content, out msg.Text);
            }
            if (!msg.Flag)
            {
                WriteLog("Logon", msg.Flag, msg.Text);
            }
            return(Converter.Serialize(msg));
        }
예제 #14
0
        public string QueryTrade()
        {
            MMessage <ICollection <MSaleFlow> > msg = new MMessage <ICollection <MSaleFlow> >();

            msg.Flag = isValid(soapHeader, out msg.Text);
            if (msg.Flag)
            {
                msg.Flag = TradeDAL.QueryTrade(soapHeader.PosNO, out msg.Content, out msg.Text);
            }
            if (!msg.Flag)
            {
                WriteLog("QueryTrade", msg.Flag, msg.Text);
            }
            return(Converter.Serialize(msg));
        }
예제 #15
0
        public async Task <IActionResult> PostMessageAsync([FromBody] MMessage message)
        {
            int userId = int.Parse(User.Identity.Name);

            message.FromUserId = userId;
            foreach (var reply in message.Replies)
            {
                reply.UserId = userId;
            }

            message = await messagesRepository.AddMessageAsync(message);

            await discordService.SendMessageAsync(message.Id, Request.Headers["Origin"]);

            return(Ok(message));
        }
예제 #16
0
 /// <summary>
 /// 测试连接
 /// </summary>
 /// <returns></returns>
 public static bool HelloWorld(string Server, string Port, out string msg)
 {
     try
     {
         TransService TestClass = new TransService();
         TestClass.Url = @"http://" + Server + ":" + Port + @"/TransService.asmx";
         string            json = TestClass.HelloWorld();
         MMessage <string> mmsg = Converter.Deserialize <MMessage <string> >(json);
         msg = mmsg.Text;
         return(true);
     }
     catch (Exception ex)
     {
         msg = "连接错误:" + ex.Message;
         return(false);
     }
 }
예제 #17
0
        public string SaveTrade(string saleFlowJson, string payFlowJson)
        {
            MMessage <MCzCard> msg = new MMessage <MCzCard>();

            msg.Flag = isValid(soapHeader, out msg.Text);
            if (msg.Flag)
            {
                MSaleFlow[] saleFlowList = Converter.Deserialize <MSaleFlow[]>(saleFlowJson);
                MPayFlow[]  payFlowList  = Converter.Deserialize <MPayFlow[]>(payFlowJson);
                msg.Flag = TradeDAL.SaveTrade(saleFlowList, payFlowList, out msg.Content, out msg.Text);
            }
            if (!msg.Flag)
            {
                WriteLog("SaveTrade", msg.Flag, msg.Text);
            }
            return(Converter.Serialize(msg));
        }
예제 #18
0
        public async Task <MMessage> AddMessageAsync(MMessage message)
        {
            const string sql = "INSERT INTO dbo.Messages (FromUserId, ToUserId, Title) " +
                               "OUTPUT INSERTED.Id, INSERTED.FromUserId, INSERTED.ToUserId, INSERTED.Title, INSERTED.CreateDate " +
                               "VALUES (@FromUserId, @ToUserId, @Title);";

            var msg = await connection.QuerySingleAsync <MMessage>(sql, message);

            msg.Replies = new List <MMessageReply>();

            foreach (var reply in message.Replies)
            {
                reply.MessageId = msg.Id;
                msg.Replies.Add(await AddMessageReplyAsync(reply));
            }

            return(msg);
        }
예제 #19
0
 public RP6Control(Arduino arduino)
 {
     _arduino     = arduino;
     _moveMessage = new MMessage();
 }
예제 #20
0
 private void GoToMessage(MMessage msg)
 {
     NavigationManager.NavigateTo("/messages/" + msg.Id);
 }
예제 #21
0
        /// <summary>
        /// 读取参数
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool GetConfig(out string msg)
        {
            try
            {
                string json = TransClass.GetConfig();
                MMessage <MConfig[]> mmsg = Converter.Deserialize <MMessage <MConfig[]> >(
                    json);
                if (mmsg.Flag)
                {
                    foreach (MConfig config in mmsg.Content)
                    {
                        switch (config.ItemName)
                        {
                        case "RECEIPT HEAD1":
                            PubGlobal.SysConfig.PrnHeader1 = config.ItemValue;
                            break;

                        case "RECEIPT HEAD2":
                            PubGlobal.SysConfig.PrnHeader2 = config.ItemValue;
                            break;

                        case "RECEIPT HEAD3":
                            PubGlobal.SysConfig.PrnHeader3 = config.ItemValue;
                            break;

                        case "RECEIPT TAIL1":
                            PubGlobal.SysConfig.PrnFooter1 = config.ItemValue;
                            break;

                        case "RECEIPT TAIL2":
                            PubGlobal.SysConfig.PrnFooter2 = config.ItemValue;
                            break;

                        case "RECEIPT TAIL3":
                            PubGlobal.SysConfig.PrnFooter3 = config.ItemValue;
                            break;

                        case "ICNEWMM":
                            PubGlobal.SysConfig.CzkPassword = Des.DecryStrHex(config.ItemValue, "0125");
                            break;

                        case "IcLen":
                            PubGlobal.SysConfig.CzkLen = int.Parse(config.ItemValue);
                            break;

                        default:
                            break;
                        }
                    }
                    msg = "读取参数完毕";
                    return(true);
                }
                else
                {
                    msg = mmsg.Text;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                msg = "系统异常:" + ex.Message;
                return(false);
            }
        }
예제 #22
0
        public string CheckUpdate(string oldVersion, ref List <MDownloadfile> fileList)
        {
            MMessage <string> msg = new MMessage <string>();
            bool   update         = false;
            string newVersion;

            try
            {
                string _path = @"\Updates";
                string ss    = Server.MapPath(_path);
                if (File.Exists(Server.MapPath(_path + @"\POS.exe")))
                {
                    newVersion = FileVersionInfo.GetVersionInfo(Server.MapPath(_path + @"\POS.exe")).FileVersion;
                    //判断版本号
                    string[] oldVers = oldVersion.Split('.');
                    string[] newVers = newVersion.Split('.');
                    for (int i = 0; i < 4; i++)
                    {
                        //逐位比较版本号
                        if (int.Parse(oldVers[i]) == int.Parse(newVers[i]))
                        {
                            //旧版本号等于新版本号
                            update = false;
                            continue;
                        }
                        if (int.Parse(oldVers[i]) > int.Parse(newVers[i]))
                        {
                            //旧版本号大于新版本号
                            throw new Exception("本地版本比服务器版本高");
                        }
                        if (int.Parse(oldVers[i]) < int.Parse(newVers[i]))
                        {
                            //旧版本号小于新版本号
                            update = true;
                            break;
                        }
                    }
                    if (update)
                    {
                        #region 生成配置文件
                        //写配置文件
                        using (StreamWriter wt = new StreamWriter(Server.MapPath(_path + @"\Version.inf"), false))
                        {
                            wt.WriteLine(newVersion);
                            wt.Close();
                        }
                        #endregion

                        DirectoryInfo updateFolder = new DirectoryInfo(Server.MapPath(_path));
                        fileList = new List <MDownloadfile>();
                        foreach (FileInfo file in updateFolder.GetFiles())
                        {
                            fileList.Add(new MDownloadfile(file.Name, ZipClass.ZipFileToBytes(file.FullName)));
                        }
                        msg.Flag = true;
                        //msg.Content = fileList;
                        return(Converter.Serialize(msg));
                    }
                    else
                    {
                        msg.Flag = false;
                        msg.Text = "已是最新程序";
                        return(Converter.Serialize(msg));
                    }
                }
                else
                {
                    msg.Flag = false;
                    msg.Text = "更新文件不存在";
                    return(Converter.Serialize(msg));
                }
            }
            catch (Exception ex)
            {
                WriteLog("Update", false, ex.Message);
                msg.Flag    = false;
                msg.Text    = ex.Message;
                msg.Content = null;
                return(Converter.Serialize(msg));
            }
        }