You are here

Feed aggregator

Small Basic Turtle Object - 5 Practice Exercises!

MSDN Blogs - 1 hour 32 min ago

Here are five Practice Exercises for the Small Basic Turtle Object!

 

1. Write a program that draws the pattern below. (Hint: draw one flag and then rotate it 10 times.)


 
2. First write a program where your turtle draws the house in the left figure below. You can create the pattern in the right figure by rotating this house 12 times. Write a program to create the pattern, and then check your answer.


 

3. Write a program to draw a flower pot like this one:

 

4. The next figure (left) shows a code snippet for drawing a circle. Write a program to have the turtle repeat this code 12 times to create the pattern on the right.

 

 

5. Recreate the code below and experiment with it. Change the move distance after rotating each circle to discover new patterns!

 

Azure Resource Manager – Adding and Assigning Certificates to a Website

MSDN Blogs - 1 hour 34 min ago
Overview

This post is going to cover working with Azure Resource Manager using the REST interfaces [1] and specifically the “Microsoft.Web/sites” and “Microsoft.Web/certificates” providers.

You can review the list of Resource Providers by issuing an authenticated REST call to the Uri below, replacing {subscriptionId} with your tenant id.

https://management.azure.com/subscriptions/{subscriptionId}/providers?api-version=2015-0101 [2]

For this sample, I’m going to make use of the Active Directory Authentication Library for .NET – primarily to make the REST calls for acquiring an Access Token [3]. You don’t have to use these libraries, but for this sample and to abbreviate the token dance with AAD, I’m using them.

It’s important to note that Certificates are now part of the Resource Group itself, and can be assigned to multiple web sites within that Resource Group.

Basic Steps

The basic steps for adding a certificate and assigning it to an Azure Website are as follows.

Note: All of these preparation steps can be done via script or REST calls as well; this sample is just demonstrating certificate upload and assignment to an existing Azure Web Site that already has DNS names (custom) assigned to them. You will also incur additional charges for the custom domain and SSL as warned during the portal method – you will not see warnings via code. Please review pricing information to understand the impact.

Preparation

1. Using an AAD credential that is part of the AAD Domain that the Resource Group is part of – for this example, I add a credential for the AAD user store.

2. Creation of an Application in the AAD Domain for the Resource Group

3. Assigning permissions to the credential for the Resource Group via RBAC

4. Have a Web site running already with custom DNS names already assigned; this will be in a Resource Group that is protected by Role Based Access Control (RBAC)

5. Creation of a SSL Certificate – for this I used ‘makecert.exe’ and created a wildcard certificate

Uploading and Assigning Certificate

6. Make a call to the /certificates resource provider to ‘ADD (PUT)’ a new Certificate to the Resource Group

7. Make a call to the /sites resource provider to ‘Update (PUT)’ the assignment of the cer5iridate to the DNS name

And that’s it. So, for steps 1 – 5, let’s review some of the setup steps:

1. Adding an AAD Credential for this sample – since we’re going to use Username / Password authentication to acquire a token, I’ll need the Password. This will require an initial sign on. The easiest way to do this is once you create a user, just login via a private browser sessions with that credential to https://portal.azure.com or https://manage.windowsazure.com

2. Creation of an Application in your AAD domain – same one where the credential is.

1) Sign in to the Azure management portal https://manage.windowsazure.com.

2) Click on Active Directory in the left hand nav.

3) Click the directory tenant where you wish to register the sample application.

4) Click the Applications tab.

5) In the drawer, click Add.

6) Click "Add an application my organization is developing".

7) Enter a friendly name for the application, for example "AADDemoCertificates", select "Native Client Application", and click next.

8) For the sign-on URL, enter the base URL for the sample, you’ll need this for the sample later: https://localhost:8080/login

After done, we need to retrieve the ClientID; for that app:

9) In the Azure portal, click configure

10) Retrieve the ClientID and save it

3. Next, in the “New Portal” - https://portal.azure.com we need to assign the user permissions to the respective Resource Group

1) Click Browse

2) Find “Resource Groups”

3) Locate the Resource Group that the Azure Web Site is in that we will be assigning the certificate to.

4) In the “Blade” go to the bottom tile labeled “Access” and click on “Owner”

5) Another blade opens showing any existing Owners

6) Click on “+ Add”

7) You should see existing Users in the domain; find the User or enter the ‘user@domain’ in the Search box

8) Select that user, then click “Select” at the bottom of the blade – this will add that user to the group

4. Looking at your Web site in Azure – ensure and jot down:

a. Name of the Resource Group (should be same as above step)

b. Name of the Site

c. DNS names – add a custom DNS domain – see the Azure portal for instructions

i. This is under “Custom Domains and SSL” – you have to choose a “Basic” plan or higher for Custom Domains and SSL

5. For making a self-signed cert, these are the commands I used:

REM make the root makecert -n "CN=Development Test Authority" -cy authority -a sha1 -sv "DevelopmentTestAuthority.pvk" -r "DevelopmentTestAuthority.cer" REM makecert -n "CN=*.cicoriadev.net" -ic "DevelopmentTestAuthority.cer" -iv "DevelopmentTestAuthority.pvk" -a sha1 -sky exchange -pe -sv "wildcard.cicoriadevnet.pvk" "wildcard.cicoriadevnet.cer" makecert -n "CN=*.cicoriadev.net" -ic "DevelopmentTestAuthority.cer" -iv "DevelopmentTestAuthority.pvk" -a sha1 -sky exchange -pe -sv "wildcard.cicoriadevnet.pvk" "wildcard.cicoriadevnet.cer" pvk2pfx -pvk "wildcard.cicoriadevnet.pvk" -spc "wildcard.cicoriadevnet.cer" -pfx "wildcard.cicoriadevnet.pfx" -pi pass@word1 Sample Code

For the sample code, you’ll see a call via the AADL library to use a Username & Password for obtaining an AuthenticationResult object – which contains an AccessToken. Note that the resource URI that the token is generated for is https://management.azure.com/ .

Adding a Certificate via REST

The sample code makes use of JSON.NET and anonymous objects for creating the PUT HTTP request bodies. Here is what the shape of the PUT request looks like for ‘adding’ a certificate to a Resource Group.

Request PUT https://management.azure.com/subscriptions/{subscriptionId}/ resourceGroups/{resourceGroupName/providers/ Microsoft.Web/certificates/{resourceName}?api-version=2014-11-01 Content-Type: application/json Authorization: Bearer {accessToken} Content-Length: 3675 { "name": "{resourceName}", "type": "Microsoft.Web/certificates", "location": "{location}", "properties" : { "pfxBlob": {base64ByteArrayOfPfx}, "password": "pass@word1" } } Replacement Parameters

subscriptionId – this is the subscription that the Resource Group (and it’s web site) is contained within

resourceGroupName – this is the name of the resource group

resourceName – this is what the friendly name of the certificate WILL be – this is a PUT request, but the resourceName must be on the Uri in addition to the json request body – and they must match

accessToken – this is the token obtained from the AADL library call

location – for my sample, I used “East US” – which is the Azure Region. Note that not all Resource Providers are available or registered for your subscription in all regions. Review the response from the /providers REST call prior in this post to see what is available for each region, along with the ‘api-version’ that is supported.

base64ByteArrayOfPfx – this the pfx file in bytes, then converted to base64

password- this is the password of the pfx file that was used during pfx creation

Response

The HTTP Response code is a 200 – this a content body that dumps out the certificate information. I’ve abbreviated most of the response in the following. Make note of the thumbprint if you haven’t already as this is what the assignment will use, along with the Site name, to bind the SSL certificate to the web site.

{ "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates/{resourceName}", "name": "{resourceName}", "type": "Microsoft.Web/certificates", "location": "{location}", "properties": { "friendlyName": "", "subjectName": "*.cicoriadev.net", "hostNames": [ "*.cicoriadev.net" ], "pfxBlob": null, "siteName": null, "selfLink": null, "issuer": "Development Test Authority", "issueDate": "2015-01-27T22:34:57+00:00", "expirationDate": "2039-12-31T23:59:59+00:00", "thumbprint": "DEA5DED6142EDECCDF952F4D431ED772F01D22D1", } } Assigning a Certificate via REST

For the assignment, we make use of the Resource Manager “Microsoft.Web/sites”.

Request PUT https://management.azure.com/subscriptions/{subscriptionId}/ resourceGroups/{resourceGroupName/providers/ Microsoft.Web/sites/{resourceName}?api-version=2014-11-01 Content-Type: application/json Authorization: Bearer {accessToken} Content-Length: 567 { "name": "{resourceName}", "type": "Microsoft.Web/sites", "location": "{location}", "properties" : { "hostNameSslStates": [ { "name": "azw.cicoriadev.net", "sslState": 1, "thumbprint": "DEA5DED6142EDECCDF952F4D431ED772F01D22D1", "toUpdate": 1, } ] } } Replacement Parameters

subscriptionId – this is the subscription that the Resource Group (and it’s web site) is contained within

resourceGroupName – this is the name of the resource group

resourceName – this is what the friendly name of the certificate WILL be – this is a PUT request, but the resourceName must be on the Uri in addition to the json request body – and they must match

accessToken – this is the token obtained from the AADL library call

location – for my sample, I used “East US” – which is the Azure Region. Note that not all Resource Providers are available or registered for your subscription in all regions. Review the response from the /providers REST call prior in this post to see what is available for each region, along with the ‘api-version’ that is supported.

Thumbprint – this would be the thumbprint known for that certificate in Azure – again, it should always be the same locally, but if you have any issues assigning, this must match what Azure knows in /certificates.

Response

The Response should show you the chosen site DNS name with the thumbprint associated, similar to the following:

"hostNameSslStates": [ { "name": "azw.cicoriadev.net", "sslState": 1, "ipBasedSslResult": null, "virtualIP": null, "thumbprint": "DEA5DED6142EDECCDF952F4D431ED772F01D22D1", "toUpdate": null, "toUpdateIpBasedSsl": null, "ipBasedSslState": 0, "hostType": 0 },

 

 

Sample Solution and Source Code

The source code is located on github: http://bit.ly/azrmsamples - or direct https://github.com/cicorias/AzureResourceManagerSamples

[1] Azure Resource Manager REST API Reference https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx

[2] Listing All Resource Providers https://msdn.microsoft.com/en-us/library/azure/dn790524.aspx

[3] Active Directory Authentication Library for .NET – github https://github.com/AzureAD/azure-activedirectory-library-for-dotnet

Know it. Prove it. 28 days to rock your skills.

MSDN Blogs - 3 hours 37 min ago


Registration is open for Know it. Prove it., a month-long MVA learning challenge to accelerate your skills on the tech topic of your choice. Join the community, commit to the challenge, share your progress, and make February the month you perfect your tech chops. Earn badges and points as you compete in the learning challenges, while getting encouragement and accolades from your peers. Register: http://spr.ly/6186IgQQ

Small Basic: The History of the Logo Turtle

MSDN Blogs - 4 hours 43 min ago

Let’s take a look at where the Small Basic Turtle object came from!

 

Turtle graphics were based on turtle robots, which were used in programming. In 1948, Grey Walter created his first robots, named Elmer and Elsie. People often thought his robots looked and moved like tortoises.

http://media.tumblr.com/tumblr_m41ogptcSC1rpx08t.png

http://2.bp.blogspot.com/-Oxd4RRCuF5o/UY-KhgISNYI/AAAAAAAAAtc/HUWzGb9JjYU/s1600/historia-logo-turtle-01.jpg

 

Years later, in 1967, two MIT professors (in Cambridge, Massachusetts) invented their PDP 1 computer. Kids from schools connected to it from phone lines. Because they didn’t have monitors, they wanted the kids to see robotics as the result of the programming. That led to the return of the turtle! Only this turtle was more like R2D2:

http://media.tumblr.com/tumblr_m43bakRVSb1rpx08t.png

 

In order to program for this physical turtle, they created this concept of the display turtle as part of their Logo programming language: 

https://theantiroom.files.wordpress.com/2011/04/logo_turtle.jpg

 

(Logo comes from the Greek word, logos, which means “thought” or “word”, to differentiate that the language is based on words, graphics, and logic, and not just on numbers like most of the contemporary programming languages.)

 

Before long, most modern implementation of Turtle Graphics show the cursor as an actual turtle:

http://www.annehelmond.nl/wordpress/wp-content/uploads/2007/11/logo_mit.png

 

And that even extended to the turtle robots as well:

http://gallery.nen.gov.uk/assets/0802/0000/0121/ict_equipment21_mid.jpg

 

Similar to the Small Basic turtle, the Logo turtle included commands for relative movement and turning.

 

Here are the methods of the Turtle object in Small Basic:

  • Turtle.X - Gets or sets the X location of the turtle. Setting this property changes the turtle’s horizontal location instantly without leaving any trace or turning its head.
  • Turtle.Y - Gets or sets the Y location of the turtle. Setting this property changes its vertical location without leaving any trace or turning it direction.
  • Turtle.Angle - Gets or sets the angle of the turtle. Setting this property turns the turtle to the new angle.
  • Turtle.MoveTo(x, y) - Turns and moves the turtle to the new location. If the pen’s down, the turtle draws a line as it moves.
  • Turtle.Move(distance) - Moves your turtle a number of steps in its current direction. If the distance is negative, the turtle moves backwards. If the pen’s down, your turtle draws a line as it moves!
  • Turtle.Turn(angle) - Turns your turtle by an angle (in degrees) from its current direction. If the angle’s positive, the turtle turns to its right (clockwise). If the angle’s negative, your turtle turns to its left (counterclockwise).
  • Turtle.TurnRight() - Turns your turtle 90 degrees to its right.
  • Turtle.TurnLeft() - Turns the turtle 90 degrees to its left.

 

See Also:

 

Have a turtle-tastic day!

   - Ninja Ed

Inconsistency between quantity in purchase order and quantity in inventory transaction.

MSDN Blogs - 5 hours 47 min ago

The purchase order invoicing process has a functionality where the end user could identify a particular quantity which will be invoiced, and this could be controlled by the over/under deliver percentage on the purchase order line. The invoiced quantity in the purchase order invoice is linked to the item unit of measure, where the item inventory unit of measure could be different than the purchase unit of measure. For example a company stock specific item in Kilogram and purchase it from the vendor in Ton, in that sense the purchase invoice will be issued in tons, and the inventory will be added in kilogram and bear in mind that in some scenarios the inventory and purchase unit of measure are the same.

The unit of measures are defined on the item master, Product information management| Common| Released product, then press edit on a particular item record then go to Manage costs fast tab, as shown in the below screen shot the which illustrate the inventory base unit of measure.

In order identify the sales unit of measure move to Purchase fast tab

In a purchase order with quantity = 10 ea in a purchase line, the quantity here represented in the purchase unit of measure

The quantity of the purchase line which represents the purchase unit of measure will be reflected in the purchase order invoice, in addition to inventory unit of measure as well. The quantity in purchase unit of measure will be found under Lines details tab, Quantity filed. The quantity under update will be the base of the liability entry (Quantity * Purchase price).

The quantity in inventory unit of measure will be found under Product tab, Quantity filed.

 

If the user change the quantity in the quantity filed under the Line details tab, then the quantity under the Product tab will be changed as well, if the user change quantity under Product details the quantities under Line details tab will not change, in that said the changes mechanism only works in one way as mentioned.

 

If the second scenario of changes occurred where the user change quantities under Product tab, the system will keep the quantity under Line details tab as it represents the purchase unit of measure, which is acceptable if there is a slight differences in the purchase unit of measure and inventory unit of measure.

But if it is occurred without a business requirement this will lead to inconsistency between quantity in purchase order and quantity in inventory transaction.

The conclusion an issue may raise because of this mismatch, and in order to check the posted transactions, go to Accounts payable| Inquiry| Journals| Invoice journal then right click and press Record info, and press Show all fields.

The quantity in the left side represents quantity in purchase line, and quantity in right side represents the quantity updated in the inventory transactions.

The rationale behind it in case there is an item has two different unit of measure (Purchase & Inventory) and the user may want to change the quantity of which will be added to the inventory without changing the quantity in the purchase order, in the other hand if the item has the same unit of measure the quantities in the two fields should be identical, but if the user changes the quantities under line Product tab it will not change the quantities under Line details tab.  Please note that the same mechanism working in the Sales order side.

Item cost not updated after posting Purchase Order Invoice.

MSDN Blogs - 6 hours 44 min ago

In case of that you've go through the following symptom where the item cost is not updated as expected after posting Purchase Order Invoice, this occurred with the following scenario.

After creating the purchase order and confirming it with specific Financial Dimensions in the purchase order line, then change the Financial Dimension and re-confirm the purchase order.

Please note that the financial entry, is still consider the removed financial dimension

 

There is a hotfix have been released for this symptom in Microsoft Dynamics AX 2012 R3 RTM - KB2974637, there more information about this hotfix in Microsoft Dynamics Lifecycle Services - LCS under issue search.

"Note: The hotfix will correct the future of the system behavior, and will not correct the historical transaction. It should be corrected from application transaction whether "inventory adjustment for on-hand quantity, or transaction adjustment" 

 

 

 

 

   

博客园客户端(Universal App)开发随笔 - Setting Page的实现方法与经验

MSDN Blogs - 6 hours 52 min ago
前言

几乎所有的移动 App 都会为用户提供一个设置页面(Setting Page 或 Preference Page),来满足大家对于一个 App 众口难调的需求。虽然有一种说法表示,最好的 App 不需要设置,一切默认呈现给用户的就是最好的选择。但是对于大多数开发人员来说,这样的境界不是可以简单达到的;而且对于部分“设置控”用户来说,没有设置页面怎么看都觉得少了些什么。所以对于大部分 App 来说,设置页面还是一个必备品。

本文将分别介绍 Windows 和 Windows Phone 的设置页面的界面设计,最后介绍他们后台的统一实现与数据保存。

  Windows App 的Setting界面设计

在 Windows App 中,设置页面的入口被统一在了 charm bar 中,手指从触摸屏右侧滑入或鼠标从屏幕右下角向下滑动都可以调出 charm bar,然后进入默认的设置页面。

开发中的默认的设置页面只有 Permissions (权限)一项,发布在市场后会自动添加 Rate and Review (评分)这一项,所以不必自己实现,但是在Windows Phone中需要自己实现。

对于一个一般的 App 来说,可以在设置页面添加如下几项:

  • 选项 / 偏好 (Option / Preference)
  • 关于(About)
  • 隐私声明(Privacy Statement)(如果 App 使用了网络权限,则这一项必选)

 

选项 / 偏好 (Option / Preference)

以博客园应用下一版即将加入的阅读模式为例。我们希望在选项中新增阅读模式的设置,具体实现方式为在 App 的设置中增加选项一栏,点击后跳转到选项页面,并进行相应设置。

首先我们在 Universal App 中添加一个 Setting Flyout 页面:

在XAML部分,我们加入简单的说明与一个 ToggleButton。

<StackPanel Style="{StaticResource SettingsFlyoutSectionStyle}"> <TextBlock Text="阅读设置" Style="{StaticResource TitleTextBlockStyle}"/> <TextBlock Margin="0,0,0,10" Text="在阅读设置部分,可以进行所有和阅读相关的设置" Style="{StaticResource BodyTextBlockStyle}"/> <ToggleSwitch Margin="-6,0,0,0" x:Name="ReadingModeToggle" Header = "阅读模式" HorizontalAlignment="Left" HorizontalContentAlignment="Left" OffContent="日间模式" OnContent="夜间模式" Toggled="ReadingModeToggle_Toggled"/> </StackPanel>

这样就实现了一个最简单的 SettingFlyout 页面。那么如何在 App 中调出这个页面呢?我们在App.xaml.cs文件中添加如下代码:

#if WINDOWS_APP using Windows.UI.ApplicationSettings; #endif

并在 OnLaunched 方法内添加:

#if WINDOWS_APP SettingsPane.GetForCurrentView().CommandsRequested += (s, args) => { Add an About command to the settings pane var preference = new SettingsCommand("设置", "设置", (handler) => new PreferenceSettingsFlyout().Show()); args.Request.ApplicationCommands.Add(preference); }; #endif

这样,打开应用时,在右侧的 Setting Pane 中就增加了我们的选项一栏,并可以打开进行设置。

具体设置的后台实现,可以通过 Toggled="ReadingModeToggle_Toggled" 调用后台的具体方法实现。这一部分的有关内容将在后文提到。

关于(About)

关于(About)页面可以放置 App 相关的介绍与作者联系方式等信息,具体的实现与选项 / 偏好 (Option / Preference) 页面相似,此处不再赘述。

隐私声明(Privacy Statement)

这一项比较特殊,凡是申请了网络权限,包括 internetClient,internetClientServer 和 privateNetworkClientServer 权限的 App,都必须提供隐私声明。开发者可以在自己的网站或博客建立一个专门的页面用来放置应用的隐私声明,并在设置栏中提供一个转向的入口,这样才能确保 App 在提交时通过审核。

由于只需要跳转的链接,所以隐私声明的实现比较简单。首先在 App.xaml.cs 的 OnLaunched 方法内添加:

#if WINDOWS_APP var privacy = new SettingsCommand("隐私声明", "隐私声明", GetPrivacyPolicyAsync); args.Request.ApplicationCommands.Add(privacy); #endif

提供隐私声明的入口,并在 App.xaml.cs 中添加以下方法:

#if WINDOWS_APP private async void GetPrivacyPolicyAsync(Windows.UI.Popups.IUICommand command) { await Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.microsoft.com/privacystatement/zh-cn/core/default.aspx")); } #endif

即可以实现。其中的 URL 请替换为适合 App 本身的隐私声明地址。

 

Windows Phone App的Setting界面设计

Windows Phone App 与 Windows App 在设置界面方面有两点不同:

1. Windows Phone 没有提供统一的设置入口。

2. Windows Phone App 不需要强制提供隐私声明。

因此,开发者需要自己为设置界面提供入口和界面页面。以博客园 UAP 的 Windows Phone 版举例,首先我们在项目中添加 SettingPage.xaml。

博客园的设置页面实现使用了 Pivot,好处是可以在一个页面同时实现“选项”与“关于”两项内容,并且将来可以很方便地添加新的子项。

<Pivot x:Name="pivot_Main" SelectionChanged="Pivot_SelectionChanged"> <PivotItem Margin="0" Tag="setting"> <PivotItem.Header> <TextBlock Style="{StaticResource PivotTitleFont}" Text="设置" /> </PivotItem.Header> <StackPanel Orientation="Vertical" Margin="20"> <ToggleSwitch Header="博客标题/摘要" OffContent="只显示标题" OnContent="显示标题和摘要" IsOn="{Binding DefaultDisplaySummary, Mode=TwoWay}"/> <TextBlock Text="(刷新生效)" Foreground="{ThemeResource CNBlogsAttributionColor}" FontSize="14" Margin="0,-5,0,10"/> <ToggleSwitch Header="点击博客标题时" OffContent="阅读正文" OnContent="显示/隐藏摘要" IsOn="{Binding ClickTitleForSummary, Mode=TwoWay}"/> <TextBlock Text="(刷新生效)" Foreground="{ThemeResource CNBlogsAttributionColor}" FontSize="14" Margin="0,-5,0,10"/> </StackPanel> </PivotItem> <PivotItem Margin="0" Tag="about"> <PivotItem.Header> <TextBlock Style="{StaticResource PivotTitleFont}" Text="关于" /> </PivotItem.Header> <StackPanel Margin="20" HorizontalAlignment="Center"> <Image x:Name="image_Logo" Height="100" Margin="0,20" Source="ms-appx:///Assets/Logo.100.Blue.png" Opacity="0"> <Image.Projection> <PlaneProjection /> </Image.Projection> </Image> <StackPanel x:Name="sp_aboutContent" Opacity="0"> <TextBlock Margin="0,10" HorizontalAlignment="Center" Style="{StaticResource SettingPageTextHeader}" Text="博客园" /> <TextBlock Margin="0,10" HorizontalAlignment="Center" Style="{StaticResource SettingPageTextHeader}" Text="Windows Phone 客户端" /> <TextBlock HorizontalAlignment="Center" FontSize="14" Style="{StaticResource SettingPageTextHeader}" Text="Powered By Microsoft" /> <TextBlock x:Name="tbkVersion" Text="1.0" HorizontalAlignment="Center" FontSize="14" Style="{StaticResource SettingPageTextHeader}"/> <HyperlinkButton x:Name="btn_RateMe" Margin="0,40,0,10" Content="给个好评" Style="{StaticResource SettingPageHyperlinkButtonText}" HorizontalAlignment="Center" Click="btn_RateMe_Click"/> <TextBlock Margin="30" FontSize="14" FontFamily="Segoe WP" TextWrapping="Wrap" Foreground="{ThemeResource CNBlogsSummaryColor}"> <Run Text="本应用为Universal App的示例应用,使用WindowsRT SDK开发,支持Windows Phone 8.1。"/> <Run Text="还有一个同名应用同时发布在Windows 8.1上,两者共用一套底层代码。"/> </TextBlock> </StackPanel> </StackPanel> </PivotItem> </Pivot>

通过以上代码框架实现设置和关于页面的内容填充,即可实现简单的设置页面效果。

在“关于”页面中的那个“给个好评”,必须自己实现,两行代码搞定:

? 1 2 var uri = new Uri(string.Format("ms-windows-store:navigate?appid={0}", urrentApp.AppId)); await Windows.System.Launcher.LaunchUriAsync(uri);

 上面的那个版本号,也可以用code从Package.appxmanifest中的这里读取:

? 1 <Identity Name="36385XiaowuHu.100280B26F648" Publisher="CN=60BC9EB8-6EF8-44C4-817C-FCE25D428B9B" Version="1.<span style="color: rgb(255, 102, 0);">0.0.18</span>" />

 

在博客园 Universal App 中,Windows Phone 版的设置页面的入口是 BottomAppBar 中定义的

<AppBarButton x:Name="btn_Setting" Label="设置" Icon="Setting" Click="btn_Setting_Click"/>

按钮提供的。这也是大多数 Windows Phone App 的设置页面的入口。

 

除了 AppBarButton 以外,我们还可以通过更快捷的方式直接进入设置的具体页面。例如我们在 BottomAppBar 中添加

<CommandBar.SecondaryCommands> <AppBarButton x:Name="btnAbout" Label="关于本应用" Click="btnAbout_Click" /> </CommandBar.SecondaryCommands>

并在后台实现点击事件对应的方法:

private void btnLogon_Click(object sender, RoutedEventArgs e) { this.Frame.Navigate(typeof(SettingsPage), new DataModel.SettingNavigationParameter() { targetPivot = TargetPivotItemName.About, targetCss = 0 }); }

即可直接跳转到对应的关于页面。这样除了统一的设置入口以外,在不同页面添加适应不同页面的不同快捷入口,使得用户可以根据当前页面快速找到对应设置选项。这是一个非常好的实践经验和用户体验,即,在不同上下文时提供不同的设置入口,比如在Reading Page,可以提供“设置字号”菜单进入Setting Page;在Write Comment Page可以提供“登录”菜单进入Setting Page。

设置页面的后台实现与数据保存

所有设置页面的操作,例如对 ToggleButton 的拖动,对 Button 的点击等等,都可以通过填写控件本身提供的事件方法来进行相应的操作,此处就不再赘述。那么当用户进行设置以后,如何保存用户的设置,使得用户每次打开 App 都应用上次保存的设置内容呢?

在 App 中常用的保存数据有 XML 序列化和保存 Setting 字段两种方式,前者主要适用于保存结构化的数据,对于简单的设置数据的保存,我们在博客园应用中使用了后者。

我们在 CNBlogs.DataHelper.DataModel 的命名空间下添加 Setting.cs 用于定义各设置数据。以夜间模式举例,在此类中添加如下定义:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Windows.Storage; namespace CNBlogs.DataHelper.DataModel { public sealed class CNBlogSettings : DataModelBase { private ApplicationDataContainer settings = Windows.Storage.ApplicationData.Current.LocalSettings; const string SettingKey_NightModeTheme = "cnblog_night_mode_theme"; public bool NightModeTheme { get { var obj = this.settings.Values[SettingKey_NightModeTheme]; return obj == null ? false : (bool)obj; } set { this.settings.Values[SettingKey_NightModeTheme] = value; base.OnPropertyChanged("NightModeTheme"); } } } }

就实现了简单的 NightModeTheme 字段的本地保存。为了保持一致性,还可以将 Setting 类设计为单例模式。

这样,在 ToggleButton 提供的事件方法中,我们可以对 NightModeTheme 字段进行修改,Setting 类会负责读取与保存该字段的内容。

当然,可不可以不通过 C# 代码也能实现对 Setting 字段的修改呢?当然可以。XAML 的数据绑定为此提供了更优雅的解决方案。我们只需要在夜间模式对应的 ToggleButton 中的XAML定义中添加 IsOn="{Binding NightModeTheme, Mode=TwoWay}" 这么一个属性,就可以绑定 ToggleButton 的状态与 Setting 类中 NightModeTheme 的值了。当然,根据 NightModeTheme 的值来进行怎样的操作,如提供夜间模式变换主题状态等操作,还是需要后台代码实现的。

总结

本文介绍对 Windows App 和 Windows Phone App 设置界面的简单设计,并给出了后台代码和数据保存的基本实现。通过这些,Universal App 就可以拥有一个看起来像模像样的设置页面了。至于如何设计更加人性化,更加“高大上”的设计界面,就需要开发者们努力实现了。比如在我们的博客园客户端中的关于界面,实现了一个超出用户预期的小动画。欢迎交流。

 

你可以从这里下载我们分享的源代码:

https://code.msdn.microsoft.com/CNBlogs-Client-Universal-477943ab

当然更可以直接下载两个App来看效果,但是由于designer介入较晚,所以UI上面还需要完善,我们会持续更新App。

Windows Phone Store App link:

http://www.windowsphone.com/zh-cn/store/app/博客园-uap/500f08f0-5be8-4723-aff9-a397beee52fc

Windows Store App link:

http://apps.microsoft.com/windows/zh-cn/app/c76b99a0-9abd-4a4e-86f0-b29bfcc51059

纯粹干净的App, 里面绝无广告,请放心使用。

 分享代码,改变世界!

MSDN官方文档:

Quickstart: Add app settings (XAML)

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh872190.aspx

Guidelines for app settings

http://msdn.microsoft.com/en-us/library/windows/apps/hh770544.aspx

Adding app settings (XAML)

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh770543.aspx

App certification requirements for the Windows Store

http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx

Loading and saving settings

http://msdn.microsoft.com/en-us/library/windows/apps/dn263230.aspx

博客园客户端(Universal App)开发随笔 - UAP中的项目和目录组织

MSDN Blogs - 6 hours 54 min ago
前言

本篇随笔主要是分享一下做一个Universal App的目录组织结构,说明什么样的结构才能适合一个团队开发,使开发成员之间的相互影响最小。这些组织好的项目和目录会成为一个公共的规约,大家都能知道什么东西应该放在哪里,或者在什么地方能找到什么功能。这对于避免重复写code或者最大限度地复用code来说是至关重要的。

这种工程结构和目录划分虽然没有什么理论基础,但是是经过我们很多项目的经验总结出来的,如果是个人开发者,也严重建议参考此组织结构,能够帮助你理清思路,做好功能设计和类设计。

项目组织

开发一个Universal App, 如果前篇所说,基本框架在VS里有了(对不起我这里不小心装了个英文版),先选Universal Apps,再选Blank App,再把App1改成CNBlogs,就可以猛击OK了。

它缺省会帮你建立三个projects:CNBlogs.Windows(Windows 8.1)和CNBlogs.WindowsPhone(Windows Phone 8.1)。还有一个特殊的CNBLogs.Shared,扩展名为.shproj,是被上面两个project共用的。

如果做一个简单的UAP,这三个project就足够了。但是如果涉及到团队开发的较大的项目,还要有其它一些辅助的Project和其下面的一系列Folders才能够应付。如下图所示:

我们建立了以下辅助project:

1)BackgroundTask

2)DataHelper

3)NotificatoinsExtensions

说明如下:

1)BackgroundTask主要完成的任务是后台更新动态磁贴。这个以后我们说到Windows/Phone的后台任务时,会专门解释。

2)DataHelper,里面有两个folder,一个CloudAPI,里面针对每一个DataSource(API接口)都有个一个单独的类来处理,还可以根据各个DataSource的相似度,来抽象更底层的类。另一个是DataModel,就是数据模型类。这个DataHelper我们后续的CloudAPI篇里会仔细说。

3) NotificatoinsExtensions 这个其实不是我们自己写的,是直接从MSDN里的sample里下载的(按照微软的建议,但不明白为什么不做成一个库,而是以源代码形式给出)。这个项目里主要给出了一些帮助方法,来简单地更新磁贴,否则就要直接操作XML数据来更新磁贴,非常容易出错,而且不容易理解。这个以后讲动态磁贴时才细说。

在这个有个问题:为什么DataHelper project不放在Shared里面呢?原因特简单:因为BackgroundTask也需要访问DataHelper, 如果放在Shared里面访问不到,因为Shared只为Windows/WindowsPhone两个Project服务。(如果这里我的理解有什么错误请大虾们指正)

目录组织

我们着重说一下Windows, WindowsPhone, Shared三个Project中的文件夹。

CNBlogs.Windows(Windows 8.1)

1)Assets

里面装着那些图像文件,一般有三类:A) Tile类,只为磁贴而做;B) Image类,只为背景图,装饰图之类的而做;C)Icon类,放在AppBar中的图标。如果项目较大,图像文件较多时,可以在这个文件夹下建立三个子文件夹,分别为Tile, Image, Icon。

2)Common

这个是系统自带的。如果系统没有生成这个文件夹,你在添加一个新的Page时,指定BasicPage,就可以生成它。这个文件夹里有个4个文件,包括了很多帮助函数,供处理Navigation时是使用。轻易不动它。

3)Controls

这里放着你的小宝贝们,就是那些Template Control,或者User Control。如果是Template Control, 这里面只放一个XXXControl.cs; 如果是User Control, 这里面放一个XXXControl.xaml, 下面附带了XXXControl.xaml.cs。关于这两种Control的区别,我们后续有专门的一篇博客讲解。

5)Pages

这里面放着你的大宝贝们,就是那些页面啦。每个页面都有个单独的XAML和其下面附带的.cs文件来描述其样式和行为,以及和其他页面的交互关系。

6)SettingFlyouts

Windows中的设置页面比较特殊,在右面,是一种规约,鼠标右键或者轻扫右侧边框弹出5个系统按钮,按下面的“设置”即可进入某个App自己的设置页面。这些设置页面其实也是用XAML来表现的。

7)Themes

这里放的是Template Control的样式,只有一个Generic.xml,里面放了所有自定义Template Control的样式(User Control不在这里)。不需要把它挪出来放在别的什么地方,别有洁癖,谁知道移到别的地方会出什么错误。

Folder就这些了,各有各的用处,有的是系统建的,有的是你自己建的,目的只有一个,让自己和别人可以很快地找到东西。

有一个地方要注意,就是namespace。如果你在Project上右键添加一个Page, namespace是CNBlogs; 如果在Pages上添加,namespace是CNBLogs.Pages。都可以,但是要统一,否则要出麻烦。

CNBlogs.WindowsPhone(Windows Phone 8.1)

Windows Phone的Folder们和Windows的基本一样,只是最下面的Pages和Views的区别,这个只是习惯问题,您随便。

CNBLogs.Shared

Shared Project有些不一样了,我们细细说来。

1)Assets

如果Windows/Phone有相同的图像资源(样子/颜色/尺寸都相同),可以只放一份在这里。但是目前Windows/Phone的Tile有尺寸上区别,所以Tile部分要分开放。背景图之类的肯定也不一样,一大一小。ICON部分可能会一致,因为Windows和Phone下面的AppBar中AppBarButton大小一样。

2)ControlHelper

这里面一般放置两类cs文件,一类是TemplateSelector,另一类是Converter,就是数据转换类。这个我们在后面的博客中专门讲(记得提醒我,我已经承诺不少东西了)。这两类东西,对于Windows/Phone来说是共用的。

3)FunctionHelper

顾名思义,放的是你自己的通用的帮助函数类。

4)HTML

可有可无,看项目。如果项目中有用到WebView的,也许需要一些初始的HTML或者css。

5)SampleData

对于大多数应用来说,都需要data支持,有的是用本地data,有的用远程data。当data没有到位时(CloudAPI部分还没有完工),你可以先手工制作一些模拟data放这里,不影响开发进度。

6)Strings

这里面放的是Resources, 按国家/市场划分。比如我们只有一个zh-CN子目录,也许还有个ja-JP子目录,里面放着Resources.resw。这个样子的:

所有界面上用到的字符串都扔里面,比如在zh-CN中有个”Title \t 首页”,在en-US中必须有个”Title \t Home“来对应,以便在不同国家显示不同语言。

7)App.xaml和StyleDictionary.xaml

共用的,放这里没事儿。尤其是StyleDictionary.xaml,里面放着所有的颜色,字体,样式等信息,你在Windows上的应用使用蓝底白字,在Windows Phone上要统一用蓝底白字,就靠使用这个文件里的信息了。

小结

在本篇随笔中,我们强调了CloudAPI的重要性,是因为我们从很多成功的App中总结出云端数据和服务支持的重要性; 而削弱了MVVM的重要性,是因为我们从实践中体会到,Model和View都是不可或缺的,但是ViewModel就不是那么重要了,代码重复,可读性差,能替代它的方法很多。至于什么可自动测试性,根本谈不上。开发测试一体,有助于节约成本,提高工作效率,增强开发人员的责任心。

 

你可以从这里下载我们分享的源代码:

https://code.msdn.microsoft.com/CNBlogs-Client-Universal-477943ab

当然更可以直接下载两个App来看效果,但是由于designer介入较晚,所以UI上面还需要完善,我们会持续更新App。

Windows Phone Store App link:

http://www.windowsphone.com/zh-cn/store/app/博客园-uap/500f08f0-5be8-4723-aff9-a397beee52fc

Windows Store App link:

http://apps.microsoft.com/windows/zh-cn/app/c76b99a0-9abd-4a4e-86f0-b29bfcc51059

纯粹干净的App, 里面绝无广告,请放心使用。

博客园客户端(Universal App)开发随笔 - Hello, Universal

MSDN Blogs - 6 hours 56 min ago

在移动和云成为微软的主题之后,Windows Phone 8.1 手机和Windows 8.1平板也渐渐成熟,吸引了越来越多的开发者。为了让开发者们高效的开发一款跨手机和平板的应用,微软顺势推出了Universal应用的概念。

今天我们想向大家分享怎样用C#和XAML语言开始开发一个跨Windows 8.1和 Windows Phone 8.1 的 Universal 应用。

准备

首先硬件方面我们的计算机要支持Hyper-V功能或者有一部运行Windows Phone 8.1 操作系统的手机。

软件则需要在计算机上安装Windows 8.1 和 Visual Studio 2013 update 2 及以上的版本。免费的面向 Windows 的 Microsoft Visual Studio Express 2013 with Update 4 就可以,在http://www.visualstudio.com/zh-cn/downloads#d-express-windows-8 能够找到。

启动Visual Studio 2013,首次启动会需要注册一个Microsoft账号,有了的话直接登录就可以。

Hello Universal

现在我们就可以创建 Windows Universal App 了。

在start界面上点击新建项目或者在菜单栏上点击文件->新建->项目

选择已安装->Visual C#->应用商店应用->通用应用程序->空白应用程序

选择保存文件夹并输入项目名称,比如“my Universal”

点击确定。

好了,Visual Studio 已经自动为我们创建了Universal解决方案:

在解决方案资源管理器中可以看到我们的Universal解决方案包含3个项目,my Universal.Windows,my Universal.WindowsPhone,my Universal.Shared。

 

它们分别对应了Windows应用,Windows Phone应用,共享资源。

 

启动

现在虽然我们还没有写一行代码,但其实我们的应用已经可以运行了。

先来看看我们的Windows应用:

点击debug按钮  

经过一段时间的编译,我们的Windows应用就启动了。当然没有什么内容,只有一个Title is Here。现在把鼠标移到右上角,先关闭它。(这里可能回到Visual Studio 后会看到还是在debug状态,需要手动停止一下Debug。)

接下来看看我们的Windows Phone 应用。

点击debug按钮旁边的向下小箭头。

 

选择启动项目-> my universal.WindowsPhone(Windows Phone 8.1)

Debug按钮发生了变化,文字变成了Device,如果你的计算机支持Hyper-V,那么还会看到一系列windows模拟器(Emulator)。

 

先看看支持Hyper-V的情况。我们选择一种模拟器,点击debug按钮。Visual Studio 会启动对应的模拟器,在上面部署并启动我们的Windows Phone应用。(启动模拟器会比较慢,我们可以在结束debug时不关闭模拟器,而是在Visual Studio中点击停止Debug按钮 ,这样模拟器就不会关闭)

当然目前我们的Windows Phone 也是没什么内容,同样只有一行Title is Here。

下面看看如果我们的计算机不支持Hyper-V的情况:

通常我们日常使用的Windows  Phone 8.1手机是不能马上用于开发的,我们要把它注册为开发者手机。

我们需要把我们的Windows Phone 8.1 手机通过usb线连接到电脑上,解开锁屏。

接着在开始界面打开Windows Phone Developer Registration 8.1。

 

程序检测到我们的Windows Phone 8.1 手机后点击注册,输入我们的Microsoft账号,就可以把它注册为开发者手机了。

 

这样就可以在debug按钮上选择device,用手机而不是模拟器debug我们的Windows Phone 8.1 应用了。

Universal 是什么

大家可能注意到我们的debug按钮里可以选择的启动项目只有my Universal.Windows,my Universal.WindowsPhone两个,那么my Universal.Shared这个项目是做什么用的呢?

实际上这个项目是Universal应用的重点,我们可以在其中共享Windows应用和Windows Phone应用的代码。

我们的应用既可以在Windows上又可以在Windows Phone上运行,它们的界面是有着很大区别的。但是背后的逻辑,运作方式却几乎一样。在以往的开发方式中,我们可能要写两套后台代码,分别维护它们。一边发现了什么问题,需要修改,还得检查另一边的代码。但当我们创建了Universal 应用之后,这种情况就会大大减少。只要修改同一个.Share项目,就可以同时对Windows和Windows Phone应用产生作用。它们之间有所区别的地方,我们也可以用条件编译来区分。

比如我们可以打开项目my universal.Shared中的App.xaml.cs文件:

 

可以看到编辑区域左上角的选项有.Windows和.Windows Phone,目前选择的是.Windows。在代码区域中,夹在#if WINDOWS_PHONE_APP…#endif 之间的代码则是灰色的状态。这段代码就是Windows Phone独有的。现在显示灰色是由于我们在左上角选择了.Windows项目,它是不起作用的。

整体看来,Universal应用就是通过.Share项目共享了不同平台的代码,减少了跨平台的维护工作,让我们能够实现高效的开发。

小结

是不是非常方便?一次创建,2个应用。这就是Universal的魅力所在。接下来我们会一步一步向大家分享如何把这个简单的应用扩充成为一个功能完善的cnblogs阅读器。欢迎大家继续关注。

你可以从这里下载我们分享的源代码:

https://code.msdn.microsoft.com/CNBlogs-Client-Universal-477943ab

Windows Phone Store App link:

http://www.windowsphone.com/zh-cn/store/app/博客园-uap/500f08f0-5be8-4723-aff9-a397beee52fc

Windows Store App link:

http://apps.microsoft.com/windows/zh-cn/app/c76b99a0-9abd-4a4e-86f0-b29bfcc51059

博客园客户端(Universal App)开发随笔 - Universal App(UAP)开篇

MSDN Blogs - 6 hours 58 min ago

Universal App (以下简称UAP) 对大多数人来说还是个新概念,因为有了Windows 8.1和Windows Phone 8.1以后,才有了这个概念,大概意思是说:你写一套代码,能够在所有运行Windows的平台上通用。目前来看,PC/Surface/WindowsPhone可以做到这一点,xBox很快也可以做到。

但是一提起Windows Phone的开发,很多人会觉得无所适从,到底是用UAP所依赖的Windows Runtime SDK呢,还是使用Silverlight呢?

熟悉WPF/Silverlight的童鞋们可能已经觉察到了微软不再对这项技术进行升级,但是你仍然可以选择使用Silverlight在WP7/8/8.1上开发App,而UAP是针对WP8.1及以上的版本的SDK,所以可以理解为Windows Runtime SDK是已经确立的一种趋势。想继续维护Silverlight App的,没问题,可以继续升级你的App。但是如果想做一个新App, 强烈建议使用UAP框架进行开发,没准儿哪天你就想把你的手机应用放到xBox上呢。

MSDN上的关于UAP的链接在这里:http://msdn.microsoft.com/zh-cn/library/windows/apps/dn609832.aspx。入口网址是这个:http://dev.windows.com/zh-cn,你可以更改zh-cn为en-us去看英文原版。

然后点��上面的”开发“:

再点击上面的”操作步骤“,就可以进入UAP开发文档的总入口,适合于developer查阅。Designer可以查阅左侧的”设计“页。

CNBLogs大家庭中也有很多博主提到过这个东西,比如:http://www.cnblogs.com/sonic1abc/p/3772693.html,在此谢谢王博博主。

大家可以先看看,全面了解一下该技术/框架是否符合自己的个人兴趣或商业利益,再决定是不是要继续跟进我们后续的一系列博文。

系列博文:

http://www.cnblogs.com/ms-uap/

你可以从这里下载我们分享的源代码:

https://code.msdn.microsoft.com/CNBlogs-Client-Universal-477943ab

https://github.com/MS-UAP/cnblogs-UAP

Windows Phone Store App link:

http://www.windowsphone.com/zh-cn/store/app/博客园-uap/500f08f0-5be8-4723-aff9-a397beee52fc

Windows Store App link:

http://apps.microsoft.com/windows/zh-cn/app/c76b99a0-9abd-4a4e-86f0-b29bfcc51059

Inconsistency between quantity in sales order and quantity in inventory transaction.

MSDN Blogs - 7 hours 31 min ago

The sales order invoicing process has a functionality where the end user could identify a particular quantity which will be invoiced, and this could be controlled by the over/under deliver percentage on the sales line. The invoiced quantity in the sales order invoice is linked to the item
unit of measure, where the item inventory unit of measure could be different than the sales unit of measure. For example a company stock specific item in Kilogram and sell it to the end customer in Ton, in that sense the sales invoice will be issued in tons, and the inventory consumption will be in kilogram and bear in mind that in some scenarios the inventory and sales unit of measure are the same.

The unit of measures are defined on the item master, Product information management| Common| Released product, then press edit on a particular item record then go to Manage costs fast tab, as shown in the below screen shot the which illustrate the inventory base unit of measure.

In order identify the sales unit of measure move to Sell fast tab

 

In a sales order with quantity = 10 ea in a sales line, the quantity here represented in the sales unit of measure.

 

 

The quantity of the sales line which represents the sales unit of measure will be reflected in the sales order invoice, in addition to inventory unit of measure as well. The quantity in sales unit of measure will be found under Lines tab, Update filed. The quantity under update will be the base of the revenue entry (Quantity * Sales price).

 

The quantity in inventory unit of measure will be found under Line details tab, Update filed. The quantity under update will be the base of the COGS entry (Quantity * Cost price).

If the user change the quantity in the update filed under the Lines tab, then the quantity under the Line details will be changed as well, if the user change update filed under Line details is changes the quantities under Lines tab will not change, in that said the changes mechanism only works in one way as mentioned.

If the second scenario of changes occurred where the user change quantities under Lines detail, the system will keep the quantity under Lines tab as it represents the sales unit of measure, which is acceptable if there is a slight differences in the sales unity of measure and
inventory unit of measure.

But if it is occurred without a business requirement this will lead to inconsistency between quantity in sales order and quantity in inventory transaction.

And in other hand the generated financial entry of the invoice.

 

The conclusion an issue may raise because of this mismatch, and in order to check the posted transactions, go to Accounts receivable| Inquiry| History| Invoice then right click and press Record info, and press Show all fields.

The quantity in the left side represents quantity in sales line, and quantity in right side represents the quantity updated in the inventory transactions.


The rationale behind it in case there is an item has two different unit of measure (Sales & Inventory) and the user may want to change the quantity of which will be reduced from the inventory without changing the quantity in the sales order, in the other hand if the item has the same unit of measure the quantities in the two fields should be identical, but if the user changes the quantities under line details tab it will not change the quantities under lines tab.  Please note that the same mechanism working in the Purchase order side.

One reference architecture in PaaS cloud solution.

MSDN Blogs - 9 hours 6 min ago

It is from projects to demonstrate cloud energy and relieve big headaches in traditional solutions, the architecture can be realized smartly with public cloud while keep connected with local network, and the reference may help in Windows Azure, Amazon Web Service and more cloud platforms.

Highlights to demonstrate:

  •  Apply Microsoft cloud to grant traditional solution capability to process sudden dramatic increase requests or huge incoming traffic in a very smart way
  •  Able to save more than 50% system cost
  •  On premise solution can be integrated with or migrated to cloud services, leading to a more powerful and decoupled solution
  •  Numerous great features in Microsoft Azure accelerates development cycle and make online solutions easy to go with performance guarantee
  •  Popular 3rd party technologies can be well applied as they were

Key features involved:

  • Classic programing pattern: multi tiers design & integration, security enhancement, performance optimization.
  • Auto scaling on Azure: flexible cloud technology to respond changing business traffic.
  • Virtual network: extend on premise network & machine to cloud, keep traditional software solution still working for Azure.
  • WAD: powerful monitoring and diagnostics from Windows Azure.
  • ACS: let customer benefit more from existing identity providers and Azure cloud, then focus more on business logic.
  • Service Bus: solutions for those who doesn’t have public endpoint but needs real time communication.
  • Cache Service: Improve performance both for Azure solution and on premise application.
  • SQL Azure: Powerful Relation Database Engine on cloud, provide reliable and secure structured storage for cloud apps and local apps. 
  • Others: easy management and high efficiency of Windows Azure, good support on open tech and third party plugins.

Brief Workflow:

  1. Load test generates web requests to web role.
  2. Web role handles incoming traffic initially and adds the corresponding message in target storage queue.
  3. Worker role picks up messages from storage queue, and process them one by one.
  4. When worker role process a message, it needs some important information from on premise server.
  5. During the whole workflow, end user can trace the status of his request from web role


More reference: http://2014.cloudapp.net

 

Command-Line Utility to Create BlogEngine.NET Password Hashes

MSDN Blogs - 11 hours 28 min ago

I ran into an interesting predicament the other day, and I thought that both the situation and my solution were worth sharing. Here's the scenario: I host websites for several family members and friends, and one of my family member's uses BlogEngine.NET for her blog. (As you may have seen in my previous blogs, I'm a big fan of BlogEngine.NET.) In any event, she forgot her password, so I logged into the admin section of her website, only to discover that there was no way for me to reset her password – I could only reset my password. Since it's my webserver, I have access to the physical files, so I decided to write a simple utility that can create the requisite SHA256/BASE64 password hashes that BlogEngine.NET uses, and then I can manually update the Users.xml file with new password hashes as I create them.

With that in mind, here is the code for the command-line utility:

using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace BlogEnginePasswordHash { class Program { static void Main(string[] args) { // Verify that a single argument was passed to the application... if (args.Length != 1) { // ...if not, reply with generic help message. Console.WriteLine("\nUSAGE: BlogEnginePasswordHash <password>\n"); } // ...otherwise... else { // Retrieve a sequence of bytes for the password argument. var passwordBytes = Encoding.UTF8.GetBytes(args[0]); // Retrieve a SHA256 object. using (HashAlgorithm sha256 = new SHA256Managed()) { // Hash the password. sha256.TransformFinalBlock(passwordBytes, 0, passwordBytes.Length); // Convert the hashed password to a Base64 string. string passwordHash = Convert.ToBase64String(sha256.Hash); // Display the password and it's hash. Console.WriteLine("\nPassword: {0}\nHash: {1}\n", args[0], passwordHash); } } } } }

That code snippet should be pretty self-explanatory; the application takes a single argument, which is the password to hash. Once you enter a password and hit enter, the password and it's respective hash will be displayed.

Here are a few examples:

C:\>BlogEnginePasswordHash.exe "This is my password" Password: This is my password Hash: 6tV+IGzvN4gaQ0vmCWNHSQ0UQ0WgW4+ThJuhpXR6Z3c= C:\>BlogEnginePasswordHash.exe Password1 Password: Password1 Hash: GVE/3J2k+3KkoF62aRdUjTyQ/5TVQZ4fI2PuqJ3+4d0= C:\>BlogEnginePasswordHash.exe Password2 Password: Password2 Hash: G+AiJ1Cq84iauVtdWTuhLk/xBGR0cC1rR3n0tScwWyM= C:\>

Once you have created password hashes, you can paste those into the Users.xml file for your website:

<Users> <User> <UserName>Alice</UserName> <Password>GVE/3J2k+3KkoF62aRdUjTyQ/5TVQZ4fI2PuqJ3+4d0=</Password> <Email>alice@fabrikam.com</Email> <LastLoginTime>2015-01-31 01:52:00</LastLoginTime> </User> <User> <UserName>Bob</UserName> <Password>G+AiJ1Cq84iauVtdWTuhLk/xBGR0cC1rR3n0tScwWyM=</Password> <Email>bob@fabrikam.com</Email> <LastLoginTime>2015-01-31 01:53:00</LastLoginTime> </User> </Users>

That's all there is to do. Pretty simple stuff.

Transforming learning using Lync and Office 365 collaboration

MSDN Blogs - 12 hours 38 min ago
Guest Post by Naomi Manning - Expert Educator One of the exciting things I worked on at the very end of last year was a project with Year 9 students at Ormiston College in Queensland and Year 8 girls at Abbotsleigh in Sydney. It was a new style of learning that was student centred video conferencing and saw Ormiston students teach the Abbotsleigh students new concepts and Abbotsleigh completed new projects and provided feedback on the teaching materials all via Lync, Office Mix and OneNote in...(read more)

Small Basic: Turtle Polygon Patterns

MSDN Blogs - Fri, 01/30/2015 - 22:42

Here is a gallery of some of our favorite patterns made with the Turtle object in Small Basic!

 

This first Turtle pattern comes from litdev:

Turtle.Speed = 10

For i = 1 To 600

Turtle.Move(10)

Turtle.Turn(i*11)

EndFor

 

Next, here's an interesting shape from Zock77:

Import code: FFB727

 

As a bit of a joke, Pappa Lapub used it as a Turtle Frame:

And here are Pappa's three shapes:

Turtle PolySpiral   LNZ598  18 Lines , shortened as (too) much as could, but 3 figures, not my idea

TurtlePattern Brillie   JMC583   10 Lines   OK, but not my idea

Circle Series / Flower   QCL151  15 Lines

PS: Turtle.Hide sends Turtle (Image Shape) to Oblivion and it will never be seen in the same program again.  Turtle.Show wont bring it back.
Although not the same; to hide Turtle Shape and then show it up again Shapes.HideShape("_turtle") and Shapes.ShowShape("_turtle") can be used.

  

And here is some code from MK_hobby_coder:

Changing the number used in the turtle code makes different pictures.  The following code makes a  pictogram for 0-9.  Then the user can make a pictogram to store a numeric code. 

program : TLQ846

Turtle.Speed = 10
tutrix = Turtle.X
tutriy = Turtle.Y
For x = 0 To 9
  GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
  Turtle.X = tutrix+(x*100)-300
  Turtle.Y = tutriy - 100
  Turtle.Angle=0
  GraphicsWindow.FontSize = 20
  GraphicsWindow.DrawText(Turtle.x,Turtle.y,x)
For i = 1 To 300 Step (x+1)
  Turtle.Move(10)
  Turtle.Turn((x+1)*i)
EndFor
EndFor
  code = "1=3;2=5;3=6;4=8;5=2;6=2;7=5;8=0"
  For x = 1 To Array.GetItemCount(code)
  GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
  Turtle.X = tutrix+(x*100)-300
  Turtle.Y = tutriy + 100
  Turtle.Angle=0
  GraphicsWindow.FontSize = 20
  'GraphicsWindow.DrawText(Turtle.x,Turtle.y,code[x])
For i = 1 To 300 Step (code[x]+1)
  Turtle.Move(10)
  Turtle.Turn((code[x]+1)*i)
EndFor
EndFor

==================

 

Enjoy the Turtle Patterns! Do you know why turtles love fancy patterns? No? Well see Small Basic: Why Turtles Love Fancy Patterns .

   - Ninja Ed

Small Basic: Why Turtles Love Fancy Patterns

MSDN Blogs - Fri, 01/30/2015 - 22:34

Did you know that turtles love to make fancy patterns? You didn’t know that?

 

Well, take a look at this one:

 TLQ846 

 

And take a look at this one from Zock77:

Import code: FFB727

And then Pappa Lapub used it as a Turtle Frame:

   

I think you’ll start to see how much turtles love fancy patterns!

 

It all started with Tommy Turtle. At that point in time, all turtles had smooth shells. But Tommy couldn't help but feel that everyone looked the same, and they couldn't really express themselves as individuals!

And so Tommy Turtle went to work!

He had Tammy Turtle and Tara Turtle help decorate his shell! They painted it, they carved it with him, and by the time they were done, he finally had color and a design on his shell!

Tommy Turtle looked different. Now, others looked at him and said, "That's Tommy Turtle!" Tommy became famous.

And that made all the other turtles jealous! They came up to Tommy, and they said, "Tommy, why do you get a unique shell? All our shells are boring! We all look the same, except for you. It's just not fair!"

Well, that made Tommy Turtle think. Were they right? Was it not fair that Tommy got to enjoy some independence and personal expression, and they didn't?

But what if they did? Tommy began to wonder about it.

Finally, Tommy decided to help out all the other turtles. Tommy said, "You know what. You're right. It's not fair. So Tammy Turtle, Tara Turtle, and I will help you design your shell and make it so that each of you is unique!"

But Tyler Turtle objected, "Wait! If we're all made different, like you, then we'll all be the same again! The only difference is that we'll have the same patterned shells and not the same smooth shells!"

"Well that's a good point," said Tommy Turtle. "I know! Instead of making all the designs the same, we'll make each design a little different, with different patterns and different colors!"

Well Tommy's idea was well received, and so Tommy, Tammy, and Tara all got to work, helping make unique colors and designs on all the turtles.

 

And after time passed, all those turtles had future generations of turtles, and all their shells are now patterned, just like those turtles in the past were!

Well, their love for designs grew back then, and ever since then, turtles have loved to create designs! Well, Small Basic is no different! The Small Basic turtles also love designs.

Don't believe me? Well, take a look at this turtle, from litdev:

Turtle.Speed = 10

For i = 1 To 600

Turtle.Move(10)

Turtle.Turn(i*11)

EndFor

 

Oh, those crazy turtles and their patterns!

You can go here to see what other shenanigans those turtles are up to:

Small Basic Turtle Games & Graphics

 

Have a great day!

   - Ninja Ed

 

 

 

Heap Corruption Exception 0xC0000374

MSDN Blogs - Fri, 01/30/2015 - 18:19
Modern computers can execute millions of instructions per second, and if one of them is erroneous, then the process could crash. Often analysis of a crash dump can immediately indicates what the problem is, so the fix is easy. For example a NullReference exception: declare a Process variable with a null value, then try to find the value of the Id member.             System.Diagnostics.Process process = null; var procid = process.Id; Seeing these...(read more)

Cyber thieves stealing from businesses and how DMARC can help

MSDN Blogs - Fri, 01/30/2015 - 17:52

I read an article yesterday entitled Cyber thieves stole $215 million from businesses using hacked email addresses. How did they do it? Here’s a key except:

Here's a nightmare scenario: You're working in the accounts department, when you receive an email from your boss, asking that you urgently wire one of the company's foreign suppliers a five-figure sum that has been somehow missed. You do, and then you email your boss to let him or her know—only to receive an email back that reads, "Which wire transfer?"

Yep, you've been scammed—and according to a recent alert from the FBI, it's one that cyber thieves have used to pilfer almost $215 million from businesses over the past 14 months… Rather than spamming thousands of people at a time as with a regular email scam, the "business email compromise" (BEC) swindle specifically targets businesses known to work with foreign suppliers or other businesses, and to routinely use wire transfer payments.

As the article says, this is a nightmare scenario, and it is becoming more common. So how do we stop it?

One way to do it is with DMARC which protects the From: address that you see in your email client. Many corporations use Microsoft Exchange which shows your picture when the sending email address matches the person’s account information in Active Directory, for example:

Many people looking at that would be tempted to think it was a legitimate message sent from me. After all, it’s got my picture next to it.

But in this case, it’s not from me, it is spoofed. And that’s where DMARC comes in; it helps protect the From: address from spoofing, and that’s the one you really want to protect because in the corporate environment it really looks like it is an internal message, and therefore your guard is down.

This is one reason why DMARC is critically important for businesses – it helps cut down on malicious spoofing like this which is how hackers break in much (most?) of the time. You need to deploy DMARC!

For more information on how to do this in Office 365, please see this previous blog post: Using DMARC in Office 365.

Now, in this article, I did take a few liberties. The article is not about spoofed messages from the outside but instead hacked accounts from the inside. That is, a hacker broke into someone’s account by stealing his username and password. He then logged into that account and sent a message from his account (i.e., a real message) to someone else. In this case, DMARC wouldn’t work because it is an internal message and would have passed DMARC if it even would have been scanned at all.

Those types of compromises are more difficult to detect so you have to have a product that monitors those sorts of things – intrusion detection and hackers moving laterally. There are a few products out there that do this sort of thing.

Security needs to be done in layers and this article, and this blog post, illustrates why – because the type of detection is different depending on where the threat is coming from.

My reading for Engineering System and Continuous Delivery

MSDN Blogs - Fri, 01/30/2015 - 15:11
Below is the list of talks which in my reading list for Engineering System and Continuous Delivery The Evolution of Continuous Delivery at Scale @ Linkedin Jason Toy talks about the evolution and history of LinkedIn's release strategy. Jason Toy drives the direction for build automation at LinkedIn, focusing on the commit to release pipeline with the ultimate goal of allowing developers to move code from dev to prod in 30 minutes. Continuous Delivery: Building Systems that Can...(read more)

BA Marathon: Free Day of Online Analytics Learning Spotlights Power BI, Excel

MSDN Blogs - Fri, 01/30/2015 - 15:00

Guest blog post by: PASS VP of Marketing Denise McInerney – a Data Architect at Intuit – began her career as a SQL Server DBA in 1998 and now applies her deep understanding of data to enable analytic solutions to business problems. She is founder of the PASS Women in Technology virtual chapter, and a speaker at user group meetings and conferences. You can follow her on Twitter at @denisemc06.

On your mark… Get ready… Get set for a free day of online analytics learning at the PASS BA Marathon webinar series Tuesday, Feb. 3, kicking off with an inside look at the new Power BI platform, redesigned for data professionals, business analysts, and business users.

Featuring six back-to-back live webinars with an exceptional lineup of business analytics and data experts from around the world, the BA Marathon will preview a slice of top speakers and sessions coming up at the PASS Business Analytics Conference, April 20-22, in Santa Clara, CA.

The BA Marathon is excited to have Jen Underwood, Sr. Program Manager of Microsoft Business Intelligence & Analytics, and Miguel Martinez, Product Marketing Manager for Power BI, participating in the webinar series and sharing how business analytics and BI professionals can get more from Power BI and Excel.

Check out the full BA Marathon lineup, and register now for your favorite sessions – or all of them! And make sure to follow the conversation at #PASSBAMarathon.

Then see how to continue your analytics learning at the PASS BA Conference, with 60+ real-world sessions from these Excel and Power BI all-stars and more. Get the best rate when you register by Feb. 16 – and save an additional $150 with discount code BAMSFTBL150. I look forward to seeing you in Santa Clara! 

Pages

Subscribe to Randy Riness @ SPSCC aggregator
Drupal 7 Appliance - Powered by TurnKey Linux