Commit d537c7538c2bc65c126d5e7ea74a2049cbb917ce
Merge branch 'Develop' into QA
Showing
44 changed files
with
3536 additions
and
212 deletions
.gitignore
... | ... | @@ -35,4 +35,6 @@ $tf*/ |
35 | 35 | 300-PROTOTYPES/POC/AIAHTML5 |
36 | 36 | 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js.orig |
37 | 37 | 400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js.orig |
38 | -400-SOURCECODE/AIAHTML5.Web/index.html.orig | |
39 | 38 | \ No newline at end of file |
39 | +400-SOURCECODE/AIAHTML5.Web/index.html.orig | |
40 | +400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll | |
41 | +400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb | ... | ... |
150-DOCUMENTATION/002-DBScripts/CreateContentTable.sql
0 → 100644
1 | +CREATE TABLE Content | |
2 | +( | |
3 | + Id INT NOT NULL, | |
4 | + Title VARCHAR(50) NOT NULL, | |
5 | + Content NVARCHAR(MAX) | |
6 | +) | |
7 | + | |
8 | +INSERT INTO Content VALUES (1, 'Terms of Service', '<u><b>END USER LICENSE AGREEMENT: A.D.A.M. INTERACTIVE ANATOMY </b></u><br> | |
9 | +YOU SHOULD CAREFULLY READ THE FOLLOWING TERMS AND CONDITIONS OF THIS END USER LICENSE AGREEMENT (THIS "AGREEMENT") BEFORE YOU USE THE WEB APPLICATION (AS DEFINED BELOW). THIS AGREEMENT IS A LEGALLY BINDING CONTRACT BETWEEN A.D.A.M. Education, a division of Ebix, Inc. ("ADAM") AND YOU. ADAM IS LICENSING THE WEB APPLICATION TO YOU FOR YOUR USE ONLY AS SET FORTH BELOW. BY USING ANY PART OF THE WEB APPLICATION, YOU ACCEPT AND AGREE TO ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT ACCEPT AND AGREE TO BE BOUND BY ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT, YOU SHOULD NOT REGISTER THIS LICENSE OR USE THE WEB APPLICATION AND SHOULD PROMPTLY CONTACT A.D.A.M. , WITHIN TEN DAYS AFTER YOU OBTAIN THE WEB APPLICATION ACCESS, FOR A REFUND OF YOUR MONEY.<br> | |
10 | +<b>DEFINITIONS </b><br>The following definitions apply to the terms as they appear in this Agreement:<ul><li>"You" and "Your" refer to any person or entity that acquires or uses this Web Application.</li><li>"Content" means digitally encoded illustrations, pictures, images, animations, video, sound, text and other material for use by or with the Web Application.</li><li>"A.D.A.M. Content" refers to Content created by ADAM or its suppliers.</li><li>"A.D.A.M. Images" means all or part of A.D.A.M. Content that is displayed in a single window on a computer display at any time.</li><li>"Educational Multimedia Project" means a project created by an educator or student as part of a systematic learning activity by a Educational Institution that incorporates the student''s or educator''s original material, such as course notes or commentary, together with various copyrighted media formats including but not limited to, motion media, music, text material, graphics, illustrations, photographs and digital software which are combined into an integrated presentation.</li><li>"Educational Institution" means an organization whose primary focus is supporting research and instructional activities of educators and students for educational purposes.</li><li>"Guidelines" means the Fair Use Guidelines for Educational Media published by the Consortium of College and University Media Centers.</li><li>"Web Application" means, without limitation, the Web Application programs contained in A.D.A.M. Interactive Anatomy online created by ADAM or its suppliers, A.D.A.M. Content, documentation and other material provided to You by ADAM.</li><li>"Curriculum Builder" means the proprietary authoring tool of ADAM included in the Web Application.</li></ul> | |
11 | +<b>1. GRANT OF LICENSE </b><br> | |
12 | +Subject to the terms of this Agreement, ADAM grants You, and You accept from ADAM, a limited, personal, revocable, non-transferable, non-exclusive license to use the machine-readable, object code form of the Web Application and any accompanying documentation (the "Documentation") for personal use. The Web Application and Documentation are licensed (not sold) to you. You agree that ADAM does not transfer to you any of ADAM''s right, title, or interest in or to the Web Application or Documentation or any component part thereof except as expressly set forth herein, and under no circumstances shall this Agreement be considered a "sale" of the Web Application or Documentation or of any component part thereof to you. You agree that ADAM retains all right, title, and interest in and to the Web Application and Documentation and all component parts thereof and to all intellectual and industrial property rights therein, subject only to the limited right of use granted to you hereunder, which right of use ADAM may terminate or revoke in accordance with the terms of this Agreement. The Web Application contains components that actively monitor for license violations. In the event that a license violation is detected, the Web Application may be automatically disabled. You agree to allow for this monitoring to occur and for ADAM to disable the Web Application in the event that a license violation is detected.<br> | |
13 | +<b>2. PERMITTED USES OF THE WEB APPLICATION </b><br> | |
14 | +(A) Single Computer Use: Student''s and Instructor''s Editions (each referring to the Web Application)<br>ADAM grants You a limited license to use the Web Application as follows. You may:<ul><li>Log in to the Web Application to be accessed and used at only one log in session per (1) computer owned, leased, or otherwise controlled by You. Concurrent user or site license access, or use of the Web Application on two (2) or more computers concurrently is not permitted without separate written authorization by ADAM and the possible payment of additional license fees to ADAM; and</li><li>You may also make one copy of the Documentation for backup purposes. Any such copies of the Documentation shall include ADAM''s copyright and other proprietary notices. Except as authorized under this Section 2(a), no copies, clones, or duplicates of the Web Application or Documentation or any component part thereof may be made by You or any person under Your authority or control.</li></ul><p> | |
15 | +(B) Concurrent License Use: Student/Library Patron Edition</p><p>ADAM also grants You a limited license to use the Web Application as follows. You may:</p><ul><li>Access the Web Application up to the number but not greater than the quantity of concurrent users licensed. Web Application to be accessed and used at only up to the license quantity in sessions on computer owned, leased, or otherwise controlled by You or Your enrolled students and faculty or library patrons.</li><li>You may also make one copy of the Documentation for backup purposes. Any such copies of the Documentation shall include ADAM''s copyright and other proprietary notices. Except as authorized under this Section 2(b), no copies, clones, or duplicates of the Web application and Documentation or any component part thereof may be made by You or any person under Your authority or control.</li></ul><p> | |
16 | +(C) Site License Use: Student/Faculty and Library Patron Edition</p><p>ADAM also grants You a limited license to use the Web Application as follows. You may:</p><ul><li>Access the Web Application through a secure username and password location on your organizations intranet, learning management system, OPAC or other portal requiring user ID and password entry. Web Application to be accessed and used only by enrolled students and employed faculty or library patrons, sessions on computer owned, leased, or otherwise controlled by You or Your enrolled students and faculty or library patrons. </li><li>You may also make one copy of the Documentation for backup purposes. Any such copies of the Documentation shall include ADAM''s copyright and other proprietary notices. Except as authorized under this Section 2(c), no copies, clones, or duplicates of the Web application and Documentation or any component part thereof may be made by You or any person under Your authority or control.</li></ul><br> | |
17 | +<b>3. PERMITTED USES OF THE A.D.A.M. CONTENT </b><br> | |
18 | +ADAM grants You a limited license to use the A.D.A.M. Content in accordance with this Agreement. The permitted uses of A.D.A.M. Content listed below do <u>not</u> apply to any commercial use of the A.D.A.M. Content. Commercial use (that is, use of A.D.A.M. Content in any other means not expressly granted herein would require an additional license from ADAM. | |
19 | +<ul><li><b>For electronic Educational Multimedia Projects created using Curriculum Builder: </b> Using<b> Curriculum Builder</b>, You may use A.D.A.M. Content to create electronic Educational Multimedia Projects, and may include an unlimited number of A.D.A.M. Images in each of those <b>Curriculum Builder</b> projects. You may modify any A.D.A.M. Image included in a<b> Curriculum Builder</b> electronic Educational Multimedia Project (for example, by adding labels), as long as you maintain the integrity of the A.D.A.M. Image and include ADAM''s copyright notice (© 2012 A.D.A.M. Education.) with the image. You may publish a<b> Curriculum Builder</b> Educational Multimedia Project electronically, on a local network or on the Internet, without restriction only while Your subscription to the Web Application is active.</li><br> | |
20 | +<li><b>For electronic Educational Multimedia Projects created using authoring tools other than Curriculum Builder: </b> You may use A.D.A.M. Content to create electronic Educational Multimedia Projects with authoring tools other than <b>Curriculum Builder</b>, subject to the restrictions specified in this paragraph. For example, You could extract an A.D.A.M. Image and import the image into a graphics package (such as Microsoft® PowerPoint®), solely for inclusion in your electronic Educational Multimedia Project, and modify the extracted A.D.A.M. Image (for example, by adding labels). If You modify an extracted A.D.A.M. Image, you must maintain the integrity of the image, note in your projects that you have modified the image, and include ADAM''s copyright notice (© 2012 A.D.A.M. Education) with the image. The number of A.D.A.M. Images included in all electronic Educational Multimedia Projects created using any authoring tool other than<b> Curriculum Builder</b> must not exceed, in the aggregate, 100 images for each licenses You have subscribed to of the Web Application. If an electronic Educational Multimedia Project created using an authoring tool other than<b> Curriculum Builder</b> is placed on Your computer network, You are responsible for taking reasonable steps to ensure that access to such electronic Educational Multimedia Project is strictly limited to authorized students and educators of Your Educational Institution (for example, through the use of a password or PIN). You must also provide notice that the electronic Educational Multimedia Project is copyrighted and may not be copied and distributed by students. You may use such electronic Educational Multimedia Project only while Your subscription to the Web Application is active.</li><br> | |
21 | +<li>You may make up to five (5) copies of an Educational Multimedia Project in the form of a videotape that includes A.D.A.M. Content, with no restriction on the number of A.D.A.M. Images that may be used in such videotape; but such videotapes may not be sold, offered for sale, leased, rented, licensed or otherwise used for any commercial purpose. If You are an academic institution, such videotapes may be made available only to students and staff and may not be distributed outside Your institution.</li><br> | |
22 | +<li>You may create print copies of an Educational Multimedia Project using the A.D.A.M. Content and make up to one thousand (1000) copies of each page of such output (if You are an academic institution, You may make up to one thousand (1000) copies of each page of such output per quarter), provided that the number of A.D.A.M. Images included in all print Educational Multimedia Projects created under each subscription license You have of the Web Application, in the aggregate, must not exceed one hundred (100) images and You must not bind projects in a book or book-like form. If You are an academic institution, You may sell copies of print projects to Your students, but only for an amount sufficient to cover Your cost of reproduction and distribution, not for a profit. If You make more than fifty (50) copies of a print Educational Multimedia Project, You must provide ADAM with a copy of such print project for archival purposes. You may use such print copies of an Educational Multimedia Project only while Your subscription to the Web Application is active.</li><br> | |
23 | +<li>You may make up to five (5) copies of an Educational Multimedia Project in the form of 35 mm photographic slides or overhead transparencies that include A.D.A.M. Content, provided that the number of A.D.A.M. Images included in all such projects created under each license You have of the Web Application, in the aggregate, must not exceed one hundred (100) images.</li></ul> | |
24 | +All output and copies You make of A.D.A.M. Content, regardless of their form, must bear and prominently display ADAM''s copyright notice in the following form: <b>© 2012 A.D.A.M., Education</b>. ADAM reserves, and You hereby grant to ADAM the right to review all such copies to verify compliance with this Agreement. | |
25 | +The permitted uses described above are based in large part upon the Fair Use Guidelines for Educational Media published by the Consortium of College and University Media Centers. In the event of any discrepancies between the specific terms of this Agreement and the Guidelines, this Agreement will govern. The Guidelines may be found at http://www.ccumc.org/copyright/ccguides.html | |
26 | +If you would like to make any use of the A.D.A.M. Content not authorized under this Agreement, you should contact A.D.A.M. Education License Administrator at 800-755-2326.<br> | |
27 | +<b>4. OWNERSHIP OF PROJECTS</b><br> | |
28 | +You retain ownership of (i) any electronic Educational Multimedia Project created using the A.D.A.M. Content, whether or not such project was created using Curriculum Builder, and any copies You make of such electronic Educational Multimedia Project and (ii) any intellectual properties related to such project. However, ADAM or its suppliers will retain ownership of (i) all A.D.A.M. Content, including the A.D.A.M. Images, used in any electronic Educational Multimedia Project and all A.D.A.M. Images that You alter or modify in the creation of such project and (ii) any intellectual properties related to the A.D.A.M. Content, including the A.D.A.M. Images, whether or not altered or modified.<br> | |
29 | +<b>5. PRIVACY AND PRODUCT ACTIVATION </b><br> | |
30 | +When the Web Application is first used, it must be activated. A questionnaire is provided with information submitted to ADAM prior to the online activation process, along with the license data. The information may be used by ADAM for the purposes of developing marketing materials for future and existing products. | |
31 | +<p>In addition to the questionnaire, information, and license, certain identifying system information is encrypted via a one-way hash function and the result of this function is transmitted as well. This system information is used solely to uniquely identify the machine that the Web Application is access from, and the hash function prevents the retrieval of the original system information from the hashed result. The use of internet protocols necessitates that the program will also transmit the IP (internet protocol) address of the machine from which the Web Application is being used, and this information may be logged by ADAM''s servers as well. All information is transmitted via SSL (secure socket layer) to deter electronic eavesdropping.</p> <br> | |
32 | +<b>6. RESTRICTIONS </b><br> | |
33 | +You agree that the Web Application and Documentation and all component parts thereof contain copyrighted material, trademarks, trade secrets, and other proprietary material of ADAM protected under applicable U.S. and international intellectual and industrial property laws (regardless of whether such rights of ADAM are registered or unregistered). You agree that, except as provided for in Section 2 above, you will not: (i) copy, reproduce, modify, network, rent, loan, lease, re-sell, or otherwise distribute the Web Application or Documentation any of its or their components to any third-party; (ii) make the Web Application or Documentation available on any public Internet sites, by "bulletin boards," on-line services, remote dial-in, or network or telecommunications link of any kind; (iii) create derivative works or any other works that are based on or derived, in whole or in part, from the Web Application, A.D.A.M. Content, or Documentation or any of its or their components; (iv) assign, sublicense, transfer, pledge, or otherwise share your rights under this Agreement; or (v) decompile, reverse engineer, disassemble, or translate the Web Application or otherwise reduce the Web Application to a humanly perceivable form. The trademarks, service marks, and logos used on the Web Application and/or Documentation are owned by ADAM or third parties who have granted limited rights of use to ADAM, and all rights therein are reserved by the respective owners. You will not alter, remove, or obfuscate any trademarks, copyrights, or other proprietary rights notices contained on the Web Application or the Documentation.<br> | |
34 | +<b>7. TRANSFER </b><br> | |
35 | +You may not permanently transfer all of Your rights under this Agreement.<br> | |
36 | +<b>8. TERMINATION</b><br> | |
37 | +This Agreement and Your rights to use the Web Application and Documentation terminate automatically if You violate any part of this Agreement or the Guidelines. In the event of termination, You must immediately remove all access of the Web Application and Documentation.<br> | |
38 | +<b>9. DISCLAIMER OF WARRANTY </b><br> | |
39 | +THE WEB APPLICATION AND DOCUMENTATION IS PROVIDED ON AN "AS-IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ADAM DISCLAIMS ANY WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ALL WARRANTIES AGAINST INFRINGEMENT ARE HEREBY DISCLAIMED EXCEPT ADAM REPRESENTS THAT IT HAS SUFFICIENT AUTHORIZATION TO LICENSE THE WEB APPLICATION AND DOCUMENTATION TO YOU. ADAM DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE WEB APPLICATION MEET YOUR REQUIREMENTS OR THAT THE USE OF THE WEB APPLICATION WILL BE UNINTERRUPTED OR ERROR FREE. ADAM MAKES NO REPRESENTATION OR WARRANTY THAT ITS WEB APPLICATION WILL WORK IN COMBINATION WITH ANY HARDWARE APPLICATIONS OR WEB APPLICATION OF THIRD PARTIES, OR THAT ALL DEFECTS IN THE WEB APPLICATION WILL BE CORRECTED. THE WEB APPLICATION MAY INCLUDE OR BE BUNDLED WITH THIRD-PARTY WEB APPLICATION, THE USE OF WHICH IS GOVERNED BY A SEPARATE END-USER LICENSE AGREEMENT. THIS WARRANTY DOES NOT APPLY TO SUCH THIRD PARTY WEB APPLICATION. FOR APPLICABLE WARRANTY INFORMATION FOR SUCH THIRD PARTY WEB APPLICATION, PLEASE REFER TO THE END USER LICENSE AGREEMENT GOVERNING THE USE OF SUCH THIRD PARTY WEB APPLICATION OR THE ACCOMPANYING DOCUMENTATION RELATING TO SUCH THIRD PARTY WEB APPLICATION. | |
40 | +If the Web Application fails to comply with these limited warranties, at A.D.A.M. Education, a division of Ebix, Inc. option, make a reasonable effort to correct any nonconformities in the Web Application. | |
41 | +If ADAM is unable to correct defective media or nonconformities in the Web Application, ADAM will refund the price You paid for this subscription. The refund will fully satisfy all of Your claims under this limited warranty. This limited warranty shall continue for any replacement Web Application for the rest of the original 90-day warranty period or for 30 days from the date You receive the replacement license, whichever is longer. ADAM ''s liability to You for actual damages for any cause whatsoever, and regardless of the form of the action, will be limited to the money paid for the Web Application Subscription.<br> | |
42 | +<b>10. DISCLAIMER OF MEDICAL WARRANTY </b><br> | |
43 | +ADAM MAKES NO REPRESENTATION OR WARRANTY TO YOU OR ANY OTHER PARTY REGARDING THE ACCURACY OF ANY MEDICAL INFORMATION MADE AVAILABLE THROUGH THE WEB APPLICATION. YOU AGREE THAT THE WEB APPLICATION IS MADE AVAILABLE TO YOU ONLY FOR GENERAL EDUCATION AND ENTERTAINMENT PURPOSES. YOU SHOULD NOT USE ANY INFORMATION MADE AVAILABLE THROUGH THE WEB APPLICATION TO DIAGNOSE OR TREAT ANY MEDICAL CONDITION. YOU SHOULD CONSULT A LICENSED PHYSICIAN TO DIAGNOSE AND TREAT ANY MEDICAL CONDITION.<br> | |
44 | +<b>11. LIMITATION OF LIABILITY </b><br> | |
45 | +(a) IN NO EVENT SHALL ADAM''S CUMULATIVE LIABILITY TO YOU OR ANY OTHER PARTY FOR ANY LOSS OR DAMAGES RESULTING FROM ANY CLAIMS, DEMANDS, OR ACTIONS (WHETHER IN CONTRACT, TORT, OR OTHERWISE) ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE USE OF (OR THE INABILITY TO USE) THE WEB APPLICATION AND DOCUMENTATION EXCEED THE AMOUNT OF LICENSE FEES ACTUALLY PAID BY YOU TO ADAM FOR THE WEB APPLICATION AND DOCUMENTATION. | |
46 | +(b) IN NO EVENT SHALL ADAM BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR EXEMPLARY DAMAGES, OR LOST PROFITS, EVEN IF ADAM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY TO YOU. <br> | |
47 | +<b>12. EXPORT CONTROLS </b><br> | |
48 | +The Web Application and Documentation and every component part thereof are subject to the export controls of the United States of America (including, without limitation, the U.S. Export Administration Act and any regulations thereto). No portion of the Web Application may be downloaded, exported, or re-exported: (i) into (or to a national or resident of) Cuba, Iraq, Libya, Sudan, North Korea, Iran, Syria, or any country to which the United States of America has embargoed goods; or (ii) to anyone on the U. S. Treasury Department''s list of Specially Designated Nationals or the U. S. Commerce Department''s Table of Denial Orders. By using the Web Application, you are agreeing to the foregoing and you are warranting that you are not located in, under the control of, or a national or resident of any such country on any such list. <br> | |
49 | +<b>13. U.S. GOVERNMENT RESTRICTED RIGHTS </b><br> | |
50 | +The Web Application and Documentation are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at D.F.A.R.S. 252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial Computer Software - Restricted Rights at 48 C.F.R. 52.227-19, as applicable. The manufacturer for such purpose is A.D.A.M., Inc., 10 10th Street, Suite 500, Atlanta, Georgia 30309.<br> | |
51 | +<b>14. MISCELLANEOUS </b><br> | |
52 | +This Agreement shall be governed by the laws of the State of Georgia, United States of America, excluding the application of its conflicts of law provisions. You agree that all legal proceedings arising out of or in connection with this Agreement shall be brought exclusively in the state courts of Georgia located in Fulton County, Georgia, or the U.S. District Court located in the Northern District of Georgia - Atlanta Division, and You expressly submit to the jurisdiction and venue of such courts and consent to extra-territorial service of process, should a dispute arise. Should any provision of this Agreement be declared invalid or unenforceable by any court of competent jurisdiction, such provision shall be deemed severable from this Agreement and shall not affect the validity and enforceability of the remaining provisions of this Agreement. If any action is brought by either party to this Agreement against the other party regarding the subject matter of this Agreement, the prevailing party shall be entitled to recover, in addition to any other relief granted, reasonable attorneys'' fees and expenses of such action. The failure or delay at any time of either party to this Agreement to require performance by the other party of any responsibility or obligation provided for in this Agreement shall in no way affect the full right of such party to require such performance at any time thereafter, nor shall the waiver by either such party of a breach of any provision of this Agreement by the other party constitute a waiver of any succeeding breach of the same or any other provisions, nor constitute a waiver of the responsibility or obligation itself. This Agreement constitutes the entire agreement between You and ADAM relating to the subject matter herein and shall not be modified except in writing signed by both you and ADAM. You agree that any violation by You of the provisions of this Agreement would cause ADAM irreparable harm for which ADAM would have no adequate remedy at law. Therefore, in addition to other remedies, which may be available to ADAM, ADAM will be entitled to seek injunctive relief, without the necessity of posting bond, against any such violation or threatened violation. | |
53 | +<p>Copyright © 2012 A.D.A.M. Education, Ebix, Inc.. All rights reserved.<br> | |
54 | +A.D.A.M. Interactive Anatomy requires Adobe Flash Player software by Adobe, Inc., Copyright © 2012 Abode, Inc. All rights reserved. Adobe, and Flash are trademarks of Adobe, Inc.<br> | |
55 | +A.D.A.M. Interactive Anatomy requires Unity Pro Player software by Unity Technologies, Copyright © 2012 Unity Technologies. All rights reserved. Unity Pro and Unity Technologies are trademarks of Unity Technologies.</p> | |
56 | +') | |
0 | 57 | \ No newline at end of file | ... | ... |
150-DOCUMENTATION/002-DBScripts/GetTermsOfServiceText.sql
0 → 100644
1 | +-- ================================================ | |
2 | +-- Template generated from Template Explorer using: | |
3 | +-- Create Procedure (New Menu).SQL | |
4 | +-- | |
5 | +-- Use the Specify Values for Template Parameters | |
6 | +-- command (Ctrl-Shift-M) to fill in the parameter | |
7 | +-- values below. | |
8 | +-- | |
9 | +-- This block of comments will not be included in | |
10 | +-- the definition of the procedure. | |
11 | +-- ================================================ | |
12 | +SET ANSI_NULLS ON | |
13 | +GO | |
14 | +SET QUOTED_IDENTIFIER ON | |
15 | +GO | |
16 | +-- ============================================= | |
17 | +-- Author: <Author,,Name> | |
18 | +-- Create date: <Create Date,,> | |
19 | +-- Description: <Description,,> | |
20 | +-- ============================================= | |
21 | +CREATE PROCEDURE GetTermsOfServiceText | |
22 | + -- Add the parameters for the stored procedure here | |
23 | + | |
24 | +AS | |
25 | +BEGIN | |
26 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
27 | + -- interfering with SELECT statements. | |
28 | + SET NOCOUNT ON; | |
29 | + | |
30 | + -- Insert statements for procedure here | |
31 | + SELECT Content.Title, Content.Content FROM Content WHERE ID = 1 | |
32 | +END | |
33 | +GO | ... | ... |
400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj
... | ... | @@ -106,7 +106,7 @@ |
106 | 106 | </ItemGroup> |
107 | 107 | <ItemGroup> |
108 | 108 | <Compile Include="App_Start\WebApiConfig.cs" /> |
109 | - <Compile Include="Constants\AIAConstants.cs" /> | |
109 | + <Compile Include="content\AIAConstants.cs" /> | |
110 | 110 | <Compile Include="Controllers\AdminAccessController.cs" /> |
111 | 111 | <Compile Include="Controllers\AuthenticateController.cs" /> |
112 | 112 | <Compile Include="Controllers\ForgotUserController.cs" /> |
... | ... | @@ -143,6 +143,7 @@ |
143 | 143 | </ItemGroup> |
144 | 144 | <ItemGroup> |
145 | 145 | <Folder Include="App_Data\" /> |
146 | + <Folder Include="Constants\" /> | |
146 | 147 | </ItemGroup> |
147 | 148 | <PropertyGroup> |
148 | 149 | <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ... | ... |
400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
... | ... | @@ -21,5 +21,8 @@ namespace AIAHTML5.API.Constants |
21 | 21 | public const string PASSWORD_UPDATE_FAILED = "Password update failed"; |
22 | 22 | |
23 | 23 | public const string INVALID_USER = "Invalid UserID"; |
24 | + | |
25 | + public const string LICENSE_TERM_CONDITION_UPDATE_SUCCESS = "License Term Accepted field updated successfully."; | |
26 | + public const string LICENSE_TERM_CONDITION_UPDATE_FAILED = "License Term Accepted field update failed."; | |
24 | 27 | } |
25 | 28 | } |
26 | 29 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Controllers/LicenseTermConditionController.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Net; | |
5 | +using System.Net.Http; | |
6 | +using System.Web.Http; | |
7 | +using log4net; | |
8 | +using AIAHTML5.API.Constants; | |
9 | +using Newtonsoft.Json; | |
10 | +using Newtonsoft.Json.Linq; | |
11 | + | |
12 | +namespace AIAHTML5.API.Controllers | |
13 | +{ | |
14 | + public class LicenseTermConditionController : ApiController | |
15 | + { | |
16 | + // GET api/licensetermcondition | |
17 | + public IEnumerable<string> Get() | |
18 | + { | |
19 | + return new string[] { "value1", "value2" }; | |
20 | + } | |
21 | + | |
22 | + // GET api/licensetermcondition/5 | |
23 | + public string Get(int id) | |
24 | + { | |
25 | + return "value"; | |
26 | + } | |
27 | + | |
28 | + // POST api/licensetermcondition | |
29 | + public HttpResponseMessage Post([FromBody]string licenseeAccountNumber) | |
30 | + { | |
31 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
32 | + logger.Debug("inside POST"); | |
33 | + HttpResponseMessage response = null; | |
34 | + | |
35 | + int result = AIAHTML5.API.Models.Users.UpdateLicenseTerm(licenseeAccountNumber); | |
36 | + if (result > 0) | |
37 | + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.LICENSE_TERM_CONDITION_UPDATE_SUCCESS) }; | |
38 | + else | |
39 | + response = new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.LICENSE_TERM_CONDITION_UPDATE_FAILED) }; | |
40 | + | |
41 | + return response; | |
42 | + } | |
43 | + | |
44 | + | |
45 | + // PUT api/licensetermcondition/5 | |
46 | + public void Put(int id, [FromBody]string value) | |
47 | + { | |
48 | + } | |
49 | + | |
50 | + // DELETE api/licensetermcondition/5 | |
51 | + public void Delete(int id) | |
52 | + { | |
53 | + } | |
54 | + } | |
55 | +} | ... | ... |
400-SOURCECODE/AIAHTML5.API/Controllers/ResetPasswordController.cs
... | ... | @@ -42,7 +42,7 @@ namespace AIAHTML5.API.Controllers |
42 | 42 | int result = 0; |
43 | 43 | if (!String.IsNullOrEmpty(userInfo["newPassword"].ToString())) |
44 | 44 | { |
45 | - result = AIAHTML5.API.Models.Users.UpdatePassword(userInfo, userData.LoginId, userData.EmailId); | |
45 | + result = AIAHTML5.API.Models.Users.UpdatePassword(userInfo); | |
46 | 46 | if (result > 0) |
47 | 47 | response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.PASSWORD_UPDATE_SUCCESS) }; |
48 | 48 | else | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... | ... | @@ -32,20 +32,30 @@ namespace AIAHTML5.API.Models |
32 | 32 | |
33 | 33 | protected static DataSet GetSQLData(string commandText, bool isSp) |
34 | 34 | { |
35 | - conn = new SqlConnection(dbConnectionString); | |
36 | - if (isSp) | |
35 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
36 | + logger.Debug(" inside GetSQLData for command text = " + commandText); | |
37 | + DataSet ds= null; | |
38 | + try | |
37 | 39 | { |
38 | - cmd = new SqlCommand(commandText, conn); | |
39 | - cmd.CommandType = CommandType.StoredProcedure; | |
40 | + conn = new SqlConnection(dbConnectionString); | |
41 | + if (isSp) | |
42 | + { | |
43 | + cmd = new SqlCommand(commandText, conn); | |
44 | + cmd.CommandType = CommandType.StoredProcedure; | |
45 | + } | |
46 | + else | |
47 | + { | |
48 | + cmd = new SqlCommand(commandText, conn); | |
49 | + } | |
50 | + SqlDataAdapter da = new SqlDataAdapter(); | |
51 | + da.SelectCommand = cmd; | |
52 | + ds = new DataSet(); | |
53 | + da.Fill(ds); | |
40 | 54 | } |
41 | - else | |
55 | + catch (SqlException ex) | |
42 | 56 | { |
43 | - cmd = new SqlCommand(commandText, conn); | |
57 | + logger.Fatal("Exception in GetSQLData for command text =" + commandText + ", Exception= " + ex.Message); | |
44 | 58 | } |
45 | - SqlDataAdapter da = new SqlDataAdapter(); | |
46 | - da.SelectCommand = cmd; | |
47 | - DataSet ds = new DataSet(); | |
48 | - da.Fill(ds); | |
49 | 59 | return ds; |
50 | 60 | } |
51 | 61 | |
... | ... | @@ -202,6 +212,16 @@ namespace AIAHTML5.API.Models |
202 | 212 | |
203 | 213 | ArrayList userModuleList = objModel.GetUserModulesList(allModulesList, licensedModulesList); |
204 | 214 | objUser.Modules = userModuleList; |
215 | + | |
216 | + if (!objUser.License.IsTermAccepted) | |
217 | + { | |
218 | + ArrayList termsList = DBModel.GetTermsOfServiceText(); | |
219 | + foreach(Hashtable item in termsList) | |
220 | + { | |
221 | + objUser.TermsOfServiceTitle = item["title"].ToString(); | |
222 | + objUser.TermsOfServiceText = item["content"].ToString(); | |
223 | + } | |
224 | + } | |
205 | 225 | } |
206 | 226 | else |
207 | 227 | { |
... | ... | @@ -431,7 +451,7 @@ namespace AIAHTML5.API.Models |
431 | 451 | return objUser; |
432 | 452 | } |
433 | 453 | |
434 | - public static int UpdateUserPassword(dynamic userInfo, string loginId, string emailId) | |
454 | + public static int UpdateUserPassword(dynamic userInfo) | |
435 | 455 | { |
436 | 456 | int result = 0; |
437 | 457 | conn = new SqlConnection(dbConnectionString); |
... | ... | @@ -440,8 +460,8 @@ namespace AIAHTML5.API.Models |
440 | 460 | conn.Open(); |
441 | 461 | cmd.CommandText = "UpdateUserPassword"; |
442 | 462 | cmd.CommandType = CommandType.StoredProcedure; |
443 | - cmd.Parameters.AddWithValue("@sLoginId", loginId); | |
444 | - cmd.Parameters.AddWithValue("@sEmailId", emailId); | |
463 | + cmd.Parameters.AddWithValue("@sLoginId", userInfo["loginId"].ToString()); | |
464 | + cmd.Parameters.AddWithValue("@sEmailId", userInfo["emailId"].ToString()); | |
445 | 465 | cmd.Parameters.AddWithValue("@sNewPassword", userInfo["newPassword"].ToString()); |
446 | 466 | result = cmd.ExecuteNonQuery(); |
447 | 467 | conn.Close(); |
... | ... | @@ -576,9 +596,9 @@ namespace AIAHTML5.API.Models |
576 | 596 | lic.LicenseTypeId = Convert.ToInt32(dr[dc]); |
577 | 597 | if (dc.ColumnName == "InstitutionName") |
578 | 598 | lic.InstitutionName = dr[dc].ToString(); |
579 | - if (dc.ColumnName == "Adress1") | |
599 | + if (dc.ColumnName == "Address1") | |
580 | 600 | lic.Address1 = dr[dc].ToString(); |
581 | - if (dc.ColumnName == "Adress2") | |
601 | + if (dc.ColumnName == "Address2") | |
582 | 602 | lic.Address2 = dr[dc].ToString(); |
583 | 603 | if (dc.ColumnName == "CountryId") |
584 | 604 | lic.CountryId = Convert.ToInt32(dr[dc]); |
... | ... | @@ -592,7 +612,7 @@ namespace AIAHTML5.API.Models |
592 | 612 | lic.Phone = dr[dc].ToString(); |
593 | 613 | if (dc.ColumnName == "EmailId") |
594 | 614 | lic.EmailId = dr[dc].ToString(); |
595 | - if (dc.ColumnName == "TotalLogin") | |
615 | + if (dc.ColumnName == "TotalLogins") | |
596 | 616 | lic.TotalLogins = Convert.ToInt32(dr[dc]); |
597 | 617 | if (dc.ColumnName == "AccountTypeId") |
598 | 618 | lic.AccountTypeId = Convert.ToInt32(dr[dc]); |
... | ... | @@ -614,7 +634,7 @@ namespace AIAHTML5.API.Models |
614 | 634 | } |
615 | 635 | if (dc.ColumnName == "NoOfRenewals") |
616 | 636 | lic.NoOfRenewals = Convert.ToInt32(dr[dc]); |
617 | - if (dc.ColumnName == "IsTermAccepted") | |
637 | + if (dc.ColumnName == "IsTermsAccepted") | |
618 | 638 | lic.IsTermAccepted = Convert.ToBoolean(dr[dc]); |
619 | 639 | if (dc.ColumnName == "ProductId") |
620 | 640 | lic.ProductId = dr[dc].ToString(); |
... | ... | @@ -628,5 +648,49 @@ namespace AIAHTML5.API.Models |
628 | 648 | |
629 | 649 | return lic; |
630 | 650 | } |
651 | + | |
652 | + public static int UpdateLicenseTermStatus(string accountNumber) | |
653 | + { | |
654 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
655 | + logger.Debug(" inside UpdateTermAcceptedStatus for AccountNumber = " + accountNumber); | |
656 | + int result = 0; | |
657 | + try | |
658 | + { | |
659 | + conn = new SqlConnection(dbConnectionString); | |
660 | + cmd = new SqlCommand(); | |
661 | + cmd.Connection = conn; | |
662 | + conn.Open(); | |
663 | + cmd.CommandText = "UpdateLicenseTermAcceptedStatus"; | |
664 | + cmd.CommandType = CommandType.StoredProcedure; | |
665 | + cmd.Parameters.AddWithValue("@sAccountNumber", accountNumber); | |
666 | + result = cmd.ExecuteNonQuery(); | |
667 | + conn.Close(); | |
668 | + } | |
669 | + catch (SqlException ex) | |
670 | + { | |
671 | + conn.Close(); | |
672 | + logger.Fatal("Exception in UpdateLicenseTermStatus for AccountNumber =" + accountNumber + ", Exception= " + ex.Message); | |
673 | + } | |
674 | + return result; | |
675 | + } | |
676 | + | |
677 | + protected static ArrayList GetTermsOfServiceText() | |
678 | + { | |
679 | + ArrayList arrTermsOfService = new ArrayList(); | |
680 | + Hashtable contentHash = null; | |
681 | + string str = string.Empty; | |
682 | + string spName = "GetTermsOfServiceText"; | |
683 | + DataSet ds = DBModel.GetSQLData(spName, true); | |
684 | + DataTable dt = ds.Tables[0]; | |
685 | + | |
686 | + foreach (DataRow dr in dt.Rows) | |
687 | + { | |
688 | + contentHash = new Hashtable(); | |
689 | + contentHash.Add(AIAConstants.KEY_TITLE, dr["Title"]); | |
690 | + contentHash.Add(AIAConstants.KEY_CONTENT, dr["Content"]); | |
691 | + arrTermsOfService.Add(contentHash); | |
692 | + } | |
693 | + return arrTermsOfService; | |
694 | + } | |
631 | 695 | } |
632 | 696 | } |
633 | 697 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs
... | ... | @@ -9,17 +9,18 @@ namespace AIAHTML5.API.Models |
9 | 9 | { |
10 | 10 | public class PixelLocator |
11 | 11 | { |
12 | - | |
13 | - internal static dynamic GetBodyRegionsPixelData(string layerNumber, string bodyViewIndex, string systemNumber, string zoom) | |
14 | - { | |
15 | - try | |
12 | + | |
13 | + internal static dynamic GetBodyRegionsPixelData(string layerNumber, string bodyViewIndex, string systemNumber, string zoom) | |
16 | 14 | { |
17 | - var client = new MongoClient(); | |
18 | - var db = client.GetDatabase("AIAHTML5"); | |
15 | + try | |
16 | + { | |
17 | + //var client = new MongoClient("mongodb://192.168.90.43:27017"); | |
18 | + var client = new MongoClient(); | |
19 | + var db = client.GetDatabase("AIAHTML5"); | |
19 | 20 | |
20 | - var col = db.GetCollection<BsonDocument>("DAImages"); | |
21 | + var col = db.GetCollection<BsonDocument>("DAImages"); | |
21 | 22 | |
22 | - var pipeline = new BsonDocument[] | |
23 | + var pipeline = new BsonDocument[] | |
23 | 24 | { |
24 | 25 | new BsonDocument{{"$unwind", "$terms"}}, |
25 | 26 | new BsonDocument{ { "$match", new BsonDocument("terms.SystemNumbers", Convert.ToInt32(systemNumber)).Add("bodyViewIndex", Convert.ToInt32(bodyViewIndex)).Add("layerNumber", Convert.ToInt32(layerNumber)).Add("zoom", Convert.ToInt32(zoom)) }}, |
... | ... | @@ -31,15 +32,15 @@ namespace AIAHTML5.API.Models |
31 | 32 | }; |
32 | 33 | |
33 | 34 | |
34 | - var pixelData = col.Aggregate<BsonDocument>(pipeline).ToList(); | |
35 | + var pixelData = col.Aggregate<BsonDocument>(pipeline).ToList(); | |
35 | 36 | |
36 | - return pixelData.ToJson(); | |
37 | - } | |
38 | - catch (Exception e) | |
39 | - { | |
40 | - string error = e.Message+"..STACKTRACE: "+e.StackTrace; | |
41 | - return error; | |
37 | + return pixelData.ToJson(); | |
38 | + } | |
39 | + catch (Exception e) | |
40 | + { | |
41 | + string error = e.Message + "..STACKTRACE: " + e.StackTrace; | |
42 | + return error; | |
43 | + } | |
42 | 44 | } |
43 | 45 | } |
44 | -} | |
45 | -} | |
46 | +} | |
46 | 47 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/User.cs
... | ... | @@ -30,6 +30,8 @@ namespace AIAHTML5.API.Models |
30 | 30 | public LicenseSubscriptionDetails LicenseSubscriptions { get; set; } |
31 | 31 | public bool IsSubscriptionExpired { get; set; } |
32 | 32 | public string SubscriptionExpirationDateString { get; set; } |
33 | + public string TermsOfServiceTitle { get; set; } | |
34 | + public string TermsOfServiceText { get; set; } | |
33 | 35 | |
34 | 36 | public const string SUPER_ADMIN = "Super Admin"; |
35 | 37 | public const string GENERAL_ADMIN = "General Admin"; | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... | ... | @@ -131,7 +131,7 @@ namespace AIAHTML5.API.Models |
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | - internal static dynamic UpdatePassword(Newtonsoft.Json.Linq.JObject userInfo, string sLoginId, string sEmailId) | |
134 | + internal static dynamic UpdatePassword(Newtonsoft.Json.Linq.JObject userInfo) | |
135 | 135 | { |
136 | 136 | ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); |
137 | 137 | //var client = new MongoClient(); |
... | ... | @@ -144,7 +144,7 @@ namespace AIAHTML5.API.Models |
144 | 144 | |
145 | 145 | //var result = collection.UpdateOne(filter, update); |
146 | 146 | |
147 | - int result = DBModel.UpdateUserPassword(userInfo, sLoginId, sEmailId); | |
147 | + int result = DBModel.UpdateUserPassword(userInfo); | |
148 | 148 | |
149 | 149 | if (result != null) |
150 | 150 | return result; |
... | ... | @@ -157,5 +157,12 @@ namespace AIAHTML5.API.Models |
157 | 157 | return AIAConstants.ERROR_IN_FECTHING_DETAILS; |
158 | 158 | } |
159 | 159 | } |
160 | + | |
161 | + internal static dynamic UpdateLicenseTerm(string accNumber) | |
162 | + { | |
163 | + int result = DBModel.UpdateLicenseTermStatus(accNumber); | |
164 | + | |
165 | + return result; | |
166 | + } | |
160 | 167 | } |
161 | 168 | } |
162 | 169 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll deleted
No preview for this file type
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb deleted
No preview for this file type
400-SOURCECODE/AIAHTML5.API/content/AIAConstants.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Web; | |
5 | + | |
6 | +namespace AIAHTML5.API.Constants | |
7 | +{ | |
8 | + public class AIAConstants | |
9 | + { | |
10 | + public const string ERROR_IN_FECTHING_DETAILS = "Error in fecthing details."; | |
11 | + public const string USER_NOT_FOUND = "User not found."; | |
12 | + public const string MAIL_NOT_SENT = "Mail not sent."; | |
13 | + public const string MAIL_SENT = "Mail sent."; | |
14 | + | |
15 | + public const string KEY_ID = "id"; | |
16 | + public const string KEY_TITLE = "title"; | |
17 | + public const string KEY_NAME = "name"; | |
18 | + public const string KEY_SLUG = "slug"; | |
19 | + | |
20 | + public const string PASSWORD_UPDATE_SUCCESS = "Password updated successfully"; | |
21 | + public const string PASSWORD_UPDATE_FAILED = "Password update failed"; | |
22 | + | |
23 | + public const string INVALID_USER = "Invalid UserID"; | |
24 | + | |
25 | + public const string LICENSE_TERM_CONDITION_UPDATE_SUCCESS = "License Term Accepted field updated successfully."; | |
26 | + public const string LICENSE_TERM_CONDITION_UPDATE_FAILED = "License Term Accepted field update failed."; | |
27 | + | |
28 | + public const string KEY_CONTENT = "content"; | |
29 | + } | |
30 | +} | |
0 | 31 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/3dAController.js
... | ... | @@ -6,6 +6,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
6 | 6 | $scope.threeDAnatomyData; |
7 | 7 | $scope.Id; |
8 | 8 | $scope.$on('$viewContentLoaded', function (event) { |
9 | + if ($rootScope.refreshcheck == null) { | |
10 | + $location.path('/'); | |
11 | + } | |
9 | 12 | $scope.scroll(); |
10 | 13 | var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json') |
11 | 14 | promise.then( |
... | ... | @@ -86,7 +89,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
86 | 89 | } |
87 | 90 | |
88 | 91 | $scope.Open3DModelBody = function () { |
89 | - | |
92 | + if ($rootScope.refreshcheck == null) { | |
93 | + $location.path('/'); | |
94 | + } | |
90 | 95 | $rootScope.isLoading = true; |
91 | 96 | $('#spinner').css('visibility', 'visible'); |
92 | 97 | //alert(localStorage.getItem("currentBodyViewId")); | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/ADAMImgController.js
... | ... | @@ -12,6 +12,9 @@ function ($scope, $rootScope, pages, log, $location) { |
12 | 12 | //alert("scroll"); |
13 | 13 | } |
14 | 14 | $scope.$on('$viewContentLoaded', function (event) { |
15 | + if ($rootScope.refreshcheck == null) { | |
16 | + $location.path('/'); | |
17 | + } | |
15 | 18 | // code that will be executed ... |
16 | 19 | // every time this view is loaded |
17 | 20 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/AODController.js
... | ... | @@ -19,6 +19,9 @@ function ($scope, $rootScope, pages, log, $location) { |
19 | 19 | //$rootScope.currentActiveModuleTitle = pages[10].name; |
20 | 20 | |
21 | 21 | $scope.$on('$viewContentLoaded', function (event) { |
22 | + if ($rootScope.refreshcheck == null) { | |
23 | + $location.path('/'); | |
24 | + } | |
22 | 25 | // code that will be executed ... |
23 | 26 | // every time this view is loaded |
24 | 27 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/AnatTestController.js
... | ... | @@ -13,6 +13,9 @@ function ($scope, $rootScope, pages, log, $location) { |
13 | 13 | } |
14 | 14 | |
15 | 15 | $scope.$on('$viewContentLoaded', function (event) { |
16 | + if ($rootScope.refreshcheck == null) { | |
17 | + $location.path('/'); | |
18 | + } | |
16 | 19 | // code that will be executed ... |
17 | 20 | // every time this view is loaded |
18 | 21 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/CAController.js
... | ... | @@ -27,6 +27,10 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout |
27 | 27 | }; |
28 | 28 | |
29 | 29 | $scope.$on('$viewContentLoaded', function (event) { |
30 | + if ($rootScope.refreshcheck == null) { | |
31 | + $location.path('/'); | |
32 | + } | |
33 | + | |
30 | 34 | // code that will be executed ... |
31 | 35 | // every time this view is loaded |
32 | 36 | |
... | ... | @@ -173,7 +177,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout |
173 | 177 | }); |
174 | 178 | |
175 | 179 | }); |
176 | - | |
180 | + $('#' + localStorage.getItem("currentBodyViewId")).find('.thumbnail').addClass('HightLightThumbnail'); | |
177 | 181 | }, |
178 | 182 | function (error) { |
179 | 183 | // handle errors here |
... | ... | @@ -460,7 +464,9 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout |
460 | 464 | } |
461 | 465 | |
462 | 466 | $scope.openBodyView = function () { |
463 | - | |
467 | + if ($rootScope.refreshcheck == null) { | |
468 | + $location.path('/'); | |
469 | + } | |
464 | 470 | if ($rootScope.disableAnnotationTB == true) |
465 | 471 | { |
466 | 472 | $('#AnnotaionPopupDiv').find('input, textarea, button, select,img,div').attr('disabled', 'disabled'); | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/CIController.js
... | ... | @@ -32,6 +32,9 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout |
32 | 32 | }; |
33 | 33 | |
34 | 34 | $scope.$on('$viewContentLoaded', function (event) { |
35 | + if ($rootScope.refreshcheck == null) { | |
36 | + $location.path('/'); | |
37 | + } | |
35 | 38 | // code that will be executed ... |
36 | 39 | // every time this view is loaded |
37 | 40 | |
... | ... | @@ -197,7 +200,9 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout |
197 | 200 | // }); |
198 | 201 | |
199 | 202 | //}); |
200 | - | |
203 | + $timeout(function () { $('#' + localStorage.getItem("currentBodyViewId")).find('.thumbnail').addClass('HightLightThumbnail'); }, 100); | |
204 | + | |
205 | + | |
201 | 206 | $timeout(function () { $('#ciSpinner').css('visibility', 'hidden'); }, 300); |
202 | 207 | }, |
203 | 208 | function (error) { |
... | ... | @@ -528,7 +533,9 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout |
528 | 533 | } |
529 | 534 | |
530 | 535 | $scope.openBodyView = function () { |
531 | - | |
536 | + if ($rootScope.refreshcheck == null) { | |
537 | + $location.path('/'); | |
538 | + } | |
532 | 539 | $rootScope.isLoading = true; |
533 | 540 | $('#spinner').css('visibility', 'visible'); |
534 | 541 | $scope.voId = localStorage.getItem("currentBodyViewId"); |
... | ... | @@ -626,16 +633,18 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout |
626 | 633 | "slug": $rootScope.currentSlug |
627 | 634 | }); |
628 | 635 | |
636 | + | |
637 | + $("#ciImagePanel .img-thumbnail").css("height", $("#ciImagePanel .jsPanel-content").height()); | |
629 | 638 | var jspContentHeight = $('.jsPanel-content').height(); |
630 | - var imgHeight = $('.img-thumbnail').find('img').height(); | |
631 | - if (imgHeight <= 0) | |
632 | - imgHeight = 320; | |
633 | - var textH = $('.img-subtitle').height(); | |
634 | - textH = textH + 40; | |
635 | - var blackBorderHeight = jspContentHeight - (imgHeight + textH); | |
636 | - if ($('.jsPanel-content').length > 0) { | |
637 | - $('.img-subtitle').css('margin-bottom', blackBorderHeight); | |
638 | - } | |
639 | + //var imgHeight = $('.img-thumbnail').find('img').height(); | |
640 | + //if (imgHeight <= 0) | |
641 | + // imgHeight = 320; | |
642 | + //var textH = $('.img-subtitle').height(); | |
643 | + //textH = textH + 40; | |
644 | + //var blackBorderHeight = jspContentHeight - (imgHeight + textH); | |
645 | + //if ($('.jsPanel-content').length > 0) { | |
646 | + // $('.img-subtitle').css('margin-bottom', blackBorderHeight); | |
647 | + //} | |
639 | 648 | } |
640 | 649 | |
641 | 650 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js
... | ... | @@ -19,7 +19,9 @@ function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location) { |
19 | 19 | } |
20 | 20 | //load json data |
21 | 21 | $scope.loadCurriculumBuiderData = function () { |
22 | - | |
22 | + if ($rootScope.refreshcheck == null) { | |
23 | + $location.path('/'); | |
24 | + } | |
23 | 25 | //get current path |
24 | 26 | var currentURL = $location.path(); |
25 | 27 | var selectedModuleName = ''; | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
... | ... | @@ -376,7 +376,9 @@ AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$l |
376 | 376 | |
377 | 377 | //load json data for body view |
378 | 378 | $scope.loadDissectibleAnatomyData = function () { |
379 | - | |
379 | + if ($rootScope.refreshcheck == null) { | |
380 | + $location.path('/'); | |
381 | + } | |
380 | 382 | //get current path |
381 | 383 | var currentURL = $location.path(); |
382 | 384 | var selectedModuleName = ''; |
... | ... | @@ -2845,193 +2847,202 @@ AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$l |
2845 | 2847 | |
2846 | 2848 | .then( |
2847 | 2849 | function (result) { |
2848 | - console.log('1. HighlightBodyByTermListForBodySystem is called'); | |
2849 | - $rootScope.macthedTermList = result; | |
2850 | - var termNo = 0; | |
2851 | - var pixcelLocation = 0; | |
2852 | - var prevBRID = 0; | |
2853 | - if ($rootScope.macthedTermList.length > 0) { | |
2854 | - console.log('2. HighlightBodyByTermListForBodySystem is called'); | |
2855 | - //remove existing data and draw fresh data | |
2856 | - for(var i=0; i<$rootScope.grayImageDataList.length;i++){ | |
2857 | - var grayCanvasID = 'imageCanvas' + parseInt(i+1); | |
2858 | - var grayCanvas = document.getElementById(grayCanvasID); | |
2859 | - | |
2860 | - if (grayCanvas != null) { | |
2861 | - var grayCanvasContext = grayCanvas.getContext("2d"); | |
2862 | - | |
2863 | - var canvasHeight = grayCanvas.height; | |
2864 | - var canvasWidth = grayCanvas.width; | |
2865 | - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) | |
2866 | - grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(i)], 0, 0); | |
2850 | + | |
2851 | + if (result.length == 0) | |
2852 | + { | |
2853 | + $rootScope.isLoading = false; | |
2854 | + $('#spinner').css('visibility', 'hidden'); | |
2855 | + | |
2856 | + } | |
2857 | + else { | |
2858 | + console.log('1. HighlightBodyByTermListForBodySystem is called'); | |
2859 | + $rootScope.macthedTermList = result; | |
2860 | + var termNo = 0; | |
2861 | + var pixcelLocation = 0; | |
2862 | + var prevBRID = 0; | |
2863 | + if ($rootScope.macthedTermList.length > 0) { | |
2864 | + console.log('2. HighlightBodyByTermListForBodySystem is called'); | |
2865 | + //remove existing data and draw fresh data | |
2866 | + for (var i = 0; i < $rootScope.grayImageDataList.length; i++) { | |
2867 | + var grayCanvasID = 'imageCanvas' + parseInt(i + 1); | |
2868 | + var grayCanvas = document.getElementById(grayCanvasID); | |
2869 | + | |
2870 | + if (grayCanvas != null) { | |
2871 | + var grayCanvasContext = grayCanvas.getContext("2d"); | |
2872 | + | |
2873 | + var canvasHeight = grayCanvas.height; | |
2874 | + var canvasWidth = grayCanvas.width; | |
2875 | + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) | |
2876 | + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(i)], 0, 0); | |
2877 | + } | |
2867 | 2878 | } |
2868 | - } | |
2869 | - for (var i = 4; i <= $rootScope.grayImageMRDataList.length; i++) { | |
2870 | - var grayCanvasMRID = 'imageCanvas' + i+'_MR'; | |
2871 | - var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
2879 | + for (var i = 4; i <= $rootScope.grayImageMRDataList.length; i++) { | |
2880 | + var grayCanvasMRID = 'imageCanvas' + i + '_MR'; | |
2881 | + var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
2872 | 2882 | |
2873 | - if (grayCanvasMR != null) { | |
2874 | - var grayCanvasContextMR = grayCanvasMR.getContext("2d"); | |
2883 | + if (grayCanvasMR != null) { | |
2884 | + var grayCanvasContextMR = grayCanvasMR.getContext("2d"); | |
2875 | 2885 | |
2876 | - var canvasHeight = grayCanvasMR.height; | |
2877 | - var canvasWidth = grayCanvasMR.width; | |
2878 | - grayCanvasContextMR.clearRect(0, 0, canvasHeight, canvasWidth) | |
2879 | - grayCanvasContextMR.putImageData($rootScope.grayImageMRDataList[parseInt(i)], 0, 0); | |
2886 | + var canvasHeight = grayCanvasMR.height; | |
2887 | + var canvasWidth = grayCanvasMR.width; | |
2888 | + grayCanvasContextMR.clearRect(0, 0, canvasHeight, canvasWidth) | |
2889 | + grayCanvasContextMR.putImageData($rootScope.grayImageMRDataList[parseInt(i)], 0, 0); | |
2890 | + } | |
2880 | 2891 | } |
2881 | - } | |
2882 | 2892 | |
2883 | - angular.forEach($rootScope.macthedTermList, function (value, key) { | |
2893 | + angular.forEach($rootScope.macthedTermList, function (value, key) { | |
2884 | 2894 | |
2885 | 2895 | |
2886 | - var TermExistInBodyRegionId = value.bodyRegionId; | |
2887 | - console.log('3. HighlightBodyByTermListForBodySystem is called TermExistInBodyRegionId=' + TermExistInBodyRegionId); | |
2888 | - if (TermExistInBodyRegionId != undefined) { | |
2889 | - if (prevBRID != TermExistInBodyRegionId) { | |
2896 | + var TermExistInBodyRegionId = value.bodyRegionId; | |
2897 | + console.log('3. HighlightBodyByTermListForBodySystem is called TermExistInBodyRegionId=' + TermExistInBodyRegionId); | |
2898 | + if (TermExistInBodyRegionId != undefined) { | |
2899 | + if (prevBRID != TermExistInBodyRegionId) { | |
2890 | 2900 | |
2891 | 2901 | |
2892 | - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; | |
2893 | - var grayCanvas = document.getElementById(grayCanvasID); | |
2902 | + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; | |
2903 | + var grayCanvas = document.getElementById(grayCanvasID); | |
2894 | 2904 | |
2895 | - if (grayCanvas != null) { | |
2905 | + if (grayCanvas != null) { | |
2896 | 2906 | |
2897 | - var grayCanvasContext = grayCanvas.getContext("2d"); | |
2907 | + var grayCanvasContext = grayCanvas.getContext("2d"); | |
2898 | 2908 | |
2899 | - var canvasHeight = grayCanvas.height; | |
2900 | - var canvasWidth = grayCanvas.width; | |
2901 | - var canvasX = grayCanvas.style.left; | |
2902 | - var canvasY = grayCanvas.style.top; | |
2909 | + var canvasHeight = grayCanvas.height; | |
2910 | + var canvasWidth = grayCanvas.width; | |
2911 | + var canvasX = grayCanvas.style.left; | |
2912 | + var canvasY = grayCanvas.style.top; | |
2903 | 2913 | |
2904 | 2914 | |
2905 | - grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) | |
2906 | - grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0); | |
2915 | + grayCanvasContext.clearRect(0, 0, canvasHeight, canvasWidth) | |
2916 | + grayCanvasContext.putImageData($rootScope.grayImageDataList[parseInt(TermExistInBodyRegionId) - 1], 0, 0); | |
2907 | 2917 | |
2908 | - var gData = grayCanvasContext.getImageData(0, 0, canvasWidth, canvasHeight); | |
2918 | + var gData = grayCanvasContext.getImageData(0, 0, canvasWidth, canvasHeight); | |
2909 | 2919 | |
2910 | - //for mirror images | |
2911 | - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
2912 | - var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
2913 | - var grayCanvasMRX; | |
2914 | - var grayCanvasMRY; | |
2920 | + //for mirror images | |
2921 | + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
2922 | + var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
2923 | + var grayCanvasMRX; | |
2924 | + var grayCanvasMRY; | |
2915 | 2925 | |
2916 | - //draw a canvas for same bodyregion wich will be flipped after coloring the body system | |
2917 | - if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { | |
2926 | + //draw a canvas for same bodyregion wich will be flipped after coloring the body system | |
2927 | + if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { | |
2918 | 2928 | |
2919 | 2929 | |
2920 | - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
2921 | - var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
2922 | - grayCanvasMRX = grayCanvasMR.style.left; | |
2923 | - grayCanvasMRY = grayCanvasMR.style.top; | |
2930 | + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
2931 | + var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
2932 | + grayCanvasMRX = grayCanvasMR.style.left; | |
2933 | + grayCanvasMRY = grayCanvasMR.style.top; | |
2924 | 2934 | |
2925 | - var FlipedImgCanvas = document.createElement('canvas'); | |
2926 | - FlipedImgCanvas.height = canvasHeight; | |
2927 | - FlipedImgCanvas.width = canvasWidth; | |
2928 | - FlipedImgCanvas.setAttribute("data-IsMirrored", "Y") | |
2929 | - FlipedImgCanvas.style.position = "absolute"; | |
2930 | - FlipedImgCanvas.style.left = canvasX + "px"; | |
2931 | - FlipedImgCanvas.style.top = canvasY + "px"; | |
2932 | - FlipedImgCanvas.style.visibility = 'hidden'; | |
2933 | - FlipedImgCanvas.id = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
2935 | + var FlipedImgCanvas = document.createElement('canvas'); | |
2936 | + FlipedImgCanvas.height = canvasHeight; | |
2937 | + FlipedImgCanvas.width = canvasWidth; | |
2938 | + FlipedImgCanvas.setAttribute("data-IsMirrored", "Y") | |
2939 | + FlipedImgCanvas.style.position = "absolute"; | |
2940 | + FlipedImgCanvas.style.left = canvasX + "px"; | |
2941 | + FlipedImgCanvas.style.top = canvasY + "px"; | |
2942 | + FlipedImgCanvas.style.visibility = 'hidden'; | |
2943 | + FlipedImgCanvas.id = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
2934 | 2944 | |
2935 | - //remove previous canavs | |
2936 | - $('#' + grayCanvasMRID).remove(); | |
2945 | + //remove previous canavs | |
2946 | + $('#' + grayCanvasMRID).remove(); | |
2937 | 2947 | |
2938 | - //add new canvas on same location and after flipping it will be added to mirrored position | |
2939 | - document.getElementById('canvasDiv').appendChild(FlipedImgCanvas); | |
2940 | - //put grayData | |
2948 | + //add new canvas on same location and after flipping it will be added to mirrored position | |
2949 | + document.getElementById('canvasDiv').appendChild(FlipedImgCanvas); | |
2950 | + //put grayData | |
2941 | 2951 | |
2942 | - var filppedCanvasContx = FlipedImgCanvas.getContext("2d"); | |
2943 | - filppedCanvasContx.putImageData(gData, 0, 0); | |
2952 | + var filppedCanvasContx = FlipedImgCanvas.getContext("2d"); | |
2953 | + filppedCanvasContx.putImageData(gData, 0, 0); | |
2944 | 2954 | |
2945 | - } | |
2955 | + } | |
2946 | 2956 | |
2947 | - grayImageDataVar = null; | |
2948 | - var macthedData = new jinqJs() | |
2949 | - .from($rootScope.macthedTermList) | |
2950 | - .where('bodyRegionId == ' + TermExistInBodyRegionId) | |
2951 | - .select(); | |
2957 | + grayImageDataVar = null; | |
2958 | + var macthedData = new jinqJs() | |
2959 | + .from($rootScope.macthedTermList) | |
2960 | + .where('bodyRegionId == ' + TermExistInBodyRegionId) | |
2961 | + .select(); | |
2952 | 2962 | |
2953 | 2963 | |
2954 | 2964 | |
2955 | - var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1]; | |
2965 | + var coloredImageDataVar = $rootScope.coloredImageCanvasList[parseInt(TermExistInBodyRegionId) - 1]; | |
2956 | 2966 | |
2957 | - var grayImageDataValue = gData.data; | |
2958 | - var coloredImageDataValue = coloredImageDataVar.data; | |
2967 | + var grayImageDataValue = gData.data; | |
2968 | + var coloredImageDataValue = coloredImageDataVar.data; | |
2959 | 2969 | |
2960 | 2970 | |
2961 | - angular.forEach(macthedData, function (value2, key) { | |
2971 | + angular.forEach(macthedData, function (value2, key) { | |
2962 | 2972 | |
2963 | - $rootScope.termListWithLocation = value2.terms; | |
2973 | + $rootScope.termListWithLocation = value2.terms; | |
2964 | 2974 | |
2965 | - //pick the color from coloredImage data and put on gray imagedata | |
2966 | - angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) { | |
2975 | + //pick the color from coloredImage data and put on gray imagedata | |
2976 | + angular.forEach($rootScope.termListWithLocation.PixelLocations, function (value1, key1) { | |
2967 | 2977 | |
2968 | - var RED = coloredImageDataValue[value1]; | |
2969 | - var GREEN = coloredImageDataValue[value1 + 1]; | |
2970 | - var BLUE = coloredImageDataValue[value1 + 2]; | |
2978 | + var RED = coloredImageDataValue[value1]; | |
2979 | + var GREEN = coloredImageDataValue[value1 + 1]; | |
2980 | + var BLUE = coloredImageDataValue[value1 + 2]; | |
2971 | 2981 | |
2972 | - grayImageDataValue[value1] = RED; | |
2973 | - grayImageDataValue[value1 + 1] = GREEN; | |
2974 | - grayImageDataValue[value1 + 2] = BLUE; | |
2975 | - }) | |
2982 | + grayImageDataValue[value1] = RED; | |
2983 | + grayImageDataValue[value1 + 1] = GREEN; | |
2984 | + grayImageDataValue[value1 + 2] = BLUE; | |
2985 | + }) | |
2976 | 2986 | |
2977 | - //for non mirrored bpdy regions | |
2978 | - var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; | |
2979 | - var grayCanvas = document.getElementById(grayCanvasID); | |
2987 | + //for non mirrored bpdy regions | |
2988 | + var grayCanvasID = 'imageCanvas' + TermExistInBodyRegionId; | |
2989 | + var grayCanvas = document.getElementById(grayCanvasID); | |
2980 | 2990 | |
2981 | - if (grayCanvas != null) { | |
2991 | + if (grayCanvas != null) { | |
2982 | 2992 | |
2983 | - var grayCanvasContext = grayCanvas.getContext("2d"); | |
2993 | + var grayCanvasContext = grayCanvas.getContext("2d"); | |
2984 | 2994 | |
2985 | - grayCanvasContext.putImageData(gData, 0, 0); | |
2995 | + grayCanvasContext.putImageData(gData, 0, 0); | |
2986 | 2996 | |
2987 | - } | |
2997 | + } | |
2988 | 2998 | |
2989 | - //for mirror body regions | |
2990 | - if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { | |
2999 | + //for mirror body regions | |
3000 | + if (TermExistInBodyRegionId == 4 || TermExistInBodyRegionId == 5 || TermExistInBodyRegionId == 6) { | |
2991 | 3001 | |
2992 | - var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
3002 | + var grayCanvasMRID = 'imageCanvas' + TermExistInBodyRegionId + '_MR'; | |
2993 | 3003 | |
2994 | - var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
3004 | + var grayCanvasMR = document.getElementById(grayCanvasMRID); | |
2995 | 3005 | |
2996 | - if (grayCanvasMR != null) { | |
3006 | + if (grayCanvasMR != null) { | |
2997 | 3007 | |
2998 | - var grayCanvasMRContext = grayCanvasMR.getContext("2d"); | |
3008 | + var grayCanvasMRContext = grayCanvasMR.getContext("2d"); | |
2999 | 3009 | |
3000 | - grayCanvasMRContext.save(); | |
3001 | - grayCanvasMRContext.translate(canvasWidth, 0); | |
3002 | - grayCanvasMRContext.scale(-1, 1); | |
3003 | - //flip does not work with putImageData, that is why we used drawImage | |
3004 | - grayCanvasMRContext.drawImage(grayCanvas, 0, 0, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight); | |
3005 | - grayCanvasMRContext.restore(); | |
3010 | + grayCanvasMRContext.save(); | |
3011 | + grayCanvasMRContext.translate(canvasWidth, 0); | |
3012 | + grayCanvasMRContext.scale(-1, 1); | |
3013 | + //flip does not work with putImageData, that is why we used drawImage | |
3014 | + grayCanvasMRContext.drawImage(grayCanvas, 0, 0, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight); | |
3015 | + grayCanvasMRContext.restore(); | |
3006 | 3016 | |
3007 | - //set this canavs on the actual posution of mirror image | |
3008 | - grayCanvasMR.style.left = grayCanvasMRX; | |
3009 | - grayCanvasMR.style.top = grayCanvasMRY; | |
3010 | - grayCanvasMR.style.visibility = 'visible'; | |
3017 | + //set this canavs on the actual posution of mirror image | |
3018 | + grayCanvasMR.style.left = grayCanvasMRX; | |
3019 | + grayCanvasMR.style.top = grayCanvasMRY; | |
3020 | + grayCanvasMR.style.visibility = 'visible'; | |
3011 | 3021 | |
3012 | 3022 | |
3023 | + } | |
3013 | 3024 | } |
3014 | - } | |
3015 | 3025 | |
3016 | - $('#spinner').css('visibility', 'hidden') | |
3017 | - $rootScope.isLoading = false; | |
3026 | + $('#spinner').css('visibility', 'hidden') | |
3027 | + $rootScope.isLoading = false; | |
3018 | 3028 | |
3019 | - prevBRID = TermExistInBodyRegionId; | |
3020 | - }) | |
3029 | + prevBRID = TermExistInBodyRegionId; | |
3030 | + }) | |
3031 | + } | |
3021 | 3032 | } |
3022 | 3033 | } |
3023 | - } | |
3024 | - else { | |
3025 | - $('#spinner').css('visibility', 'hidden') | |
3026 | - $rootScope.isLoading = false; | |
3027 | - } | |
3034 | + else { | |
3035 | + $('#spinner').css('visibility', 'hidden') | |
3036 | + $rootScope.isLoading = false; | |
3037 | + } | |
3028 | 3038 | |
3029 | - }) | |
3039 | + }) | |
3040 | + | |
3041 | + } | |
3030 | 3042 | |
3031 | - } | |
3032 | 3043 | |
3033 | - | |
3034 | 3044 | |
3045 | + } | |
3035 | 3046 | }, |
3036 | 3047 | function (error) { |
3037 | 3048 | console.log(' Error in getting term data = ' + error.statusText); | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... | ... | @@ -90,6 +90,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
90 | 90 | $rootScope.passwordMismatchMessage; |
91 | 91 | $rootScope.isVisibleLogin; |
92 | 92 | $rootScope.haveRoleAdmin; |
93 | + $rootScope.checked = false; | |
94 | + $rootScope.licenseeAccountNumber = null; | |
93 | 95 | var isfilloptionChecked = ""; |
94 | 96 | var isOutlineOptionChecked = ""; |
95 | 97 | $rootScope.forgotPwdModalShow = function () |
... | ... | @@ -127,8 +129,10 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
127 | 129 | |
128 | 130 | function (result) { |
129 | 131 | if (result == 'true') { |
132 | + | |
130 | 133 | $rootScope.userModules = UserModules; |
131 | 134 | $rootScope.isVisibleLogin = false; |
135 | + $location.path('/'); | |
132 | 136 | } |
133 | 137 | else { |
134 | 138 | if (result == LoginConstants.USER_NOT_FOUND) { |
... | ... | @@ -147,8 +151,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
147 | 151 | else { |
148 | 152 | if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) { |
149 | 153 | |
150 | - if ($("#messageModal").length > 0){ | |
151 | - | |
154 | + if ($("#messageModal").length > 0){ | |
152 | 155 | $("#messageModal").modal('hide'); |
153 | 156 | } |
154 | 157 | if (result == LoginMessageConstants.INVALID_USER) { |
... | ... | @@ -164,16 +167,43 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
164 | 167 | $rootScope.haveRoleAdmin = false; |
165 | 168 | localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); |
166 | 169 | $('#dvUserModulesInfo').modal('show'); |
170 | + $location.path('/'); | |
167 | 171 | } |
168 | - //else if () | |
169 | - else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) { | |
172 | + //else if ((!result.IsSubscriptionExpired) && (result.UserType== UserTypeConstants.CLIENT_ADMIN || result.UserType== UserTypeConstants.DISTRICT_ADMIN || result.UserType== UserTypeConstants.SINGLE_USER ||result.UserType== UserTypeConstants.RESELLER) && result.License.IsTermAccepted) {} | |
170 | 173 | |
171 | - $rootScope.userData = result; | |
172 | - $rootScope.userModules = result.Modules; | |
173 | - $rootScope.isVisibleLogin = false; | |
174 | - $rootScope.haveRoleAdmin = true; | |
175 | - localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); | |
176 | - $('#dvUserModulesInfo').modal('show'); | |
174 | + else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) { | |
175 | + if (result.UserType == UserTypeConstants.CLIENT_ADMIN || result.UserType == UserTypeConstants.DISTRICT_ADMIN || result.UserType == UserTypeConstants.SINGLE_USER || result.UserType == UserTypeConstants.RESELLER) { | |
176 | + if (result.License.IsTermAccepted) { | |
177 | + $rootScope.userData = result; | |
178 | + $rootScope.userModules = result.Modules; | |
179 | + $rootScope.isVisibleLogin = false; | |
180 | + $rootScope.haveRoleAdmin = true; | |
181 | + $rootScope.licenseeAccountNumber = result.License.AccountNumber; | |
182 | + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); | |
183 | + $('#dvUserModulesInfo').modal('show'); | |
184 | + $location.path('/'); | |
185 | + } | |
186 | + else { | |
187 | + if ($('#dvTerms').length > 0) { | |
188 | + $('#dvTerms').html(result.TermsOfServiceText); | |
189 | + } | |
190 | + $rootScope.isVisibleLogin = true; | |
191 | + $('#dvTermCondition').fadeIn(); | |
192 | + $rootScope.userData = result; | |
193 | + $rootScope.userModules = result.Modules; | |
194 | + $rootScope.haveRoleAdmin = true; | |
195 | + $rootScope.licenseeAccountNumber = result.License.AccountNumber; | |
196 | + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); | |
197 | + } | |
198 | + } | |
199 | + else { | |
200 | + $rootScope.userData = result; | |
201 | + $rootScope.userModules = result.Modules; | |
202 | + $rootScope.isVisibleLogin = false; | |
203 | + $rootScope.haveRoleAdmin = true; | |
204 | + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); | |
205 | + $('#dvUserModulesInfo').modal('show'); | |
206 | + } | |
177 | 207 | } |
178 | 208 | else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) { |
179 | 209 | $rootScope.isVisibleLogin = true; |
... | ... | @@ -209,8 +239,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
209 | 239 | $("#messageModal").modal('show'); |
210 | 240 | } |
211 | 241 | } |
212 | - } | |
213 | - | |
242 | + } | |
214 | 243 | } |
215 | 244 | } |
216 | 245 | }, |
... | ... | @@ -224,6 +253,31 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
224 | 253 | } |
225 | 254 | |
226 | 255 | } |
256 | + $rootScope.UpdateLicenseTermStatus = function () { | |
257 | + $('#dvTermCondition').fadeOut(); | |
258 | + if($rootScope.licenseeAccountNumber !=null) { | |
259 | + | |
260 | + AuthenticationService.UpdateLicenseTerm($rootScope.licenseeAccountNumber) | |
261 | + .then(function (result) { | |
262 | + console.log(' Term and Condition acceptance status updated successfully.'); | |
263 | + | |
264 | + }, | |
265 | + function (error) { | |
266 | + console.log(' Error in Term and Condition acceptance status update = ' + error);//.statusText | |
267 | + }); | |
268 | + } | |
269 | + var currentUserDetails = localStorage.getItem('loggedInUserDetails'); | |
270 | + if (currentUserDetails) { | |
271 | + var userInfo = JSON.parse(currentUserDetails); | |
272 | + | |
273 | + if (userInfo.loginId != undefined || userInfo.loginId != "" || userInfo.loginId != null) { | |
274 | + $rootScope.isVisibleLogin = false; | |
275 | + $rootScope.userData = userInfo; | |
276 | + $rootScope.userModules = userInfo.Modules; | |
277 | + $('#dvUserModulesInfo').modal('show'); | |
278 | + } | |
279 | + } | |
280 | + }; | |
227 | 281 | function VerifyUrlForQuerystring() { |
228 | 282 | var url = $location.url(); |
229 | 283 | |
... | ... | @@ -247,8 +301,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
247 | 301 | $rootScope.isVisibleLogin = true; |
248 | 302 | } |
249 | 303 | |
250 | - function getUserDetails() { | |
251 | - //Retain logged in user details | |
304 | + function getUserDetails() { //Retain logged in user details | |
252 | 305 | var currentUserDetails = localStorage.getItem('loggedInUserDetails'); |
253 | 306 | if (currentUserDetails) { |
254 | 307 | try { |
... | ... | @@ -3234,7 +3287,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic |
3234 | 3287 | $("#optionsListManagerTab").removeClass("active"); |
3235 | 3288 | console.log('close'); |
3236 | 3289 | $rootScope.disableAnnotationtoolOnListManager = false; |
3237 | - if ($rootScope.MenuModuleName == "DA") { | |
3290 | + if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") { | |
3238 | 3291 | $("#annotationpaintbrushsize").attr("href", "#canvasPaint"); |
3239 | 3292 | $("#annotationpainteraser").attr("href", "#canvasPaint"); |
3240 | 3293 | if ($rootScope.disableAnnotationtoolOnListManager == false) { | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
... | ... | @@ -13,6 +13,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
13 | 13 | $scope.dragableId = ""; |
14 | 14 | $scope.blReviewAttempt = false; |
15 | 15 | $scope.$on('$viewContentLoaded', function (event) { |
16 | + if ($rootScope.refreshcheck == null) { | |
17 | + $location.path('/'); | |
18 | + } | |
16 | 19 | // code that will be executed ... |
17 | 20 | // every time this view is loaded |
18 | 21 | |
... | ... | @@ -88,6 +91,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location |
88 | 91 | |
89 | 92 | |
90 | 93 | $scope.GetQuizByTopic = function () { |
94 | + if ($rootScope.refreshcheck == null) { | |
95 | + $location.path('/'); | |
96 | + } | |
91 | 97 | var keywords = $location.search(); |
92 | 98 | $scope.LabExerciseName = keywords.labexercise; |
93 | 99 | $scope.LabExerciseModules = null; | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/LinkController.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | -AIA.controller("LinkController", ["$scope", "$rootScope","$log", "pages", "$routeParams", | |
4 | -function ($scope, $rootScope, log, pages, $routeParams) { | |
3 | +AIA.controller("LinkController", ["$scope", "$rootScope", "$log", "$location", "pages", "$routeParams", | |
4 | +function ($scope, $rootScope, log, $location, pages, $routeParams) { | |
5 | 5 | |
6 | 6 | //$rootScope.currentActiveModuleTitle = Modules[10].Name; |
7 | 7 | //$rootScope.currentActiveModuleTitle = $routeParams.modname; |
... | ... | @@ -17,6 +17,10 @@ function ($scope, $rootScope, log, pages, $routeParams) { |
17 | 17 | ]; |
18 | 18 | |
19 | 19 | $scope.$on('$viewContentLoaded', function (event) { |
20 | + | |
21 | + if ($rootScope.refreshcheck == null) { | |
22 | + $location.path('/'); | |
23 | + } | |
20 | 24 | // code that will be executed ... |
21 | 25 | // every time this view is loaded |
22 | 26 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js
... | ... | @@ -86,13 +86,28 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou |
86 | 86 | var moduleItemDataToBeSavedID = localStorage.getItem("listViewSelectedID"); |
87 | 87 | $("#list-view table tbody #" + moduleItemDataToBeSavedID).addClass("active"); |
88 | 88 | $scope.isListViewButtonClicked = true; |
89 | + var curAAListViewScroll = localStorage.getItem("AAListViewScroll"); | |
90 | + | |
91 | + if (typeof (curAAListViewScroll) !== "undefined" && curAAListViewScroll !== null && curAAListViewScroll !== '') { | |
92 | + if (typeof InstallTrigger !== 'undefined') { | |
93 | + | |
94 | + $('#list-view table tbody').animate({ scrollTop: localStorage.getItem("AAListViewScroll") }); | |
95 | + } | |
96 | + else { | |
97 | + | |
98 | + $('#list-view table tbody').scrollTop(localStorage.getItem("AAListViewScroll")); | |
99 | + } | |
100 | + | |
101 | + } | |
89 | 102 | // } |
90 | 103 | }, 2000); |
91 | 104 | } |
92 | 105 | }; |
93 | 106 | |
94 | 107 | $scope.loadForModuleById = function (moduleId) { |
95 | - | |
108 | + if ($rootScope.refreshcheck == null) { | |
109 | + $location.path('/'); | |
110 | + } | |
96 | 111 | $scope.moduleId = moduleId; |
97 | 112 | $scope.activeTab = 1; |
98 | 113 | console.log('loadForModuleById is called') |
... | ... | @@ -107,7 +122,10 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou |
107 | 122 | function (result) { |
108 | 123 | |
109 | 124 | $scope.moduleLandingData = result; |
110 | - | |
125 | + // setTimeout(function () { $('#' + $rootScope.highlightid).find('.thumbnail').addClass('hightlightstate'); }, 100); | |
126 | + if (localStorage.getItem('AAGridViewHighlightThumbnail') !== null) { | |
127 | + setTimeout(function () { $('#' + localStorage.getItem("AAGridViewHighlightThumbnail")).find('.thumbnail').addClass('HightLightThumbnail'); }, 100); | |
128 | + } | |
111 | 129 | //console.log(JSON.stringify(result, null, 4)); |
112 | 130 | }, |
113 | 131 | function (error) { |
... | ... | @@ -127,8 +145,8 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou |
127 | 145 | //}); |
128 | 146 | $scope.isOpenBtnClicked = false; |
129 | 147 | $scope.openModuleItemView = function (event) { |
130 | - | |
131 | - localStorage.setItem("activeTab", $scope.activeTab); | |
148 | + $rootScope.MenuModuleName = "AA"; | |
149 | + localStorage.setItem("activeTab", $scope.activeTab); | |
132 | 150 | //0. Get selected Image Id |
133 | 151 | if ($scope.isListViewButtonClicked == true) { |
134 | 152 | if ($scope.isOpenBtnClicked == true) { |
... | ... | @@ -163,6 +181,8 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou |
163 | 181 | //3. set opened module item ti |
164 | 182 | localStorage.setItem("currentViewTitle", $rootScope.OpenedTileData[6]); |
165 | 183 | localStorage.setItem("AAGridViewScroll", $($window).scrollTop()); |
184 | + localStorage.setItem("AAGridViewHighlightThumbnail", $(event.target).parent().parent().parent().attr('id')); | |
185 | + | |
166 | 186 | //3. Navigate to the Module-item-view |
167 | 187 | var u = $location.url(); |
168 | 188 | $location.url('/module-item-view'); |
... | ... | @@ -176,6 +196,7 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou |
176 | 196 | $("#list-view table tbody tr").removeClass("active"); |
177 | 197 | localStorage.setItem("listViewSelectedID", moduleItemDataToBeSavedID); |
178 | 198 | $("#list-view table tbody #" + moduleItemDataToBeSavedID).addClass("active"); |
199 | + localStorage.setItem("AAListViewScroll", $("#list-view table tbody").scrollTop()); | |
179 | 200 | var moduleItemDataToBeSaved = $("#list-view table tbody #" + moduleItemDataToBeSavedID).find('td:eq(0)').text(); |
180 | 201 | $rootScope.OpenedTileData = ModuleService.GetOpenedTileData(moduleItemDataToBeSaved, $scope.moduleLandingData); |
181 | 202 | $rootScope.OpenItemImagePath = "../../../content/images/aa/images/" + $rootScope.OpenedTileData[3]; |
... | ... | @@ -186,6 +207,9 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou |
186 | 207 | |
187 | 208 | |
188 | 209 | $scope.openModuleItem = function () { |
210 | + if ($rootScope.refreshcheck == null) { | |
211 | + $location.path('/'); | |
212 | + } | |
189 | 213 | var jsContentURL; |
190 | 214 | var moduleItemViewDivId; |
191 | 215 | |
... | ... | @@ -247,9 +271,8 @@ function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeou |
247 | 271 | if (document.getElementById('aaDetailPageDiv') != null) { |
248 | 272 | |
249 | 273 | //0.4 added some stylesheets |
250 | - $('.aaBodyView').css("height", $(window).outerHeight() - $('.navbar-fixed-top').height()); | |
251 | - $('.aaBodyView').css("width", $(window).outerWidth()); | |
252 | - $rootScope.canvasDivHeight = $('.aaBodyView').height(); | |
274 | + | |
275 | + $rootScope.canvasDivHeight = $('.jsPanel-content').height() - $('.main2 .stickey-area').height(); | |
253 | 276 | |
254 | 277 | $('.canvasDivClass').css("height", $rootScope.canvasDivHeight); |
255 | 278 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js
... | ... | @@ -54,5 +54,23 @@ |
54 | 54 | return deferred.promise; |
55 | 55 | }, |
56 | 56 | |
57 | + UpdateLicenseTerm: function (licenseeAccountNumber) { | |
58 | + var deferred = $q.defer(); | |
59 | + | |
60 | + $http.post('/API/api/LicenseTermCondition', JSON.stringify(licenseeAccountNumber), { | |
61 | + headers: { | |
62 | + 'Content-Type': 'application/json' | |
63 | + } | |
64 | + }) | |
65 | + .success(function (data, status, headers, config) { | |
66 | + console.log('success') | |
67 | + deferred.resolve(data); | |
68 | + }).error(function (data, status, headers, config) { | |
69 | + console.log('error') | |
70 | + deferred.reject(status); | |
71 | + }); | |
72 | + return deferred.promise; | |
73 | + } | |
74 | + | |
57 | 75 | } |
58 | 76 | }); |
59 | 77 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/views/aa/atlas-anatomy-detail.html
400-SOURCECODE/AIAHTML5.Web/index.html
... | ... | @@ -1298,6 +1298,32 @@ |
1298 | 1298 | </div> |
1299 | 1299 | </div> |
1300 | 1300 | |
1301 | + <!-- Terms & Condition Modal --> | |
1302 | + <div class=" fade ui-draggable in" id="dvTermCondition" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="padding-left: 17px; display: none; left: 0px !important; z-index: 111111; position: fixed; top: 0; overflow-x: hidden; overflow-y: auto; right: 0px; bottom: 0px; "> | |
1303 | + <div class="modal-dialog" role="document"> | |
1304 | + <div class="modal-content"> | |
1305 | + <div class="modal-header ui-draggable-handle " style="color: #ffffff; background-color: #0095da; border-color: #007ab3;cursor:default;"> | |
1306 | + <!--color: #e5e5e5;--> | |
1307 | + <h6 class="text-left lhgt19 padd5" style="color:#fff; text-align:left;">Terms of Service</h6> | |
1308 | + </div> | |
1309 | + | |
1310 | + <div class="modal-body" style="width: 597px; height: 400px; overflow-x: auto;"> | |
1311 | + <div class="panel-body"> | |
1312 | + <div id="dvTerms" style="font-size: 13px;"></div> | |
1313 | + </div> | |
1314 | + </div> | |
1315 | + <div class="modal-footer ui-draggable-handle " style="color: #ffffff; cursor:default;"> <!--background-color: #0095da; border-color: #007ab3;--> | |
1316 | + <!-- form --> | |
1317 | + <form class="form-horizontal"> | |
1318 | + <!--<div class="form-group">--> | |
1319 | + <div style="clear: left; float: left; color: #000;"><input type="checkbox" id="chkAccept" ng-model="checked" style="vertical-align: top;"/> I accept</div> | |
1320 | + <div style="float: right;"><button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#mymodal" ng-disabled="!checked" data-dismiss="modal" ng-click="UpdateLicenseTermStatus()"><i class="fa fa-check"></i> Next</button></div> | |
1321 | + <!--</div>--> | |
1322 | + </form> | |
1323 | + </div> | |
1324 | + </div> | |
1325 | + </div> | |
1326 | + </div> | |
1301 | 1327 | <script> |
1302 | 1328 | |
1303 | 1329 | function enableDisableFillOption() { | ... | ... |
400-SOURCECODE/AIAHTML5.Web/libs/html2canvas.js
... | ... | @@ -2858,7 +2858,7 @@ _html2canvas.Renderer.Canvas = function(options) { |
2858 | 2858 | if (/*@cc_on!@*/false || !!document.documentMode) { |
2859 | 2859 | |
2860 | 2860 | var imgData = canvas.getContext("2d").getImageData(bounds.left, bounds.top, bounds.width, bounds.height); |
2861 | - ctx.putImageData(imgData, 50, 0); | |
2861 | + ctx.putImageData(imgData, 0, 0); | |
2862 | 2862 | } |
2863 | 2863 | else { |
2864 | 2864 | ... | ... |
400-SOURCECODE/AIAHTML5.Web/themes/default/css/bootstrap/3.3.6/main.css
400-SOURCECODE/AIAHTML5.sln
1 | 1 | |
2 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 |
3 | -# Visual Studio 14 | |
4 | -VisualStudioVersion = 14.0.25420.1 | |
3 | +# Visual Studio 2013 | |
4 | +VisualStudioVersion = 12.0.21005.1 | |
5 | 5 | MinimumVisualStudioVersion = 10.0.40219.1 |
6 | 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIAHTML5.API", "AIAHTML5.API\AIAHTML5.API.csproj", "{29B2F1D1-8B39-4B74-9874-7CB659800E3F}" |
7 | 7 | EndProject | ... | ... |
600-POC/fileSave/DBSAVe/Program.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading; | |
6 | +using System.Threading.Tasks; | |
7 | +//using log4net; | |
8 | +using MongoDB.Driver; | |
9 | +using System.IO; | |
10 | +using Newtonsoft.Json.Linq; | |
11 | +using MongoDB.Bson.Serialization.Attributes; | |
12 | +using MongoDB.Bson; | |
13 | + | |
14 | +namespace AIAHighlight.DBSave | |
15 | +{ | |
16 | + [BsonIgnoreExtraElements] | |
17 | + public class BodyRegionImage | |
18 | + { | |
19 | + public ObjectId _id { get; set; } | |
20 | + public string imageName; | |
21 | + public int bodyViewIndex; | |
22 | + public int layerNumber; | |
23 | + public int bodyRegionId; | |
24 | + public int zoom; | |
25 | + public List<Term> terms; | |
26 | + | |
27 | + public BodyRegionImage() | |
28 | + { | |
29 | + this.terms = new List<Term>(); | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + public class Term | |
34 | + { | |
35 | + public int TermNumber; | |
36 | + public List<int> SystemNumbers; | |
37 | + public List<int> PixelLocations; | |
38 | + public int ActualTermNumber; | |
39 | + | |
40 | + public Term(int termNumber, int systemNumber, int pixelLocation) | |
41 | + { | |
42 | + this.SystemNumbers = new List<int>(); | |
43 | + this.PixelLocations = new List<int>(); | |
44 | + this.TermNumber = termNumber; | |
45 | + this.SystemNumbers.Add(systemNumber); | |
46 | + this.PixelLocations.Add(pixelLocation); | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + | |
51 | + | |
52 | + | |
53 | + public class Program | |
54 | + { | |
55 | + //public JObject data { get; set; } | |
56 | + // public Dictionary<int, Term> termList; | |
57 | + | |
58 | + internal void saveImageData(JObject data, int bodyviewId) | |
59 | + { | |
60 | + // DateTime datetime = new DateTime(); | |
61 | + Console.WriteLine("AT "+ DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz")+"..In saveImageData. for imageName: "+ data["imageName"].ToString()+ ",bodyViewIndex= "+ data["bodyViewIndex"]+ ",layerNumber: "+ | |
62 | + data["layerNumber"]+ ",bodyRegionId= "+ data["bodyRegion"]); | |
63 | + try | |
64 | + { | |
65 | + BodyRegionImage bodyRegionImage = new BodyRegionImage(); | |
66 | + | |
67 | + var client = new MongoClient(); | |
68 | + | |
69 | + //var db = client.GetDatabase("AIADB_bodyviewId"+bodyviewId.ToString()); | |
70 | + var db = client.GetDatabase("aia"); | |
71 | + | |
72 | + var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
73 | + | |
74 | + JObject imageData = data; | |
75 | + | |
76 | + | |
77 | + | |
78 | + string bodyViewIndex = data["bodyViewIndex"].ToString(); | |
79 | + | |
80 | + string termFilePath = @"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\bodyViewsData\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
81 | + //string termFilePath = @"D:\100-PROJECTS\008-AIAHighlight.FileSave\dist\assets\data\json\da\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
82 | + | |
83 | + string systemTermMapping; | |
84 | + using (StreamReader reader = new StreamReader(termFilePath)) | |
85 | + | |
86 | + // using (StreamReader reader = new StreamReader(path+fileName)) | |
87 | + { | |
88 | + systemTermMapping = reader.ReadToEnd(); | |
89 | + } | |
90 | + | |
91 | + JObject systemTermMappingObject = JObject.Parse(systemTermMapping); | |
92 | + | |
93 | + //Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + ".systemTermMappingObject created."); | |
94 | + | |
95 | + dynamic systemTerms = systemTermMappingObject["BodySystem"]["BodySystemTerm"]; | |
96 | + | |
97 | + dynamic imageDataArray = data["data"]; | |
98 | + | |
99 | + Dictionary<int,Term> termList = new Dictionary<int, Term>(); | |
100 | + | |
101 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..before itrating imageDataArray. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
102 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
103 | + | |
104 | + for (int i = 0; i < imageDataArray.Count; i += 4) | |
105 | + { | |
106 | + if(imageDataArray[i] == 0 && imageDataArray[i+1] == 0 && imageDataArray[i+2] == 0) | |
107 | + { | |
108 | + continue; | |
109 | + } | |
110 | + var RED = Convert.ToInt32(imageDataArray[i]) - 9; | |
111 | + var GREEN = Convert.ToInt32(imageDataArray[i + 1]) - 9; | |
112 | + var BLUE = Convert.ToInt32(imageDataArray[i + 2]) - 9; | |
113 | + | |
114 | + if (RED == -9 && GREEN == -9 && BLUE == -9) | |
115 | + continue; | |
116 | + | |
117 | + var Red = ""; | |
118 | + var Green = ""; | |
119 | + var Blue = ""; | |
120 | + string zero = "0"; | |
121 | + | |
122 | + if ((RED).ToString().Length != 2) | |
123 | + { | |
124 | + Red = zero + RED.ToString(); | |
125 | + } | |
126 | + else | |
127 | + { | |
128 | + Red = RED.ToString(); | |
129 | + } | |
130 | + if ((GREEN).ToString().Length != 2) | |
131 | + { | |
132 | + Green = zero + GREEN.ToString(); | |
133 | + } | |
134 | + else | |
135 | + { | |
136 | + Green = GREEN.ToString(); | |
137 | + } | |
138 | + if ((BLUE).ToString().Length != 2) | |
139 | + { | |
140 | + Blue = zero + BLUE.ToString(); | |
141 | + } | |
142 | + else | |
143 | + { | |
144 | + Blue = BLUE.ToString(); | |
145 | + } | |
146 | + | |
147 | + string Icolor = (Red + Green + Blue); | |
148 | + | |
149 | + | |
150 | + | |
151 | + foreach (dynamic systemTerm in systemTerms) | |
152 | + { | |
153 | + | |
154 | + int iColor = Convert.ToInt32(Icolor); | |
155 | + int termNumber = Convert.ToInt32(systemTerm._TermNumber.ToString()); | |
156 | + int systemNumber = Convert.ToInt32(systemTerm._SystemNumber.ToString()); | |
157 | + | |
158 | + if (systemTerm._TermNumber.ToString() == Icolor) | |
159 | + { | |
160 | + this.AddToTermList(termNumber, systemNumber, i, termList); | |
161 | + //this.AddToTermList(termNumber, systemNumber, i, termList); | |
162 | + this.AddToTermList(termNumber, systemNumber, i + 1, termList); | |
163 | + this.AddToTermList(termNumber, systemNumber, i + 2, termList); | |
164 | + break; | |
165 | + } | |
166 | + } | |
167 | + } | |
168 | + | |
169 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..after craeting termList.. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
170 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
171 | + | |
172 | + bodyRegionImage.imageName = data["imageName"].ToString(); | |
173 | + bodyRegionImage.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
174 | + bodyRegionImage.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
175 | + bodyRegionImage.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
176 | + bodyRegionImage.zoom = Convert.ToInt32(data["zoom"]); | |
177 | + | |
178 | + foreach (int key in termList.Keys) | |
179 | + { | |
180 | + bodyRegionImage.terms.Add(termList[key]); | |
181 | + } | |
182 | + | |
183 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "...inserting for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
184 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
185 | + | |
186 | + col.InsertOne(bodyRegionImage); | |
187 | + | |
188 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..inserted for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
189 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
190 | + | |
191 | + var logCol = db.GetCollection<BodyRegionImage>("DAImageLogs"); | |
192 | + | |
193 | + BodyRegionImage bodyRegionImageTolog = new BodyRegionImage(); | |
194 | + bodyRegionImageTolog.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
195 | + bodyRegionImageTolog.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
196 | + bodyRegionImageTolog.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
197 | + bodyRegionImageTolog.zoom = Convert.ToInt32(data["zoom"]); | |
198 | + | |
199 | + logCol.InsertOne(bodyRegionImageTolog); | |
200 | + | |
201 | + bodyRegionImageTolog = null; | |
202 | + | |
203 | + data = null; | |
204 | + termList = null; | |
205 | + systemTermMappingObject = null; | |
206 | + systemTerms = null; | |
207 | + } | |
208 | + catch(Exception ex) | |
209 | + { | |
210 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..Exception occured for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
211 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]+"... EXCEPTION= "+ex.Message+".. STACKTRACE= "+ex.StackTrace); | |
212 | + | |
213 | + } | |
214 | + | |
215 | + | |
216 | + } | |
217 | + | |
218 | + public void AddToTermList(int termNumber, int systemNumber, int pixelLocation,Dictionary<int, Term> termList) | |
219 | + { | |
220 | + if (!termList.ContainsKey(termNumber)) | |
221 | + { | |
222 | + termList.Add(termNumber, new Term(termNumber, systemNumber, pixelLocation)); | |
223 | + } | |
224 | + else | |
225 | + { | |
226 | + bool isSystemNumberExisting = false; | |
227 | + foreach (int sn in termList[termNumber].SystemNumbers) | |
228 | + { | |
229 | + if (systemNumber == sn) | |
230 | + { | |
231 | + isSystemNumberExisting = true; | |
232 | + break; | |
233 | + } | |
234 | + | |
235 | + } | |
236 | + if (!isSystemNumberExisting) | |
237 | + termList[termNumber].SystemNumbers.Add(systemNumber); | |
238 | + | |
239 | + bool isPixelLocationExisting = false; | |
240 | + foreach (int pl in termList[termNumber].PixelLocations) | |
241 | + { | |
242 | + if (pixelLocation == pl) | |
243 | + { | |
244 | + isPixelLocationExisting = true; | |
245 | + break; | |
246 | + } | |
247 | + | |
248 | + } | |
249 | + if (!isPixelLocationExisting) | |
250 | + termList[termNumber].PixelLocations.Add(pixelLocation); | |
251 | + | |
252 | + } | |
253 | + } | |
254 | + | |
255 | + | |
256 | + | |
257 | + | |
258 | + static void Main(string[] args) | |
259 | + { | |
260 | + | |
261 | + Console.WriteLine("Enter BodyViewId"); | |
262 | + int BodyViewIndex = Convert.ToInt32(Console.ReadLine()); | |
263 | + | |
264 | + Program program = new Program(); | |
265 | + program.getAlreadyInsertedLayer(BodyViewIndex.ToString()); | |
266 | + program = null; | |
267 | + | |
268 | + } | |
269 | + | |
270 | + internal void getAlreadyInsertedLayer(string bodyviewId) | |
271 | + { | |
272 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "inside getAlreadyInsertedLayer"); | |
273 | + int totalLayers = 0; | |
274 | + int [] totalBodyReigons =null; | |
275 | + List<int> bodyRegions = new List<int>(); | |
276 | + | |
277 | + switch (Convert.ToInt32(bodyviewId)) | |
278 | + { | |
279 | + case 1: | |
280 | + totalLayers = 330; | |
281 | + totalBodyReigons = new int[6] {1,2,3,4,5,6}; | |
282 | + bodyRegions.Add(1); | |
283 | + bodyRegions.Add(2); | |
284 | + bodyRegions.Add(3); | |
285 | + bodyRegions.Add(4); | |
286 | + bodyRegions.Add(5); | |
287 | + bodyRegions.Add(6); | |
288 | + break; | |
289 | + case 2: | |
290 | + totalLayers = 288; | |
291 | + bodyRegions.Add(1); | |
292 | + bodyRegions.Add(2); | |
293 | + bodyRegions.Add(3); | |
294 | + bodyRegions.Add(4); | |
295 | + bodyRegions.Add(5); | |
296 | + break; | |
297 | + case 3: | |
298 | + totalLayers = 127; | |
299 | + bodyRegions.Add(1); | |
300 | + bodyRegions.Add(2); | |
301 | + bodyRegions.Add(3); | |
302 | + bodyRegions.Add(4); | |
303 | + bodyRegions.Add(5); | |
304 | + break; | |
305 | + case 4: | |
306 | + totalLayers = 186; | |
307 | + bodyRegions.Add(1); | |
308 | + bodyRegions.Add(2); | |
309 | + bodyRegions.Add(3); | |
310 | + bodyRegions.Add(4); | |
311 | + bodyRegions.Add(5); | |
312 | + bodyRegions.Add(6); | |
313 | + break; | |
314 | + case 5: | |
315 | + totalLayers = 229; | |
316 | + bodyRegions.Add(1); | |
317 | + bodyRegions.Add(2); | |
318 | + bodyRegions.Add(3); | |
319 | + bodyRegions.Add(4); | |
320 | + bodyRegions.Add(5); | |
321 | + bodyRegions.Add(6); | |
322 | + break; | |
323 | + case 6: | |
324 | + totalLayers = 289; | |
325 | + bodyRegions.Add(1); | |
326 | + bodyRegions.Add(2); | |
327 | + bodyRegions.Add(3); | |
328 | + bodyRegions.Add(4); | |
329 | + bodyRegions.Add(5); | |
330 | + | |
331 | + break; | |
332 | + case 7: | |
333 | + totalLayers = 130; | |
334 | + | |
335 | + bodyRegions.Add(1); | |
336 | + bodyRegions.Add(2); | |
337 | + bodyRegions.Add(3); | |
338 | + bodyRegions.Add(4); | |
339 | + bodyRegions.Add(5); | |
340 | + | |
341 | + break; | |
342 | + case 8: | |
343 | + totalLayers = 186; | |
344 | + | |
345 | + bodyRegions.Add(1); | |
346 | + bodyRegions.Add(2); | |
347 | + bodyRegions.Add(3); | |
348 | + bodyRegions.Add(4); | |
349 | + bodyRegions.Add(5); | |
350 | + bodyRegions.Add(6); | |
351 | + break; | |
352 | + case 9: | |
353 | + totalLayers = 64; | |
354 | + bodyRegions.Add(6); | |
355 | + break; | |
356 | + case 10: | |
357 | + totalLayers = 72; | |
358 | + bodyRegions.Add(6); | |
359 | + break; | |
360 | + case 11: | |
361 | + totalLayers = 64; | |
362 | + bodyRegions.Add(6); | |
363 | + break; | |
364 | + case 12: | |
365 | + totalLayers = 72; | |
366 | + bodyRegions.Add(6); | |
367 | + break; | |
368 | + } | |
369 | + | |
370 | + var client = new MongoClient(); | |
371 | + // var db = client.GetDatabase("AIADB_bodyviewId" + bodyviewId.ToString()); | |
372 | + var db = client.GetDatabase("aia"); | |
373 | + | |
374 | + var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
375 | + //var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
376 | + | |
377 | + | |
378 | + FilterDefinition<BodyRegionImage>[] filterCondition = { | |
379 | + Builders<BodyRegionImage>.Filter.Eq("bodyViewIndex", Convert.ToInt32(bodyviewId))}; | |
380 | + | |
381 | + dynamic list = col.Find(Builders<BodyRegionImage>.Filter.And(filterCondition)).Project(Builders<BodyRegionImage>.Projection.Include("layerNumber").Include("bodyRegionId")).ToList(); | |
382 | + Console.WriteLine("already inserted record count: " + list.Count); | |
383 | + | |
384 | + Dictionary<int, List<int>> layersToProcess = new Dictionary<int, List<int>>(); | |
385 | + | |
386 | + for (int i = 1; i <= totalLayers; i++) | |
387 | + { | |
388 | + List<int> bodyRegionForThisLayer = new List<int>(); | |
389 | + switch (Convert.ToInt32(bodyviewId)) | |
390 | + { | |
391 | + case 1: | |
392 | + bodyRegionForThisLayer.Add(1); | |
393 | + bodyRegionForThisLayer.Add(2); | |
394 | + bodyRegionForThisLayer.Add(3); | |
395 | + bodyRegionForThisLayer.Add(4); | |
396 | + bodyRegionForThisLayer.Add(5); | |
397 | + bodyRegionForThisLayer.Add(6); | |
398 | + break; | |
399 | + case 2: | |
400 | + bodyRegionForThisLayer.Add(1); | |
401 | + bodyRegionForThisLayer.Add(2); | |
402 | + bodyRegionForThisLayer.Add(3); | |
403 | + bodyRegionForThisLayer.Add(4); | |
404 | + bodyRegionForThisLayer.Add(5); | |
405 | + break; | |
406 | + case 3: | |
407 | + bodyRegionForThisLayer.Add(1); | |
408 | + bodyRegionForThisLayer.Add(2); | |
409 | + bodyRegionForThisLayer.Add(3); | |
410 | + bodyRegionForThisLayer.Add(4); | |
411 | + bodyRegionForThisLayer.Add(5); | |
412 | + break; | |
413 | + case 4: | |
414 | + bodyRegionForThisLayer.Add(1); | |
415 | + bodyRegionForThisLayer.Add(2); | |
416 | + bodyRegionForThisLayer.Add(3); | |
417 | + bodyRegionForThisLayer.Add(4); | |
418 | + bodyRegionForThisLayer.Add(5); | |
419 | + bodyRegionForThisLayer.Add(6); | |
420 | + break; | |
421 | + case 5: | |
422 | + bodyRegionForThisLayer.Add(1); | |
423 | + bodyRegionForThisLayer.Add(2); | |
424 | + bodyRegionForThisLayer.Add(3); | |
425 | + bodyRegionForThisLayer.Add(4); | |
426 | + bodyRegionForThisLayer.Add(5); | |
427 | + bodyRegionForThisLayer.Add(6); | |
428 | + break; | |
429 | + case 6: | |
430 | + bodyRegionForThisLayer.Add(1); | |
431 | + bodyRegionForThisLayer.Add(2); | |
432 | + bodyRegionForThisLayer.Add(3); | |
433 | + bodyRegionForThisLayer.Add(4); | |
434 | + bodyRegionForThisLayer.Add(5); | |
435 | + | |
436 | + break; | |
437 | + case 7: | |
438 | + bodyRegionForThisLayer.Add(1); | |
439 | + bodyRegionForThisLayer.Add(2); | |
440 | + bodyRegionForThisLayer.Add(3); | |
441 | + bodyRegionForThisLayer.Add(4); | |
442 | + bodyRegionForThisLayer.Add(5); | |
443 | + | |
444 | + break; | |
445 | + case 8: | |
446 | + bodyRegionForThisLayer.Add(1); | |
447 | + bodyRegionForThisLayer.Add(2); | |
448 | + bodyRegionForThisLayer.Add(3); | |
449 | + bodyRegionForThisLayer.Add(4); | |
450 | + bodyRegionForThisLayer.Add(5); | |
451 | + bodyRegionForThisLayer.Add(6); | |
452 | + break; | |
453 | + } | |
454 | + | |
455 | + int previousLayerNumber = 0; | |
456 | + int existingLayerNumber = 0; | |
457 | + bool isLayerMatched = false; | |
458 | + | |
459 | + foreach (dynamic lNumber in list) | |
460 | + { | |
461 | + existingLayerNumber = Convert.ToInt32((lNumber.GetValue("layerNumber")).ToString()); | |
462 | + | |
463 | + if (existingLayerNumber == i) | |
464 | + { | |
465 | + isLayerMatched = true; | |
466 | + int existingBodyRegionId = Convert.ToInt32((lNumber.GetValue("bodyRegionId")).ToString()); | |
467 | + | |
468 | + | |
469 | + if (bodyRegionForThisLayer.Contains(existingBodyRegionId)) { | |
470 | + //remove from bodyRegions list as this is already present | |
471 | + bodyRegionForThisLayer.Remove(existingBodyRegionId); | |
472 | + } | |
473 | + previousLayerNumber = existingLayerNumber; | |
474 | + | |
475 | + } | |
476 | + | |
477 | + else | |
478 | + { | |
479 | + | |
480 | + } | |
481 | + | |
482 | + } | |
483 | + if(isLayerMatched) | |
484 | + layersToProcess.Add(previousLayerNumber, bodyRegionForThisLayer); | |
485 | + else | |
486 | + layersToProcess.Add(i, bodyRegionForThisLayer); | |
487 | + } | |
488 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "after preparing list to process files To Process count: "+ layersToProcess.Count); | |
489 | + | |
490 | + makeFileNameAndProcess(layersToProcess,Convert.ToInt32(bodyviewId)); | |
491 | + } | |
492 | + | |
493 | + | |
494 | + internal void makeFileNameAndProcess(Dictionary<int, List<int>> filesToProcess, int BodyViewIndex) | |
495 | + { | |
496 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "in makeFileNameAndProcess"); | |
497 | + | |
498 | + foreach (KeyValuePair<int, List<int>> pair in filesToProcess) | |
499 | + { | |
500 | + | |
501 | + | |
502 | + foreach (int item in pair.Value) | |
503 | + { | |
504 | + string fileName = "BodyView" + BodyViewIndex + "_layer" + pair.Key + "_bodyRegionId" + item+".json"; | |
505 | + | |
506 | + //string filePath = @"D:\100-PROJECTS\008-AIAHighlight.FileSave\AIAHighlight\AIAHighlight\data\" + fileName; | |
507 | + string filePath = @"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\data\" + fileName; | |
508 | + getDataFromFileAndSaveInDB(filePath, BodyViewIndex); | |
509 | + } | |
510 | + | |
511 | + } | |
512 | + } | |
513 | + | |
514 | + internal void processFiles(string[] files,int bodyviewId) | |
515 | + { | |
516 | + | |
517 | + //without multithreading | |
518 | + foreach(string filename in files) | |
519 | + { | |
520 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "in processFiles for filename"); | |
521 | + getDataFromFileAndSaveInDB(filename, bodyviewId); | |
522 | + } | |
523 | + | |
524 | + } | |
525 | + | |
526 | + | |
527 | + | |
528 | + internal void getDataFromFileAndSaveInDB(string filePath,int bodyViewId) | |
529 | + { | |
530 | + if (File.Exists(filePath)) | |
531 | + { | |
532 | + string fileData; | |
533 | + using (StreamReader reader = new StreamReader(filePath)) | |
534 | + { | |
535 | + fileData = reader.ReadToEnd(); | |
536 | + | |
537 | + JObject data = JObject.Parse(fileData); | |
538 | + this.saveImageData(data, bodyViewId); | |
539 | + } | |
540 | + | |
541 | + | |
542 | + } | |
543 | + else | |
544 | + { | |
545 | + Console.WriteLine("FILE.NOT.FOUND AT" + | |
546 | + ": " + filePath); | |
547 | + | |
548 | + } | |
549 | + } | |
550 | + } | |
551 | +} | ... | ... |
600-POC/fileSave/DBSAVe/Program_20Threadsfor25Zoom.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading; | |
6 | +using System.Threading.Tasks; | |
7 | +//using log4net; | |
8 | +using MongoDB.Driver; | |
9 | +using System.IO; | |
10 | +using Newtonsoft.Json.Linq; | |
11 | +using MongoDB.Bson.Serialization.Attributes; | |
12 | +using MongoDB.Bson; | |
13 | + | |
14 | +namespace AIAHighlight.DBSave | |
15 | +{ | |
16 | + [BsonIgnoreExtraElements] | |
17 | + public class BodyRegionImage | |
18 | + { | |
19 | + public ObjectId _id { get; set; } | |
20 | + public string imageName; | |
21 | + public int bodyViewIndex; | |
22 | + public int layerNumber; | |
23 | + public int bodyRegionId; | |
24 | + public int zoom; | |
25 | + public List<Term> terms; | |
26 | + | |
27 | + public BodyRegionImage() | |
28 | + { | |
29 | + this.terms = new List<Term>(); | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + public class Term | |
34 | + { | |
35 | + public int TermNumber; | |
36 | + public List<int> SystemNumbers; | |
37 | + public List<int> PixelLocations; | |
38 | + public int ActualTermNumber; | |
39 | + | |
40 | + public Term(int termNumber, int systemNumber, int pixelLocation) | |
41 | + { | |
42 | + this.SystemNumbers = new List<int>(); | |
43 | + this.PixelLocations = new List<int>(); | |
44 | + this.TermNumber = termNumber; | |
45 | + this.SystemNumbers.Add(systemNumber); | |
46 | + this.PixelLocations.Add(pixelLocation); | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + | |
51 | + | |
52 | + | |
53 | + public class Program | |
54 | + { | |
55 | + //public JObject data { get; set; } | |
56 | + // public Dictionary<int, Term> termList; | |
57 | + | |
58 | + internal void saveImageData(JObject data) | |
59 | + { | |
60 | + // DateTime datetime = new DateTime(); | |
61 | + Console.WriteLine("AT "+ DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz")+"..In saveImageData. for imageName: "+ data["imageName"].ToString()+ ",bodyViewIndex= "+ data["bodyViewIndex"]+ ",layerNumber: "+ | |
62 | + data["layerNumber"]+ ",bodyRegionId= "+ data["bodyRegion"]); | |
63 | + try | |
64 | + { | |
65 | + BodyRegionImage bodyRegionImage = new BodyRegionImage(); | |
66 | + | |
67 | + var client = new MongoClient(); | |
68 | + | |
69 | + var db = client.GetDatabase("AIAImageData_25"); | |
70 | + | |
71 | + var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
72 | + | |
73 | + JObject imageData = data; | |
74 | + | |
75 | + | |
76 | + | |
77 | + string bodyViewIndex = data["bodyViewIndex"].ToString(); | |
78 | + | |
79 | + string termFilePath = @"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\bodyViewsData\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
80 | + //string termFilePath = @"D:\100-PROJECTS\008-AIAHighlight.FileSave\dist\assets\data\json\da\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
81 | + | |
82 | + string systemTermMapping; | |
83 | + using (StreamReader reader = new StreamReader(termFilePath)) | |
84 | + | |
85 | + // using (StreamReader reader = new StreamReader(path+fileName)) | |
86 | + { | |
87 | + systemTermMapping = reader.ReadToEnd(); | |
88 | + } | |
89 | + | |
90 | + JObject systemTermMappingObject = JObject.Parse(systemTermMapping); | |
91 | + | |
92 | + //Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + ".systemTermMappingObject created."); | |
93 | + | |
94 | + dynamic systemTerms = systemTermMappingObject["BodySystem"]["BodySystemTerm"]; | |
95 | + | |
96 | + dynamic imageDataArray = data["data"]; | |
97 | + | |
98 | + Dictionary<int,Term> termList = new Dictionary<int, Term>(); | |
99 | + | |
100 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..before itrating imageDataArray. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
101 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
102 | + | |
103 | + for (int i = 0; i < imageDataArray.Count; i += 4) | |
104 | + { | |
105 | + if(imageDataArray[i] == 0 && imageDataArray[i+1] == 0 && imageDataArray[i+2] == 0) | |
106 | + { | |
107 | + continue; | |
108 | + } | |
109 | + var RED = Convert.ToInt32(imageDataArray[i]) - 9; | |
110 | + var GREEN = Convert.ToInt32(imageDataArray[i + 1]) - 9; | |
111 | + var BLUE = Convert.ToInt32(imageDataArray[i + 2]) - 9; | |
112 | + | |
113 | + if (RED == -9 && GREEN == -9 && BLUE == -9) | |
114 | + continue; | |
115 | + | |
116 | + var Red = ""; | |
117 | + var Green = ""; | |
118 | + var Blue = ""; | |
119 | + string zero = "0"; | |
120 | + | |
121 | + if ((RED).ToString().Length != 2) | |
122 | + { | |
123 | + Red = zero + RED.ToString(); | |
124 | + } | |
125 | + else | |
126 | + { | |
127 | + Red = RED.ToString(); | |
128 | + } | |
129 | + if ((GREEN).ToString().Length != 2) | |
130 | + { | |
131 | + Green = zero + GREEN.ToString(); | |
132 | + } | |
133 | + else | |
134 | + { | |
135 | + Green = GREEN.ToString(); | |
136 | + } | |
137 | + if ((BLUE).ToString().Length != 2) | |
138 | + { | |
139 | + Blue = zero + BLUE.ToString(); | |
140 | + } | |
141 | + else | |
142 | + { | |
143 | + Blue = BLUE.ToString(); | |
144 | + } | |
145 | + | |
146 | + string Icolor = (Red + Green + Blue); | |
147 | + | |
148 | + | |
149 | + | |
150 | + foreach (dynamic systemTerm in systemTerms) | |
151 | + { | |
152 | + | |
153 | + int iColor = Convert.ToInt32(Icolor); | |
154 | + int termNumber = Convert.ToInt32(systemTerm._TermNumber.ToString()); | |
155 | + int systemNumber = Convert.ToInt32(systemTerm._SystemNumber.ToString()); | |
156 | + | |
157 | + if (systemTerm._TermNumber.ToString() == Icolor) | |
158 | + { | |
159 | + this.AddToTermList(termNumber, systemNumber, i, termList); | |
160 | + //this.AddToTermList(termNumber, systemNumber, i, termList); | |
161 | + this.AddToTermList(termNumber, systemNumber, i + 1, termList); | |
162 | + this.AddToTermList(termNumber, systemNumber, i + 2, termList); | |
163 | + break; | |
164 | + } | |
165 | + } | |
166 | + } | |
167 | + | |
168 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..after craeting termList.. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
169 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
170 | + | |
171 | + bodyRegionImage.imageName = data["imageName"].ToString(); | |
172 | + bodyRegionImage.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
173 | + bodyRegionImage.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
174 | + bodyRegionImage.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
175 | + bodyRegionImage.zoom = Convert.ToInt32(data["zoom"]); | |
176 | + | |
177 | + foreach (int key in termList.Keys) | |
178 | + { | |
179 | + bodyRegionImage.terms.Add(termList[key]); | |
180 | + } | |
181 | + | |
182 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "...inserting for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
183 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
184 | + | |
185 | + col.InsertOne(bodyRegionImage); | |
186 | + | |
187 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..inserted for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
188 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
189 | + | |
190 | + var logCol = db.GetCollection<BodyRegionImage>("DAImageLogs"); | |
191 | + | |
192 | + BodyRegionImage bodyRegionImageTolog = new BodyRegionImage(); | |
193 | + bodyRegionImageTolog.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
194 | + bodyRegionImageTolog.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
195 | + bodyRegionImageTolog.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
196 | + bodyRegionImageTolog.zoom = Convert.ToInt32(data["zoom"]); | |
197 | + | |
198 | + logCol.InsertOne(bodyRegionImageTolog); | |
199 | + | |
200 | + bodyRegionImageTolog = null; | |
201 | + | |
202 | + data = null; | |
203 | + termList = null; | |
204 | + systemTermMappingObject = null; | |
205 | + systemTerms = null; | |
206 | + } | |
207 | + catch(Exception ex) | |
208 | + { | |
209 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..Exception occured for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
210 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]+"... EXCEPTION= "+ex.Message+".. STACKTRACE= "+ex.StackTrace); | |
211 | + | |
212 | + } | |
213 | + | |
214 | + | |
215 | + } | |
216 | + | |
217 | + public void AddToTermList(int termNumber, int systemNumber, int pixelLocation,Dictionary<int, Term> termList) | |
218 | + { | |
219 | + if (!termList.ContainsKey(termNumber)) | |
220 | + { | |
221 | + termList.Add(termNumber, new Term(termNumber, systemNumber, pixelLocation)); | |
222 | + } | |
223 | + else | |
224 | + { | |
225 | + bool isSystemNumberExisting = false; | |
226 | + foreach (int sn in termList[termNumber].SystemNumbers) | |
227 | + { | |
228 | + if (systemNumber == sn) | |
229 | + { | |
230 | + isSystemNumberExisting = true; | |
231 | + break; | |
232 | + } | |
233 | + | |
234 | + } | |
235 | + if (!isSystemNumberExisting) | |
236 | + termList[termNumber].SystemNumbers.Add(systemNumber); | |
237 | + | |
238 | + bool isPixelLocationExisting = false; | |
239 | + foreach (int pl in termList[termNumber].PixelLocations) | |
240 | + { | |
241 | + if (pixelLocation == pl) | |
242 | + { | |
243 | + isPixelLocationExisting = true; | |
244 | + break; | |
245 | + } | |
246 | + | |
247 | + } | |
248 | + if (!isPixelLocationExisting) | |
249 | + termList[termNumber].PixelLocations.Add(pixelLocation); | |
250 | + | |
251 | + } | |
252 | + } | |
253 | + | |
254 | + | |
255 | + | |
256 | + | |
257 | + static void Main(string[] args) | |
258 | + { | |
259 | + | |
260 | + | |
261 | + //string[] files = Directory.GetFiles("D:\\100-PROJECTS\\008-AIAHighlight.FileSave\\AIAHighlight\\AIAHighlight\\data", "*.json"); | |
262 | + | |
263 | + string[] files = Directory.GetFiles(@"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\data\25", "*.json"); | |
264 | + //string[] files = Directory.GetFiles(@"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\data\BodyView4", "*.json"); | |
265 | + Program program = new Program(); | |
266 | + program.processFiles(files, 0, 19); | |
267 | + program = null; | |
268 | + | |
269 | + } | |
270 | + | |
271 | + internal void processFiles(string[] files, int startIndex, int endIndex) | |
272 | + { | |
273 | + | |
274 | + prepareArrayOfFiles(files, startIndex, endIndex); | |
275 | + | |
276 | + } | |
277 | + | |
278 | + internal void prepareArrayOfFiles(string[] files, int startIndex, int endIndex) | |
279 | + { | |
280 | + string[] filesToProcess = new string[20]; | |
281 | + int processedFiles = 0; | |
282 | + int j = 0; | |
283 | + for (int i = startIndex; i <= endIndex; i++) | |
284 | + { | |
285 | + | |
286 | + filesToProcess[j] = files[i]; | |
287 | + j++; | |
288 | + | |
289 | + } | |
290 | + | |
291 | + Parallel.ForEach(filesToProcess, (currentFile) => | |
292 | + { | |
293 | + if (currentFile != null) | |
294 | + { | |
295 | + Console.WriteLine("currentFile = " + currentFile); | |
296 | + using (StreamReader reader = new StreamReader(currentFile)) | |
297 | + { | |
298 | + getDataFromFileAndSaveInDB(currentFile); | |
299 | + processedFiles++; | |
300 | + | |
301 | + } | |
302 | + | |
303 | + if (processedFiles == 20) | |
304 | + { | |
305 | + startIndex = endIndex + 1; | |
306 | + endIndex = startIndex + 19; | |
307 | + filesToProcess = null; | |
308 | + | |
309 | + //in case after adding 20, the endIndex reaches more than length of files array(total files) | |
310 | + if (endIndex > files.Length - 1) | |
311 | + { | |
312 | + // int remainingFiles = endIndex - files.Length; | |
313 | + endIndex = files.Length - 1; | |
314 | + } | |
315 | + if (endIndex < files.Length) | |
316 | + { | |
317 | + processFiles(files, startIndex, endIndex); | |
318 | + } | |
319 | + //} | |
320 | + } | |
321 | + } | |
322 | + } | |
323 | + ); | |
324 | + | |
325 | + } | |
326 | + | |
327 | + | |
328 | + internal void getDataFromFileAndSaveInDB(string filePath) | |
329 | + { | |
330 | + if (File.Exists(filePath)) | |
331 | + { | |
332 | + string fileData; | |
333 | + using (StreamReader reader = new StreamReader(filePath)) | |
334 | + { | |
335 | + fileData = reader.ReadToEnd(); | |
336 | + | |
337 | + JObject data = JObject.Parse(fileData); | |
338 | + this.saveImageData(data); | |
339 | + } | |
340 | + | |
341 | + | |
342 | + } | |
343 | + else | |
344 | + { | |
345 | + Console.WriteLine("FILE.NOT.FOUND AT" + | |
346 | + ": " + filePath); | |
347 | + | |
348 | + } | |
349 | + } | |
350 | + //internal void getAlreadyInsertedLayer(string bodyviewId) | |
351 | + //{ | |
352 | + // Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "inside getAlreadyInsertedLayer"); | |
353 | + // int totalLayers = 0; | |
354 | + // int [] totalBodyReigons =null; | |
355 | + // List<int> bodyRegions = new List<int>(); | |
356 | + | |
357 | + // switch (Convert.ToInt32(bodyviewId)) | |
358 | + // { | |
359 | + // case 1: | |
360 | + // totalLayers = 330; | |
361 | + // totalBodyReigons = new int[6] {1,2,3,4,5,6}; | |
362 | + // bodyRegions.Add(1); | |
363 | + // bodyRegions.Add(2); | |
364 | + // bodyRegions.Add(3); | |
365 | + // bodyRegions.Add(4); | |
366 | + // bodyRegions.Add(5); | |
367 | + // bodyRegions.Add(6); | |
368 | + // break; | |
369 | + // case 2: | |
370 | + // totalLayers = 288; | |
371 | + // // totalBodyReigons = 6; | |
372 | + // break; | |
373 | + // case 3: | |
374 | + // totalLayers = 127; | |
375 | + // // totalBodyReigons = 6; | |
376 | + // break; | |
377 | + // case 4: | |
378 | + // totalLayers = 186; | |
379 | + // // totalBodyReigons = 6; | |
380 | + // break; | |
381 | + // case 5: | |
382 | + // totalLayers = 229; | |
383 | + // // totalBodyReigons = 6; | |
384 | + // break; | |
385 | + // case 6: | |
386 | + // totalLayers = 289; | |
387 | + // // totalBodyReigons = 6; | |
388 | + // break; | |
389 | + // case 7: | |
390 | + // totalLayers = 130; | |
391 | + // // totalBodyReigons = 6; | |
392 | + // break; | |
393 | + // case 8: | |
394 | + // totalLayers = 186; | |
395 | + // // totalBodyReigons = 6; | |
396 | + // break; | |
397 | + // case 9: | |
398 | + // totalLayers = 64; | |
399 | + // // totalBodyReigons = 6; | |
400 | + // break; | |
401 | + // case 10: | |
402 | + // totalLayers = 72; | |
403 | + // // totalBodyReigons = 6; | |
404 | + // break; | |
405 | + // case 11: | |
406 | + // totalLayers = 64; | |
407 | + // // totalBodyReigons = 6; | |
408 | + // break; | |
409 | + // case 12: | |
410 | + // totalLayers = 72; | |
411 | + // // totalBodyReigons = 6; | |
412 | + // break; | |
413 | + // } | |
414 | + | |
415 | + // var client = new MongoClient(); | |
416 | + // var db = client.GetDatabase("AIADB_bodyviewId" + bodyviewId.ToString()); | |
417 | + // //var db = client.GetDatabase("AIAImageDB"); | |
418 | + | |
419 | + // var col = db.GetCollection<BodyRegionImage>("DAImagesLogs"); | |
420 | + // //var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
421 | + | |
422 | + | |
423 | + // FilterDefinition<BodyRegionImage>[] filterCondition = { | |
424 | + // Builders<BodyRegionImage>.Filter.Eq("bodyViewIndex", Convert.ToInt32(bodyviewId))}; | |
425 | + | |
426 | + // dynamic list = col.Find(Builders<BodyRegionImage>.Filter.And(filterCondition)).Project(Builders<BodyRegionImage>.Projection.Include("layerNumber").Include("bodyRegionId")).ToList(); | |
427 | + // //collection.Find(new BsonDocument()).Project(Builders<BsonDocument>.Projection.Include("Price").Exclude("_id")).ToListAsync(); | |
428 | + // // return list; | |
429 | + // Dictionary<int, List<int>> layersToProcess = new Dictionary<int, List<int>>(); | |
430 | + | |
431 | + // for (int i = 1; i <= totalLayers; i++) | |
432 | + // { | |
433 | + // List<int> bodyRegionForThisLayer = new List<int>(); | |
434 | + // bodyRegionForThisLayer.Add(1); | |
435 | + // bodyRegionForThisLayer.Add(2); | |
436 | + // bodyRegionForThisLayer.Add(3); | |
437 | + // bodyRegionForThisLayer.Add(4); | |
438 | + // bodyRegionForThisLayer.Add(5); | |
439 | + // bodyRegionForThisLayer.Add(6); | |
440 | + | |
441 | + // int previousLayerNumber = 0; | |
442 | + // int existingLayerNumber = 0; | |
443 | + // bool isLayerMatched = false; | |
444 | + | |
445 | + // foreach (dynamic lNumber in list) | |
446 | + // { | |
447 | + // existingLayerNumber = Convert.ToInt32((lNumber.GetValue("layerNumber")).ToString()); | |
448 | + | |
449 | + // if (existingLayerNumber == i) | |
450 | + // { | |
451 | + // isLayerMatched = true; | |
452 | + // int existingBodyRegionId = Convert.ToInt32((lNumber.GetValue("bodyRegionId")).ToString()); | |
453 | + | |
454 | + | |
455 | + // if (bodyRegionForThisLayer.Contains(existingBodyRegionId)) { | |
456 | + // //remove from bodyRegions list as this is already present | |
457 | + // bodyRegionForThisLayer.Remove(existingBodyRegionId); | |
458 | + // } | |
459 | + // previousLayerNumber = existingLayerNumber; | |
460 | + | |
461 | + // } | |
462 | + | |
463 | + // else | |
464 | + // { | |
465 | + | |
466 | + // } | |
467 | + | |
468 | + // } | |
469 | + // if(isLayerMatched) | |
470 | + // layersToProcess.Add(previousLayerNumber, bodyRegionForThisLayer); | |
471 | + // else | |
472 | + // layersToProcess.Add(i, bodyRegionForThisLayer); | |
473 | + // } | |
474 | + // Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "after preparing list to process"); | |
475 | + | |
476 | + // makeFileNameAndProcess(layersToProcess,Convert.ToInt32(bodyviewId)); | |
477 | + //} | |
478 | + | |
479 | + | |
480 | + //internal void makeFileNameAndProcess(Dictionary<int, List<int>> filesToProcess, int BodyViewIndex) | |
481 | + //{ | |
482 | + // Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "in makeFileNameAndProcess"); | |
483 | + | |
484 | + // foreach (KeyValuePair<int, List<int>> pair in filesToProcess) | |
485 | + // { | |
486 | + | |
487 | + | |
488 | + // foreach (int item in pair.Value) | |
489 | + // { | |
490 | + // string fileName = "BodyView" + BodyViewIndex + "_layer" + pair.Key + "_bodyRegionId" + item+".json"; | |
491 | + | |
492 | + // //string filePath = @"D:\100-PROJECTS\008-AIAHighlight.FileSave\AIAHighlight\AIAHighlight\data\" + fileName; | |
493 | + // string filePath = @"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\data\" + fileName; | |
494 | + // getDataFromFileAndSaveInDB(filePath, BodyViewIndex); | |
495 | + // } | |
496 | + | |
497 | + // } | |
498 | + //} | |
499 | + | |
500 | + //internal void processFiles(string[] files,int bodyviewId) | |
501 | + //{ | |
502 | + | |
503 | + // //without multithreading | |
504 | + // foreach(string filename in files) | |
505 | + // { | |
506 | + // Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "in processFiles for filename"); | |
507 | + // getDataFromFileAndSaveInDB(filename, bodyviewId); | |
508 | + // } | |
509 | + | |
510 | + //} | |
511 | + | |
512 | + | |
513 | + | |
514 | + //internal void getDataFromFileAndSaveInDB(string filePath,int bodyViewId) | |
515 | + //{ | |
516 | + // if (File.Exists(filePath)) | |
517 | + // { | |
518 | + // string fileData; | |
519 | + // using (StreamReader reader = new StreamReader(filePath)) | |
520 | + // { | |
521 | + // fileData = reader.ReadToEnd(); | |
522 | + | |
523 | + // JObject data = JObject.Parse(fileData); | |
524 | + // this.saveImageData(data, bodyViewId); | |
525 | + // } | |
526 | + | |
527 | + | |
528 | + // } | |
529 | + // else | |
530 | + // { | |
531 | + // Console.WriteLine("FILE.NOT.FOUND AT" + | |
532 | + // ": " + filePath); | |
533 | + | |
534 | + // } | |
535 | + //} | |
536 | + } | |
537 | +} | ... | ... |
600-POC/fileSave/DBSAVe/Program_NOMultiThreading.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading; | |
6 | +using System.Threading.Tasks; | |
7 | +//using log4net; | |
8 | +using MongoDB.Driver; | |
9 | +using System.IO; | |
10 | +using Newtonsoft.Json.Linq; | |
11 | +using MongoDB.Bson.Serialization.Attributes; | |
12 | +using MongoDB.Bson; | |
13 | + | |
14 | +namespace AIAHighlight.DBSave | |
15 | +{ | |
16 | + [BsonIgnoreExtraElements] | |
17 | + public class BodyRegionImage | |
18 | + { | |
19 | + public ObjectId _id { get; set; } | |
20 | + public string imageName; | |
21 | + public int bodyViewIndex; | |
22 | + public int layerNumber; | |
23 | + public int bodyRegionId; | |
24 | + public int zoom; | |
25 | + public List<Term> terms; | |
26 | + | |
27 | + public BodyRegionImage() | |
28 | + { | |
29 | + this.terms = new List<Term>(); | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + public class Term | |
34 | + { | |
35 | + public int TermNumber; | |
36 | + public List<int> SystemNumbers; | |
37 | + public List<int> PixelLocations; | |
38 | + public int ActualTermNumber; | |
39 | + | |
40 | + public Term(int termNumber, int systemNumber, int pixelLocation) | |
41 | + { | |
42 | + this.SystemNumbers = new List<int>(); | |
43 | + this.PixelLocations = new List<int>(); | |
44 | + this.TermNumber = termNumber; | |
45 | + this.SystemNumbers.Add(systemNumber); | |
46 | + this.PixelLocations.Add(pixelLocation); | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + | |
51 | + | |
52 | + | |
53 | + public class Program | |
54 | + { | |
55 | + //public JObject data { get; set; } | |
56 | + public Dictionary<int, Term> termList; | |
57 | + | |
58 | + internal void saveImageData(JObject data) | |
59 | + { | |
60 | + // DateTime datetime = new DateTime(); | |
61 | + Console.WriteLine("AT "+ DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz")+"..In saveImageData. for imageName: "+ data["imageName"].ToString()+ ",bodyViewIndex= "+ data["bodyViewIndex"]+ ",layerNumber: "+ | |
62 | + data["layerNumber"]+ ",bodyRegionId= "+ data["bodyRegion"]); | |
63 | + try | |
64 | + { | |
65 | + BodyRegionImage bodyRegionImage = new BodyRegionImage(); | |
66 | + // var client = new MongoClient("mongodb://192.168.90.43:27017"); | |
67 | + var client = new MongoClient("mongodb://192.168.90.43:27017"); | |
68 | + | |
69 | + var db = client.GetDatabase("aia"); | |
70 | + | |
71 | + var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
72 | + | |
73 | + // var list = col.Find(Builders<BodyRegionImage>.Filter.Eq("imageName", image["imageName"].ToString())).ToList(); | |
74 | + JObject imageData = data; | |
75 | + | |
76 | + | |
77 | + var projection = Builders<BodyRegionImage>.Projection.Include("_id"); | |
78 | + | |
79 | + FilterDefinition<BodyRegionImage>[] filterCondition = { Builders<BodyRegionImage>.Filter.Eq("imageName", data["imageName"].ToString()), | |
80 | + Builders<BodyRegionImage>.Filter.Eq("bodyViewIndex", Convert.ToInt32(data["bodyViewIndex"])), | |
81 | + Builders<BodyRegionImage>.Filter.Eq("layerNumber", Convert.ToInt32(data["layerNumber"])), | |
82 | + Builders<BodyRegionImage>.Filter.Eq("bodyRegionId", Convert.ToInt32(data["bodyRegion"])), | |
83 | + Builders<BodyRegionImage>.Filter.Eq("zoom", Convert.ToInt32(data["zoom"]))}; | |
84 | + var list = col.Find(Builders<BodyRegionImage>.Filter.And(filterCondition)).Project<BodyRegionImage>(projection).ToList(); | |
85 | + | |
86 | + //FilterDefinition<BodyRegionImage>[] filterCondition = { Builders<BodyRegionImage>.Filter.Eq("imageName", data["imageName"].ToString()), | |
87 | + // Builders<BodyRegionImage>.Filter.Eq("bodyViewIndex", Convert.ToInt32(data["bodyViewIndex"])), | |
88 | + // Builders<BodyRegionImage>.Filter.Eq("layerNumber", Convert.ToInt32(data["layerNumber"])), | |
89 | + // Builders<BodyRegionImage>.Filter.Eq("bodyRegionId", Convert.ToInt32(data["bodyRegion"])), | |
90 | + // Builders<BodyRegionImage>.Filter.Eq("zoom", Convert.ToInt32(data["zoom"]))}; | |
91 | + //var list = col.Find(Builders<BodyRegionImage>.Filter.And(filterCondition)).ToList(); | |
92 | + | |
93 | + if (list.Count > 0) | |
94 | + return; | |
95 | + | |
96 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..record not found."); | |
97 | + | |
98 | + string bodyViewIndex = data["bodyViewIndex"].ToString(); | |
99 | + // string termFilePath = "D:\\100-PROJECTS\\008-AIAHighlight.FileSave\\dist\\assets\\data\\json\\da\\body-views\\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
100 | + // string termFilePath = " D:\\ADAM\\100-Projects\\001-AIAHighlight.FileSave\\AIAHighlight\\dist\\assets\\data\\json\\da\\body-views\\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
101 | + string path = @"\\ADAMSRVR\dist\assets\data\json\da\body-views\" + bodyViewIndex+"\\"; | |
102 | + string fileName = "da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
103 | + string termFilePath = " D:\\ADAM\\100-Projects\\001-AIAHighlight.FileSave\\AIAHighlight\\dist\\assets\\data\\json\\da\\body-views\\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
104 | + string systemTermMapping; | |
105 | + // using (StreamReader reader = new StreamReader(termFilePath)) | |
106 | + | |
107 | + using (StreamReader reader = new StreamReader(path+fileName)) | |
108 | + { | |
109 | + systemTermMapping = reader.ReadToEnd(); | |
110 | + } | |
111 | + | |
112 | + JObject systemTermMappingObject = JObject.Parse(systemTermMapping); | |
113 | + | |
114 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + ".systemTermMappingObject craeted."); | |
115 | + | |
116 | + dynamic systemTerms = systemTermMappingObject["BodySystem"]["BodySystemTerm"]; | |
117 | + | |
118 | + dynamic imageDataArray = data["data"]; | |
119 | + | |
120 | + Dictionary<int,Term> termList = new Dictionary<int, Term>(); | |
121 | + | |
122 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..before itrating imageDataArray"); | |
123 | + | |
124 | + for (int i = 0; i < imageDataArray.Count; i += 4) | |
125 | + { | |
126 | + var RED = Convert.ToInt32(imageDataArray[i]) - 9; | |
127 | + var GREEN = Convert.ToInt32(imageDataArray[i + 1]) - 9; | |
128 | + var BLUE = Convert.ToInt32(imageDataArray[i + 2]) - 9; | |
129 | + | |
130 | + if (RED == -9 && GREEN == -9 && BLUE == -9) | |
131 | + continue; | |
132 | + | |
133 | + var Red = ""; | |
134 | + var Green = ""; | |
135 | + var Blue = ""; | |
136 | + string zero = "0"; | |
137 | + | |
138 | + if ((RED).ToString().Length != 2) | |
139 | + { | |
140 | + Red = zero + RED.ToString(); | |
141 | + } | |
142 | + else | |
143 | + { | |
144 | + Red = RED.ToString(); | |
145 | + } | |
146 | + if ((GREEN).ToString().Length != 2) | |
147 | + { | |
148 | + Green = zero + GREEN.ToString(); | |
149 | + } | |
150 | + else | |
151 | + { | |
152 | + Green = GREEN.ToString(); | |
153 | + } | |
154 | + if ((BLUE).ToString().Length != 2) | |
155 | + { | |
156 | + Blue = zero + BLUE.ToString(); | |
157 | + } | |
158 | + else | |
159 | + { | |
160 | + Blue = BLUE.ToString(); | |
161 | + } | |
162 | + | |
163 | + string Icolor = (Red + Green + Blue); | |
164 | + // alert('Icolor: ' + Icolor) | |
165 | + | |
166 | + foreach (dynamic systemTerm in systemTerms) | |
167 | + { | |
168 | + int iColor = Convert.ToInt32(Icolor); | |
169 | + int termNumber = Convert.ToInt32(systemTerm._TermNumber.ToString()); | |
170 | + int systemNumber = Convert.ToInt32(systemTerm._SystemNumber.ToString()); | |
171 | + | |
172 | + if (systemTerm._TermNumber.ToString() == Icolor) | |
173 | + { | |
174 | + this.AddToTermList(termNumber, systemNumber, i, termList); | |
175 | + //new Program().AddToTermList(termNumber, systemNumber, i,termList); | |
176 | + //new Program().AddToTermList(termNumber, systemNumber, i + 1, termList); | |
177 | + //new Program().AddToTermList(termNumber, systemNumber, i + 2, termList); | |
178 | + this.AddToTermList(termNumber, systemNumber, i, termList); | |
179 | + this.AddToTermList(termNumber, systemNumber, i + 1, termList); | |
180 | + this.AddToTermList(termNumber, systemNumber, i + 2, termList); | |
181 | + } | |
182 | + } | |
183 | + } | |
184 | + | |
185 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..after craeting termList."); | |
186 | + | |
187 | + bodyRegionImage.imageName = data["imageName"].ToString(); | |
188 | + bodyRegionImage.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
189 | + bodyRegionImage.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
190 | + bodyRegionImage.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
191 | + bodyRegionImage.zoom = Convert.ToInt32(data["zoom"]); | |
192 | + | |
193 | + foreach (int key in termList.Keys) | |
194 | + { | |
195 | + bodyRegionImage.terms.Add(termList[key]); | |
196 | + } | |
197 | + | |
198 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "...inserting for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
199 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
200 | + | |
201 | + col.InsertOne(bodyRegionImage); | |
202 | + | |
203 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..inserted for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
204 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
205 | + | |
206 | + data = null; | |
207 | + termList = null; | |
208 | + systemTermMappingObject = null; | |
209 | + systemTerms = null; | |
210 | + } | |
211 | + catch(Exception ex) | |
212 | + { | |
213 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..Exception occured for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
214 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]+"... EXCEPTION= "+ex.Message+".. STACKTRACE= "+ex.StackTrace); | |
215 | + | |
216 | + } | |
217 | + | |
218 | + | |
219 | + } | |
220 | + | |
221 | + public void AddToTermList(int termNumber, int systemNumber, int pixelLocation,Dictionary<int, Term> termList) | |
222 | + { | |
223 | + if (!termList.ContainsKey(termNumber)) | |
224 | + { | |
225 | + termList.Add(termNumber, new Term(termNumber, systemNumber, pixelLocation)); | |
226 | + } | |
227 | + else | |
228 | + { | |
229 | + bool isSystemNumberExisting = false; | |
230 | + foreach (int sn in termList[termNumber].SystemNumbers) | |
231 | + { | |
232 | + if (systemNumber == sn) | |
233 | + { | |
234 | + isSystemNumberExisting = true; | |
235 | + break; | |
236 | + } | |
237 | + | |
238 | + } | |
239 | + if (!isSystemNumberExisting) | |
240 | + termList[termNumber].SystemNumbers.Add(systemNumber); | |
241 | + | |
242 | + bool isPixelLocationExisting = false; | |
243 | + foreach (int pl in termList[termNumber].PixelLocations) | |
244 | + { | |
245 | + if (pixelLocation == pl) | |
246 | + { | |
247 | + isPixelLocationExisting = true; | |
248 | + break; | |
249 | + } | |
250 | + | |
251 | + } | |
252 | + if (!isPixelLocationExisting) | |
253 | + termList[termNumber].PixelLocations.Add(pixelLocation); | |
254 | + | |
255 | + } | |
256 | + } | |
257 | + //static void saveImageData() | |
258 | + //{ | |
259 | + | |
260 | + //} | |
261 | + | |
262 | + static void Main(string[] args) | |
263 | + { | |
264 | + Console.WriteLine("Enter BodyViewIndex"); | |
265 | + string bodyViewId = Console.ReadLine(); | |
266 | + string searchPattern = "BodyView" + bodyViewId+"_layer*"; | |
267 | + // string[] files = Directory.GetFiles("D:\\100-PROJECTS\\008-AIAHighlight.FileSave\\AIAHighlight\\AIAHighlight\\data"); | |
268 | + // string[] files = Directory.GetFiles("D:\\ADAM\\100-Projects\\001-AIAHighlight.FileSave\\AIAHighlight.Serevr\\AIAHighlight\\data", "*.json"); | |
269 | + // string[] files = Directory.GetFiles("D:\\100-PROJECTS\\008-AIAHighlight.FileSave\\AIAHighlight\\AIAHighlight\\data",searchPattern); | |
270 | + | |
271 | + string[] files = Directory.GetFiles(@"\\ADAMSRVR\data", searchPattern); | |
272 | + Program program; | |
273 | + foreach (string filePath in files) | |
274 | + { | |
275 | + program = new Program(); | |
276 | + program.getDataFromFileAndSaveInDB(filePath); | |
277 | + program = null; | |
278 | + } | |
279 | + | |
280 | + } | |
281 | + | |
282 | + internal void getDataFromFileAndSaveInDB(string filePath) | |
283 | + { | |
284 | + if (File.Exists(filePath)) | |
285 | + { | |
286 | + string fileData; | |
287 | + using (StreamReader reader = new StreamReader(filePath)) | |
288 | + { | |
289 | + fileData = reader.ReadToEnd(); | |
290 | + | |
291 | + JObject data = JObject.Parse(fileData); | |
292 | + this.saveImageData(data); | |
293 | + } | |
294 | + | |
295 | + | |
296 | + } | |
297 | + } | |
298 | + } | |
299 | +} | ... | ... |
600-POC/fileSave/DBSAVe/Program_UserInput_DifferentDB.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading; | |
6 | +using System.Threading.Tasks; | |
7 | +//using log4net; | |
8 | +using MongoDB.Driver; | |
9 | +using System.IO; | |
10 | +using Newtonsoft.Json.Linq; | |
11 | +using MongoDB.Bson.Serialization.Attributes; | |
12 | +using MongoDB.Bson; | |
13 | + | |
14 | +namespace AIAHighlight.DBSave | |
15 | +{ | |
16 | + [BsonIgnoreExtraElements] | |
17 | + public class BodyRegionImage | |
18 | + { | |
19 | + public ObjectId _id { get; set; } | |
20 | + public string imageName; | |
21 | + public int bodyViewIndex; | |
22 | + public int layerNumber; | |
23 | + public int bodyRegionId; | |
24 | + public int zoom; | |
25 | + public List<Term> terms; | |
26 | + | |
27 | + public BodyRegionImage() | |
28 | + { | |
29 | + this.terms = new List<Term>(); | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + public class Term | |
34 | + { | |
35 | + public int TermNumber; | |
36 | + public List<int> SystemNumbers; | |
37 | + public List<int> PixelLocations; | |
38 | + public int ActualTermNumber; | |
39 | + | |
40 | + public Term(int termNumber, int systemNumber, int pixelLocation) | |
41 | + { | |
42 | + this.SystemNumbers = new List<int>(); | |
43 | + this.PixelLocations = new List<int>(); | |
44 | + this.TermNumber = termNumber; | |
45 | + this.SystemNumbers.Add(systemNumber); | |
46 | + this.PixelLocations.Add(pixelLocation); | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + | |
51 | + | |
52 | + | |
53 | + public class Program | |
54 | + { | |
55 | + //public JObject data { get; set; } | |
56 | + // public Dictionary<int, Term> termList; | |
57 | + | |
58 | + internal void saveImageData(JObject data, int bodyviewId) | |
59 | + { | |
60 | + // DateTime datetime = new DateTime(); | |
61 | + Console.WriteLine("AT "+ DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz")+"..In saveImageData. for imageName: "+ data["imageName"].ToString()+ ",bodyViewIndex= "+ data["bodyViewIndex"]+ ",layerNumber: "+ | |
62 | + data["layerNumber"]+ ",bodyRegionId= "+ data["bodyRegion"]); | |
63 | + try | |
64 | + { | |
65 | + BodyRegionImage bodyRegionImage = new BodyRegionImage(); | |
66 | + // var client = new MongoClient("mongodb://192.168.90.43:27017"); | |
67 | + var client = new MongoClient(); | |
68 | + | |
69 | + var db = client.GetDatabase("AIADB_bodyviewId"+bodyviewId.ToString()); | |
70 | + | |
71 | + var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
72 | + | |
73 | + // var list = col.Find(Builders<BodyRegionImage>.Filter.Eq("imageName", image["imageName"].ToString())).ToList(); | |
74 | + JObject imageData = data; | |
75 | + | |
76 | + | |
77 | + //var projection = Builders<BodyRegionImage>.Projection.Include("_id"); | |
78 | + | |
79 | + //FilterDefinition<BodyRegionImage>[] filterCondition = { Builders<BodyRegionImage>.Filter.Eq("imageName", data["imageName"].ToString()), | |
80 | + // Builders<BodyRegionImage>.Filter.Eq("bodyViewIndex", Convert.ToInt32(data["bodyViewIndex"])), | |
81 | + // Builders<BodyRegionImage>.Filter.Eq("layerNumber", Convert.ToInt32(data["layerNumber"])), | |
82 | + // Builders<BodyRegionImage>.Filter.Eq("bodyRegionId", Convert.ToInt32(data["bodyRegion"])), | |
83 | + // Builders<BodyRegionImage>.Filter.Eq("zoom", Convert.ToInt32(data["zoom"]))}; | |
84 | + //var list = col.Find(Builders<BodyRegionImage>.Filter.And(filterCondition)).Project<BodyRegionImage>(projection).ToList(); | |
85 | + | |
86 | + | |
87 | + //if (list.Count > 0) | |
88 | + // return; | |
89 | + | |
90 | + //Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..record not found."); | |
91 | + | |
92 | + string bodyViewIndex = data["bodyViewIndex"].ToString(); | |
93 | + | |
94 | + //string termFilePath = @"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\bodyViewsData\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
95 | + string termFilePath = @"D:\100-PROJECTS\008-AIAHighlight.FileSave\dist\assets\data\json\da\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
96 | + //string path = @"\\ADAMSRVR\dist\assets\data\json\da\body-views\" + bodyViewIndex+"\\"; | |
97 | + //string fileName = "da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
98 | + | |
99 | + string systemTermMapping; | |
100 | + using (StreamReader reader = new StreamReader(termFilePath)) | |
101 | + | |
102 | + // using (StreamReader reader = new StreamReader(path+fileName)) | |
103 | + { | |
104 | + systemTermMapping = reader.ReadToEnd(); | |
105 | + } | |
106 | + | |
107 | + JObject systemTermMappingObject = JObject.Parse(systemTermMapping); | |
108 | + | |
109 | + //Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + ".systemTermMappingObject created."); | |
110 | + | |
111 | + dynamic systemTerms = systemTermMappingObject["BodySystem"]["BodySystemTerm"]; | |
112 | + | |
113 | + dynamic imageDataArray = data["data"]; | |
114 | + //int[] imageDataIntArray = (int[])imageDataArray; | |
115 | + //int numToRemove = 0; | |
116 | + //dynamic imageDataWithoutZero = imageDataIntArray.Where(val => val != numToRemove).ToArray(); | |
117 | + | |
118 | + Dictionary<int,Term> termList = new Dictionary<int, Term>(); | |
119 | + | |
120 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..before itrating imageDataArray. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
121 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
122 | + | |
123 | + for (int i = 0; i < imageDataArray.Count; i += 4) | |
124 | + { | |
125 | + var RED = Convert.ToInt32(imageDataArray[i]) - 9; | |
126 | + var GREEN = Convert.ToInt32(imageDataArray[i + 1]) - 9; | |
127 | + var BLUE = Convert.ToInt32(imageDataArray[i + 2]) - 9; | |
128 | + | |
129 | + if (RED == -9 && GREEN == -9 && BLUE == -9) | |
130 | + continue; | |
131 | + | |
132 | + var Red = ""; | |
133 | + var Green = ""; | |
134 | + var Blue = ""; | |
135 | + string zero = "0"; | |
136 | + | |
137 | + if ((RED).ToString().Length != 2) | |
138 | + { | |
139 | + Red = zero + RED.ToString(); | |
140 | + } | |
141 | + else | |
142 | + { | |
143 | + Red = RED.ToString(); | |
144 | + } | |
145 | + if ((GREEN).ToString().Length != 2) | |
146 | + { | |
147 | + Green = zero + GREEN.ToString(); | |
148 | + } | |
149 | + else | |
150 | + { | |
151 | + Green = GREEN.ToString(); | |
152 | + } | |
153 | + if ((BLUE).ToString().Length != 2) | |
154 | + { | |
155 | + Blue = zero + BLUE.ToString(); | |
156 | + } | |
157 | + else | |
158 | + { | |
159 | + Blue = BLUE.ToString(); | |
160 | + } | |
161 | + | |
162 | + string Icolor = (Red + Green + Blue); | |
163 | + // alert('Icolor: ' + Icolor) | |
164 | + if(Icolor=="000000") | |
165 | + foreach (dynamic systemTerm in systemTerms) | |
166 | + { | |
167 | + int iColor = Convert.ToInt32(Icolor); | |
168 | + int termNumber = Convert.ToInt32(systemTerm._TermNumber.ToString()); | |
169 | + int systemNumber = Convert.ToInt32(systemTerm._SystemNumber.ToString()); | |
170 | + | |
171 | + if (systemTerm._TermNumber.ToString() == Icolor) | |
172 | + { | |
173 | + this.AddToTermList(termNumber, systemNumber, i, termList); | |
174 | + this.AddToTermList(termNumber, systemNumber, i, termList); | |
175 | + this.AddToTermList(termNumber, systemNumber, i + 1, termList); | |
176 | + this.AddToTermList(termNumber, systemNumber, i + 2, termList); | |
177 | + break; | |
178 | + } | |
179 | + } | |
180 | + } | |
181 | + | |
182 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..after craeting termList.. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
183 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
184 | + | |
185 | + bodyRegionImage.imageName = data["imageName"].ToString(); | |
186 | + bodyRegionImage.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
187 | + bodyRegionImage.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
188 | + bodyRegionImage.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
189 | + bodyRegionImage.zoom = Convert.ToInt32(data["zoom"]); | |
190 | + | |
191 | + foreach (int key in termList.Keys) | |
192 | + { | |
193 | + bodyRegionImage.terms.Add(termList[key]); | |
194 | + } | |
195 | + | |
196 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "...inserting for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
197 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
198 | + | |
199 | + col.InsertOne(bodyRegionImage); | |
200 | + | |
201 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..inserted for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
202 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
203 | + | |
204 | + var logCol = db.GetCollection<BodyRegionImage>("DAImageLogs"); | |
205 | + | |
206 | + BodyRegionImage bodyRegionImageTolog = new BodyRegionImage(); | |
207 | + bodyRegionImageTolog.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
208 | + bodyRegionImageTolog.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
209 | + bodyRegionImageTolog.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
210 | + bodyRegionImageTolog.zoom = Convert.ToInt32(data["zoom"]); | |
211 | + | |
212 | + logCol.InsertOne(bodyRegionImageTolog); | |
213 | + | |
214 | + bodyRegionImageTolog = null; | |
215 | + | |
216 | + data = null; | |
217 | + termList = null; | |
218 | + systemTermMappingObject = null; | |
219 | + systemTerms = null; | |
220 | + } | |
221 | + catch(Exception ex) | |
222 | + { | |
223 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..Exception occured for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
224 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]+"... EXCEPTION= "+ex.Message+".. STACKTRACE= "+ex.StackTrace); | |
225 | + | |
226 | + } | |
227 | + | |
228 | + | |
229 | + } | |
230 | + | |
231 | + public void AddToTermList(int termNumber, int systemNumber, int pixelLocation,Dictionary<int, Term> termList) | |
232 | + { | |
233 | + if (!termList.ContainsKey(termNumber)) | |
234 | + { | |
235 | + termList.Add(termNumber, new Term(termNumber, systemNumber, pixelLocation)); | |
236 | + } | |
237 | + else | |
238 | + { | |
239 | + bool isSystemNumberExisting = false; | |
240 | + foreach (int sn in termList[termNumber].SystemNumbers) | |
241 | + { | |
242 | + if (systemNumber == sn) | |
243 | + { | |
244 | + isSystemNumberExisting = true; | |
245 | + break; | |
246 | + } | |
247 | + | |
248 | + } | |
249 | + if (!isSystemNumberExisting) | |
250 | + termList[termNumber].SystemNumbers.Add(systemNumber); | |
251 | + | |
252 | + bool isPixelLocationExisting = false; | |
253 | + foreach (int pl in termList[termNumber].PixelLocations) | |
254 | + { | |
255 | + if (pixelLocation == pl) | |
256 | + { | |
257 | + isPixelLocationExisting = true; | |
258 | + break; | |
259 | + } | |
260 | + | |
261 | + } | |
262 | + if (!isPixelLocationExisting) | |
263 | + termList[termNumber].PixelLocations.Add(pixelLocation); | |
264 | + | |
265 | + } | |
266 | + } | |
267 | + | |
268 | + | |
269 | + //static void Main(string[] args) | |
270 | + //{ | |
271 | + // Console.WriteLine("Enter BodyViewIndex"); | |
272 | + // string bodyViewId = Console.ReadLine(); | |
273 | + // string searchPattern = "BodyView" + bodyViewId+"_layer*"; | |
274 | + | |
275 | + // string[] files = Directory.GetFiles(@"\\ADAMSRVR\data", searchPattern); | |
276 | + // Program program; | |
277 | + // foreach (string filePath in files) | |
278 | + // { | |
279 | + // program = new Program(); | |
280 | + // program.getDataFromFileAndSaveInDB(filePath); | |
281 | + // program = null; | |
282 | + // } | |
283 | + | |
284 | + //} | |
285 | + | |
286 | + static void Main(string[] args) | |
287 | + { | |
288 | + | |
289 | + | |
290 | + //string[] files = Directory.GetFiles("D:\\100-PROJECTS\\008-AIAHighlight.FileSave\\AIAHighlight\\AIAHighlight\\data", "*.json"); | |
291 | + | |
292 | + //string[] files = Directory.GetFiles(@"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\data", "*.json"); | |
293 | + Console.WriteLine("Enter BodyViewId"); | |
294 | + int BodyViewIndex = Convert.ToInt32(Console.ReadLine()); | |
295 | + | |
296 | + Console.WriteLine("Enter LayerNumber"); | |
297 | + string layerNumber = Console.ReadLine(); | |
298 | + int totalLayers = 0; | |
299 | + | |
300 | + switch (BodyViewIndex) | |
301 | + { | |
302 | + case 1: | |
303 | + totalLayers = 330; | |
304 | + break; | |
305 | + case 2: | |
306 | + totalLayers = 288; | |
307 | + break; | |
308 | + case 3: | |
309 | + totalLayers = 127; | |
310 | + break; | |
311 | + case 4: | |
312 | + totalLayers = 186; | |
313 | + break; | |
314 | + case 5: | |
315 | + totalLayers = 229; | |
316 | + break; | |
317 | + case 6: | |
318 | + totalLayers = 289; | |
319 | + break; | |
320 | + case 7: | |
321 | + totalLayers = 130; | |
322 | + break; | |
323 | + case 8: | |
324 | + totalLayers = 186; | |
325 | + break; | |
326 | + case 9: | |
327 | + totalLayers = 64; | |
328 | + break; | |
329 | + case 10: | |
330 | + totalLayers = 72; | |
331 | + break; | |
332 | + case 11: | |
333 | + totalLayers = 64; | |
334 | + break; | |
335 | + case 12: | |
336 | + totalLayers = 72; | |
337 | + break; | |
338 | + } | |
339 | + | |
340 | + for (int i = Convert.ToInt32(layerNumber); i <= totalLayers; i++) | |
341 | + { | |
342 | + string searchPattern = "BodyView" + BodyViewIndex + "_layer" + i + "*"; | |
343 | + // string searchPattern = "BodyView" + bodyViewId + "_layer*"; | |
344 | + | |
345 | + string[] files = Directory.GetFiles(@"D:\100-PROJECTS\008-AIAHighlight.FileSave\data", searchPattern); | |
346 | + // string[] files = Directory.GetFiles(@"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\data\", searchPattern); | |
347 | + Program program = new Program(); | |
348 | + program.processFiles(files, BodyViewIndex); | |
349 | + program = null; | |
350 | + } | |
351 | + } | |
352 | + | |
353 | + internal void processFiles(string[] files,int bodyviewId) | |
354 | + { | |
355 | + //with multithreading | |
356 | + // prepareArrayOfFiles(files, startIndex, endIndex); | |
357 | + | |
358 | + //without multithreading | |
359 | + foreach(string filename in files) | |
360 | + { | |
361 | + getDataFromFileAndSaveInDB(filename, bodyviewId); | |
362 | + } | |
363 | + | |
364 | + } | |
365 | + | |
366 | + //internal void prepareArrayOfFiles(string[] files,int startIndex, int endIndex) | |
367 | + //{ | |
368 | + // string[] filesToProcess = new string[20]; | |
369 | + // int processedFiles = 1; | |
370 | + // int j = 0; | |
371 | + // for (int i = startIndex; i <= endIndex; i++) | |
372 | + // { | |
373 | + | |
374 | + // filesToProcess[j] = files[i]; | |
375 | + // j++; | |
376 | + | |
377 | + // } | |
378 | + | |
379 | + // Parallel.ForEach(filesToProcess, (currentFile) => | |
380 | + // { | |
381 | + // if (currentFile != null) | |
382 | + // { | |
383 | + // using (StreamReader reader = new StreamReader(currentFile)) | |
384 | + // { | |
385 | + // getDataFromFileAndSaveInDB(currentFile); | |
386 | + // processedFiles++; | |
387 | + | |
388 | + // } | |
389 | + | |
390 | + // if (processedFiles == 20) | |
391 | + // { | |
392 | + // startIndex = endIndex + 1; | |
393 | + // endIndex = startIndex + 19; | |
394 | + // filesToProcess = null; | |
395 | + | |
396 | + // //in case after adding 20, the endIndex reaches more than length of files array(total files) | |
397 | + // if (endIndex > files.Length - 1) | |
398 | + // { | |
399 | + // // int remainingFiles = endIndex - files.Length; | |
400 | + // endIndex = files.Length - 1; | |
401 | + // } | |
402 | + // if (endIndex < files.Length) | |
403 | + // { | |
404 | + // processFiles(files, startIndex, endIndex); | |
405 | + // } | |
406 | + // //} | |
407 | + // } | |
408 | + // } | |
409 | + // } | |
410 | + // ); | |
411 | + | |
412 | + //} | |
413 | + | |
414 | + | |
415 | + internal void getDataFromFileAndSaveInDB(string filePath,int bodyViewId) | |
416 | + { | |
417 | + if (File.Exists(filePath)) | |
418 | + { | |
419 | + string fileData; | |
420 | + using (StreamReader reader = new StreamReader(filePath)) | |
421 | + { | |
422 | + fileData = reader.ReadToEnd(); | |
423 | + | |
424 | + JObject data = JObject.Parse(fileData); | |
425 | + this.saveImageData(data, bodyViewId); | |
426 | + } | |
427 | + | |
428 | + | |
429 | + } | |
430 | + else | |
431 | + { | |
432 | + Console.WriteLine("FILE.NOT.FOUND AT" + | |
433 | + ": " + filePath); | |
434 | + | |
435 | + } | |
436 | + } | |
437 | + } | |
438 | +} | ... | ... |
600-POC/fileSave/DBSAVe/Program_WithoutMultithreading_withDBSearchBeforeExeutiom.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading; | |
6 | +using System.Threading.Tasks; | |
7 | +//using log4net; | |
8 | +using MongoDB.Driver; | |
9 | +using System.IO; | |
10 | +using Newtonsoft.Json.Linq; | |
11 | +using MongoDB.Bson.Serialization.Attributes; | |
12 | +using MongoDB.Bson; | |
13 | + | |
14 | +namespace AIAHighlight.DBSave | |
15 | +{ | |
16 | + [BsonIgnoreExtraElements] | |
17 | + public class BodyRegionImage | |
18 | + { | |
19 | + public ObjectId _id { get; set; } | |
20 | + public string imageName; | |
21 | + public int bodyViewIndex; | |
22 | + public int layerNumber; | |
23 | + public int bodyRegionId; | |
24 | + public int zoom; | |
25 | + public List<Term> terms; | |
26 | + | |
27 | + public BodyRegionImage() | |
28 | + { | |
29 | + this.terms = new List<Term>(); | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + public class Term | |
34 | + { | |
35 | + public int TermNumber; | |
36 | + public List<int> SystemNumbers; | |
37 | + public List<int> PixelLocations; | |
38 | + public int ActualTermNumber; | |
39 | + | |
40 | + public Term(int termNumber, int systemNumber, int pixelLocation) | |
41 | + { | |
42 | + this.SystemNumbers = new List<int>(); | |
43 | + this.PixelLocations = new List<int>(); | |
44 | + this.TermNumber = termNumber; | |
45 | + this.SystemNumbers.Add(systemNumber); | |
46 | + this.PixelLocations.Add(pixelLocation); | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + | |
51 | + | |
52 | + | |
53 | + public class Program | |
54 | + { | |
55 | + //public JObject data { get; set; } | |
56 | + // public Dictionary<int, Term> termList; | |
57 | + | |
58 | + internal void saveImageData(JObject data, int bodyviewId) | |
59 | + { | |
60 | + // DateTime datetime = new DateTime(); | |
61 | + Console.WriteLine("AT "+ DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz")+"..In saveImageData. for imageName: "+ data["imageName"].ToString()+ ",bodyViewIndex= "+ data["bodyViewIndex"]+ ",layerNumber: "+ | |
62 | + data["layerNumber"]+ ",bodyRegionId= "+ data["bodyRegion"]); | |
63 | + try | |
64 | + { | |
65 | + BodyRegionImage bodyRegionImage = new BodyRegionImage(); | |
66 | + | |
67 | + var client = new MongoClient(); | |
68 | + | |
69 | + var db = client.GetDatabase("AIADB_bodyviewId"+bodyviewId.ToString()); | |
70 | + | |
71 | + var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
72 | + | |
73 | + JObject imageData = data; | |
74 | + | |
75 | + | |
76 | + | |
77 | + string bodyViewIndex = data["bodyViewIndex"].ToString(); | |
78 | + | |
79 | + string termFilePath = @"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\bodyViewsData\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
80 | + //string termFilePath = @"D:\100-PROJECTS\008-AIAHighlight.FileSave\dist\assets\data\json\da\body-views\" + bodyViewIndex + "\\da_dat_body_system_term_" + bodyViewIndex + ".json"; | |
81 | + | |
82 | + string systemTermMapping; | |
83 | + using (StreamReader reader = new StreamReader(termFilePath)) | |
84 | + | |
85 | + // using (StreamReader reader = new StreamReader(path+fileName)) | |
86 | + { | |
87 | + systemTermMapping = reader.ReadToEnd(); | |
88 | + } | |
89 | + | |
90 | + JObject systemTermMappingObject = JObject.Parse(systemTermMapping); | |
91 | + | |
92 | + //Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + ".systemTermMappingObject created."); | |
93 | + | |
94 | + dynamic systemTerms = systemTermMappingObject["BodySystem"]["BodySystemTerm"]; | |
95 | + | |
96 | + JObject sysT = JObject.Parse(systemTerms); | |
97 | + | |
98 | + dynamic imageDataArray = data["data"]; | |
99 | + | |
100 | + Dictionary<int,Term> termList = new Dictionary<int, Term>(); | |
101 | + | |
102 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..before itrating imageDataArray. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
103 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
104 | + | |
105 | + for (int i = 0; i < imageDataArray.Count; i += 4) | |
106 | + { | |
107 | + if(imageDataArray[i] == 0 && imageDataArray[i+1] == 0 && imageDataArray[i+2] == 0) | |
108 | + { | |
109 | + continue; | |
110 | + } | |
111 | + var RED = Convert.ToInt32(imageDataArray[i]) - 9; | |
112 | + var GREEN = Convert.ToInt32(imageDataArray[i + 1]) - 9; | |
113 | + var BLUE = Convert.ToInt32(imageDataArray[i + 2]) - 9; | |
114 | + | |
115 | + if (RED == -9 && GREEN == -9 && BLUE == -9) | |
116 | + continue; | |
117 | + | |
118 | + var Red = ""; | |
119 | + var Green = ""; | |
120 | + var Blue = ""; | |
121 | + string zero = "0"; | |
122 | + | |
123 | + if ((RED).ToString().Length != 2) | |
124 | + { | |
125 | + Red = zero + RED.ToString(); | |
126 | + } | |
127 | + else | |
128 | + { | |
129 | + Red = RED.ToString(); | |
130 | + } | |
131 | + if ((GREEN).ToString().Length != 2) | |
132 | + { | |
133 | + Green = zero + GREEN.ToString(); | |
134 | + } | |
135 | + else | |
136 | + { | |
137 | + Green = GREEN.ToString(); | |
138 | + } | |
139 | + if ((BLUE).ToString().Length != 2) | |
140 | + { | |
141 | + Blue = zero + BLUE.ToString(); | |
142 | + } | |
143 | + else | |
144 | + { | |
145 | + Blue = BLUE.ToString(); | |
146 | + } | |
147 | + | |
148 | + string Icolor = (Red + Green + Blue); | |
149 | + | |
150 | + | |
151 | + | |
152 | + foreach (dynamic systemTerm in systemTerms) | |
153 | + { | |
154 | + | |
155 | + int iColor = Convert.ToInt32(Icolor); | |
156 | + int termNumber = Convert.ToInt32(systemTerm._TermNumber.ToString()); | |
157 | + int systemNumber = Convert.ToInt32(systemTerm._SystemNumber.ToString()); | |
158 | + | |
159 | + if (systemTerm._TermNumber.ToString() == Icolor) | |
160 | + { | |
161 | + this.AddToTermList(termNumber, systemNumber, i, termList); | |
162 | + //this.AddToTermList(termNumber, systemNumber, i, termList); | |
163 | + this.AddToTermList(termNumber, systemNumber, i + 1, termList); | |
164 | + this.AddToTermList(termNumber, systemNumber, i + 2, termList); | |
165 | + break; | |
166 | + } | |
167 | + } | |
168 | + } | |
169 | + | |
170 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..after craeting termList.. for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
171 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
172 | + | |
173 | + bodyRegionImage.imageName = data["imageName"].ToString(); | |
174 | + bodyRegionImage.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
175 | + bodyRegionImage.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
176 | + bodyRegionImage.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
177 | + bodyRegionImage.zoom = Convert.ToInt32(data["zoom"]); | |
178 | + | |
179 | + foreach (int key in termList.Keys) | |
180 | + { | |
181 | + bodyRegionImage.terms.Add(termList[key]); | |
182 | + } | |
183 | + | |
184 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "...inserting for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
185 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
186 | + | |
187 | + col.InsertOne(bodyRegionImage); | |
188 | + | |
189 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..inserted for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
190 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]); | |
191 | + | |
192 | + var logCol = db.GetCollection<BodyRegionImage>("DAImageLogs"); | |
193 | + | |
194 | + BodyRegionImage bodyRegionImageTolog = new BodyRegionImage(); | |
195 | + bodyRegionImageTolog.bodyViewIndex = Convert.ToInt32(data["bodyViewIndex"]); | |
196 | + bodyRegionImageTolog.layerNumber = Convert.ToInt32(data["layerNumber"]); | |
197 | + bodyRegionImageTolog.bodyRegionId = Convert.ToInt32(data["bodyRegion"]); | |
198 | + bodyRegionImageTolog.zoom = Convert.ToInt32(data["zoom"]); | |
199 | + | |
200 | + logCol.InsertOne(bodyRegionImageTolog); | |
201 | + | |
202 | + bodyRegionImageTolog = null; | |
203 | + | |
204 | + data = null; | |
205 | + termList = null; | |
206 | + systemTermMappingObject = null; | |
207 | + systemTerms = null; | |
208 | + } | |
209 | + catch(Exception ex) | |
210 | + { | |
211 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "..Exception occured for imageName: " + data["imageName"].ToString() + ",bodyViewIndex= " + data["bodyViewIndex"] + ",layerNumber: " + | |
212 | + data["layerNumber"] + ",bodyRegionId= " + data["bodyRegion"]+"... EXCEPTION= "+ex.Message+".. STACKTRACE= "+ex.StackTrace); | |
213 | + | |
214 | + } | |
215 | + | |
216 | + | |
217 | + } | |
218 | + | |
219 | + public void AddToTermList(int termNumber, int systemNumber, int pixelLocation,Dictionary<int, Term> termList) | |
220 | + { | |
221 | + if (!termList.ContainsKey(termNumber)) | |
222 | + { | |
223 | + termList.Add(termNumber, new Term(termNumber, systemNumber, pixelLocation)); | |
224 | + } | |
225 | + else | |
226 | + { | |
227 | + bool isSystemNumberExisting = false; | |
228 | + foreach (int sn in termList[termNumber].SystemNumbers) | |
229 | + { | |
230 | + if (systemNumber == sn) | |
231 | + { | |
232 | + isSystemNumberExisting = true; | |
233 | + break; | |
234 | + } | |
235 | + | |
236 | + } | |
237 | + if (!isSystemNumberExisting) | |
238 | + termList[termNumber].SystemNumbers.Add(systemNumber); | |
239 | + | |
240 | + bool isPixelLocationExisting = false; | |
241 | + foreach (int pl in termList[termNumber].PixelLocations) | |
242 | + { | |
243 | + if (pixelLocation == pl) | |
244 | + { | |
245 | + isPixelLocationExisting = true; | |
246 | + break; | |
247 | + } | |
248 | + | |
249 | + } | |
250 | + if (!isPixelLocationExisting) | |
251 | + termList[termNumber].PixelLocations.Add(pixelLocation); | |
252 | + | |
253 | + } | |
254 | + } | |
255 | + | |
256 | + | |
257 | + | |
258 | + | |
259 | + static void Main(string[] args) | |
260 | + { | |
261 | + | |
262 | + Console.WriteLine("Enter BodyViewId"); | |
263 | + int BodyViewIndex = Convert.ToInt32(Console.ReadLine()); | |
264 | + | |
265 | + Program program = new Program(); | |
266 | + program.getAlreadyInsertedLayer(BodyViewIndex.ToString()); | |
267 | + program = null; | |
268 | + | |
269 | + } | |
270 | + | |
271 | + internal void getAlreadyInsertedLayer(string bodyviewId) | |
272 | + { | |
273 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "inside getAlreadyInsertedLayer"); | |
274 | + int totalLayers = 0; | |
275 | + int [] totalBodyReigons =null; | |
276 | + List<int> bodyRegions = new List<int>(); | |
277 | + | |
278 | + switch (Convert.ToInt32(bodyviewId)) | |
279 | + { | |
280 | + case 1: | |
281 | + totalLayers = 330; | |
282 | + totalBodyReigons = new int[6] {1,2,3,4,5,6}; | |
283 | + bodyRegions.Add(1); | |
284 | + bodyRegions.Add(2); | |
285 | + bodyRegions.Add(3); | |
286 | + bodyRegions.Add(4); | |
287 | + bodyRegions.Add(5); | |
288 | + bodyRegions.Add(6); | |
289 | + break; | |
290 | + case 2: | |
291 | + totalLayers = 288; | |
292 | + // totalBodyReigons = 6; | |
293 | + break; | |
294 | + case 3: | |
295 | + totalLayers = 127; | |
296 | + // totalBodyReigons = 6; | |
297 | + break; | |
298 | + case 4: | |
299 | + totalLayers = 186; | |
300 | + // totalBodyReigons = 6; | |
301 | + break; | |
302 | + case 5: | |
303 | + totalLayers = 229; | |
304 | + // totalBodyReigons = 6; | |
305 | + break; | |
306 | + case 6: | |
307 | + totalLayers = 289; | |
308 | + // totalBodyReigons = 6; | |
309 | + break; | |
310 | + case 7: | |
311 | + totalLayers = 130; | |
312 | + // totalBodyReigons = 6; | |
313 | + break; | |
314 | + case 8: | |
315 | + totalLayers = 186; | |
316 | + // totalBodyReigons = 6; | |
317 | + break; | |
318 | + case 9: | |
319 | + totalLayers = 64; | |
320 | + // totalBodyReigons = 6; | |
321 | + break; | |
322 | + case 10: | |
323 | + totalLayers = 72; | |
324 | + // totalBodyReigons = 6; | |
325 | + break; | |
326 | + case 11: | |
327 | + totalLayers = 64; | |
328 | + // totalBodyReigons = 6; | |
329 | + break; | |
330 | + case 12: | |
331 | + totalLayers = 72; | |
332 | + // totalBodyReigons = 6; | |
333 | + break; | |
334 | + } | |
335 | + | |
336 | + var client = new MongoClient(); | |
337 | + var db = client.GetDatabase("AIADB_bodyviewId" + bodyviewId.ToString()); | |
338 | + //var db = client.GetDatabase("AIAImageDB"); | |
339 | + | |
340 | + var col = db.GetCollection<BodyRegionImage>("DAImagesLogs"); | |
341 | + //var col = db.GetCollection<BodyRegionImage>("DAImages"); | |
342 | + | |
343 | + | |
344 | + FilterDefinition<BodyRegionImage>[] filterCondition = { | |
345 | + Builders<BodyRegionImage>.Filter.Eq("bodyViewIndex", Convert.ToInt32(bodyviewId))}; | |
346 | + | |
347 | + dynamic list = col.Find(Builders<BodyRegionImage>.Filter.And(filterCondition)).Project(Builders<BodyRegionImage>.Projection.Include("layerNumber").Include("bodyRegionId")).ToList(); | |
348 | + //collection.Find(new BsonDocument()).Project(Builders<BsonDocument>.Projection.Include("Price").Exclude("_id")).ToListAsync(); | |
349 | + // return list; | |
350 | + Dictionary<int, List<int>> layersToProcess = new Dictionary<int, List<int>>(); | |
351 | + | |
352 | + for (int i = 1; i <= totalLayers; i++) | |
353 | + { | |
354 | + List<int> bodyRegionForThisLayer = new List<int>(); | |
355 | + bodyRegionForThisLayer.Add(1); | |
356 | + bodyRegionForThisLayer.Add(2); | |
357 | + bodyRegionForThisLayer.Add(3); | |
358 | + bodyRegionForThisLayer.Add(4); | |
359 | + bodyRegionForThisLayer.Add(5); | |
360 | + bodyRegionForThisLayer.Add(6); | |
361 | + | |
362 | + int previousLayerNumber = 0; | |
363 | + int existingLayerNumber = 0; | |
364 | + bool isLayerMatched = false; | |
365 | + | |
366 | + foreach (dynamic lNumber in list) | |
367 | + { | |
368 | + existingLayerNumber = Convert.ToInt32((lNumber.GetValue("layerNumber")).ToString()); | |
369 | + | |
370 | + if (existingLayerNumber == i) | |
371 | + { | |
372 | + isLayerMatched = true; | |
373 | + int existingBodyRegionId = Convert.ToInt32((lNumber.GetValue("bodyRegionId")).ToString()); | |
374 | + | |
375 | + | |
376 | + if (bodyRegionForThisLayer.Contains(existingBodyRegionId)) { | |
377 | + //remove from bodyRegions list as this is already present | |
378 | + bodyRegionForThisLayer.Remove(existingBodyRegionId); | |
379 | + } | |
380 | + previousLayerNumber = existingLayerNumber; | |
381 | + | |
382 | + } | |
383 | + | |
384 | + else | |
385 | + { | |
386 | + | |
387 | + } | |
388 | + | |
389 | + } | |
390 | + if(isLayerMatched) | |
391 | + layersToProcess.Add(previousLayerNumber, bodyRegionForThisLayer); | |
392 | + else | |
393 | + layersToProcess.Add(i, bodyRegionForThisLayer); | |
394 | + } | |
395 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "after preparing list to process"); | |
396 | + | |
397 | + makeFileNameAndProcess(layersToProcess,Convert.ToInt32(bodyviewId)); | |
398 | + } | |
399 | + | |
400 | + | |
401 | + internal void makeFileNameAndProcess(Dictionary<int, List<int>> filesToProcess, int BodyViewIndex) | |
402 | + { | |
403 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "in makeFileNameAndProcess"); | |
404 | + | |
405 | + foreach (KeyValuePair<int, List<int>> pair in filesToProcess) | |
406 | + { | |
407 | + | |
408 | + | |
409 | + foreach (int item in pair.Value) | |
410 | + { | |
411 | + string fileName = "BodyView" + BodyViewIndex + "_layer" + pair.Key + "_bodyRegionId" + item+".json"; | |
412 | + | |
413 | + //string filePath = @"D:\100-PROJECTS\008-AIAHighlight.FileSave\AIAHighlight\AIAHighlight\data\" + fileName; | |
414 | + string filePath = @"C:\ADAM-AWS-FTP\ADAM-AWS\AIAHTML5\data\" + fileName; | |
415 | + getDataFromFileAndSaveInDB(filePath, BodyViewIndex); | |
416 | + } | |
417 | + | |
418 | + } | |
419 | + } | |
420 | + | |
421 | + internal void processFiles(string[] files,int bodyviewId) | |
422 | + { | |
423 | + | |
424 | + //without multithreading | |
425 | + foreach(string filename in files) | |
426 | + { | |
427 | + Console.WriteLine("AT " + DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz") + "in processFiles for filename"); | |
428 | + getDataFromFileAndSaveInDB(filename, bodyviewId); | |
429 | + } | |
430 | + | |
431 | + } | |
432 | + | |
433 | + | |
434 | + | |
435 | + internal void getDataFromFileAndSaveInDB(string filePath,int bodyViewId) | |
436 | + { | |
437 | + if (File.Exists(filePath)) | |
438 | + { | |
439 | + string fileData; | |
440 | + using (StreamReader reader = new StreamReader(filePath)) | |
441 | + { | |
442 | + fileData = reader.ReadToEnd(); | |
443 | + | |
444 | + JObject data = JObject.Parse(fileData); | |
445 | + this.saveImageData(data, bodyViewId); | |
446 | + } | |
447 | + | |
448 | + | |
449 | + } | |
450 | + else | |
451 | + { | |
452 | + Console.WriteLine("FILE.NOT.FOUND AT" + | |
453 | + ": " + filePath); | |
454 | + | |
455 | + } | |
456 | + } | |
457 | + } | |
458 | +} | ... | ... |
600-POC/fileSave/jsonFile_generate/AJs/app.component.css
0 → 100644
600-POC/fileSave/jsonFile_generate/AJs/app.component.html
0 → 100644
1 | +<div> | |
2 | + bodyViewId: <input type="text" name="bodyViewId" [(ngModel)]="bodyViewId" /><div>{{bodyViewId}}</div> | |
3 | + layerNo: <input type="text" name="layerNo" [(ngModel)]="layerNo" /> | |
4 | + <button id="generateFile" (click)="generateFile()">Generate Files</button> | |
5 | +</div> | |
0 | 6 | \ No newline at end of file | ... | ... |
600-POC/fileSave/jsonFile_generate/AJs/app.component.spec.ts
0 → 100644
1 | +import { TestBed, async } from '@angular/core/testing'; | |
2 | + | |
3 | +import { AppComponent } from './app.component'; | |
4 | + | |
5 | +describe('AppComponent', () => { | |
6 | + beforeEach(async(() => { | |
7 | + TestBed.configureTestingModule({ | |
8 | + declarations: [ | |
9 | + AppComponent | |
10 | + ], | |
11 | + }).compileComponents(); | |
12 | + })); | |
13 | + | |
14 | + it('should create the app', async(() => { | |
15 | + const fixture = TestBed.createComponent(AppComponent); | |
16 | + const app = fixture.debugElement.componentInstance; | |
17 | + expect(app).toBeTruthy(); | |
18 | + })); | |
19 | + | |
20 | + it(`should have as title 'app works!'`, async(() => { | |
21 | + const fixture = TestBed.createComponent(AppComponent); | |
22 | + const app = fixture.debugElement.componentInstance; | |
23 | + expect(app.title).toEqual('app works!'); | |
24 | + })); | |
25 | + | |
26 | + it('should render title in a h1 tag', async(() => { | |
27 | + const fixture = TestBed.createComponent(AppComponent); | |
28 | + fixture.detectChanges(); | |
29 | + const compiled = fixture.debugElement.nativeElement; | |
30 | + expect(compiled.querySelector('h1').textContent).toContain('app works!'); | |
31 | + })); | |
32 | +}); | ... | ... |
600-POC/fileSave/jsonFile_generate/AJs/app.component.ts
0 → 100644
1 | + | |
2 | +import { Component, AfterViewInit, ViewChild } from '@angular/core'; | |
3 | +import { ImageService } from './services/image.service'; | |
4 | + | |
5 | +declare var jQuery: any; | |
6 | +declare var jinqJs: any; | |
7 | + | |
8 | +@Component({ | |
9 | + selector: 'app-root', | |
10 | + templateUrl: './app.component.html', | |
11 | + styleUrls: ['./app.component.css'], | |
12 | + providers: [ImageService] | |
13 | +}) | |
14 | +export class AppComponent implements AfterViewInit { | |
15 | + title = 'app works!'; | |
16 | + context: CanvasRenderingContext2D; | |
17 | + bodyViewData: any; | |
18 | + imageData: any; | |
19 | + imageDataCollection: Array<any>; | |
20 | + imageCount: number; | |
21 | + isLayerProcessCompleted: boolean; | |
22 | + totalBodyViews: number; | |
23 | + bodyViewIndex: number; | |
24 | + currentLayer: number; | |
25 | + datalayerLength: number; | |
26 | + bodyRegionInLayer: Array<any>;; | |
27 | + BRCounter: number; | |
28 | + layerNo: string; | |
29 | + bodyViewId: string; | |
30 | + remainingFiles75: any; | |
31 | + remainingFiles25: any; | |
32 | + bodyRegionId: number; | |
33 | + previousBodyViewId: number; | |
34 | + counter: number; | |
35 | + constructor(private imageService: ImageService) { | |
36 | + this.imageData = new Object(); | |
37 | + this.imageDataCollection = new Array<any>(); | |
38 | + this.isLayerProcessCompleted = true; | |
39 | + this.totalBodyViews = 12; | |
40 | + this.bodyViewIndex = 2; | |
41 | + this.currentLayer = 95; | |
42 | + this.previousBodyViewId = 0; | |
43 | + this.counter = 0; | |
44 | + } | |
45 | + | |
46 | + ngAfterViewInit(): void { | |
47 | + // this.getBodyViewJson(); | |
48 | + //for (let i = 1; i <= 12; i++) { | |
49 | + // this.imageService.getBodyViewData(i).subscribe((data) => { | |
50 | + // this.bodyViewData = data.json(); | |
51 | + // this.saveBodyViewImageData(); | |
52 | + // }); | |
53 | + //} | |
54 | + } | |
55 | + | |
56 | + | |
57 | + getBodyViewJson() { | |
58 | + console.log("inside getBodyViewJson for this.bodyViewIndex= " + this.bodyViewIndex); | |
59 | + this.previousBodyViewId = this.bodyViewIndex; | |
60 | + this.imageService.getBodyViewData(this.bodyViewIndex).subscribe((data) => { | |
61 | + console.log("Fetched body view json for bodyViewIndex: " + this.bodyViewIndex); | |
62 | + this.bodyViewData = data.json(); | |
63 | + this.getImageName(); | |
64 | + }); | |
65 | + } | |
66 | + | |
67 | + getImageName(): void { | |
68 | + | |
69 | + //var layerData = this.bodyViewData.filter(lNo => lNo._LayerNumber == this.layerNo); | |
70 | + //var bodyRegiondata = layerData.filter(br => br._BodyRegionId == this.bodyRegionId); | |
71 | + | |
72 | + //var layerData = this.bodyViewData.find(findData); | |
73 | + //var bodyRegiondata = layerData.filter(findData);\ | |
74 | + console.log("getImageName:" + this.currentLayer); | |
75 | + var layerNumber = this.currentLayer + 1; | |
76 | + console.log('layerNumber= ' + layerNumber); | |
77 | + var layerData = new jinqJs() | |
78 | + .from(this.bodyViewData.Layers.DataLayer) | |
79 | + .where('_LayerNumber == ' + layerNumber) | |
80 | + .select(); | |
81 | + alert("layerData= " + layerData[0]); | |
82 | + | |
83 | + | |
84 | + var bodyRegiondata = new jinqJs() | |
85 | + .from(layerData[0].BodyRegion) | |
86 | + .where('_BodyRegionId == ' + this.bodyRegionId) | |
87 | + .select(); | |
88 | + | |
89 | + alert("bodyRegiondata= " + bodyRegiondata); | |
90 | + | |
91 | + const imgName = bodyRegiondata[0].Image._ImageName.split('.')[0] + '_mci.png'; | |
92 | + const skintone = bodyRegiondata[0].Image._SkintTone; | |
93 | + const bodyRegionId = bodyRegiondata[0]._BodyRegionId; | |
94 | + | |
95 | + console.log("inside getImageName. imgName= " + imgName + ",skintone= " + skintone); | |
96 | + | |
97 | + this.drawImage(imgName, this.bodyViewIndex, this.currentLayer, bodyRegionId, 75, skintone); | |
98 | + | |
99 | + } | |
100 | + | |
101 | + findData(layer):any { | |
102 | + return layer._LayerNumber === this.layerNo; | |
103 | + } | |
104 | + saveBodyViewImageData(): void { | |
105 | + this.datalayerLength = this.bodyViewData.Layers.DataLayer.length; | |
106 | + console.log('this.datalayerLength= ' + this.datalayerLength); | |
107 | + console.log('this.bodyViewData.Layers.DataLayer = ' + this.bodyViewData.Layers.DataLayer); | |
108 | + this.processLayer(); | |
109 | + //for (let i = 0; i <= datalayerLength-1; i++) { | |
110 | + // const bodyRegions = this.bodyViewData.Layers.DataLayer[datalayerLength - i - 1].BodyRegion; | |
111 | + // let k = 1; | |
112 | + // this.imageCount = bodyRegions.length; | |
113 | + // for (let j = bodyRegions.length - 1; j >= 0; j--) { | |
114 | + // const imgName = bodyRegions[j].Image._ImageName.split('.')[0] + '_mci.png'; | |
115 | + // this.drawImage(imgName, 1, i, k, 75); | |
116 | + | |
117 | + // if (j === 0) { | |
118 | + // k = 1; | |
119 | + // } else { | |
120 | + // k = k + 1; | |
121 | + // } | |
122 | + | |
123 | + // } | |
124 | + //} | |
125 | + } | |
126 | + | |
127 | + processLayer(): void { | |
128 | + console.log("Processing started for layer: " + this.currentLayer + ' of bodyViewIndex: ' + this.bodyViewIndex + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
129 | + this.imageDataCollection = null; | |
130 | + this.imageDataCollection = new Array<any>(); | |
131 | + this.BRCounter = 1; | |
132 | + this.bodyRegionInLayer = new Array<any>(); | |
133 | + console.log('inside processLayer. this.bodyViewData.Layers.DataLayer = ' + this.bodyViewData.Layers.DataLayer); | |
134 | + //console.log('this.bodyViewData.Layers.DataLayer[63].BodyRegion = ' + this.bodyViewData.Layers.DataLayer[63].BodyRegion); | |
135 | + //console.log('this.datalayerLength - this.currentLayer - 1= ' + (this.datalayerLength - this.currentLayer - 1)); | |
136 | + const bodyRegions = this.bodyViewData.Layers.DataLayer[this.datalayerLength - this.currentLayer - 1].BodyRegion; | |
137 | + //console.log('bodyRegions= ' + bodyRegions + ' this.bodyViewData.Layers.DataLayer[this.datalayerLength - this.currentLayer - 1].BodyRegion.length= ' + (this.bodyViewData.Layers.DataLayer[this.datalayerLength - this.currentLayer - 1].BodyRegion).length); | |
138 | + //console.log("Process layer: " + this.currentLayer + ", bodyRegions length= " + bodyRegions.length); | |
139 | + //console.log('abc= ' + bodyRegions._BodyRegionId + ', xyze= ' + bodyRegions.Image._ImageName); | |
140 | + //let k = 1; | |
141 | + if (this.bodyViewIndex == 9 || this.bodyViewIndex == 10 || this.bodyViewIndex == 11 || this.bodyViewIndex == 12) { | |
142 | + | |
143 | + this.imageCount = 1; | |
144 | + const imgName = bodyRegions.Image._ImageName.split('.')[0] + '_mci.png'; | |
145 | + const skintone = bodyRegions.Image._SkintTone; | |
146 | + const bodyRegionId = bodyRegions._BodyRegionId; | |
147 | + this.drawImage(imgName, this.bodyViewIndex, this.currentLayer, bodyRegionId, 25, skintone); | |
148 | + | |
149 | + } | |
150 | + else{ | |
151 | + this.imageCount = bodyRegions.length; | |
152 | + for (let j = bodyRegions.length - 1; j >= 0; j--) { | |
153 | + const imgName = bodyRegions[j].Image._ImageName.split('.')[0] + '_mci.png'; | |
154 | + const skintone = bodyRegions[j].Image._SkintTone; | |
155 | + const bodyRegionId = bodyRegions[j]._BodyRegionId; | |
156 | + //for missing BRs | |
157 | + // if (bodyRegionId == 2 || bodyRegionId == 3 || bodyRegionId == 6) { | |
158 | + | |
159 | + this.drawImage(imgName, this.bodyViewIndex, this.currentLayer, bodyRegionId, 25, skintone); | |
160 | + // } | |
161 | + | |
162 | + } //if (j === 0) { | |
163 | + // k = 1; | |
164 | + //} else { | |
165 | + // k = k + 1; | |
166 | + //} | |
167 | + | |
168 | + } | |
169 | + } | |
170 | + | |
171 | + drawImage(imageName: string, bodyViewIndex: number, layerNumber: number, bodyRegionIndex: number, zoom: number, skintone: string): void { | |
172 | + console.log('drawImage for bodyViewIndex= ' + bodyViewIndex + ',layerNumber= ' + layerNumber + ',bodyRegionIndex= ' + bodyRegionIndex); | |
173 | + //if (layerNumber == 0) { | |
174 | + // console.log('drawImage.in if block. for bodyViewIndex= ' + bodyViewIndex + ',layerNumber= ' + layerNumber + ',bodyRegionIndex= ' + bodyRegionIndex); | |
175 | + | |
176 | + // const img = new Image(); | |
177 | + // img.src = '../assets/images/da/' + zoom + '/body-views/' + bodyViewIndex + '/layers/' + layerNumber + '/' + bodyRegionIndex + '/' + skintone + '/' + imageName; | |
178 | + // img.onload = (() => { | |
179 | + // this.imageData.imageName = imageName; | |
180 | + // this.imageData.bodyViewIndex = bodyViewIndex; | |
181 | + // this.imageData.layerNumber = layerNumber; | |
182 | + // this.imageData.bodyRegion = bodyRegionIndex; | |
183 | + // const canvas: HTMLCanvasElement = document.createElement('canvas'); | |
184 | + // canvas.width = this.imageData.width = img.width; | |
185 | + // canvas.height = this.imageData.height = img.height; | |
186 | + // this.context = canvas.getContext('2d'); | |
187 | + // this.context.drawImage(img, 0, 0); | |
188 | + // this.imageData.data = Array.from(this.context.getImageData(0, 0, img.width, img.height).data); | |
189 | + // console.log(this.imageData); | |
190 | + // this.writeImageDataToJson(this.imageData); | |
191 | + // this.imageData = new Object(); | |
192 | + // }); | |
193 | + | |
194 | + | |
195 | + // } | |
196 | + | |
197 | + // else { | |
198 | + console.log('drawImage.in else block. for bodyViewIndex= ' + bodyViewIndex + ',layerNumber= ' + layerNumber + ',bodyRegionIndex= ' + bodyRegionIndex); | |
199 | + | |
200 | + var img = new Image(); | |
201 | + img.id = 'canvasImg'; | |
202 | + | |
203 | + img.src = '../assets/images/da/' + zoom + '/body-views/' + bodyViewIndex + '/layers/' + layerNumber + '/' + bodyRegionIndex + '/' + imageName; | |
204 | + img.onload = (() => { | |
205 | + console.log("onload. img.src= " + img.src); | |
206 | + this.imageData.imageName = imageName; | |
207 | + this.imageData.bodyViewIndex = bodyViewIndex; | |
208 | + this.imageData.layerNumber = layerNumber; | |
209 | + this.imageData.bodyRegion = bodyRegionIndex; | |
210 | + this.imageData.zoom = zoom; | |
211 | + var elem = document.getElementById("imgCanvas"); | |
212 | + if (elem != null) { | |
213 | + elem.parentNode.removeChild(elem); | |
214 | + elem = null; | |
215 | + } | |
216 | + var canvas: HTMLCanvasElement = document.createElement('canvas'); | |
217 | + canvas.id = 'imgCanvas'; | |
218 | + canvas.width = this.imageData.width = img.width; | |
219 | + canvas.height = this.imageData.height = img.height; | |
220 | + this.context = canvas.getContext('2d'); | |
221 | + this.context.drawImage(img, 0, 0); | |
222 | + this.imageData.data = Array.from(this.context.getImageData(0, 0, img.width, img.height).data); | |
223 | + console.log("imageData of of bodyViewIndex: " + this.bodyViewIndex + ", layerNumber: " + layerNumber + ", bodyRegionIndex: " + bodyRegionIndex + ", imgData= " + this.imageData); | |
224 | + this.writeImageDataToJson(this.imageData); | |
225 | + var elem1 = document.getElementById("canvasImg"); | |
226 | + if (elem1 != null) { | |
227 | + elem1.parentNode.removeChild(elem1); | |
228 | + elem1 = null; | |
229 | + } | |
230 | + this.imageData = new Object(); | |
231 | + }); | |
232 | + //} | |
233 | + // canvas.width = canvas.width; // to clear the canvas | |
234 | + | |
235 | + // console.log(img.src); | |
236 | + } | |
237 | + | |
238 | + writeImageDataToJson(imageData: any): void { | |
239 | + this.imageService.updateImageData(imageData).subscribe((resp) => { | |
240 | + console.log('inside subscribe of addToImageDataCollection: result= ' + 'bodyViewIndex:' + resp.bodyViewIndex + ',layerNumber:' + resp.layerNumber + ',bodyRegionId:' + resp.bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
241 | + if (this.counter < this.remainingFiles75.length) { | |
242 | + this.counter++; | |
243 | + this.getDataFromFile(this.remainingFiles75, this.counter); | |
244 | + } | |
245 | + }); | |
246 | + } | |
247 | + | |
248 | + addToImageDataCollection(imageData: any): void { | |
249 | + for (let i = 0; i < this.imageDataCollection.length; i++) { | |
250 | + if (this.imageDataCollection[i].imageName === imageData.imageName) { | |
251 | + return; | |
252 | + } | |
253 | + } | |
254 | + this.imageDataCollection.push(imageData); | |
255 | + console.log("this.imageDataCollection.length= " + this.imageDataCollection.length); | |
256 | + | |
257 | + if (this.imageDataCollection.length === this.imageCount) { | |
258 | + console.log("starting pushing to server for layer: " + this.currentLayer + " of bodyViewIndex: " + this.bodyViewIndex + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
259 | + for (let i = 0; i < this.imageDataCollection.length; i++) { | |
260 | + this.imageService.updateImageData(this.imageDataCollection[i]).subscribe((resp) => { | |
261 | + | |
262 | + // alert("resp:" + resp.isSuccess); | |
263 | + // this.BRCounter++; | |
264 | + | |
265 | + this.bodyRegionInLayer.push({ 'bodyViewIndex': resp.bodyViewIndex, 'layerNumber': resp.layerNumber, 'bodyRegionId': resp.bodyRegionId }); | |
266 | + | |
267 | + console.log('inside subscribe of addToImageDataCollection: result= ' + 'bodyViewIndex:' + resp.bodyViewIndex + ',layerNumber:' + resp.layerNumber + ',bodyRegionId:' + resp.bodyRegionId + ', time: ' + new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1")); | |
268 | + //if (i === this.imageDataCollection.length - 1 && this.BRCounter == this.imageCount) | |
269 | + //{ | |
270 | + | |
271 | + if (this.bodyRegionInLayer.length > 0 && this.bodyRegionInLayer.length == this.imageCount) { | |
272 | + //comparign with this.datalayerLength - 2(-2 due to we have not processed from layer 0) | |
273 | + if ((this.currentLayer <= this.datalayerLength - 2)) { | |
274 | + this.currentLayer++; | |
275 | + this.processLayer(); | |
276 | + } | |
277 | + else { | |
278 | + if (this.bodyViewIndex < this.totalBodyViews) { | |
279 | + this.bodyViewIndex++; | |
280 | + //if (this.bodyViewIndex == 3) { | |
281 | + | |
282 | + //} | |
283 | + //else { | |
284 | + this.currentLayer = 1; | |
285 | + this.getBodyViewJson(); | |
286 | + //} | |
287 | + } | |
288 | + } | |
289 | + } | |
290 | + }); | |
291 | + } | |
292 | + } | |
293 | + } | |
294 | + | |
295 | + generateFile(): void { | |
296 | + | |
297 | + //this.imageService.getRemianingFilesData('../remainingFies/RemainingFiles25'); | |
298 | + | |
299 | + //this.imageService.getBodyViewData(this.bodyViewIndex).subscribe((data) => { | |
300 | + // // console.log("Fetched body view json for bodyViewIndex: " + this.bodyViewIndex); | |
301 | + // this.remainingFiles25 = data; | |
302 | + // //this.saveBodyViewImageData(); | |
303 | + //}); | |
304 | + | |
305 | + | |
306 | + this.imageService.getRemianingFilesData('../assets/remainingFies/RemainingFiles75.json').subscribe((data) => { | |
307 | + console.log("Fetched RemainingFiles75.data= ====" + data); | |
308 | + | |
309 | + this.remainingFiles75 = data; | |
310 | + console.log("this.remainingFiles75.length= " + this.remainingFiles75.length) | |
311 | + | |
312 | + this.getDataFromFile(this.remainingFiles75, this.counter); | |
313 | + //for (let i = 0; i < this.remainingFiles75.length; i++) { | |
314 | + | |
315 | + | |
316 | + //} | |
317 | + }); | |
318 | + } | |
319 | + | |
320 | + getDataFromFile(remainingFiles75,i): void { | |
321 | + | |
322 | + var filename = this.remainingFiles75[i]; | |
323 | + var spiltedFileName = filename.split('_'); | |
324 | + | |
325 | + var bodyViewString = spiltedFileName[0]; | |
326 | + // alert("bodyViewString: " + bodyViewString + "bodyViewString.indexOf('w'):" + bodyViewString.indexOf('w') + ".bodyViewString.Length: " + bodyViewString.length); | |
327 | + | |
328 | + var indexofW = bodyViewString.indexOf('w'); | |
329 | + var bodyViewId = bodyViewString.substring(indexofW + 1); | |
330 | + | |
331 | + | |
332 | + | |
333 | + var layerString = spiltedFileName[1]; | |
334 | + // alert("layerString: " + layerString + "layerString.indexOf('r'):" + layerString.indexOf('r') + ".layerString.Length: " + layerString.length); | |
335 | + | |
336 | + var indexofR = layerString.indexOf('r'); | |
337 | + var layerNo = layerString.substring(indexofR + 1); | |
338 | + | |
339 | + var brString = spiltedFileName[2]; | |
340 | + // alert("brString: " + brString + "brString.indexOf('id'):" + brString.indexOf("id") + ".brString.Length: " + brString.length); | |
341 | + | |
342 | + var indexofId = brString.indexOf("Id"); | |
343 | + var BRId = (brString.substring(indexofId + 2)).replace('.json', ''); | |
344 | + | |
345 | + this.currentLayer = parseInt(layerNo); | |
346 | + this.bodyViewIndex = parseInt(bodyViewId); | |
347 | + this.bodyRegionId = parseInt(BRId); | |
348 | + | |
349 | + console.log("bodyViewId= " + bodyViewId + ",layerNo= " + layerNo + ",BRId= " + BRId); | |
350 | + | |
351 | + | |
352 | + if (parseInt(layerNo) != 0) { | |
353 | + console.log("this.bodyViewIndex: " + this.bodyViewIndex + ", this.currentLayer: " + this.currentLayer + ", this.bodyRegionId:" + this.bodyRegionId); | |
354 | + this.getBodyViewJson(); | |
355 | + | |
356 | + } | |
357 | + //else { | |
358 | + // console.log("this.bodyViewIndex: " + this.bodyViewIndex + ", this.currentLayer: " + this.currentLayer + ", this.bodyRegionId:" + this.bodyRegionId); | |
359 | + // this.getBodyViewJson(); | |
360 | + //} | |
361 | + | |
362 | + } | |
363 | + | |
364 | + } | |
365 | + | |
366 | + | |
367 | + | ... | ... |
600-POC/fileSave/jsonFile_generate/AJs/app.module.ts
0 → 100644
1 | +import { BrowserModule } from '@angular/platform-browser'; | |
2 | +import { NgModule } from '@angular/core'; | |
3 | +import { FormsModule } from '@angular/forms'; | |
4 | +import { HttpModule } from '@angular/http'; | |
5 | + | |
6 | +import { AppComponent } from './app.component'; | |
7 | + | |
8 | +@NgModule({ | |
9 | + declarations: [ | |
10 | + AppComponent | |
11 | + ], | |
12 | + imports: [ | |
13 | + BrowserModule, | |
14 | + FormsModule, | |
15 | + HttpModule | |
16 | + ], | |
17 | + providers: [], | |
18 | + bootstrap: [AppComponent] | |
19 | +}) | |
20 | +export class AppModule { } | ... | ... |
600-POC/fileSave/jsonFile_generate/AJs/services/image.service.ts
0 → 100644
1 | +import { Injectable } from '@angular/core'; | |
2 | +import { Http, Response, Headers, URLSearchParams } from '@angular/http'; | |
3 | +import { Router } from '@angular/router'; | |
4 | + | |
5 | +import { Observable } from 'rxjs/Observable'; | |
6 | +import 'rxjs/add/operator/map'; | |
7 | +import 'rxjs/add/operator/catch'; | |
8 | + | |
9 | +declare var jQuery: any; | |
10 | + | |
11 | +@Injectable() | |
12 | +export class ImageService { | |
13 | + | |
14 | + constructor(private http: Http) { | |
15 | + | |
16 | + } | |
17 | + | |
18 | + public getRemianingFilesData(filePath: string): Observable<any> { | |
19 | + return this.http.get(filePath).map(this.getData).catch(this.handleError); | |
20 | + | |
21 | + } | |
22 | + public getBodyViewData(index: number): Observable<any> { | |
23 | + console.log("getBodyViewData.index :" + index); | |
24 | + return this.http.get('../assets/data/json/da/body-views/' + index + '/da_dat_layer_' + index + '.json'); | |
25 | + } | |
26 | + | |
27 | + public updateImageData(imageData: any): Observable<any> { | |
28 | + const headers = new Headers(); | |
29 | + headers.append('Content-Type', 'application/json'); | |
30 | + headers.append('bodyViewIndex', imageData.bodyViewIndex); | |
31 | + headers.append('layerNumber', imageData.layerNumber); | |
32 | + headers.append('bodyRegion', imageData.bodyRegion); | |
33 | + | |
34 | + let payload: string = JSON.stringify(imageData); | |
35 | + console.log('inside updateImageData.JSON.stringify(imageData)= ' + payload); | |
36 | + return this.http.post('/API/api/ProcessImage', payload, { headers: headers }) | |
37 | + .map(this.extractData) | |
38 | + .catch(this.handleError); | |
39 | + } | |
40 | + | |
41 | + //public updateImageData(imageData: any): any { | |
42 | + // const headers = new Headers(); | |
43 | + // headers.append('Content-Type', 'application/json'); | |
44 | + // let payload: string = JSON.stringify(imageData); | |
45 | + // console.log('inside updateImageData.JSON.stringify(imageData)= ' + payload); | |
46 | + // //return this.http.post('/API/api/ProcessImage', payload, { headers: headers }) | |
47 | + // // .map(this.extractData) | |
48 | + // // .catch(this.handleError); | |
49 | + // jQuery.ajax({ | |
50 | + // headers: { | |
51 | + // 'Accept': 'application/json', | |
52 | + // 'Content-Type': 'application/json' | |
53 | + // }, | |
54 | + // url: '/API/api/ProcessImage/Post', | |
55 | + // type: 'POST', | |
56 | + // data: { "value": payload }, | |
57 | + // success: function (result) { | |
58 | + // return result; | |
59 | + // } | |
60 | + // }); | |
61 | + //} | |
62 | +private getData(res:Response){ | |
63 | + const body = res.json(); | |
64 | + console.log("inside getData.body: "+body) | |
65 | + return body || {}; | |
66 | + } | |
67 | + | |
68 | + private extractData(res: Response) { | |
69 | + const body = res.json(); | |
70 | + return body || {}; | |
71 | + } | |
72 | + | |
73 | + private handleError(error: Response | any) { | |
74 | + // In a real world app, we might use a remote logging infrastructure | |
75 | + let errMsg: string; | |
76 | + if (error instanceof Response) { | |
77 | + const body = error.json() || ''; | |
78 | + const err = body.error || JSON.stringify(body); | |
79 | + errMsg = `${error.status} - ${error.statusText || ''} ${err}`; | |
80 | + } else { | |
81 | + errMsg = error.message ? error.message : error.toString(); | |
82 | + } | |
83 | + console.error(errMsg); | |
84 | + return Observable.throw(errMsg); | |
85 | + } | |
86 | +} | ... | ... |
600-POC/fileSave/jsonFile_generate/ProcessImageController.cs
0 → 100644
1 | +using AIAHighlight.Helpers; | |
2 | +using Newtonsoft.Json; | |
3 | +using Newtonsoft.Json.Linq; | |
4 | +using System; | |
5 | +using System.Collections.Generic; | |
6 | +using System.IO; | |
7 | +using System.Linq; | |
8 | +using System.Net; | |
9 | +using System.Net.Http; | |
10 | +using System.Threading.Tasks; | |
11 | +using System.Web; | |
12 | +using System.Web.Http; | |
13 | + | |
14 | +namespace AIAHighlight.Controllers | |
15 | +{ | |
16 | + public class ProcessImageController : ApiController | |
17 | + { | |
18 | + // GET: api/ProcessImage | |
19 | + public IEnumerable<string> Get() | |
20 | + { | |
21 | + return new string[] { "value1", "value2" }; | |
22 | + } | |
23 | + | |
24 | + // GET: api/ProcessImage/5 | |
25 | + public string Get(int id) | |
26 | + { | |
27 | + return "value"; | |
28 | + } | |
29 | + | |
30 | + // POST: api/ProcessImage | |
31 | + [HttpPost] | |
32 | + public async Task<HttpResponseMessage> Post(HttpRequestMessage request) | |
33 | + { | |
34 | + var httpRequest = HttpContext.Current.Request; | |
35 | + Stream requestStream = await request.Content.ReadAsStreamAsync(); | |
36 | + HttpResponseMessage result = null; | |
37 | + | |
38 | + IEnumerable<string> layerNumberHeaderValue = request.Headers.GetValues("layerNumber"); | |
39 | + var layerNumber = layerNumberHeaderValue.FirstOrDefault(); | |
40 | + | |
41 | + IEnumerable<string> bodyViewIndexHeaderValue = request.Headers.GetValues("bodyViewIndex"); | |
42 | + var bodyViewIndex = bodyViewIndexHeaderValue.FirstOrDefault(); | |
43 | + | |
44 | + IEnumerable<string> bodyRegionHeaderValue = request.Headers.GetValues("bodyRegion"); | |
45 | + var bodyRegionId = bodyRegionHeaderValue.FirstOrDefault(); | |
46 | + | |
47 | + if (requestStream != null) | |
48 | + { | |
49 | + | |
50 | + string fileName = "BodyView" + bodyViewIndex + "_layer" + layerNumber + "_bodyRegionId" + bodyRegionId; | |
51 | + // string filePath = "D:\\ADAM\\100-PROJECTS\\001-AIAHighlight.FileSave\\AIAHighlight.Serevr\\AIAHighlight\\data1\\75\\" + fileName + ".json"; | |
52 | + string filePath = "D:\\100-PROJECTS\\008-AIAHighlight.FileSave\\AIAHighlight\\AIAHighlight\\data1\\75\\" + fileName + ".json"; | |
53 | + | |
54 | + | |
55 | + try | |
56 | + { | |
57 | + using (FileStream fileStream = System.IO.File.Create(filePath, (int)requestStream.Length)) | |
58 | + { | |
59 | + // Fill the bytes[] array with the stream data | |
60 | + byte[] bytesInStream = new byte[requestStream.Length]; | |
61 | + // string response1 = (JsonConvert.SerializeObject(bytesInStream)); | |
62 | + requestStream.Read(bytesInStream, 0, (int)bytesInStream.Length); | |
63 | + // Use FileStream object to write to the specified file | |
64 | + fileStream.Write(bytesInStream, 0, bytesInStream.Length); | |
65 | + result = Request.CreateResponse(HttpStatusCode.Created, "TEMP.txt"); | |
66 | + } | |
67 | + return result; | |
68 | + } | |
69 | + catch (HttpException ex) | |
70 | + { | |
71 | + return result = Request.CreateResponse(HttpStatusCode.BadGateway, "Http Exception Come" + ex.Message); | |
72 | + } | |
73 | + catch (Exception ex) | |
74 | + { | |
75 | + return result = Request.CreateResponse(HttpStatusCode.BadGateway, "Http Exception Come" + ex.Message); | |
76 | + } | |
77 | + } | |
78 | + | |
79 | + return result; ; | |
80 | + } | |
81 | + //public HttpResponseMessage Post([FromBody]JObject image) | |
82 | + //{ | |
83 | + // dynamic response = new ProcessImageHelper().writeFile(image); | |
84 | + // return new HttpResponseMessage { StatusCode = HttpStatusCode.Created, Content = new StringContent(JsonConvert.SerializeObject(response)) }; | |
85 | + //} | |
86 | + | |
87 | + // PUT: api/ProcessImage/5 | |
88 | + //public void Put(int id, [FromBody]string value) | |
89 | + //{ | |
90 | + //} | |
91 | + | |
92 | + //// DELETE: api/ProcessImage/5 | |
93 | + //public void Delete(int id) | |
94 | + //{ | |
95 | + //} | |
96 | + } | |
97 | +} | ... | ... |