public void InitData(string root, ChangeStorage storage, LogAccessor accessor)
 {
     _accessor = accessor;
     _storage  = storage;
     DataId    = root;
     LD_Log?.Init($"{DataId}.log", storage, _Log);
 }
Beispiel #2
0
 public InternalAccessors(LogicData LogicData, IStateFactory factory)
 {
     Factory             = factory;
     ConditionController = new ConditionController();
     FormulaController   = new FormulaController();
     AchievementAccessor = new AchievementAccessor();
     BattleAccessor      = new BattleAccessor();
     CutSceneAccessor    = new CutSceneAccessor();
     ExplorerAccessor    = new ExplorerAccessor();
     InventoryAccessor   = new InventoryAccessor();
     LogAccessor         = new LogAccessor();
     LogAccessor.Data    = LogicData;
     PlayerAccessor      = new PlayerAccessor();
     ScorersAccessor     = new ScorersAccessor();
     SettingsAccessor    = new SettingsAccessor();
     ShopAccessor        = new ShopAccessor();
     UnitsAccessor       = new UnitsAccessor();
 }
Beispiel #3
0
        public void Log(LogRequest request)
        {
            if (request == null || request.LogHistory == null)
            {
                ArgumentNullException ex = new ArgumentNullException("EditUser request");
                LogError(ex);
            }

            try
            {
                LogAccessor accessor = new LogAccessor();
                accessor.Log(request.LogHistory);
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
        }
        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;
        }
Beispiel #5
0
 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;
 }
Beispiel #6
0
        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;
            }
        }
        protected IDirectoryManager FactoryManager(ConfigSettingsDto settings = null, IDbContextFactory <LogContext> logCtxFactory = null, IDbContextFactory <DirectoryContext> dirCtxFactory = null, IDbContextFactory <ExportContext> xprtCtxFactory = null)
        {
            if (settings == null)
            {
                settings = new ConfigSettingsDto
                {
                    StateCacheTtlSeconds       = 1200,
                    TranslationCacheTtlSeconds = 1200
                }
            }
            ;

            if (logCtxFactory == null)
            {
                logCtxFactory = new SqliteInMemoryContextFactory <LogContext>();
            }

            if (dirCtxFactory == null)
            {
                dirCtxFactory = new SqliteInMemoryContextFactory <DirectoryContext>();
            }

            if (xprtCtxFactory == null)
            {
                xprtCtxFactory = new SqliteInMemoryContextFactory <ExportContext>();
            }

            var cacheAccessor  = new CacheAccessor(new MemoryCache(), settings);
            var dirAccessor    = new DirectoryAccessor(dirCtxFactory);
            var logAccessor    = new LogAccessor(logCtxFactory);
            var exportAccessor = new ExportAccessor(xprtCtxFactory);

            var dirEngine = new DirectoryEngine(dirAccessor, cacheAccessor, exportAccessor);

            return(new DirectoryManager(dirEngine, logAccessor));
        }
    }
Beispiel #8
0
        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;
            }
        }
Beispiel #9
0
        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;
            }
        }
Beispiel #10
0
        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;
            }
        }
Beispiel #11
0
 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;
     }
 }
Beispiel #12
0
 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;
     }
 }
 internal static void SetAccessor(LogAccessor inst, SettingsAccessor settings)
 {
     _inst     = inst;
     _settings = settings;
 }
Beispiel #14
0
        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());
                }
            }
        }
Beispiel #15
0
        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;
            }
        }
Beispiel #16
0
 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;
     }
 }
Beispiel #17
0
        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;
            }
        }
Beispiel #18
0
        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;
            }
        }
Beispiel #19
0
        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;
            }
        }
Beispiel #20
0
 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 void InitData(ILogStateClient client, LogAccessor accessor, ChangeStorage storage)
 {
     _storage  = storage;
     _accessor = accessor;
     LD_Log.Init(client.Log, storage);
 }