예제 #1
0
파일: MlTest.cs 프로젝트: schifflee/bjd5
        public void SetUp()
        {
            init = new Initialization();

            ml = init.CreateMl();

            user1 = new MailAddress("*****@*****.**");
            user2 = new MailAddress("*****@*****.**");
            //user3 = new MailAddress("*****@*****.**");
            user4  = new MailAddress("*****@*****.**");
            admin  = new MailAddress("*****@*****.**");
            admin2 = new MailAddress("*****@*****.**");
            //mlCtrl = init.MlAddr.Ctrl;
            //mlPost = init.MlAddr.Post;
            mlAdmin = init.MlAddr.Admin;
            //mailDaemon = new MailAddress("*****@*****.**");
            user1Str = string.Format("\"USER1\" <{0}>", user1.ToString());
            //user2Str = string.Format("\"USER2\" <{0}>", user2.ToString());
            //user3Str = string.Format("\"USER3\" <{0}>", user3.ToString());
            user4Str = string.Format("\"USER4\" <{0}>", user4.ToString());
            //adminStr = string.Format("\"ADMIN\" <{0}>", admin.ToString());
            admin2Str  = string.Format("\"ADMIN2\" <{0}>", admin2.ToString());
            mlCtrlStr  = string.Format("\"1BAN(CTRL)\" <{0}>", init.MlAddr.Ctrl);
            mlPostStr  = string.Format("\"1BAN\" <{0}>", init.MlAddr.Post);
            mlAdminStr = init.MlAddr.Admin.ToString();
            //mailDaemonStr = string.Format("\"Mail Delivery Subsystem\"<{0}>", mailDaemon.ToString());

            init.TestMailSave.Clear();//初期化
        }
예제 #2
0
파일: MlGetTest.cs 프로젝트: schifflee/bjd5
        public void SetUp()
        {
            const string mlName     = "1ban";
            var          domainList = new List <string> {
                "example.com"
            };
            //var tsDir = new TsDir();
            var kernel    = new Kernel();
            var logger    = new Logger();
            var manageDir = TestUtil.GetTmpDir("TestDir");


            _tsMailSave = new TsMailSave();//MailSaveのモックオブジェクト

            var memberList = new Dat(new[] { CtrlType.TextBox, CtrlType.TextBox, CtrlType.CheckBox, CtrlType.CheckBox, CtrlType.CheckBox, CtrlType.TextBox });

            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, ""));     //一般・読者・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, ""));    //一般・読者・×
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, ""));    //一般・×・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN", "*****@*****.**", true, false, true, "123"));  //管理者・×・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456")); //管理者・読者・投稿
            var        docs             = (from object o in Enum.GetValues(typeof(MlDocKind)) select "").ToList();
            const int  maxSummary       = 10;
            const int  getMax           = 10;
            const bool autoRegistration = true;
            const int  titleKind        = 5;
            var        mlOption         = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList);

            _ml = new Ml(kernel, logger, _tsMailSave, mlOption, mlName, domainList);
        }
예제 #3
0
        /// <summary>
        ///     Returns true if OrderRunnerChange instances are equal
        /// </summary>
        /// <param name="other">Instance of OrderRunnerChange to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrderRunnerChange other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return((Mb == other.Mb || Mb != null && Mb.SequenceEqual(other.Mb)) &&
                   (Uo == other.Uo || Uo != null && Uo.SequenceEqual(other.Uo)) &&
                   (Id == other.Id || Id != null && Id.Equals(other.Id)) &&
                   (Hc == other.Hc || Hc != null && Hc.Equals(other.Hc)) &&
                   (FullImage == other.FullImage || FullImage != null && FullImage.Equals(other.FullImage)) &&
                   (Ml == other.Ml || Ml != null && Ml.SequenceEqual(other.Ml)));
        }
예제 #4
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Mb != null)
                {
                    hash = hash * 59 + Mb.GetHashCode();
                }

                if (Uo != null)
                {
                    hash = hash * 59 + Uo.GetHashCode();
                }

                if (Id != null)
                {
                    hash = hash * 59 + Id.GetHashCode();
                }

                if (Hc != null)
                {
                    hash = hash * 59 + Hc.GetHashCode();
                }

                if (FullImage != null)
                {
                    hash = hash * 59 + FullImage.GetHashCode();
                }

                if (Ml != null)
                {
                    hash = hash * 59 + Ml.GetHashCode();
                }

                return(hash);
            }
        }
예제 #5
0
        //Does not work, needs a lot of work
        public async Task <ActionResult> GetMlRecs()
        {
            //get a playlist
            //try March 2019
            var listitemTest = await GetPlaylistTracks("https://api.spotify.com/v1/playlists/5h9qlv28tzvKGS3zuVSFAE");

            //get tracks
            var blah = new string[listitemTest.Length];
            var i    = 0;

            foreach (var t in listitemTest)
            {
                blah[i] = t.Track.Id;
                i++;
            }

            var fun = await GetAudioFeatures(blah);

            var listitemTestA = await GetPlaylistTracks("https://api.spotify.com/v1/playlists/0q8gYT2lebXYpRnoqpyGFa");

            //get tracks
            var blahA = new string[listitemTestA.Length];
            var j     = 0;

            foreach (var t in listitemTestA)
            {
                blahA[j] = t.Track.Id;
                j++;
            }

            var funA = await GetAudioFeatures(blah);

            //run through recommendation

            var b = Ml.Predict(fun, funA);


            //return playlist
            return(RedirectToAction("ViewPlaylist", new { href = "" }));
        }
예제 #6
0
파일: PostTest.cs 프로젝트: schifflee/bjd5
        public void SetUp()
        {
            var tsDir = new TsDir();

            _tsOption = new TsOption(tsDir);
            _tsOption.Set("FOLDER", "MailBox", "dir", string.Format("{0}\\MailBox", tsDir.Src));
            //user1,user2,user3
            _tsOption.Set("DAT", "MailBox", "user", "user1\tpass\buser2\tpass\buser3\tpass");

            var kernel    = new Kernel(null, null, null, null);
            var logger    = new Logger(kernel, "LOG", false, null);
            var manageDir = tsDir.Src + "\\TestDir";

            //MailQueue
            _mailQueue = new MailQueue(tsDir.Src + "\\MailQueue");
            var oneOption = kernel.ListOption.Get("MailBox");

            _mailBox = new MailBox(kernel, oneOption);

            var mailSave = new MailSave(kernel, _mailBox, logger, _mailQueue, "", _domainList);//モック

            var memberList = new Dat();

            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, ""));  //一般・読者・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, "")); //一般・読者・×
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, "")); //一般・×・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6" , "*****@*****.**" , false, false, true, ""));//一般・×・投稿 (Disable)
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN" , "*****@*****.**" , true, false, true, "123"));//管理者・×・投稿
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//管理者・読者・投稿 (Disable)
            var        docs             = (from object o in Enum.GetValues(typeof(MLDocKind)) select "").ToList();
            const int  maxSummary       = 10;
            const int  getMax           = 10;
            const bool autoRegistration = true;
            const int  titleKind        = 1;
            var        mlOption         = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList);

            _ml = new Ml(kernel, logger, mailSave, mlOption, _mlName, _domainList);
        }
예제 #7
0
        public Initialization2()
        {
            var tsDir = new TsDir();
            //var tsOption = new TsOption(tsDir);
            //var manageDir = tsDir.Src + "\\TestDir";

            //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory());
            var optionDef = tsDir.Src + "\\Option.def";


            //Docs
            Docs = new List <string>();
            var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932));

            foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind)))
            {
                var  tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower());
                bool hit = false;
                foreach (var l in lines)
                {
                    if (l.IndexOf(tag) == 0)
                    {
                        Docs.Add(l.Substring(tag.Length));
                        hit = true;
                        break;
                    }
                }
                if (!hit)
                {
                    Docs.Add("");
                }
            }

            Kernel     = new Kernel(null, null, null, null);
            Logger     = Kernel.CreateLogger("LOG", true, null);
            domainList = new List <string>()
            {
                "example.com"
            };
            MlAddr = new MlAddr(mlName, domainList);
            var mailQueue = new MailQueue(tsDir.Src + "TestDir");
            var oneOption = new Option(Kernel, "", "");
            var mailBox   = new MailBox(Kernel, oneOption);

            MailSave = new MailSave(Kernel, mailBox, Logger, mailQueue, "", domainList);
            MlOption = CreateMlOption();
            //MlUserList = CreateMlUsers();

            Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList);
            //30件のメールを保存
            for (int i = 0; i < 30; i++)
            {
                var mail = new Mail(null);
                mail.Init(Encoding.ASCII.GetBytes("\r\n"));  //区切り行(ヘッダ終了)
                mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1));
                mail.Init(Encoding.ASCII.GetBytes("1\r\n")); //本文
                mail.Init(Encoding.ASCII.GetBytes("2\r\n")); //本文
                mail.Init(Encoding.ASCII.GetBytes("3\r\n")); //本文

                Ml.Save(mail);
            }
        }