public void SendMail() { var recipients = new List <MapiRecipDesc>(); To.ForEach(email => recipients.Add(new MapiRecipDesc { recipClass = RecipClass.To, name = email })); CC.ForEach(email => recipients.Add(new MapiRecipDesc { recipClass = RecipClass.CC, name = email })); BCC.ForEach(email => recipients.Add(new MapiRecipDesc { recipClass = RecipClass.BCC, name = email })); var msg = new MapiMessage { subject = Subject, noteText = Body, recips = GetRecipientsData(recipients), recipCount = recipients.Count, files = GetAttachmentsData(Attachments), fileCount = Attachments.Count, }; int result = MAPISendMail(IntPtr.Zero, IntPtr.Zero, msg, MAPI_LOGON_UI | MAPI_DIALOG, 0); if (result > 1) { throw new Exception("Failed to send mail: {0}.".Fmt(GetErrorMessage(result))); } Cleanup(msg); }
public void SetUserReadStatus(User user, bool read) { if (Receivers.Contains(user) || BCC.Contains(user) || CC.Contains(user)) { IsRead[user.Email] = read; } }
/// <summary> /// E-Mail durch Benutzereingabe /// </summary> /// <param name="model"></param> /// <returns></returns> public EmailResult CustomTextEmail(CustomMailModel model) { if (!string.IsNullOrEmpty(model.SenderUser.Email)) { From = new MailAddress(model.SenderUser.Email, model.SenderUser.FirstName + " " + model.SenderUser.LastName + " (via NINE)").ToString(); } if (model.ReceiverUsers.Count == 1) { To.Add(model.ReceiverUsers.First().Email); } else { // Mehr als einer => BCC foreach (var receiver in model.ReceiverUsers) { BCC.Add(receiver.Email); } } foreach (var attachtment in model.Attachments) { Attachments.Add(attachtment.FileName, attachtment.Bytes); } Subject = model.Subject; return(Email("CustomTextMail", model)); }
private void CleanCollections() { To?.RemoveAll(s => s == null); CC?.RemoveAll(s => s == null); BCC?.RemoveAll(s => s == null); ReplyToList?.RemoveAll(s => s == null); Headers?.RemoveAll(s => s == null); Attachments?.RemoveAll(s => s == null); }
protected void Button1_Click(object sender, EventArgs e) { DataView dvieww; string SMTP; string BCC; string EmailFrom; string Password; dvieww = (DataView)SqlDataSource8.Select(DataSourceSelectArguments.Empty); SMTP = (string)dvieww.Table.Rows[0]["SMTP"]; BCC = (string)dvieww.Table.Rows[0]["BCC"]; EmailFrom = (string)dvieww.Table.Rows[0]["EmailFrom"]; Password = (string)dvieww.Table.Rows[0]["Password"]; MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(SMTP.ToString()); mail.From = new MailAddress(EmailFrom.ToString()); //Email acpe = new Email(); mail.To.Add(TextBox2.Text); mail.Bcc.Add(BCC.ToString()); StreamReader reader = new StreamReader(Server.MapPath("~/email/Contact.html")); string readFile = reader.ReadToEnd(); string myString = ""; myString = readFile; //string name = HttpUtility.UrlEncode(Encrypt(Session["UserName"].ToString().Trim())); //string technology = HttpUtility.UrlEncode(Encrypt(ddlTechnology.SelectedItem.Value)); myString = myString.Replace("{#Name}", TextBox1.Text); myString = myString.Replace("{#Email}", TextBox2.Text); myString = myString.Replace("{#Message}", TextBox3.Text); //myString = myString.Replace("{#message}", TextBox4.Text); mail.Subject = "New Contact on onlinehcs.com"; mail.IsBodyHtml = true; mail.Body = myString.ToString(); SmtpServer.Port = 8889; SmtpServer.Credentials = new System.Net.NetworkCredential(EmailFrom.ToString(), Password.ToString()); SmtpServer.EnableSsl = false; object userState = mail; SmtpServer.SendCompleted += new SendCompletedEventHandler(SMTPClientForAsy.SmtpClient_OnCompleted); SmtpServer.SendAsync(mail, userState); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; TextBox3.Text = string.Empty; Label5.Text = "Submitted Successfully"; }
public Rents(Controller contobj1, MainPage M1) { InitializeComponent(); contobj = contobj1; M = M1; string[] Status = new string[3] { "ALL", "Paid", "Not-Paid" }; RS.DataSource = Status; RS.Refresh(); DataTable dt1 = contobj.GetAllCollecters(); RC.DataSource = dt1; RC.DisplayMember = "Employee_FirstName"; RC.ValueMember = "Employee_Id"; RC.Refresh(); DataTable dt2 = contobj.GetAllCollecters(); Collecter.DataSource = dt2; Collecter.DisplayMember = "Employee_FirstName"; Collecter.ValueMember = "Employee_Id"; Collecter.Refresh(); DataTable dt3 = contobj.GetAllUnits(); Units.DataSource = dt3; Units.ValueMember = "Unit_Id"; Units.Refresh(); DataTable dt4 = contobj.GetAllTenants(); tenants.DataSource = dt4; tenants.DisplayMember = "Tenant_FirstName"; tenants.ValueMember = "Tenant_Id"; tenants.Refresh(); DataTable dt5 = contobj.GetAllBuildings(); BCC.DataSource = dt5; BCC.DisplayMember = "Building_Name"; BCC.ValueMember = "Building_Id"; BCC.Refresh(); DataTable dt6 = contobj.GetAllOwners(); Owners.DataSource = dt6; Owners.DisplayMember = "Owner_Name"; Owners.ValueMember = "Owner_Id"; Owners.Refresh(); }
protected override void Execute(CodeActivityContext context) { Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); var to = To.Get(context); var cc = CC.Get(context); var bcc = BCC.Get(context); var subject = Subject.Get(context); string body = (Body != null ?Body.Get(context) : null); string htmlbody = (HTMLBody != null ? HTMLBody.Get(context) : null); if (!string.IsNullOrEmpty(htmlbody)) { body = htmlbody; } var attachments = Attachments.Get(context); var uiaction = UIAction.Get(context); email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText; email.To = to; email.Subject = subject; email.HTMLBody = body; email.CC = cc; email.BCC = bcc; if (attachments != null && attachments.Count() > 0) { foreach (var attachment in attachments) { if (!string.IsNullOrEmpty(attachment)) { email.Attachments.Add(attachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 100000, Type.Missing); } } } if (uiaction == "Show") { email.Display(true); } //else if(uiaction == "SendVisable") //{ // email.Display(true); // email.Send(); //} else { email.Send(); } if (EMail != null) { EMail.Set(context, new email(email)); } }
public override string ToString() { var emailString = string.Format("Email: \nFrom: '{0}' \nTo: '{1}' \nCC: '{2}' \nBCC: '{3}' \nSubject: '{4}' \nBody:\n{5} \nAttachments: '{6}'.", From, To.ToSeparatedString(t => t), CC.ToSeparatedString(c => c), BCC.ToSeparatedString(b => b), Subject, Body.Replace(@"<br\>", "\n").Replace(@"<br>", "\n").Replace(@"<br \>", "\n"), Attachments != null ? Attachments.ToSeparatedString(a => a.FileName) : string.Empty); return(emailString); }
protected override void Execute(CodeActivityContext context) { String sTO = To.Get(context); String sBCC = BCC.Get(context); String sCC = CC.Get(context); String sAccount = Account.Get(context); String sBody = Body.Get(context); String sSubject = Subject.Get(context); Boolean bisBodyHTML = isBodyHTML; String[] arrAttachment = Attachment.Get(context); sendOutlookMail(sTO, sCC, sBCC, sBody, sSubject, sAccount, bisBodyHTML, arrAttachment); }
internal void Validate() { if (To.Count == 0) { throw new ArgumentException(ErrorMessages.EmptyToRecipients); } To.Validate(); CC.Validate(); BCC.Validate(); }
protected override void Execute(CodeActivityContext context) { String sTO = To.Get(context); String sBCC = BCC.Get(context); String sCC = CC.Get(context); String sAccount = Account.Get(context); String sBody = Body.Get(context); String sSubject = Subject.Get(context); String[] arrAttachment = Attachment.Get(context); Dictionary <String, String> dict = EmbedImage.Get(context); sendOutlookMailImage(sTO, sCC, sBCC, sBody, sSubject, sAccount, arrAttachment, dict); }
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var resSling = ((sender as FrameworkElement).Tag as ListData).Data as ResSling; this.curSling = resSling; this.tbInfo.Text = ""; this.gridNo = resSling.CabinetGrid; // 发送开锁信号,通知柜门开锁 if (spCabinet.IsOpen) // 已打开,直接发送消息 { var msg = string.Format("8A 01 {0} 11", Convert.ToInt32(resSling.CabinetGrid).ToString("X2")); var flag = spCabinet.Write(string.Format("{0} {1}", msg, BCC.CheckXOR(msg))); if (!flag) { Log.WriteLog(string.Format("ERROR-BOM:开锁消息发送失败,{0}", msg)); } } else // 未打开,先打开端口 { SpConfig spConfig = new SpConfig(); spConfig.PortName = ConfigurationManager.AppSettings["CabinetPort"]; spConfig.BaudRate = 9600; // 波特率 spConfig.Parity = System.IO.Ports.Parity.None; // 偶校验位 spConfig.DataBits = 8; spConfig.StopBits = System.IO.Ports.StopBits.One; // 停止位 try { // 打开 string err = ""; if ((err = spCabinet.Open(spConfig)) != "") { this.ShowMessageInfo(err, this.redBrush); } // 发开锁消息 var msg = string.Format("8A 01 {0} 11", Convert.ToInt32(resSling.CabinetGrid).ToString("X2")); var flag = spCabinet.Write(string.Format("{0} {1}", msg, BCC.CheckXOR(msg))); if (!flag) { Log.WriteLog(string.Format("ERROR-BOM:开锁消息发送失败,{0}", msg)); } } catch (Exception ex) { this.ShowMessageInfo("开锁失败,请重试!", this.redBrush); Log.WriteLog(string.Format("ERROR-BOM:开锁失败,失败信息:{0}", ex.Message)); } } }
private void SpCabinet_DataReceived(DataReceivedEventArgs e) { var temps = e.data.Split(' '); if (temps.Length == 5 && temps[0] == "8A") { if (temps[3] == "11") { isOpening = true; var msginfo = string.Format("{0}号柜门已打开!请放入设备,并关闭柜门。", Convert.ToInt32(temps[2], 16)); this.ShowMessageInfo(msginfo, this.greenBrush); // 启动轮询定时器查询锁状态 if (timer.IsEnabled) { timer.Stop(); } var msg = string.Format("80 01 {0} 33", temps[2]); timer.Tag = string.Format("{0} {1}", msg, BCC.CheckXOR(msg)); timer.Start(); } else { var msg = string.Format("{0}号柜门打开失败,请重试!", Convert.ToInt32(temps[2], 16)); this.ShowMessageInfo(msg, this.redBrush); Log.WriteLog("ERROR-RET:" + msg); } } else if (temps.Length > 5 && temps[0] == "80") { if (temps[4] == "01") { // MessageBox.Show(string.Format("{0}号柜门已打开!", Convert.ToInt32(temps[1], 16))); } else if (temps[4] == "00") { this.timer.Stop(); Log.WriteLog(string.Format("INFO-RET:{0}号柜门已关闭!操作人员:{1}", this.gridNo, this.staffName)); if (grid2RFID.ContainsKey(this.gridNo)) { this.ReturnSling(grid2RFID[this.gridNo]); } var msg = string.Format("{0}号柜门已关闭!", this.gridNo); isOpening = false; this.ShowMessageInfo(msg, this.greenBrush); } } }
public void Validate() { if (this.Settings == null) { throw new Exception("Settings must be supplied"); } this.Settings.Validate(); this.CleanCollections(); if (To?.Any() == false && CC?.Any() == false && BCC?.Any() == false) { throw new Exception("At lest one To, CC or BCC must be supplied"); } if (string.IsNullOrWhiteSpace(this.Body)) { throw new Exception("Body must have some content"); } if (string.IsNullOrWhiteSpace(this.Subject)) { throw new Exception("Subjet must be supplied"); } this.Sender?.Validate(); this.From?.Validate(); this.To?.Validate(); this.CC?.Validate(); this.BCC?.Validate(); this.ReplyToList?.Validate(); this.Headers?.Validate(); this.Attachments?.Validate(); if (this.Attachments?.Sum(s => s.Content.Length) > MAXIMUM_SUM_ATTACHMENTS_SIZE) { throw new Exception($"Total size of attachments exceeds {(20971520 / 1024) / 1024}MB"); } if (Headers?.Count > 0 && Headers.Select(s => s.Name.Trim()).Distinct(StringComparer.OrdinalIgnoreCase).Count() != Headers.Count) { throw new Exception("Duplicate email headers are not allowed"); } }
public EmailResult SendNewsletter(Newsletter newsletter) { var blog = _blogRepository.First(); To.Add(blog.Email); foreach (var subscriber in newsletter.Subscribers) { BCC.Add(subscriber.Email); } From = blog.Email; Subject = newsletter.Title; return(Email("SendNewsletter", new Article { Title = newsletter.Title, ImageUrl = newsletter.ImageUrl, Body = newsletter.Body })); }
public static void EnemyTurn() { timeOut = false; BCC.ChangeChoiceText(choiceName: "monsterPreAttack", onlyShowText: new TextAndPosition(globerEnemy.PreAttackSymptom(), 15, 3 + 5, 1) { AlignH = true }); BCC.ChangeChoiceText(choiceName: "monsterAttack", onlyShowText: new TextAndPosition(globerEnemy.AttackCry(), 15, 3 + 5, 1) { AlignH = true }); String currentChoice = "monsterPreAttack"; //첫 화면 BDTG.Display(BCC.GetChoiceClone(currentChoice)); currentChoice = (String)BCC.GetChoiceClone(currentChoice).QuickNext(); WaitTimeOrInput(150); //1500ms를 기다리던지 아님 입력이 들어오면 다음으로 진행 //Console.ReadKey(); BDTG.Display(BCC.GetChoiceClone(currentChoice)); Attacking(globerEnemy, globerPlayer); currentChoice = (String)BCC.GetChoiceClone(currentChoice).QuickNext(); WaitTimeOrInput(150); //Console.ReadKey(); BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerPlayer.Reaction(), 15, 9, 1) { AlignH = true }); BDTG.Display(BCC.GetChoiceClone(currentChoice)); currentChoice = "movePhase"; WaitTimeOrInput(150); //Console.ReadKey(); if (globerPlayer.Hp <= 0) { //testLog("in die"); died = true; return; } BDTG.Display(BCC.GetChoiceClone(currentChoice)); TimerStart(); }
public EmailResult SendAnnouncementEmail(Message model, List <string> emailList) { emailList.ForEach(x => To.Add(x)); string earnEmail = "", esrgcEmail = ""; try { earnEmail = ConfigurationManager.AppSettings["earnEmail"].ToString(); esrgcEmail = ConfigurationManager.AppSettings["esrgcEmail"].ToString(); } catch { earnEmail = "*****@*****.**"; esrgcEmail = "*****@*****.**"; } BCC.Add(earnEmail); BCC.Add(esrgcEmail); Subject = "EARN MD CONNECT - " + model.Title; return(Email("SendAnnouncementEmail", model)); }
public void DebugDump() { string html = ""; if (Subject.IsNotBlank()) { html += "Subject: " + Subject.HtmlEncode() + "<br>"; } if (FromAddress.IsNotBlank()) { html += "FromAddress: " + FromAddress.HtmlEncode() + "<br>"; } if (FromName.IsNotBlank()) { html += "FromName: " + FromName.HtmlEncode() + "<br>"; } if (ToAddress.IsNotBlank()) { html += "ToAddress: " + ToAddress.HtmlEncode() + "<br>"; } if (ToName.IsNotBlank()) { html += "ToName: " + ToName.HtmlEncode() + "<br>"; } if (CC.IsNotBlank()) { html += "CC: " + CC.HtmlEncode() + "<br>"; } if (BCC.IsNotBlank()) { html += "BCC: " + BCC.HtmlEncode() + "<br>"; } if (BodyHtml.IsNotBlank()) { html += "BodyHtml: " + BodyHtml + "<br>"; } if (BodyPlain.IsNotBlank()) { html += "BodyPlain: " + BodyPlain.HtmlEncode() + "<br>"; } Web.Write(html); }
private void OpenCabinet(string cabinetGrid, string cabinetId) { // 发送开锁信号,通知柜门开锁 if (spCabinet.IsOpen) // 已打开,直接发送消息 { var msg = string.Format("8A 01 {0} 11", Convert.ToInt32(cabinetGrid).ToString("X2")); var flag = spCabinet.Write(string.Format("{0} {1}", msg, BCC.CheckXOR(msg))); if (!flag) { Log.WriteLog(string.Format("ERROR-STR:开锁消息发送失败,{0}", msg)); } } else // 未打开,先打开端口 { SpConfig spConfig = new SpConfig(); spConfig.PortName = ConfigurationManager.AppSettings["CabinetPort"]; spConfig.BaudRate = 9600; // 波特率 spConfig.Parity = System.IO.Ports.Parity.None; // 偶校验位 spConfig.DataBits = 8; spConfig.StopBits = System.IO.Ports.StopBits.One; // 停止位 try { // 打开 spCabinet.Open(spConfig); // 发开锁消息 var msg = string.Format("8A 01 {0} 11", Convert.ToInt32(cabinetGrid).ToString("X2")); var flag = spCabinet.Write(string.Format("{0} {1}", msg, BCC.CheckXOR(msg))); if (!flag) { Log.WriteLog(string.Format("ERROR-STR:开锁消息发送失败,{0}", msg)); } } catch (Exception ex) { this.ShowMessageInfo("开锁失败,请重试!", this.redBrush); Log.WriteLog(string.Format("ERROR-STR:开锁失败,失败信息:{0}", ex.Message)); } } }
private byte[] BOX(byte[] box) { int BCC, i, temp = box[0], num = box.Count(); byte[] Date = new byte[num + 3]; for (i = 1; i < box.Count(); i++) { temp = temp ^ box[i]; Date[i] = box[i - 1]; } BCC = temp ^ ETX; Date[0] = STX; i = 0; foreach (byte b in box) { Date[i + 1] = b; i++; } Date[num + 1] = ETX; Date[num + 2] = byte.Parse(BCC.ToString()); return(Date); }
/// <summary>Adds a recipient EmailAddress to the MailMessage</summary> /// <param name="address">EmailAddress that you want to add to the MailMessage</param> /// <param name="type">AddressType of the address</param> /// <example> /// <code> /// MailMessage msg = new MailMessage("*****@*****.**", "*****@*****.**"); /// MailAddress cc = new MailAddress("*****@*****.**"); /// msg.AddRecipient(cc, AddressType.Cc); /// </code> /// </example> public void AddRecipient(MailAddress address, AddressType type) { try { switch (type) { case AddressType.To: To.Add(address); break; case AddressType.Cc: CC.Add(address); break; case AddressType.Bcc: BCC.Add(address); break; } } catch (Exception e) { throw new SmtpException(string.Format("Exception in AddRecipient: {0}", e)); } }
public EmailPayload AsEmailPayload() { var toList = To.Select(item => item.To).ToList(); var bccList = BCC.Select(item => item.To).ToList(); var ccList = CC.Select(item => item.To).ToList(); return(new EmailPayload { FromEmailAddress = FromEmailAddress, To = toList, BCC = bccList, CC = ccList, Body = Body, Subject = Subject, Attachments = Attachments, Headers = Headers, ReplyToList = ReplyToList, LoginName = LoginName, Password = Password, UseSSL = UseSSL, IsBodyHtml = IsBodyHtml, AlternateViews = AlternateViews }); }
}//end function RunParallelActiveLearning /// <summary> /// RunBatchRunning experiment in background thread /// </summary> /// <param name="worker"></param> /// <param name="e"></param> public void RunBatchRunningExperiment( System.ComponentModel.BackgroundWorker worker, System.ComponentModel.DoWorkEventArgs e) { CurrentParallelState currentState; //Get the number of the total experiment Items int totalNumberOfModels = GetNumberOfExperiemntModels(); //A List of Results array ofreport all experimentItems results = new List <Results>(); currentState = new CurrentParallelState(); //Running the current experimentSetting lists and runGold accordinglyb foreach (ExperimentModel currentExpItem in experimentModels) { //currentState.currentExperimentModel = currentExpItem; if (MainPage.mainPageForm.isExperimentComplete) { return; } currentState = new CurrentParallelState(); currentState.currentExperimentModelIndex = GetExperimenModelIndex(currentExpItem); currentState.isCurrentModelCompleted = false; //Pass the started currentIndex to the mainpage, such that this currentExpItem is started worker.ReportProgress(0, currentState); //Create a BCC/CBCC model of the Batch Running Experiment BCC currentModel = null; if (currentExpItem.runType == RunType.BCC) { currentModel = new BCC(); } else if (currentExpItem.runType == RunType.CBCC) { currentModel = new CBCC(); ((CBCC)currentModel).SetCommunityCount(MainPage.mainPageForm.currentExperimentSetting.communityCount); } //When the experiment is not running while (!MainPage.mainPageForm.isExperimentRunning) { } if (MainPage.mainPageForm.isExperimentComplete) { return; } results.Add(CrowdsourcingModels.Program.RunBatchLearning(currentDataset.DatasetPath, currentExpItem.runType, currentModel, MainPage.mainPageForm.currentExperimentSetting.communityCount)); //When the experiment is not running while (!MainPage.mainPageForm.isExperimentRunning) { } if (MainPage.mainPageForm.isExperimentComplete) { return; } //add the results into the List<Results[]> //convert the lists into a single array of results (using LINQ) //notify the mainPage UI while it is completed currentState.isCurrentModelCompleted = true; worker.ReportProgress(0, currentState); } // For each experimentItem //The Batch Running is completed currentState.isRunningComplete = true; }
/// <summary> /// Background Thread for running the active learning experiment /// <param name="worker"></param> /// <param name="e"></param> public void RunParallelActiveLearning( System.ComponentModel.BackgroundWorker worker, System.ComponentModel.DoWorkEventArgs e) { //Create a state of the Thread CurrentParallelState currentState = new CurrentParallelState(); //Set setting in the experimentSetting Class int totalNumberOfModels = GetNumberOfExperiemntModels(); //Clear previous results ActiveLearning.ResetParallelAccuracyList(totalNumberOfModels); //obtain the accuracy list reference accuracyArrayOfAllExperimentModels = ActiveLearning.accuracyArray; //The RunTypes that have Worker Confusion Matrices RunType[] runTypesHaveWorkerMatrices = { RunType.DawidSkene, RunType.BCC, RunType.CBCC }; //Set the models selected in the setting pane string[] currentModelNames = new string[totalNumberOfModels]; RunType[] currentRunTypes = new RunType[totalNumberOfModels]; TaskSelectionMethod[] currentTaskSelectionMethods = new TaskSelectionMethod[totalNumberOfModels]; WorkerSelectionMethod[] currentWorkerSelectionMethods = new WorkerSelectionMethod[totalNumberOfModels]; BCC[] currentBCCModels = new BCC[totalNumberOfModels]; //for each ExperimentModel, set runTypeArray, taskSelectionMethodArray, workerSelectionMethodArray... for (int i = 0; i < totalNumberOfModels; i++) { ExperimentModel currentExperimentModel = GetExperimentModel(i); RunType currentRunType = currentExperimentModel.runType; currentRunTypes[i] = currentRunType; //set the task selection method currentTaskSelectionMethods[i] = currentExperimentModel.taskSelectionMethod; //Add into worker selection method array if the runType can have worker selection if (runTypesHaveWorkerMatrices.Contains(currentRunType)) { currentWorkerSelectionMethods[i] = currentExperimentModel.WorkerSelectionMethod; //Add corresponding model //if the RunType is BCC, add into BCC model array if (currentRunType == RunType.BCC) { currentBCCModels[i] = new BCC(); }//CBCC Model else if (currentRunType == RunType.CBCC) { CBCC currentBCCmodel = new CBCC(); currentBCCModels[i] = currentBCCmodel; } } //end if the runType has worker confusion matrices } //end for currentModelNames = currentModelNames.Select((s, i) => CrowdsourcingModels.Program.GetModelName(currentDataset.GetDataSetNameWithoutExtension(), currentRunTypes[i])).ToArray(); //run RunParallelActiveLearning in the ActiveLearning ActiveLearning.RunParallelActiveLearning(currentDataset.LoadData(), currentModelNames, currentRunTypes, currentBCCModels, currentTaskSelectionMethods, currentWorkerSelectionMethods, communityCount, numberOfLabellingRound); currentState.isRunningComplete = true; Debug.WriteLine("RunParallelActiveLearning Complete"); //isSimulationComplete = true; //worker.ReportProgress(0, currentState); }//end function RunParallelActiveLearning
public void AddBCC(ICollection <string> bcc) { bcc = bcc ?? new List <string>(); BCC.AddRange(bcc); }
protected override void Execute(CodeActivityContext context) { MailMessage forwardMail = MailMessage.Get(context); if (forwardMail != null) { string html = ExportMailToHtml(forwardMail); string strHeader = "<p>"; string fMessage = ForwardMessage.Get(context); if (!string.IsNullOrEmpty(fMessage)) { fMessage = TextToHtml(fMessage); Console.WriteLine(fMessage); strHeader = fMessage + "<br>"; } if (ShowOriginalMessage) { strHeader = strHeader + "<br><br>" + "-----Original Message-----" + "<br>"; strHeader += "From: " + forwardMail.From.DisplayName + "<br>"; strHeader += "Sent: " + forwardMail.Headers["Date"] + "<br>"; strHeader += "To: " + forwardMail.To + "<br>"; strHeader += "Subject: " + forwardMail.Subject + "<br><br>"; } forwardMail.Subject = "FW: " + forwardMail.Subject; forwardMail.IsBodyHtml = true; forwardMail.Body = strHeader + GetTrimmedBodyText(html) + "</p>"; string to = To.Get(context); if (!string.IsNullOrEmpty(to)) { to = to.Replace(",", ";"); var toSplits = to.Split(';'); foreach (var t in toSplits) { forwardMail.To.Add(new MailAddress(t)); } } string cc = CC.Get(context); if (!string.IsNullOrEmpty(cc)) { cc = cc.Replace(",", ";"); var ccSplits = cc.Split(';'); foreach (var cs in ccSplits) { forwardMail.CC.Add(new MailAddress(cs)); } } string bcc = BCC.Get(context); if (!string.IsNullOrEmpty(bcc)) { bcc = bcc.Replace(",", ";"); var bccSplits = bcc.Split(';'); foreach (var b in bccSplits) { forwardMail.Bcc.Add(new MailAddress(b)); } } this.ForwardMail.Set(context, forwardMail); } else { Console.WriteLine("No Mail Message Found"); } }
public static void BattleReaction() { Random random = new Random(); currentChoice = (String)BCC.GetChoiceClone(currentChoice).QuickNext(); Choice cho; if (currentChoice == "reactionPhase") //8.22 { BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerEnemy.Reaction(), 15, 9, 1) { AlignH = true }); BCC.ChangeChoiceText(choiceName: "movePhase", onlyShowText: new TextAndPosition(globerEnemy.CurrentState(), 15, 3 + 5, 1) { AlignH = true }); } //12.07 공격 파워에 따른 메세지를 최대체력 비례에서 현재체력 비례로 변경함에 따라 몬스터에게 데미지가 들어가는 타이밍을 몬스터Reaction메세지를 받은 후로 바꾸려다가... 말음 //대신 이전 현재체력을 나타내는 것 변수 추가 BDTG.Display(BCC.GetChoiceClone(currentChoice)); keyInfo = Console.ReadKey(); if (globerEnemy.HpState() == 3) //8.22 몬스터의 HP상태가 빈사 상태일때 배틀 페이즈 종료 const int Died = 3 { BCC.ChangeChoiceText(choiceName: "andPhase", onlyShowText: new TextAndPosition(globerEnemy.CurrentState(), 15, 3 + 5, 1) { AlignH = true }); BDTG.Display(BCC.GetChoiceClone("andPhase")); keyInfo = Console.ReadKey(); globerPlayer.PlayerQuestCheck(globerEnemy); //testLog(((HuntQuest)globerPlayer.QuestList[0]).MonsterCount[0]); List <Item> drops = globerEnemy.ItemDrop(); foreach (Item i in drops) { globerPlayer.inven.AddItem(i); int rx = random.Next(20, 100); int ry = random.Next(2, 13); AlertWindow(i.Name + " 획득!", windowXPos: rx, windowYPos: ry, textXPos: 0, textYPos: 9, background: "getItem", delay: 10, color: ConsoleColor.DarkYellow); } if (drops.Count > 0) { Console.ReadKey(); } if (globerEnemy.IsSpawnOnce) { GameManager.DespawnEnemy(globerEnemy.Name, PlayData.WorldMap.GetChoice(backField)); } if (globerEnemy.DeathEvent != null) { PlayData.delegateList.ActionList[globerEnemy.DeathEvent](); //여기서 backField에 접근하므로 DespawnEnemy가 먼저 실행되어야한다. } battleAnd = true; turnAnd = true; } else { currentChoice = "movePhase"; BDTG.Display(BCC.GetChoiceClone(currentChoice)); TimerStart(); turnAnd = true; } }
public static void PlayerTurn() { timerEnd = false; turnAnd = false; while (!turnAnd) { if (currentChoice == "movePhase") { turnAnd = true; } if (currentChoice == "attackPhase") //Attacker,Defender에 값을 넣으면 서로 데미지 계산 1회 실행 { actionType = ActionType.ATTACK; BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerPlayer.AttackCry(), 15, 9, 1) { AlignH = true }); Attacker = globerPlayer; Defender = globerEnemy; Thread.Sleep(10); BDTG.Display(BCC.GetChoiceClone(currentChoice)); Console.ReadKey(); BattleReaction(); } else if (currentChoice == "block") //Attacker,Defender에 값을 넣으면 서로 데미지 계산 1회 실행 { actionType = ActionType.BLOCK; Attacker = globerPlayer; Defender = globerEnemy; Thread.Sleep(10); if (successCheck) { currentChoice = "successBlock"; BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerEnemy.BlockSuccess(), 15, 9, 1) { AlignH = true }); } else { currentChoice = "failBlock"; BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerEnemy.BlockFail(), 15, 9, 1) { AlignH = true }); } BDTG.Display(BCC.GetChoiceClone(currentChoice)); Console.ReadKey(); if (currentChoice == "failBlock") { currentChoice = (String)BCC.GetChoiceClone(currentChoice).QuickNext(); //monsterReactionPhase BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerPlayer.Reaction(), 15, 9, 1) { AlignH = true }); BDTG.Display(BCC.GetChoiceClone(currentChoice)); Console.ReadKey(); } currentChoice = (String)BCC.GetChoiceClone(currentChoice).QuickNext(); //movePhase BDTG.Display(BCC.GetChoiceClone(currentChoice)); if (globerPlayer.Hp <= 0) { //testLog("in die"); died = true; timeOut = false; return; } turnAnd = true; TimerStart(); } else if (currentChoice == "dodge") //Attacker,Defender에 값을 넣으면 서로 데미지 계산 1회 실행 { actionType = ActionType.DODGE; Attacker = globerPlayer; Defender = globerEnemy; Thread.Sleep(10); if (successCheck) { currentChoice = "successDodge"; BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerEnemy.DodgeSuccess(), 15, 9, 1) { AlignH = true }); } else { currentChoice = "failDodge"; BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerEnemy.DodgeFail(), 15, 9, 1) { AlignH = true }); } BDTG.Display(BCC.GetChoiceClone(currentChoice)); Console.ReadKey(); if (currentChoice == "failDodge") { currentChoice = (String)BCC.GetChoiceClone(currentChoice).QuickNext(); //monsterReactionPhase BCC.ChangeChoiceText(choiceName: currentChoice, onlyShowText: new TextAndPosition(globerPlayer.Reaction(), 15, 9, 1) { AlignH = true }); BDTG.Display(BCC.GetChoiceClone(currentChoice)); Console.ReadKey(); } currentChoice = (String)BCC.GetChoiceClone(currentChoice).QuickNext(); //movePhase BDTG.Display(BCC.GetChoiceClone(currentChoice)); if (globerPlayer.Hp <= 0) { //testLog("in die"); died = true; timeOut = false; return; } turnAnd = true; TimerStart(); } } }
public static String BattlePhase(Player player, Enemy monster, String back) { globerPlayer = player; globerEnemy = monster; currentChoice = "firstPhase"; //첫 화면 limit = 3 * (1.0 * globerPlayer.AttackSpeed / globerEnemy.AttackSpeed); globerPlayer.ReactionMessage = globerEnemy.PlayerReactionMessage; backField = back; currentChoice = "firstPhase"; battleAnd = false; timerStart = false; BCC.ChangeChoiceText(choiceName: "movePhase", onlyShowText: new TextAndPosition(globerEnemy.CurrentState(), 15, 3 + 5, 1) { AlignH = true }); BCC.ChangeChoiceText(choiceName: "firstPhase", onlyShowText: new TextAndPosition(globerEnemy.GetRandomSpawnMessage().text, 15, 3 + 5, 1) { AlignH = true }); //Task.Run(()=>DisplayTimer()); BDTG.Display(BCC.GetChoiceClone(currentChoice)); while (true) { keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Enter) { currentChoice = (String)BDTG.GetCurrentSelectValue(); if (currentChoice == "end") { return(backField); } BDTG.Display(BCC.GetChoiceClone(currentChoice)); break; } BDTG.SelectingText(keyInfo); BDTG.Display(); } while (!battleAnd) { if (died) { died = false; globerPlayer.Hp = globerPlayer.MaxHp; //살아날때 체력 회복 timeOut = false; count = 0; return(savePoint); } TimerStart(); while (true) { Thread.Sleep(10); if (timeOut) { EnemyTurn(); } if (died) { died = false; globerPlayer.Hp = globerPlayer.MaxHp; //살아날때 체력 회복 timeOut = false; count = 0; return(savePoint); } if (Console.KeyAvailable) { break; } } keyInfo = Console.ReadKey(); BDTG.SelectingText(keyInfo); if (keyInfo.Key == ConsoleKey.Enter) { currentChoice = (String)BDTG.GetCurrentSelectValue(); if (currentChoice == "movePhase") { continue; } timerEnd = true; timer.Wait(); PlayerTurn(); timeOut = false; } else { BDTG.Display(); } } return(backField); }
/// <summary> /// Runs the active learning experiment presented in Venanzi et.al (WWW14) on a single data set. /// </summary> /// <param name="dataSet">The data.</param> /// <param name="runType">The model run type.</param> /// <param name="taskSelectionMethod">The method for selecting tasks (Random / Entropy).</param> /// <param name="model">The model instance.</param> /// <param name="communityCount">The number of communities (only for CBCC).</param> public static void RunHCOMPActiveLearning(string dataSet, RunType runType, TaskSelectionMethod taskSelectionMethod, int InitialNumLabelsPerTask, BCC model, int communityCount = 4) { var data = Datum.LoadData(@"Data/" + dataSet + ".csv"); string modelName = Program.GetModelName(dataSet, runType, taskSelectionMethod, WorkerSelectionMethod.RandomWorker); //initial Number of Label Per Task //int initialNumLabelsPerTask = 1; int initialNumLabelsPerTask = InitialNumLabelsPerTask; ActiveLearning.RunActiveLearning(data, modelName, runType, model, taskSelectionMethod, WorkerSelectionMethod.RandomWorker, ResultsDir, communityCount, initialNumLabelsPerTask); }