Esempio n. 1
0
        /// <summary>
        /// Constructor. Put whatever initialization code in here that you need
        /// </summary>
        public Logger(int AppId, string serverUrl = "http://localhost:{0}/", int serverPort = 54531)
        {
            ApplicationId      = AppId;
            SERVICE_URL        = serverUrl;
            SERVICE_PORT       = serverPort;
            client.BaseAddress = new Uri(String.Format(SERVICE_URL, SERVICE_PORT));

            Thread sendThread = new Thread(() =>
            {
                while (true)
                {
                    Thread.Sleep(200); // sleep and let sendQ be filled up

                    /// send out a list of errors rather than one by one.
                    var errVM            = sendQ.deQ(); // here could be block by empty Q!
                    ApplicationVM appErr = new ApplicationVM()
                    {
                        ApplicationId = this.ApplicationId,
                    };
                    appErr.Errors.Add(errVM);

                    int qsize = sendQ.size();
                    for (int i = 0; i < qsize; ++i)
                    {
                        errVM = sendQ.deQ();
                        appErr.Errors.Add(errVM);
                    }

                    callLoggerWebApi(appErr);
                }
            }
                                           );

            sendThread.Start();
        }
 public static SavedApplicationVM FromVM(ApplicationVM vm)
 {
     return(new SavedApplicationVM
     {
         Scripts = vm.Scripts.Select(n => SavedScriptInfo.FromScriptInfo(n))
     });
 }
        // get application by id
        public ApplicationVM GetApplication(string referenceID)
        {
            string[] serverRefIDs = _context.Application
                                    .Where(a => a.ReferenceID == referenceID)
                                    .FirstOrDefault().Servers
                                    .Select(s => s.ReferenceID)
                                    .ToArray();

            ApplicationVM application = _context.Application
                                        .Where(a => a.ReferenceID == referenceID)
                                        .Select(b => new ApplicationVM
            {
                ApplicationName = b.ApplicationName,
                ReferenceID     = b.ReferenceID,
                Description     = b.Description,
                URL             = b.URL,
                StatusName      = b.Status.StatusName,
                ClientName      = b.Client.ClientName,
                StatusID        = b.StatusID,
                ClientRefID     = b.Client.ReferenceID
            }).FirstOrDefault();

            application.ServerReferenceIDs = serverRefIDs;
            return(application);
        }
        // -- < For .Net WebApplication Log > --

        public static void insertOneLog(ApplicationVM apperrVM)
        {
            using (DatabaseModel.ErrorModelDbContext db = new DatabaseModel.ErrorModelDbContext())
            {
                db.Database.Initialize(false);

                var queryApp = (from app in db.ApplicationSet
                                where app.ApplicationId == apperrVM.ApplicationId
                                select app).First();
                if (queryApp != null)
                {
                    foreach (var errVM in apperrVM.Errors)
                    {
                        queryApp.Errors.Add(new Error()
                        {
                            ErrorMessage = errVM.ErrorMessage,
                            Time         = errVM.Time,
                            LogLevel     = errVM.LogLevel,
                            ExMessage    = errVM.ExMessage
                        });
                    }
                }

                db.SaveChanges();
            }
        }
        /// <summary>
        /// Private method to merge in the model
        /// </summary>
        /// <returns></returns>
        private ApplicationVM GetUpdatedModel()
        {
            ApplicationVM model = new ApplicationVM();

            RepopulateListsFromCacheSession(model);
            model.Message = "";

            if (SessionManager.CurrentApplication != null)
            {
                model.ApplicationItem = SessionManager.CurrentApplication;
            }

            //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING **************************
            bool result = TryUpdateModel(model);//This also validates and sets ModelState

            //*******************************************************************************************************************************
            if (SessionManager.CurrentApplication != null)
            {
                //*****************************************PREVENT OVER POSTING ATTACKS******************************************************
                //Get the values for read only fields from session
                MergeNewValuesWithOriginal(model.ApplicationItem);
                //***************************************************************************************************************************
            }

            SetAccessContext(model);

            return(model);
        }
        public ActionResult Create(ApplicationVM model)
        {
            string msg = "";

            if (ModelState.IsValid)
            {
                bool success = _aRepo.AddApplication(model, out msg);
                if (success)
                {
                    TempData["SuccessMsg"] = msg;
                    return(RedirectToAction("index"));
                }
                else
                {
                    TempData["ErrorMsg"] = msg;
                }
            }
            else
            {
                TempData["ErrorMsg"] = "Application cannot be added at this time.";
            }
            model.StatusList = _sRepo.GetStatusList(Key.STATUS_TYPE_APPLICATION);
            model.ServerList = _sRepo.GetServerList();
            model.ClientList = _sRepo.GetClientList();
            return(View(model));
        }
        private void RepopulateListsFromCacheSession(ApplicationVM model)
        {
            // Populate cached lists if they are empty. Will invoke service call
            ApplicationLookupListsCacheObject CachedLists = CacheManager.ApplicationListCache;

            // Retrieve any cached lists to model
        }
Esempio n. 8
0
        public ActionResult SignUp(ApplicationVM model)
        {
            if (ModelState.IsValid)
            {
                //foreach (var file_ in file)
                //{
                //    if (file_.ContentType == "application/pdf" || file_.ContentType == "image/jpeg" || file_.ContentType == "application/msword" || file_.ContentType == "text/csv" || file_.ContentType == "application/vnd.ms-excel" || file_.ContentType == "image/png" || file_.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || file_.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
                //    {
                //        var b = file_.ContentType;

                //        files.Add(ConvertToByte(file_));
                //        filenames.Add(file_.FileName);
                //    }
                //}


                //var obj = MinnyCasinoAffiliate.Wrapper.Post<bool>("User/Create", model);
            }

            else
            {
                //retain and display error message
                ViewBag.ErrorMessage = "INVALID INPUT";
            }

            return(Redirect("LogIn"));
        }
Esempio n. 9
0
        /// <summary>
        /// Custom startup so we load our IoC immediately before anything else
        /// </summary>
        /// <param name="e"></param>
        protected override async void OnStartup(StartupEventArgs e)
        {
            // Let the base application do what it needs
            base.OnStartup(e);

            // Setup the main application
            await ApplicationSetupAsync();

            // Log it
            Logger.LogDebugSource("Application starting...");

            // Setup the application view model based on if we are logged in
            ApplicationVM.GoToPage(
                // If we are logged in...
                ClientDataStore.HasCredentials() ?
                // Go to chat page
                ApplicationPage.Chat :
                // Otherwise, go to login page
                ApplicationPage.Login);

            var window = new MainWindow();

            if (window.DataContext is ViewModelBase vb)
            {
                vb.FinishInteraction = () =>
                {
                    window.Close();
                };
            }
            window.Show();
        }
Esempio n. 10
0
        public override void Initialize()
        {
            base.Initialize();
            ImagedEntity entity = GetConcretEntity <ImagedEntity>();

            if (entity != null)
            {
                if (entity.Image_Id.HasValue && entity.Image_Id.Value > 0)
                {
                    int typeId     = entity.GetImageType().Id;
                    int imageValue = entity.Image_Id.Value;
                    if (ApplicationVM.LocalCache.AllImages.ContainsKey(typeId))
                    {
                        if (ApplicationVM.LocalCache.AllImages[typeId].ContainsKey(imageValue))
                        {
                            ImageVM = ApplicationVM.LocalCache.AllImages[typeId][imageValue];
                        }
                    }
                    if (ImageVM == null || !File.Exists(ImageVM.StaticImageFile))
                    {
                        var img = ApplicationVM.ChatClient.GetImage(imageValue);
                        if (img != null)
                        {
                            ImageVM = ApplicationVM.AddImage(img);
                            string dir = Path.GetDirectoryName(ImageVM.StaticImageFile);
                            if (!Directory.Exists(dir))
                            {
                                Directory.CreateDirectory(dir);
                            }
                            File.WriteAllBytes(ImageVM.StaticImageFile, img.TheImage);
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        private ApplicationVM ConvertToApplicationVM(Application application)
        {
            ApplicationVM ApplicationVM = new ApplicationVM();

            ApplicationVM.ID   = application.ID;
            ApplicationVM.Name = application.Name;
            return(ApplicationVM);
        }
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = SessionManager.ApplicationCode;

            ApplicationVM model = new ApplicationVM();

            // Not from staff or error
            if (String.IsNullOrEmpty(code))
            {
                //If session has lists then use them
                RepopulateListsFromCacheSession(model);

                //Assume we are in create mode as no code passed
                model.ApplicationItem = new ApplicationModel()
                {
                    IsActive = true
                };
            }
            //if we have been passed a code then assume we are in edit situation and we need to retrieve from the database.
            else
            {
                // Create service instance
                AdminServiceClient sc = new AdminServiceClient();

                try
                {
                    // Call service to get Application item and any associated lookups
                    ApplicationVMDC returnedObject = sc.GetApplication(CurrentUser, CurrentUser, appID, "", code);

                    // Close service communication
                    sc.Close();

                    //Get view model from service
                    model = ConvertApplicationDC(returnedObject);

                    ResolveFieldCodesToFieldNamesUsingLists(model);

                    //Store the service version
                    SessionManager.ApplicationServiceVersion = model.ApplicationItem;
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, sc);
                    model.Message = message;

                    return(View(model));
                }
            }

            //Adds current retrieved Application to session
            SessionManager.CurrentApplication = model.ApplicationItem;
            SetAccessContext(model);

            return(View(model));
        }
        public ActionResult Edit(string id)
        {
            ApplicationVM application = _aRepo.GetApplication(id);

            application.StatusList = _sRepo.GetStatusList(Key.STATUS_TYPE_APPLICATION);
            application.ServerList = _sRepo.GetServerList();
            application.ClientList = _sRepo.GetClientList();
            return(View(application));
        }
        private void SetFlagsFalse(ApplicationVM model)
        {
            model.IsExitConfirmed = "False";
            model.IsNewConfirmed  = "False";

            //Stop the binder resetting the posted values
            ModelState.Remove("IsDeleteConfirmed");
            ModelState.Remove("IsExitConfirmed");
            ModelState.Remove("IsNewConfirmed");
        }
 public bool Insert(ApplicationVM aplicationVM)
 {
     if (string.IsNullOrWhiteSpace(aplicationVM.Name))
     {
         return(status);
     }
     else
     {
         return(iApplicationRepository.Insert(aplicationVM));
     }
 }
Esempio n. 16
0
        /// <summary>
        ///   Performs an update check for a <see cref="ApplicationVM" /> instance.
        /// </summary>
        /// <param name="applicationVM">
        ///   The <see cref="ApplicationVM" /> instance requesting the update check.
        /// </param>
        private void ApplicationVM_RequestShowAbout(ApplicationVM applicationVM)
        {
            // Make sure that auto termination is no longer requested if a window is shown.
            this.Environment.IsNoAutoTerminateDefined = true;

            AboutWindow aboutWindow = new AboutWindow(this.Environment);

            aboutWindow.Owner = this.MainWindow;
            aboutWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            aboutWindow.ShowDialog();
        }
        public ActionResult Create()
        {
            var model = new ApplicationVM
            {
                StatusList = _sRepo.GetStatusList(Key.STATUS_TYPE_APPLICATION),
                ClientList = _sRepo.GetClientList(),
                ServerList = _sRepo.GetServerList(),
            };

            return(View(model));
        }
Esempio n. 18
0
        // note: user role cannot access deactive app
        public static ICollection <ApplicationVM> queryAllAppErrsByPsersonId(int id)
        {
            ICollection <ApplicationVM> appVMs = new List <ApplicationVM>();

            using (DatabaseModel.ErrorModelDbContext db = new DatabaseModel.ErrorModelDbContext())
            {
                // Initialize the DB - false doesn't force reinitialization if the DB already exists
                db.Database.Initialize(false);

                var queryUserRole = (from n in db.LoginSet where n.OnePerson.PersonId == id select n).First().Role;

                List <Application> queryApps;
                // check whether user-role, if yes, filter deactive apps
                if (queryUserRole < (int)RoleEnum.Admin)
                {
                    queryApps = (from n in db.ApplicationSet
                                 where n.Persons.Any(x => x.PersonId == id) && n.IsActive == true
                                 select n).ToList();
                }
                else
                {
                    queryApps = (from n in db.ApplicationSet
                                 where n.Persons.Any(x => x.PersonId == id)
                                 select n).ToList();
                }

                foreach (var app in queryApps)
                {
                    var appVM = new ApplicationVM()
                    {
                        ApplicationId = app.ApplicationId,
                        AppName       = app.AppName,
                        IsActive      = app.IsActive
                    };

                    foreach (var err in app.Errors)
                    {
                        var errVm = new ErrorVM()
                        {
                            ErrorId      = err.ErrorId,
                            ErrorMessage = err.ErrorMessage,
                            Time         = err.Time,
                            LogLevel     = err.LogLevel,
                            ExMessage    = err.ExMessage
                        };
                        appVM.Errors.Add(errVm);
                    }

                    appVMs.Add(appVM);
                }
            }

            return(appVMs);
        }
        private ApplicationVM ConvertApplicationDC(ApplicationVMDC returnedObject)
        {
            ApplicationVM model = new ApplicationVM();

            // Map Application Item
            model.ApplicationItem = Mapper.Map <ApplicationDC, ApplicationModel>(returnedObject.ApplicationItem);

            // Map lookup data lists

            return(model);
        }
Esempio n. 20
0
 public void Close()
 {
     //if (ApplicationVM.IsAuthenticated)
     //{
     //    View_Close();
     //}
     //else
     //{
     ApplicationVM.ShutDown();
     //}
 }
 private void DetermineIsDirty(ApplicationVM model)
 {
     //Compare the Application to the original session
     if (model.ApplicationItem.PublicInstancePropertiesEqual(SessionManager.ApplicationServiceVersion, "RowIdentifier"))
     {
         model.IsViewDirty = false;
     }
     else
     {
         model.IsViewDirty = true;
     }
 }
Esempio n. 22
0
        /// <summary>
        ///   Performs an update check for a <see cref="ApplicationVM" /> instance.
        /// </summary>
        /// <param name="applicationVM">
        ///   The <see cref="ApplicationVM" /> instance requesting the update check.
        /// </param>
        private void ApplicationVM_RequestShowChangelog(ApplicationVM applicationVM)
        {
            // Make sure that auto termination is no longer requested if the Changelog is shown.
            this.Environment.IsNoAutoTerminateDefined = true;

            if (!File.Exists(this.Environment.ChangelogFilePath))
            {
                DialogManager.ShowGeneral_FileNotFound(this.MainWindow, this.Environment.ChangelogFilePath);
                return;
            }

            Process.Start(this.Environment.ChangelogFilePath);
        }
        // GET: Application
        public ActionResult Index()
        {
            ApplicationVM vm = new ApplicationVM();

            if (HttpContext.Application["counter"] == null)
            {
                HttpContext.Application["counter"] = 0;
            }
            vm.Old = (int)HttpContext.Application["counter"];
            HttpContext.Application["counter"] = (int)HttpContext.Application["counter"] + 1;
            vm.New = (int)HttpContext.Application["counter"];
            return(View(vm));
        }
Esempio n. 24
0
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            _ApplicationVM = Resources["ApplicationVM"] as ApplicationVM;

            if (_ApplicationVM != null)
            {
                _ApplicationVM.Startup();
                MainWindow mainWindow = new MainWindow();
                this.MainWindow       = mainWindow;
                this.MainWindow.Title = "";
                this.MainWindow.Show();
            }
        }
Esempio n. 25
0
        public ActionResult AddApp(ApplicationVM postedObj)
        {
            if (ModelState.IsValid)
            {
                var apps = Loader.queryAllApps();

                if (!apps.Any(x => x.AppName == postedObj.AppName))
                {
                    Loader.createApp(postedObj);
                }
                return(RedirectToAction(WebConstants.HOME_ADMIN_PAGE));
            }
            return(View(postedObj));
        }
Esempio n. 26
0
        public ActionResult Index()
        {
            if (!Convert.ToBoolean(Session["IsLogged"]))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var applicationViewModel = new ApplicationVM
            {
                Applications = _unitOfWork.ApplicationRepository.GetAll().OrderByDescending(s => s.ApplicationID)
            };

            ViewBag.ApplicationList = applicationViewModel.Applications.ToList();
            return(View(applicationViewModel));
        }
 private void SetAccessContext(ApplicationVM model)
 {
     //Decide on access context
     if (null == model.ApplicationItem || model.ApplicationItem.Code == Guid.Empty)
     {
         // Create context
         model.AccessContext = ApplicationAccessContext.Create;
     }
     else
     {
         // Edit context
         model.AccessContext = ApplicationAccessContext.Edit;
     }
 }
Esempio n. 28
0
 private void SecureCommandExecute(SecureCommandArgs args)
 {
     if (CanSecureCommandExecute(args))
     {
         if (execute == null)
         {
             ApplicationVM.ExecuteCommand(this, args);
         }
         else
         {
             execute(args);
         }
     }
 }
Esempio n. 29
0
        /// <summary>
        ///   Performs an update check for a <see cref="ApplicationVM" /> instance.
        /// </summary>
        /// <param name="applicationVM">
        ///   The <see cref="ApplicationVM" /> instance requesting the update check.
        /// </param>
        private void ApplicationVM_RequestUpdateCheck(ApplicationVM applicationVM)
        {
            if (UpdateManager.IsDownloadingUpdate)
            {
                return;
            }

            UpdateManager updateManager = new UpdateManager(this.Environment);

            updateManager.VersionCheckSuccessful   += this.UpdateManager_VersionCheckSuccessful;
            updateManager.VersionCheckError        += this.UpdateManager_VersionCheckError;
            updateManager.DownloadUpdateSuccessful += this.UpdateManager_DownloadUpdateSuccessful;
            updateManager.DownloadUpdateError      += this.UpdateManager_DownloadUpdateError;
            updateManager.BeginVersionCheck();
        }
Esempio n. 30
0
        // GET: ReviewMember
        public ActionResult Index()
        {
            int MemberNumber = 0;

            try
            {
                MemberNumber = int.Parse(Session["MemberNumber"].ToString());
            }
            catch (Exception)
            {
                return(RedirectToAction("Index", "LogIn"));
            }
            List <Application>   Applications = new ApplicationsRepository().GetApplications();
            List <ApplicationVM> list         = new List <ApplicationVM>();

            foreach (Application item in Applications)
            {
                ApplicationVM obj = new ApplicationVM();
                obj.ApplicationID     = item.ApplicationID;
                obj.LastName          = item.LastName;
                obj.FirstName         = item.FirstName;
                obj.Address           = item.Address;
                obj.PostalCode        = item.PostalCode;
                obj.Phone             = item.Phone;
                obj.AltPhone          = item.AltPhone;
                obj.Email             = item.Email;
                obj.BirthDate         = item.BirthDate.ToShortDateString();
                obj.Occupation        = item.Occupation;
                obj.CompanyName       = item.CompanyName;
                obj.CompanyAddress    = item.CompanyAddress;
                obj.CompanyPostalCode = item.CompanyPostalCode;
                obj.CompanyPhone      = item.CompanyPhone;
                obj.SubmitDate        = item.SubmitDate.ToShortDateString();
                obj.Sex              = item.Sex.ToString();
                obj.WantsShare       = item.WantsShare ? "Yes" : "No";
                obj.Waitlisted       = item.Waitlisted ? "Yes" : "No";
                obj.Onhold           = item.Onhold ? "Yes" : "No";
                obj.ShareholderName1 = item.ShareholderName1;
                obj.ShareholderDate1 = item.ShareholderDate1.ToShortDateString();
                obj.ShareholderName2 = item.ShareholderName2;
                obj.ShareholderDate2 = item.ShareholderDate2.ToShortDateString();
                list.Add(obj);
            }
            ViewBag.lstData = list;
            return(View());
        }