Exemplo n.º 1
0
 protected virtual void OnConnect(ParseEventArgs e)
 {
     if (Connect != null)
     {
         Connect(this, e);
     }
 }
Exemplo n.º 2
0
 protected virtual void OnLookQzone(ParseEventArgs e)
 {
     if (LookQzone != null)
     {
         LookQzone(this, e);
     }
 }
Exemplo n.º 3
0
 protected virtual void OnLookNumber(ParseEventArgs e)
 {
     if (LookNumber != null)
     {
         LookNumber(this, e);
     }
 }
Exemplo n.º 4
0
 protected virtual void OnLookSos(ParseEventArgs e)
 {
     if (LookSos != null)
     {
         LookSos(this, e);
     }
 }
Exemplo n.º 5
0
        public void look_sos(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg   = new Regex("AT\\+uart:sos1,(.+?),sos2,(.+?),sos3,(.+?)#");
            Match  match = reg.Match(e.mLine);
            String sos1  = match.Groups[1].Value;
            String sos2  = match.Groups[2].Value;
            String sos3  = match.Groups[3].Value;

            if (sos1 != "?")
            {
                SOS1.Text = sos1;
            }
            if (sos2 != "?")
            {
                SOS2.Text = sos2;
            }
            if (sos3 != "?")
            {
                SOS3.Text = sos3;
            }
        }
Exemplo n.º 6
0
 protected virtual void OnLookUpload(ParseEventArgs e)
 {
     if (LookUpload != null)
     {
         LookUpload(this, e);
     }
 }
Exemplo n.º 7
0
 protected virtual void OnLookMonitor(ParseEventArgs e)
 {
     if (LookMonitor != null)
     {
         LookMonitor(this, e);
     }
 }
Exemplo n.º 8
0
 protected override void OnParsing(
     ParseEventArgs e)
 {
     if (SuppressTextInput)
     {
         // this is readonly control like ImageEdit, BackgroundEdit, text
         // of such control can not be changed by the user
         // so parsing is not needed
         e.Value     = null;
         e.Succeeded = false;
     }
     else
     {
         var ttva = new TextToValueArgs(e.Text);
         if (TextToValue(ttva))
         {
             e.Value     = ttva.Value;
             e.Succeeded = true;
         }
         else
         {
             e.Succeeded = false;
             e.ParseInfo.ErrorMessage = ttva.ErrorMessage;
         }
     }
     base.OnParsing(e);
 }
Exemplo n.º 9
0
        public void look_server(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg   = new Regex("AT\\+uart:ip_url,(.+?),port,(.+?),url,(.+?)#");
            Match  match = reg.Match(e.mLine);
            String ip    = match.Groups[1].Value;
            String port  = match.Groups[2].Value;
            String isIp  = match.Groups[3].Value;

            if (ip != "?")
            {
                IpUrl.Text = ip;
            }
            if (port != "?")
            {
                PortText.Text = port;
            }
            if (isIp == "1")
            {
                Domain.Checked = true;
            }
        }
Exemplo n.º 10
0
 protected virtual void OnLookImei(ParseEventArgs e)
 {
     if (LookImei != null)
     {
         LookImei(this, e);
     }
 }
Exemplo n.º 11
0
 public void connect(Object sender, ParseEventArgs e)
 {
     if (mIsStop)
     {
         return;
     }
     DataStatusText.Text = "已连接";
     byte[] command = Protocol.lookVer();
     mCom.Write(command, 0, Protocol.getDataLen());
 }
Exemplo n.º 12
0
 private static void Compare(ParseEventArgs e, string s, string o, params string[] vs)
 {
     Assert.AreEqual(s, e.SwitchName);
     Assert.AreEqual(o, e.OptionName);
     Assert.AreEqual(vs.Length, e.Values.Length);
     for (int i = 0; i < vs.Length; ++i)
     {
         Assert.AreEqual(vs[i], e.Values[i]);
     }
 }
Exemplo n.º 13
0
        private void parseData(String data)
        {
            if (mIsStop)
            {
                return;
            }
            ParseEventArgs e = null;

            if (data.Contains("AT:connect ok!#"))
            {
                e = new ParseEventArgs(data);
                OnConnect(e);
            }
            else if (data.Contains("AT+uart:ver,"))
            {
                e = new ParseEventArgs(data);
                OnLookVer(e);
            }
            else if (data.Contains("AT+uart:imei,"))
            {
                e = new ParseEventArgs(data);
                OnLookImei(e);
            }
            else if (data.Contains("AT+uart:ip_url,"))
            {
                e = new ParseEventArgs(data);
                OnLookServer(e);
            }
            else if (data.Contains("AT+uart:center_number,"))
            {
                e = new ParseEventArgs(data);
                OnLookNumber(e);
            }
            else if (data.Contains("AT+uart:language,"))
            {
                e = new ParseEventArgs(data);
                OnLookQzone(e);
            }
            else if (data.Contains("AT+uart:sos1,"))
            {
                e = new ParseEventArgs(data);
                OnLookSos(e);
            }
            else if (data.Contains("AT+uart:monitor,"))
            {
                e = new ParseEventArgs(data);
                OnLookMonitor(e);
            }
            else if (data.Contains("AT+uart:upload,"))
            {
                e = new ParseEventArgs(data);
                OnLookUpload(e);
            }
        }
Exemplo n.º 14
0
        private void conv_ParseNext(object?sender, ParseEventArgs e)
        {
            switch (_state)
            {
            case 0:
                Compare(e, string.Empty, string.Empty, "a", "b", "c");
                break;

            case 1:
                Compare(e, string.Empty, "o");
                break;

            case 2:
                Compare(e, string.Empty, "-option");
                break;

            case 3:
                Compare(e, "S", string.Empty);
                break;

            case 4:
                Compare(e, "switch", string.Empty, "val0", "val1");
                break;

            case 5:
                Compare(e, "switch", "x", "val2", "val3");
                break;

            case 6:
                Compare(e, "switch", "y");
                break;

            case 7:
                Compare(e, "switch", "-z");
                break;

            case 8:
                Compare(e, string.Empty, string.Empty, "a");
                break;

            case 9:
                Compare(e, string.Empty, string.Empty, "abc");
                break;

            case 10:
                Compare(e, "123", string.Empty, "/123", "!!");
                break;

            default:
                Assert.Fail("the state value: " + _state);
                break;
            }
            ++_state;
        }
Exemplo n.º 15
0
        private void Service_BeforeStlParse(object sender, ParseEventArgs e)
        {
            if (e.TemplateType != TemplateType.ContentTemplate || e.ContentId <= 0)
            {
                return;
            }

            var apiUrl = $"{Context.Environment.ApiUrl}/{PluginId}/hits/{e.SiteId}/{e.ChannelId}/{e.ContentId}";

            e.ContentBuilder.Append($@"
<script src=""{apiUrl}"" type=""text/javascript""></script>");
        }
Exemplo n.º 16
0
        private void WatchDog_ParseFileEvent(object sender, ParseEventArgs e)
        {
            Logger.GetInstance().Info(e.FilePath + " dosyası okunacak");
            try
            {
                if (File.Exists(e.FilePath))
                {
                    using (FileStream fs = new FileStream(e.FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (StreamReader sr = new StreamReader(fs))
                        {
                            string content = sr.ReadToEnd();
                            if (BL.IsValidHTML(content))
                            {
                                List <ParsedData> parsedData     = BL.Parse(content);
                                RequestBarcode    requestBarcode = BL.CreateRequestModel(parsedData);



                                lastRequestBarcode = requestBarcode;
                                if (!Settings.Default.IsManuelMode)
                                {
                                    ResponseBarcode responseBarcode = BL.PostRequest(requestBarcode);
                                    if (responseBarcode.Data != null)
                                    {
                                        new Thread(() => ShowNotification(responseBarcode)).Start();
                                    }

                                    else
                                    {
                                        new FormNotification("Aradığınız ilaç için veriler henüz eklenmedi. En kısa sürede eklenecektir", NotificationType.Warning).ShowDialog();
                                    }
                                }
                            }
                            else
                            {
                                Logger.GetInstance().Info(e.FilePath + " dosyasının içeriğinde \"" + Settings.Default.IsParseableKeyword + "\" geçemediği için ya da Recete No=0 olduğu için okunamadı");
                            }
                        }
                        fs.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.GetInstance().Error("Dosya okunurken hata oluştu", ex);
                new FormNotification("FarmaKode hata. " + ex.Message, NotificationType.Error).ShowDialog();
            }
        }
Exemplo n.º 17
0
        public void look_imei(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg   = new Regex("AT\\+uart:imei,(.+?)#");
            Match  match = reg.Match(e.mLine);
            String imei  = match.Groups[1].Value;

            if (imei != "?")
            {
                ImeiText.Text = imei;
            }
        }
Exemplo n.º 18
0
        public void look_ver(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg   = new Regex("AT\\+uart:ver,(.+?)#");
            Match  match = reg.Match(e.mLine);
            string value = match.Groups[1].Value;

            if (value != "?")
            {
                LookVerText.Text = value;
            }
        }
Exemplo n.º 19
0
        public void look_monitor(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg     = new Regex("AT\\+uart:monitor,(.+?)#");
            Match  match   = reg.Match(e.mLine);
            String monitor = match.Groups[1].Value;

            if (monitor != "?")
            {
                Monitor.Text = monitor;
            }
        }
Exemplo n.º 20
0
        public void look_upload(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg    = new Regex("AT\\+uart:upload,(.+?)#");
            Match  match  = reg.Match(e.mLine);
            String upload = match.Groups[1].Value;

            if (upload != "?")
            {
                Upload.Text = upload;
            }
        }
Exemplo n.º 21
0
        private static bool IsAdvertisementExists(ParseEventArgs args)
        {
            var lists = GetAdvertisementLists(args.SiteId);

            if (args.TemplateType == TemplateType.IndexPageTemplate || args.TemplateType == TemplateType.ChannelTemplate)
            {
                var list = lists[0];
                return(list.Contains(args.ChannelId));
            }

            if (args.TemplateType == TemplateType.ContentTemplate)
            {
                var list = lists[1];
                return(list.Contains(args.ContentId));
            }

            return(false);
        }
Exemplo n.º 22
0
        public void look_number(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg          = new Regex("AT\\+uart:center_number,(.+?),slave_number,(.+?)#");
            Match  match        = reg.Match(e.mLine);
            String centerNumber = match.Groups[1].Value;
            String slaveNumber  = match.Groups[2].Value;

            if (centerNumber != "?")
            {
                CenterNumberText.Text = centerNumber;
            }
            if (slaveNumber != "?")
            {
                SlaveNumberText.Text = slaveNumber;
            }
        }
Exemplo n.º 23
0
        public void look_qzone(Object sender, ParseEventArgs e)
        {
            if (mIsStop)
            {
                return;
            }
            Regex  reg      = new Regex("AT\\+uart:language,(.+?),zone,(.+?)#");
            Match  match    = reg.Match(e.mLine);
            String language = match.Groups[1].Value;
            String zone     = match.Groups[2].Value;

            if (language != "?")
            {
                LanguageText.Text = language;
            }
            if (zone != "?")
            {
                QzoneText.Text = zone;
            }
        }
Exemplo n.º 24
0
        private void Service_AfterStlParse(object sender, ParseEventArgs e)
        {
            var configInfo = GetConfig(e.SiteId);

            if (!configInfo.IsEnabled)
            {
                return;
            }

            var isChannel = false;

            if (configInfo.IsAllChannels)
            {
                isChannel = true;
            }
            else
            {
                if (configInfo.BlockChannels != null && configInfo.BlockChannels.Contains(e.ChannelId))
                {
                    isChannel = true;
                }
            }

            if (!isChannel)
            {
                return;
            }

            e.ContentBuilder.Replace("<body", @"<body style=""display: none""");

            var pluginUrl = Context.PluginApi.GetPluginUrl(Utils.PluginId);

            e.HeadCodes[Utils.PluginId] = $@"
<script src=""{pluginUrl}/assets/lib/es6-promise.auto.min.js"" type=""text/javascript""></script>
<script src=""{pluginUrl}/assets/lib/axios-0.18.0.min.js"" type=""text/javascript""></script>
<script src=""{pluginUrl}/assets/lib/sweetalert2-7.28.4.all.min.js"" type=""text/javascript""></script>
<script src=""{pluginUrl}/assets/js/swal2.js"" type=""text/javascript""></script>
<script src=""{pluginUrl}/assets/block.js"" data-api-url=""{Context.Environment.ApiUrl}"" data-site-id=""{e.SiteId}"" type=""text/javascript""></script>
";
        }
Exemplo n.º 25
0
 private static void Service_BeforeStlParse(object sender, ParseEventArgs e)
 {
     AdvertisementManager.AddAdvertisements(e);
 }
Exemplo n.º 26
0
        public static void AddAdvertisements(ParseEventArgs args)
        {
            if (!IsAdvertisementExists(args))
            {
                return;
            }

            var advertisementInfoList = Repository.GetAdvertisementInfoList(args.SiteId);

            foreach (var adInfo in advertisementInfoList)
            {
                if (adInfo.IsDateLimited)
                {
                    if (DateTime.Now < adInfo.StartDate || DateTime.Now > adInfo.EndDate)
                    {
                        continue;
                    }
                }
                var isToDo = false;
                if (args.TemplateType == TemplateType.IndexPageTemplate || args.TemplateType == TemplateType.ChannelTemplate)
                {
                    if (!string.IsNullOrEmpty(adInfo.ChannelIdCollectionToChannel))
                    {
                        var nodeIdArrayList = Utils.StringCollectionToIntList(adInfo.ChannelIdCollectionToChannel);
                        if (nodeIdArrayList.Contains(args.ChannelId))
                        {
                            isToDo = true;
                        }
                    }
                }
                else if (args.TemplateType == TemplateType.ContentTemplate)
                {
                    if (!string.IsNullOrEmpty(adInfo.ChannelIdCollectionToContent))
                    {
                        var nodeIdArrayList = Utils.StringCollectionToIntList(adInfo.ChannelIdCollectionToContent);
                        if (nodeIdArrayList.Contains(args.ContentId))
                        {
                            isToDo = true;
                        }
                    }
                }

                if (!isToDo)
                {
                    continue;
                }

                var scripts = string.Empty;
                if (EAdvertisementTypeUtils.Equals(adInfo.AdvertisementType, EAdvertisementType.FloatImage))
                {
                    args.HeadCodes["JsAdFloating"] =
                        $@"<script type=""text/javascript"" src=""{Context.PluginApi.GetPluginUrl(Utils.PluginId, "assets/adFloating.js")}""></script>";

                    var floatScript = new ScriptFloating(adInfo);
                    scripts = floatScript.GetScript();
                }
                else if (EAdvertisementTypeUtils.Equals(adInfo.AdvertisementType, EAdvertisementType.ScreenDown))
                {
                    if (!args.HeadCodes.ContainsKey("Jquery"))
                    {
                        args.HeadCodes["Jquery"] =
                            $@"<script type=""text/javascript"" src=""{Context.PluginApi.GetPluginUrl(Utils.PluginId, "assets/jquery-1.9.1.min.js")}""></script>";
                    }

                    var screenDownScript = new ScriptScreenDown(adInfo);
                    scripts = screenDownScript.GetScript();
                }
                else if (EAdvertisementTypeUtils.Equals(adInfo.AdvertisementType, EAdvertisementType.OpenWindow))
                {
                    var openWindowScript = new ScriptOpenWindow(adInfo);
                    scripts = openWindowScript.GetScript();
                }

                args.BodyCodes[adInfo.AdvertisementType + "_" + adInfo.AdvertisementName] = scripts;
            }
        }
Exemplo n.º 27
0
 public void OnAfterStlParse(ParseEventArgs e)
 {
     AfterStlParse?.Invoke(this, e);
 }
Exemplo n.º 28
0
 public void OnBeforeStlParse(ParseEventArgs e)
 {
     BeforeStlParse?.Invoke(this, e);
 }