Ejemplo n.º 1
0
        /**
         * Login Method to handle Login Button
         * @param  object sender
         * @param  RoutedEventArgs e
         */
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            ApiOperations ops      = new ApiOperations();
            string        username = tbxUsername.Text;
            string        password = pbxPassword.Password;


            // Kan slettes, bruges blot til test
            if (ops.CheckIfAdmin(username, password))
            {
                ShowMainMenu();
                return;
            }
            //NavigationService.Navigate(new MainWindow());

            User user = ops.AuthenticateUser(username, password);

            if (user == null)
            {
                MessageBox.Show("Invalid username or password");
                return;
            }

            Globals.LoggedInUser = user;
            // MessageBox.Show("Login successful");
            ShowMainMenu();
            //NavigationService.Navigate(new DetailsPage());

            //her indsættes kode til at åbne MainWindow
        }
Ejemplo n.º 2
0
        public virtual JsonResult RemoveDocumentSharepointTemp(
            int instanceId,
            string operationNumber,
            string documentNumber,
            string documentName,
            string documentNameTemp)
        {
            string folder = Globals.GetSetting("Temporary_Documents_VER");

            string docName;

            if (string.IsNullOrEmpty(documentNameTemp))
            {
                var docEntitie = _verDocumentService.GetDocumentByReference(documentNumber);
                docName = SanitizeFileName(docEntitie.VerDocumentEntitie.DocumentName) + Path.GetExtension(docEntitie.VerDocumentEntitie.Document.Description);
            }
            else
            {
                docName = documentNameTemp;
            }

            var request = new DeleteDocumentApi365Request
            {
                Connection   = new DataConnection(folder, IDBContext.Current.UserName, operationNumber),
                DocumentId   = documentNumber,
                DocumentName = docName
            };

            var apiShp      = new ApiOperations();
            var responseApi = apiShp.DeleteDocument(request);

            return(Json(responseApi));
        }
Ejemplo n.º 3
0
        public TokenResponse GetToken()
        {
            ApiOperations ops   = new ApiOperations();
            TokenResponse token = ops.Authenticate("regula", "fritzli-hansli-greteli");

            return(token);
        }
        public HttpStatusCode AddRule(GatewayViewModel inputData)
        {
            //GatewayViewModel inputData = (GatewayViewModel)TempData["ipData"];
            inputData.operation = Operations.AddRule.ToString();

            var result = ApiOperations.ExecutivePutApi(_apiHostedUrl, inputData);

            if (result == HttpStatusCode.OK)
            {
                _resultset.Add(new Resultcs()
                {
                    Message = "Rule created successfully", Status = "Completed", State = true
                });
                return(HttpStatusCode.OK);
            }
            else
            {
                _resultset.Add(new Resultcs()
                {
                    Message = "Unable to create Rule", Status = "Error", State = false
                });
            }

            return(HttpStatusCode.BadRequest);
        }
Ejemplo n.º 5
0
        public virtual JsonResult DeleteFolderSharepoint(string operationNumber, string folderName)
        {
            var request = new DeleteFolderRequest
            {
                Connection      = new DataConnection(null, IDBContext.Current.UserName, operationNumber),
                NameFolder      = folderName,
                DeleteAllFolder = true
            };
            var apiShp   = new ApiOperations();
            var response = apiShp.DeleteFolder(request);

            return(Json(response));
        }
Ejemplo n.º 6
0
        public void ShowMainMenu()
        {
            MainWindow MW = new MainWindow();

            Hide();
            MW.ShowDialog();
            // Koden herunder bliver først kørt når brugeren trykker kryds på applikationen
            ApiOperations op = new ApiOperations();

            op.Logout();
            Show();
            tbxUsername.Text     = "";
            pbxPassword.Password = "";
        }
Ejemplo n.º 7
0
        /**
         * Fetch User Details
         */
        private void FetchUserDetails()
        {
            ApiOperations ops  = new ApiOperations();
            User          user = ops.GetUserDetails(Globals.LoggedInUser);

            if (user == null)
            {
                MessageBox.Show("Session expired");
                // Navigate back to login page
                NavigationService.Navigate(new LoginPage());
            }

            Globals.LoggedInUser = user;
        }
Ejemplo n.º 8
0
        public virtual FileResult VerDownloadDocument(string documentId, string opDownNumber)
        {
            var opNumber = IDBContext.Current.Operation ?? opDownNumber;
            var user     = ConfigurationManager.AppSettings["UserDownload_API365"];

            DownloadDocumentApi365Request request = new DownloadDocumentApi365Request
            {
                Connection = new DataConnection(null, user, opNumber),
                DocumentId = documentId
            };
            var apiShp   = new ApiOperations();
            var response = apiShp.DownloadDocumentNew(request);

            return(!response.IsValid ? null : File(
                       response.File, System.Net.Mime.MediaTypeNames.Application.Octet, response.FileName));
        }
        /**
         * Login Method to handle Login Button
         * @param  object sender
         * @param  RoutedEventArgs e
         */
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string username = tbxUsername.Text;
            string password = pbxPassword.Password;

            ApiOperations ops  = new ApiOperations();
            User          user = ops.AuthenticateUser(username, password);

            if (user == null)
            {
                MessageBox.Show("Invalid username or password");
                return;
            }

            Globals.LoggedInUser = user;
            MessageBox.Show("Login successful");
            NavigationService.Navigate(new DetailsPage());
        }
        public HttpStatusCode AddAddHttpSettings(GatewayViewModel inputData)
        {
            //var inputData = (GatewayViewModel)TempData["ipData"];

            if (TempData["myData"] != null)
            {
                _resultset = TempData["myData"] as List <Resultcs>;
            }

            TempData.Keep();

            inputData.operation = Operations.AddHTTPSettings.ToString();
            var result = ApiOperations.ExecutivePutApi(_apiHostedUrl, inputData);


            if (result == HttpStatusCode.OK)
            {
                _resultset.Add(new Resultcs()
                {
                    Message = "HttpSettings created successfully", Status = "Completed", State = true
                });
                //RedirectToAction("AddBackendAddressPool", "Gateway");
                return(AddBackendAddressPool(inputData));
            }
            else
            {
                _resultset.Add(new Resultcs()
                {
                    Message = "Failed to create HttpSettings", Status = "Error", State = false
                });
                _resultset.Add(new Resultcs()
                {
                    Message = "Unable to create BackendAddressPool", Status = "Not Performed", State = false
                });
                _resultset.Add(new Resultcs()
                {
                    Message = "Unable to create Rule", Status = "Not Performed", State = false
                });
            }
            return(HttpStatusCode.BadRequest);
        }
        /**
         * Register method to handle the Register Button
         * @param object sender
         * @param RoutedEventArgs e
         */
        private void btnReg_Click(object sender, RoutedEventArgs e)
        {
            string username = tbxUsername.Text;
            string password = pbxPassword.Password;
            string fullname = tbxFullName.Text;


            ApiOperations ops  = new ApiOperations();
            User          user = ops.RegisterUser(username, password, fullname);

            if (user == null)
            {
                MessageBox.Show("Username already exists");
                return;
            }

            //Globals.LoggedInUser = user;
            MessageBox.Show("Registration successful");
            // NavigationService.Navigate(new DetailsPage());
            //NavigationService.GoBack(); // If page
        }
Ejemplo n.º 12
0
        private void btnReg_Click(object sender, RoutedEventArgs e)
        {
            string username   = tbxUsername.Text;
            string password   = pbxPassword.Password;
            string firstname  = tbxFirstname.Text;
            string lastname   = tbxLastname.Text;
            string middlename = tbxMiddlename.Text;
            int    age        = int.Parse(tbxAge.Text);

            ApiOperations ops  = new ApiOperations();
            User          user = ops.RegisterUser(username, password, firstname, lastname, middlename, age);

            if (user == null)
            {
                MessageBox.Show("Username already exists");
                return;
            }

            Globals.LoggedInUser = user;
            MessageBox.Show("Registration successful");
            NavigationService.Navigate(new DetailsPage());
        }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Policy                           = new PolicyOperations(this);
     PolicySnippets                   = new PolicySnippetsOperations(this);
     Regions                          = new RegionsOperations(this);
     Api                              = new ApiOperations(this);
     ApiRevisions                     = new ApiRevisionsOperations(this);
     ApiRelease                       = new ApiReleaseOperations(this);
     ApiOperation                     = new ApiOperationOperations(this);
     ApiOperationPolicy               = new ApiOperationPolicyOperations(this);
     ApiProduct                       = new ApiProductOperations(this);
     ApiPolicy                        = new ApiPolicyOperations(this);
     ApiSchema                        = new ApiSchemaOperations(this);
     ApiDiagnostic                    = new ApiDiagnosticOperations(this);
     ApiDiagnosticLogger              = new ApiDiagnosticLoggerOperations(this);
     ApiIssue                         = new ApiIssueOperations(this);
     ApiIssueComment                  = new ApiIssueCommentOperations(this);
     ApiIssueAttachment               = new ApiIssueAttachmentOperations(this);
     AuthorizationServer              = new AuthorizationServerOperations(this);
     Backend                          = new BackendOperations(this);
     Certificate                      = new CertificateOperations(this);
     ApiManagementOperations          = new ApiManagementOperations(this);
     ApiManagementServiceSkus         = new ApiManagementServiceSkusOperations(this);
     ApiManagementService             = new ApiManagementServiceOperations(this);
     Diagnostic                       = new DiagnosticOperations(this);
     DiagnosticLogger                 = new DiagnosticLoggerOperations(this);
     EmailTemplate                    = new EmailTemplateOperations(this);
     Group                            = new GroupOperations(this);
     GroupUser                        = new GroupUserOperations(this);
     IdentityProvider                 = new IdentityProviderOperations(this);
     Logger                           = new LoggerOperations(this);
     Notification                     = new NotificationOperations(this);
     NotificationRecipientUser        = new NotificationRecipientUserOperations(this);
     NotificationRecipientEmail       = new NotificationRecipientEmailOperations(this);
     NetworkStatus                    = new NetworkStatusOperations(this);
     OpenIdConnectProvider            = new OpenIdConnectProviderOperations(this);
     SignInSettings                   = new SignInSettingsOperations(this);
     SignUpSettings                   = new SignUpSettingsOperations(this);
     DelegationSettings               = new DelegationSettingsOperations(this);
     Product                          = new ProductOperations(this);
     ProductApi                       = new ProductApiOperations(this);
     ProductGroup                     = new ProductGroupOperations(this);
     ProductSubscriptions             = new ProductSubscriptionsOperations(this);
     ProductPolicy                    = new ProductPolicyOperations(this);
     Property                         = new PropertyOperations(this);
     QuotaByCounterKeys               = new QuotaByCounterKeysOperations(this);
     QuotaByPeriodKeys                = new QuotaByPeriodKeysOperations(this);
     Reports                          = new ReportsOperations(this);
     Subscription                     = new SubscriptionOperations(this);
     TagResource                      = new TagResourceOperations(this);
     Tag                              = new TagOperations(this);
     TagDescription                   = new TagDescriptionOperations(this);
     Operation                        = new OperationOperations(this);
     TenantAccess                     = new TenantAccessOperations(this);
     TenantAccessGit                  = new TenantAccessGitOperations(this);
     TenantConfiguration              = new TenantConfigurationOperations(this);
     User                             = new UserOperations(this);
     UserGroup                        = new UserGroupOperations(this);
     UserSubscription                 = new UserSubscriptionOperations(this);
     UserIdentities                   = new UserIdentitiesOperations(this);
     ApiVersionSet                    = new ApiVersionSetOperations(this);
     ApiExport                        = new ApiExportOperations(this);
     BaseUri                          = new System.Uri("https://management.azure.com");
     ApiVersion                       = "2018-01-01";
     AcceptLanguage                   = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
        public ActionResult AddProbe(UserInputModel inputData)
        {
            GatewayViewModel apiInputData = new GatewayViewModel();

            apiInputData.operation              = Operations.CreateProbe.ToString();
            apiInputData.SubscriptionId         = Constant.subscriptionId;
            apiInputData.ResourceGroupName      = Constant.resourceGroupName;
            apiInputData.ApplicationGatewayName = Constant.applicationGatewayName;

            apiInputData.ProbeName = inputData.FIName + "CustomHealthProbe";
            apiInputData.Protocol  = inputData.Protocol;

            apiInputData.Host      = inputData.Host;
            apiInputData.Probepath = inputData.Probepath;

            apiInputData.HttpSettingsName = inputData.FIName + "AppGatewayHTTPSettings";
            apiInputData.HttpSettingsPort = inputData.Port;


            apiInputData.BckendPoolName  = inputData.FIName + "AppGWBackendpool";
            apiInputData.BckendipAddress = inputData.Host;

            apiInputData.RuleName = inputData.FIName;
            apiInputData.RulePath = inputData.RulePath;

            apiInputData.brearerToken = inputData.BrearerToken;

            var result = ApiOperations.ExecutivePutApi(_apiHostedUrl, apiInputData);

            if (result == HttpStatusCode.OK)
            {
                _resultset.Add(new Resultcs()
                {
                    Message = "Probe created successfully", Status = "Completed", State = true
                });
                AddAddHttpSettings(apiInputData);
            }
            else
            {
                _resultset.Add(new Resultcs()
                {
                    Message = "Failed to create Probe", Status = "Error", State = false
                });
                _resultset.Add(new Resultcs()
                {
                    Message = "Unable to create HttpSettings", Status = "Not Performed", State = false
                });
                _resultset.Add(new Resultcs()
                {
                    Message = "Unable to create BackendAddressPool", Status = "Not Performed", State = false
                });
                _resultset.Add(new Resultcs()
                {
                    Message = "Unable to create Rule", Status = "Not Performed", State = false
                });
            }

            TempData.Put("Result", _resultset);

            return(RedirectToAction("SendResult"));
        }
Ejemplo n.º 15
0
 public void Setup()
 {
     _uut = new ApiOperations();
 }
        public virtual ActionResult UploadFile(
            HttpPostedFileBase file,
            string module,
            string operationNumber,
            string folder,
            string nameDocument,
            bool newDocumentForSave,
            string documentList)
        {
            var oldName = Path.GetFileNameWithoutExtension(file.FileName);

            var documentToList = documentList.Split(',').ToList();

            if (string.IsNullOrEmpty(nameDocument) && documentToList.Contains(oldName))
            {
                return(new JsonResult
                {
                    Data = new ResponseApi365
                    {
                        IsValid = false,
                        ErrorMessage = Localization.GetText("VER.Homepage.TabDocuments.AlreadyExist")
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            var formatDate = string.Format("{0:yyyyMMddHHmmff}", DateTime.Now);
            var prefix     = "_" + formatDate;

            var nameDoc = new StringBuilder();

            nameDoc.Append(string.IsNullOrEmpty(nameDocument)
                ? oldName
                : SanitizeFileName(nameDocument));
            nameDoc.Append(prefix);
            nameDoc.Append(Path.GetExtension(file.FileName));

            var stream = new MemoryStream();

            file.InputStream.CopyTo(stream);

            var request = new UploadDocumentApi365Request
            {
                Connection = new DataConnection(string.IsNullOrEmpty(folder) ? Globals.GetSetting("Temporary_Documents_VER") : folder,
                                                IDBContext.Current.UserName,
                                                operationNumber,
                                                string.IsNullOrEmpty(module) ? null : module),
                Name          = nameDoc.ToString(),
                DocumentFile  = stream.ToArray(),
                OptionVersion = OptionVersion.NoVersion
            };
            var apiShp   = new ApiOperations();
            var response = string.IsNullOrEmpty(module) ?
                           apiShp.AddDocumentTempVer(request) :
                           apiShp.AddDocument(request);

            response.DocumentNameTemp = nameDoc.ToString();
            response.DocumentName     = string.IsNullOrEmpty(nameDocument) ? oldName : nameDocument;

            return(new JsonResult {
                Data = response, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }