Exemplo n.º 1
0
        public bool IsWhiteListed(System.Collections.Generic.List <RunOn> runons)
        {
            DateTime now = DateTime.Now;

            if (!runons.Any())
            {
                return(true);
            }

            List <string> runonDays = runons.Select(a => a.Day).ToList();

            if (runonDays.Select(a => a.ToUpper()).Contains(now.DayOfWeek.ToString().ToUpper())) //day check
            {
                //time check
                foreach (var timeR in runons.Where(a => a.Day.Equals(now.DayOfWeek.ToString(), StringComparison.OrdinalIgnoreCase)).ToList())
                {
                    var start = DateTime.Parse(timeR.From, System.Globalization.CultureInfo.CurrentCulture);
                    var end   = DateTime.Parse(timeR.To, System.Globalization.CultureInfo.CurrentCulture);

                    if (start <= end)
                    {
                        return(start <= now && now <= end);
                    }
                    return(!(end <= now && now <= start));
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public static string ExecuteGetRequest(ClientContext context, string endPointUrl, string select = null, string filter = null, string expand = null, uint?top = null)
        {
            var url = endPointUrl;

            if (!url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
            {
                url = context.Url + "/_api/" + endPointUrl;
            }
            var restparams = new System.Collections.Generic.List <string>();

            if (!string.IsNullOrEmpty(select))
            {
                restparams.Add($"$select={select}");
            }
            if (!string.IsNullOrEmpty(filter))
            {
                restparams.Add($"$filter={filter}");
            }
            if (!string.IsNullOrEmpty(expand))
            {
                restparams.Add($"$expand={expand}");
            }
            if (top.HasValue)
            {
                restparams.Add($"$top={top}");
            }
            if (restparams.Any())
            {
                url += $"?{string.Join("&", restparams)}";
            }
            var client = PnP.Framework.Http.PnPHttpClient.Instance.GetHttpClient();

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", context.GetAccessToken());

            var authManager = context.GetContextSettings().AuthenticationManager;

            if (authManager.CookieContainer != null)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var cookie in authManager.CookieContainer.GetCookies(new Uri(url)))
                {
                    sb.AppendFormat("{0}; ", cookie.ToString());
                }
                client.DefaultRequestHeaders.Add("Cookie", sb.ToString());
            }
            var returnValue = client.GetStringAsync(url).GetAwaiter().GetResult();

            return(returnValue);
        }
Exemplo n.º 3
0
        private static HttpResponseMessage ExecutePostRequestInternal(ClientContext context, string endPointUrl, HttpContent content, string select = null, string filter = null, string expand = null, Dictionary <string, string> additionalHeaders = null, uint?top = null)
        {
            var url = endPointUrl;

            if (!url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
            {
                url = context.Url + "/_api/" + endPointUrl;
            }
            var restparams = new System.Collections.Generic.List <string>();

            if (!string.IsNullOrEmpty(select))
            {
                restparams.Add($"$select={select}");
            }
            if (!string.IsNullOrEmpty(filter))
            {
                restparams.Add($"$filter=({filter})");
            }
            if (!string.IsNullOrEmpty(expand))
            {
                restparams.Add($"$expand={expand}");
            }
            if (top.HasValue)
            {
                restparams.Add($"$top={top}");
            }
            if (restparams.Any())
            {
                url += $"?{string.Join("&", restparams)}";
            }

            var client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", context.GetAccessToken());
            client.DefaultRequestHeaders.Add("X-RequestDigest", context.GetRequestDigest().GetAwaiter().GetResult());

            if (additionalHeaders != null)
            {
                foreach (var key in additionalHeaders.Keys)
                {
                    client.DefaultRequestHeaders.Add(key, additionalHeaders[key]);
                }
            }
            var returnValue = client.PostAsync(url, content).GetAwaiter().GetResult();

            returnValue.EnsureSuccessStatusCode();
            return(returnValue);
        }
Exemplo n.º 4
0
        public static string ExecuteGetRequest(ClientContext context, string endPointUrl, string select = null, string filter = null, string expand = null, uint?top = null)
        {
            var url = endPointUrl;

            if (!url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
            {
                url = context.Url + "/_api/" + endPointUrl;
            }
            var restparams = new System.Collections.Generic.List <string>();

            if (!string.IsNullOrEmpty(select))
            {
                restparams.Add($"$select={select}");
            }
            if (!string.IsNullOrEmpty(filter))
            {
                restparams.Add($"$filter={filter}");
            }
            if (!string.IsNullOrEmpty(expand))
            {
                restparams.Add($"$expand={expand}");
            }
            if (top.HasValue)
            {
                restparams.Add($"$top={top}");
            }
            if (restparams.Any())
            {
                url += $"?{string.Join("&", restparams)}";
            }
            var client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", context.GetAccessToken());
            var returnValue = client.GetStringAsync(url).GetAwaiter().GetResult();

            return(returnValue);
        }
Exemplo n.º 5
0
    static void SetGraphicsSettings()
    {
        VRC.Core.Logger.Log("Setting Graphics Settings", VRC.Core.DebugLevel.All);

        const string     GraphicsSettingsAssetPath = "ProjectSettings/GraphicsSettings.asset";
        SerializedObject graphicsManager           = new SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(GraphicsSettingsAssetPath)[0]);

        SerializedProperty deferred = graphicsManager.FindProperty("m_Deferred.m_Mode");

        deferred.enumValueIndex = 1;

        SerializedProperty deferredReflections = graphicsManager.FindProperty("m_DeferredReflections.m_Mode");

        deferredReflections.enumValueIndex = 1;

        SerializedProperty screenSpaceShadows = graphicsManager.FindProperty("m_ScreenSpaceShadows.m_Mode");

        screenSpaceShadows.enumValueIndex = 1;

        SerializedProperty legacyDeferred = graphicsManager.FindProperty("m_LegacyDeferred.m_Mode");

        legacyDeferred.enumValueIndex = 1;

        SerializedProperty depthNormals = graphicsManager.FindProperty("m_DepthNormals.m_Mode");

        depthNormals.enumValueIndex = 1;

        SerializedProperty motionVectors = graphicsManager.FindProperty("m_MotionVectors.m_Mode");

        motionVectors.enumValueIndex = 1;

        SerializedProperty lightHalo = graphicsManager.FindProperty("m_LightHalo.m_Mode");

        lightHalo.enumValueIndex = 1;

        SerializedProperty lensFlare = graphicsManager.FindProperty("m_LensFlare.m_Mode");

        lensFlare.enumValueIndex = 1;

#if ENV_SET_INCLUDED_SHADERS && VRC_CLIENT
        SerializedProperty alwaysIncluded = graphicsManager.FindProperty("m_AlwaysIncludedShaders");
        alwaysIncluded.arraySize = 0;   // clear GraphicsSettings->Always Included Shaders - these cause a +5s app startup time increase on Quest.
                                        // include Shader objects as resources instead

#if ENV_SEARCH_FOR_SHADERS
        Resources.LoadAll("", typeof(Shader));
        System.Collections.Generic.List <Shader> foundShaders = Resources.FindObjectsOfTypeAll <Shader>()
                                                                .Where(s => { string name = s.name.ToLower(); return(0 == (s.hideFlags & HideFlags.DontSave)); })
                                                                .GroupBy(s => s.name)
                                                                .Select(g => g.First())
                                                                .ToList();
#else
        System.Collections.Generic.List <Shader> foundShaders = new System.Collections.Generic.List <Shader>();
#endif

        for (int shaderIdx = 0; shaderIdx < ensureTheseShadersAreAvailable.Length; ++shaderIdx)
        {
            if (foundShaders.Any(s => s.name == ensureTheseShadersAreAvailable[shaderIdx]))
            {
                continue;
            }
            Shader namedShader = Shader.Find(ensureTheseShadersAreAvailable[shaderIdx]);
            if (namedShader != null)
            {
                foundShaders.Add(namedShader);
            }
        }

        foundShaders.Sort((s1, s2) => s1.name.CompareTo(s2.name));

        // populate Resources list of "always included shaders"
        ShaderAssetList alwaysIncludedShaders = AssetDatabase.LoadAssetAtPath <ShaderAssetList>("Assets/Resources/AlwaysIncludedShaders.asset");
        alwaysIncludedShaders.Shaders = new Shader[foundShaders.Count];
        for (int shaderIdx = 0; shaderIdx < foundShaders.Count; ++shaderIdx)
        {
            alwaysIncludedShaders.Shaders[shaderIdx] = foundShaders[shaderIdx];
        }
#endif

        SerializedProperty preloaded = graphicsManager.FindProperty("m_PreloadedShaders");
        preloaded.ClearArray();
        preloaded.arraySize = 0;

        SerializedProperty spritesDefaultMaterial = graphicsManager.FindProperty("m_SpritesDefaultMaterial");
        spritesDefaultMaterial.objectReferenceValue = Shader.Find("Sprites/Default");

        SerializedProperty renderPipeline = graphicsManager.FindProperty("m_CustomRenderPipeline");
        renderPipeline.objectReferenceValue = null;

        SerializedProperty transparencySortMode = graphicsManager.FindProperty("m_TransparencySortMode");
        transparencySortMode.enumValueIndex = 0;

        SerializedProperty transparencySortAxis = graphicsManager.FindProperty("m_TransparencySortAxis");
        transparencySortAxis.vector3Value = Vector3.forward;

        SerializedProperty defaultRenderingPath = graphicsManager.FindProperty("m_DefaultRenderingPath");
        defaultRenderingPath.intValue = 1;

        SerializedProperty defaultMobileRenderingPath = graphicsManager.FindProperty("m_DefaultMobileRenderingPath");
        defaultMobileRenderingPath.intValue = 1;

        SerializedProperty tierSettings = graphicsManager.FindProperty("m_TierSettings");
        tierSettings.ClearArray();
        tierSettings.arraySize = 0;

#if ENV_SET_LIGHTMAP
        SerializedProperty lightmapStripping = graphicsManager.FindProperty("m_LightmapStripping");
        lightmapStripping.enumValueIndex = 1;

        SerializedProperty instancingStripping = graphicsManager.FindProperty("m_InstancingStripping");
        instancingStripping.enumValueIndex = 2;

        SerializedProperty lightmapKeepPlain = graphicsManager.FindProperty("m_LightmapKeepPlain");
        lightmapKeepPlain.boolValue = true;

        SerializedProperty lightmapKeepDirCombined = graphicsManager.FindProperty("m_LightmapKeepDirCombined");
        lightmapKeepDirCombined.boolValue = true;

        SerializedProperty lightmapKeepDynamicPlain = graphicsManager.FindProperty("m_LightmapKeepDynamicPlain");
        lightmapKeepDynamicPlain.boolValue = true;

        SerializedProperty lightmapKeepDynamicDirCombined = graphicsManager.FindProperty("m_LightmapKeepDynamicDirCombined");
        lightmapKeepDynamicDirCombined.boolValue = true;

        SerializedProperty lightmapKeepShadowMask = graphicsManager.FindProperty("m_LightmapKeepShadowMask");
        lightmapKeepShadowMask.boolValue = true;

        SerializedProperty lightmapKeepSubtractive = graphicsManager.FindProperty("m_LightmapKeepSubtractive");
        lightmapKeepSubtractive.boolValue = true;
#endif

        SerializedProperty albedoSwatchInfos = graphicsManager.FindProperty("m_AlbedoSwatchInfos");
        albedoSwatchInfos.ClearArray();
        albedoSwatchInfos.arraySize = 0;

        SerializedProperty lightsUseLinearIntensity = graphicsManager.FindProperty("m_LightsUseLinearIntensity");
        lightsUseLinearIntensity.boolValue = true;

        SerializedProperty lightsUseColorTemperature = graphicsManager.FindProperty("m_LightsUseColorTemperature");
        lightsUseColorTemperature.boolValue = true;

        graphicsManager.ApplyModifiedProperties();
    }
Exemplo n.º 6
0
        /// <summary>
        ///     Setup the "Samples" sub-menu with contents of samples directory.
        /// </summary>
        private void LoadSamplesMenu()
        {
            var samplesDirectory = dynamoViewModel.Model.PathManager.SamplesDirectory;
            if (Directory.Exists(samplesDirectory))
            {
                var sampleFiles = new System.Collections.Generic.List<string>();
                string[] dirPaths = Directory.GetDirectories(samplesDirectory);
                string[] filePaths = Directory.GetFiles(samplesDirectory, "*.dyn");

                // handle top-level files
                if (filePaths.Any())
                {
                    foreach (string path in filePaths)
                    {
                        var item = new MenuItem
                        {
                            Header = Path.GetFileNameWithoutExtension(path),
                            Tag = path
                        };
                        item.Click += OpenSample_Click;
                        SamplesMenu.Items.Add(item);
                        sampleFiles.Add(path);
                    }
                }

                // handle top-level dirs, TODO - factor out to a seperate function, make recusive
                if (dirPaths.Any())
                {
                    foreach (string dirPath in dirPaths)
                    {
                        var dirItem = new MenuItem
                        {
                            Header = Path.GetFileName(dirPath),
                            Tag = Path.GetFileName(dirPath)
                        };

                        filePaths = Directory.GetFiles(dirPath, "*.dyn");
                        if (filePaths.Any())
                        {
                            foreach (string path in filePaths)
                            {
                                var item = new MenuItem
                                {
                                    Header = Path.GetFileNameWithoutExtension(path),
                                    Tag = path
                                };
                                item.Click += OpenSample_Click;
                                dirItem.Items.Add(item);
                                sampleFiles.Add(path);
                            }
                        }
                        SamplesMenu.Items.Add(dirItem);
                    }
                }

                if (dirPaths.Any())
                {
                    var showInFolder = new MenuItem
                    {
                        Header = Wpf.Properties.Resources.DynamoViewHelpMenuShowInFolder,
                        Tag = dirPaths[0]
                    };
                    showInFolder.Click += OnShowInFolder;
                    SamplesMenu.Items.Add(new Separator());
                    SamplesMenu.Items.Add(showInFolder);
                }

                if (sampleFiles.Any() && startPage != null)
                {
                    var firstFilePath = Path.GetDirectoryName(sampleFiles.ToArray()[0]);
                    var rootPath = Path.GetDirectoryName(firstFilePath);
                    var root = new DirectoryInfo(rootPath);
                    var rootProperty = new SampleFileEntry("Samples", "Path");
                    startPage.WalkDirectoryTree(root, rootProperty);
                    startPage.SampleFiles.Add(rootProperty);
                }
            }
        }
        public void GenerarReporte()
        {
            try
            {
                if (SelectedFechaInicial == null)
                {
                    return;
                }

                if (SelectedFechaFinal == null)
                {
                    return;
                }

                var encabezado           = new System.Collections.Generic.List <cEncabezado>();
                var listaIngresosActivos = new System.Collections.Generic.List <cReporteIngresosActivosCierre>();
                var centro = new SSP.Controlador.Catalogo.Justicia.cCentro().Obtener(GlobalVar.gCentro).FirstOrDefault();
                encabezado.Add(new cEncabezado()
                {
                    ImagenDerecha = Parametro.LOGO_ESTADO_BC,
                    TituloUno     = Parametro.ENCABEZADO1,
                    TituloDos     = Parametro.ENCABEZADO2,
                    NombreReporte = centro != null ? !string.IsNullOrEmpty(centro.DESCR) ? centro.DESCR.Trim() : string.Empty : string.Empty,
                    PieUno        = string.Format("Reporte de Población Activa al Cierre \n Del {0} Al {1}",
                                                  SelectedFechaInicial.HasValue ? SelectedFechaInicial.Value.ToString("dd/MM/yyyy") : string.Empty,
                                                  SelectedFechaFinal.HasValue ? SelectedFechaFinal.Value.ToString("dd/MM/yyyy") : string.Empty)
                });

                var _IngresosActivos = new SSP.Controlador.Catalogo.Justicia.cIngreso().ObtenerIngresosActivosPorFecha(GlobalVar.gCentro, SelectedFechaInicial, SelectedFechaFinal);
                int alf = _IngresosActivos.Count(x => x.IMPUTADO.NACIMIENTO_PAIS != null);
                if (_IngresosActivos.Any())
                {
                    int _NoUbicados        = new int();
                    int _HombresNoUbicados = new int();
                    int _MujeresNoUbicadas = new int();
                    var _Agrupados         = _IngresosActivos.GroupBy(x => x.IMPUTADO.NACIMIENTO_PAIS);
                    if (_Agrupados.Any())
                    {
                        foreach (var item in _Agrupados)
                        {
                            var _NombrePais = new SSP.Controlador.Catalogo.Justicia.cPaises().GetData(x => x.ID_PAIS_NAC == item.Key).FirstOrDefault();
                            if (_NombrePais == null)
                            {
                                _NoUbicados        = _NoUbicados + item.Count();
                                _HombresNoUbicados = _HombresNoUbicados + (item.Any() ? item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "M") : 0);
                                _MujeresNoUbicadas = _MujeresNoUbicadas + (item.Any() ? item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "F") : 0);
                                continue;
                            }
                            else
                            if (string.IsNullOrEmpty(_NombrePais.PAIS))
                            {
                                _NoUbicados        = _NoUbicados + item.Count();
                                _HombresNoUbicados = _HombresNoUbicados + (item.Any() ? item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "M") : 0);
                                _MujeresNoUbicadas = _MujeresNoUbicadas + (item.Any() ? item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "F") : 0);
                                continue;
                            }
                            else
                            {
                                listaIngresosActivos.Add(new cReporteIngresosActivosCierre
                                {
                                    TotalM     = item.Any() ? item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "F") : 0,
                                    TotalH     = item.Any() ? item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "M") : 0,
                                    NombrePais = _NombrePais != null ? !string.IsNullOrEmpty(_NombrePais.PAIS) ? _NombrePais.PAIS.Trim() : "SIN CAPTURAR" : "SIN CAPTURAR",
                                    GrandTotal = item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "M") + item.Count(x => x.IMPUTADO != null && x.IMPUTADO.SEXO == "F")
                                });
                            }
                        }
                        ;

                        //Ya tengo el condensado de las personas que no tienen pais
                        listaIngresosActivos.Add(new cReporteIngresosActivosCierre
                        {
                            NombrePais = "SIN CAPTURAR",
                            TotalH     = _HombresNoUbicados,
                            TotalM     = _MujeresNoUbicadas,
                            GrandTotal = _HombresNoUbicados + _MujeresNoUbicadas
                        });
                    }
                }
                ;

                Reporte.LocalReport.ReportPath = "Reportes/rReporteIngresosActivosCierre.rdlc";
                Reporte.LocalReport.DataSources.Clear();

                Microsoft.Reporting.WinForms.ReportDataSource ReportDataSource_Encabezado = new Microsoft.Reporting.WinForms.ReportDataSource();
                ReportDataSource_Encabezado.Name  = "DataSet1";
                ReportDataSource_Encabezado.Value = encabezado;

                Microsoft.Reporting.WinForms.ReportDataSource ReportDataSource_Motivos = new Microsoft.Reporting.WinForms.ReportDataSource();
                ReportDataSource_Motivos.Name  = "DataSet2";
                ReportDataSource_Motivos.Value = listaIngresosActivos != null?listaIngresosActivos.Any() ? listaIngresosActivos.OrderBy(x => x.NombrePais).ToList() : new List <cReporteIngresosActivosCierre>() : new List <cReporteIngresosActivosCierre>();

                Reporte.LocalReport.DataSources.Add(ReportDataSource_Encabezado);
                Reporte.LocalReport.DataSources.Add(ReportDataSource_Motivos);

                System.Windows.Application.Current.Dispatcher.Invoke((System.Action)(delegate
                {
                    Reporte.Refresh();
                    Reporte.RefreshReport();
                }));
            }

            catch (System.Exception exc)
            {
                throw;
            }
        }
        public override bool IsValid(object value)
        {
            if (value == null)
            {
                return(true);
            }
            if (!(value is ContentArea))
            {
                throw new ValidationException("AvailableContentTypesAttribute is intended only for use with ContentArea properties");
            }
            ContentArea contentArea = value as ContentArea;

            System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
            if (contentArea != null)
            {
                if (IncludeFrom != null)
                {
                    var includedTypes = ((AvailableContentTypesAttribute)Attribute
                                         .GetCustomAttribute(IncludeFrom, typeof(AvailableContentTypesAttribute)))
                                        .IfNotNull(x => x.Include);

                    if (includedTypes != null)
                    {
                        Include = Include != null?Include.Union(includedTypes).ToArray() : includedTypes;
                    }
                }
                if (this.Include != null)
                {
                    System.Collections.Generic.IEnumerable <IContent> source =
                        from x in contentArea.Contents
                        where !this.ContainsType(this.Include, x.GetType())
                        select x;
                    if (source.Any <IContent>())
                    {
                        list.AddRange(
                            from x in source
                            select string.Format("[{2}] {0} ({1})", x.Name, x.ContentLink.ID, GetFriendlyBlockTypeName(x)));
                    }
                }
                if (this.Exclude != null)
                {
                    System.Collections.Generic.IEnumerable <IContent> source =
                        from x in contentArea.Contents
                        where this.ContainsType(this.Exclude, x.GetType())
                        select x;
                    if (source.Any <IContent>())
                    {
                        list.AddRange(
                            from x in source
                            select string.Format("[{2}] {0} ({1})", x.Name, x.ContentLink.ID, GetFriendlyBlockTypeName(x)));
                    }
                }
            }
            bool result;

            if (list.Any <string>())
            {
                base.ErrorMessage = "contains invalid content items: ";
                foreach (string current in list)
                {
                    base.ErrorMessage = base.ErrorMessage + " " + current + ", ";
                }
                base.ErrorMessage = base.ErrorMessage.TrimEnd(new char[]
                {
                    ',', ' '
                });
                ErrorMessage += ". Supported block types: " + string.Join(", ", Include.Select(type => GetFriendlyName(type.Name))) + ".";
                result        = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
Exemplo n.º 9
0
        public NewEntryBox BindData(string quart)
        {
            var list = (from Quart in DB.Quarter
                        where Quart.Quarter == quart
                        select new
            {
                Quart.Month
            }).ToList();

            string currentQuarter = GetQuarter();

            string currentmonth = quart == currentQuarter?DateTime.Now.Month.ToString("d2") : quart == "Q4" ? "10" : quart == "Q3" ? "07" : quart == "Q2" ? "04" : "01";

            string month1 = quart != currentQuarter && quart == "Q4" ? DateTime.Now.AddYears(-1).ToString("yyyy/" + list[0].Month + "/01") : DateTime.Now.ToString("yyyy/" + list[0].Month + "/01");
            string month2 = quart != currentQuarter && quart == "Q4" ? DateTime.Now.AddYears(-1).ToString("yyyy/" + list[1].Month + "/01") : DateTime.Now.ToString("yyyy/" + list[1].Month + "/01");
            string month3 = quart != currentQuarter && quart == "Q4" ? DateTime.Now.AddYears(-1).ToString("yyyy/" + list[2].Month + "/01") : DateTime.Now.ToString("yyyy/" + list[2].Month + "/01");

            if (currentmonth == list[0].Month)
            {
                TempData["CheckMonth"] = 1;
            }
            else if (currentmonth == list[1].Month)
            {
                TempData["CheckMonth"] = 2;
            }
            else if (currentmonth == list[2].Month)
            {
                TempData["CheckMonth"] = 3;
            }
            long empid = (long)Session[Constants.SessionEmpID];

            System.Collections.Generic.List <BoxItems> GetDetails = DB.Database.SqlQuery <BoxItems>(
                @"exec " + Constants.P_GetNewEntryDefault_Test + " @EmpID,@Month1,@Month2,@Month3",
                new object[] {
                new SqlParameter("@EmpID", empid),
                new SqlParameter("@Month1", month1),
                new SqlParameter("@Month2", month2),
                new SqlParameter("@Month3", month3)
            }).ToList();


            int year = (quart == "Q4" && currentQuarter != "Q4") ? DateTime.Now.AddYears(-1).Year : DateTime.Now.Year;

            NewEntryBox model = new NewEntryBox
            {
                CheckMonth = TempData["CheckMonth"].ToString(),
                Month1     = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(Convert.ToInt32(list[0].Month)) + " " + year,
                Month2     = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(Convert.ToInt32(list[1].Month)) + " " + year,
                Month3     = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(Convert.ToInt32(list[2].Month)) + " " + year
            };

            foreach (BoxItems item in GetDetails)
            {
                item.InvolvementEditDays1 = item.InvolvementEditDays1 == 0 && item.InvolvementDays1 != 0 && item.IsEdit1 ? item.InvolvementDays1 : item.InvolvementEditDays1;
                item.InvolvementEditDays2 = item.InvolvementEditDays2 == 0 && item.InvolvementDays2 != 0 && item.IsEdit2 ? item.InvolvementDays2 : item.InvolvementEditDays2;
                item.InvolvementEditDays3 = item.InvolvementEditDays3 == 0 && item.InvolvementDays3 != 0 && item.IsEdit3 ? item.InvolvementDays3 : item.InvolvementEditDays3;
            }

            DateTime origDT1   = Convert.ToDateTime(month1);
            DateTime lastDate1 = new DateTime(origDT1.Year, origDT1.Month, 1).AddMonths(1).AddDays(-1);
            DateTime origDT2   = Convert.ToDateTime(month2);
            DateTime lastDate2 = new DateTime(origDT2.Year, origDT2.Month, 1).AddMonths(1).AddDays(-1);
            DateTime origDT3   = Convert.ToDateTime(month3);
            DateTime lastDate3 = new DateTime(origDT3.Year, origDT3.Month, 1).AddMonths(1).AddDays(-1);

            foreach (BoxItems item in GetDetails.Where(x => x.TsID != "Total"))
            {
                model.TotalDaysEditCount1    = model.TotalDaysEditCount1 + item.InvolvementEditDays1;
                model.TotalDaysEditCount2    = model.TotalDaysEditCount2 + item.InvolvementEditDays2;
                model.TotalDaysEditCount3    = model.TotalDaysEditCount3 + item.InvolvementEditDays3;
                item.OldInvolvementEditDays1 = item.InvolvementEditDays1;
                item.OldInvolvementEditDays2 = item.InvolvementEditDays2;
                item.OldInvolvementEditDays3 = item.InvolvementEditDays3;
                if (!model.ShowWarning)
                {
                    if (Models.Common.CheckDateRange(item.StartDate.Value, Convert.ToDateTime(month1), lastDate3))
                    {
                        if (!Models.Common.CheckIfNotMonthDateDate(Convert.ToDateTime(month1), Convert.ToDateTime(month2), Convert.ToDateTime(month3), item.StartDate.Value) || (item.EndDate <= lastDate3 && !Models.Common.CheckIfNotMonthDateDate(lastDate1, lastDate2, lastDate3, item.EndDate.Value)))
                        {
                            model.ShowWarning = true;
                        }
                    }
                    else if (Models.Common.CheckDateRange(item.EndDate.Value, Convert.ToDateTime(month1), lastDate3))
                    {
                        if ((item.StartDate.Value >= Convert.ToDateTime(month1) && !Models.Common.CheckIfNotMonthDateDate(Convert.ToDateTime(month1), Convert.ToDateTime(month2), Convert.ToDateTime(month3), item.StartDate.Value)) || (item.EndDate <= lastDate3 && !Models.Common.CheckIfNotMonthDateDate(lastDate1, lastDate2, lastDate3, item.EndDate.Value)))
                        {
                            model.ShowWarning = true;
                        }
                    }
                }
            }

            DateTime date1 = Convert.ToDateTime(month1);
            DateTime date2 = Convert.ToDateTime(month2);
            DateTime date3 = Convert.ToDateTime(month3);

            WorkDaysModel totalDays1 = DB.Workdays.FirstOrDefault(x => x.EmpID == empid && x.InvolveMonth == date1.Date);
            WorkDaysModel totalDays2 = DB.Workdays.FirstOrDefault(x => x.EmpID == empid && x.InvolveMonth == date2.Date);
            WorkDaysModel totalDays3 = DB.Workdays.FirstOrDefault(x => x.EmpID == empid && x.InvolveMonth == date3.Date);
            long          manDays    = 0;

            if (totalDays1 == null || totalDays2 == null || totalDays3 == null)
            {
                manDays = DB.Settings.Where(x => x.SetCode == "ManDays").First().SetValue;
            }
            if (GetDetails.Any())
            {
                int totalInvolvementPercentage = (from x in DB.Employee
                                                  where x.EmployeeID == empid
                                                  select x.TotalInvolvement ?? 100).FirstOrDefault();

                GetDetails[GetDetails.Count - 1].InvolvementEditDays1 = model.TotalDaysEditCount1;
                GetDetails[GetDetails.Count - 1].InvolvementEditDays2 = model.TotalDaysEditCount2;
                GetDetails[GetDetails.Count - 1].InvolvementEditDays3 = model.TotalDaysEditCount3;

                GetDetails[GetDetails.Count - 1].InvolvementDays1 = totalInvolvementPercentage * (totalDays1 != null ? totalDays1.DaysCount : manDays) / 100;
                GetDetails[GetDetails.Count - 1].InvolvementDays2 = totalInvolvementPercentage * (totalDays2 != null ? totalDays2.DaysCount : manDays) / 100;
                GetDetails[GetDetails.Count - 1].InvolvementDays3 = totalInvolvementPercentage * (totalDays3 != null ? totalDays3.DaysCount : manDays) / 100;
            }

            model.Count1 = model.TotalDaysEditCount1 == 0 && model.TotalDaysCount1 == 0 && date1 <= DateTime.Now ? totalDays1 != null ? totalDays1.DaysCount : manDays : model.TotalDaysEditCount1;
            model.Count2 = model.TotalDaysEditCount2 == 0 && model.TotalDaysCount2 == 0 && date2 <= DateTime.Now ? totalDays2 != null ? totalDays2.DaysCount : manDays : model.TotalDaysEditCount2;
            model.Count3 = model.TotalDaysEditCount3 == 0 && model.TotalDaysCount3 == 0 && date3 <= DateTime.Now ? totalDays3 != null ? totalDays3.DaysCount : manDays : model.TotalDaysEditCount3;

            model.QID = quart;

            model.CurrentYear = (quart == "Q4" && currentQuarter != "Q4") ? DateTime.Now.AddYears(-1).Year : DateTime.Now.Year;
            model.Items       = GetDetails;
            foreach (BoxItems item in model.Items.Where(x => x.ProjectID == 0))
            {
                item.IsEdit1 = false;
                item.IsEdit2 = false;
                item.IsEdit3 = false;
            }

            ViewBag.IsEditable = model.Items.Any(x => (x.IsEdit1 || x.IsEdit2 || x.IsEdit3) && x.ProjectID != 0);
            return(model);
        }
Exemplo n.º 10
0
        protected override void FixInternal()
        {
            if (!Movie.AutomaticFolderRoot.HasValue())
            {
                throw new FixCheckException("Movie has no automatic folder root");
            }
            if (Movie.ManualLocations.Count > 1)
            {
                throw new FixCheckException("Movie has multiple manual locations - unclear which to copy across");
            }
            if (Movie.ManualLocations.Count == 0)
            {
                //no files to copy
                Movie.UseAutomaticFolders = true;
                Movie.UseManualLocations  = false;
                return;
            }

            if (Movie.ManualLocations.Count == 1)
            {
                DirectoryInfo source = new DirectoryInfo(Movie.ManualLocations.First());
                if (!source.Exists)
                {
                    Movie.UseManualLocations  = false;
                    Movie.UseAutomaticFolders = true;
                    return;
                }

                if (!source.EnumerateFiles().Any() && !source.EnumerateDirectories().Any())
                {
                    //directory has nothing in it
                    FileHelper.RemoveDirectory(source.FullName);
                    Movie.UseManualLocations  = false;
                    Movie.UseAutomaticFolders = true;
                    return;
                }

                Movie.UseAutomaticFolders = true;
                //try to copy/move files
                System.Collections.Generic.List <string> automaticLocations = Movie.AutomaticLocations().ToList();

                if (automaticLocations.Count > 1)
                {
                    throw new FixCheckException("Multiple target locations for the automated folders");
                }

                if (!automaticLocations.Any())
                {
                    throw new FixCheckException("No target automatic folders can be established");
                }

                if (source.FullName.Equals(automaticLocations.First(), StringComparison.CurrentCultureIgnoreCase))
                {
                    Movie.UseManualLocations = false;
                    return;
                }

                //Do we want to copy the whole folder or just some files from witin?
                //we have one location to copy to

                bool manualLocationOnlyHasOneMovie = source.EnumerateFiles().Where(f => f.IsMovieFile()).All(file => Movie.NameMatch(file, false));

                if (manualLocationOnlyHasOneMovie)
                {
                    CopyOrMove(source, automaticLocations.First());
                }
                else
                {
                    MoveFiles(source.EnumerateFiles().Where(f => f.IsMovieFile()).Where(file => Movie.NameMatch(file, false)), automaticLocations.First());
                }

                Movie.UseManualLocations = false;
            }
        }
Exemplo n.º 11
0
    protected void ImportResource(DataTable dtExcelInfo, System.Collections.Generic.Dictionary <string, int> dicRes)
    {
        System.Collections.Generic.List <string> priceTypeCodes = ResPriceType.GetPriceTypeCodes();
        string text = PageHelper.QueryUser(this, base.UserCode);
        int    num  = 0;

        for (int i = 0; i < dtExcelInfo.Rows.Count; i++)
        {
            DataRow dataRow = dtExcelInfo.Rows[i];
            string  text2   = dataRow[dicRes["ResourceCode"]].ToString();
            bool    flag    = this.IsExistResourceCode(text2);
            if (flag)
            {
                Label  expr_57 = this.lblErrorMsg;
                string text3   = expr_57.Text;
                expr_57.Text = string.Concat(new string[]
                {
                    text3,
                    "<div align='left' style=' margin-top:3px; padding-left:15px;  border-bottom-style:solid; border-bottom-color:#cccccc; border-bottom-width:1px;  background-color:white; line-height:28px; height:28px; text-align:left;'>在您的Excel中:",
                    dtExcelInfo.Columns[dicRes["ResourceCode"]].ColumnName,
                    "<span style='color:green;'>",
                    text2,
                    "</span>,此编码已经存在导入失败!</div>"
                });
            }
            else
            {
                string text4 = dtExcelInfo.Rows[i][dicRes["ResourceName"]].ToString();
                if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text4))
                {
                    string  brand   = dicRes.Keys.Any((string a) => a == "Brand") ? dataRow[dicRes["Brand"]].ToString() : string.Empty;
                    string  text5   = dicRes.Keys.Any((string a) => a == "TaxRate") ? dataRow[dicRes["TaxRate"]].ToString() : string.Empty;
                    decimal?taxRate = null;
                    decimal value;
                    if (!string.IsNullOrEmpty(text5) && decimal.TryParse(text5, out value))
                    {
                        taxRate = new decimal?(value);
                    }
                    string specification  = dicRes.Keys.Any((string a) => a == "Specification") ? dataRow[dicRes["Specification"]].ToString() : string.Empty;
                    string technicalParam = dicRes.Keys.Any((string a) => a == "TechnicalParameter") ? dataRow[dicRes["TechnicalParameter"]].ToString() : string.Empty;
                    string text6          = dicRes.Keys.Any((string a) => a == "Unit") ? dataRow[dicRes["Unit"]].ToString() : string.Empty;
                    if (string.IsNullOrEmpty(text6))
                    {
                        text6 = "xx";
                    }
                    string attributeName    = dicRes.Keys.Any((string a) => a == "Attribute") ? dataRow[dicRes["Attribute"]].ToString() : string.Empty;
                    string series           = dicRes.Keys.Any((string a) => a == "Series") ? dataRow[dicRes["Series"]].ToString() : string.Empty;
                    string supplierName     = dicRes.Keys.Any((string a) => a == "SupplierId") ? dataRow[dicRes["SupplierId"]].ToString() : string.Empty;
                    int?   supplierIdByName = cn.justwin.Domain.Resource.GetSupplierIdByName(supplierName);
                    string modelNumber      = dicRes.Keys.Any((string a) => a == "ModelNumber") ? dataRow[dicRes["ModelNumber"]].ToString() : string.Empty;
                    if (!dicRes.Keys.Any((string a) => a == "Note"))
                    {
                        string arg_400_0 = string.Empty;
                    }
                    else
                    {
                        dataRow[dicRes["Note"]].ToString();
                    }
                    System.Collections.Generic.Dictionary <ResPriceType, decimal?> dictionary = new System.Collections.Generic.Dictionary <ResPriceType, decimal?>();
                    foreach (string key in dicRes.Keys)
                    {
                        bool flag2 = priceTypeCodes.Any((string a) => a == key);
                        if (flag2)
                        {
                            string  s = dataRow[dicRes[key]].ToString();
                            decimal value2;
                            decimal.TryParse(s, out value2);
                            dictionary.Add(ResPriceType.GetByTypeCode(key), new decimal?(value2));
                        }
                    }
                    ResType                    byId            = ResType.GetById(base.Request["parentId"]);
                    ResUnit                    unit            = this.GetUnit(text6, text);
                    ResTypeAttribute           byAttributeName = ResTypeAttribute.GetByAttributeName(attributeName);
                    cn.justwin.Domain.Resource resource        = cn.justwin.Domain.Resource.Create(System.Guid.NewGuid().ToString(), byId, text2, text4, brand, taxRate, specification, modelNumber, technicalParam, unit, byAttributeName, series, dictionary, text, new System.DateTime?(System.DateTime.Now), supplierIdByName);
                    cn.justwin.Domain.Resource.Add(resource);
                    num++;
                }
            }
        }
        if (num == 0)
        {
            base.RegisterScript("alert('系统提示:\\n数据导入失败!');setTem('2');");
            return;
        }
        if (num == dtExcelInfo.Rows.Count)
        {
            base.RegisterScript("alert('系统提示:\\n数据导入成功!');setTem('2');closePage();");
            return;
        }
        base.RegisterScript("alert('系统提示:\\n数据导入成功!');setTem('2');");
    }
Exemplo n.º 12
0
        public void checkAndHighlightSelectedTile(Vector2 worldPosition, Texture2D selectedTexture, string selectedTexturePath)
        {
            System.Collections.Generic.List <TileObject> copyOfBarriersList = new System.Collections.Generic.List <TileObject>(barriersList);
            foreach (TileObject rect in copyOfBarriersList)
            {
                bool isHit = false;
                if (gridMapType == GridMapType.Default)
                {
                    isHit = rect.Rectangle.Contains(worldPosition);
                }
                if (gridMapType == GridMapType.Isometric)
                {
                    isHit = rect.Rectangle.Contains(worldPosition);
                }
                if (isHit)
                {
                    if (game.currentLayerDepthLevel == rect.layerDepth)
                    {
                        //spriteBatch.Begin(SpriteSortMode.BackToFront,BlendState.AlphaBlend,null,null,null,null,camera.get_transformation(graphics.GraphicsDevice));
                        //   spriteBatch.Begin();
                        // System.Console.WriteLine("Hit rect at {0} {1}",mouseState.X,mouseState.Y);
                        Texture2D texture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                        texture.SetData <Color>(new Color[] { Color.White });


                        rect.layerDepth  = game.currentLayerDepthLevel;
                        rect.texture     = selectedTexture;
                        rect.texturePath = selectedTexturePath;
                        rect.isGreen     = true;



                        if (gridMapType == GridMapType.Default)
                        {
                            spriteBatch.Draw(texture, rect.Rectangle, Color.Green);
                        }
                        if (gridMapType == GridMapType.Isometric)
                        {
                            spriteBatch.Draw(texture, rect.Rectangle, null, Color.Green, 0, Vector2.Zero, SpriteEffects.None, rect.layerDepth);
                        }
                    }
                    else
                    {
                        TileObject newTile = new TileObject(rect);

                        Texture2D texture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                        texture.SetData <Color>(new Color[] { Color.White });


                        newTile.layerDepth  = game.currentLayerDepthLevel;
                        newTile.texture     = selectedTexture;
                        newTile.texturePath = selectedTexturePath;
                        newTile.isGreen     = true;
                        if (!barriersList.Any(n => n.Rectangle == newTile.Rectangle && n.layerDepth == newTile.layerDepth && n.texturePath == newTile.texturePath && n.texture == newTile.texture))
                        {
                            barriersList.Add(newTile);
                        }
                    }
                    //    spriteBatch.End();
                }
            }
        }
Exemplo n.º 13
0
            private static Zatrideni.Item[] GetSubjektyDirect(StatniOrganizaceObor obor)
            {
                string[] icos = null;
                string   sql  = "";

                switch (obor)
                {
                case StatniOrganizaceObor.Vse:
                    icos = GetAllSubjektyFromRPP();
                    break;

                case StatniOrganizaceObor.Zdravotni_ustavy:
                case StatniOrganizaceObor.Hasicsky_zachranny_sbor:
                case StatniOrganizaceObor.Krajske_hygienicke_stanice:
                case StatniOrganizaceObor.Krajska_statni_zastupitelstvi:
                case StatniOrganizaceObor.Krajske_soudy:
                case StatniOrganizaceObor.Soudy:
                case StatniOrganizaceObor.Statutarni_mesta:
                case StatniOrganizaceObor.Verejne_vysoke_skoly:
                case StatniOrganizaceObor.Krajska_reditelstvi_policie:
                case StatniOrganizaceObor.Statni_fondy:
                case StatniOrganizaceObor.OSSZ:
                case StatniOrganizaceObor.Kraje_Praha:
                case StatniOrganizaceObor.Zdravotni_pojistovny:
                case StatniOrganizaceObor.Katastralni_urady:
                case StatniOrganizaceObor.Ministerstva:
                case StatniOrganizaceObor.Organizacni_slozky_statu:
                case StatniOrganizaceObor.Dalsi_ustredni_organy_statni_spravy:
                case StatniOrganizaceObor.Celni_urady:
                case StatniOrganizaceObor.Financni_urady:
                case StatniOrganizaceObor.Konzervatore:
                case StatniOrganizaceObor.Mestske_casti_Prahy:
                case StatniOrganizaceObor.OVM_pro_evidenci_skutecnych_majitelu:
                case StatniOrganizaceObor.Obce_III_stupne:
                    icos = GetSubjektyFromRPP((int)obor);
                    break;

                case StatniOrganizaceObor.Vsechny_ustredni_organy_statni_spravy:
                    icos = GetSubjektyFromRPP((int)StatniOrganizaceObor.Dalsi_ustredni_organy_statni_spravy)
                           .Concat(GetSubjektyFromRPP((int)StatniOrganizaceObor.Ministerstva))
                           .ToArray();
                    break;

                case StatniOrganizaceObor.Nemocnice:
                    sql  = @"select distinct ico from (
select f.ICO from Firma f where Jmeno like N'%nemocnice%' and f.IsInRS = 1
union
select distinct f.ico
    from Firma_NACE fn
    join firma f on f.ICO = fn.ICO
    where (nace like '861%' or NACE like '862%') and f.IsInRS = 1
    and f.Kod_PF not in (105, 101, 801, 601)
								
) as f
where f.ICO not in ('70876606','70994226','45274649','05243793','64203450','25916092','60800691','08297517','00212423')";
                    icos = GetSubjektyFromSQL(sql);
                    break;

                case StatniOrganizaceObor.Velke_nemocnice:
                    icos = "00064165,00064173,00064203,00098892,00159816,00179906,00669806,00843989,25488627,26365804,27283933,27661989,65269705,27283518,26000202,00023736,00023884,27256391,61383082,27256537,00023001,27520536,26068877,47813750,00064211,00209805,27660915,00635162,27256456,00090638,00092584,00064190"
                           .Split(',');
                    break;

                case StatniOrganizaceObor.Fakultni_nemocnice:
                    icos = "65269705,00179906,00669806,00098892,00843989,00064165,00064203,00159816,00064173"
                           .Split(',');
                    break;

                case StatniOrganizaceObor.Krajske_spravy_silnic:
                    icos = "00066001,00090450,70947023,70946078,72053119,00080837,70971641,27502988,00085031,70932581,70960399,00095711,26913453,03447286,25396544,60733098"
                           .Split(',');
                    break;

                case StatniOrganizaceObor.Dopravni_podniky:
                    icos = "05792291,25095251,25136046,25137280,00005886,25166115,25164538,25220683,29099846,61058238,48364282,62240935,64053466,06231292,62242504,25013891,47311975,00079642,06873031,25267213,63217066,25512897,25508881,00100790,47676639,05724252,64610250,61974757,60730153"
                           .Split(',');
                    break;

                case StatniOrganizaceObor.Technicke_sluzby:
                    sql  = @"select ico from Firma f where Jmeno like N'technické služby%' and f.IsInRS = 1";
                    icos = GetSubjektyFromSQL(sql);
                    break;

                case StatniOrganizaceObor.Domov_duchodcu:
                    sql  = @"select ico from Firma f where Jmeno like N'%domov důchodců%' and f.IsInRs = 1";
                    icos = GetSubjektyFromSQL(sql);
                    break;

                case StatniOrganizaceObor.Vyjimky_RS:

                    // Poslanecká sněmovna, Senát, Kancelář prezidenta republiky, Ústavní soud, Nejvyšší kontrolní úřad,
                    //Kancelář veřejného ochránce práv a Úřad Národní rozpočtové rady
                    //CNB
                    icos = new string[] { "00006572", "63839407", "48136000", "48513687", "49370227", "70836981", "05553539", "48136450" };
                    break;

                case StatniOrganizaceObor.Ostatni:
                    icos = new string[] { };
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                bool removeKraj = false;

                switch (obor)
                {
                case StatniOrganizaceObor.Ostatni:
                case StatniOrganizaceObor.Zdravotni_pojistovny:
                case StatniOrganizaceObor.Fakultni_nemocnice:
                case StatniOrganizaceObor.Krajska_statni_zastupitelstvi:
                case StatniOrganizaceObor.Krajske_soudy:
                case StatniOrganizaceObor.Kraje_Praha:
                case StatniOrganizaceObor.Mestske_casti_Prahy:
                case StatniOrganizaceObor.OSSZ:
                case StatniOrganizaceObor.Ministerstva:
                case StatniOrganizaceObor.Organizacni_slozky_statu:
                case StatniOrganizaceObor.Vsechny_ustredni_organy_statni_spravy:
                case StatniOrganizaceObor.Dalsi_ustredni_organy_statni_spravy:
                case StatniOrganizaceObor.Financni_urady:
                case StatniOrganizaceObor.Vyjimky_RS:
                case StatniOrganizaceObor.Verejne_vysoke_skoly:
                case StatniOrganizaceObor.Konzervatore:
                case StatniOrganizaceObor.Krajske_spravy_silnic:
                case StatniOrganizaceObor.OVM_pro_evidenci_skutecnych_majitelu:
                    removeKraj = true;
                    break;

                default:
                    break;
                }

                if (icos.Count() == 0)
                {
                    return new Item[] { }
                }
                ;
                else
                {
                    var ret = new System.Collections.Generic.List <Item>();

                    Devmasters.Batch.Manager.DoActionForAll <string>(icos.Select(m => m.Trim()).Distinct(),
                                                                     ic =>
                    {
                        var f = Firmy.Get(ic);

                        if (f.PatrimStatu())
                        {
                            lock (_getSubjektyDirectLock)
                            {
                                if (!ret.Any(ff => ff.Ico == f.ICO))
                                {
                                    ret.Add(new Item()
                                    {
                                        Ico    = f.ICO,
                                        Jmeno  = f.Jmeno,
                                        KrajId = removeKraj ? "" : f.KrajId,
                                        Kraj   = removeKraj ? "" : CZ_Nuts.Nace2Kraj(f.KrajId, "(neznamý)")
                                    });
                                }
                            }
                        }
                        return(new Devmasters.Batch.ActionOutputData());
                    }, !System.Diagnostics.Debugger.IsAttached);

                    return(ret.ToArray());
                }
            }
Exemplo n.º 14
0
        public void GetImages()
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog()
            {
                RootFolder = System.Environment.SpecialFolder.Desktop
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var ext = new System.Collections.Generic.List <string> {
                    ".jpg", ".bmp", ".png"
                };
                var myImagesFiles = Directory.GetFiles(dialog.SelectedPath, "*.*", SearchOption.AllDirectories).Where(s => ext.Any(e => s.EndsWith(e)));
                foreach (var file in myImagesFiles)
                {
                    using (var image = new FormsImage(file))
                    {
                        red.Database.AddImage(image, Path.GetFileName(file));
                    }
                }
            }
        }
Exemplo n.º 15
0
        public void SettingTools()
        {
            bool local = true; //changes this to false if you want to connect to a runtime service
                               //remote capabilities are only available with advanced licenses
            string remoteServerAddress = "http://*****:*****@"C:\Users\jkhong\Pictures\ZZZZ\", "*.*", SearchOption.AllDirectories).Where(s => ext.Any(e => s.EndsWith(e)));

            foreach (var file in myImagesFiles)
            {
                using (var image = new FormsImage(file))
                {
                    stream.Database.AddImage(image, Path.GetFileName(file));
                }
            }

            //---------------BLUE TOOL----------------------

            //modifying the ROI
            IManualRegionOfInterest blueROI = blue.RegionOfInterest as IManualRegionOfInterest; //gets the region of interest

            //changing the angle
            blueROI.Angle = 10.0;

            //processes all images in order to apply the ROI
            blue.Database.Process();
            //waiting fo the end of the processing
            blue.Wait();

            //get the first view in the database
            var firstView = blue.Database.List().First();

            //add some features to the first view in the database
            blue.Database.AddFeature(firstView, "0", new ViDi2.Point(firstView.Size.Width / 2, firstView.Size.Height / 2), 0.0, 1.0);
            blue.Database.AddFeature(firstView, "1", new ViDi2.Point(firstView.Size.Width / 3, firstView.Size.Height / 3), 0.0, 1.0);

            //adding a model to the blue tool
            var model = blue.Models.Add("model1") as INodeModel;
            //adding some nodes in the model
            var node = model.Nodes.Add();

            node.Fielding = new List <string> {
                "1"
            };
            node.Position = new ViDi2.Point(0.0, 0.0);
            node          = model.Nodes.Add();
            node.Fielding = new List <string> {
                "0"
            };
            node.Position = new ViDi2.Point(1.0, 0.0);

            //changing some parameters
            blue.Parameters.FeatureSize = new ViDi2.Size(30, 30);

            //saving the workspace
            workspace.Save();

            //trains and wait for the training to be finished
            blue.Train();

            try
            {
                while (!blue.Wait(1000))
                {
                    System.Console.WriteLine(blue.Progress.Description + " " + blue.Progress.ETA.ToString());
                }
            }
            catch (ViDi2.Exception e)
            {
                /* you'll likely get a "numeric instability detected" exception
                 * that will put you right here. That happens because the resources
                 * that are being used from the "images" folder are probably not
                 * well suited for the specific stream that we have set up.
                 */
                System.Console.WriteLine(e.Message);
                return;
            }

            var blueSummary = blue.Database.Summary();

            //---------------RED TOOL----------------------

            //setting the roi in the red tool. It is a IBlueRegionOfInterest because the red tool is linked to a blue tool
            var redRoi = red.RegionOfInterest as IBlueRegionOfInterest;

            //selecting the model used for the ROI
            redRoi.MatchFilter = "name='" + model.Name + "'";
            //setting the size of the ROI
            redRoi.Size = new ViDi2.Size(100, 100);

            //applying the ROI on all images
            red.Database.Process();

            //waiting for red tool to finish applying ROI
            red.Wait();

            //changing the rotation perturbation parameter
            red.Parameters.Rotation = new System.Collections.Generic.List <Interval>()
            {
                new Interval(0.0, 360.0)
            };

            //labellling images
            red.Database.LabelViews("'bad'", "bad");  //label good images
            red.Database.LabelViews("not 'bad'", ""); // label bad images
            workspace.Save();

            //training the workspace
            red.Train();
            try
            {
                while (!red.Wait(1000))
                {
                    System.Console.WriteLine(red.Progress.Description + " " + red.Progress.ETA.ToString());
                }
            }
            catch (ViDi2.Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
            var redSummary = red.Database.Summary();

            //---------------GREEN TOOL----------------------

            //Applying the ROI to the green tool
            green.Database.Process();
            red.Wait();

            //tagging the images
            green.Database.Tag("'bad'", "b");
            green.Database.Tag("not 'bad'", "g");

            workspace.Save();
            green.Train();
            try
            {
                while (!green.Wait(1000))
                {
                    System.Console.WriteLine(green.Progress.Description + " " + green.Progress.ETA.ToString());
                }
            }
            catch (ViDi2.Exception e)
            {
                System.Console.WriteLine(e.Message);
            }

            var greenSummary = green.Database.Summary();

            //closing the workspaces
            foreach (var w in control.Workspaces)
            {
                w.Close();
            }
            control.Dispose();
        }