Dispose own created Tab - cefsharp

Hi I have upgrade my application from 45 to Cefsharp version 71,Earlier new created tab is easily dispose(remove) but now the whole application is shut down,When i am using remove method the tab is closed but it remain in the memory that cause system hanged.
public void AddNewBrowserTab(string url, int? insertIndex = null) {
browserTabControl.SuspendLayout();
var browser = new BrowserTabUserControl(AddNewBrowserTab, url, UserName, pass, browserTabControl, txtUName.Text.ToString().Trim(), txtUPassword.Text.ToString().Trim(), MUser, TUser);
var tabPage = new TabPage(url);
browser.CreateControl();
tabPage.Controls.Add(browser);
if (insertIndex == null) {
browserTabControl.TabPages.Add(tabPage);
} else {
browserTabControl.TabPages.Insert(insertIndex.Value, tabPage);
}
browserTabControl.SelectedTab = tabPage;
browserTabControl.ResumeLayout(true);
}
//Call Method
public BrowserTabUserControl(Action<string, int?> openNewTab, string url, string uname, string pwd, TabControl browserTabControl, string loginUsrname, string LoginUsrpwd, string muser, string thuser) {
InitializeComponent();
MonsterUsr = monsteruser;
Techfetchuser = techfetchuser;
loginUsername = loginUsrname;
name = uname;
passwd = pwd;
txtuname = loginUsrname;
txtupwd = LoginUsrpwd;
browserTabControls = browserTabControl;
var browser = new ChromiumWebBrowser(url) {
Dock = DockStyle.Fill
};
var userControl = new UserControl { Dock = DockStyle.Fill };
ZoomIn.Controls.Add(browser);
Browser = browser;
browser.MenuHandler = new MenuHandler();
browser.JsDialogHandler = new JsDialogHandler();
browser.AddressChanged += Browser_AddressChanged;
browser.DownloadHandler = new DownloadHandler(browserTabControl);
browser.LifeSpanHandler = new LifeSpanHandler(browserTabControl, ref Browser, loginUsrname, LoginUsrpwd);
browser.KeyboardHandler = new KeyboardHandler();
}

Related

Issue with loading dicom images in WADO loader

I am working on a web based OHIF Dicom viewer. I am using clear canvas as my PACs server. So I developed one broker application in .net core which works like WADO-RS and supply information to OHIF viewer from clear canvas. In my broker application I am passing metadata to OHIF viewer in json format by using FO-dicom json converter which converts dcm file into Json string.
My code for sending metadata:
var files = Directory.GetFiles(directory);
List<JObject> lstjo = new List<JObject>();
JObject jo;
foreach (var file in files)
{
var dicomDirectory = DicomFile.Open(file, FileReadOption.ReadAll);
if (dicomDirectory.Dataset.InternalTransferSyntax.UID.UID != DicomTransferSyntax.ImplicitVRLittleEndian.UID.UID)
{
var transcoder = new DicomTranscoder(dicomDirectory.Dataset.InternalTransferSyntax, DicomTransferSyntax.ImplicitVRLittleEndian);
dicomDirectory = transcoder.Transcode(dicomDirectory);
}
JsonDicomConverter dicomConverter = new JsonDicomConverter();
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
JsonWriter writer = new JsonTextWriter(sw);
Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();
dicomConverter.WriteJson(writer, dicomDirectory.Dataset, serializer);
jo = JObject.Parse(sb.ToString());
// jo.Property("7FE00010").Remove();
retJsonstring += jo.ToString() + ",";
}
if (retJsonstring.Length > 6)
{
retJsonstring = retJsonstring.Substring(0, retJsonstring.Length - 1) + "]";
}
else
{
retJsonstring += "]";
}
retJsonstring = retJsonstring.Replace("\r", "").Replace("\n", "");
}
return retJsonstring;
During passing metadata there is no issue in Ohif viewer. After then OHIF viewer sending WADORS request for frames to display. My broker application also send responding for that request in multipart.
My code for sending Multipart response :
{
var dicomFile = DicomFile.Open(path, FileReadOption.ReadAll);
string transfersyntax = dicomFile.Dataset.InternalTransferSyntax.UID.UID;
MemoryStream streamContent = new MemoryStream();
if (transfersyntax != DicomTransferSyntax.ImplicitVRLittleEndian.UID.UID)
{
var transcoder = new DicomTranscoder(dicomFile.Dataset.InternalTransferSyntax, DicomTransferSyntax.ImplicitVRLittleEndian);
dicomFile = transcoder.Transcode(dicomFile);
}
dicomFile.Save(streamContent);
DicomImage img = new DicomImage(dicomFile.Dataset, 0);
streamContent.Seek(0, SeekOrigin.Begin);
string boundary = Guid.NewGuid().ToString();
MultipartContent multipartContent = new MultipartContent();
//newFile.Save(multipartContent.Stream);
multipartContent.Stream = streamContent;// File.OpenRead(path);
multipartContent.ContentType = "application/octet-stream";
multipartContent.transfersyntax = dicomFile.Dataset.InternalTransferSyntax.UID.UID;
multipartContent.FileName = "";
multiContentResult = new MultipartResult("related", boundary) { multipartContent };
return multiContentResult;
}
Mulitpart class and MulticontentResult Class:
public class MultipartContent
{
public string ContentType { get; set; }
public string FileName { get; set; }
public Stream Stream { get; set; }
public string transfersyntax { get; set; }
}
public class MultipartResult : Collection<MultipartContent>, IActionResult
{
private readonly System.Net.Http.MultipartContent content;
public MultipartResult(string subtype = "byteranges", string boundary = null)
{
if (boundary == null)
{
this.content = new System.Net.Http.MultipartContent(subtype);
}
else
{
this.content = new System.Net.Http.MultipartContent(subtype, boundary);
}
}
public async Task ExecuteResultAsync(ActionContext context)
{
foreach (var item in this)
{
if (item.Stream != null)
{
var content = new StreamContent(item.Stream);
if (item.ContentType != null)
{
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(item.ContentType);
content.Headers.ContentType.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("transfer-syntax", item.transfersyntax));
}
this.content.Add(content);
}
}
context.HttpContext.Response.ContentLength = content.Headers.ContentLength;
context.HttpContext.Response.ContentType = content.Headers.ContentType.ToString();
await content.CopyToAsync(context.HttpContext.Response.Body);
}
}
After sending WAROrs response , I getting error in OHIF viewer in RangeError: offset is out of bounds in stackviewport.js during set pixeldata flat32array to scaledata flat32array like below Image
So I inspect in browser after then I come know that Pixel data size and scaledata size is different like below image..
To verify my dcm file I checked with ohif viewer by directly opened those file in https://v3-demo.ohif.org/local. It is opening properly.
So what are possible reason for this issue ? how to rectify?

dont show help page in web api

I want to create help pages for ASP.NET Web API.
I created a new ASP.NET Web application project and select the Web API project template. It added Areas/HelpPage.
When I run the application, the home page contains a link to the API help page. From the home page, the relative path is /Help. It shows ValuesController action, but when I add another controller, the help page doesn't show that controller and any of its actions.
public class CalendarController : ApiController
{
private readonly string siteUrl = ConfigurationManager.AppSettings["SiteUrl"];
private readonly CalendarService calendarService;
public CalendarController()
{
calendarService = new CalendarService();
}
[HttpPost]
public async Task<ResponseModel<List<ApiCalendarViewModel>>> Paging(JObject param)
{
try
{
var startIndex = Convert.ToInt32(param["StartIndex"]);
var pageSize = Convert.ToInt32(param["PageSize"]);
var CalendarList = await calendarService.SelectAllAsync(startIndex, pageSize);
var list = CalendarList.Select(m => new ApiCalendarViewModel()
{
Author = m.Author,
Date = PersianDateTime.ToLongDateWithDayString(m.CreatedDate),
Excerpt = m.Excerpt,
Id = m.Id,
MainImage = siteUrl + m.Image,
Title = m.Title,
StartYear = m.StartYear,
EndYear = m.EndYear,
Semester = m.Semester.GetDisplayName()
}).ToList();
return new ResponseModel<List<ApiCalendarViewModel>>()
{
IsSuccess = true,
Data = list
};
}
catch (Exception e)
{
return new ResponseModel<List<ApiCalendarViewModel>>()
{
IsSuccess = false,
Message = e.Message
};
}
}
[HttpGet]
public async Task<ResponseModel<List<ApiCalendarViewModel>>> GetAll()
{
try
{
var CalendarList = await calendarService.SelectAllAsync();
var list = CalendarList.Select(m => new ApiCalendarViewModel()
{
Author = m.Author,
Date = PersianDateTime.ToLongDateWithDayString(m.CreatedDate),
Excerpt = m.Excerpt,
Id = m.Id,
MainImage = siteUrl + m.Image,
Title = m.Title,
StartYear = m.StartYear,
EndYear = m.EndYear,
Semester = m.Semester.GetDisplayName()
}).ToList();
return new ResponseModel<List<ApiCalendarViewModel>>()
{
IsSuccess = true,
Data = list
};
}
catch (Exception e)
{
return new ResponseModel<List<ApiCalendarViewModel>>()
{
IsSuccess = false,
Message = e.Message
};
}
}
}

ASP.NET Cloudinary getting response

I have little problem with using Cloudinary, I can upload the images it works fine but I guess i cant get any response from Cloudinary. Suggestion? about required parameters
Handler
public async Task<Photo> Handle(Command request, CancellationToken cancellationToken)
{
var photoUploadResult = _photoAccessor.AddPhoto(request.File);
var photo = new Photo
{
Url = photoUploadResult.Url,
Id = photoUploadResult.PublicId
};
var success = await _context.SaveChangesAsync() > 0;
if (success) return photo;
throw new Exception("Problem saving changes");
}
Accessor
public PhotoUploadResult AddPhoto(IFormFile file)
{
var uploadResult = new ImageUploadResult();
if (file.Length > 0)
{
using (var stream = file.OpenReadStream())
{
var uploadParams = new ImageUploadParams
{
File = new FileDescription(file.FileName, stream)
};
uploadResult = _cloudinary.Upload(uploadParams);
}
}
if (uploadResult.Error != null)
throw new Exception(uploadResult.Error.Message);
return new PhotoUploadResult
{
PublicId = uploadResult.PublicId,
Url = uploadResult.SecureUri.AbsoluteUri
};
}
What do you get in response? Can you try:
string cloud_name = "<Cloud Name>";
string ApiKey = "<Api-Key>";
string ApiSecret = "<Api-Secret>";
Account account = new Account(cloud_name,ApiKey,ApiSecret);
Cloudinary cloudinary = new Cloudinary(account);
cloudinary.Api.Timeout = int.MaxValue;
var ImguploadParams = new ImageUploadParams()
{
File = new FileDescription(#"http://res.cloudinary.com/demo/image/upload/couple.jpg"),
PublicId = "sample",
Invalidate = true,
Overwrite = true
};
var ImguploadResult = cloudinary.Upload(ImguploadParams);
Console.WriteLine(ImguploadResult.SecureUri);

How to get the published date of a page using the Core Service?

I have to create a custom page having list of all pages with its published date within a publication. Can someone guide me how to use this code to get published date in custom page?
private ItemType GetTridionItemType(RepositoryLocalObjectData source)
{
string itemType = source.GetType().Name;
switch (itemType)
{
case "PageData":
return ItemType.Page;
}
return ItemType.UnknownByClient;
}
private string CreateNewItemCopy(string title, RepositoryLocalObjectData source,
string filename)
{
ItemType tridionItemType = GetTridionItemType(source);
string orgItemUri = source.LocationInfo.OrganizationalItem.IdRef;
var newItem = client.Copy(source.Id, orgItemUri, true, new ReadOptions());
newItem.Title = title;
if (tridionItemType == ItemType.Page)
{
PageData pageData = newItem as PageData;
pageData.FileName = filename;
client.Update(pageData, new ReadOptions());
}
else
{
client.Update(newItem, new ReadOptions());
}
return newItem.Id;
}
We can get the publish info from coreservice
TridionGeneration Generation = new TridionGeneration();
Generation.Settings = GetImportSetting();
var objclient = new CoreService2010Client();
objclient.ClientCredentials.Windows.ClientCredential.UserName = Generation.Settings.Username;
objclient.ClientCredentials.Windows.ClientCredential.Password = Generation.Settings.Password;
objclient.Open();
Generation.client = objclient;
var objectList = Generation.client.GetListPublishInfo([object tcm uri]);
PublishEngine.GetPublishInfo returns the Publish Info of an Item. Which contains the Published Date. (PublishInfo.PublishedAt).
You can also use CoreService.GetListPublishInfo.

Cannot get properties of some groups in my AD

I am trying to retrieve all the email gruops and their mail address from company's AD system. I've got about 1800 groups but I've found there are about 20 gourps which I cannot get their properties. I tried in my outlook and got properties like mail address correctly. But I cannot get them by code, someone please help. Thanks. Below is my code snippet:
static void TestGroupEmails()
{
ICollection<DirectoryEntry> groups = GetGroups();
Console.WriteLine(groups.Count + "groups");
List<String> noNameGroups = new List<String>();
foreach (DirectoryEntry de in groups)
{
String name = de.Properties["sAMAccountName"].Value as String;
String email = de.Properties["mail"].Value as String;
if (String.IsNullOrEmpty(email))
noNameGroups.Add(name);
}
StreamWriter writer = new StreamWriter(#"C:\ad\group mails.txt");
noNameGroups.Sort();
foreach (String name in noNameGroups)
{
writer.WriteLine(name);
}
writer.Close();
Console.ReadLine();
}
public static List<DirectoryEntry> GetGroups()
{
String filter = #"(&(objectCategory=group))";
List<DirectoryEntry> groups = new List<DirectoryEntry>();
using (DirectoryEntry root = new DirectoryEntry(Constants.ADConnPrefix))
{
using (DirectorySearcher searcher = new DirectorySearcher(filter, null))
{
searcher.PageSize = 10000;
searcher.ReferralChasing = ReferralChasingOption.All;
searcher.SearchScope = SearchScope.Subtree;
searcher.SearchRoot = root;
root.Username = Constants.UserName;
root.Password = Constants.Password;
using (SearchResultCollection searchResult = searcher.FindAll())
{
foreach (SearchResult sr in searchResult)
{
DirectoryEntry de = sr.GetDirectoryEntry();
groups.Add(de);
}
}
}
}
return groups;
}
public static SearchResult GetGroupInfo(String groupName)
{
String normalName = Utility.RemoveLoginNamePrefix(groupName);
String filterFormat = "(&(objectCategory=group)(sAMAccountName={0}))";
using (SearchResultCollection searchResult = Search(ADConnPrefix, null, filterFormat, normalName))
{
int count = searchResult.Count;
SearchResult sr = searchResult[0];
return sr;
}
}
Are you certain the groups in question actually have email addresses? It is possible for groups in AD to not have them.
If you modify your search filter to (&(objectCategory=group)(mail=*)) it will filter out any groups that don't have email addresses.

Resources