public Task Register(ApiServices services, HttpRequestContext context,
        NotificationRegistration registration)
        {
            try
            {
                // Perform a check here for user ID tags, which are not allowed.
                if (!ValidateTags(registration))
                {
                    throw new InvalidOperationException(
                        "You cannot supply a tag that is a user ID.");
                }

                // Get the logged-in user.
                var currentUser = context.Principal as ServiceUser;

                // Add a new tag that is the user ID.
                registration.Tags.Add(currentUser.Id);

                //services.Log.Info("Registered tag for userId: " + currentUser.Id);
            }
            catch (Exception ex)
            {
                //services.Log.Error(ex.ToString());
            }
            return Task.FromResult(true);
        }
Exemplo n.º 2
0
        public static void AppendNamespacesOld(this IBreadcrumbItem breadcrumb, ApiServices context, DocumentedNamespace @namespace, bool link)
        {
            var owner = CreateNamespace(context, @namespace, link);
            var dropdown = new BreadcrumbDropdown(owner);
            var parts = @namespace.Identity.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
            for (int index = 0; index < parts.Length - 1; index++)
            {
                var temp = string.Join(".", parts.Take(index + 1));
                var documentedNamespace = context.ModelResolver.FindNamespace(temp);
                if (documentedNamespace != null)
                {
                    dropdown.AppendNamespace(context, documentedNamespace, true);
                }
            }
            if (link)
            {
                dropdown.Append(owner);
            }

            if (dropdown.Count > 1)
            {
                breadcrumb.Append(dropdown);
            }
            else
            {
                breadcrumb.Append(owner);
            }
        }
Exemplo n.º 3
0
        public ClientsController(ApiServices services, IUnitOfWork unitOfWork, IClientService clientService, IAccountService accountService)
            : base(services, unitOfWork)
        {
            Requires.NotNull(clientService, "clientService");
            _clientService = clientService;

            Requires.NotNull(accountService, "accountService");
            _accountService = accountService;
        }
Exemplo n.º 4
0
        public AccountsController(ApiServices services, IUnitOfWork unitOfWork, IAccountService accountService, ITransactionService transactionService)
            : base(services, unitOfWork)
        {
            Requires.NotNull(accountService, "accountService");
            Requires.NotNull(transactionService, "transactionService");

            _accountService = accountService;
            _transactionService = transactionService;
        }
Exemplo n.º 5
0
        public static async Task<string> SaveBinaryToAzureStorage(ApiServices services, string blobId, string blobData )
        {
            string storageAccountName;
            string storageAccountKey;


            // Try to get the Azure storage account token from app settings.  
            if (!(services.Settings.TryGetValue("STORAGE_ACCOUNT_NAME", out storageAccountName) |
            services.Settings.TryGetValue("STORAGE_ACCOUNT_ACCESS_KEY", out storageAccountKey)))
            {
                return string.Empty;
            }

            // Set the URI for the Blob Storage service.
            Uri blobEndpoint = new Uri(string.Format("https://{0}.blob.core.windows.net", storageAccountName));

            // Create the BLOB service client.
            CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint,
                new StorageCredentials(storageAccountName, storageAccountKey));

            string ContainerName = "beerdrinkinimages";

            // Create a container, if it doesn't already exist.
            CloudBlobContainer container = blobClient.GetContainerReference(ContainerName);
            await container.CreateIfNotExistsAsync();

            // Create a shared access permission policy. 
            BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

            // Enable anonymous read access to BLOBs.
            containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;
            container.SetPermissions(containerPermissions);

            // Define a policy that gives write access to the container for 1 minute.                                   
            SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy()
            {
                SharedAccessStartTime = DateTime.UtcNow,
                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(1),
                Permissions = SharedAccessBlobPermissions.Write
            };

            // Get the SAS as a string.
            var SasQueryString = container.GetSharedAccessSignature(sasPolicy);

            // Set the URL used to store the image.
            var avatarUri = string.Format("{0}{1}/{2}", blobEndpoint.ToString(),
                ContainerName, blobId.ToLower());

            // Upload the new image as a BLOB from the string.
            CloudBlockBlob blobFromSASCredential =
                container.GetBlockBlobReference(blobId.ToLower());
            blobFromSASCredential.UploadTextAsync(blobData);

            return avatarUri;
        }
        public static bool SendCurrentIncidentInvoiceEmail(Incident incident, ApiServices Services)
        {
            IncidentInfo invoiceIncident = new IncidentInfo(incident);

            if (invoiceIncident.PaymentAmount < invoiceIncident.ServiceFee)
            {

                SendGridMessage invoiceMessage = new SendGridMessage();

                invoiceMessage.From = SendGridHelper.GetAppFrom();
                invoiceMessage.AddTo(invoiceIncident.IncidentUserInfo.Email);
                invoiceMessage.Html = " ";
                invoiceMessage.Text = " ";
                invoiceMessage.Subject = "StrandD Invoice - Payment for Service Due";

                invoiceMessage.EnableTemplateEngine(WebConfigurationManager.AppSettings["RZ_InvoiceTemplateID"]);
                invoiceMessage.AddSubstitution("%invoicestub%", new List<string> { invoiceIncident.IncidentGUID.Substring(0, 5).ToUpper() });
                invoiceMessage.AddSubstitution("%incidentguid%", new List<string> { invoiceIncident.IncidentGUID });
                invoiceMessage.AddSubstitution("%name%", new List<string> { invoiceIncident.IncidentUserInfo.Name });
                invoiceMessage.AddSubstitution("%phone%", new List<string> { invoiceIncident.IncidentUserInfo.Phone });
                invoiceMessage.AddSubstitution("%email%", new List<string> { invoiceIncident.IncidentUserInfo.Email });
                invoiceMessage.AddSubstitution("%jobdescription%", new List<string> { invoiceIncident.JobCode });
                invoiceMessage.AddSubstitution("%servicefee%", new List<string> { (invoiceIncident.ServiceFee - invoiceIncident.PaymentAmount).ToString() });
                invoiceMessage.AddSubstitution("%datesubmitted%", new List<string> { DateTime.Now.ToShortDateString() });
                invoiceMessage.AddSubstitution("%datedue%", new List<string> { (DateTime.Now.AddDays(30)).ToShortTimeString() });
                invoiceMessage.AddSubstitution("%servicepaymentlink%", new List<string> { (WebConfigurationManager.AppSettings["RZ_ServiceBaseURL"].ToString() + "/view/customer/incidentpayment/" + invoiceIncident.IncidentGUID) });

                // Create an Web transport for sending email.
                var transportWeb = new Web(SendGridHelper.GetNetCreds());

                // Send the email.
                try
                {
                    transportWeb.Deliver(invoiceMessage);
                    Services.Log.Info("Incident Invoice Email Sent to [" + invoiceIncident.IncidentUserInfo.Email + "]");
                    return true;
                }
                catch (InvalidApiRequestException ex)
                {
                    for (int i = 0; i < ex.Errors.Length; i++)
                    {
                        Services.Log.Error(ex.Errors[i]);
                        return false;
                    }
                }
                return false;

            }
            else
            {
                return false;
            }
        }
Exemplo n.º 7
0
        public UserAppSocket(WebSocket socket, ApiServices services, string homeHubId, string userEmail) : base(socket, services)
        {
            Debug.WriteLine("UserApp Conection opened");
            _userEmail = userEmail;

            _chatHub = ChatHub.Get(homeHubId);
            _chatHub.ClientMessage += _chatHub_ClientMessage;

            _checkInOutMonitor = CheckInOutMonitor.Create(homeHubId);
            _checkInOutMonitor.CheckInOut += _checkInOutMonitor_CheckInOut; ;

            SendInitialStates(homeHubId);
            SendInitialConnectionStatus();
            SendInitialUserInOut();
        }
Exemplo n.º 8
0
 public static bool InsureBreweryDBIsInitialized(ApiServices services)
 {
     if (string.IsNullOrEmpty(BreweryDB.BreweryDBClient.ApplicationKey))
     {
         string apiKey;
         // Try to get the BreweryDB API key  app settings.  
         if (!(services.Settings.TryGetValue("BREWERYDB_API_KEY", out apiKey)))
         {
             services.Log.Error("Could not retrieve BreweryDB API key.");
             return false;
         }
         services.Log.Info(string.Format("BreweryDB API Key {0}", apiKey));
         BreweryDB.BreweryDBClient.Initialize(apiKey);
     }
     return true;
 }
Exemplo n.º 9
0
 public HomeHubSocket(WebSocket socket, ApiServices services) : base(socket, services)
 {
     Debug.WriteLine("HomeHub Conection opened");
 }
Exemplo n.º 10
0
        private async void proceed_Clicked(object sender, EventArgs e)
        {
            try
            {
                loading.IsVisible = true;
                if (email.Text == "" || phone.Text == "")
                {
                    error.IsVisible   = true;
                    loading.IsVisible = false;
                    return;
                }
                var model = new CheckDataRequest()
                {
                    phoneNumber = phone.Text,
                    email       = email.Text,
                    tenantId    = App.AppKey
                };
                var res = await ApiServices.CheckData(model);

                if (res != null)
                {
                    if (res.status)
                    {
                        Preferences.Set("userIdFromDb", res.returnObject.record2.personId);
                        var answer = await DisplayAlert("", "Your data exists in our database, Do you want to sync now?", "Yes", "No");

                        if (answer)
                        {
                            var response = await ApiServices.GetOTP(phone.Text, App.AppKey);

                            if (response != null)
                            {
                                await Navigation.PushModalAsync(new EnterPasswordPage(response.returnObject.otp));
                            }
                            else
                            {
                                MessageDialog.Show("", "Network Error, Please check your conneection or restart the app", "Cancel");
                                await Navigation.PopModalAsync();
                            }
                        }
                        //MessageDialog.Show("","Your data exists in our database, Do you want to sync now?","Ok", async() =>
                        //{


                        //});
                        loading.IsVisible = false;
                    }
                }
                else
                {
                    Preferences.Set("newEmail", email.Text);
                    Preferences.Set("newPhone", phone.Text);
                    await Navigation.PushModalAsync(new RegisterPage());

                    loading.IsVisible = false;
                }
            }
            catch (Exception x)
            {
                await DisplayAlert("", x.Message, "Cancel");

                loading.IsVisible = false;
            }
        }
Exemplo n.º 11
0
 public static void AppendType(this IBreadcrumbItem breadcrumb, ApiServices context, DocumentedType type, bool link)
 {
     Uri uri = null;
     if (link)
     {
         uri = new Uri(context.UrlResolver.GetUrl(type.Identity), UriKind.Relative);
     }
     var signature = context.SignatureResolver.GetTypeSignature(type);
     breadcrumb.Append(new BreadcrumbItem(context.SignatureRenderer.Render(signature, TypeRenderOption.Name), uri));
 }
 public Task Unregister(ApiServices services, HttpRequestContext context,
                        string deviceId)
 {
     // This is where you can hook into registration deletion.
     return(Task.FromResult(true));
 }
        public static async Task SaveCostingSlabAsync(IncidentCostingRequest costingRequest, CostingSlab inputSlab, string slabType, ApiServices Services)
        {

            string responseText;

            //Get Tax Rate
            decimal taxZoneRate = System.Convert.ToDecimal(WebConfigurationManager.AppSettings["RZ_DefaultTaxZoneRate"]);

            //Calulate Provider
            decimal calculatedBaseServiceCost =
                (costingRequest.ServiceKilometers > inputSlab.BaseKilometersFloor) ? (inputSlab.BaseCharge + ((costingRequest.ServiceKilometers - inputSlab.BaseKilometersFloor)) * inputSlab.ExtraKilometersCharge) : inputSlab.BaseCharge;
            decimal calculatedSubtotal = calculatedBaseServiceCost + costingRequest.ParkingCosts + costingRequest.TollCosts + costingRequest.OtherCosts - costingRequest.OffsetDiscount;
            decimal calculatedTaxes = (calculatedSubtotal * taxZoneRate) / 100;
            decimal calculatedTotalCost = calculatedSubtotal + calculatedTaxes;

            stranddContext context = new stranddContext();

            //Check for Provider Incident in IncidentCosting
            IncidentCosting updateIncidentCosting = await (from r in context.IncidentCostings where (r.IncidentGUID == costingRequest.IncidentGUID && r.Type == slabType) 
                                                          select r).FirstOrDefaultAsync();

            if (updateIncidentCosting != null)
            {
                updateIncidentCosting.IdentifierGUID = inputSlab.IdentifierGUID;
                updateIncidentCosting.ServiceType = costingRequest.ServiceType;
                updateIncidentCosting.CostingSlabGUID = inputSlab.Id;
                updateIncidentCosting.TaxZoneRate = taxZoneRate;
                updateIncidentCosting.ServiceKilometers = costingRequest.ServiceKilometers;
                updateIncidentCosting.ParkingCosts = costingRequest.ParkingCosts;
                updateIncidentCosting.TollCosts = costingRequest.TollCosts;
                updateIncidentCosting.OtherCosts = costingRequest.OtherCosts;
                updateIncidentCosting.OffsetDiscount = (slabType=="CUSTOMER") ? costingRequest.OffsetDiscount : 0;
                updateIncidentCosting.CalculatedSubtotal = calculatedSubtotal;
                updateIncidentCosting.CalculatedBaseServiceCost = calculatedBaseServiceCost;
                updateIncidentCosting.CalculatedTaxes = calculatedTaxes;
                updateIncidentCosting.CalculatedTotalCost = calculatedTotalCost;

                await context.SaveChangesAsync();

                responseText = "IncidentCostings (" + slabType + ") Successfully Updated";
            }

            else
            {
                IncidentCosting newIncidentCosting = new IncidentCosting
                {
                    Id = Guid.NewGuid().ToString(),
                    IncidentGUID = costingRequest.IncidentGUID,
                    IdentifierGUID = inputSlab.IdentifierGUID,
                    Type = slabType,
                    ServiceType = costingRequest.ServiceType,
                    CostingSlabGUID = inputSlab.Id,
                    TaxZoneRate = taxZoneRate,
                    ServiceKilometers = costingRequest.ServiceKilometers,
                    ParkingCosts = costingRequest.ParkingCosts,
                    TollCosts = costingRequest.TollCosts,
                    OtherCosts = costingRequest.OtherCosts,
                    OffsetDiscount = (slabType == "CUSTOMER") ? costingRequest.OffsetDiscount : 0,
                    CalculatedSubtotal = calculatedSubtotal,
                    CalculatedBaseServiceCost = calculatedBaseServiceCost,
                    CalculatedTaxes = calculatedTaxes,
                    CalculatedTotalCost = calculatedTotalCost

                };
                context.IncidentCostings.Add(newIncidentCosting);
                await context.SaveChangesAsync();

                responseText = "IncidentCostings (" + slabType + ") Successfully Generated";
            }

        }
Exemplo n.º 14
0
 private static BreadcrumbItem CreateNamespace(ApiServices context, DocumentedNamespace @namespace, bool link)
 {
     Uri uri = null;
     if (link)
     {
         uri = new Uri(context.UrlResolver.GetUrl(@namespace.Identity), UriKind.Relative);
     }
     return new BreadcrumbItem(MvcHtmlString.Create(@namespace.Name), uri);
 }
Exemplo n.º 15
0
 public CurrencyRatesController(ApiServices services, IUnitOfWork unitOfWork, ICurrencyRateService currencyRateService)
     : base(services, unitOfWork)
 {
     Requires.NotNull(currencyRateService, "currencyRateService");
     _currencyRateService = currencyRateService;
 }
Exemplo n.º 16
0
 public ConsentDocumentPatientTrueViewModel()
 {
     apiService = new ApiServices();
     GetConsentDocument();
     instance = this;
 }
 public InternetBankAuthorizationController(ApiServices services, IUnitOfWork unitOfWork, IClientAuthorizationService clientAuthorizationService)
     : base(services, unitOfWork)
 {
     Requires.NotNull(clientAuthorizationService, "clientAuthorizationService");
     _clientAuthorizationService = clientAuthorizationService;
 }
Exemplo n.º 18
0
 public CameraSocket(WebSocket socket, ApiServices services) : base(socket, services)
 {
     Debug.WriteLine("Camera Conection opened");
 }
Exemplo n.º 19
0
 public StateNotification(ApiServices services)
 {
     _services = services;
 }
Exemplo n.º 20
0
 public static void AppendProperty(this IBreadcrumbItem breadcrumb, ApiServices context, DocumentedProperty property)
 {
     breadcrumb.Append(new BreadcrumbItem(MvcHtmlString.Create(property.Definition.Name)));
 }
Exemplo n.º 21
0
        public static void AppendNamespaces(this IBreadcrumbItem breadcrumb, ApiServices context, DocumentedNamespace @namespace, bool link)
        {
            var current = CreateNamespace(context, @namespace, link);

            var parentNamespaces = new List<DocumentedNamespace>();
            var parent = @namespace.Tree.Parent;
            while (parent != null)
            {
                parentNamespaces.Add(parent.Namespace);
                parent = parent.Parent;
            }

            if (!link)
            {
                if (parentNamespaces.Count == 1)
                {
                    // Add the item in the drop down as an item.
                    breadcrumb.AppendNamespace(context, parentNamespaces[0], true);
                    // Append the current namespace.
                    breadcrumb.Append(current);
                }
                else if(parentNamespaces.Count > 1)
                {
                    // Create a dropdown with the first parent namespace as the owner.
                    var dropdown = new BreadcrumbDropdown(CreateNamespace(context, parentNamespaces[0], true));
                    foreach (var parentNamespace in parentNamespaces)
                    {
                        dropdown.AppendNamespace(context, parentNamespace, true);
                    }
                    // Append the dropdown.
                    breadcrumb.Append(dropdown);
                    // Append the current namespace.
                    breadcrumb.Append(current);
                }
                else
                {
                    // No parents. Just show the current namespace.
                    breadcrumb.Append(current);
                }
            }
            else
            {
                if (parentNamespaces.Count >= 1)
                {
                    // Create a dropdown with the current namespace as the owner.
                    var dropdown = new BreadcrumbDropdown(current);
                    dropdown.Append(current);
                    foreach (var parentNamespace in parentNamespaces)
                    {
                        dropdown.AppendNamespace(context, parentNamespace, true);
                    }
                    // Append the dropdown.
                    breadcrumb.Append(dropdown);
                }
                else
                {
                    // No parents. Just show the current namespace.
                    breadcrumb.Append(current);
                }
            }
        }
 public AdministracijaProjektaViewModel(Guid id)
 {
     _apiServices = new ApiServices();
     GetData(id);
 }
Exemplo n.º 23
0
        public static void SendIncidentSubmissionAdminEmail(Incident incident, ApiServices Services)
        {
            SendGridMessage submissionMessage = new SendGridMessage();
            IncidentInfo submisionIncident = new IncidentInfo(incident);

            submissionMessage.From = SendGridHelper.GetAppFrom();
            submissionMessage.AddTo(WebConfigurationManager.AppSettings["RZ_SysAdminEmail"]);
            submissionMessage.Html = " ";
            submissionMessage.Text = " ";
            submissionMessage.Subject = " [" + WebConfigurationManager.AppSettings["MS_MobileServiceName"] + "]";

            submissionMessage.EnableTemplateEngine(WebConfigurationManager.AppSettings["RZ_SubmisionTemplateID"]);
            submissionMessage.AddSubstitution("%timestamp%", new List<string> { submisionIncident.CreatedAt.ToString() });
            submissionMessage.AddSubstitution("%incidentguid%", new List<string> { submisionIncident.IncidentGUID });
            submissionMessage.AddSubstitution("%vehicledetails%", new List<string> { submisionIncident.IncidentVehicleInfo.RegistrationNumber });
            submissionMessage.AddSubstitution("%name%", new List<string> { submisionIncident.IncidentUserInfo.Name });
            submissionMessage.AddSubstitution("%phone%", new List<string> { submisionIncident.IncidentUserInfo.Phone });
            submissionMessage.AddSubstitution("%email%", new List<string> { submisionIncident.IncidentUserInfo.Email });
            submissionMessage.AddSubstitution("%jobdescription%", new List<string> { submisionIncident.JobCode });
            submissionMessage.AddSubstitution("%location%", new List<string> { submisionIncident.LocationObj.RGDisplay });

            // Create an Web transport for sending email.
            var transportWeb = new Web(SendGridHelper.GetNetCreds());

            // Send the email.
            try
            {
                transportWeb.Deliver(submissionMessage);
                Services.Log.Info("New Incident Submission Email Sent to [" + submisionIncident.IncidentUserInfo.Email + "]");
            }
            catch (InvalidApiRequestException ex)
            {
                for (int i = 0; i < ex.Errors.Length; i++)
                {
                    Services.Log.Error(ex.Errors[i]);
                }
            }
        }
Exemplo n.º 24
0
        public void GetDetalleGrilla(int idEstado)
        {
            switch (idEstado)
            {
            case 1:     //Pendiente
                LblTituloGrilla.Text = "Listado de Canjes Pendientes";
                break;

            case 2:     //Cancelados
                LblTituloGrilla.Text = "Listado de Canjes Cancelados";
                break;

            case 3:     //Iniciados
                LblTituloGrilla.Text = "Listado de Canjes Iniciados";
                break;

            case 4:     //Confirmados
                LblTituloGrilla.Text = "Listado de Canjes Confirmados";
                break;
            }

            ApiServices         objApi   = new ApiServices();
            string              Request  = "{}";
            HttpResponseMessage response = objApi.CallService("Pedidos/CanjesByState/" + idEstado, Request, ApiServices.TypeMethods.GET).Result;

            if (response.IsSuccessStatusCode)
            {
                string Respuesta = response.Content.ReadAsStringAsync().Result;
                List <Models.PedidoViewModel> obj = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Models.PedidoViewModel> >(Respuesta);
                string data = "";

                foreach (var item in obj)
                {
                    data += "<tr> ";
                    data += "<td> <img src='" + item.Img_Usuario + "'> " + item.Nombre_Usuario + " </td>  ";

                    data += "<td> " + item.Nombre_Producto + " </td> ";
                    data += "<td><label class='badge badge-gradient-success'>" + item.Desc_Estado + "</label></td>  ";
                    data += "<td> " + item.FechaPedido + " </td> ";
                    data += "<td> " + item.Id + " </td> ";
                    data += "<td style='font-size: x-large'>  ";
                    if (idEstado == 1)
                    {
                        data += "<a style='cursor:pointer' onclick='VerDetalleProducto(" + item.Id + ");return false' ><i class='mdi mdi-magnify'></i><span class='count-symbol bg-warning'></span></a> ";
                    }
                    else
                    {
                        data += "<a style='cursor:pointer' onclick='VerDetalle(" + item.Id + ");return false' ><i class='mdi mdi-magnify'></i><span class='count-symbol bg-warning'></span></a> ";
                    }

                    data += "</td></td>	</tr> ";
                }
                LitGrilla.Text = data;
            }
            else
            {
                string RespuestaService  = response.Content.ReadAsStringAsync().Result;
                ApiServices.Response obj = Newtonsoft.Json.JsonConvert.DeserializeObject <ApiServices.Response>(RespuestaService);
                RespuestaService = response.StatusCode + " - " + obj.Error.message;
            }
            //return ListaOrdenes;
        }
Exemplo n.º 25
0
 public UpdateConfigGlobalConventionViewModel()
 {
     apiService = new ApiServices();
     ListNomenclaturaAutoComplete();
     GetConventionById();
 }
        public static void ProcessProviderOutreach(Incident newIncident, ApiServices Services)
        {
            IHubContext hubContext = Services.GetRealtime<IncidentHub>();

            ProviderJobOffer jobOffer = new ProviderJobOffer()
            {
                JobTag = newIncident.Id,
                ExpirySeconds = 30,
                IncidentInformation = new IncidentInfo(newIncident)
            };

            hubContext.Clients.All.offerMobileProviderClientJob(jobOffer);
            Services.Log.Info("All Mobile Providers Offered Job");
        }
Exemplo n.º 27
0
 public ArchiveRequestViewModel()
 {
     apiService = new ApiServices();
     GetList();
 }
Exemplo n.º 28
0
 public static void AppendMethod(this IBreadcrumbItem breadcrumb, ApiServices context, DocumentedMethod method)
 {
     if (method.Definition.IsConstructor)
     {
         breadcrumb.Append(new BreadcrumbItem("Constructor"));
     }
     else
     {
         var methodSignature = context.SignatureResolver.GetMethodSignature(method);
         breadcrumb.Append(new BreadcrumbItem(context.SignatureRenderer.Render(methodSignature, MethodRenderOption.Name), null));
     }
 }
 public W8RoundTripDomainManager(SDKClientTestContext context, HttpRequestMessage request, ApiServices services)
     : base(context, request, services)
 {
 }
Exemplo n.º 30
0
        private async void TestTime(float averageWorking)
        {
            ApiServices apiServices                          = new ApiServices();
            int         xTotalCases                          = 0;
            int         xEffCases                            = 0;
            int         xIneffCases                          = 0;
            double      effLikelyhood                        = 0;
            double      ineffLikelyhood                      = 0;
            int         totalEffectiveInstances              = 0;
            int         totalIneffectiveInstances            = 0;
            double      xEffProbability                      = 0;
            double      xEffProbabilityMultEffLikelyhood     = 0;
            double      xIneffProbability                    = 0;
            double      xIneffProbabilityMultIneffLikelyhood = 0;
            double      possibilityOfX                       = 0;

            var shiftsSubject = await apiServices.FindWorkshiftsSubjectOfUser(Settings.UserName, viewModel.Item.TitleWorkTask);

            if (shiftsSubject.Count > 0)
            {
                foreach (var shift in shiftsSubject)
                {
                    if (shift.WasEffective == true)
                    {
                        totalEffectiveInstances = totalEffectiveInstances + 1;
                        if (shift.MinutesWorking > averageWorking)
                        {
                            xEffCases = xEffCases + 1;
                        }
                    }
                    else
                    {
                        totalIneffectiveInstances = totalIneffectiveInstances + 1;
                        if (shift.MinutesWorking > averageWorking)
                        {
                            xIneffCases = xIneffCases + 1;
                        }
                    }
                    if (shift.MinutesWorking > averageWorking)
                    {
                        xTotalCases = xTotalCases + 1;
                    }
                }


                //Steg 1: Kolla sannolikhet för effektivt/ineffektivt av alla fall
                effLikelyhood   = (double)totalEffectiveInstances / shiftsSubject.Count;
                ineffLikelyhood = (double)totalIneffectiveInstances / shiftsSubject.Count;

                //Steg 2: Sannolikheten att ett pass upplevs som effektivt/ineffektivt när användaren arbetar efter x

                xEffProbability = (double)xEffCases / totalEffectiveInstances;
                xEffProbabilityMultEffLikelyhood = (double)xEffProbability * effLikelyhood;
                xIneffProbability = (double)xIneffCases / totalIneffectiveInstances;
                xIneffProbabilityMultIneffLikelyhood = (double)xIneffProbability * ineffLikelyhood;
                //Steg 3: För att normalisera divideras båda sidor av beviset med sannolikheten för särdraget som vi är intresserade av, P(x)
                possibilityOfX = (double)xTotalCases / shiftsSubject.Count;
                double effResult   = (double)xEffProbabilityMultEffLikelyhood / possibilityOfX;
                double ineffResult = (double)xIneffProbabilityMultIneffLikelyhood / possibilityOfX;

                if (effResult > ineffResult)
                {
                    lblRecommendation.Text = "Tips: Arbeta längre än " + _avg + " min";
                }
            }
        }
Exemplo n.º 31
0
 public LoginViewModel()
 {
     this.apiService   = new ApiServices();
     this.IsEnabled    = true;
     this.IsRemembered = true;
 }
Exemplo n.º 32
0
        // Called when the user is attempting authorization
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            if (actionContext == null)
            {
                throw new ArgumentNullException("actionContext");
            }

            _services = new ApiServices(actionContext.ControllerContext.Configuration);

            // Check whether we are running in a mode where local host access is allowed 
            // through without authentication.
            if (!_isInitialized)
            {
                HttpConfiguration config = actionContext.ControllerContext.Configuration;
                _isHosted = config.GetIsHosted();
                _isInitialized = true;
            }

            // No security when hosted locally
            if (!_isHosted && actionContext.RequestContext.IsLocal)
            {
                _services.Log.Warn("AuthorizeAadRole: Local Hosting.");
                return;
            }

            ApiController controller = actionContext.ControllerContext.Controller as ApiController;
            if (controller == null)
            {
                _services.Log.Error("AuthorizeAadRole: No ApiController.");
            }

            bool isAuthorized = false;
            try
            {
                // Initialize a mapping for the group id to our enumerated type
                InitGroupIds();

                // Retrieve a AAD token from ADAL
                GetAdToken();
                if (_token == null)
                {
                    _services.Log.Error("AuthorizeAadRole: Failed to get an AAD access token.");
                }
                else
                {
                    // Check group membership to see if the user is part of the group that corresponds to the role
                    if (!string.IsNullOrEmpty(groupIds[(int)Role]) && controller != null)
                    {
                        ServiceUser serviceUser = controller.User as ServiceUser;
                        if (serviceUser != null && serviceUser.Level == AuthorizationLevel.User)
                        {
                            var idents = serviceUser.GetIdentitiesAsync().Result;
                            AzureActiveDirectoryCredentials clientAadCredentials =
                                idents.OfType<AzureActiveDirectoryCredentials>().FirstOrDefault();
                            if (clientAadCredentials != null)
                            {
                                isAuthorized = CheckMembership(clientAadCredentials.ObjectId);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _services.Log.Error(e.Message);
            }
            finally
            {
                if (isAuthorized == false)
                {
                    _services.Log.Error("Denying access");

                    actionContext.Response = actionContext.Request
                        .CreateErrorResponse(HttpStatusCode.Forbidden,
                            "User is not logged in or not a member of the required group");
                }
            }
        }
Exemplo n.º 33
0
 public RequestPatientViewModel()
 {
     apiService = new ApiServices();
     GetRequests();
     instance = this;
 }
Exemplo n.º 34
0
 public VentasItemViewModel()
 {
     apiServices = new ApiServices();
     mainModel   = MainViewModel.Getinstance();
 }
 static PushNotificationsService()
 {
     var options = new ConfigOptions();
     HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));
     Services = new ApiServices(config);
 }
 public MobileRatingSheetDomainManager(RatingtoolContext dbContext, HttpRequestMessage request, ApiServices services)
     : base(dbContext, request, services)
 {
     context = dbContext;
 }
Exemplo n.º 37
0
        public static void SendIncidentPaymentReceiptEmail(Payment payment, ApiServices Services)
        {
            SendGridMessage receiptMessage = new SendGridMessage();
            IncidentInfo receiptIncident = new IncidentInfo(payment.IncidentGUID);

            receiptMessage.From = SendGridHelper.GetAppFrom();
            receiptMessage.AddTo(receiptIncident.IncidentUserInfo.Email);
            receiptMessage.Html = " ";
            receiptMessage.Text = " ";
            receiptMessage.Subject = " ";

            receiptMessage.EnableTemplateEngine(WebConfigurationManager.AppSettings["RZ_ReceiptTemplateID"]);
            receiptMessage.AddSubstitution("%invoicestub%", new List<string> { receiptIncident.IncidentGUID.Substring(0, 5).ToUpper() });
            receiptMessage.AddSubstitution("%name%", new List<string> { receiptIncident.IncidentUserInfo.Name });
            receiptMessage.AddSubstitution("%jobdescription%", new List<string> { receiptIncident.JobCode });
            receiptMessage.AddSubstitution("%servicefee%", new List<string> { receiptIncident.ServiceFee.ToString() });
            receiptMessage.AddSubstitution("%datesubmitted%", new List<string> { DateTime.Now.ToShortDateString() });
            receiptMessage.AddSubstitution("%paymentmethod%", new List<string> { receiptIncident.PaymentMethod });
            receiptMessage.AddSubstitution("%paymentamount%", new List<string> { receiptIncident.PaymentAmount.ToString() });

            // Create an Web transport for sending email.
            var transportWeb = new Web(SendGridHelper.GetNetCreds());

            // Send the email.
            try
            {
                transportWeb.Deliver(receiptMessage);
                Services.Log.Info("Payment Receipt Email Sent to [" + receiptIncident.IncidentUserInfo.Email + "]");
            }
            catch (InvalidApiRequestException ex)
            {
                for (int i = 0; i < ex.Errors.Length; i++)
                {
                    Services.Log.Error(ex.Errors[i]);
                }
            }
        }
Exemplo n.º 38
0
 public UpdateTVAViewModel()
 {
     apiService = new ApiServices();
 }
Exemplo n.º 39
0
 public async Task <List <Applications> > Get()
 {
     _api = new ApiServices("applications", null);
     return(JsonConvert.DeserializeObject <List <Applications> >(await _api.Get()));
 }
Exemplo n.º 40
0
 public CommentRendererContext(HtmlTextWriter writer, ApiServices services)
 {
     Writer = writer;
     Services = services;
 }
Exemplo n.º 41
0
 public NewNotificationViewModel()
 {
     apiService = new ApiServices();
 }
Exemplo n.º 42
0
 public FavoritesDomainManager(mpbdmContext <Guid> context, HttpRequestMessage request, ApiServices services, IPrincipal User)
     : base(context, request, services, true)
 {
     this.User     = User;
     domainManager = new EntityDomainManager <Favorites>(context, request, services, true);
 }
 public PedestriansDomainManager(DbContext context, HttpRequestMessage request, ApiServices services)
     : base(context, request, services)
 {
 }
Exemplo n.º 44
0
 public UpdateJobCronViewModel()
 {
     apiService = new ApiServices();
 }
Exemplo n.º 45
0
 public AileController(ApiServices apiServices)
 {
     _apiServices = apiServices;
 }
Exemplo n.º 46
0
 public UpdateAntecedentViewModel()
 {
     apiService = new ApiServices();
 }
Exemplo n.º 47
0
 public BiblesViewModel()
 {
     this.apiservices = new ApiServices();
     this.LoadBibles();
 }
Exemplo n.º 48
0
 public PatientSlaveViewModel()
 {
     apiService = new ApiServices();
     GetPatients();
 }
Exemplo n.º 49
0
 public ProductsViewModel()
 {
     instance          = this;
     this._apiServices = new ApiServices();
     this.LoadProducts();
 }
 public ConventionDeactivateViewModel()
 {
     apiService = new ApiServices();
 }
Exemplo n.º 51
0
 public static IHtmlString ExtensionMethodLink(this ApiServices context, DocumentedMethod method)
 {
     return(MethodLink(context, method, MethodRenderOption.Name | MethodRenderOption.Parameters | MethodRenderOption.ExtensionMethod));
 }
Exemplo n.º 52
0
 public RoomDeactivateViewModel()
 {
     apiService = new ApiServices();
 }
Exemplo n.º 53
0
 public UpdateSIAPECViewModel()
 {
     apiService = new ApiServices();
     ListBranchAutoComplete();
     ListCodRLAutoComplete();
 }
        public static void RevokeProviderJobs(Incident updateIncident, ApiServices Services)
        {
            IHubContext hubContext = Services.GetRealtime<IncidentHub>();

            hubContext.Clients.All.revokeMobileProviderClientJob(updateIncident.Id);
            Services.Log.Info("All Mobile Providers Offered Job");
        }
Exemplo n.º 55
0
 public PocetnaViewModel()
 {
     _apiServices = new ApiServices();
     GetData();
 }
        public static void ProcessStatusRequestBehavior(IncidentStatusRequest statusRequest, Incident updateIncident, ApiServices Services)
        {
            IHubContext hubContext = Services.GetRealtime<IncidentHub>();

            switch (updateIncident.StatusCode)
            {
                case "PROVER-FOUND":

                    //Notify Particular Connected User through SignalR
                    hubContext.Clients.Group(updateIncident.ProviderUserID).updateMobileClientStatus(statusRequest.GetCustomerPushObject());
                    Services.Log.Info("Mobile Client [" + updateIncident.ProviderUserID + "] Status Update Payload Sent");

                    //Notifying Connect WebClients with IncidentInfo Package            
                    hubContext.Clients.All.updateIncidentStatusAdmin(new IncidentInfo(updateIncident));
                    Services.Log.Info("Connected Clients Updated");

                    RevokeProviderJobs(updateIncident, Services);
                    Services.Log.Info("Provider Jobs Revoked");

                    break;

                case "ARRIVED":
                    
                    //Notify Particular Connected User through SignalR
                    hubContext.Clients.Group(updateIncident.ProviderUserID).updateMobileClientStatus(statusRequest.GetCustomerPushObject());
                    Services.Log.Info("Mobile Client [" + updateIncident.ProviderUserID + "] Status Update Payload Sent");

                    //Notifying Connect WebClients with IncidentInfo Package            
                    hubContext.Clients.All.updateIncidentStatusAdmin(new IncidentInfo(updateIncident));
                    Services.Log.Info("Connected Clients Updated");

                    SendGridController.SendCurrentIncidentInvoiceEmail(updateIncident, Services);

                    break;

                case "COMPLETED":

                    //Notify Particular Connected User through SignalR
                    hubContext.Clients.Group(updateIncident.ProviderUserID).updateMobileClientStatus(statusRequest.GetCustomerPushObject());
                    Services.Log.Info("Mobile Client [" + updateIncident.ProviderUserID + "] Status Update Payload Sent");

                    //Notifying Connect WebClients with IncidentInfo Package            
                    hubContext.Clients.All.updateIncidentStatusAdmin(new IncidentInfo(updateIncident));
                    Services.Log.Info("Connected Clients Updated");
                    break;

                case "DECLINED":

                    //Notify Particular Connected User through SignalR
                    hubContext.Clients.Group(updateIncident.ProviderUserID).updateMobileClientStatus(statusRequest.GetCustomerPushObject());
                    Services.Log.Info("Mobile Client [" + updateIncident.ProviderUserID + "] Status Update Payload Sent");

                    //Notifying Connect WebClients with IncidentInfo Package            
                    hubContext.Clients.All.updateIncidentStatusAdmin(new IncidentInfo(updateIncident));
                    Services.Log.Info("Connected Clients Updated");

                    RevokeProviderJobs(updateIncident, Services);
                    Services.Log.Info("Provider Jobs Revoked");

                    break;

                case "CANCELLED":
                    //Notifying Connect WebClients with IncidentInfo Package            
                    hubContext.Clients.All.updateIncidentStatusCustomerCancel(new IncidentInfo(updateIncident));
                    Services.Log.Info("Connected Clients Updated");

                    RevokeProviderJobs(updateIncident, Services);
                    Services.Log.Info("Provider Jobs Revoked");

                    break;

                default:
                    //Notify Particular Connected User through SignalR
                    hubContext.Clients.Group(updateIncident.ProviderUserID).updateMobileClientStatus(statusRequest.GetCustomerPushObject());
                    Services.Log.Info("Mobile Client [" + updateIncident.ProviderUserID + "] Status Update Payload Sent");

                    //Notifying Connect WebClients with IncidentInfo Package            
                    hubContext.Clients.All.updateIncidentStatusAdmin(new IncidentInfo(updateIncident));
                    Services.Log.Info("Connected Clients Updated");

                    break;
            }
        }
Exemplo n.º 57
0
 public MainViewModel()
 {
     apiService = new ApiServices();
     cargar();
 }
 public Task Unregister(ApiServices services, HttpRequestContext context,
     string deviceId)
 {
     // This is where you can hook into registration deletion.
     return Task.FromResult(true);
 }
Exemplo n.º 59
0
 public static void AppendNamespace(this IBreadcrumbItem breadcrumb, ApiServices context, DocumentedNamespace @namespace, bool link)
 {
     breadcrumb.Append(CreateNamespace(context, @namespace, link));
 }