public UserAgreement CreateAgreement(DateTime agreementTime, string userName, string value, string IPAddress) { UserAgreement userAgreement = new UserAgreement(); userAgreement.agreementTime = agreementTime; userAgreement.userName = userName; userAgreement.value = value; userAgreement.IPAddress = IPAddress; try { VestnDB db = new VestnDB(); db.userAgreements.Add(userAgreement); db.SaveChanges(); } catch (Exception e) { LogAccessor logAccessor = new LogAccessor(); logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); } return userAgreement; }
public bool AddNetworkUser(int networkId, int userId) { try { VestnDB db = new VestnDB(); var n = new Network { id = networkId }; var u = new User { id = userId }; db.networks.Attach(n); db.users.Attach(u); n.networkUsers.Add(u); db.SaveChanges(); return true; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor AddAdmin", ex.StackTrace); return false; } }
public Bitmap CreateThumbnail(Stream input, int displayWidth, int displayHeight) { int width = displayWidth; int height = displayHeight; decimal Dwidth = Decimal.Parse(width.ToString()); decimal Dheight = Decimal.Parse(height.ToString()); decimal aspectRatio = Dwidth / Dheight; try { input.Seek(0, SeekOrigin.Begin); var originalImage = new Bitmap(input); if (originalImage.Width > displayWidth || originalImage.Height > displayHeight) { if (originalImage.Width / aspectRatio > originalImage.Height) { height = (int)Math.Ceiling(Decimal.Parse(originalImage.Height.ToString()) * Decimal.Parse(displayWidth.ToString()) / Decimal.Parse(originalImage.Width.ToString())); } else { width = (int)Math.Ceiling(Decimal.Parse(originalImage.Width.ToString()) * Decimal.Parse(displayHeight.ToString()) / Decimal.Parse(originalImage.Height.ToString())); } var thumbnailImage = new Bitmap(width, height); using (Graphics graphics = Graphics.FromImage(thumbnailImage)) { graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(originalImage, 0, 0, width, height); } return thumbnailImage; } return originalImage; } catch (Exception e) { LogAccessor logAccessor = new LogAccessor(); logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); return null; } }
public Bitmap CreateProfileThumbnail(Stream input, int displayWidth, int displayHeight) { int width = displayWidth; int height = displayHeight; decimal Dwidth = Decimal.Parse(width.ToString()); decimal Dheight = Decimal.Parse(height.ToString()); decimal aspectRatio = Dwidth / Dheight; try { input.Seek(0, SeekOrigin.Begin); var originalImage = new Bitmap(input); decimal originalAspect = (Decimal.Parse(originalImage.Width.ToString()) / Decimal.Parse(originalImage.Height.ToString())); if (originalImage.Width < width || originalImage.Height < height) { //picture does not meet size requirements } if (originalImage.Width < originalImage.Height) { //width = displayWidth height = (int)Math.Ceiling(width / originalAspect); var thumbnailImage = new Bitmap(width, height); using (Graphics graphics = Graphics.FromImage(thumbnailImage)) { graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(originalImage, 0, 0, width, height); } int xCoordinate = 0; int yCoordinate = ((height - displayHeight) / 2); Rectangle rect = new Rectangle(xCoordinate, yCoordinate, displayWidth, displayHeight); Bitmap bmpCrop = thumbnailImage.Clone(rect, thumbnailImage.PixelFormat); return bmpCrop; } else if (originalImage.Height < originalImage.Width) { //height = displayHeight width = (int)Math.Ceiling(originalAspect * Dheight); var thumbnailImage = new Bitmap(width, height); using (Graphics graphics = Graphics.FromImage(thumbnailImage)) { graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(originalImage, 0, 0, width, height); } int yCoordinate = 0; int xCoordingate = ((width - displayWidth) / 2); Rectangle rect = new Rectangle(xCoordingate, yCoordinate, displayWidth, displayHeight); Bitmap bmpCrop = thumbnailImage.Clone(rect, thumbnailImage.PixelFormat); return bmpCrop; } else { var thumbnailImage = new Bitmap(width, height); using (Graphics graphics = Graphics.FromImage(thumbnailImage)) { graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(originalImage, 0, 0, width, height); } return thumbnailImage; } } catch (Exception ex) { LogAccessor logAccessor = new LogAccessor(); logAccessor.CreateLog(DateTime.Now, "Thumbnail Engine - CreateProfileThumbnail", ex.StackTrace); return null; } }
public Network UpdateNetworkInformation(Network network) { try { VestnDB db = new VestnDB(); var n = new Network { id = network.id }; db.networks.Attach(n); n.name = network.name; n.privacy = network.privacy; n.description = network.description; db.SaveChanges(); return network; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor Update Network", ex.StackTrace); return null; } }
public Network UpdateNetworkUrl(Network network) { try { VestnDB db = new VestnDB(); var n = new Network { id = network.id }; db.networks.Attach(n); n.profileURL = network.profileURL; db.SaveChanges(); return network; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor Update Network", ex.StackTrace); return null; } }
public bool UpdateNetworkCoverPicture(int networkId, string coverPictureLocation) { try { VestnDB db = new VestnDB(); var n = new Network {id = networkId}; db.networks.Attach(n); n.coverPicture = coverPictureLocation; db.SaveChanges(); return true; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor UpdateNetworkCoverPicture", ex.StackTrace); return false; } }
public bool UpdateNetworkIdentifier(int networkId, string identifier) { try { VestnDB db = new VestnDB(); Network n = new Network { id = networkId }; db.networks.Attach(n); n.networkIdentifier = identifier; db.SaveChanges(); return true; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor Update Network Identifier", ex.StackTrace); return false; } }
public Network GetNetworkByIdentifier(string identifier) { VestnDB db = new VestnDB(); try { Network network = db.networks.Where(n => n.networkIdentifier == identifier) .Include(n => n.admins) .Include(n => n.networkUsers) .FirstOrDefault(); return network; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor GetNetworkByIdentifier", ex.StackTrace); return null; } }
public Network_TopNetwork GetTopNetwork(int networkId) { Network_TopNetwork network; VestnDB db = new VestnDB(); try { network = db.networks.OfType<Network_TopNetwork>().Where(n => n.id == networkId) .Include(n => n.subNetworks) .Include(n => n.admins) .Include(n => n.networkUsers) .FirstOrDefault(); return network; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor Get Network", ex.StackTrace); return null; } }
public bool DeleteSubNetwork(int topNetworkId, int subNetworkId) { try { VestnDB db = new VestnDB(); Network_TopNetwork topnet = (Network_TopNetwork)db.networks.Single(top => top.id == topNetworkId); Network_SubNetwork subnet = (Network_SubNetwork)db.networks.Single(sub => sub.id == subNetworkId); topnet.subNetworks.Remove(subnet); db.SaveChanges(); return true; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor DeleteSubnetwork", ex.StackTrace); return false; } }
public bool DeleteNetworkUser(int networkId, int userId) { try { VestnDB db = new VestnDB(); Network net = db.networks.Single(n => n.id == networkId); User user = db.users.Single(u => u.id == userId); net.networkUsers.Remove(user); db.SaveChanges(); return true; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor DeleteNetworkUser", ex.StackTrace); return false; } }
public Network CreateNetwork(Network network) { try { VestnDB db = new VestnDB(); db.networks.Add(network); db.SaveChanges(); return network; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor Create Network", ex.StackTrace); return null; } }
public List<int> stringOrderToList(string projectOrder) { LogAccessor logAccessor = new LogAccessor(); string[] s = null; try { s = projectOrder.Split(','); } catch (Exception e) { logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); return null; } List<int> ids = new List<int>(); foreach (string c in s) { int value; int.TryParse(c, out value); ids.Add(value); } return ids; }
public override void Run() { Trace.WriteLine("BackgroundProcesses entry point called", "Information"); Trace.WriteLine(Thread.CurrentThread.Name, "Information"); try { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("BlobConnectionString")); Trace.WriteLine("storage account configured", "Information"); queueClient = storageAccount.CreateCloudQueueClient(); queue = queueClient.GetQueueReference(messageQueueName); queue.CreateIfNotExist(); queue.Clear(); } catch (Exception e) { LogAccessor logAccessor = new LogAccessor(); logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); } while (true) { try { CloudQueueMessage msg = queue.GetMessage(); if (msg != null) { Trace.WriteLine("Queue Message Recieved", "Information"); // parse message retrieved from queue string userFullName = ""; string presetDocURL = ""; var messageParts = msg.AsString.Split(new char[] { ',' }); var mediaURI = messageParts[0]; int ID = Int32.Parse(messageParts[1]); var operation = messageParts[2]; var type = messageParts[3]; int displayWidth = Int32.Parse(messageParts[4]); int displayHeight = Int32.Parse(messageParts[5]); try { userFullName = messageParts[6]; presetDocURL = messageParts[7]; } catch (Exception) { } if (operation.Equals("thumbnail")) { UploadManager uploadManager = new UploadManager(); string thumbnailURI = uploadManager.generateThumbnail(mediaURI, ID, type, displayWidth, displayHeight, presetDocURL); } else if (operation.Equals("documentConversion")) { UploadManager uploadManager = new UploadManager(); uploadManager.convertDocument(mediaURI, type, ID, userFullName, presetDocURL); } else if (operation.Equals("userDocumentConversion")) { UploadManager uploadManager = new UploadManager(); uploadManager.convertUserDocument(mediaURI, type, ID, userFullName, presetDocURL); } queue.DeleteMessage(msg); } Thread.Sleep(500); //Trace.WriteLine("Working - thread sleep", "Information"); } catch (Exception e) { LogAccessor logAccessor = new LogAccessor(); logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); } } }