public ActionResult FinanceList(
     AvailableServices Service, 
     bool PlainText, 
     string Quote, 
     string DateFrom, 
     string DateTo,
     string Format,
     int page = 1
     )
 {
     try
     {
         var url_builder = Service.ConvertToURLBuilderable(Quote, DateFrom, DateTo, Format, page);
         var answer = this._retrieve.GetResponse(url_builder, need_serialization: PlainText);
         if (answer.Equals(string.Empty))
             throw new InvalidOperationException(string.Format("Nothing found for quote {0}", Quote));
         if (!PlainText)
             return Content(answer, "application/json");
         else
             return Content(answer, url_builder.GetFormat(to_web_format: true));
     }
     catch (InvalidOperationException e)
     {
         return Json(new { errorMessage = e.Message }, JsonRequestBehavior.AllowGet);
     }
     catch(Exception) {
         return Json(new { errorMessage = "Sorry, error is occured. Check your form data and try again." }, JsonRequestBehavior.AllowGet);
     }
 }
예제 #2
0
        /// <summary>
        /// Adds the UPS international shipping method.
        /// </summary>
        //[TestMethod]
        //[Priority(27)]
        public void AddSM_UPSInternational()
        {
            #region Arrange
            var smethod0     = new ShippingMethod();
            var store        = _application.CurrentStore;
            var setting      = _irepo.GetAddSMInfo_UPS_Internation(ref store, ref smethod0);
            var spproviderid = GetShippingProviderId(smethod0.ShippingProviderId);
            var smethod1     = new ShippingMethod
            {
                Name               = smethod0.Name,
                StoreId            = _application.CurrentStore.Id,
                ZoneId             = smethod0.ZoneId,
                AdjustmentType     = ShippingMethodAdjustmentType.Amount,
                Adjustment         = 0,
                ShippingProviderId = spproviderid,
            };

            var settings = new UPSServiceSettings();
            settings.Merge(smethod1.Settings);
            var servicecodes = AvailableServices.FindById(GetShippingProviderId(smethod0.ShippingProviderId), _application.CurrentStore).ListAllServiceCodes();

            foreach (var scode in setting.ServiceCodeFilter.Select(filter => servicecodes.FirstOrDefault(x => x.DisplayName.Equals(filter.DisplayName))))
            {
                settings.ServiceCodeFilter.Add(scode);
            }

            smethod1.Settings.Merge(settings);
            #endregion

            //Act/Assert
            Assert.IsTrue(_application.OrderServices.ShippingMethods.Create(smethod1));
        }
예제 #3
0
 public WebSocketHub(ILogger <WebSocketHub> log, CommandDispatcher commandDispatcher, HubManager hubManager, AvailableServices availableServices)
 {
     this.log = log;
     this.commandDispatcher = commandDispatcher;
     this.hubManager        = hubManager;
     this.availableServices = availableServices;
 }
예제 #4
0
        /// <summary>
        /// Edits the UPS international shipping method.
        /// </summary>
        //[TestMethod]
        //[Priority(28)]
        public void EditSM_UPSInternational()
        {
            #region Arrange
            var smethod0 = new ShippingMethod();
            var store    = _application.CurrentStore;
            var setting  = _irepo.GetEditSMInfo_UPS_Internation(ref store, ref smethod0);

            var smethod1 = _application.OrderServices.ShippingMethods.FindAll(_application.CurrentStore.Id)
                           .FirstOrDefault(x => x.ShippingProviderId.Equals(GetShippingProviderId(smethod0.ShippingProviderId)));

            smethod1.Name   = smethod0.Name;
            smethod1.ZoneId = smethod0.ZoneId;

            var settings = new UPSServiceSettings();
            settings.Merge(smethod1.Settings);
            var servicecodes = AvailableServices.FindById(GetShippingProviderId(smethod0.ShippingProviderId), _application.CurrentStore).ListAllServiceCodes();

            foreach (var scode in setting.ServiceCodeFilter.Select(filter => servicecodes.FirstOrDefault(x => x.DisplayName.Equals(filter.DisplayName))))
            {
                settings.ServiceCodeFilter.Add(scode);
            }

            smethod1.Settings.Merge(settings);
            #endregion

            //Act/Assert
            Assert.IsTrue(_application.OrderServices.ShippingMethods.Update(smethod1));
        }
예제 #5
0
        private void LoadShippingMethodEditor(ShippingMethod shippingMethod)
        {
            var p = AvailableServices.FindById(shippingMethod.ShippingProviderId, HccApp.CurrentStore);

            var editor = (HccShippingPart)HccPartController.LoadShippingEditor(p.Name, Page);

            if (editor != null)
            {
                ClearEditorsInfo();
                if (string.IsNullOrEmpty(shippingMethod.Bvin))
                {
                    NewShippingMethod = shippingMethod;
                }
                else
                {
                    EditedShippingMethodId = shippingMethod.Bvin;
                }
                editor.ShippingMethod = shippingMethod;
                editor.ID             = string.Format("ShippingMethod_{0}_{1}", shippingMethod.ShippingProviderId,
                                                      shippingMethod.Bvin);
                editor.EditingComplete += ShippingMethodEditor_EditingComplete;
                AddCloseDialogScript(editor);
                phrEditor.Controls.Add(editor);
            }
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualPeripheralPageViewModel" /> class.
 /// </summary>
 public VirtualPeripheralPageViewModel()
 {
     Context.PropertyChanged += Context_PropertyChanged;
     AvailableServices.Add("Battery");
     AvailableServices.Add("Microsoft Service");
     AvailableServices.Add("Heart Rate Service");
     AvailableServices.Add("Blood Pressure Service");
 }
예제 #7
0
        public ServicesViewModel()
        {
            Title = "Services";
            var services = new AvailableServices();

            Items      = services.Services;
            ItemTapped = new Command <ServicesModel>(OnItemSelected);
        }
 private void LoadProviders()
 {
     lstProviders.ClearSelection();
     foreach (var p in AvailableServices.FindAll(HccApp.CurrentStore))
     {
         lstProviders.Items.Add(new ListItem(p.Name, p.Id));
     }
 }
예제 #9
0
 private void LoadServiceCodes()
 {
     MerchantTribe.Shipping.IShippingService uspostal = AvailableServices.FindById(ShippingMethod.ShippingProviderId, CurrentStore);
     this.ShippingTypesCheckBoxList.DataSource     = uspostal.ListAllServiceCodes();
     this.ShippingTypesCheckBoxList.DataTextField  = "DisplayName";
     this.ShippingTypesCheckBoxList.DataValueField = "Code";
     this.ShippingTypesCheckBoxList.DataBind();
 }
예제 #10
0
 private void LoadServices()
 {
     MerchantTribe.Shipping.IShippingService uspostal = AvailableServices.FindById(WebAppSettings.ShippingUSPostalDomesticId, MTApp.CurrentStore);
     this.lstServiceTypes.DataSource     = uspostal.ListAllServiceCodes();
     this.lstServiceTypes.DataTextField  = "DisplayName";
     this.lstServiceTypes.DataValueField = "Code";
     this.lstServiceTypes.DataBind();
 }
예제 #11
0
 private void LoadProviders()
 {
     ddlProviders.ClearSelection();
     foreach (var shippingService in AvailableServices.FindAll(HccApp.CurrentStore))
     {
         ddlProviders.Items.Add(new RadComboBoxItem(shippingService.Name, shippingService.Id));
     }
 }
예제 #12
0
        private void LoadServiceCodes()
        {
            var ups = AvailableServices.FindById(ShippingMethod.ShippingProviderId, HccApp.CurrentStore);

            ShippingTypesCheckBoxList.DataSource     = ups.ListAllServiceCodes();
            ShippingTypesCheckBoxList.DataTextField  = "DisplayName";
            ShippingTypesCheckBoxList.DataValueField = "Code";
            ShippingTypesCheckBoxList.DataBind();
        }
        private void LoadServices()
        {
            var uspostal = AvailableServices.FindById(DomesticProvider.ServiceId, HccApp.CurrentStore);

            lstServiceTypes.DataSource     = uspostal.ListAllServiceCodes();
            lstServiceTypes.DataTextField  = "DisplayName";
            lstServiceTypes.DataValueField = "Code";
            lstServiceTypes.DataBind();
        }
        private void MigrateFedExRateSetting()
        {
            // 1.9.0: negotiated rates are no longer a global setting, but a "local" setting
            var context         = new HccRequestContext();
            var accountServices = Factory.CreateService <AccountService>(context);
            var stores          = accountServices.Stores.FindAllPaged(1, int.MaxValue);

            foreach (var store in stores)
            {
                context.CurrentStore = store;

                var fedExService =
                    AvailableServices.FindAll(store).FirstOrDefault(s => s.GetType() == typeof(FedExProvider));

                if (fedExService != null)
                {
                    var oldNegotiationRateValue   = true;
                    var oldNegotiationRateSetting =
                        store.Settings.AllSettings.FirstOrDefault(s => s.SettingName == "ShippingFedExUseListRates");

                    if (oldNegotiationRateSetting != null)
                    {
                        // reversing the logic since the previous setting was citing LIST rates and not negotiated rates
                        oldNegotiationRateValue = !oldNegotiationRateSetting.SettingValueAsBool;
                    }

                    // get all fedex methods
                    var orderService = Factory.CreateService <OrderService>(context);
                    var methods      =
                        orderService.ShippingMethods.FindAll(store.Id)
                        .Where(m => m.ShippingProviderId == fedExService.Id);

                    foreach (var method in methods)
                    {
                        // update each FedEx shipping method instance with a local setting, using the original global value as a default
                        var settings = new FedExServiceSettings();
                        settings.Merge(method.Settings);

                        settings["UseNegotiatedRates"] = oldNegotiationRateValue.ToString();

                        method.Settings.Merge(settings);

                        orderService.ShippingMethods.Update(method);
                    }

                    // get rid of the old global setting
                    if (oldNegotiationRateSetting != null)
                    {
                        var settingsRepo = Factory.CreateRepo <StoreSettingsRepository>(context);
                        settingsRepo.Delete(oldNegotiationRateSetting.Id);
                    }
                }

                CacheManager.ClearForStore(store.Id);
            }
        }
예제 #15
0
        public void LoadServiceCodes()
        {
            //Arrange
            var count = _irepo.GetUpsServiceCodeCount();

            //Act
            var resultcount = AvailableServices.FindAll(_application.CurrentStore).FirstOrDefault(x => x.Name.Equals("UPS")).ListAllServiceCodes().Count;

            //Assert
            Assert.AreEqual(count, resultcount);
        }
예제 #16
0
        private void ScanTypes()
        {
            _logger.Debug($"Scan for services");
            AssemblyUtils.GetAttribute <ArgonServiceAttribute>().ForEach(s =>
            {
                _logger.Debug($"Registering service {s.Name}");

                _containerBuilder.RegisterType(s).As(AssemblyUtils.GetInterfaceOfType(s)).SingleInstance();
                AvailableServices.Add(s);
            });
        }
예제 #17
0
        public void LoadTotalShippingMethods()
        {
            //Arrange
            var store        = _application.CurrentStore;
            var storesmethod = AvailableServices.FindAll(store);

            //Act
            var resultcount = _irepo.GetTotalShippingMethodCount();

            //Assert
            Assert.AreEqual(storesmethod.Count, resultcount);
        }
 public AvailableServices FindMethod(string MethodName)
 {
     AvailableServices serv = new AvailableServices();
     foreach (AvailableServices item in availservice)
     {
         if (item.MethodName.Equals(MethodName))
         {
             serv = item;
             break;
         }
     }
     return serv;
 }
예제 #19
0
        internal void LoadUIControls()
        {
            if (ServiceSelectors != null && ServiceSelectors.Any())
            {
                ServiceSelectors.Apply(box => { box.Checked -= ServiceBoxOnCheckChanged; box.Unchecked -= ServiceBoxOnCheckChanged; });
            }
            ServiceSelectors = new ObservableCollection <CheckBox>(AvailableServices.OrderBy(service => service.Order).Select(service => service.GetServiceSelector()));
            ServiceSelectors.Apply(box => { box.Checked += ServiceBoxOnCheckChanged; box.Unchecked += ServiceBoxOnCheckChanged; });

            LoadExternalSettings();
            LoadBuildProperties();
            LoadBuildTargets();
        }
예제 #20
0
        private void PopulateLists()
        {
            var provider = AvailableServices.FindById(ShippingMethod.ShippingProviderId, HccApp.CurrentStore);

            if (provider != null)
            {
                var codes = provider.ListAllServiceCodes();
                lstServiceCode.Items.Clear();
                foreach (var code in codes)
                {
                    lstServiceCode.Items.Add(new ListItem(code.DisplayName, code.Code));
                    lstServicesTest.Items.Add(new ListItem(code.DisplayName, code.Code));
                }
            }
        }
예제 #21
0
        /// <summary>
        /// Sets the services filter code.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="serviceCodeFilter">The service code filter.</param>
        /// <returns></returns>
        private List <IServiceCode> SetServicesFilterCode(string name, IEnumerable <IServiceCode> serviceCodeFilter)
        {
            try
            {
                var servicecodes = AvailableServices.FindAll(_application.CurrentStore)
                                   .FirstOrDefault(x => x.Name.Equals(name))
                                   .ListAllServiceCodes();

                return(serviceCodeFilter.Select(filter => servicecodes.FirstOrDefault(x => x.DisplayName.Equals(filter.DisplayName))).ToList());
            }
            catch (Exception)
            {
                return(new List <IServiceCode>());
            }
        }
예제 #22
0
        private void LoadServiceCodes()
        {
            ShippingTypesRadioButtonList.Items.Clear();

            var ups = AvailableServices.FindById(ShippingMethod.ShippingProviderId, HccApp.CurrentStore);

            ShippingTypesRadioButtonList.DataSource     = ups.ListAllServiceCodes();
            ShippingTypesRadioButtonList.DataTextField  = "DisplayName";
            ShippingTypesRadioButtonList.DataValueField = "Code";
            ShippingTypesRadioButtonList.DataBind();

            if (IsNew || ShippingTypesRadioButtonList.SelectedIndex == -1)
            {
                ShippingTypesRadioButtonList.Items[0].Selected = true;
            }
        }
예제 #23
0
        /// <summary>
        /// Factory returns the service associated to the FactoryService enum
        /// </summary>
        /// <param name="service">The type of service</param>
        /// <returns>An IService</returns>
        public IService GetDbService(AvailableServices service)
        {
            switch (service)
            {
            case AvailableServices.Toggler:
                return(new TogglerService(_fileSettingsPath));

            case AvailableServices.UserAccounts:
                return(new UserAccountService(_fileSettingsPath));

            case AvailableServices.TogglerApplication:
                return(new ApplicationService(_fileSettingsPath));

            default:
                throw new OperationCanceledException("Service name not found.");
            }
        }
        private void InsertFixedBotThomas()
        {
            // Create a Service object for the brick bot
            Service service = new Service("Bricker BIM Bot", "Convert limestone walls to bricks",
                                          "Bricker", "http://www.clker.com/cliparts/a/g/Z/8/6/G/blue-ibm-wall-md.png",
                                          new List <string> {
                "IFC_STEP_2X3TC1"
            },
                                          new List <string> {
                "BCF_ZIP_2_0"
            },
                                          null,
                                          "http://ec2-18-218-56-112.us-east-2.compute.amazonaws.com/");

            // Add the service/bot to the list of services
            AvailableServices.Add(service);
        }
예제 #25
0
        private void LoadEditor()
        {
            var p = AvailableServices.FindById(m.ShippingProviderId, HccApp.CurrentStore);

            var editor = HccPartController.LoadShippingEditor(p.Name, this) as HccShippingPart;

            if (editor != null)
            {
                editor.ShippingMethod = m;
                phEditor.Controls.Add(editor);
                editor.EditingComplete += editor_EditingComplete;
            }
            else
            {
                phEditor.Controls.Add(new LiteralControl(Localization.GetString("EditorLoadError")));
            }
        }
        public void GetAvailableServices()
        {
            try
            {
                // Clear the list
                AvailableServices.Clear();

                // Get list of known providers of BIM Bot services from GitHub
                string resstr = ResponseOfGetRequest("https://raw.githubusercontent.com/opensourceBIM/BIMserver-Repository/master/serviceproviders.json");
                if (resstr != null)
                {
                    // modify the response to add the ifcanalysis provider for now (TODO remove in future)
                    resstr = resstr.Insert(resstr.LastIndexOf(']'), ", {\n" +
                                           "\"name\": \"ifcanalysis.bimserver.services\", \n" +
                                           "\"description\": \"Experimental services provider\", \n" +
                                           "\"listUrl\": \"https://ifcanalysis.bimserver.services/servicelist\"\n" +
                                           "}");

                    // Deserialize the JSON response
                    JsonProviderList gitProviders = JsonConvert.DeserializeObject <JsonProviderList>(resstr);

                    // Insert services of each provider
                    foreach (JsonProvider provider in gitProviders.active)
                    {
                        JsonServiceList serviceList = provider.GetJsonServices();
                        if (serviceList != null)
                        {
                            // Add each service in the list from the JSON response
                            foreach (Service service in serviceList.Services)
                            {
                                // Add the service to the service list
                                AvailableServices.Add(service);
                            }
                        }
                    }
                }

                // add the provider of Kalkzandsteen bot (Thomas) for now (TODO remove in future)
                InsertFixedBotThomas();
            }
            catch (Exception e)
            {
                Console.Write(e);
            }
        }
예제 #27
0
        public override void Initialize(MazeTask mazeTask)
        {
            foreach (var triggerInfo in mazeTask.Triggers)
            {
                var triggerInfoType = triggerInfo.GetType();
                var description     = AvailableServices.First(x => x.DtoType == triggerInfoType);
                var view            = CreateView(description);

                TaskServiceViewModelUtils.Initialize(view.ViewModel, triggerInfo);
                AddChild(view);

                if (mazeTask.Triggers.Count == 1)
                {
                    SetProperty(ref _selectedService, description, nameof(SelectedService));
                    SetProperty(ref _selectedChild, view, nameof(SelectedChild));
                }
            }
        }
예제 #28
0
        public void UPS_DomesticTestRate()
        {
            #region Arrange
            var shipment = _irepo.GetTestRate_UPS_DomesticShipment();
            var item     = _irepo.GetTestRate_UPS_DomesticShippableInfo();
            shipment.Items.Add(item);
            var globalSettings = new USPostalServiceGlobalSettings {
                UserId           = _application.CurrentStore.Settings.ShippingUSPostalUserId,
                DiagnosticsMode  = true,
                IgnoreDimensions = false
            };
            var settings = _irepo.GetTestRate_UPS_DomesticServiceSetting();

            var servicecodes = AvailableServices.FindById(GetShippingProviderId("US Postal Service - Domestic"), _application.CurrentStore).ListAllServiceCodes();

            var displayname = settings.ServiceCodeFilter.FirstOrDefault().DisplayName;

            var code = servicecodes.FirstOrDefault(x => x.DisplayName.Equals(displayname));

            settings.ServiceCodeFilter = new List <IServiceCode> {
                code
            };

            var provider = new DomesticProvider(globalSettings, new Web.Logging.TextLogger())
            {
                Settings = settings
            };
            #endregion

            //Act
            var rates = provider.RateShipment(shipment);

            //Assert
            if (rates == null)
            {
                Assert.AreEqual(1, 0);
            }
            else
            {
                Assert.AreEqual(25, rates.FirstOrDefault().EstimatedCost);
            }
        }
예제 #29
0
        public async Task Get_ReturnResponse_InvalidAddress()
        {
            // Arrange
            var mockAWSGatewayService = new Mock <IAWSGateway>();
            var mockLogger            = new Mock <ILogger <SiteInfoController> >();
            var controller            = new SiteInfoController(mockAWSGatewayService.Object, mockLogger.Object);
            AvailableServices request = new AvailableServices()
            {
                Address = "-invaliddomainaddress",
                Service = new List <string> {
                    "rdap", "freegeoip"
                },
                SearchType = "ip"
            };

            // Act
            var result = await controller.Get(request);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(result, "{\"Address\":[\"Please provide a valid IP or domain name\"]}");
        }
예제 #30
0
        private void ShippingProviderServices()
        {
            var selectedValue = lstTrackingProvider.SelectedValue;
            var services      = new List <IServiceCode>();

            if (!string.IsNullOrEmpty(selectedValue))
            {
                var shippingMethod = HccApp.OrderServices.ShippingMethods.Find(selectedValue);
                var provider       = AvailableServices.FindById(shippingMethod.ShippingProviderId, HccApp.CurrentStore);
                services = provider.ListAllServiceCodes();
            }

            if (services != null && services.Any())
            {
                var removeItem = services.FirstOrDefault(x => x.DisplayName == "All Available Services");
                if (removeItem != null)
                {
                    services.Remove(removeItem);
                }
            }

            if (services != null && services.Any())
            {
                lstTrackingProviderServices.ClearSelection();
                lblShippingServices.Visible                = true;
                lstTrackingProviderServices.Visible        = true;
                lstTrackingProviderServices.DataSource     = services;
                lstTrackingProviderServices.DataTextField  = "DisplayName";
                lstTrackingProviderServices.DataValueField = "Code";
                lstTrackingProviderServices.DataBind();
            }
            else
            {
                lstTrackingProviderServices.Items.Clear();
                lstTrackingProviderServices.Visible = false;
                lblShippingServices.Visible         = false;
            }
        }
예제 #31
0
        /// <summary>
        /// Gets the service methods.
        /// </summary>
        /// <param name="serviceName">Name of the service.</param>
        /// <returns></returns>
        public List <string> GetServiceMethods(string serviceName)
        {
            if (!_availableTypes.ContainsKey(serviceName))
            {
                throw new Exception("Service Not Available");
            }

            Type type = _availableTypes[serviceName];

            var methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Select(method => method.Name).ToList();

            WebServiceMethods = GetWebMethods(type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly));

            foreach (var contractDescription in Contracts)
            {
                if (contractDescription.Name == serviceName && !AvailableServices.ContainsKey(serviceName))
                {
                    AvailableServices.Add(serviceName, WebServiceMethods);
                }
            }

            return(methods);
        }
예제 #32
0
        public async Task Get_ReturnResponse_Valid()
        {
            // Arrange
            var mockAWSGatewayService = new Mock <IAWSGateway>();
            var mockLogger            = new Mock <ILogger <SiteInfoController> >();
            var controller            = new SiteInfoController(mockAWSGatewayService.Object, mockLogger.Object);
            AvailableServices request = new AvailableServices()
            {
                Address = "34.218.207.214",
                Service = new List <string> {
                    "rdap"
                },
                SearchType = "ip"
            };

            mockAWSGatewayService.Setup(m => m.GetMServiceResults("rdap", request.SearchType, request.Address)).ReturnsAsync(GenerateMserviceData());

            // Act
            var result = await controller.Get(request);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("{\"RDAP\": " + "[{\"objectClassName\":\"domain\",\"bunchofotherdata\":\"blahblah\"}]}", result);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        PreRender += new EventHandler(CustomizeWorkflow_PreRender);
        lstipTextBoxes = new List<TextBox>();
        lstMethodNames = new List<TextBox>();
        if (!Page.IsPostBack)
        {
            ShowServices();
        }

        string Methods;
        string Inputs;
        string[] MethodIDs = null;
        string[] Input = null;

        #region DataSourceBinding

        //Get methods for the workflow ID
        localhost.Service serviceObj = new localhost.Service();
        localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(11, 31, Convert.ToInt32(Session["WfID"]));
        string[] arr = obj.FieldNamesProperty;
        List<string> array = new List<string>(arr);
        string[] values = obj.FieldValuesProperty;
        List<string> valuearr = new List<string>(values);
        int counter = 0;
        defaultwrkflw.WfID = Convert.ToInt32(Session["WfID"]);
        for (int j = 0; j < array.Count; j++)
        {
            if (arr[j].ToString() == "wfname")
            {
                defaultwrkflw.WfName = valuearr[counter].ToString();
            }
            if (arr[j].ToString() == "wfmethods")
            {
                Methods = valuearr[counter].ToString();
                MethodIDs = Methods.Split(',');
            }
            if (arr[j].ToString() == "wfinputs")
            {
                Inputs = valuearr[counter].ToString();
                Input = Inputs.Split(',');
                defaultwrkflw.Inputs = Input;
            }
            counter++;
        }

        foreach (var item in MethodIDs)
        {
            defaultwrkflw.Methods.Add(Convert.ToInt32(item));
            obj = serviceObj.ReadDataWithGUID(11, 30, Int32.Parse(item));
            arr = obj.FieldNamesProperty;
            array = new List<string>(arr);
            values = obj.FieldValuesProperty;
            valuearr = new List<string>(values);
            counter = 0;
            for (int j = 0; j < array.Count; j++)
            {
                if (arr[j].ToString() == "minput")
                {
                    defaultwrkflw.InputParam.Add(valuearr[counter].ToString());
                }
                if (arr[j].ToString() == "mname")
                {
                    defaultwrkflw.MethodName.Add(valuearr[counter].ToString());
                }
                if (arr[j].ToString() == "moutput")
                {
                    defaultwrkflw.OutputParam.Add(valuearr[counter].ToString());
                }
                counter++;
            }
        }

        obj = serviceObj.ReadData(11, 30);
        arr = obj.FieldNamesProperty;
        array = new List<string>(arr);
        values = obj.FieldValuesProperty;
        valuearr = new List<string>(values);
        int countRow = valuearr.Count / array.Count;
        counter = 0;
        int addrow = 0;
        for (int i = 0; i < countRow; i++)
        {
            AvailableServices serv = new AvailableServices();
            addrow = 0;
            for (int j = 0; j < array.Count; j++)
            {
                if (arr[j].ToString() == "GUID")
                {
                    serv.MethodId = Convert.ToInt32(valuearr[counter].ToString());
                }
                if (arr[j].ToString() == "mname")
                {
                    serv.MethodName = valuearr[counter].ToString();
                }
                if (arr[j].ToString() == "minput")
                {
                    serv.InputParam = valuearr[counter].ToString();
                }
                if (arr[j].ToString() == "moutput")
                {
                    serv.OutputParam = valuearr[counter].ToString();
                }
                if (arr[j].ToString() == "ownerid")
                {
                    if (Convert.ToInt32(valuearr[counter]) == 11 || Convert.ToInt32(valuearr[counter]) == Convert.ToInt32(Session["OrgId"]))
                    {
                        addrow = 1;
                    }
                }
                counter++;
            }
            if (addrow > 0)
            {
                availservice.Add(serv);
            }
        }
        #endregion

        #region AddControls
        int methodcounter = 0;
        Panel2.Controls.Add(new LiteralControl("<br />"));

        Label work_label = new Label();
        work_label.Text = defaultwrkflw.WfName + " Workflow Steps";
        work_label.Font.Bold = true;
        work_label.Font.Size = 20;
        Panel2.Controls.Add(work_label);
        Panel2.Controls.Add(new LiteralControl("<br />"));
        Table methodtable = new Table();
        methodtable.BorderStyle = BorderStyle.Solid;
        methodtable.BorderWidth = 5;
        methodtable.Font.Bold = true;
        methodtable.Font.Size = 10;
        methodtable.Attributes.Add("runat", "Server");
        methodtable.ID = defaultwrkflw.Methods[methodcounter].ToString();

        TableRow row = new TableHeaderRow();
        var cell1 = new TableCell();
        cell1.Text = "Service Name";
        row.Cells.Add(cell1);

        cell1 = new TableCell();
        cell1.Text = "Ouput Mapping";
        row.Cells.Add(cell1);
        methodtable.Rows.Add(row);

        counter = 0;
        foreach (string item in defaultwrkflw.MethodName)
        {
            if (!item.Equals(""))
            {
                TableRow tr = new TableRow();
                TableCell tc = new TableCell();
                TableCell tc2 = new TableCell();

                TextBox txtMethodName = new TextBox();
                txtMethodName.Width = 350;
                txtMethodName.Text = item;
                TextBox txtInputParam = new TextBox();
                txtInputParam.Text = defaultwrkflw.Inputs[counter++];
                txtInputParam.Width = 50;
                lstipTextBoxes.Add(txtInputParam);
                lstMethodNames.Add(txtMethodName);
                tc.Controls.Add(txtMethodName);
                tc2.Controls.Add(txtInputParam);

                methodtable.Controls.Add(tr);
                tr.Controls.Add(tc);
                tr.Controls.Add(tc2);
            }
        }
        int methodcount = 10 - defaultwrkflw.MethodName.Count;
        while (methodcount > 0 )
        {
            TableRow tr = new TableRow();
            TableCell tc = new TableCell();
            TableCell tc2 = new TableCell();

            TextBox txtMethodName = new TextBox();
            txtMethodName.Width = 350;
            txtMethodName.Text = "";

            TextBox txtInputParam = new TextBox();
            txtInputParam.Text = "";
            txtInputParam.Width = 50;
            lstipTextBoxes.Add(txtInputParam);
            lstMethodNames.Add(txtMethodName);
            tc.Controls.Add(txtMethodName);
            tc2.Controls.Add(txtInputParam);

            methodtable.Controls.Add(tr);
            tr.Controls.Add(tc);
            tr.Controls.Add(tc2);
            methodcount--;
        }
        Panel2.Controls.Add(methodtable);

        #endregion
    }
예제 #34
0
 public RequiredServicesAttribute(AvailableServices requiredServices)
 {
     this.RequiredServices = requiredServices;
 }
예제 #35
0
        //this method chooses a location at random, makes sure it supports the required services, and then
        //randomly decides whether to create an affinity group or not.
        internal static void GetLocationOrAffinityGroup(TestContext testContext, AzureHttpClient testClient, out string locationName, out string affinityGroup, AvailableServices requiredServices)
        {
            locationName = null;
            affinityGroup = null;

            CancellationTokenSource source = new CancellationTokenSource();
            CancellationToken token = source.Token;

            testContext.WriteLine("Listing available locations:");
            var listTask = testClient.ListLocationsAsync(token);
            testContext.WriteLine(listTask.Result.ToString());

            string locationToUse = null;
            bool appropriateLocationFound = false;
            Random r = new Random();

            while (!appropriateLocationFound)
            {
                testContext.WriteLine("Choosing a location at random");
                int idx = r.Next(listTask.Result.Count);
                var location = listTask.Result[idx];

                testContext.WriteLine("Chose Location {0} randomly", location.Name);

                testContext.WriteLine("Checking to see if it supports required services.");
                testContext.WriteLine("Asking for {0}, locations supports {1}", requiredServices.ToString(), location.AvailableServices.ToString());

                if ((requiredServices & location.AvailableServices) == requiredServices)
                {
                    testContext.WriteLine("Found appropriate location {0}", location.Name);
                    locationToUse = location.Name;
                    appropriateLocationFound = true;
                }
                else
                {
                    testContext.WriteLine("Location {0} is not appropriate, it does not support {1} service.", location.Name, (requiredServices ^ location.AvailableServices).ToString());
                }
            }

            bool doAffinityGroup = r.Next(2) == 1;

            if (doAffinityGroup)
            {
                //create an affinity group with a unique name
                string affinityGroupName;
                string affinityGroupLabel;

                CreateUniqueNameAndLabel(out affinityGroupName, out affinityGroupLabel);

                testContext.WriteLine("Randomly chose to create an affinity group, with name {0} and label {1}.", affinityGroupName, affinityGroupLabel);

                var affinityGroupTask = testClient.CreateAffinityGroupAsync(affinityGroupName, affinityGroupLabel, null, locationToUse);
                affinityGroupTask.Wait();
                testContext.WriteLine("Affinity Group {0} created.", affinityGroupName);

                testContext.WriteLine("Getting properties for affinity group {0}", affinityGroupName);
                var getAffinityGroupTask = testClient.GetAffinityGroupAsync(affinityGroupName, token);

                testContext.WriteLine(getAffinityGroupTask.Result.ToString());

                affinityGroup = getAffinityGroupTask.Result.Name;
            }
            else
            {
                locationName = locationToUse;
            }
        }