Exemple #1
0
        public void Delete(WSI w)
        {
            var _context = new DataContext();

            _context.WSIs.Remove(w);
            _context.SaveChanges();
        }
Exemple #2
0
        public string DoItUsernamePwd(string email, string password, string document)
        {
            var wsi = new WSI();

            if (!wsi.AuthenticateRequest(email, password))
            {
                throw new ArgumentException("Authentication Failed");
            }

            try
            {
                wsi.LoadFromString(document);
                wsi.DoIt();

                return(wsi
                       .GetResults()
                       .InnerXml);
            }
            catch (XmlException)
            {
                throw new ArgumentException("Invalid Import XmlDocument");
            }
            catch
            {
                return(wsi.GetResultsAsString());
            }
        }
Exemple #3
0
        public void Insert(WSI w)
        {
            var _context = new DataContext();

            _context.WSIs.Add(w);
            _context.SaveChanges();
        }
Exemple #4
0
        public void Update(WSI w)
        {
            var _context = new DataContext();

            _context.Entry(w).State = EntityState.Modified;
            _context.SaveChanges();
        }
        public void Delete(WSI w)
        {
            var _context = new ApplicationDbContext();

            _context.WSIs.Remove(w);
            _context.SaveChanges();
        }
        public void Insert(WSI w)
        {
            var _context = new ApplicationDbContext();

            _context.WSIs.Add(w);
            _context.SaveChanges();
        }
Exemple #7
0
    public String DoIt(String AuthenticationEMail, String AuthenticationPassword, String XmlInputRequestString)
    {
        WSI IPXObject = new WSI();

        if (!IPXObject.AuthenticateRequest(AuthenticationEMail, AuthenticationPassword))
        {
            throw new ArgumentException("Authentication Failed");
        }
        return(DoItHelper(IPXObject, ref XmlInputRequestString));
    }
 protected string GetPreviewUrl(WSI.Model.Entities.Information info)
 {
     var nav = info.NavigationList.ElementAtOrDefault(0);
     if (food_navigations.Contains(nav.NavId.ToString()))
     {
         return string.Format("{0}?infoid={1}&navid={2}", Common.SITE_URL + "/Food/FoodDetail.aspx", info.InfoId, nav.NavId);
     }
     else
     {
         return string.Format("{0}?infoid={1}&navid={2}", Common.SITE_URL + Common.NEWS_PREVIEW_PAGE, info.InfoId, nav.NavId);
     }
 }
Exemple #9
0
    public String DoItWSE3(String XmlInputRequestString)
    {
        if (!HttpContext.Current.Items.Contains("WSIAuthenticateTokenReceived") ||
            !(HttpContext.Current.User is AspDotNetStorefrontPrincipal))
        {
            // our username token manager did NOT set the context flag, indicating a successful authentication, so fail this request hard.
            throw new ArgumentException("Authentication Failed");
        }

        // Since we already validated the  user through the ASPDNSFUsernameTokenManager
        // We're safe to assume that it's already the current principal
        Customer thisCustomer = (HttpContext.Current.User as AspDotNetStorefrontPrincipal).ThisCustomer;
        // we'll just explitictly pass the customer object itself
        WSI IPXObject = new WSI(thisCustomer);

        return(DoItHelper(IPXObject, ref XmlInputRequestString));
    }
Exemple #10
0
 private String DoItHelper(WSI IPXObject, ref String XmlInputRequestString)
 {
     try
     {
         IPXObject.LoadFromString(XmlInputRequestString);
     }
     catch
     {
         throw new ArgumentException("Invalid Import XmlDocument");
     }
     IPXObject.DoIt();
     try
     {
         XmlDocument d     = IPXObject.GetResults();
         String      d_xml = d.InnerXml;
         return(d_xml);
     }
     catch
     {
         return(IPXObject.GetResultsAsString());
     }
 }
Exemple #11
0
        public ActionResult Index(HttpPostedFileBase file, WSI wsi, Stain stain, Organ organ, Tissue tissue)
        {
            //TODO

            var reglement = manager.GetReglement(stain.Name, organ.Name);
            //var sharpnessEvaluationParameters = '+' + reglament.TileSize.ToString() + '+' + reglament.SharpnessThresholdValue+ '+' + reglament.Scaling.ToString()+ '+' + reglament.Edges.ToString();

            //Directory for WSI Uploads on the Server
            var root     = @"C:\Users\AnnaToshiba2\Desktop\WSI\Sharpness_WebApp_Uploads\";
            var fileName = "";

            wsi.WSIId = Guid.NewGuid();

            //Create a directory for a report and WSI
            string outputDir = Path.Combine(Path.GetDirectoryName(root), User.Identity.GetUserName(), "WSI " + wsi.WSIId + @"\");

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }
            if (file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(outputDir, fileName);
                file.SaveAs(path);
                wsi.Path   = path;
                wsi.UserId = User.Identity.GetUserId();
                repoWSIs.Insert(wsi);
            }

            //Generate a report link for the Viewer
            var reportLink     = User.Identity.GetUserName() + "/" + "WSI " + wsi.WSIId + "/" + fileName + " ";
            var evaluationLink = root + reportLink.Replace("/", @"\");

            //External sharpness console app
            Process sharpnessConsoleApp = new Process();

            //Path to  the sharpness console app
            sharpnessConsoleApp.StartInfo.FileName = @"C:\Users\AnnaToshiba2\Documents\GitHub\sharpness\sharpness console App\SharpnessExplorationCurrent\SharpnessExplorationCurrent\bin\x64\Release\SharpnessExplorationCurrent.exe";

            //WSI Path + Reglemnets arguments
            //structure -> wsi.path#(separator)#tileSize#threshold#scale#edges
            sharpnessConsoleApp.StartInfo.Arguments = String.Format(@"""{0}""", wsi.Path + "#" + reglement.TileSize.ToString() + "#" + reglement.Scaling.ToString() + "#" + reglement.SharpnessThresholdValue.ToString() + "#" + reglement.Edges.ToString());
            sharpnessConsoleApp.Start();
            sharpnessConsoleApp.WaitForExit();

            var report = new Report();

            //TODO
            //only one reglement is possible

            report.ReglementId = reglement.ReglementId;
            report.Comment     = "Kommentar";
            report.OrganName   = organ.Name;
            if (tissue != null)
            {
                report.TissueName = tissue.Name;
            }
            if (tissue == null)
            {
                report.TissueName = null;
            }

            report.WSIId                 = wsi.WSIId;
            report.StainName             = stain.Name;
            report.SharpnessMapPath      = outputDir + Path.GetFileNameWithoutExtension(fileName) + ".png";
            report.SharpnessMapPathDebug = outputDir + Path.GetFileNameWithoutExtension(fileName) + "Debug.png";
            var semaphoreValues = manager.GetSemaphoreValues(report.SharpnessMapPath);
            var channelsValues  = manager.GetChannelsValues(report.SharpnessMapPathDebug);

            report.Semaphore_Red    = semaphoreValues[0];
            report.Semaphore_Green  = semaphoreValues[1];
            report.Semaphore_Yellow = semaphoreValues[2];
            report.Red_Channel      = channelsValues[0];
            report.Blue_Channel     = channelsValues[1];

            if (semaphoreValues[1] > reglement.AcceptanceValue)
            {
                report.Evaluation = true;
            }
            else
            {
                report.Evaluation = false;
            }
            report.ReportLink = reportLink;
            report.UserId     = User.Identity.GetUserId();
            repoReports.Insert(report);
            return(RedirectToAction("Report", new { ReportId = report.ReportId }));
        }
        public ActionResult Index(HttpPostedFileBase file, WSI wsi, Stain stain, Organ organ, Tissue tissue)
        {
            //TODO
            //Today only one value possible
            //var tissue = _repoTissues.GetTissueByName("Tissue");
            ISharpnessManager manager = new SharpnessManager();
            //
            var root     = @"C:\Users\AnnaToshiba2\Desktop\WSI\Sharpness_WebApp_Uploads\";
            var fileName = "";

            wsi.WSIId = Guid.NewGuid();

            string outputDir = Path.Combine(Path.GetDirectoryName(root), User.Identity.GetUserId(), "WSI " + wsi.WSIId + @"\");

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }
            if (file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(outputDir, fileName);
                file.SaveAs(path);


                wsi.Path   = path;
                wsi.UserId = User.Identity.GetUserId();
                _repoWSIs.Insert(wsi);
            }

            var     reportLink     = User.Identity.GetUserId() + "/" + "WSI " + wsi.WSIId + "/" + fileName + " ";
            var     evaluationLink = root + reportLink.Replace("/", @"\");
            Process first          = new Process();

            first.StartInfo.FileName  = @"C:\Users\AnnaToshiba2\Documents\GitHub\sharpness\sharpness console App\SharpnessExplorationCurrent\SharpnessExplorationCurrent\bin\x64\Release\SharpnessExplorationCurrent.exe";
            first.StartInfo.Arguments = String.Format(@"""{0}""", wsi.Path);
            first.Start();
            first.WaitForExit();

            var report = new Report();

            report.ReglamentId = _repoReglaments.GetReglamentByTitel("Default").ReglamentId;
            report.Comment     = "some words";

            report.OrganName             = organ.Name;
            report.TissueName            = tissue.Name;
            report.WSIId                 = wsi.WSIId;
            report.StainName             = stain.Name;
            report.SharpnessMapPath      = outputDir + Path.GetFileNameWithoutExtension(fileName) + ".png";
            report.SharpnessMapPathDebug = outputDir + Path.GetFileNameWithoutExtension(fileName) + "Debug.png";
            var semaphoreValues = manager.GetSemaphoreValues(report.SharpnessMapPath);
            var channelsValues  = manager.GetChannelsValues(report.SharpnessMapPathDebug);


            report.Semaphore_Red    = semaphoreValues[0];
            report.Semaphore_Green  = semaphoreValues[1];
            report.Semaphore_Yellow = semaphoreValues[2];

            report.Red_Channel  = channelsValues[0];
            report.Blue_Channel = channelsValues[1];

            if (semaphoreValues[1] > 70)
            {
                report.Evaluation = true;
            }
            else
            {
                report.Evaluation = false;
            }
            report.ReportLink = reportLink;
            report.UserId     = User.Identity.GetUserId();
            _repoReports.Insert(report);



            return(RedirectToAction("Report", new { ReportId = report.ReportId }));
        }
Exemple #13
0
 private void setRoleInfo(WSI.DataAccess.WSICmsContext context, UserInfo user, IList<string> roleidlist)
 {
     user.RoleList = new List<RoleInfo>();
     if (roleidlist != null)
     {
         foreach (var roleid in roleidlist)
         {
             Guid id;
             RoleInfo role;
             if (Guid.TryParse(roleid, out id))
             {
                 role = context.RoleInfoes.Find(id);
                 if (role != null)
                 {
                     user.RoleList.Add(role);
                 }
             }
         }
     }
 }
Exemple #14
0
 //设置新闻的所属栏目
 private void setNavigation(WSI.DataAccess.WSICmsContext context, Information info, IList<string> idlist)
 {
     //初始化
     info.NavigationList = new List<FrontendNavigation>();
     foreach (var navid in idlist)
     {
         Guid id;
         if (Guid.TryParse(navid, out id))
         {
             FrontendNavigation nav = context.FrontendNavigations.Find(id);
             if (nav != null)
             {
                 info.NavigationList.Add(nav);
             }
         }
     }
 }
Exemple #15
0
 //设置新闻的关键字
 private void setKeyWords(WSI.DataAccess.WSICmsContext context, Information info, IList<string> keywords)
 {
     //添加时初始化列表,修改时删除所有关键字关联重新添加
     info.KeyWords = new List<KeyWord>();
     foreach (var key in keywords)
     {
         if (key != "")
         {
             KeyWord keyword = context.KeyWords.SingleOrDefault(k => k.Content == key);
             //如果关键字已存在
             if (keyword != null)
             {
                 info.KeyWords.Add(keyword);
             }
             else
             {
                 //只需要直接将关键字添加到新闻的关键字字段中
                 info.KeyWords.Add(new KeyWord()
                 {
                     Content = key,
                     CreateTime = DateTime.Now
                 });
             }
         }
     }
 }