示例#1
0
        public static EndpointActionDto ToEndpointRuleDto(this EndpointActionEntity entity, InternalHelper internalHelper)
        {
            var actionType  = internalHelper.GetConcreteActionType(entity.ActionType);
            var optionsType = actionType.BaseType.GetGenericArguments().FirstOrDefault();

            var dto = new EndpointActionDto();

            dto.Id                   = entity.Id;
            dto.ActionType           = entity.ActionType;
            dto.Enabled              = entity.Enabled;
            dto.EndpointRuleEntityId = entity.EndpointRuleEntityId;
            dto.Order                = entity.Order;
            dto.Terminating          = entity.Terminating;
            dto.WriteStreamDirect    = entity.WriteStreamDirect;
            var tempDict = Json.Converter.ToDictionary(entity.Parameters);
            var nDict    = new Dictionary <string, object>();

            foreach (var(key, value) in tempDict)
            {
                var prop = optionsType.GetProperty(key);
                if (prop == null)
                {
                    continue;
                }

                var internalProp = prop.GetCustomAttribute <InternalAttribute>();
                if (internalProp == null)
                {
                    nDict.Add(key, value);
                }
            }

            dto.Parameters = nDict;


            return(dto);
        }
示例#2
0
        public MapView()
        {
            this.InitializeComponent();
            MapControl    = Map;
            StaticMapView = this;
            Map.Style     = MapStyle.None;
            Map.TileSources.Clear();
            var AllowOverstretch     = SettingsSetters.GetAllowOverstretch();
            var FadeAnimationEnabled = SettingsSetters.GetFadeAnimationEnabled();

            Map.RotateInteractionMode = MapInteractionMode.GestureOnly;
            //Map.RotateInteractionMode = SettingsSetters.GetRotationControlsVisible();
            var ZoomInteractionMode = SettingsSetters.GetZoomControlsVisible();

            if (ZoomInteractionMode == MapInteractionMode.Auto || ZoomInteractionMode == MapInteractionMode.ControlOnly || ZoomInteractionMode == MapInteractionMode.GestureAndControl || ZoomInteractionMode == MapInteractionMode.PointerKeyboardAndControl)
            {
                ZoomUserControl.Visibility = Visibility.Visible;
            }
            else
            {
                ZoomUserControl.Visibility = Visibility.Collapsed;
            }
            if (ZoomInteractionMode == MapInteractionMode.Auto || ZoomInteractionMode == MapInteractionMode.GestureAndControl || ZoomInteractionMode == MapInteractionMode.GestureOnly || ZoomInteractionMode == MapInteractionMode.PointerAndKeyboard || ZoomInteractionMode == MapInteractionMode.PointerKeyboardAndControl || ZoomInteractionMode == MapInteractionMode.PointerOnly)
            {
                Map.ZoomInteractionMode = MapInteractionMode.GestureOnly;
            }
            else
            {
                Map.ZoomInteractionMode = MapInteractionMode.Disabled;
            }
            if (InternalHelper.InternetConnection())
            {
                //var hm = new HttpMapTileDataSource() { AllowCaching = true };
                //var md = new MapTileSource(hm) { AllowOverstretch = false };
                //Map.TileSources.Add(md);
                //hm.UriRequested += Hm_UriRequested;
                //New
                //Map.TileSources.Add(new MapTileSource(new HttpMapTileDataSource("https://www.googleapis.com/tile/v1/tiles/{x}/{y}/{zoomlevel}?session=sessiontoken&key=AIzaSyCFQ-I2-SPtdtVR4TCa6665mLMX5n_I5Sc")
                //{ AllowCaching = true })
                //{ AllowOverstretch = false, IsFadingEnabled = false, ZoomLevelRange = new MapZoomLevelRange() { Max = 22, Min = 1 } });
                //OLD
                //lyrs parameter h = dark, y = hybrid
                string mapuri = "http://mt1.google.com/vt/lyrs=r&hl=" + AppCore.OnMapLanguage + "&z={zoomlevel}&x={x}&y={y}";
                Map.TileSources.Add(new MapTileSource(new HttpMapTileDataSource(mapuri)
                {
                    AllowCaching = true
                })
                {
                    AllowOverstretch = AllowOverstretch, IsFadingEnabled = FadeAnimationEnabled, ZoomLevelRange = new MapZoomLevelRange()
                    {
                        Max = 22, Min = 0
                    }
                });
            }
            else
            {
                Map.TileSources.Add(new MapTileSource(new LocalMapTileDataSource("ms-appdata:///local/MahMaps/mah_x_{x}-y_{y}-z_{zoomlevel}.jpeg"))
                {
                    AllowOverstretch = AllowOverstretch, IsFadingEnabled = FadeAnimationEnabled
                });
            }
            //if (ClassInfo.DeviceType() == ClassInfo.DeviceTypeEnum.Phone)
            //{
            //    ChangeViewControl.Margin = new Thickness(28, 95, 28, 0);
            //    Searchbar.Margin = new Thickness(28, 40, 28, 0);
            //    DirectionsControl.Margin = new Thickness(28, 0, 28, 0);
            //    MyLocationControl.Margin = new Thickness(28, 28, 28, 28);
            //}
        }
示例#3
0
        public static EndpointRuleDto ToEndpointRuleDto(this EndpointRuleEntity entity, InternalHelper internalHelper)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new EndpointRuleDto();

            dto.Id          = entity.Id;
            dto.Name        = entity.Name;
            dto.Enabled     = entity.Enabled;
            dto.Hostname    = entity.Hostname;
            dto.Path        = entity.Path;
            dto.Order       = entity.Order;
            dto.Scheme      = MappingHelper.Split(entity.Scheme);
            dto.HttpMethods = MappingHelper.Split(entity.HttpMethods);
            dto.Actions     = entity.Actions.OrderBy(a => a.Order).Select(a => a.ToEndpointRuleDto(internalHelper)).ToList();
            dto.Permissions = entity.Permissions.OrderBy(a => a.Order).Select(ToDto).ToList();
            return(dto);
        }
示例#4
0
 private static Task <RpcResult <object> > DrillDownResponseObj(object retVal)
 {
     return(InternalHelper.DrillDownResponseObj(retVal));
 }
 public LiteDBRepoController(IServiceProvider serviceProvider, IMapper mapper, InternalHelper internalHelper)
 {
     _mapper         = mapper;
     _internalHelper = internalHelper;
     Repo            = serviceProvider.GetNamedService <IMiddlerStorage>("litedb");
 }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppLinkPackage" /> class.
        /// </summary>
        /// <param name="linkPath">The link path.</param>
        /// <param name="location">The location.</param>
        /// <param name="settingsStorage">The settings storage.</param>
        /// <remarks>...</remarks>
        public AppLinkPackage(string linkPath, string location, IPackageSettingsStorage settingsStorage)
            : base(location, settingsStorage) {
            if (!Directory.Exists(location))
                Directory.CreateDirectory(location);

            // Package type marker.
            SettingsStorage.Put(this, PackageTypeId, PackageTypeId);

            // Pre-load settings for app link apps.
            // This prevent abnormal behavious as Row/Column span for html apps are included in settings file
            // while app expects them as compiled defaults.
            Load();

            // Create settings
            customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                s.LinkPath = linkPath;
                s.IconPath = Path.Combine(Location, "Icon.png");
                s.ScreenshotPath = Path.Combine(Location, "Screenshot.png");
            });

            // Create icons and texts
            Uri uri;
            if (Uri.TryCreate(customizedSettings.LinkPath, UriKind.RelativeOrAbsolute, out uri)
                &&
                (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
                ) {
                // For url
                customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                    s.IsUrl = true;
                });

                browser = new System.Windows.Forms.WebBrowser();
                browser.ScrollBarsEnabled = false;
                browser.ScriptErrorsSuppressed = true;
                browser.DocumentCompleted += OnbrowserDocumentCompleted;
                browser.Width = (int)SystemParameters.WorkArea.Width;
                browser.Height = (int)SystemParameters.WorkArea.Height;
                browser.Navigate(customizedSettings.LinkPath);
            }
            else {
                // For file / folder

                // Check shell
                if (!File.Exists(customizedSettings.LinkPath) & !Directory.Exists(customizedSettings.LinkPath))
                    return;

                // Check Directory
                if (Directory.Exists(customizedSettings.LinkPath))
                    customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                        s.IsFolder = true;
                    });

                // Create texts
                customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                    if (customizedSettings.IsFolder)
                        s.Title = new DirectoryInfo(s.LinkPath).Name;
                    else
                        s.Title = FileVersionInfo.GetVersionInfo(s.LinkPath).FileDescription ?? new FileInfo(s.LinkPath).Name;
                });

                // Create images
                var icon = InternalHelper.GetThumbnail(customizedSettings.LinkPath) as BitmapSource;
                icon.ToFile(new PngBitmapEncoder(), Path.Combine(Location, customizedSettings.IconPath));

                // Create tile color
                GetSettings().ObjectData[TileControl.TileBgColorKey] = icon.CalculateAverageColor(0xFF).ToString();
            }
        }
 static StringDisplayDrawer()
 {
     ScrollableTextAreaInternal = InternalHelper.CreateDelegate <ScrollableTextAreaInternalSignature>(typeof(EditorGUI), nameof(ScrollableTextAreaInternal));
 }
 /// <summary>
 /// 获取指定实体配置入口点
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 public static IExcelConfiguration <TEntity> For <TEntity>() => InternalHelper.GetExcelConfigurationMapping <TEntity>();
 public EndpointActionController(IMapper mapper, InternalHelper internalHelper, EndpointRuleRepository endpointRuleRepository)
 {
     _mapper                 = mapper;
     _internalHelper         = internalHelper;
     _endpointRuleRepository = endpointRuleRepository;
 }
        public void Init(string Email, string Password, List <InternalItem> internalItems, string url, bool isEnableTicket)
        {
            if (internalItems == null && internalItems.Count == 0)
            {
                return;
            }

            bool isActivityUse = internalItems.Exists(x => x.Activity != null);

            using (var driver = new ChromeDriver(Path.GetDirectoryName(this.ChromeDriverFolder), this.ChromeOptions))
            {
                SeleniumHelper selenium = new SeleniumHelper(driver);
                driver.Navigate().GoToUrl(url);
                driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(200);
                selenium.FindElement(By.XPath("//*[@data-original-title='Log in using your Google account']"), 50)
                .Click();
                selenium.GoogleLogin(Email, Password);

                Thread.Sleep(4000);

                IWebElement Element =
                    selenium.FindElement(By.XPath("//table[@class='table table-hover']"), 100);
                IWebElement         Table = Element.FindElement(By.TagName("tbody"));
                IJavaScriptExecutor js    = driver as IJavaScriptExecutor;

                List <WebProject> listProject = new List <WebProject>();

                foreach (var tr in Table.FindElements(By.TagName("tr")))
                {
                    js.ExecuteScript("arguments[0].style='background-color: red;'", tr);

                    WebProject newProject = new WebProject();

                    int elementCount = 0;
                    foreach (var td in tr.FindElements(By.TagName("td")))
                    {
                        if (elementCount == 1)
                        {
                            newProject.Project = td.Text;
                        }

                        if (elementCount == 2)
                        {
                            newProject.Task = td.Text;
                        }

                        if (elementCount == 7)
                        {
                            newProject.Button    = td.FindElements(By.TagName("button"))[1];
                            newProject.IdElement = td.FindElements(By.TagName("button"))[1].GetAttribute("data-id");
                        }

                        elementCount++;
                    }

                    listProject.Add(newProject);
                    js.ExecuteScript("arguments[0].style='background-color: gray;'", tr);
                }


                listProject = listProject.OrderBy(lp => lp.Project).ToList();

                List <InternalItem> histories = new List <InternalItem>();
                using (StreamReader sr = new StreamReader("TimeEntries.txt", false))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] words = line.Split(';');
                        histories.Add(new InternalItem()
                        {
                            Project  = words[1],
                            Task     = words[2],
                            Activity = words[3],
                            Comment  = words[0]
                        });
                    }
                }

                InternalItem history = new InternalItem();

                foreach (InternalItem entry in internalItems)
                {
                    if (entry.Project == null && histories.Exists(h => h.Comment.Equals(entry.Comment)))
                    {
                        if (isActivityUse)
                        {
                            history = histories.FindLast(h => h.Comment.Equals(entry.Comment) && h.Activity == entry.Activity);
                        }
                        else
                        {
                            history = histories.FindLast(h => h.Comment.Equals(entry.Comment));
                        }


                        if (history != null && listProject.Any(x => x.Project.Equals(history.Project)))
                        {
                            entry.Project  = history.Project;
                            entry.Task     = history.Task;
                            entry.Activity = history.Activity;
                        }
                    }

                    if (entry.Project == null)
                    {
                        InternalItem aux = InternalHelper.GetPredictedProjectValue(entry);
                        entry.Project = aux.Project;
                        entry.Task    = aux.Task;
                    }

                    if (entry.Project == null)
                    {
                        var webProjectObject = GetProjectValue(listProject, entry);

                        //If select skip option
                        if (string.IsNullOrEmpty(webProjectObject.Project))
                        {
                            continue;
                        }

                        entry.Project = webProjectObject.Project;
                        entry.Task    = webProjectObject.Task;
                        Console.Clear();
                    }


                    if (entry.Activity == null || string.IsNullOrEmpty(entry.Activity))
                    {
                        entry.Activity = InternalHelper.GetPredictedActivityValue(entry.Comment);
                    }

                    if (entry.Activity == null || string.IsNullOrEmpty(entry.Activity))
                    {
                        entry.Activity = InternalHelper.GetActivityValue(entry);
                        Console.Clear();
                    }


                    if (!(histories.Exists(h => h.Comment.Equals(entry.Comment)) &&
                          histories.Exists(h => h.Activity.Equals(entry.Activity)) &&
                          histories.Exists(h => h.Project.Equals(entry.Project)) &&
                          histories.Exists(h => h.Task.Equals(entry.Task))))
                    {
                        using (StreamWriter outputFile = File.AppendText("TimeEntries.txt"))
                        {
                            outputFile.WriteLine($"{entry.Comment};{entry.Project};{entry.Task};{entry.Activity}");
                        }

                        histories.Add(new InternalItem()
                        {
                            Project  = entry.Project,
                            Task     = entry.Task,
                            Activity = entry.Activity,
                            Comment  = entry.Comment
                        });
                    }
                }

                //Remove all skip entries
                internalItems.RemoveAll(x => x.IsSkip);

                internalItems = GroupByPerDay(internalItems);

                foreach (InternalItem entry in internalItems)
                {
                    WebProject test = listProject.Find(l =>
                                                       l.Project.ToLower().Equals(entry.Project.ToLower()) &&
                                                       l.Task.ToLower().Equals(entry.Task.ToLower()));

                    if (test != null)
                    {
                        DateTime myDate = DateTime.ParseExact(entry.Date, "yyyy-MM-dd",
                                                              System.Globalization.CultureInfo.InvariantCulture);
                        //string timeDaily = (double.Parse(Time.GetInternalTime(entry.Time).Replace(".", ",")) / 2).ToString().Replace(",", ".");
                        string timeDaily = TimeHelper.GetInternalTime(entry.Time);

                        selenium.FindElement(By.XPath("//button[@data-id='" + test.IdElement + "']"), 50).Click();
                        Thread.Sleep(5000);
                        selenium.FindElement(By.XPath("//input[@name='WorkedHourDate']"), 50).Clear();
                        selenium.FindElement(By.XPath("//input[@name='WorkedHourDate']"), 50)
                        .SendKeys(myDate.ToString("dd/MM/yyyy"));
                        selenium.FindElement(By.XPath("//input[@name='WorkedHourDate']"), 50).SendKeys(Keys.Enter);

                        selenium.FindElement(By.XPath("//input[@name='Amount']"), 50).Clear();
                        selenium.FindElement(By.XPath("//input[@name='Amount']"), 50).SendKeys(entry.Time);
                        selenium.FindElement(By.XPath("//input[@name='Description']"), 50).SendKeys(entry.Comment);

                        if (!string.IsNullOrWhiteSpace(entry.Ticket) && isEnableTicket)
                        {
                            selenium.FindElement(
                                By.XPath("//span[@class='select2-selection select2-selection--single']"), 50).Click();
                            IWebElement TicketSelect =
                                selenium.FindElement(By.XPath("//input[@class='select2-search__field']"), 50);
                            TicketSelect.SendKeys(entry.Ticket);
                            Thread.Sleep(15000);
                            try
                            {
                                TicketSelect.SendKeys(Keys.Enter);
                            }
                            catch (Exception e)
                            {
                                Thread.Sleep(15000);
                                TicketSelect.SendKeys(Keys.Enter);
                            }
                        }

                        IWebElement ActivitySelect =
                            selenium.FindElement(By.XPath("//*[@id='addDashboardHoursInputActivities']"), 50);
                        ActivitySelect.Click();
                        ActivitySelect.FindElement(By.XPath(".//option[contains(text(),'" + entry.Activity + "')]"))
                        .Click();
                        selenium.FindElement(By.XPath("//button[@value='submit']"), 50).Click();
                    }
                    else
                    {
                        Console.WriteLine(string.Format(
                                              "Project {0} doesn't exist - Task {1} - Activity {2} - Date {3}", entry.Project.ToLower(),
                                              entry.Task, entry.Activity, entry.Date));
                    }
                }
            }
        }