public void ProcessRequest(HttpContext context) { Context = context; int ItemID = Param("ItemID"); int AccountID = Param("AccountID"); BytesResult res = ES.Services.ExchangeServer.GetPicture(ItemID, AccountID); if (res.IsSuccess) { context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(res.Value); } else { context.Response.Redirect(PortalUtils.GetThemedImage("empty.gif"), true); } }
public override BytesResult GetPicture(string accountName) { ExchangeLog.LogStart("GetPicture"); BytesResult res = new BytesResult() { IsSuccess = true }; Runspace runSpace = null; try { runSpace = OpenRunspace(); Command cmd; cmd = new Command("Export-RecipientDataProperty"); cmd.Parameters.Add("Identity", accountName); cmd.Parameters.Add("Picture", true); Collection <PSObject> result = ExecuteShellCommand(runSpace, cmd, res, true); if (result.Count > 0) { res.Value = ((Microsoft.Exchange.Data.BinaryFileDataObject) (result[0].ImmediateBaseObject)).FileData; } } finally { CloseRunspace(runSpace); } ExchangeLog.LogEnd("GetPicture"); return(res); }
public void ProcessRequest(HttpContext context) { Context = context; int ItemID = Param("ItemID"); int AccountID = Param("AccountID"); BytesResult res = ES.Services.ExchangeServer.GetPicture(ItemID, AccountID); if ((res != null) && (res.IsSuccess) && (res.Value != null)) { context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(res.Value); } else { MemoryStream pictureStream = new MemoryStream(); Bitmap emptyBmp = new Bitmap(1, 1); emptyBmp.Save(pictureStream, System.Drawing.Imaging.ImageFormat.Jpeg); context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(pictureStream.ToArray()); } }
public override BytesResult GetPicture(string accountName) { ExchangeLog.LogStart("GetPicture"); BytesResult res = new BytesResult() { IsSuccess = true }; Runspace runSpace = null; try { runSpace = OpenRunspace(); Command cmd; cmd = new Command("Export-RecipientDataProperty"); cmd.Parameters.Add("Identity", accountName); cmd.Parameters.Add("Picture", true); Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd, res, true); if (result.Count > 0) { res.Value = ((Microsoft.Exchange.Data.BinaryFileDataObject) (result[0].ImmediateBaseObject)).FileData; } } finally { CloseRunspace(runSpace); } ExchangeLog.LogEnd("GetPicture"); return res; }
public static BytesResult GetWebDeployPublishingProfile(int siteItemId) { var result = new BytesResult(); try { TaskManager.StartTask(LOG_SOURCE_WEB, "GetWebDeployPublishingProfile"); TaskManager.WriteParameter("SiteItemId", siteItemId); // load site item WebSite item = (WebSite)PackageController.GetPackageItem(siteItemId); // var siteItem = GetWebSite(siteItemId); // if (item == null) { TaskManager.WriteWarning("Web site not found"); return result; } // int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { TaskManager.WriteWarning("Current user is either demo or inactive"); return result; } // check package int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { TaskManager.WriteWarning("Current user is either not allowed to access the package or the package inactive"); return result; } // string accountName = item.WebDeployPublishingAccount; // if (String.IsNullOrEmpty(accountName)) { TaskManager.WriteWarning("Web Deploy Publishing Access account name is either not set or empty"); return result; } // var packageInfo = PackageController.GetPackage(item.PackageId); // var userInfo = UserController.GetUser(packageInfo.UserId); // var items = new Hashtable() { { "WebSite", siteItem }, { "User", userInfo }, }; // Retrieve service item ids from the profile var serviceItemIds = Array.ConvertAll<string, int>( item.WebDeploySitePublishingProfile.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), (string x) => { return Convert.ToInt32(x.Trim()); }); // foreach (var serviceItemId in serviceItemIds) { var packageItem = PackageController.GetPackageItem(serviceItemId); // Handle SQL databases if (packageItem is SqlDatabase) { var dbItemKey = packageItem.GroupName.StartsWith("MsSQL") ? "MsSqlDatabase" : "MySqlDatabase"; var dbServerKeyExt = packageItem.GroupName.StartsWith("MsSQL") ? "MsSqlServerExternalAddress" : "MySqlServerExternalAddress"; var dbServerKeyInt = packageItem.GroupName.StartsWith("MsSQL") ? "MsSqlServerInternalAddress" : "MySqlServerInternalAddress"; // items.Add(dbItemKey, DatabaseServerController.GetSqlDatabase(serviceItemId)); // Retrieve settings var sqlSettings = ServerController.GetServiceSettings(packageItem.ServiceId); items[dbServerKeyExt] = sqlSettings["ExternalAddress"]; items[dbServerKeyInt] = sqlSettings["InternalAddress"]; } else if (packageItem is SqlUser) { var itemKey = packageItem.GroupName.StartsWith("MsSQL") ? "MsSqlUser" : "MySqlUser"; // items.Add(itemKey, DatabaseServerController.GetSqlUser(serviceItemId)); } else if (packageItem is FtpAccount) { // items.Add("FtpAccount", FtpServerController.GetFtpAccount(serviceItemId)); // Get FTP DNS records List<GlobalDnsRecord> ftpRecords = ServerController.GetDnsRecordsByService(packageItem.ServiceId); if (ftpRecords.Count > 0) { GlobalDnsRecord ftpRecord = ftpRecords[0]; string ftpIp = ftpRecord.ExternalIP; if (String.IsNullOrEmpty(ftpIp)) ftpIp = ftpRecord.RecordData; // Assign FTP service address variable items["FtpServiceAddress"] = ftpIp; } } } // Decrypt publishing password & copy related settings siteItem.WebDeployPublishingPassword = CryptoUtils.Decrypt(item.WebDeployPublishingPassword); siteItem.WebDeployPublishingAccount = item.WebDeployPublishingAccount; siteItem.WebDeploySitePublishingEnabled = item.WebDeploySitePublishingEnabled; siteItem.WebDeploySitePublishingProfile = item.WebDeploySitePublishingProfile; // Retrieve publishing profile template from the Web Policy settings var webPolicy = UserController.GetUserSettings(packageInfo.UserId, UserSettings.WEB_POLICY); // Instantiate template, it's content and related items and then evaluate it var template = new Template(webPolicy["PublishingProfile"]); // Receive bytes for the evaluated template result.Value = Encoding.UTF8.GetBytes(template.Evaluate(items)); // result.IsSuccess = true; } catch (Exception ex) { TaskManager.WriteError(ex); // result.IsSuccess = false; } finally { TaskManager.CompleteTask(); } // return result; }
private void ExecuteContent(IContext context) { string contentType; if (ContentType != null) contentType = ContentType; else contentType = MimeTypes.UNKNOWN; var result = new BytesResult(Content, contentType); if (!string.IsNullOrEmpty(FileDownloadName)) result.FileDownloadName = FileDownloadName; ExecuteFileResult(context, result); }