Esempio n. 1
0
        public static void GetAndPrintAllData()
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(String.Format(SERVICE_URL, SERVICE_PORT));

            HttpResponseMessage  response = client.GetAsync(GET_ACTION).Result;
            OperationsOnDatabase odb      = new OperationsOnDatabase();

            if (response.IsSuccessStatusCode)
            {
                IEnumerable <ErrorClass> result   = response.Content.ReadAsAsync <IEnumerable <ErrorClass> >().Result;
                List <ErrorClass>        templist = new List <ErrorClass>();
                Console.WriteLine("   Data:");
                foreach (ErrorClass value in result)
                {
                    // Console.WriteLine("     " + value);
                    templist.Add(value);
                }
                foreach (var temp in templist)
                {
                    //Console.WriteLine("templist     " + temp);
                    odb.AddErrorLogsFromRest(temp.Loglevel, temp.ApplicationId, temp.ErrorText);
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("ERROR: {0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
Esempio n. 2
0
        private static void GetAndPrintAllData()
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(String.Format(SERVICE_URL, SERVICE_PORT));

            HttpResponseMessage  response = client.GetAsync(GENERAL_ACTION).Result;
            OperationsOnDatabase odb      = new OperationsOnDatabase();
            List <MyData>        list2    = new List <MyData>();

            if (response.IsSuccessStatusCode)
            {
                // in order to make this work, this project needs a reference to System.Net.Http.Formatting
                IEnumerable <MyData> result = response.Content.ReadAsAsync <IEnumerable <MyData> >().Result;

                Console.WriteLine("   Data:");
                foreach (MyData aRecord in result)
                {
                    //odb.AddErrorLogsFromRest(aRecord.Id, aRecord.AppId,aRecord.Text );
                    list2.Add(aRecord);
                    Console.WriteLine("     " + aRecord);
                }
                foreach (MyData aRecord in list2)
                {
                    odb.AddErrorLogsFromRest(aRecord.Id, aRecord.AppId, aRecord.Text);
                    Console.WriteLine("    " + aRecord);
                }

                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("ERROR: {0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
Esempio n. 3
0
        public ActionResult ViewLog(string appname)
        {
            OperationsOnDatabase    odb = new OperationsOnDatabase();
            ICollection <Errorlogs> errorlogs;

            errorlogs = odb.ViewLogs(appname);
            TempData["OwnersLogs"] = errorlogs;
            return(View(errorlogs));
        }
Esempio n. 4
0
        public static void CreateItem(ErrorClass newItem)
        {
            OperationsOnDatabase odb    = new OperationsOnDatabase();
            HttpClient           client = new HttpClient();

            client.BaseAddress = new Uri(String.Format(SERVICE_URL, SERVICE_PORT));
            odb.AddErrorLogsFromRest(newItem.Loglevel, newItem.ApplicationId, newItem.ErrorText);
            client.PostAsJsonAsync(GET_ACTION, newItem).Wait();
        }
Esempio n. 5
0
 public ActionResult AddOwnerToExistingApp(AddOwnerListModel am)
 {
     if (ModelState.IsValid)
     {
         OperationsOnDatabase db = new OperationsOnDatabase();
         db.AddOwnerToExistingApplication(am.selectedApplication, am.selectedUsername);
         return(RedirectToAction("successPage"));
     }
     return(RedirectToAction("ErrorLogin"));
 }
Esempio n. 6
0
 public ActionResult CreateApplication(CreateAppSettingModel cm)
 {
     try
     {
         OperationsOnDatabase db = new OperationsOnDatabase();
         db.CreateApplication(cm.ApplicationName, cm.SelectedUserName);
         return(RedirectToAction("successPage"));
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 7
0
 public ActionResult RegisterUser(UserRegistrationModel userInfo)
 {
     try
     {
         OperationsOnDatabase.RegisterUser(userInfo.FirstName, userInfo.LastName, userInfo.PhoneNumber, userInfo.EmailID, userInfo.Username, userInfo.Password);
         return(RedirectToAction("successPage"));
     }
     catch (Exception e)
     {
         log.Error("Register User class in project controller" + e.Message);
         return(View("ErrorLogin"));
     }
 }
Esempio n. 8
0
 public ActionResult DeactivateAnApplication(ApplicationActivationModel appDetails)
 {
     try
     {
         OperationsOnDatabase odb = new OperationsOnDatabase();
         odb.DeactivateApplication(appDetails.SelectedApplication);
         return(RedirectToAction("successPage"));
     }
     catch (Exception e)
     {
         log.Error("Problem while deactivating the application" + e.Message);
         return(View("ErrorLogin"));
     }
 }
Esempio n. 9
0
 public ActionResult ActivateAUser(DeactivateUserModel userDetails)
 {
     try
     {
         OperationsOnDatabase odb = new OperationsOnDatabase();
         odb.ActivateUser(userDetails.SelectedUserName);
         return(RedirectToAction("successPage"));
     }
     catch (Exception e)
     {
         log.Error("Prolem while deactivating the user" + e.Message);
         return(View("ErrorLogin"));
     }
 }
Esempio n. 10
0
 public ActionResult SearchLogs(SearchLogsModel logmodel)
 {
     try
     {
         OperationsOnDatabase    odb = new OperationsOnDatabase();
         ICollection <Errorlogs> errorlist;
         List <Errorlogs>        errorlistfromlogview = new List <Errorlogs>();
         errorlistfromlogview       = TempData["OwnersLogs"] as List <Errorlogs>;
         errorlist                  = odb.SearchLogs(logmodel.loglevel, errorlistfromlogview);
         TempData["Searchederrors"] = errorlist;
         return(RedirectToAction("ViewSearchedLog"));
     }
     catch (Exception e)
     {
         log.Error("Prolem while deactivating the user" + e.Message);
         return(View("ErrorLogin"));
     }
 }
Esempio n. 11
0
 public ActionResult UserLogin(UserLoginPageReq userCreds)
 {
     try
     {
         bool truthval;
         OperationsOnDatabase odb = new OperationsOnDatabase();
         PasswordEncryption   pe  = new PasswordEncryption();
         truthval = pe.AuthenticateUser(userCreds.name, userCreds.password);
         if (truthval == true)
         {
             TempData["userdata"] = userCreds;
             return(RedirectToAction("ShowAppsToUsers"));
         }
         return(RedirectToAction("ErrorLogin"));
     }
     catch (Exception e)
     {
         log.Error("UserLogin class in project controller" + e.Message);
         return(RedirectToAction("ErrorLogin"));
     }
 }
Esempio n. 12
0
        public ActionResult AdminNew(Admin ad)
        {
            try
            {
                bool truthval            = false;
                OperationsOnDatabase odb = new OperationsOnDatabase();
                PasswordEncryption   pe  = new PasswordEncryption();
                truthval = pe.AuthenticateAdmin(ad.name, ad.password);
                if (truthval == true)
                {
                    return(RedirectToAction("AdminPage"));
                }
                return(RedirectToAction("ErrorLogin"));
            }
            catch (Exception e)
            {
                log.Error("Conditions for a user not satisfied." + e.Message);
                return(RedirectToAction("ErrorLogin"));

                throw e;
            }
        }