public ActionResult IndexCompleted(MyContent first, MyContent second) { return View(new AsynchroIndexViewModel { Title = first.Title, Detail = first.Detail, Body = second.Title + second.Detail, }); }
public static void Main() { var Error1 = File.ReadAllBytes("MySounds.WaveComponent/Error1.wav"); var Error1Player = new SoundPlayer(new MemoryStream(Error1)); Error1Player.PlaySync(); Error1Player.PlaySync(); Error1Player.PlaySync(); Console.WriteLine("other projects: "); Console.WriteLine("# http://naudio.codeplex.com/sourcecontrol/changeset/view/28884?projectName=naudio#"); Console.WriteLine(); var MyContent = new MyContent(); MyContent.WriteTo((sender, args) => ShowProperties((MyContent.WriteToArguments)args)); Console.WriteLine(); // you really should not use headphones with PC speakers TestMemoryStream(); Console.ForegroundColor = ConsoleColor.Yellow; Action<string> f = logo; f("hi"); Console.WriteLine("got music?"); var a = WaveExampleType.ExampleSquareWave.ToSoundPlayer(68); var b = WaveExampleType.ExampleSawtoothWave.ToSoundPlayer(115); var c = WaveExampleType.ExampleSquareWave.ToSoundPlayer(168); a.PlaySync(); a.Stream.WriteTo("a.wav"); b.PlaySync(); c.PlaySync(); //b.Stream.WriteTo("b.wav"); //c.Stream.WriteTo("c.wav"); //return 0; }
protected void Page_Load(object sender, System.EventArgs e) { int curId = Convert.ToInt32(Request.QueryString["ID"]); int curVer = Convert.ToInt32(Request.QueryString["Ver"]); if (!Request.IsAuthenticated) { ucLogin.Visible = true; } else { ucLogout.Visible = true; } MyContent content = new MyContent(appEnv.GetConnection()); AccountProperty property = new AccountProperty(appEnv.GetConnection()); DataRow dr = content.GetContentForIDVer(curId, curVer); if (Convert.ToInt32(dr["Protected"]) > 0) { if (!Request.IsAuthenticated) { Response.Redirect("../Login.aspx?URL=" + HttpUtility.UrlEncode(Request.RawUrl)); } } if (dr != null) { lbHeadline.Text = dr["Headline"].ToString(); lbSource.Text = dr["Source"].ToString(); lbByline.Text = property.GetValue(Convert.ToInt32(dr["Byline"]), "UserName").Trim(); lbDate.Text = dr["ModifiedDate"].ToString(); lbTeaser.Text = dr["Teaser"].ToString(); lbBody.Text = dr["Body"].ToString(); lbTagline.Text = dr["Tagline"].ToString(); } else { lbHeadline.Text = "No Stories"; lbBy.Visible = false; lbDashes.Visible = false; } }
public static bool SaveEditMyContent(MyContent model) { using (var entity = new BusEntities()) { var obj = entity.MyContent.FirstOrDefault(x => x.ID == model.ID); if (obj != null) { obj.action = model.action; obj.Title = model.Title; obj.Thumb = model.Thumb; obj.SubContent = model.SubContent; obj.LinkUrl = model.LinkUrl; obj.Contents = model.Contents; return(entity.SaveChanges() > 0); } return(false); } }
private void SetAsEditor() { int id; MyContent content = new MyContent(appEnv.GetConnection()); Account account = new Account(appEnv.GetConnection()); DataRow dr = dt.Rows[0]; content.SetEditor(Convert.ToInt32(dr["ContentID"]), Convert.ToInt32(dr["Version"]), (id = account.GetAccountID(User.Identity.Name))); dt = new MyContent(appEnv.GetConnection()).GetContentForID(Convert.ToInt32(dr["ContentID"])); // Only one person can edit a piece of content if (id != Convert.ToInt32(dt.Rows[0]["Editor"])) { Page_Error("<h3>Too Slow!!</h3>Someone is editing this already"); } }
async void Rotate_Clicked(object sender, EventArgs e) { if (_collapsed) { await Task.WhenAll(new List <Task> { MyContent.LayoutTo(new Rectangle(MyContent.Bounds.X, MyContent.Bounds.Y, MyContent.Bounds.Width, 300), 500, Easing.CubicOut), MyButton.RotateTo(180, 500, Easing.SpringOut) }); _collapsed = false; } else { await Task.WhenAll(new List <Task> { MyContent.LayoutTo(new Rectangle(MyContent.Bounds.X, MyContent.Bounds.Y, MyContent.Bounds.Width, 0), 500, Easing.CubicIn), MyButton.RotateTo(360, 500, Easing.SpringOut) }); MyButton.Rotation = 0; _collapsed = true; } }
protected void BecomeDead() { MyContainer.Tell(new ContainerNotify($"{Name} has died!", Self)); Self.Tell(new Notify($"You have died!")); Sender.Tell(new Died()); HP = 0; IsAlive = false; var corpse = Context.System.ActorOf(Props.Create(() => new Corpse($"Corpse of {Name}"))); corpse.Tell(new SetContainer(MyContainer)); MyContent.TellAll(new SetContainer(MyContainer)); //remove self from container MyContainer.Tell(new ContainerRemove(Self)); Context.Stop(Self); //Become(() => //{ // Ambient(); // Dead(); //}); }
public ActionResult PostContent(MyContent newContent) { using (var db = new ATinformContainer()) { try { newContent.content.PostedDate = DateTime.Now; string curUser = User.Identity.GetUserId(); newContent.content.AtUser = db.AtUserSet.Where(elm => elm.AspNetID == curUser).First(); newContent.content.Group = db.GroupSet.Find(newContent.groupId); var sanitizer = new HtmlSanitizer(); newContent.content.Text = sanitizer.Sanitize(newContent.content.Text); db.ContentSet.Add(newContent.content); db.SaveChanges(); foreach (var file in newContent.Uploads) { if (file != null) { var newFile = new Attachment { FileName = Path.GetFileName(file.FileName), FilePath = "~/FileBase/", Content = newContent.content }; var path = Path.Combine(Server.MapPath(newFile.FilePath), newFile.FileName); int count = 1; string fileNameOnly = Path.GetFileNameWithoutExtension(path); string extension = Path.GetExtension(path); while (System.IO.File.Exists(path)) { string tempFileName = string.Format("{0}({1})", fileNameOnly, count++); newFile.FileName = tempFileName + extension; path = Path.Combine(Server.MapPath(newFile.FilePath), newFile.FileName); } file.SaveAs(path); db.AttachmentSet.Add(newFile); } } db.SaveChanges(); } catch { } int id = newContent.content.Group.Id; return(RedirectToAction("/SelectedCourse/" + id)); } }
protected void Page_Load(object sender, System.EventArgs e) { cid = Convert.ToInt32(Request.QueryString["ID"]); ver = Convert.ToInt32(Request.QueryString["Ver"]); if (cid == 0) { Page_Error("ContentID Missing"); } if (ver == 0) { Page_Error("Version Missing"); } content = new MyContent(appEnv.GetConnection()); dr = content.GetContentForIDVer(cid, ver); lbWhichHeadline.Text = dr["Headline"].ToString(); lbWhichBody.Text = dr["Body"].ToString(); }
private void BuildBody() { Distribution dist = new Distribution(appEnv.GetConnection()); DataTable dtd = dist.GetOrdered(ZoneID); int contentid = 0; int version = 0; if (dtd.Rows.Count > 0) { contentid = Convert.ToInt32(dtd.Rows[0]["ContentID"]); version = Convert.ToInt32(dtd.Rows[0]["Version"]); } MyContent content = new MyContent(appEnv.GetConnection()); DataRow dr = content.GetContentForIDVer(contentid, version); if (dr != null) { lbHeadline.Text = dr["Headline"].ToString(); lbSource.Text = dr["Source"].ToString().Trim(); lbByline.Text = property.GetValue(Convert.ToInt32(dr["Byline"]), "UserName").Trim(); lbTeaser.Text = dr["Teaser"].ToString().Trim(); hlReadMore.NavigateUrl = "StoryPg.aspx?ID=" + contentid + "&Ver=" + version; hlReadMore.Visible = true; lbBy.Visible = true; imgPlus.Visible = true; } else { lbHeadline.Text = "No Stories"; lbSource.Text = ""; lbByline.Text = ""; lbTeaser.Text = ""; hlReadMore.Visible = false; lbBy.Visible = false; imgPlus.Visible = false; } }
protected void Page_Load(object sender, System.EventArgs e) { if (IsPostBack) { Page.Validate(); if (Page.IsValid) { try { MyContent content = new MyContent(appEnv.GetConnection()); Account account = new Account(appEnv.GetConnection()); content.Insert(tbHeadline.Text, tbSource.Text, account.GetAccountID(User.Identity.Name), tbTeaser.Text, tbBody.Text, tbTagline.Text); } catch (Exception err) { Page_Error("The following error occured: " + err.Message); } Response.Redirect("AutList.aspx"); } } }
protected void Page_Load(object sender, System.EventArgs e) { account = new Account(appEnv.GetConnection()); content = new MyContent(appEnv.GetConnection()); notes = new ContentNotes(appEnv.GetConnection()); DataTable dt; int accountNo = account.GetAccountID(User.Identity.Name); if (accountNo == 1) // Admin sees all { dt = content.GetHeadlines(); } else { dt = content.GetHeadlinesForAuth(accountNo); } LiteralControl lit; TableCell cell; int prv = -1; int cur; foreach (DataRow dr in dt.Rows) { cur = Convert.ToInt32(dr["ContentID"]); if (cur != prv) { prv = cur; if (IsTypeRequested(dr["Status"].ToString())) { TableRow row = new TableRow(); tblView.Rows.Add(row); lit = new LiteralControl(dr["ContentID"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); cell.HorizontalAlign = HorizontalAlign.Center; row.Cells.Add(cell); lit = new LiteralControl(dr["Version"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); cell.HorizontalAlign = HorizontalAlign.Center; row.Cells.Add(cell); lit = new LiteralControl(dr["Headline"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); row.Cells.Add(cell); lit = new LiteralControl(StatusCodes.ToString( Convert.ToInt32(dr["Status"]))); cell = new TableCell(); cell.Font.Size = new FontUnit(FontSize.XSmall); cell.HorizontalAlign = HorizontalAlign.Center; cell.Controls.Add(lit); row.Cells.Add(cell); BuildImageButton(row, "AutView.aspx?ContentID=" + dr["ContentID"].ToString(), -1); BuildImageButton(row, "../Note/NoteList.aspx?ContentID=" + dr["ContentID"].ToString() + "&Origin=Author", notes.CountNotesForID(Convert.ToInt32(dr["ContentID"]))); if (StatusCodes.isCreating(dr["Status"].ToString())) { BuildImageButton(row, "AutUpdate.aspx?ContentID=" + dr["ContentID"].ToString(), -1); BuildImageButton(row, "AutSubmit.aspx?ContentID=" + dr["ContentID"].ToString(), -1); BuildImageButton(row, "AutRemove.aspx?ContentID=" + dr["ContentID"].ToString(), -1); } else { BuildImageButton(row, null, -1); BuildImageButton(row, null, -1); BuildImageButton(row, null, -1); } } } } }
public async void SavesOnlyAutoGeneratedFields() { var contentTypeId = "amet"; var propertyDefinitions = new List <PropertyDefinitionDescriptor> { new PropertyDefinitionDescriptor(nameof(MyContent.Generated), typeof(string), c => ((MyContent)c).Generated, (c, v) => ((MyContent)c).Generated = (string)v, typeof(MyContent).GetProperty(nameof(MyContent.Generated)).GetCustomAttributes()), new PropertyDefinitionDescriptor(nameof(MyContent.NotGenerated), typeof(string), c => ((MyContent)c).NotGenerated, (c, v) => ((MyContent)c).NotGenerated = (string)v, typeof(MyContent).GetProperty(nameof(MyContent.NotGenerated)).GetCustomAttributes()), }; var propertyDefinitionProvider = Mock.Of <IPropertyDefinitionProvider>(); Mock.Get(propertyDefinitionProvider).Setup(p => p.GetFor(contentTypeId)).Returns(propertyDefinitions); var contentType = new ContentTypeDescriptor(contentTypeId, typeof(MyContent)); var contentTypeRepository = Mock.Of <IContentTypeProvider>(); Mock.Get(contentTypeRepository).Setup(r => r.Get(contentTypeId)).Returns(contentType); var id = new string[] { "lorem" }; var a = new MyContent { KeyValues = id, Generated = "ipsum", NotGenerated = "dolor", }; var b = new MyContent { KeyValues = id, Generated = "sit", NotGenerated = null, }; var body = new SaveContentController.SaveContentRequestBody { KeyValues = id, ContentTypeId = contentTypeId, Content = JsonConvert.SerializeObject(b), }; var containerSpecificContentUpdater = Mock.Of <IContentUpdater>(); Mock.Get(containerSpecificContentUpdater).Setup(u => u.UpdateAsync(It.IsAny <MyContent>())).Callback <object, string>((content, _) => { Assert.Equal(b.Generated, ((MyContent)content).Generated); Assert.Equal(a.NotGenerated, ((MyContent)content).NotGenerated); }); var contentGetter = Mock.Of <IContentGetter>(); Mock.Get(contentGetter).Setup(g => g.GetAsync <MyContent>(id)).Returns(Task.FromResult(a)); var contentTypeCoreInterfaceProvider = Mock.Of <IContentTypeCoreInterfaceProvider>(); var formProvider = Mock.Of <IPolymorphicCandidateProvider>(); Mock.Get(formProvider).Setup(p => p.GetAll()).Returns(new List <PolymorphicCandidateDescriptor> { }); await new SaveContentController(contentTypeRepository, null, null, contentGetter, contentTypeCoreInterfaceProvider, propertyDefinitionProvider, containerSpecificContentUpdater, null, new PolymorphicFormConverter(Mock.Of <ILogger <PolymorphicFormConverter> >(), formProvider, Mock.Of <IHumanizer>())).SaveContent(body); Mock.Get(containerSpecificContentUpdater).Verify(u => u.UpdateAsync(It.IsAny <MyContent>())); }
protected virtual void Ambient() { Random rnd = new Random(GetHashCode()); //api //TODO: name should probably be refactored to contain aliases too, so a list instead of a single name Receive <GetName>(msg => Sender.Tell(Name)); //container commands Receive <SetContainer>(msg => { MyContainer?.Tell(new ContainerRemove(Self), Sender); //TODO: this can be racy MyContainer = msg.Container; MyContainer.Tell(new ContainerAdd(Self), Sender); }); //add an item to the container, notify others in the same container Receive <ContainerAdd>(msg => { NotifyObjectAppears(msg.ObjectToAdd, Self, Sender); MyContent.Add(msg.ObjectToAdd); }); //remove from container, notify others in the same container Receive <ContainerRemove>(msg => { MyContent.Remove(msg.ObjectToRemove); var sender = Sender; msg .ObjectToRemove .GetName() .ContinueWith(t => new ContainerNotify($"{t.Result} disappears", msg.ObjectToRemove, sender)) .PipeTo(Self); }); //aggregate names of content and notify sender Receive <ContainerLook>(msg => { MyContent.Except(msg.Who) .GetNames() .ContinueWith(t => new Notify($"You see {t.Result}")) .PipeTo(msg.Who); }); //get name of the one that talks, notify all others Receive <ContainerSay>(msg => { msg .Who .GetName() .ContinueWith(t => new ContainerNotify($"{t.Result} says: {msg.Message}", msg.Who)) .PipeTo(Self); }); //broadcast notification to everyone in this container Receive <ContainerNotify>(msg => ContainerNotify(msg, MyContent)); Receive <FindObjectByName>(msg => FindObjectByName(msg, Sender, MyContent)); //actions Receive <Say>(msg => Say(msg, Self, MyContainer)); Receive <Look>(msg => Look(Self, MyContainer)); Receive <Where>(msg => Where(Self, MyContainer)); Receive <Take>(msg => Take(msg, Self, MyContainer)); Receive <Drop>(msg => Drop(msg, Self, MyContainer)); Receive <Put>(msg => Put(msg, Self, MyContainer)); //output stream Receive <Notify>(msg => Output?.Tell(msg)); Receive <SetOutput>(msg => Output = msg.Output); Receive <StartFight>(msg => { StartFight(msg, Name, Self, MyContainer); }); Receive <SetTarget>(msg => { Target = msg.Target; AttackTimer?.Cancel(); AttackTimer = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), Self, new Attack(), Self); }); Receive <Attack>(msg => { var dmg = rnd.Next(1, 10); Target.Tell(new TakeDamage(dmg)); Target .GetName() .ContinueWith(t => new Notify($"You swing at {t.Result}!")) .PipeTo(Self); }); Receive <TakeDamage>(msg => { ProcessDamage(msg); }); Receive <NotifyCombatStatus>(msg => { NotifyCombatStatus(); }); Receive <Died>(msg => { if (Sender == Target) { AttackTimer?.Cancel(); } }); }
public static void ShowProperties(MyContent.WriteToArguments a) { a.Name.PropertyToConsole(a.Value).ToConsole(); }
public MainPage() { this.InitializeComponent(); MyContent.Navigate(typeof(Sales)); SqlUtil.LoadDatabase(); }
private void ParseParameter(Stream stream, Encoding encoding) { this.Success = false; // Read the stream into a byte array byte[] data = ToByteArray(stream); // Copy to a string for header parsing string content = encoding.GetString(data); // The first line should contain the delimiter int delimiterEndIndex = content.IndexOf("\r\n"); if (delimiterEndIndex > -1) { string delimiter = content.Substring(0, content.IndexOf("\r\n")); string[] splitContents = content.Split(new[] { delimiter }, StringSplitOptions.RemoveEmptyEntries); foreach (string t in splitContents) { // Look for Content-Type Regex contentTypeRegex = new Regex(@"(?<=Content\-Type:)(.*?)(?=\r\n\r\n)"); Match contentTypeMatch = contentTypeRegex.Match(t); // Look for name of parameter Regex re = new Regex(@"(?<=name\=\"")(.*)"); Match name = re.Match(t); // Look for filename re = new Regex(@"(?<=filename\=\"")(.*?)(?=\"")"); Match filenameMatch = re.Match(t); // Did we find the required values? if (name.Success || filenameMatch.Success) { // Set properties //this.ContentType = name.Value.Trim(); int startIndex; if (filenameMatch.Success) { this.Filename = filenameMatch.Value.Trim(); } if (contentTypeMatch.Success) { // Get the start & end indexes of the file contents startIndex = contentTypeMatch.Index + contentTypeMatch.Length + "\r\n\r\n".Length; } else { startIndex = name.Index + name.Length + "\r\n\r\n".Length; } //byte[] delimiterBytes = encoding.GetBytes("\r\n" + delimiter); //int endIndex = IndexOf(data, delimiterBytes, startIndex); //int contentLength = t.Length - startIndex; string propertyData = t.Substring(startIndex - 1, t.Length - startIndex); // Extract the file contents from the byte array //byte[] paramData = new byte[contentLength]; //Buffer.BlockCopy(data, startIndex, paramData, 0, contentLength); MyContent myContent = new MyContent(); myContent.Data = encoding.GetBytes(propertyData); myContent.StringData = propertyData; myContent.PropertyName = name.Value.Trim(); if (MyContents == null) { MyContents = new List <MyContent>(); } MyContents.Add(myContent); this.Success = true; } } } }
protected void Page_Load(object sender, System.EventArgs e) { zone = new Zone(appEnv.GetConnection()); dist = new Distribution(appEnv.GetConnection()); content = new MyContent(appEnv.GetConnection()); LiteralControl lit; TableCell cell; DropDownList ddlRank; DataTable AllRanks = null; string inZone = Request.QueryString["Zone"]; DataTable dtz = zone.GetAllZones(); DataTable dt = content.GetHeadlines(); if (dt.Rows.Count > 0) { int prv = -1; int cur; foreach (DataRow dr in dt.Rows) { cur = Convert.ToInt32(dr["ContentID"]); if (cur != prv) { prv = cur; if (StatusCodes.isApproved(dr["Status"].ToString())) { TableRow row = new TableRow(); tblNewContent.Rows.Add(row); lit = new LiteralControl(dr["Headline"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); row.Cells.Add(cell); BuildImageButton(row, "DeployView.aspx?ID=" + dr["ContentID"] + "&Ver=" + dr["Version"]); BuildImageButton(row, "DeployDeploy.aspx?ID=" + dr["ContentID"] + "&Ver=" + dr["Version"]); BuildImageButton(row, "DeployReturn.aspx?ID=" + dr["ContentID"] + "&Ver=" + dr["Version"]); } } } } if (!IsPostBack) { if (inZone == null) { inZone = "None"; } ListItem item; ddlZones.Items.Add(new ListItem("None")); ddlZones.Items.Add(item = new ListItem("All")); if (inZone.Equals("All")) { item.Selected = true; } foreach (DataRow dr in dtz.Rows) { ddlZones.Items.Add(item = new ListItem(dr["Title"].ToString())); if (dr["Title"].ToString().Trim().Equals(inZone)) { item.Selected = true; } } } // else // { foreach (DataRow dr in dtz.Rows) { DataTable dtd = dist.GetOrdered(Convert.ToInt32(dr["ZoneID"])); if (ddlZones.SelectedItem.Text.Equals("All") || ddlZones.SelectedItem.Text.Equals(dr["Title"])) { if (dtd.Rows.Count == 0) { TableRow row = new TableRow(); tblSiteContent.Rows.Add(row); lit = new LiteralControl(dr["Title"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); row.Cells.Add(cell); lit = new LiteralControl("No Content"); cell = new TableCell(); cell.ColumnSpan = 4; cell.Controls.Add(lit); row.Cells.Add(cell); } foreach (DataRow drd in dtd.Rows) { TableRow row = new TableRow(); tblSiteContent.Rows.Add(row); lit = new LiteralControl(dr["Title"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); row.Cells.Add(cell); DataRow drc = content.GetContentForIDVer(Convert.ToInt32(drd["ContentID"]), Convert.ToInt32(drd["Version"])); lit = new LiteralControl(drc["Headline"].ToString()); cell = new TableCell(); cell.Controls.Add(lit); row.Cells.Add(cell); if (AllRanks == null) { AllRanks = new ContentRank(appEnv.GetConnection()).GetRanks(); } cell = new TableCell(); ddlRank = new DropDownList(); foreach (DataRow drr in AllRanks.Rows) { ddlRank.Items.Add(new ListItem(drr["Rank"].ToString(), drr["RankID"].ToString())); } ddlRank.Items.FindByValue(drd["Ranking"].ToString()).Selected = true; cell.Controls.Add(ddlRank); row.Cells.Add(cell); BuildImageButton(row, "DeployView.aspx?ID=" + drd["ContentID"] + "&Ver=" + drd["Version"]); BuildImageButton(row, "DeployArchive.aspx?ID=" + drd["ContentID"] + "&Ver=" + drd["Version"]); } } } // } }