public void AddDevicesToGroup(List <string> deviceNames, string groupName)
 {
     DeviceHelper.AddDevicesFromListsToGroup(deviceNames, groupName, TVs.Cast <SmartDevice>().ToList(), radios.Cast <SmartDevice>().ToList());
 }
Ejemplo n.º 2
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace("Begin Process Data");

                //Lưu lại Data
                Log.Trace(StringData);

                string strResult = StringData;
                while (!Char.IsLetterOrDigit(strResult[0]))
                {
                    strResult = strResult.Remove(0, 1);
                }

                //Lay ve ngay thang nam lam xn
                string pMonth = strResult.Substring(5).Substring(4, 5).Replace(".", "").Trim();
                //lấy tháng
                pMonth = DeviceHelper.GetMonth(pMonth);
                //Lấy ngày
                string pDay = strResult.Substring(5).Substring(0, 3).Replace(".", "").Trim();
                //lấy Năm
                string pYear = strResult.Substring(5).Substring(9, 4).Trim();
                if (pDay.Length == 1)
                {
                    pDay = "0" + pDay;
                }

                string tempTestDate = string.Format("{0}/{1}/20{2}", pDay, pMonth, pYear);

                IEnumerable <string> arrPatients = SeparatorData(strResult);
                //duyệt từng bệnh nhân
                foreach (string patient in arrPatients)
                {
                    TestResult.TestDate = tempTestDate;
                    string[] allRecord = patient.Split(DeviceHelper.CR);
                    for (int i = 0; i <= 2; i++)
                    {
                        if (i == 0)
                        {
                            TestResult.TestSequence = allRecord[i].Split()[1];
                            TestResult.Barcode      = allRecord[i].Split()[0];
                        }
                        else
                        {
                            string testName;
                            string testValue;
                            if (i == 1)
                            {
                                testName  = "TT";
                                testValue = allRecord[i].Substring(0, 4).Trim();
                                if (testValue != "")
                                {
                                    AddResult(new ResultItem(testName, testValue));
                                    Log.Debug("Add new result Success: TestName={0} TestValue = {1}", testName,
                                              testValue);
                                }

                                testName  = "TT(%)";
                                testValue = allRecord[i].Substring(4, 4).Trim();
                                if (testValue != "")
                                {
                                    AddResult(new ResultItem(testName, testValue));
                                    Log.Debug("Add new result Success: TestName={0} TestValue = {1}", testName,
                                              testValue);
                                }

                                testName  = "PT-INR";
                                testValue = allRecord[i].Substring(9, 5).Trim();
                                if (testValue != "")
                                {
                                    AddResult(new ResultItem(testName, testValue));
                                    Log.Debug("Add new result Success: TestName={0} TestValue = {1}", testName,
                                              testValue);
                                }

                                testName  = "FIB";
                                testValue = allRecord[i].Substring(14, 4).Trim();
                                if (testValue != "")
                                {
                                    AddResult(new ResultItem(testName, testValue));
                                    Log.Debug("Add new result Success: TestName={0} TestValue = {1}", testName,
                                              testValue);
                                }
                            }
                            else
                            {
                                try
                                {
                                    testName  = "APTT";
                                    testValue = allRecord[i].Substring(0, 4).Trim();
                                    if (testValue != "")
                                    {
                                        AddResult(new ResultItem(testName, testValue));
                                        Log.Debug("Add new result Success: TestName={0} TestValue = {1}", testName,
                                                  testValue);
                                    }

                                    testName  = "APTT-INR";
                                    testValue = allRecord[i].Substring(4, 4).Trim();
                                    if (testValue != "")
                                    {
                                        AddResult(new ResultItem(testName, testValue));
                                        Log.Debug("Add new result Success: TestName={0} TestValue = {1}", testName,
                                                  testValue);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Log.Error("Error while add APTT or APTT-INR {0}", ex.ToString());
                                }
                            }
                        }
                    }
                    Log.Debug("Begin Import Result");
                    ImportResults();
                    Log.Debug("Import Result Success");
                }
                Log.Trace("Finish Process Data {0}", DeviceHelper.CRLF);
            }
            catch (Exception ex)
            {
                //  throw ex;
                Log.Error(string.Format("{0} /n {1}", "Lỗi Trong quá trình xử lý dữ liệu", ex));
            }
            finally
            {
                ClearData();
            }
        }
 public List <SmartDevice> GetGroup(string groupName) //Radios and tvs of same group
 {
     return(DeviceHelper.GetGroupFromDeviceLists(groupName, TVs.Cast <SmartDevice>().ToList(), radios.Cast <SmartDevice>().ToList()));
 }
Ejemplo n.º 4
0
        public MainPage()
        {
            InitializeComponent();

            var list = new ObservableCollection <Announcement>
            {
                new Announcement
                {
                    ID         = 1,
                    Title      = "Yedek parça siparişlerinizde %22' ye varan indirim!",
                    ImagePath  = "https://image5.sahibinden.com/photos/08/54/18/x5_719085418j7p.jpg",
                    IsActive   = true,
                    CreateDate = DateTime.Now,
                },
                new Announcement
                {
                    ID         = 2,
                    Title      = "Fren Balataları Hangi Sıklıkla Değiştirilmelidir?",
                    ImagePath  = "https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTJzQfduSrJ3Nh7SHzGSGrCmTnWses4AcfuRSnU7hX4y9XN4TSU&usqp=CAU",
                    IsActive   = true,
                    CreateDate = DateTime.Now,
                }
            };

            DeviceHelper helper = DependencyService.Get <IDeviceHelper>().GetDevice();

            double height = 0;

            //double width = helper.ScreenWidth / 2 - 30;

            for (int m = 0; m < 6; m++)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    Frame frame = new Frame
                    {
                        Padding = new Thickness(0, 0, 0, 0)
                    };

                    // Stack
                    StackLayout stack = new StackLayout
                    {
                        Margin = new Thickness(10),
                    };

                    // Image
                    Image image = new Image
                    {
                        Source            = list[i].ImagePath,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand
                    };

                    // Title
                    Label title = new Label
                    {
                        Text     = list[i].Title,
                        Margin   = new Thickness(0, 6, 0, 0),
                        FontSize = 13
                    };

                    // Date
                    Label date = new Label
                    {
                        Text      = list[i].CreateDate.ToString().Substring(0, 10), // temporary workaround
                        Margin    = new Thickness(0, 6, 0, 0),
                        TextColor = Color.Gray,
                        FontSize  = 11
                    };

                    stack.Children.Add(image);
                    stack.Children.Add(title);
                    stack.Children.Add(date);

                    frame.Content = stack;


                    if (i % 2 == 0)
                    {
                        stckLeft.Children.Add(frame);
                    }
                    else
                    {
                        stckRight.Children.Add(frame);

                        SizeRequest columnSizeRequest = frame.Measure(300, 400);
                        height += columnSizeRequest.Request.Height * 6;
                    }
                }
            }
            stckLeft.HeightRequest  = height;
            stckRight.HeightRequest = height;

            scrList.HeightRequest = helper.ScreenHeight - 100;
            //stckParent.HeightRequest = list.Count * 100;
        }
Ejemplo n.º 5
0
        public override void OnInCommingData(object obj)
        {
            try
            {
                // Chuyển kiểu dữ liệu về dạng DataReceiveRs232 do lớp Base Devices chỉ gửi Object
                var rawData = (DataReceiveRs232)obj;
                if (rawData != null)
                {
                    // Nếu chưa gán Port thì gán
                    SetNetStream(rawData.Port);

                    byte[] allbyte = rawData.Data;
                    _tempbuffer = string.Concat(_tempbuffer, Encoding.ASCII.GetString(allbyte));

                    for (int i = 0; i < allbyte.Length; ++i)
                    {
                        byte onebyte = allbyte[i];
                        if (onebyte.Equals((byte)DeviceHelper.ENQ))
                        {
                            Log.Debug(@"ASTM Machine: <ENQ>");
                            DumpStateMachine(objWorkFlowRuntime, InstanceId);
                            objASTM.CallGetENQ(objDataEventArgs);
                            BufferData = _tempbuffer = string.Empty;
                            _timeoutManager.Stop();
                            _timeoutManager.Start();
                        }
                        else if (onebyte.Equals((byte)DeviceHelper.LF))
                        {
                            Log.Debug("ASTM Machine: {0}", _tempbuffer);
                            _timeoutManager.Stop();

                            string temp = DeviceHelper.GetStringAfterCheckSum(_tempbuffer);
                            _tempbuffer = string.Empty;
                            if (temp != string.Empty)
                            {
                                //SendStringData(DeviceHelper.ACK.ToString());
                                objASTM.CallGetRightFrame(objDataEventArgs);
                                BufferData = string.Concat(BufferData, temp);
                            }

                            else
                            {
                                //SendByte((byte)DeviceHelper.NAK);
                                objASTM.CallGetWrongFrame(objDataEventArgs);
                            }
                            _timeoutManager.Start();
                        }
                        else if (onebyte.Equals((byte)DeviceHelper.EOT))
                        {
                            Log.Debug(@"ASTM Machine: <EOT>");
                            objASTM.CallGetEOT(objDataEventArgs);
                            _timeoutManager.Stop();
                            var orderString = new List <string>();
                            if (ProcessData(BufferData, ref orderString))
                            {
                                if (_prvRequestArray != null)
                                {
                                    if (orderString.Count > 0)
                                    {
                                        _prvRequestArray.Enqueue(orderString);
                                    }
                                }
                            }
                            if (_prvRequestArray != null && _prvRequestArray.Count != 0)
                            {
                                Log.Debug(@"Number of order in queue: {0}", _prvRequestArray.Count);
                                objASTM.CallGetQuery(objDataEventArgs);

                                _timeoutManager.Start();
                            }

                            //Send((int)EventID.GetEOT,_newQuery);
                        }
                        else if (onebyte.Equals((byte)DeviceHelper.ACK))
                        {
                            //Send((int) EventID.GetACK);
                            Log.Debug(@"ASTM Machine: <ACK>");
                            DumpStateMachine(objWorkFlowRuntime, InstanceId);
                            _timeoutManager.Stop();
                            objASTM.CallGetACK(objDataEventArgs);
                            if (_lastState == 0)
                            {
                                _currentOrder    = _prvRequestArray.Dequeue();
                                _currentOrderIdx = 0;
                            }
                            _lastState++;
                            if (((_currentOrder != null) && (_currentOrder.Count != 0)) &&
                                (_currentOrderIdx < _currentOrder.Count))
                            {
                                _prvLastStringRequest = _currentOrder[_currentOrderIdx];
                                _currentOrderIdx++;
                                Log.Debug("Send String Data: {0}", _prvLastStringRequest);
                                SendStringData(_prvLastStringRequest);
                                _timeoutManager.Start();
                            }
                            else
                            {
                                //SendByte((byte)DeviceHelper.EOT);
                                _timeoutManager.Stop();
                                Log.Debug(@"Session closing ...");
                                objASTM.CallCloseSession(objDataEventArgs);

                                if (_prvRequestArray != null && _prvRequestArray.Count != 0)
                                {
                                    objASTM.CallGetQuery(objDataEventArgs);

                                    _timeoutManager.Start();
                                }
                            }
                        }
                        else if (onebyte.Equals((byte)DeviceHelper.NAK))
                        {
                            _timeoutManager.Stop();
                            Log.Debug(@"ASTM Machine: <NAK>");
                            if (++_failSending < 5)
                            {
                                if (_lastState > 0)
                                {
                                    objASTM.CallGetNAK(objDataEventArgs);
                                    SendStringData(_prvLastStringRequest);
                                }
                                //if NAK after ENQ sent then session must be closed
                                else
                                {
                                    Log.Debug(@"Get NAK after ENQ sent. Session closing ...");
                                    objASTM.CallCloseSession(objDataEventArgs);
                                }

                                _timeoutManager.Start();
                            }
                            else
                            {
                                Log.Error("Too much NAK! Session closed!");
                                objASTM.CallCloseSession(objDataEventArgs);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("Error: {0}", ex));
            }
        }
Ejemplo n.º 6
0
 public void loadAllDevices()
 {
     inputDevices  = DeviceHelper.getAvailableInputDevices();
     outputDevices = DeviceHelper.getAvailableOutputDevices();
 }
Ejemplo n.º 7
0
 protected override void OnAwake()
 {
     memoryStreamForCameraInfo = new MemoryStream();
     cam      = gameObject.GetComponent <SensorDevices.MultiCamera>();
     partName = DeviceHelper.GetPartName(gameObject);
 }
 private string OrderPath()
 {
     return(Application.persistentDataPath + "/" + Obj_MyselfPlayer.GetMe().accountID + DeviceHelper.GetChannelID() + ".data");
 }
Ejemplo n.º 9
0
 public List <SmartDevice> GetGroup(string groupName) //Radios and tvs of same group
 {
     return(DeviceHelper.GetGroupFromDeviceLists(groupName, cameras.Cast <SmartDevice>().ToList(), motionSensors.Cast <SmartDevice>().ToList()));
 }
Ejemplo n.º 10
0
        public override void ProcessRawData()
        {
            Log.Trace("Begin Process Data");
            Log.Trace("Raw Data \n {0}", StringData);
            try
            {
                // Tách riêng dữ liệu của từng bệnh nhân
                IEnumerable <string> allPatients = SeparatorData(StringData);

                // Xử lý dữ liệu của từng bệnh nhân
                foreach (string patient in allPatients)
                {
                    try
                    {
                        string[] strResult = DeviceHelper.DeleteAllBlankLine(patient, DeviceHelper.CRLF, false);

                        // Lấy Ngày tháng
                        string sTemp = strResult[0];
                        TestResult.TestDate = sTemp.ToUpper().StartsWith("DATE")
                            ? sTemp.Substring(sTemp.IndexOf(':') + 1, 10)
                            : DateTime.Now.ToString("dd/MM/yyyy");

                        //Lấy barcode:
                        sTemp = strResult[2];
                        sTemp = sTemp.Substring(sTemp.IndexOf(':') + 1).Replace("-", "");
                        TestResult.Barcode = sTemp == "" ? "0" : sTemp;
                        Log.Debug("Begin Add result for barcode: {0}", TestResult.Barcode);

                        for (int i = 3; i < strResult.Length; i++)
                        {
                            strResult[i] = strResult[i].Substring(0, strResult[i].Length - 6);
                            string   testName  = strResult[i].Substring(0, 4).Replace("*", "").Trim();
                            string[] tempValue = DeviceHelper.DeleteAllBlankLine(strResult[i], " ");
                            string   testValue = tempValue[tempValue.Length - 1];
                            if (testValue.ToUpper() == "POS")
                            {
                                testValue = "Positive";
                            }
                            else if (testValue.ToUpper() == "NEG")
                            {
                                testValue = "Negative";
                            }
                            AddResult(new ResultItem(testName, testValue));
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    Log.Debug(ImportResults() ? "Import Result Success" : "Error While Import Result");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ClearData();
            }
        }
Ejemplo n.º 11
0
    // 根据选择语言进行初始化
    public static int init()
    {
        destroy();

        countryCodeTable  = new Dictionary <string, string[]>();
        countryIdTable    = new Dictionary <int, string[]>();
        languageCodeTable = new Dictionary <string, string[]>();
        languageIdTable   = new Dictionary <int, string[]>();

        // 读取国家信息
        TableUtil _countryTxt = new TableUtil();

        if (_countryTxt.OpenFromData("localization_country.txt") == false)
        {
            return(-1);
        }
        for (int row = 0; row < _countryTxt.GetRecordsNum(); row++)
        {
            string countryCode   = _countryTxt.GetValue(row, 0);       //  国家英文代码(国际标准)
            string CountryID     = _countryTxt.GetValue(row, 1);       //  国家数字代码(国际标准)
            string CountryNameID = _countryTxt.GetValue(row, 2);       //  国家名称ID
            string CountryFlag   = _countryTxt.GetValue(row, 3);       //  国旗资源名
            string CountryMoney  = _countryTxt.GetValue(row, 4);       //  货币简称

            // 英文编码作key
            if (countryCodeTable.ContainsKey(countryCode) == false)
            {
                string[] ls = new string[4];
                ls[0] = CountryID;
                ls[1] = CountryNameID;
                ls[2] = CountryFlag;
                ls[3] = CountryMoney;
                countryCodeTable.Add(countryCode, ls);
            }
            // 数字编码作key
            if (countryIdTable.ContainsKey(Convert.ToInt32(CountryID)) == false)
            {
                string[] ls = new string[4];
                ls[0] = countryCode;
                ls[1] = CountryNameID;
                ls[2] = CountryFlag;
                ls[3] = CountryMoney;
                countryIdTable.Add(Convert.ToInt32(CountryID), ls);
            }
        }

        // 读取语言信息
        TableUtil _languageTxt = new TableUtil();

        if (_languageTxt.OpenFromData("localization_language.txt") == false)
        {
            return(-2);
        }
        for (int row = 0; row < _languageTxt.GetRecordsNum(); row++)
        {
            string LanguageCode      = _languageTxt.GetValue(row, 0);       //  语言英文代码(国际标准)
            string LanguageCustomID  = _languageTxt.GetValue(row, 1);       //  语言自定义ID(无标准,暂时跟u3d里定义的语言ID走)
            string LanguageNameID    = _languageTxt.GetValue(row, 2);       //  语言名称ID
            string LanguageDirectory = _languageTxt.GetValue(row, 3);       //  语言存在目录
            string TranslationCode   = _languageTxt.GetValue(row, 4);       //  翻译Code

            // 英文编码作key
            if (languageCodeTable.ContainsKey(LanguageCode) == false)
            {
                string[] ls = new string[4];
                ls[0] = LanguageCustomID;
                ls[1] = LanguageNameID;
                ls[2] = LanguageDirectory;
                ls[3] = TranslationCode;
                languageCodeTable.Add(LanguageCode, ls);
            }
            // 数字编码作key
            if (languageIdTable.ContainsKey(Convert.ToInt32(LanguageCustomID)) == false)
            {
                string[] ls = new string[4];
                ls[0] = LanguageCode;
                ls[1] = LanguageNameID;
                ls[2] = LanguageDirectory;
                ls[3] = TranslationCode;
                languageIdTable.Add(Convert.ToInt32(LanguageCustomID), ls);
            }
        }

        // 用户本地配置文件里获取玩家已经选择的国家语言
        IniUtil userIni = new IniUtil();

        userIni.OpenFromTXT(PathUtil.ConfigPath() + "user.txt");

        // 读取使用语言
        currentLanguage = userIni.ReadValue("LANGUAGE", "").ToString();
        if (currentLanguage == "")
        {
            // 没有存档的,那么使用配置文件默认的
            IniUtil appIni = new IniUtil();
            appIni.OpenFromData("app.txt");
            currentLanguage = appIni.ReadValue("DEFAULT_LANGUAGE", "").ToString();
            userIni.WriteValue("LANGUAGE", currentLanguage);
        }

        if (currentLanguage == "")
        {
            // 没有默认的,那么使用设备当前的
            currentLanguage = DeviceHelper.getLanguage();
            userIni.WriteValue("LANGUAGE", currentLanguage);
        }

        // 读取使用国家
        currentCountry = userIni.ReadValue("COUNTRY", "").ToString();
        if (currentCountry == "")
        {
            // 没有存档的,使用设备当前的
            currentCountry = DeviceHelper.getCountry();
            userIni.WriteValue("COUNTRY", currentCountry);
        }

        // 先去语言信息里找一下,语言-地区的目录(如zh-cn),没有则直接使用语言(如zh,ru,en等),还是没有则使用英文的
        string localizeDir = languageDirectory(currentLanguage + "-" + currentCountry);

        if (localizeDir == "")
        {
            localizeDir = languageDirectory(currentLanguage);
            if (localizeDir == "")
            {
                //localizeDir = languageDirectory( "en" );
                localizeDir = languageDirectory("tw");
                if (localizeDir == "")
                {
                    return(-3);
                }
            }
        }
        localizeDir = localizeDir + "/";

        // 读取基础文字表
        TableUtil _localizetxt = new TableUtil();

        localize = new Dictionary <int, string>();
        if (_localizetxt.OpenFromData(localizeDir + "localize.txt") == false)
        {
            // 没有对应的语言文件夹,用英语的
            //localizeDir = languageDirectory( "en" ) + "/";
            localizeDir = languageDirectory("tw") + "/";
            if (_localizetxt.OpenFromData(localizeDir + "localize.txt") == false)
            {
                return(-4);
            }
        }

        for (int row = 0; row < _localizetxt.GetRecordsNum(); row++)
        {
            int    key  = Convert.ToInt32(_localizetxt.GetValue(row, 0));
            string text = _localizetxt.GetValue(row, 1);
            text = text.Replace("\\n", "\n");
            localize.Add(key, text);
        }

        // 读取道具文字表
        TableUtil _localizeItemTxt = new TableUtil();

        localize_item = new Dictionary <int, string>();
        if (_localizeItemTxt.OpenFromData(localizeDir + "localize_item.txt") == false)
        {
            // 没有对应的语言文件夹,用英语的
            //localizeDir = languageDirectory( "en" ) + "/";
            localizeDir = languageDirectory("tw") + "/";
            if (_localizeItemTxt.OpenFromData(localizeDir + "localize_item.txt") == false)
            {
                return(-5);
            }
        }

        for (int row = 0; row < _localizeItemTxt.GetRecordsNum(); row++)
        {
            int    key  = Convert.ToInt32(_localizeItemTxt.GetValue(row, 0));
            string text = _localizeItemTxt.GetValue(row, 1);
            text = text.Replace("\\n", "\n");
            localize_item.Add(key, text);
        }

        // 读取任务文字表
        TableUtil _localizeQuestTxt = new TableUtil();

        localize_quest = new Dictionary <int, string>();
        if (_localizeQuestTxt.OpenFromData(localizeDir + "localize_quest.txt") == false)
        {
            // 没有对应的语言文件夹,用英语的
            //localizeDir = languageDirectory( "en" ) + "/";
            localizeDir = languageDirectory("tw") + "/";
            if (_localizeQuestTxt.OpenFromData(localizeDir + "localize_quest.txt") == false)
            {
                return(-6);
            }
        }

        for (int row = 0; row < _localizeQuestTxt.GetRecordsNum(); row++)
        {
            int    key  = Convert.ToInt32(_localizeQuestTxt.GetValue(row, 0));
            string text = _localizeQuestTxt.GetValue(row, 1);
            text = text.Replace("\\n", "\n");
            localize_quest.Add(key, text);
        }

        // 容错处理,所有找不到的文字使用英文
        //localizeDir = languageDirectory( "en" ) + "/";
        localizeDir = languageDirectory("tw") + "/";

        // 读取基础文字表
        TableUtil localizetxt_en_us = new TableUtil();

        localize_en_us = new Dictionary <int, string>();
        localizetxt_en_us.OpenFromData(localizeDir + "localize.txt");
        for (int row = 0; row < localizetxt_en_us.GetRecordsNum(); row++)
        {
            int    key  = Convert.ToInt32(localizetxt_en_us.GetValue(row, 0));
            string text = localizetxt_en_us.GetValue(row, 1);
            text = text.Replace("\\n", "\n");
            localize_en_us.Add(key, text);
        }

        // 读取道具文字表
        TableUtil localizeitemtxt_en_us = new TableUtil();

        localize_item_en_us = new Dictionary <int, string>();
        localizeitemtxt_en_us.OpenFromData(localizeDir + "localize_item.txt");
        for (int row = 0; row < localizeitemtxt_en_us.GetRecordsNum(); row++)
        {
            int    key  = Convert.ToInt32(localizeitemtxt_en_us.GetValue(row, 0));
            string text = localizeitemtxt_en_us.GetValue(row, 1);
            text = text.Replace("\\n", "\n");
            localize_item_en_us.Add(key, text);
        }

        // 读取任务文字表
        TableUtil localizequesttxt_en_us = new TableUtil();

        localize_quest_en_us = new Dictionary <int, string>();
        localizequesttxt_en_us.OpenFromData(localizeDir + "localize_quest.txt");
        for (int row = 0; row < localizequesttxt_en_us.GetRecordsNum(); row++)
        {
            int    key  = Convert.ToInt32(localizequesttxt_en_us.GetValue(row, 0));
            string text = localizequesttxt_en_us.GetValue(row, 1);
            text = text.Replace("\\n", "\n");
            localize_quest_en_us.Add(key, text);
        }
        bInited = true;
        return(0);
    }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var i = (int)value;

            return(i == 2 || (DeviceHelper.IsType(DeviceFamily.Mobile) && i == 0));
        }
Ejemplo n.º 13
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace("Begin Process Data");
                Log.Debug("Raw Data: {0}{1}", DeviceHelper.CRLF, StringData);
                if (!StringData.EndsWith(string.Format("{0}{0}", DeviceHelper.CRLF)))
                {
                    return;
                }
                string[] strResutl = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.CRLF.ToCharArray());

                //TestResult.TestDate = strResutl[5].Substring(0, 9).Trim();
                string   pTempTestDate = strResutl[strResutl.Length - 1].Substring(0, 9).Trim();
                string[] tmpDate       = pTempTestDate.Split('-');
                string   pTestDate     = tmpDate[0];
                pTestDate = GetMonth(pTestDate);

                TestResult.TestDate = string.Format("{0}/{1}/20{2}", tmpDate[1], pTestDate, tmpDate[2]);

                //Tìm chuỗi ID# - Nếu không có => Barcode = ""
                int iDrowNumber = GetRowIndex(strResutl, "ID#");
                // Nếu kô tìm thấy => Barcode = "" nếu có lấy ID
                if (iDrowNumber == -1)
                {
                    TestResult.Barcode = "";
                    iDrowNumber        = GetRowIndex(strResutl, "SAMPLE");
                    if (iDrowNumber != -1)
                    {
                        TestResult.TestSequence = strResutl[iDrowNumber].Substring(6).Trim();
                    }
                }
                else
                {
                    TestResult.Barcode = strResutl[iDrowNumber].Substring(3).Trim();
                }

                // Trường hợp có kết quả thì xử lý
                if (iDrowNumber != -1)
                {
                    // Nếu dòng thứ 2 có chứa CL thì lấy kết quả 1 dòng
                    if (strResutl[iDrowNumber + 1].IndexOf("Cl") > 0)
                    {
                        string temResult = strResutl[iDrowNumber + 1];
                        AddResult(new ResultItem(temResult.Substring(0, 2).Trim(), temResult.Substring(2, 6).Trim()));
                        AddResult(new ResultItem(temResult.Substring(9, 2).Trim(), temResult.Substring(11, 6).Trim()));
                        AddResult(new ResultItem(temResult.Substring(17, 2).Trim(), temResult.Substring(19).Trim()));
                    }
                    else
                    {
                        string temResult = strResutl[iDrowNumber + 1];
                        AddResult(new ResultItem(temResult.Substring(0, 2).Trim(), temResult.Substring(2, 6).Trim()));
                        AddResult(new ResultItem(temResult.Substring(9, 2).Trim(), temResult.Substring(11).Trim()));
                        temResult = strResutl[iDrowNumber + 2];
                        AddResult(new ResultItem(temResult.Substring(0, 2).Trim(), temResult.Substring(2, 5).Trim()));
                        //AddResult(new ResultItem(temResult.Substring(8, 2).Trim(), temResult.Substring(2, 6).Trim()));
                    }
                }

                Log.Debug("Begin Import Result");
                Log.Debug(ImportResults() ? "Import Result success" : "Error While Import Result");
                ClearData();
            }
            catch (Exception)
            {
                //throw ex;
                Log.Error("Co loi khi xu ly du lieu");
            }
        }
Ejemplo n.º 14
0
        private static Device GetDevice(IntPtr errorReportPtr)
        {
            var device = app_center_unity_crashes_error_report_device(errorReportPtr);

            return(DeviceHelper.Convert(device));
        }
Ejemplo n.º 15
0
 protected override void OnNavigatedTo()
 {
     Version = string.Format("Version: {0}", DeviceHelper.GetAppPackageVersion(true).ToString());
     RaisePropertyChanged(() => Version);
 }
Ejemplo n.º 16
0
 public void AddDevicesToGroup(List <string> deviceNames, string groupName)
 {
     DeviceHelper.AddDevicesFromListsToGroup(deviceNames, groupName, cameras.Cast <SmartDevice>().ToList(), motionSensors.Cast <SmartDevice>().ToList());
 }
Ejemplo n.º 17
0
 protected override void GenerateMessage()
 {
     DeviceHelper.SetCurrentTime(imageStamped.Time);
     PushData <messages.ImageStamped>(imageStamped);
 }
Ejemplo n.º 18
0
        public override void ProcessRawData()
        {
            try
            {
                //Nếu ký tự kết thúc bằng CR thì tiến hành xử lý
                if ((StringData.EndsWith(DeviceHelper.CR.ToString(CultureInfo.InvariantCulture))) ||
                    (StringData.EndsWith(DeviceHelper.CRLF)))
                {
                    Log.Trace("Begin Process Data");
                    Log.Trace(DeviceHelper.CRLF + StringData);
                    SendStringData(DeviceHelper.ACK.ToString(CultureInfo.InvariantCulture));
                    string[] allPatients = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.CR);
                    Log.Trace("Result has {0} Patients", allPatients.Length);

                    //Duyệt theo từng dòng
                    foreach (string patient in allPatients)
                    {
                        string tempPatient = patient;
                        //Nếu đúng với các ký tự bắt đầu thì xử lý:
                        if (Validdata(patient))
                        {
                            TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                            TestResult.Barcode  = tempPatient.Substring(10, 16).Trim();
                            tempPatient         = tempPatient.Substring(40);
                            while (tempPatient.Length > 9)
                            {
                                string result    = tempPatient.Substring(0, 9);
                                string testName  = result.Substring(0, 2).Trim();
                                string testValue = result.Substring(2, 7).Trim();

                                //Xử lý các ký tự thừa trong kết quả

                                //Loại bỏ dấu "$"
                                testValue = testValue.Replace("$", "").Replace("!", "");

                                //Loại bỏ các chữ cái in hoa và in thường trong chuỗi kết quả
                                for (byte i = 65; i <= 90; i++)
                                {
                                    testValue =
                                        testValue.Replace(Convert.ToChar(i).ToString(CultureInfo.InvariantCulture), "").
                                        Replace(Convert.ToChar(i + 32).ToString(CultureInfo.InvariantCulture), "");
                                }

                                //Thêm kết quả mới
                                TestResult.Add(new ResultItem(testName, testValue));

                                //Cắt bỏ các dữ liệu vừa được xử lý
                                tempPatient = tempPatient.Substring(9);

                                //////////////Xử lý các thông số tính toán
                                ////////////double iHdlc = -1, iTrig = -1, iChol = -1, iAlb = -1, iProT = -1, iBilt = -1, iBild = -1;

                                ////////////foreach (ResultItem item in TestResult.Items)
                                ////////////{
                                ////////////    //BIL-Toàn phần
                                ////////////    if (item.TestName.Equals("10")) iBilt = TryToConvertToDouble(item.TestValue);

                                ////////////    //BIL-Trực tiếp
                                ////////////    if (item.TestName.Equals("11")) iBild = TryToConvertToDouble(item.TestValue);

                                ////////////    //Protein-T
                                ////////////    if (item.TestName.Equals("12")) iProT = TryToConvertToDouble(item.TestValue);

                                ////////////    //ALB
                                ////////////    if (item.TestName.Equals("15")) iAlb = TryToConvertToDouble(item.TestValue);

                                ////////////    //CHOL
                                ////////////    if (item.TestName.Equals("17")) iChol = TryToConvertToDouble(item.TestValue);

                                ////////////    //Trig
                                ////////////    if (item.TestName.Equals("16")) iTrig = TryToConvertToDouble(item.TestValue);

                                ////////////    //HDLC
                                ////////////    if (item.TestName.Equals("18")) iHdlc = TryToConvertToDouble(item.TestValue);
                                ////////////}

                                //////////////Tính toán

                                //////////////Bil-Gián tiếp:
                                ////////////if ((iBild > 0) && (iBilt > 0))
                                ////////////{
                                ////////////    testName = "47";
                                ////////////    testValue = (iBilt - iBild).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));
                                ////////////}

                                //////////////Globumin,Tỷ số A/G
                                ////////////if ((iProT > 0) && (iAlb > 0))
                                ////////////{
                                ////////////    //Globumin
                                ////////////    testName = "51";
                                ////////////    testValue = (iProT - iAlb).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));

                                ////////////    //Tỷ số A/G
                                ////////////    testName = "49";
                                ////////////    testValue = (iAlb/(iProT - iAlb)).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));
                                ////////////}

                                //////////////LDLC:
                                ////////////if ((iChol > 0) && (iHdlc > 0) && (iTrig > 0))
                                ////////////{
                                ////////////    testName = "50";
                                ////////////    testValue = (iChol - (iTrig/2.2 + iHdlc)).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));
                                ////////////}
                            }
                            ImportResults();
                            Log.Debug("Import Result Success For barocde:{0}", TestResult.Barcode);
                        }
                    }
                    ClearData();
                }
            }
            catch (Exception ex)
            {
                ClearData();
                throw ex;
            }
        }
Ejemplo n.º 19
0
        public static BitmapSource CreateBitmapFromVisual(Double width, Double height, Visual visualToRender, Boolean undoTransformation)
        {
            if (visualToRender == null)
            {
                return(null);
            }

            // The PixelsPerInch() helper method is used to read the screen DPI setting.
            // If you need to create a bitmap with a specified resolution, you could directly
            // pass the specified dpiX and dpiY values to RenderTargetBitmap constructor.
            RenderTargetBitmap bmp = new RenderTargetBitmap((Int32)Math.Ceiling(width), (Int32)Math.Ceiling(height), (Double)DeviceHelper.PixelsPerInch(Orientation.Horizontal), (Double)DeviceHelper.PixelsPerInch(Orientation.Vertical), PixelFormats.Pbgra32);

            // If we want to undo the transform, we could use VisualBrush trick.
            if (undoTransformation)
            {
                DrawingVisual dv = new DrawingVisual();
                using (DrawingContext dc = dv.RenderOpen())
                {
                    VisualBrush vb = new VisualBrush(visualToRender);
                    dc.DrawRectangle(vb, null, new Rect(new Point(), new Size(width, height)));
                }
                bmp.Render(dv);
            }
            else
            {
                bmp.Render(visualToRender);
            }

            return(bmp);
        }
    private void OnGUI()
    {
        //Changes both color and font size
        GUIStyle localStyle = new GUIStyle();

        localStyle.normal.textColor = Color.black;
        localStyle.fontSize         = 45;

#if UNITY_EDITOR
        // Hardcode the hinge mask for the Unity game preview
        if (Screen.width == DeviceHelper.SURFACEDUO_SPANNEDWIDTH)
        { // double-portrait
            GUI.backgroundColor = Color.gray;
            GUI.Box(new Rect(x: DeviceHelper.SURFACEDUO_SCREENWIDTH, y: 0, width: DeviceHelper.SURFACEDUO_HINGEWIDTH, height: DeviceHelper.SURFACEDUO_SCREENHEIGHT), "");
        }
        else if (Screen.height == DeviceHelper.SURFACEDUO_SPANNEDHEIGHT)
        { // double-landscape
            GUI.backgroundColor = Color.gray;
            var r = new Rect(x: 0, y: DeviceHelper.SURFACEDUO_SCREENWIDTH, width: DeviceHelper.SURFACEDUO_SCREENHEIGHT, height: DeviceHelper.SURFACEDUO_HINGEWIDTH);
            GUI.Box(r, "");
        }
#endif

        GUI.Label(new Rect(HEAD_INDENT, ROW_HEIGHT * 1, 200, 20), "-Unity for Surface Duo-", localStyle);

        GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 3, 200, 20), "Unity screen orientation:", localStyle);
        GUI.Label(new Rect(HEAD_INDENT, ROW_HEIGHT * 4, 400, 20), "-DeviceHelper-", localStyle);
        GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 5, 200, 20), "IsDualScreenDevice:", localStyle);
        GUI.Label(new Rect(HEAD_INDENT, ROW_HEIGHT * 6, 200, 20), "-ScreenHelper-", localStyle);

        GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 7, 200, 20), "IsDualMode:", localStyle);
        GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 8, 200, 20), "GetCurrentRotation:", localStyle);
        GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 9, 200, 20), "GetHinge:", localStyle);
        GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 10, 200, 20), "GetScreenRectangles:", localStyle);
        // GetScreenRectangles returns two rows
        GUI.Label(new Rect(HEAD_INDENT, ROW_HEIGHT * 12, 200, 20), "-Sensor-", localStyle);
        GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 13, 200, 20), "Hinge angle:", localStyle);

        localStyle.normal.textColor = Color.blue;

        // These methods don't require a check for IsDualScreenDevice
        GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 3, 400, 20), Screen.orientation.ToString(), localStyle);
        GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 5, 400, 20), ScreenHelper.IsDualScreenDevice().ToString(), localStyle);

        if (DeviceHelper.IsDualScreenDevice())
        {
            try
            {
                // draw the DisplayMask rectangle, but with a 25 pixel bleed so you can see on the device
                var displayMask = DisplayMask.FromResourcesRect();
                foreach (var rect in displayMask.GetBoundingRects())
                {
                    var o = Screen.orientation;
                    if (o == ScreenOrientation.LandscapeLeft || o == ScreenOrientation.LandscapeRight)
                    {   // wide
                        var r = new Rect(x: rect.x - 25, y: rect.y, width: rect.width + 50, height: rect.height);
                        GUI.Box(r, "");
                    }
                    else
                    {   // portrait - tall
                        var r = new Rect(x: rect.y, y: rect.x - 25, width: rect.height, height: rect.width + 50);
                        GUI.Box(r, "");
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogWarning("DisplayMask.FromResourcesRect: " + e);
            }

            try
            {
                var isDualMode = ScreenHelper.IsDualMode();
                GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 7, 400, 20), isDualMode.ToString() + "     (same as 'Is Spanned?')", localStyle);
            }
            catch (System.Exception e)
            {
                Debug.LogWarning("ScreenHelper.IsDualMode: " + e);
            }

            try
            {
                var currentRotation = ScreenHelper.GetCurrentRotation();
                GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 8, 400, 20), currentRotation.ToString(), localStyle);
            }
            catch (System.Exception e)
            {
                Debug.LogWarning("ScreenHelper.GetCurrentRotation: " + e);
            }

            try
            {
                var hinge = ScreenHelper.GetHinge();
                GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 9, 400, 20), hinge.ToString(), localStyle);
            }
            catch (System.Exception e)
            {
                Debug.LogWarning("ScreenHelper.GetHinge: " + e);
            }

            try
            {
                var rects      = ScreenHelper.GetScreenRectangles();
                var rectString = "";
                foreach (var rect in rects)
                {
                    rectString += rect.ToString() + "," + Environment.NewLine;
                }
                GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 10, 1000, 20 * 2), rectString, localStyle);
            }
            catch (System.Exception e)
            {
                Debug.LogWarning("ScreenHelper.GetHinge: " + e);
            }

            if (hingeSensor != null)
            {
                try
                {
                    var angle = hingeSensor.GetHingeAngle();
                    GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 13, 400, 20), $"{angle}°", localStyle);
                }
                catch (Exception e)
                {
                    Debug.LogWarning($"Hinge sensor read error: {e}");
                    GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 13, 400, 20), e.ToString(), localStyle);
                }
            }
            else
            {
                GUI.Label(new Rect(COL_WIDTH, ROW_HEIGHT * 13, 400, 20), $"Error creating hinge sensor reader", localStyle);
            }
        }
#if UNITY_EDITOR
        else
        {
            GUI.Label(new Rect(LEFT_MARGIN, ROW_HEIGHT * 15, 400, 20), "(most dual-screen attributes have no value in editor)", localStyle);
        }
#endif
    }
Ejemplo n.º 21
0
        public void ProcessRequest(HttpContext context)
        {
            M_UserInfo mu = buser.GetLogin();

            retMod.retcode = M_APIResult.Failed;
            try
            {
                switch (Action)
                {
                case "submit":
                {
                    M_Design_Answer ansMod = new M_Design_Answer();
                    ansMod.AskID = Convert.ToInt32(Req("askid"));
                    //ansMod.Answer = Req("answer");//{qid:1,answer:'is answer'}
                    ansMod.Answer = Req("answer");
                    ansMod.UserID = mu.UserID;
                    ansMod.IP     = IPScaner.GetUserIP();
                    ansMod.Source = DeviceHelper.GetBrower().ToString();
                    ansMod.ID     = ansBll.Insert(ansMod);
                    //-----------单独写入表中,便于后期分析(后期优化为批量插入)
                    List <M_SubOption> ansList = JsonConvert.DeserializeObject <List <M_SubOption> >(Req("answer"));
                    foreach (M_SubOption ans in ansList)
                    {
                        M_Design_AnsDetail ansdeMod = new M_Design_AnsDetail();
                        ansdeMod.AskID  = ansMod.AskID;
                        ansdeMod.AnsID  = ansMod.ID;
                        ansdeMod.Qid    = ans.qid;
                        ansdeMod.Answer = ans.answer;
                        ansdeMod.UserID = ansMod.UserID;
                        ansdeBll.Insert(ansdeMod);
                    }
                    retMod.retcode = M_APIResult.Success;
                    retMod.result  = ansMod.ID.ToString();
                }
                break;

                case "list":
                {
                    DataTable dt = ansBll.Sel(mu.UserID, -100);
                    retMod.retcode = M_APIResult.Success;
                    retMod.result  = JsonConvert.SerializeObject(dt);
                }
                break;

                case "listbyqid":    //仅用于查看详情
                {
                    int       qid = Convert.ToInt32(Req("qid"));
                    DataTable dt  = ansdeBll.Sel(qid.ToString());
                    retMod.retcode = M_APIResult.Success;
                    retMod.result  = JsonConvert.SerializeObject(dt);
                }
                break;

                default:
                    retMod.retmsg = "[" + Action + "]接口不存在";
                    break;
                }
            }
            catch (Exception ex) { retMod.retmsg = ex.Message; }
            RepToClient(retMod);
        }
Ejemplo n.º 22
0
        //串口设备不同状态下与程序间通信
        private void CommandReceivedDelegate(Command cmd)
        {
            try
            {
                //if (cmd is Cmd_X_Check)
                //{
                //    #region 上位机请求下位机自检的协议
                //    //2.10	上位机请求下位机自检的协议
                //    //0x00:生物电绿光自检均不正常
                //    //0x01:生物电自检正常
                //    //0x02:绿光自检正常
                //    //0x03:生物电、绿光自检均正常

                //    if (cmd.GetData()[4] == 0x03)
                //    {
                //        this.Init_Check_Device1 = true;
                //    }
                //    this.Init_Check_Device2ing = false;
                //    #endregion
                //}
                //else
                if (cmd is Cmd_X_SN)
                {
                    #region 3.2	上位机查询下位机固件版本和SN的协议
                    byte[] list = cmd.GetData();
                    string x    = "";
                    for (int i = 4; i < list.Length - 2; i++)
                    {
                        x += "," + list[i];
                    }
                    // Console.WriteLine("report--" + x);
                    //this.textBox2.Text = x;
                    byte[] list2 = DeviceHelper.Com_getSubData(list);

                    ASCIIEncoding encoder = new ASCIIEncoding();
                    string        tmp     = encoder.GetString(list2, 0, list2.Length);
                    //  this.textBox2.Text = tmp;
                    yoyoConst.VERSION = tmp.Substring(0, 17);               //版本号
                    yoyoConst.EQU_SN  = tmp.Substring(17, tmp.Length - 17); //设备信息(SN码)
                    if (!DeviceHelper.Com_checkSN())
                    {
                        devicemanager.Write(new Cmd_S_SN());
                        this.Init_Check_SN    = false;
                        this.Init_Check_SNing = false;
                    }
                    else
                    {
                        this.Init_Check_SN    = true;
                        this.Init_Check_SNing = false;
                    }

                    #endregion
                }

                else if (cmd is Cmd_X_GetNew)
                {
                    //3.4	下位机查向上位机请求新版固件信息的协议

                    //temp.hardLength = FileHelper.FileSize(testuploadfile);
                    if (string.IsNullOrEmpty(yoyoConst.EQU_SN) && cmdnew.hardLength <= 0)
                    {
                        bool flag = cmdReset();
                        if (flag)
                        {
                            devicemanager.Write(cmdnew);
                        }
                    }
                    else if (!string.IsNullOrEmpty(yoyoConst.EQU_SN))
                    {
                        devicemanager.Write(cmdnew);
                    }
                }
                else if (cmd is Cmd_X_GetData)
                {
                    if (string.IsNullOrEmpty(yoyoConst.EQU_SN) && cmdnew.hardLength <= 0)
                    {
                        bool flag = cmdReset();
                    }
                    else
                    {
                        #region 3.5	下位机向上位机请求固件数据的协议
                        // string x = cmd.GetData()[4].ToString();
                        byte[] cmddata = cmd.GetData();
                        cmd.show(cmddata);
                        byte[] intBuff = new byte[2];
                        intBuff[0] = cmddata[5];
                        intBuff[1] = cmddata[4];
                        int pos   = BitConverter.ToInt16(intBuff, 0);//取得包数
                        int start = pos * testuploadbaselength;
                        int end   = (start + testuploadbaselength) >= testuploadByte.Length ? testuploadByte.Length : (start + testuploadbaselength);

                        Cmd_S_GetData data = new Cmd_S_GetData();
                        data.packagePos = pos;
                        data.package    = new byte[end - start];
                        int packagepos = 0;
                        for (int i = start; i < end; i++)
                        {
                            data.package[packagepos] = testuploadByte[i];
                            packagepos++;
                        }
                        devicemanager.Write(data);
                        #endregion
                    }
                }
                else if (cmd is Cmd_X_Success)
                {
                    //3.6	下位机告知上位机固件下载成功的协议
                    devicemanager.Write(new Cmd_S_Success());
                }
                else if (cmd is Cmd_X_UpdateSuccess)
                {
                    //3.7	下位机通知上位机升级成功的协议
                    devicemanager.Write(new Cmd_S_UpdateSuccess());
                    //更新为最新版本
                    FileHelper.DeleteFolder(this.up_mcpVersion_url);
                    Init_Device_doing = false;
                    LogisTrac.WriteLog("固件文件更新成功,版本" + model.data.mcpVersion);
                    update_start();
                    //flash_change2(yoyoConst.YoyoStep.version);
                }
            }
            catch (Exception ex)
            {
                yoyoConst.WriteLog(ex.ToString());
            }
        }
Ejemplo n.º 23
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace(DeviceHelper.CRLF + StringData);
                string rawResult = StringData.Substring(StringData.IndexOf("SAMPLE RESULTS", StringComparison.Ordinal));
                if ((rawResult.IndexOf("Na") < 0) || (rawResult.IndexOf("K") < 0) || (rawResult.IndexOf("Cl") < 0))
                {
                    Log.Trace("Data is not valided");
                    return;
                }
                string[] strResutl = DeviceHelper.DeleteAllBlankLine(rawResult, DeviceHelper.CRLF.ToCharArray());
                Log.Trace("Begin Process Data");
                //Lưu lại Data
                //Lưu lại Data

                TestResult.TestDate = strResutl[strResutl.Length - 1].Substring(0, 9).Trim();
                string pTestDate = strResutl[strResutl.Length - 1].Substring(0, 3);
                pTestDate           = DeviceHelper.GetMonth(pTestDate);
                TestResult.TestDate = string.Format("{0}/{1}/{3}{2}", TestResult.TestDate.Substring(4, 2), pTestDate,
                                                    TestResult.TestDate.Substring(7, 2),
                                                    DateTime.Now.Year.ToString(CultureInfo.InvariantCulture).Substring(0, 2));

                //Lấy về dòng chứa ID
                int tempRowIndex = GetRowIndex(strResutl, "ID");
                if (tempRowIndex == -1)
                {
                    TestResult.Barcode = "0000";
                }
                else
                {
                    string[] tempId = strResutl[tempRowIndex].Split();
                    TestResult.Barcode = tempId.Length >= 2 ? Convert.ToInt32(tempId[1]).ToString() : "0000";
                }
                //Tìm đến phần tử đầu tien chứa kết quả.
                tempRowIndex = GetRowIndex(strResutl, "Na");
                if (tempRowIndex != -1)
                {
                    string[] tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                    tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex + 1].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                    tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex + 2].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                }

                Log.Debug("Begin Importdata");
                Log.Debug(ImportResults() ? "Finish Imported result" : "Error While Import Result to DB");
                ClearData();

                //  }
            }
            catch (Exception ex)
            {
                //throw ex;
                Log.Error("Error while processing data Error: {0}", ex);
                ClearData();
            }
        }
Ejemplo n.º 24
0
        public override void ProcessRawData()
        {
            try
            {
                //Log
                Log.Debug("Begin Process Data");
                Log.Trace("RawData:{0}", StringData);
                //Lấy về danh sách bệnh nhân
                string[] strResutl = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.CRLF.ToCharArray());
                Log.Trace("Data has {0} patient(s)", strResutl.Length);

                //Duyệt từng bệnh nhân
                foreach (string patient in strResutl)
                {
                    try
                    {
                        string[] tempTestDate = patient.Substring(0, 10).Split('/');
                        TestResult.TestDate = String.Format("{0}/{1}/{2}", tempTestDate[2], tempTestDate[1],
                                                            tempTestDate[0]);
                        //Xác định ID
                        int tempindex = patient.IndexOf("ID=", StringComparison.Ordinal);

                        //Nếu không tồn tại ID chuyển sang bản ghi tiếp theo
                        if (tempindex > 0)
                        {
                            string testName  = "";
                            string testValue = "";
                            TestResult.Barcode = patient.Substring(tempindex + 3, 3);

                            //Xác định chỉ số K
                            tempindex = patient.IndexOf("K=", StringComparison.Ordinal);
                            if (tempindex > 0)
                            {
                                testName  = "K";
                                testValue = patient.Substring(tempindex + 2, 5).Trim();
                                AddResult(new ResultItem(testName, testValue));
                            }
                            Log.Debug("Add Result success TestName:{0} - TestValue:{1}", testName, testValue);

                            //Xác định chỉ số Na
                            tempindex = patient.IndexOf("Na=", StringComparison.Ordinal);
                            if (tempindex > 0)
                            {
                                testName  = "Na";
                                testValue = patient.Substring(tempindex + 3, 5).Trim();
                                AddResult(new ResultItem(testName, testValue));
                            }
                            Log.Debug("Add Result success TestName:{0} - TestValue:{1}", testName, testValue);

                            //Xác định chỉ số Cl
                            tempindex = patient.IndexOf("Cl=", StringComparison.Ordinal);
                            if (tempindex > 0)
                            {
                                testName  = "Cl";
                                testValue = patient.Substring(tempindex + 3, 5).Trim();
                                AddResult(new ResultItem(testName, testValue));
                            }
                            Log.Debug("Add Result success TestName:{0} - TestValue:{1}", testName, testValue);


                            //Import dữ liệu
                            Log.Debug("Begin Import Result");
                            ImportResults();
                            Log.Debug("Import Result success");
                        }
                    }
                    catch (Exception)
                    {
                        Log.Error(string.Format("Co loi khi xu ly du lieu cua benh nhan:{0}Data:{1}", DeviceHelper.CRLF,
                                                patient));
                    }
                }
                Log.Trace("Finish Process Data");
            }
            catch (Exception ex)
            {
                //throw ex;
                Log.Error(string.Format("Co Loi trong qua trinh xu ly du lieu {0}{1}", DeviceHelper.CRLF, ex));
            }
            finally
            {
                ClearData();
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Does the work necessary to setup and launch the app.
        /// </summary>
        /// <param name="arguments"></param>
        private void SetupAndALaunchApp(string arguments)
        {
            // Check the args for prevent crash
            if (!string.IsNullOrWhiteSpace(arguments))
            {
                var lowerArgs = arguments.ToLower();
                if (lowerArgs.Contains(CProtocolPreventCrashesDisabled))
                {
                    BaconMan.UiSettingsMan.DeveloperStopFatalCrashesAndReport = false;
                }
                else if (lowerArgs.Contains(CProtocolPreventCrashesEnabled))
                {
                    BaconMan.UiSettingsMan.DeveloperStopFatalCrashesAndReport = true;
                }
            }

            // If we are on Xbox disable the blank border around the app. Ideally we would give the user the option to re-enable this.
            if (DeviceHelper.CurrentDevice() == DeviceTypes.Xbox)
            {
                Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
            }

            // Grab the accent color and make our custom accent color brushes.
            if (!Current.Resources.ContainsKey(AccentColorLevel1Resource))
            {
                var accentColor = ((SolidColorBrush)Current.Resources["SystemControlBackgroundAccentBrush"]).Color;
                accentColor.A = 200;
                Current.Resources[AccentColorLevel1Resource] = new SolidColorBrush(accentColor);
                accentColor.A = 137;
                Current.Resources[AccentColorLevel2Resource] = new SolidColorBrush(accentColor);
                accentColor.A = 75;
                Current.Resources[AccentColorLevel3Resource] = new SolidColorBrush(accentColor);
                accentColor.A = 50;
                Current.Resources[AccentColorLevel4Resource] = new SolidColorBrush(accentColor);
            }

            // Register for back, if we haven't already.
            if (!_mHasRegisteredForBack)
            {
                _mHasRegisteredForBack = true;
                SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
            }

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (!(Window.Current.Content is Frame rootFrame))
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            switch (rootFrame.Content)
            {
            case null:
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), arguments);
                break;

            // If we have already navigated, we should tell the main page
            // we are being activated again.
            case MainPage main:
                main.OnReActivated(arguments);
                break;
            }

            // We have to get the screen res before we call activate or it will be wrong and include the system tray.
            var bounds      = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds;
            var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;

            BaconMan.BackgroundMan.ImageUpdaterMan.LastKnownScreenResolution = new Size(bounds.Width * scaleFactor, bounds.Height * scaleFactor);

            // Ensure the current window is active
            Window.Current.Activate();
        }
Ejemplo n.º 26
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace("Begin Process Data");

                //Lưu lại Data
                Log.Trace(StringData);

                // Tách nhiều bệnh nhân:
                string[] allPatients = Seperator(ReformatData(StringData));

                //Khai báo mảng kết quả.
                var arrResultName = new[]
                {
                    "WBC", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW", "PLT", "MPV",
                    "LY#", "MO#", "NE#", "EO#", "BA#", "NRBC#", "LY%", "MO%", "NE%", "EO%",
                    "BA%", "NRBC%", "PDW", "PCT"
                };
                var arrHistogram = new[]
                {
                    "RBCH", "PLTH", "WBCF"
                };
                string _destImagePath = DeviceHelper.GetImageFolder();
                if (!_destImagePath.EndsWith(Path.DirectorySeparatorChar.ToString()))
                {
                    _destImagePath = string.Format("{0}{1}", _destImagePath, Path.DirectorySeparatorChar);
                }

                // Lọc theo từng bệnh nhân để import kết quả
                foreach (string patient in allPatients)
                {
                    string[] tempStringArr;

                    string[] strResult = DeviceHelper.DeleteAllBlankLine(patient, DeviceHelper.CRLF);

                    //Lấy ngày:
                    int rowIndex = GetRowIndex(strResult, "DATE");
                    if (rowIndex > -1)
                    {
                        tempStringArr = strResult[rowIndex].Split();
                        if (tempStringArr.Length < 2)
                        {
                            TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                        }
                        else
                        {
                            if (tempStringArr[1].Trim() == "")
                            {
                                TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                            }
                            else
                            {
                                string[] s = tempStringArr[1].Trim().Split('/');

                                TestResult.TestDate = string.Format("{0}/{1}/{2}{3}", s[1], s[0],
                                                                    DateTime.Now.Year.ToString(
                                                                        CultureInfo.InvariantCulture).Substring(0, 2),
                                                                    s[2]);
                            }
                        }
                    }
                    else
                    {
                        TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                    }
                    Log.Trace("TestDate - {0}", TestResult.TestDate);

                    //Lấy TestID:
                    rowIndex = GetRowIndex(strResult, "ID1");
                    if (rowIndex > -1)
                    {
                        tempStringArr      = strResult[rowIndex].Split();
                        TestResult.Barcode = tempStringArr.Length < 2
                            ? "0000"
                            : (tempStringArr[1].Trim() == ""
                                ? "0000"
                                : tempStringArr[1].Trim());
                    }
                    else
                    {
                        TestResult.Barcode = "0000";
                    }
                    Log.Trace("Barcode - {0}", TestResult.Barcode);

                    //Lấy các kết quả.

                    //Lấy kết quả và lưu vào mảng.
                    foreach (string sResultName in arrResultName)
                    {
                        int indexResult = GetRowIndex(strResult, sResultName);
                        if (indexResult > -1)
                        {
                            tempStringArr = strResult[indexResult].Split();
                            string testValue = tempStringArr.Length < 2
                                ? ""
                                : (tempStringArr[1].Trim() == ""
                                    ? ""
                                    : tempStringArr[1].Trim());
                            AddResult(new ResultItem(sResultName, testValue));
                            Log.Trace("Add new Item Success:{0}-{1}", sResultName, testValue);
                        }
                    }

                    //try
                    //{
                    //    if (Directory.Exists(_destImagePath))
                    //    {
                    //        Log.Trace("Open folder: '{0}' Success", _destImagePath);
                    //        string fileName = string.Empty;
                    //        // Vẽ các biểu đồ
                    //        int boxWidth = 600;
                    //        int boxHeight = 300;

                    //        // Dựng Histogram

                    //        // WBC
                    //        rowIndex = GetRowIndex(strResult, "RBCH");
                    //        if (rowIndex > -1)
                    //        {
                    //            fileName = string.Format("{0}-{1}-RBCH.PNG", DateTime.Now.ToString("ddMMyyyy"),
                    //                TestResult.Barcode);
                    //            fileName = string.Format("{0}{1}", _destImagePath, fileName);
                    //            DeviceHelper.CreateHistogram("RBC", boxWidth, boxHeight,
                    //                strResult[rowIndex].Substring(4).Trim()).Save(fileName,
                    //                    ImageFormat.
                    //                        Png);
                    //            Log.Trace("Create RBC Histogram Success: File name - {0}", fileName);
                    //            TestResult.Add(new ResultItem("RBCH", fileName));
                    //        }

                    //        // PLT
                    //        rowIndex = GetRowIndex(strResult, "PLTH");
                    //        if (rowIndex > -1)
                    //        {
                    //            fileName = string.Format("{0}-{1}-PLTH.PNG", DateTime.Now.ToString("ddMMyyyy"),
                    //                TestResult.Barcode);
                    //            fileName = string.Format("{0}{1}", _destImagePath, fileName);
                    //            DeviceHelper.CreateHistogram("PLT", boxWidth, boxHeight,
                    //                strResult[rowIndex].Substring(4).Trim()).Save(fileName,
                    //                    ImageFormat.
                    //                        Png);
                    //            Log.Trace("Create PLT Histogram Success: File name - {0}", fileName);
                    //            TestResult.Add(new ResultItem("PLTH", fileName));
                    //        }
                    //        // WBC
                    //        rowIndex = GetRowIndex(strResult, "WBCF");
                    //        if (rowIndex > -1)
                    //        {
                    //            fileName = string.Format("{0}-{1}-WBCF.PNG", DateTime.Now.ToString("ddMMyyyy"),
                    //                TestResult.Barcode);
                    //            fileName = string.Format("{0}{1}", _destImagePath, fileName);
                    //            DeviceHelper.CreateHistogram("WBC", boxWidth, boxHeight,
                    //                strResult[rowIndex].Substring(4).Trim()).Save(fileName,
                    //                    ImageFormat.
                    //                        Png);
                    //            Log.Trace("Create WBC Histogram Success: File name - {0}", fileName);
                    //            TestResult.Add(new ResultItem("WBCF", fileName));
                    //        }
                    //    }
                    //    else
                    //    {
                    //        Log.Trace("Open folder: '{0}' False", _destImagePath);
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    Log.Error(string.Format("Exception while build histogram:{0}", ex));
                    //}


                    Log.Debug("Import Result for barcode:" + TestResult.Barcode);
                    ImportResults();
                    Log.Debug("Import Result Success");
                }
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("Exception while processing data:{0}", ex));
            }
            finally
            {
                ClearData();
            }
        }