Example #1
0
        public List <IDictionary <string, string> > ProcessMultipleResponse(DatabaseOperation operation, List <string> keyList)
        {
            List <IDictionary <string, string> > Result = null;

            if (RequestResultTable.ContainsKey(operation))
            {
                List <IDictionary <string, object> > ResultList = RequestResultTable[operation];
                RequestResultTable.Remove(operation);

                foreach (IDictionary <string, object> Item in ResultList)
                {
                    IDictionary <string, string> ResultLine = null;
                    foreach (string Key in keyList)
                    {
                        if (Item.ContainsKey(Key) && (ResultLine == null || !ResultLine.ContainsKey(Key)) && Item[Key] is string)
                        {
                            if (ResultLine == null)
                            {
                                ResultLine = new Dictionary <string, string>();
                                if (Result == null)
                                {
                                    Result = new List <IDictionary <string, string> >();
                                }

                                Result.Add(ResultLine);
                            }

                            ResultLine.Add(Key, Item[Key] as string);
                        }
                    }
                }
            }

            return(Result);
        }
Example #2
0
 public Task <List <ImapResponse> > Execute(ImapSession session, string args)
 {
     return(Task.FromResult(new List <ImapResponse>
     {
         new ImapResponse(ResultLine.CAPABILITY(session.Capabilities))
     }));
 }
Example #3
0
        public Task <List <ImapResponse> > Execute(ImapSession session, string args)
        {
            List <ImapResponse> result = new List <ImapResponse>();

            if (session.SelectFolder == null)
            {
                return(this.NullResult());
            }

            var deletedSeqNo = session.SelectFolder.EXPUNGE();

            foreach (var item in deletedSeqNo)
            {
                result.Add(new ImapResponse(ResultLine.EXPUNGE(item)));
            }

            session.SelectFolder.Stat = session.MailDb.Messages.GetStat(session.SelectFolder.Folder);

            var stat = session.SelectFolder.Stat;

            result.Add(new ImapResponse(ResultLine.EXISTS(stat.Exists)));
            result.Add(new ImapResponse(ResultLine.RECENT(stat.Recent)));

            result.Add(new ImapResponse(ResultLine.UIDNEXT(stat.NextUid)));

            result.Add(new ImapResponse(ResultLine.UIDVALIDAITY(stat.FolderUid)));

            return(Task.FromResult(result));
        }
Example #4
0
File: LIST.cs Project: xhute/Kooboo
        public Task <List <ImapResponse> > Execute(ImapSession session, string args)
        {
            string[] parts = TextUtils.SplitQuotedString(args, ' ', true);

            string refName = IMAP_Utils.DecodeMailbox(parts[0]);
            string folder  = IMAP_Utils.DecodeMailbox(parts[1]);

            // mailbox name is "", return delimiter and root
            if (folder == String.Empty)
            {
                var root = refName.Split(new char[] { '/' })[0];
                return(Task.FromResult(new List <ImapResponse>
                {
                    new ImapResponse(ResultLine.LIST(root, '/', null))
                }));
            }

            // Match the full mailbox pattern
            var folderPattern = folder.Replace("*", ".*").Replace("%", "[^/]*");
            var pattern       = $"^{refName}{folderPattern}$";

            var user   = Data.GlobalDb.Users.Get(session.AuthenticatedUserIdentity.Name);
            var result = new List <ImapResponse>();

            foreach (var each in GetAllFolders(user))
            {
                if (System.Text.RegularExpressions.Regex.IsMatch(each.Name, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    result.Add(new ImapResponse(Response(each.Name, '/', each.Attributes)));
                }
            }

            return(Task.FromResult(result));
        }
        /// <summary>
        /// Query rules.
        ///
        /// If RuleSet is null, then returns null.
        /// </summary>
        /// <param name="filterCriteria"></param>
        /// <returns></returns>
        /// <exception cref="Exception">Wrapped error</exception>
        public IPluralRulesEnumerable Query(PluralRuleInfo filterCriteria)
        {
            if (filterCriteria.RuleSet == null)
            {
                return(null);
            }

            ResultLine line = GetRules(filterCriteria.RuleSet);

            if (line.Error != null)
            {
                throw new Exception(line.Error.Message, line.Error);
            }
            if (line.Rules == null)
            {
                return(null);
            }

            if (line.Rules is IPluralRulesQueryable queryable)
            {
                // Set RuleSet to null
                return(queryable.Query(filterCriteria.ChangeRuleSet(null)));
            }
            return(null);
        }
    public void Init()
    {
        mathDevice.Init(MinigamesManager.types.FRACCIONES);

        if (Game.Instance.gameManager.Isla.GetComponent<Isla>().state == Isla.states.MINIGAME_STARTED) return;
        if (results != null && results.Count > 0) return;

        Texts.Minigame_Fracciones minigame = Data.Instance.texts.GetMinigame_Fracciones();
        string textFinal = minigame.title;
        //desc.text = textFinal.Replace("[]", insertfield);
        descSmall.text = textFinal;
        descSmall.text += " Coloca ";

        int total = minigame.slots;

        total++;

        results = new List<ResultLine>();
        int num = 1;
        foreach (string result in minigame.fracciones)
        {
            ResultLine line = new ResultLine();

            switch (num)
            {
                case 1:
                    descSmall.text += "una piedra verde a " + result; break;
                case 2:
                    descSmall.text += ", una roja a " + result; break;
                case 3:
                    descSmall.text += " y una amarilla a " + result; break;
            }

            string[] textSplit = result.Split("/"[0]);

            float frac = (float.Parse(textSplit[0]) / float.Parse(textSplit[1]));
            line.num = (int)(minigame.slots * frac);
            line.piedraID = num;
            results.Add(line);
            num++;
        }
        for (int a = 0; a < total; a++ )
        {
            FraccionesSlot button = Instantiate(fraccionesSlot);
            button.transform.SetParent(container);
            button.id = a;
            button.GetComponent<Button>().onClick.AddListener(() => { SlotClicked(button); });
            button.transform.localScale = Vector2.one;
            foreach (ResultLine line in results)
            {
                if (line.num == button.id) button.resultPiedraID = line.piedraID;
            }
        }
    }
        /// <summary>
        /// Try resolve
        /// </summary>
        /// <param name="rulesOrClassName"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool TryResolve(string rulesOrClassName, out IPluralRules result)
        {
            ResultLine line = GetRules(rulesOrClassName);

            if (line.Rules != null)
            {
                result = line.Rules; return(true);
            }
            result = null;
            return(false);
        }
Example #8
0
        public Task <List <ImapResponse> > Execute(ImapSession session, string args)
        {
            List <ImapResponse> result = new List <ImapResponse>();

            var deletedSeqNo = session.SelectFolder.EXPUNGE();

            foreach (var item in deletedSeqNo)
            {
                result.Add(new ImapResponse(ResultLine.EXPUNGE(item)));
            }
            return(Task.FromResult(result));
        }
Example #9
0
        private List <ResultLine> createResultsLineList(List <KeyValuePair <double, string> > docsList, string queryNum)
        {
            List <ResultLine> ans = new List <ResultLine>();

            foreach (KeyValuePair <double, string> doc in docsList)
            {
                ResultLine line = new ResultLine(doc.Key, doc.Value);
                line.queryNum = queryNum;
                ans.Add(line);
            }
            return(ans);
        }
Example #10
0
        public static List <ImapResponse> Execute(MailDb maildb, SelectFolder Folder, string args, Func <MailDb, SelectFolder, Message, int> toResult)
        {
            var cmdreader = new SearchCommand.CommandReader(args);

            var allitems = cmdreader.ReadAllDataItems();

            var searchResult = Execute(maildb, Folder, allitems, toResult);

            List <ImapResponse> result = new List <ImapResponse>();

            var line = ResultLine.SEARCH(searchResult);

            result.Add(new ImapResponse(line));

            return(result);
        }
 /// <summary>
 /// Try to resolve ruleset and evaluate number.
 /// </summary>
 /// <param name="subset"></param>
 /// <param name="number"></param>
 /// <returns></returns>
 /// <exception cref="Exception">On wrapped error</exception>
 public IPluralRule[] Evaluate(PluralRuleInfo subset, IPluralNumber number)
 {
     if (subset.RuleSet != null)
     {
         ResultLine line = GetRules(subset.RuleSet);
         if (line.Error != null)
         {
             throw new Exception(line.Error.Message, line.Error);
         }
         if (line.Rules is IPluralRulesEvaluatable eval)
         {
             // Set RuleSet to null
             return(eval.Evaluate(subset.ChangeRuleSet(null), number));
         }
     }
     return(null);
 }
Example #12
0
        // RFC 3501 6.3.1. SELECT Command.

        public Task <List <ImapResponse> > Execute(ImapSession session, string args)
        {
            string[] parts = TextUtils.SplitQuotedString(args, ' ');
            if (parts.Length >= 2)
            {
                // At moment we don't support UTF-8 mailboxes.
                if (Lib.Helper.StringHelper.IsSameValue(parts[1], "(UTF8)"))
                {
                    throw new CommandException("NO", "UTF8 name not supported");
                }
                else
                {
                    throw new CommandException("BAD", "Argument error");
                }
            }

            List <ImapResponse> Result = new List <ImapResponse>();

            string foldername = TextUtils.UnQuoteString(IMAP_Utils.DecodeMailbox(args));

            var parsedfolder = Kooboo.Mail.Utility.FolderUtility.ParseFolder(foldername);

            session.SelectFolder = new SelectFolder(foldername, session.MailDb);

            var stat = session.SelectFolder.Stat;

            session.MailDb.Messages.UpdateRecentByMaxId(stat.LastestMsgId);

            Result.Add(new ImapResponse(ResultLine.EXISTS(stat.Exists)));
            Result.Add(new ImapResponse(ResultLine.RECENT(stat.Recent)));

            if (stat.FirstUnSeen > -1)
            {
                Result.Add(new ImapResponse(ResultLine.UNSEEN(stat.FirstUnSeen)));
            }

            Result.Add(new ImapResponse(ResultLine.UIDNEXT(stat.NextUid)));

            Result.Add(new ImapResponse(ResultLine.UIDVALIDAITY(stat.FolderUid)));

            Result.Add(new ImapResponse(ResultLine.FLAGS(Setting.SupportFlags.ToList())));

            return(Task.FromResult(Result));
        }
        public static List <ResultLine> GetResults(List <MyArray> root)
        {
            List <ResultLine> results = new List <ResultLine>();

            foreach (MyArray myArray in root)
            {
                //get all the valid items
                List <Item> allItems = myArray.menu.items.Where(x => x != null).ToList();
                ResultLine  rl       = new ResultLine
                {
                    Name    = myArray.menu.header,
                    TotalId = (from item in allItems
                               where item.label != null && !item.label.Equals(string.Empty)
                               select item.id).Sum()
                };
                results.Add(rl);
            }
            return(results);
        }
Example #14
0
        public static List <ImapResponse> Execute(MailDb mailDb, IEnumerable <FetchMessage> messages, string folderName)
        {
            var prasedFolder = Utility.FolderUtility.ParseFolder(folderName);

            var folder = mailDb.Folders.Get(prasedFolder.FolderId);

            if (folder == null)
            {
                throw new CommandException("NO", "Can't move those messages or to that name");
            }

            var result = new List <ImapResponse>();

            foreach (var each in messages)
            {
                var message = each.Message;
                var flags   = mailDb.Messages.GetFlags(message.Id);

                mailDb.Messages.Delete(message.Id);

                message.Id       = 0;
                message.FolderId = folder.Id;

                if (message.AddressId == 0)
                {
                    message.AddressId = prasedFolder.AddressId;
                }

                mailDb.Messages.AddOrUpdate(message);
                flags = flags.Except(new string[] { "Deleted" }).ToArray();
                mailDb.Messages.UpdateRecent(message.Id);
                mailDb.Messages.ReplaceFlags(message.Id, flags);

                result.Add(new ImapResponse(ResultLine.EXPUNGE(each.SeqNo)));
            }

            return(result);
        }
        public void CalcFeatures()
        {
            var files       = Directory.GetFiles(datasetDir);
            var rawFiles    = files.Where(f => f.EndsWith(".raw"));
            var targetFiles = files.Where(f => f.EndsWith("_IcTda.tsv")).ToDictionary(Path.GetFileNameWithoutExtension, f => f);
            var decoyFiles  = files.Where(f => f.EndsWith("_IcDecoy.tsv")).ToDictionary(Path.GetFileNameWithoutExtension, f => f);

            var results = new ConcurrentBag <ResultLine>();

            var datasetsProcessed = 0;

            foreach (var rawFilePath in rawFiles)
            {
                var rawFile = new FileInfo(rawFilePath);
                if (rawFile.Length / 1024.0 / 1024 / 1024 > 1)
                {
                    Console.WriteLine("Skipping, {0} since over 1 GB", rawFile.FullName);
                    continue;
                }

                var idName    = $"{Path.GetFileNameWithoutExtension(rawFile.Name)}_IcTda";
                var decoyName = $"{Path.GetFileNameWithoutExtension(rawFile.Name)}_IcDecoy";

                if (!targetFiles.ContainsKey(idName))
                {
                    Console.WriteLine("Skipping, _IcTda.tsv file not found for " + rawFile.FullName);
                    continue;
                }

                if (!decoyFiles.ContainsKey(decoyName))
                {
                    Console.WriteLine("Skipping, _IcDecoy.tsv file not found for " + rawFile.FullName);
                    continue;
                }

                Console.WriteLine("Processing " + rawFile.FullName);

                var scans  = new Dictionary <int, DeconvolutedSpectrum>();
                var pbfRun = (PbfLcMsRun)PbfLcMsRun.GetLcMsRun(rawFile.FullName);

                var ids    = ParseIdFile(targetFiles[idName], true);
                var decoys = ParseIdFile(decoyFiles[decoyName], false);
                ids.AddRange(decoys);

                foreach (var id in ids)
                {
                    DeconvolutedSpectrum spectrum;
                    if (scans.ContainsKey(id.Scan))
                    {
                        spectrum = scans[id.Scan];
                    }
                    else
                    {
                        spectrum = GetDeconvolutedSpectrum(id.Scan, pbfRun);
                        scans.Add(id.Scan, spectrum);
                    }

                    var baseIonTypes = new[] { BaseIonType.A, BaseIonType.B, BaseIonType.C, BaseIonType.X, BaseIonType.Y, BaseIonType.Z };
                    var cleavages    = id.Sequence.GetInternalCleavages();
                    foreach (var cleavage in cleavages)
                    {
                        foreach (var baseIonType in baseIonTypes)
                        {
                            var baseComp    = baseIonType.IsPrefix ? cleavage.PrefixComposition : cleavage.SuffixComposition;
                            var composition = baseComp + baseIonType.OffsetComposition;
                            var mass        = composition.Mass;
                            var peak        = spectrum.FindPeak(mass, new Tolerance(10, ToleranceUnit.Ppm)) as DeconvolutedPeak;
                            if (peak == null)
                            {
                                continue;
                            }
                            else
                            {
                                var result = new ResultLine
                                {
                                    Corr      = peak.Corr,
                                    Cosine    = peak.Dist,
                                    Error     = Math.Abs(mass - peak.Mass) / peak.Mass * 1e6,
                                    Intensity = peak.Intensity,
                                    IsTarget  = id.IsTarget
                                };

                                results.Add(result);
                            }
                        }
                    }
                }

                datasetsProcessed++;

                var plotFileDir = new DirectoryInfo(outputFileDir);
                if (!plotFileDir.Exists)
                {
                    plotFileDir.Create();
                }

                var outputFilePath = Path.Combine(plotFileDir.FullName,
                                                  string.Format("result_{0}.tsv", Path.GetFileNameWithoutExtension(rawFile.Name)));

                using (var writer = new StreamWriter(new FileStream(outputFilePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)))
                {
                    foreach (var result in results)
                    {
                        var isTarget = result.IsTarget ? 1 : 0;
                        writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", result.Corr, result.Cosine, result.Error, result.Intensity, isTarget);
                    }
                }
            } //foreach

            if (datasetsProcessed == 0)
            {
                Assert.Ignore("Did not find any valid datasets in " + datasetDir);
            }
        }
        /// <summary>
        /// 加载数据
        /// </summary>
        private void Load_Data()
        {
            //用户信息
            l1.Content = user.User_Name;
            l2.Content = user.Pk_User_Id;
            //训练日期
            da.Content = trainDto.prescriptionResult.Gmt_create.ToString();
            string path = AppDomain.CurrentDomain.BaseDirectory;

            //string rootpath = path.Substring(0, path.LastIndexOf("bin"));
            //查询处方和结果
            #region 优化
            //List<NewTrainDTO> trainDtoLists = new List<NewTrainDTO>();
            //for(int i=0; i< trainDtoList.Count; i++)
            //{
            //    if(new TrainService().GetTrainDTOByPRId(Convert.ToInt32(trainDtoList[i].prescriptionResult.Pk_pr_id))[0] != null)
            //    {
            //        trainDtoLists.Add(new TrainService().GetTrainDTOByPRId(Convert.ToInt32(trainDtoList[i].prescriptionResult.Pk_pr_id))[0]);
            //    }
            //}
            #endregion
            List <NewTrainDTO> trainDtos     = new TrainService().GetTrainDTOByPRId(Convert.ToInt32(trainDto.prescriptionResult.Pk_pr_id));
            DeviceSortDAO      deviceSortDao = new DeviceSortDAO();
            ResultLine         resultLine    = new ResultLine();
            //循环判断填充数据
            foreach (NewTrainDTO trainDto in trainDtos)
            {
                switch (trainDto.devicePrescription.Fk_ds_id)
                {
                case (int)DeviceType.P01:
                    HLPGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    HLPGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    HLPRelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    HLPMoveway.Text    = trainDto.moveway;
                    HLPPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    HLPTime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        HLPTrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        HLPselect_change();
                        HLPConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        HLPReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        HLPTrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        HLPselect_change();
                        HLPSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        HLPTrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        HLPselect_change();
                        HLPSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    HLPSportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    HLPHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    HLPEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    HLPFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    HLPAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    HLPWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 0);
                    HLPWeb.Navigate(new Uri(path + "dist\\HLPLine.html"));
                    break;

                case (int)DeviceType.P00:
                    ROWGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    ROWGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    ROWRelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    ROWMoveway.Text    = trainDto.moveway;
                    ROWPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    ROWTime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        ROWTrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        ROWselect_change();
                        ROWConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        ROWReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        ROWTrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        ROWselect_change();
                        ROWSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        ROWTrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        ROWselect_change();
                        ROWSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    ROWSportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    ROWHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    ROWEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    ROWFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    ROWAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    ROWWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 1);
                    ROWWeb.Navigate(new Uri(path + "dist\\ROWLine.html"));
                    break;

                case (int)DeviceType.P09:
                    TFGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    TFGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    TFRelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    TFMoveway.Text    = trainDto.moveway;
                    TFPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    TFTime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        TFTrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        TFselect_change();
                        TFConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        TFReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        TFTrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        TFselect_change();
                        TFSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        TFTrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        TFselect_change();
                        TFSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    TFSportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    TFHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    TFEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    TFFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    TFAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    TFWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 2);
                    TFWeb.Navigate(new Uri(path + "dist\\TFLine.html"));
                    break;

                case (int)DeviceType.P06:
                    LEGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    LEGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    LERelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    LEMoveway.Text    = trainDto.moveway;
                    LEPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    LETime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        LETrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        LEselect_change();
                        LEConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        LEReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        LETrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        LEselect_change();
                        LESpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        LETrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        LEselect_change();
                        LESpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    LESportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    LEHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    LEEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    LEFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    LEAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    LEWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 3);
                    LEWeb.Navigate(new Uri(path + "dist\\LELine.html"));
                    break;

                case (int)DeviceType.P02:
                    HAGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    HAGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    HARelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    HAMoveway.Text    = trainDto.moveway;
                    HAPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    HATime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        HATrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        HAselect_change();
                        HAConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        HAReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        HATrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        HAselect_change();
                        HASpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        HATrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        HAselect_change();
                        HASpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    HASportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    HAHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    HAEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    HAFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    HAAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    HAWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 4);
                    HAWeb.Navigate(new Uri(path + "dist\\HALine.html"));
                    break;

                case (int)DeviceType.P05:
                    CPGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    CPGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    CPRelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    CPMoveway.Text    = trainDto.moveway;
                    CPPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    CPTime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        CPTrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        CPselect_change();
                        CPConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        CPReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        CPTrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        CPselect_change();
                        CPSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        CPTrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        CPselect_change();
                        CPSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    CPSportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    CPHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    CPEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    CPFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    CPAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    CPWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 5);
                    CPWeb.Navigate(new Uri(path + "dist\\CPLine.html"));
                    break;

                case (int)DeviceType.P03:
                    NewAGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    NewAGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    NewARelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    NewAMoveway.Text    = trainDto.moveway;
                    NewAPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    NewATime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        NewATrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        NewAselect_change();
                        NewAConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        NewAReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        NewATrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        NewAselect_change();
                        NewASpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        NewATrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        NewAselect_change();
                        NewASpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    NewASportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    NewAHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    NewAEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    NewAFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    NewAAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    NewAWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 6);
                    NewAWeb.Navigate(new Uri(path + "dist\\NewALine.html"));
                    break;

                case (int)DeviceType.P04:
                    NewBGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    NewBGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    NewBRelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    NewBMoveway.Text    = trainDto.moveway;
                    NewBPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    NewBTime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        NewBTrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        NewBselect_change();
                        NewBConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        NewBReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        NewBTrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        NewBselect_change();
                        NewBSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        NewBTrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        NewBselect_change();
                        NewBSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    NewBSportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    NewBHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    NewBEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    NewBFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    NewBAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    NewBWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 7);
                    NewBWeb.Navigate(new Uri(path + "dist\\NewBLine.html"));
                    break;

                case (int)DeviceType.P07:
                    NewCGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    NewCGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    NewCRelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    NewCMoveway.Text    = trainDto.moveway;
                    NewCPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    NewCTime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        NewCTrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        NewCselect_change();
                        NewCConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        NewCReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        NewCTrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        NewCselect_change();
                        NewCSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        NewCTrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        NewCselect_change();
                        NewCSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    NewCSportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    NewCHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    NewCEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    NewCFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    NewCAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    NewCWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 8);
                    NewCWeb.Navigate(new Uri(path + "dist\\NewCLine.html"));
                    break;

                case (int)DeviceType.P08:
                    NewDGroupcount.Text = trainDto.devicePrescription.Dp_groupcount.ToString();
                    NewDGroupnum.Text   = trainDto.devicePrescription.Dp_groupnum.ToString();
                    NewDRelaxTime.Text  = trainDto.devicePrescription.Dp_relaxtime.ToString();
                    NewDMoveway.Text    = trainDto.moveway;
                    NewDPower.Text      = trainDto.prescriptionResult.Power.ToString();
                    NewDTime1.Text      = trainDto.prescriptionResult.Finish_time.ToString();
                    if (trainDto.devicePrescription.Device_mode == DevConstants.REHABILITATION_MODEL)
                    {
                        NewDTrainingModel.Text = LanguageUtils.ConvertLanguage("康复模式", "Rehabilitation Model");
                        NewDselect_change();
                        NewDConsequentForce.Text = trainDto.devicePrescription.Consequent_force.ToString();
                        NewDReverseForce.Text    = trainDto.devicePrescription.Reverse_force.ToString();
                    }
                    else if (trainDto.devicePrescription.Device_mode == DevConstants.ACTIVE_MODEL)
                    {
                        NewDTrainingModel.Text = LanguageUtils.ConvertLanguage("主被动模式", "Active Model");
                        NewDselect_change();
                        NewDSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    else
                    {
                        NewDTrainingModel.Text = LanguageUtils.ConvertLanguage("被动模式", "Passive Model");
                        NewDselect_change();
                        NewDSpeedRank.Text = trainDto.devicePrescription.Speed_rank.ToString();
                    }
                    if (trainDto.prescriptionResult == null)
                    {
                        break;
                    }
                    NewDSportstrength.Text  = StrengthConverter(trainDto.prescriptionResult.pr_userthoughts.ToString());
                    NewDHeartRateList.Text  = trainDto.prescriptionResult.Heart_rate_list;
                    NewDEnergy.Text         = trainDto.prescriptionResult.Energy.ToString();
                    NewDFinishNum.Text      = trainDto.prescriptionResult.Finish_num.ToString();
                    NewDAttentionpoint.Text = trainDto.devicePrescription.Dp_memo;

                    // 心率折线图
                    NewDWeb.ObjectForScripting = new ResultLine(trainDto.prescriptionResult.Heart_rate_list, 9);
                    NewDWeb.Navigate(new Uri(path + "dist\\NewDLine.html"));
                    break;
                }
            }
        }
Example #17
0
File: LIST.cs Project: xhute/Kooboo
 protected virtual string Response(string folderName, char delimiter, List <string> attributes)
 {
     return(ResultLine.LIST(folderName, delimiter, attributes));
 }
        private void doCalculation()
        {
            progressBar.Style = ProgressBarStyle.Marquee;
            buttonGo.Enabled  = false;
            buttonOpenMasterDataFile.Enabled             = false;
            buttonForeCastFile.Enabled                   = false;
            buttonCopyToClipboardForExcelPaste.Enabled   = false;
            textBoxMasterDataFile.Enabled                = false;
            textBoxForecastFile.Enabled                  = false;
            textBoxSheetNameMasterData.Enabled           = false;
            textBoxArticleNumberColumnMasterData.Enabled = false;
            textBoxArticleNumberColumnMasterData.Enabled = false;
            textBoxLengthColumn.Enabled                  = false;
            textBoxWidthColumn.Enabled                   = false;
            textBoxThicknesColumn.Enabled                = false;
            textBoxRowFromMasterData.Enabled             = false;
            textBoxRowToMasterData.Enabled               = false;

            IDictionary <string, MasterDataLine> masterData = null;

            try
            {
                masterData = readMasterData();
            }
            catch (IOException e)
            {
                MessageBox.Show("Error While opening the File!\r\n" + e.Message);
                this.result = null;
                restoreGui();
                return;
            }

            if (masterData == null)
            {
                this.result = null;
                restoreGui();
                return;
            }

            IDictionary <string, ForecastLine> forecast = readForecast();

            IList <ResultLine> result = new List <ResultLine>();

            foreach (ForecastLine forecastLine in forecast.Values)
            {
                Application.DoEvents();
                ResultLine resultLine = new ResultLine();

                resultLine.ArtikelNrForecast = forecastLine.ArtikelNr;
                resultLine.Quantities        = forecastLine.Quantities;
                resultLine.Quantity          = forecastLine.Quantities.Sum();

                MasterDataLine masterDataLine = null;

                if (masterData.ContainsKey(forecastLine.ArtikelNr.ToUpper()))
                {
                    masterDataLine = masterData[forecastLine.ArtikelNr.ToUpper()];
                }
                else
                {
                    string artNr = forecastLine.ArtikelNr.Substring(1, forecastLine.ArtikelNr.Length - 3).ToUpper();
                    if (masterData.ContainsKey(artNr))
                    {
                        masterDataLine = masterData[artNr];
                    }
                }

                if (masterDataLine != null)
                {
                    resultLine.ArtikelNrMasterData = masterDataLine.ArtikelNr;
                    resultLine.Length    = masterDataLine.Length;
                    resultLine.Width     = masterDataLine.Width;
                    resultLine.Thickness = masterDataLine.Thickness;
                }

                result.Add(resultLine);
            }

            string s = "";

            foreach (MasterDataLine value in masterData.Values)
            {
                s += value.ToString() + "\r\n";
            }
            textBoxMasterdata.Text = s;

            s = "";
            foreach (ForecastLine value in forecast.Values)
            {
                s += value.ToString() + "\r\n";
            }
            textBoxForecast.Text = s;

            s = "";
            foreach (ResultLine value in result)
            {
                s += value.ToString() + "\r\n";
            }
            textBoxResult.Text = s;

            this.result = result;

            restoreGui();
        }
Example #19
0
        public void CalcFeatures()
        {
            var files       = Directory.GetFiles(datasetDir);
            var rawFiles    = files.Where(f => f.EndsWith(".raw"));
            var targetFiles = files.Where(f => f.EndsWith("_IcTda.tsv")).ToDictionary(Path.GetFileNameWithoutExtension, f => f);
            var decoyFiles  = files.Where(f => f.EndsWith("_IcDecoy.tsv")).ToDictionary(Path.GetFileNameWithoutExtension, f => f);

            var results = new ConcurrentBag <ResultLine>();

            foreach (var rawFile in rawFiles)
            {
                var        scans  = new Dictionary <int, DeconvolutedSpectrum>();
                PbfLcMsRun pbfRun = (PbfLcMsRun)PbfLcMsRun.GetLcMsRun(rawFile);

                var idName    = $"{Path.GetFileNameWithoutExtension(rawFile)}_IcTda";
                var ids       = this.ParseIdFile(targetFiles[idName], true);
                var decoyName = $"{Path.GetFileNameWithoutExtension(rawFile)}_IcDecoy";
                var decoys    = this.ParseIdFile(decoyFiles[decoyName], false);
                ids.AddRange(decoys);

                foreach (var id in ids)
                {
                    DeconvolutedSpectrum spectrum;
                    if (scans.ContainsKey(id.Scan))
                    {
                        spectrum = scans[id.Scan];
                    }
                    else
                    {
                        spectrum = this.GetDeconvolutedSpectrum(id.Scan, pbfRun);
                        scans.Add(id.Scan, spectrum);
                    }

                    var baseIonTypes = new[] { BaseIonType.A, BaseIonType.B, BaseIonType.C, BaseIonType.X, BaseIonType.Y, BaseIonType.Z };
                    var cleavages    = id.Sequence.GetInternalCleavages();
                    foreach (var cleavage in cleavages)
                    {
                        foreach (var baseIonType in baseIonTypes)
                        {
                            var baseComp    = baseIonType.IsPrefix ? cleavage.PrefixComposition : cleavage.SuffixComposition;
                            var composition = baseComp + baseIonType.OffsetComposition;
                            var mass        = composition.Mass;
                            var peak        = spectrum.FindPeak(mass, new Tolerance(10, ToleranceUnit.Ppm)) as DeconvolutedPeak;
                            if (peak == null)
                            {
                                continue;
                            }
                            else
                            {
                                var result = new ResultLine
                                {
                                    Corr      = peak.Corr,
                                    Cosine    = peak.Dist,
                                    Error     = Math.Abs(mass - peak.Mass) / peak.Mass * 1e6,
                                    Intensity = peak.Intensity,
                                    IsTarget  = id.IsTarget
                                };

                                results.Add(result);
                            }
                        }
                    }
                }
                using (var writer = new StreamWriter(outputFile))
                {
                    foreach (var result in results)
                    {
                        int isTarget = result.IsTarget ? 1 : 0;
                        writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", result.Corr, result.Cosine, result.Error, result.Intensity, isTarget);
                    }
                }
            }
        }
Example #20
0
 protected override string Response(string folderName, char delimiter, List <string> attributes)
 {
     return(ResultLine.LSUB(folderName, delimiter, attributes));
 }