private bool doViewReportsWithSubElements(contentManagerService1 cCMS, ref List<CogObject> reports, string cogVersion, string baseReportPath)
        {
            if (cCMS == null)
            {
                reports = null;
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                                propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled};

            // Declare properties to retrieve for package object internal to report object
            refProp packageProps = new refProp();
            packageProps.refPropName = propEnum.metadataModelPackage;
            packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps= new refProp[] { packageProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject reportsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            reportsPath.Value = "/content//report";

            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(reportsPath, reportProps, reportSort, qo);
            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties

                    cognosdotnet_2_0.report report = (cognosdotnet_2_0.report)report_item;
                    CogObject rpt = new CogObject();
                    rpt.ID = report_item.storeID.value.Value;
                    rpt.AddAttribute("ID", rpt.ID);
                    rpt.AddAttribute("Name", report_item.defaultName.value);
                    rpt.AddAttribute("CreationTime", report_item.creationTime.value.ToString());
                    rpt.AddAttribute("Type", "Report");
                    rpt.AddAttribute("Disabled", report.disabled.value.ToString());

                    // Make sure package or model is not null
                    if (report.metadataModelPackage.value!= null)
                    {
                        cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)report.metadataModelPackage.value[0];
                        rpt.AddAttribute("Package_Path", report.metadataModelPackage.value[0].searchPath.value);
                        rpt.AddAttribute("Package_Name", getPackageName(rpt.getAttributeValue("Package_Path")));
                        rpt.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                    }
                    else
                    {
                        rpt.AddAttribute("Package_Path", "null");
                        rpt.AddAttribute("Package_Name", "null");
                        rpt.AddAttribute("Package_Disabled", "null");
                    }
                    // Make sure owner is not null
                    if (report_item.owner.value != null)
                    {
                        getUserAccount(cCMS, report_item.owner.value[0].searchPath.value, ref rpt);
                        rpt.AddAttribute("Author_CAMID", report_item.owner.value[0].searchPath.value);
                    }
                    else
                    {
                        rpt.AddAttribute("Author_CAMID", "Unknown");
                    }
                    String version = cogVersion;
                    rpt.AddAttribute("Version", cogVersion);
                    rpt.AddAttribute("Path", report_item.searchPath.value);
                    rpt.AddAttribute("URL", baseReportPath + report_item.searchPath.value);
                    getSubElements(cCMS, report_item.searchPath.value, ref rpt);
                    /* This gets some limited auditing information. Most of this can be found
                     * more easily in the Raw Usage report of the Business Intelligence Dashboard
                     * package on perform-dev.tyson.com. Uncommenting the following line will
                     * cause a dramatic increase in runtime for this program
                     */
                    //getAuditInfo(ref cog);
                    reports.Add(rpt);
                }
            }
            else
            {
                reports = null;
            }
            return true;
        }
Example #2
0
        static void DoSort(int[] arr, sort methodSort)
        {
            // сортировка неупорядоченного массива
            Console.WriteLine("Несортированный массив: " + String.Join(", ", arr));
            countChange  = 0;                                   // обнуление счетчиков операций
            countCompare = 0;                                   // и времени
            int[] sortArr = methodSort(arr);
            Console.WriteLine("\nОтсортированный неупорядоченный массив: " + String.Join(", ", sortArr));
            Console.WriteLine("Затрачено {0} сравнений, {1} перессылок",
                              countCompare, countChange);

            // сортировка упорядоченного по возрастанию массива
            countChange  = 0;                                   // обнуление счетчиков операций
            countCompare = 0;                                   // и времени
            int[] sortSortedUpArr = methodSort(sortArr);
            Console.WriteLine("\nОтсортированный упорядоченный по возрастанию массив: " + String.Join(", ", sortSortedUpArr));
            Console.WriteLine("Затрачено {0} сравнений, {1} перессылок",
                              countCompare, countChange);

            Array.Reverse(sortArr);
            countChange  = 0;                                   // обнуление счетчиков операций
            countCompare = 0;                                   // и времени
            int[] sortSortedDownArr = methodSort(sortArr);
            Console.WriteLine("\nОтсортированный упорядоченный по убыванию массив: " + String.Join(", ", sortSortedDownArr));
            Console.WriteLine("Затрачено {0} сравнений, {1} перессылок",
                              countCompare, countChange);
        }
Example #3
0
 public static int[] BubleSort(int[] arr, sort a)
 {
     for (int i = 0; i < arr.Length; i++)
     {
         for (int j = 0; j < arr.Length - i - 1; j++)
         {
             if (a == "increace")
             {
                 if (arr[j] > arr[j + 1])
                 {
                     var swap = arr[j];
                     arr[j]     = arr[j + 1];
                     arr[j + 1] = swap;
                 }
             }
             if (a = "decrease")
             {
                 if (arr[j] < arr[j + 1])
                 {
                     var swap = arr[j];
                     arr[j]     = arr[j + 1];
                     arr[j + 1] = swap;
                 }
             }
         }
     }
     return(arr);
 }
Example #4
0
        private static void Main()
        {
            var scs = new sort(SimpleChoiseSort);
            var msd = new sort(RadixSort);

            while (true)
            {
                var length = Ask.Num("Введите длину массива: ");
                var arr    = Generate(length);                      // генерация массива
                Console.WriteLine(String.Join(", ", arr));          // выписать массив

                var simple = (int[])arr.Clone();
                var radix  = (int[])arr.Clone();

                // несортированный массив
                Try(simple, scs);
                Try(radix, msd);

                // сортированный массив
                Try(simple, scs);
                Try(radix, msd);

                // развернуть
                Array.Reverse(simple);
                Array.Reverse(radix);
                // сортированный в обратном порядке
                Try(simple, scs);
                Try(radix, msd);

                OC.Stay();
            }
        }
Example #5
0
        public List <JsonLocalization> GetAll(pagination pagination, sort sort, string search, string search_operator, string filter)
        {
            dynamic searchFilter     = string.Empty;
            var     operater         = string.IsNullOrEmpty(search_operator) ? null : JObject.Parse(search_operator);
            var     templocalization = localization.AsEnumerable();

            if (!string.IsNullOrEmpty(search) && search.Length > 2)
            {
                searchFilter = JObject.Parse(search);
                foreach (var _search in searchFilter)
                {
                    if (!object.ReferenceEquals(null, _search.Value) && !string.IsNullOrEmpty(_search.Value.ToString()))
                    {
                        switch ((string)_search.Name)
                        {
                        case "Resource":
                            templocalization = templocalization.Where(a => a.Key.Contains(_search.Value.ToString()));
                            break;
                            //case "Arabic":
                            //    templocalization = templocalization.//Where(a => a.LocalizedValue.Contains(_search.Value.ToString()));//Contains(_search.Value.ToString())

                            //    break;
                            //case "English":
                            //    break;
                        }
                    }
                }
            }

            return(templocalization.ToList());
        }
        private static void Merge(process[] input, int low, int middle, int high, sort type)
        {
            int left  = low;
            int right = middle + 1;

            process[] tmp      = new process[(high - low) + 1];
            int       tmpIndex = 0;

            while ((left <= middle) && (right <= high))
            {
                if ((input[left].arrivalTime < input[right].arrivalTime) && type == sort.arrivalTime)
                {
                    tmp[tmpIndex] = input[left];
                    left          = left + 1;
                }
                else if ((input[left].priority < input[right].priority) && type == sort.priority)
                {
                    tmp[tmpIndex] = input[left];
                    left          = left + 1;
                }
                else if ((input[left].index < input[right].index) && type == sort.index)
                {
                    tmp[tmpIndex] = input[left];
                    left          = left + 1;
                }
                else
                {
                    tmp[tmpIndex] = input[right];
                    right         = right + 1;
                }
                tmpIndex = tmpIndex + 1;
            }

            if (left <= middle)
            {
                while (left <= middle)
                {
                    tmp[tmpIndex] = input[left];
                    left          = left + 1;
                    tmpIndex      = tmpIndex + 1;
                }
            }

            if (right <= high)
            {
                while (right <= high)
                {
                    tmp[tmpIndex] = input[right];
                    right         = right + 1;
                    tmpIndex      = tmpIndex + 1;
                }
            }

            for (int i = 0; i < tmp.Length; i++)
            {
                input[low + i] = tmp[i];
            }
        }
 public static void SortMerge(process[] input, int low, int high, sort type)
 {
     if (low < high)
     {
         int middle = (low / 2) + (high / 2);
         SortMerge(input, low, middle, type);
         SortMerge(input, middle + 1, high, type);
         Merge(input, low, middle, high, type);
     }
 }
Example #8
0
 public void sorted(DienThoai[] list, sort cmp)
 {
     for (int i = 0; i < list.Length - 1; i++)
     {
         for (int j = i + 1; j < list.Length; j++)
         {
             if (cmp(list[i], list[j]))
             {
                 DienThoai t = list[i];
                 list[i] = list[j];
                 list[j] = t;
             }
         }
     }
 }
Example #9
0
        static void Main(string[] args)
        {
            int IComparable.CompareTo(object obj)
            {
                sort s = (sort)obj;

                return(String.Compare(this.make, s.make));
            }

            Shuffle myShuffle = new Shuffle();

            foreach (Shuffle s in myShuffle.Cards)
            {
                Console.WriteLine(s);
            }
        }
Example #10
0
        static void Try(int[] arr, sort method)
        {
            var time = Stopwatch.StartNew();                    // подготовка:

            countChange = 0;                                    // обнуление счетчиков операций
            countEqual  = 0;                                    // и времени

            Console.WriteLine();
            Console.WriteLine("Массив:");
            Console.WriteLine(String.Join(", ", arr));

            Console.WriteLine("Результат: ");
            method(arr);                                        // сортируем тута
            Console.WriteLine(String.Join(", ", arr));

            Console.WriteLine("Затрачено {0} тиков, {1} сравнений, {2} перессылок",
                              time.ElapsedTicks, countEqual, countChange);
            time.Reset();
        }
Example #11
0
        public static void SortDetection(int[] arr, sort a)
        {
            int res = 0;

            for (int i = 0; i < arr.Length - 1; i++)
            {
                if (a == "increase")
                {
                    if (arr[i] > arr[i + 1])
                    {
                        res = 1;
                    }
                    else
                    {
                        res = 2;
                        break;
                    }
                }
                if (a == "decrease")
                {
                    if (arr[i] < arr[i + 1])
                    {
                        res = 1;
                    }
                    else
                    {
                        res = 2;
                        break;
                    }
                }
            }
            if (res == 2)
            {
                Console.WriteLine("Array is sorted");
            }
            else
            {
                Console.WriteLine("Array is unsorted");
            }
        }
        private bool doViewQueriesWithSubElements(contentManagerService1 cCMS, ref List<CogObject> queries, string cogVersion, string baseQueryPath)
        {
            if (cCMS == null)
            {
                queries = null;
                return false;
            }

            //queries
            propEnum[] queryProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                                propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled};

            // Declare properties to retrieve for package object internal to report object
            refProp packageProps = new refProp();
            packageProps.refPropName = propEnum.metadataModelPackage;
            packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };

            //queries
            sort[] querySort = new sort[] { new sort() };
            querySort[0].order = orderEnum.ascending;
            querySort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { packageProps };

            searchPathMultipleObject userPath = new searchPathMultipleObject();
            searchPathMultipleObject queriesPath = new searchPathMultipleObject();
            queriesPath.Value = "/content//query";

            // Make call to get all queries. Get each author for each query during this process
            // by making a separate call, based on CAMID; the same as above when pulling the reports.
            baseClass[] bcQueries = cCMS.query(queriesPath, queryProps, querySort, qo);
            if (bcQueries.Length > 0)
            {
                foreach (baseClass query_item in bcQueries)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)query_item;
                    CogObject qry = new CogObject();
                    qry.ID = query_item.storeID.value.Value;
                    qry.AddAttribute("ID", qry.ID);
                    qry.AddAttribute("Name", query_item.defaultName.value);
                    qry.AddAttribute("CreationTime", query_item.creationTime.value.ToString());
                    qry.AddAttribute("Type", "Query");
                    qry.AddAttribute("Disabled", query.disabled.value.ToString());

                    // Make sure package or package is not null
                    if (query.metadataModelPackage.value != null)
                    {
                        cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)query.metadataModelPackage.value[0];
                        qry.AddAttribute("Package_Path", query.metadataModelPackage.value[0].searchPath.value);
                        qry.AddAttribute("Package_Name", getPackageName(qry.getAttributeValue("Package_Path")));
                        qry.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                    }
                    else
                    {
                        qry.AddAttribute("Package_Path", "null");
                        qry.AddAttribute("Package_Name", "null");
                        qry.AddAttribute("Package_Disabled", "null");
                    }
                    // Make sure owner is not null
                    if (query_item.owner.value != null)
                    {
                        getUserAccount(cCMS, query_item.owner.value[0].searchPath.value, ref qry);
                        qry.AddAttribute("Author_CAMID", query_item.owner.value[0].searchPath.value);
                    }
                    else
                    {
                        qry.AddAttribute("Author_CAMID", "Unknown");
                    }
                    qry.AddAttribute("Version", cogVersion);
                    qry.AddAttribute("Path", query_item.searchPath.value);
                    qry.AddAttribute("URL", baseQueryPath + query_item.searchPath.value);
                    getSubElements(cCMS, query_item.searchPath.value, ref qry);
                    /* This gets some limited auditing information. Most of this can be found
                     * more easily in the Raw Usage report of the Business Intelligence Dashboard
                     * package on perform-dev.tyson.com. Uncommenting the following line will
                     * cause a dramatic increase in runtime for this program
                     */
                    //getAuditInfo(ref cog);
                    queries.Add(qry);
                }
            }
            else
            {
                queries = null;
            }
            return true;
        }
        static void Main(string[] args)//主程序
        {

            #region 使用递归
            string n = "从0到";
            string j = "0";
            Console.Write("您想从0输出到:");
            j = Console.ReadLine();
            Console.WriteLine("开始输入");
            Console.WriteLine("从0到{0}:{1}", j, recursion(n));
            #endregion


            #region 排序
            sort data = new sort();
            Console.WriteLine("请输入编号,姓名,年龄,学号。之间用回车间隔。");
            data.saves(Console.ReadLine(), Console.ReadLine(), Console.ReadLine(), Console.ReadLine());
            Console.WriteLine("是否想查看数据?如果是请输入y,如果否请输入n");
            string pd = Console.ReadLine();
            if (pd == "y")
            {
                data.forout(data.allsave, 0);
            }
            Console.WriteLine("是否进行排序?如果是,请输入想按照编号、姓名、年龄还是学号排序,并选择逆序还是顺序排序。输入格式例:姓名+逆序  如果不想排序请输入n");
            #region 选择排序方式
            string choose = Console.ReadLine();
            switch (choose)
            {
                case "编号+顺序":
                    data.usesort(data.allsave, 0);
                    data.forout(data.allsave, 0);
                    break;

                case "姓名+顺序":
                    data.usesort(data.allsave, 1);
                    data.forout(data.allsave, 0);
                    break;

                case "年龄+顺序":
                    data.usesort(data.allsave, 2);
                    data.forout(data.allsave, 0);
                    break;

                case "学号+顺序":
                    data.usesort(data.allsave, 3);
                    data.forout(data.allsave, 0);
                    break;

                case "编号+逆序":
                    data.usesort(data.allsave, 0);
                    data.forout(data.allsave, data.nowjs);
                    break;

                case "姓名+逆序":
                    data.usesort(data.allsave, 1);
                    data.forout(data.allsave, data.nowjs);
                    break;

                case "年龄+逆序":
                    data.usesort(data.allsave, 2);
                    data.forout(data.allsave, data.nowjs);
                    break;

                case "学号+逆序":
                    data.usesort(data.allsave, 3);
                    data.forout(data.allsave, data.nowjs);
                    break;
            }


            #endregion
        }
        /**
         * Method to take in a list of paths to cognos objects and disable them.
         * pwnsauce...
         */
        public void disableCogObjects()
        {
            System.IO.TextReader reader = new StreamReader("objectsToDisable.txt");

            StreamWriter errorWriter = new StreamWriter("objectsNotFoundC8.txt");
            StreamWriter successWriter = new StreamWriter("objectsFoundC8.txt");
            // Declare query properties array for report
            propEnum[] props = new propEnum[] { propEnum.defaultName, propEnum.disabled,
                                                propEnum.searchPath};

            // Declare sort properties for reports and users
            //reports
            sort[] sorts = new sort[] {  };

            // Object representing path to single report
            searchPathMultipleObject reportSearchPath = new searchPathMultipleObject();

            // Query options
            queryOptions qo = new queryOptions();

            // Read in first path
            string path = reader.ReadLine();
            List<baseClass> objectsToDisable = new List<baseClass>();

            // Loop through all the paths and generate a list of objects
            // to disable
            while (path != null)
            {
                reportSearchPath.Value = path;
                // Run query to get all reports. Users will be queried as part of this
                // process, one for each report.

                try
                {
                    baseClass[] bc = cCMS.query(reportSearchPath, props, sorts, qo);
                    if (bc.Length > 0)
                    {
                        booleanProp bp = new booleanProp();
                        bp.value = true;
                        bc[0].disabled = bp;
                        // Add the object to our List of things to disable
                        objectsToDisable.Add(bc[0]);
                        successWriter.WriteLine(path);
                    }
                    else
                    {
                        errorWriter.WriteLine(path);
                    }
                }
                // The exception will simply say "The client did something wrong"
                // if the path line from the file is nothing resembling a path in the current
                // cognos environment
                catch (Exception e)
                {
                    errorWriter.WriteLine(path);
                }
                path = reader.ReadLine();
            }
            reader.Close();
            errorWriter.Close();
            successWriter.Close();

            updateOptions updateOptions = new updateOptions();

            cCMS.update(objectsToDisable.ToArray(), updateOptions);
        }
        private bool doViewObjectsByPackage(contentManagerService1 cCMS, ref List<CogObject> packages, string cogVersion, string basePackagePath)
        {
            if (cCMS == null)
            {
                packages = null;
                return false;
            }

            // Same query options used for all calls
            queryOptions qo = new queryOptions();

            //queries
            propEnum[] packageProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                propEnum.owner, propEnum.storeID, propEnum.connectionString,
                                                propEnum.metadataModelPackage, propEnum.policies, propEnum.ancestors};
            //queries
            sort[] pkgSort = new sort[] { new sort() };
            pkgSort[0].order = orderEnum.ascending;
            pkgSort[0].propName = propEnum.defaultName;

            searchPathMultipleObject packagesPath = new searchPathMultipleObject();
            packagesPath.Value = "/content//package";

            // Make call to get all queries. Get each author for each query during this process
            // by making a separate call, based on CAMID; the same as above when pulling the reports.
            baseClass[] bcPackages = cCMS.query(packagesPath, packageProps, pkgSort, qo);
            if (bcPackages.Length > 0)
            {
                 foreach (baseClass package_item in bcPackages)
                 {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)package_item;
                    CogObject pkg = new CogObject();
                    pkg.ID = package_item.storeID.value.Value;
                    pkg.AddAttribute("ID", pkg.ID);
                    pkg.AddAttribute("Name", package_item.defaultName.value);
                    pkg.AddAttribute("Type", "Package");
                    addSecurityPolicies(ref pkg, package_item);

                    if (package_item.owner.value != null)
                    {
                        getUserAccount(cCMS, package_item.owner.value[0].searchPath.value, ref pkg);
                        pkg.AddAttribute("Author_CAMID", package_item.owner.value[0].searchPath.value);
                    }
                    else
                    {
                        pkg.AddAttribute("Author_CAMID", "Unknown");
                    }
                    pkg.AddAttribute("Version", cogVersion);
                    pkg.AddAttribute("URL", basePackagePath + package_item.searchPath.value);

                    /* Run another query to retrieve all reports for given package based on package path
                    */
                    List<CogObject> children = new List<CogObject>();

                    getObjectsForPackage(cCMS, ref children, cogVersion, basePackagePath, package_item.searchPath.value +
                                         "//report | " + package_item.searchPath.value + "//query | " +
                                         package_item.searchPath.value + "//reportView");
                    pkg.addSubElements(children);
                    packages.Add(pkg);
                }
            }
            else
            {
                packages = null;
            }
            return true;
        }
Example #16
0
 /// <summery>
 /// Search users and pages with keyword
 ///
 /// <typeparam name=""></typeparam> mixed qStr
 /// <typeparam name=""></typeparam> mixed type
 /// <returns></returns> Indexed
 /// </summery>
 public function search(qStr, type = Search.SEARCH_TYPE_USER_AND_PAGE, sort, page = 1, limit = Search.SEARCH_RESULT_PER_PAGE)
        public PagingList <EmailTransfer> GetAll(pagination pagination, sort sort, string search, string search_operator, string filter)
        {
            dynamic searchFilter             = string.Empty;
            var     operater                 = string.IsNullOrEmpty(search_operator) ? null : JObject.Parse(search_operator);
            IQueryable <EmailTransfer> query = _context.Set <EmailTransfer>();

            if (!string.IsNullOrEmpty(filter) && filter.Length > 2)
            {
                searchFilter = JObject.Parse(filter);
                foreach (var _filter in searchFilter)
                {
                    string fitlterstr = (string)_filter.Value;
                    var    result     = fitlterstr.Split(',').Where(r => !string.IsNullOrEmpty(r)).ToList();
                    if (result.Count() > 1)
                    {
                        int count = 0;
                        result.ForEach(s =>
                        {
                            string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).FirstOrDefault().Value : "eq";

                            switch ((string)_filter.Key)
                            {
                            case "":
                                //query = query.Where(a=>a.Sector == Se)
                                break;

                            default:
                                var tempQuery = query;
                                query         = count == 0 ? query.Where <EmailTransfer>(
                                    (object)_filter.Key, (object)s,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)) :
                                                query.Concat <EmailTransfer>(tempQuery.Where <EmailTransfer>(
                                                                                 (object)_filter.Key, (object)s,
                                                                                 (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)));
                                count = count + 1;
                                break;
                            }
                        });
                    }

                    else if (!string.IsNullOrEmpty(_filter.Value))
                    {
                        string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).FirstOrDefault().Value : "eq";
                        query = query.Where <EmailTransfer>(
                            (object)_filter.Key, (object)result.FirstOrDefault(),
                            (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                    }
                }
            }
            if (!string.IsNullOrEmpty(search) && search.Length > 2)
            {
                searchFilter = JObject.Parse(search);
                foreach (var _search in searchFilter)
                {
                    if (!Object.ReferenceEquals(null, _search.Value) && !String.IsNullOrEmpty(_search.Value.ToString()))
                    {
                        string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _search.Name).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _search.Name).FirstOrDefault().Value : "eq";
                        string checkCurrentKey = Convert.ToString(_search.Value);
                        if (checkCurrentKey.Split(',').Count() > 1)
                        {
                            int i;
                            if (!(int.TryParse(checkCurrentKey.Split(',')[0].ToString(), out i)))
                            {
                                query = query.Where <EmailTransfer>(
                                    (object)_search.Key, (object)_search.Value,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                            }
                            else
                            {
                                int count = 0;
                                foreach (var _tempSearchKey in checkCurrentKey.Split(',').ToList())
                                {
                                    if (!string.IsNullOrEmpty(_tempSearchKey))
                                    {
                                        var tempQuery = query;
                                        query = count == 0 ? query.Where <EmailTransfer>(
                                            (object)_search.Key, (object)_tempSearchKey,
                                            (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)) :
                                                query.Concat <EmailTransfer>(tempQuery.Where <EmailTransfer>(
                                                                                 (object)_search.Key, (object)_tempSearchKey,
                                                                                 (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)));
                                        count = count + 1;
                                    }
                                }
                            }
                        }
                        else
                        {
                            string strFk = (string)_search.Value;
                            switch ((string)_search.Name)
                            {
                            case "Message":
                                string[] statusen = { "message" };
                                string[] statusar = { "نص الرسالة" };
                                int[]    result;
                                if (!_globalSettings.CurrentUser.IsRtl)
                                {
                                    result = statusen.Select((x, i) => x.Contains(strFk) ? i : -1).Where(x => x != -1).ToArray();
                                }
                                else
                                {
                                    result = statusar.Select((x, i) => x.Contains(strFk) ? i : -1).Where(x => x != -1).ToArray();
                                }
                                if (result.Count() == 0)
                                {
                                    query = query.Except(query);
                                }

                                break;

                            case "UserCounts":
                                query = query.Where(a => ((string.IsNullOrEmpty(a.UserCounts.ToString()) ? "" : a.UserCounts.ToString())).Contains(strFk));

                                break;

                            default:
                                query = query.Where <EmailTransfer>(
                                    (object)_search.Key, (object)_search.Value,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                                break;
                            }
                        }
                    }
                }
            }
            query = query.OrderBy <EmailTransfer>(sort.predicate, !sort.reverse ? "asc" : "");
            return(new PagingList <EmailTransfer>(query, pagination.start / 10, pagination.Count == 0 ? 10 : pagination.Count));
            //return _context.Set<T>();
        }
        private bool report_ReportViewDuration(ref _Worksheet oSheet, int[] cellCount)
        {
            if (cCMS == null)
            {
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                      propEnum.retentions, propEnum.owner };

            // Properties used to get account class information for the owner
            refProp ownerProps = new refProp();
            ownerProps.refPropName = propEnum.owner;
            ownerProps.properties = new propEnum[] { propEnum.searchPath, propEnum.defaultName };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { ownerProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject objectsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            objectsPath.Value = "//reportView";
            //objectsPath.Value = "/content/package[@name='National Accounts']/report[@name='(0226) NA Ebit by Customer/Minor Line - Combined']";
            //objectsPath.Value = "CAMID(\"ADS:u:cn=miller\\, barret,ou=new,ou=groups,ou=general,ou=tyson team members\")/folder[@name='My Folders']/reportView[@name='Report View of (0224) Combined Sales']";
            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(objectsPath, reportProps, reportSort, qo);

            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    if (report_item is reportView)
                    {
                        cognosdotnet_2_0.reportView reportv = (cognosdotnet_2_0.reportView)report_item;
                        foreach (retentionRule rule in reportv.retentions.value)
                        {
                            // If the rule is for the type 'reportVersion' and has the duration set
                            if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                            {
                                // Output the name
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.defaultName.value;
                                //Increment the column count
                                cellCount[1]++;
                                //Output the path
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.searchPath.value;
                                //Increment the column count
                                cellCount[1]++;
                                if (reportv.owner.value == null)
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = "unknown";
                                }
                                else
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = reportv.owner.value[0].defaultName.value;
                                }
                                //Reset the column count, and increment the row count
                                cellCount[1] = 1;
                                cellCount[0]++;
                            }
                        }
                    }
                }
            }
            return true;
        }
        /// <summary>
        /// Application entry point.
        /// </summary>
        /// <param name="args">Standard command-line arguments.</param>
        public static void Main( string[] args )
        {
            // Attempt a simple CM query.

            string searchPath = "//report";
            string userName = "******";
            string userPassword = "******";
            string userNamespace = "ADS";

            char[] arg_separator = { '=' };
            foreach( string arg in args )
            {
                string[] command = arg.Split( arg_separator, 2 );

                switch( command[0] )
                {
                    case "--search":
                        searchPath = command[1];
                        break;
                    case "--uid":
                        userName = command[1];
                        break;
                    case "--pwd":
                        userPassword = command[1];
                        break;
                    case "--namespace":
                        userNamespace = command[1];
                        break;
                    default:
                        throw new ApplicationException( "Unknown argument: " + arg );
                }
            }

            // Concatenate the read filter to the searchPath this way we
            // ask CM to only return the objects we have read acces on.
            //searchPath = searchPath + "[permission('read')]";

            // Create the ReportNet connection object.
            Console.WriteLine( "Creating CognosReportNetService..." );
            contentManagerService1 cmService = new contentManagerService1();
            cmService.Url = "http://cogpbi1.tyson.com:9300/p2pd/servlet/dispatch";

            //logon to Cognos 8
            logon(cmService, userName, userPassword, userNamespace);

            propEnum[] props = new propEnum[] { propEnum.searchPath,
                                                  propEnum.defaultName, propEnum.policies,
                                                  propEnum.permissions, propEnum.members };

            sort[] s = new sort[]{ new sort() };

            s[0].order = orderEnum.ascending;

            s[0].propName = propEnum.defaultName;

            queryOptions qo = new queryOptions();

            Console.WriteLine( "\nReports:\n" );
            // Look for all of the reports.
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            spMulti.Value = "/content//package";
            //"/content/package[@name='Sales']//report";
            baseClass[] bc = null;

            try
            {
                bc = cmService.query(spMulti, props, s, qo );

                if( bc.Length > 0 )
                {
                    foreach( baseClass report_item in bc )

                    {
                        Console.WriteLine( "  {0}", report_item.searchPath.value);
                        policy[] p = report_item.policies.value;
                        if (p.Length > 0)
                        {
                            foreach( policy pol in p )
                            {
                                Console.WriteLine( "  {0}", pol.securityObject.searchPath.value);
                                permission[] perm = pol.permissions;
                                foreach( permission prm in perm )
                                    Console.WriteLine( "  {0}   {1}",prm.name, prm.access.ToString());
                            }
                        }
                    }
                }
            }

            catch( System.Web.Services.Protocols.SoapHeaderException ex )
            {
                displayException(ex);
            }
            catch( System.Web.Services.Protocols.SoapException ex )
            {
                displayException(ex);
            }
        }
        public void disableCogObjects(string startDate, int daysBack)
        {
            List<string> reportPaths = getPathToDisableList(startDate, daysBack);

            /* Debugging
            List<string> reportPaths = new List<string>();
            reportPaths.Add("/content/package[@name='Supply Chain']/folder[@name='Demand']/report[@name='(0014) Product Group Summary'])&ui.name=(0014) Product Group Summary&ui.format=XLS&ui.backURL=/cognos8/cgi-bin/cognosisapi.dll?b_action=xts.run&m=portal/cc.xts&m_folder=iAB52A69DC50C4C77AC3A623A085EF52A");
             */

            List<string> exceptionPaths = getExceptionPathList();
            writePathToDisableList(reportPaths);

            Console.WriteLine("Please check the file: objectsToDisable.txt in the program executable folder " +
                              "to make sure everything looks good. Do you want to proceed? Enter 'yes' or 'no' (case insensitive).");

            string userChoice = Console.ReadLine();

            if(userChoice.ToLower() == "yes")
            {
                StreamWriter errorWriter = new StreamWriter("objectsNotFoundC8.txt");
                StreamWriter successWriter = new StreamWriter("objectsFoundC8.txt");
                // Declare query properties array for report
                propEnum[] props = new propEnum[] { propEnum.defaultName, propEnum.disabled,
                                                    propEnum.searchPath};

                // Declare sort properties for reports and users
                //reports
                sort[] sorts = new sort[] { };

                // Object representing path to single report
                searchPathMultipleObject reportSearchPath = new searchPathMultipleObject();

                // Query options
                queryOptions qo = new queryOptions();

                List<baseClass> objectsToDisable = new List<baseClass>();

                // Loop through all the paths and generate a list of objects
                // to disable
                for (int i = 0; i < reportPaths.Count; i++)
                {
                    string path = reportPaths[i];

                    // If the path is not in the exception list, then add it to
                    // the list of paths to be disabled
                    if (!checkAgainstExceptions(path, exceptionPaths))
                    {
                        reportSearchPath.Value = path;
                        // Run query to get all reports. Users will be queried as part of this
                        // process, one for each report.

                        try
                        {
                            baseClass[] bc = cCMS.query(reportSearchPath, props, sorts, qo);
                            if (bc.Length > 0)
                            {
                                booleanProp bp = new booleanProp();
                                bp.value = true;
                                bc[0].disabled = bp;
                                // Add the object to our List of things to disable
                                objectsToDisable.Add(bc[0]);
                                successWriter.WriteLine(path);
                            }
                            else
                            {
                                errorWriter.WriteLine(path);
                            }
                        }
                        // The exception will simply say "The client did something wrong"
                        // if the path line from the file is nothing resembling a path in the current
                        // cognos environment
                        catch (Exception e)
                        {
                            errorWriter.WriteLine(path);
                        }
                    }
                }
                errorWriter.Close();
                successWriter.Close();

                updateOptions updateOptions = new updateOptions();

                cCMS.update(objectsToDisable.ToArray(), updateOptions);
            }
            else
            {
                Console.WriteLine("User entered something other than 'yes'. Aborting...");
            }
        }
Example #21
0
 public static IObservable<user> SetSortBy(sort sort)
 {
     return client.get<user>("users/view", new p() { { "sort", ((int)sort).ToString() } });
 }
        private bool extractTablesAndFieldsFromModels()
        {
            bool success = true;
            System.IO.StreamWriter writer = new StreamWriter("ModelTablesAndFields.csv");
            writer.WriteLine("Model Name|Table Name|Field Name");

            // Same query options used for all calls
            queryOptions qo = new queryOptions();

            propEnum[] packageProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName };
            //model sorting
            sort[] pkgSort = new sort[] { new sort() };
            pkgSort[0].order = orderEnum.ascending;
            pkgSort[0].propName = propEnum.defaultName;
            searchPathMultipleObject packagePath = new searchPathMultipleObject();
            packagePath.Value = "//package";
             // Make call to get all queries. Get each author for each query during this process
            // by making a separate call, based on CAMID; the same as above when pulling the reports.
            baseClass[] bcPackages = cCMS.query(packagePath, packageProps, pkgSort, qo);

            foreach (baseClass pkg in bcPackages)
            {
                //Model properties
                propEnum[] modelProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName, propEnum.model };

                //model sorting
                sort[] mdlSort = new sort[] { new sort() };
                mdlSort[0].order = orderEnum.ascending;
                mdlSort[0].propName = propEnum.defaultName;

                searchPathMultipleObject modelsPath = new searchPathMultipleObject();
                modelsPath.Value = pkg.searchPath.value + "/model";

                // Make call to get all models. Get each author for each query during this process
                // by making a separate call, based on CAMID; the same as above when pulling the reports.
                baseClass[] bcmodels = cCMS.query(modelsPath, modelProps, mdlSort, qo);

                // Latest model should always be at the end of the array
                model latestModel = (model)bcmodels[bcmodels.Length - 1];

                /* Uncomment the following code to write a model XML out to file */
                if (pkg.defaultName.value == "Commitments")
                {
                    System.IO.StreamWriter xmlWriter = new StreamWriter("model.xml");
                    xmlWriter.Write(latestModel.model1.value);
                    xmlWriter.Close();

                    // Write out the database tables and fields used in the current model
                    //extractAndWriteTablesAndFields(ref writer, pkg.defaultName.value, latestModel.model1.value);
                }
            }
            writer.Close();
            return success;
        }
        /* Does the bulk of the work to extract information on Users' MyFolder objects
         */
        private bool doViewUsersMyFolderContentsWithSubElements(contentManagerService1 cCMS, ref List<CogObject> cogs, string cogVersion, string baseReportPath)
        {
            string camid = "//account"; //this is the search path for all user accounts
            string userSearchPaths = "";
            // We will display My Folders and My Pages for all users in namespace
            propEnum[] props = new propEnum[]{propEnum.searchPath,
                    propEnum.objectClass,propEnum.defaultName,propEnum.portalPages,
                    propEnum.ancestors, propEnum.owner};

            // Same query options used for all calls
            queryOptions qo = new queryOptions();
            // Create sort object
            sort[] accountSort = new sort[] { new sort() };
            accountSort[0].order = orderEnum.ascending;
            accountSort[0].propName = propEnum.defaultName;

            //query for all accounts
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            spMulti.Value = camid;
            baseClass[] bc = cCMS.query(spMulti, props, accountSort, qo);

            if (bc != null && bc.Length > 0)
            {
                // Set different properties to grab for the reports, queries, or report views
                props = new propEnum[]{propEnum.searchPath, propEnum.defaultName,
                                       propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                       propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled};
                // Declare properties to retrieve for package object internal to report object
                refProp packageProps = new refProp();
                packageProps.refPropName = propEnum.metadataModelPackage;
                packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };
                // Properties used to get base class information if the object is a report view
                refProp reportProps = new refProp();
                reportProps.refPropName = propEnum.@base;
                reportProps.properties = new propEnum[] { propEnum.metadataModelPackage, propEnum.storeID,
                                                      propEnum.searchPath, propEnum.disabled };
                qo.refProps = new refProp[] { packageProps, reportProps };

                for (int i = 0; i < bc.Length; i++)
                {
                    //Query the Content Store for all objects in My Folders for user bc[i]
                    userSearchPaths = bc[i].searchPath.value + "/folder[@name='My Folders']//report |" +
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//query |" +
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//reportView";

                    spMulti.Value = userSearchPaths;
                    baseClass[] contents = cCMS.query(spMulti, props, new sort[] { }, qo);
                    if (contents != null && contents.Length > 0)
                    {
                        //Display all objects in My Folders for user bc[i]
                        for (int j = 0; j < contents.Length; j++)
                        {
                            CogObject cog = new CogObject();
                            /*
                             * Check whether object is a more specific type (e.g. query or report)
                             */
                            if (contents[j] is report)
                            {
                                // Cast base class object to more specific report object for access to more
                                // properties
                                cognosdotnet_2_0.report report = (cognosdotnet_2_0.report)contents[j];
                                cog.AddAttribute("Type", "Report");
                                cog.AddAttribute("CreationTime", contents[j].creationTime.value.ToString());
                                // Make sure package or Package is not null
                                if (report.metadataModelPackage.value != null)
                                {
                                    cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)report.metadataModelPackage.value[0];
                                    cog.AddAttribute("Package_Path", report.metadataModelPackage.value[0].searchPath.value);
                                    cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                                    cog.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                                }
                                else
                                {
                                    cog.AddAttribute("Package_Path", "null");
                                    cog.AddAttribute("Package_Name", "null");
                                    cog.AddAttribute("Package_Disabled", "null");
                                }
                                cog.AddAttribute("Disabled", report.disabled.value.ToString());
                            }
                            else if (contents[j] is query)
                            {
                                // Cast base class object to more specific report object for access to more
                                // properties
                                cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)contents[j];
                                cog.AddAttribute("Type", "Query");
                                // Make sure package or Package is not null
                                if (query.metadataModelPackage.value != null)
                                {
                                    cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)query.metadataModelPackage.value[0];
                                    cog.AddAttribute("Package_Path", query.metadataModelPackage.value[0].searchPath.value);
                                    cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                                    cog.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                                }
                                else
                                {
                                    cog.AddAttribute("Package_Path", "null");
                                    cog.AddAttribute("Package_Name", "null");
                                    cog.AddAttribute("Package_Disabled", "null");
                                }
                                cog.AddAttribute("Disabled", query.disabled.value.ToString());
                            }
                            else if (contents[j] is reportView)
                            {
                                // Cast base class object to more specific report object for access to more
                                // properties
                                cognosdotnet_2_0.reportView reportView = (cognosdotnet_2_0.reportView)contents[j];
                                cog.AddAttribute("Type", "ReportView");
                                // Make sure package or Package is not null
                                if (reportView.packageBase != null)
                                {
                                    cog.AddAttribute("Package_Path", reportView.packageBase.value);
                                    cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                                }
                                else
                                {
                                    cog.AddAttribute("Package_Path", "null");
                                    cog.AddAttribute("Package_Name", "null");
                                }

                                if ([email protected] != null)
                                {
                                    cog.AddAttribute("BaseID", [email protected][0].storeID.value.Value);
                                    cog.AddAttribute("BasePath", [email protected][0].searchPath.value);

                                    if ([email protected][0] is report)
                                    {
                                        report tempReport = (report)[email protected][0];
                                        if (tempReport.metadataModelPackage.value[0] != null)
                                        {
                                            cog.AddAttribute("BasePackage_Path", tempReport.metadataModelPackage.value[0].searchPath.value);
                                            cog.AddAttribute("BasePackage_Name", getPackageName(cog.getAttributeValue("BasePackage_Path")));
                                        }
                                    }
                                    else if ([email protected][0] is query)
                                    {
                                        query tempQuery = (query)[email protected][0];
                                        if (tempQuery.metadataModelPackage.value[0] != null)
                                        {
                                            cog.AddAttribute("BasePackage_Path", tempQuery.metadataModelPackage.value[0].searchPath.value);
                                            cog.AddAttribute("BasePackage_Name", getPackageName(cog.getAttributeValue("BasePackage_Path")));
                                        }
                                    }
                                    cog.AddAttribute("Disabled", reportView.disabled.value.ToString());

                                }
                            }

                            // Make sure owner is not null
                            if (contents[j].owner.value != null)
                            {
                                /* We will get the author based on who's folder the report is in. This may
                                * not be strictly true. Uncomment the following line to get the old method.
                                * Also comment out or remove the line farther below that sets the Author_Name
                                * attribute*/
                                //getUserAccount(cCMS, contents[j].owner.value[0].searchPath.value, ref cog);
                                cog.AddAttribute("Author_CAMID", contents[j].owner.value[0].searchPath.value);
                            }
                            else
                            {
                                cog.AddAttribute("Author_CAMID", "Unknown");
                            }

                            cog.AddAttribute("Author_Name", bc[i].defaultName.value);
                            cog.AddAttribute("Version", cogVersion);
                            cog.AddAttribute("Name", contents[j].defaultName.value);
                            cog.AddAttribute("Path", contents[j].searchPath.value);
                            cog.AddAttribute("URL", baseReportPath + contents[j].searchPath.value);
                            cog.AddAttribute("MyFolder", "TRUE");
                            getSubElements(cCMS, contents[j].searchPath.value, ref cog);

                            /* This gets some limited auditing information. Most of this can be found
                             * more easily in the Raw Usage report of the Business Intelligence Dashboard
                             * package on perform-dev.tyson.com. Uncommenting the following line will
                             * cause a dramatic increase in runtime for this program
                             */
                            //getAuditInfo(ref cog);
                            cogs.Add(cog);
                        }
                    }
                }
            }
            else
            {
                cogs = null;
            }
            return true;
        }
Example #24
0
        //type : to get User By there Roles
        public PagingList <User> GetAll(pagination pagination, sort sort, string search, string search_operator, string filter, string type)
        {
            dynamic           searchFilter = string.Empty;
            var               operater     = string.IsNullOrEmpty(search_operator) ? null : JObject.Parse(search_operator);
            IQueryable <User> query        = _context.Set <User>().Where(x => x.IsDeleted != true).Include(e => e.fk_UserRoleMap).ThenInclude(y => y.UserRole.fk_UserRoleMap).Where(a => a.fk_UserRoleMap.Where(r => r.UserRole.Name != UserRoleName.Guest).Count() > 0);
            HashSet <int>     ids          = new HashSet <int>()
            {
                7
            };

            query = type != null ? (type == UserRoleName.User ? query.Where(x => x.fk_UserRoleMap.Where(u => u.UserRole.Name == UserRoleName.User).Count() > 0) : query.Where(x => x.fk_UserRoleMap.Where(u => u.UserRole.Name == type).Count() > 0)) : query;

            if (!string.IsNullOrEmpty(filter) && filter.Length > 2)
            {
                searchFilter = JObject.Parse(filter);
                foreach (var _filter in searchFilter)
                {
                    string fitlterstr = (string)_filter.Value;
                    var    result     = fitlterstr.Split(',').Where(r => !string.IsNullOrEmpty(r)).ToList();
                    if (result.Count() > 1)
                    {
                        int count = 0;
                        result.ForEach(s =>
                        {
                            string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).FirstOrDefault().Value : "eq";

                            switch ((string)_filter.Key)
                            {
                            case "":
                                //query = query.Where(a=>a.Sector == Se)
                                break;

                            default:
                                var tempQuery = query;
                                query         = count == 0 ? query.Where <User>(
                                    (object)_filter.Key, (object)s,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)) :
                                                query.Concat <User>(tempQuery.Where <User>(
                                                                        (object)_filter.Key, (object)s,
                                                                        (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)));
                                count = count + 1;
                                break;
                            }
                        });
                    }

                    else if (!string.IsNullOrEmpty(_filter.Value))
                    {
                        string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).FirstOrDefault().Value : "eq";
                        query = query.Where <User>(
                            (object)_filter.Key, result.FirstOrDefault(),
                            (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                    }
                }
            }
            if (!string.IsNullOrEmpty(search) && search.Length > 2)
            {
                searchFilter = JObject.Parse(search);
                foreach (var _search in searchFilter)
                {
                    if (!object.ReferenceEquals(null, _search.Value) && !string.IsNullOrEmpty(_search.Value.ToString()))
                    {
                        string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _search.Name).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _search.Name).FirstOrDefault().Value : "eq";
                        string checkCurrentKey = Convert.ToString(_search.Value);

                        if (checkCurrentKey.Split(',').Count() > 1)
                        {
                            int i;
                            if (!(int.TryParse(checkCurrentKey.Split(',')[0].ToString(), out i)))
                            {
                                query = query.Where <User>(
                                    (object)_search.Name, (object)_search.Value,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                            }
                            else
                            {
                                int count = 0;
                                var temp2 = query; /////3-- all 163,164,171
                                foreach (var _tempSearchKey in checkCurrentKey.Split(',').ToList())
                                {
                                    if (!string.IsNullOrEmpty(_tempSearchKey))
                                    {
                                        var tempQuery = query;
                                        query = count == 0 ? query.Where <User>((object)_search.Name, (object)_tempSearchKey, (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)) :
                                                query.Concat <User>(temp2.Where <User>((object)_search.Name, (object)_tempSearchKey, (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)));

                                        count = count + 1;
                                    }
                                }
                            }
                        }
                        else
                        {
                            string strFk = (string)_search.Value;
                            switch ((string)_search.Name)
                            {
                            //case "SectorStr":
                            //    query = query.Where(a => a.FK_Sector.Name.Contains(strFk) && a.FK_Sector.ModulType == 1);
                            //    break;
                            case "Name":
                                query = query.Where(a => ((string.IsNullOrEmpty(a.Name) ? "" : a.Name)).Contains(strFk));
                                break;

                            case "Email":
                                query = query.Where(a => ((string.IsNullOrEmpty(a.Email) ? "" : a.Email)).Contains(strFk));
                                break;

                            case "Mobile":
                                query = query.Where(a => ((string.IsNullOrEmpty(a.Mobile) ? "" : a.Mobile)).Contains(strFk));
                                break;

                            default:
                                query = query.Where <User>(
                                    (object)_search.Name, (object)_search.Value,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                                break;
                            }
                        }
                    }
                }
            }
            query = query.OrderBy <User>(sort.predicate, !sort.reverse ? "asc" : "");
            return(new PagingList <User>(query, pagination.start / 10, pagination.Count == 0 ? 10 : pagination.Count));
            //return _context.Set<T>();
        }
Example #25
0
    public static void Main(string[] args)
    {
        //Creates objects to call functions and methods from
        menuSystem menuObject      = new menuSystem();
        textFiles  textFilesObject = new textFiles();
        sort       algorithmObject = new sort();
        output     outputObject    = new output();

        //Uses the menu class to get the input options from the user
        string weatherStation   = menuObject.getWeatherStation();
        string whatToView       = menuObject.getWhatToView();
        int    menuChoiceTime   = menuObject.getWhatTime();
        int    menuChoiceDo     = menuObject.getWhatToDo();
        int    menuChoiceOutput = menuObject.getOutputType();

        //Initialise  variables
        string year  = "";
        string month = "";

        //Reads in the year and months
        string[] yearLines  = System.IO.File.ReadAllLines(@"CMP1124M_Weather_Data/Year.txt");
        string[] monthLines = System.IO.File.ReadAllLines(@"CMP1124M_Weather_Data/Month.txt");

        //Gets the year and month from the user and validates it
        if (menuChoiceTime == 1)
        {
            year = menuObject.getYear(yearLines);
        }
        else if (menuChoiceTime == 2)
        {
            year  = menuObject.getYear(yearLines);
            month = menuObject.getMonth(year, yearLines, monthLines, menuChoiceTime);
        }
        else if (menuChoiceTime == 4)
        {
            month = menuObject.getMonth(year, yearLines, monthLines, menuChoiceTime);
        }

        //Assigns an array the correct text file based on what the user wants to view
        double[] data = textFilesObject.loadInData(weatherStation, whatToView);

        //Initliases variables
        int menuAlgorithmChoice;

        object[] returnArrays;

        int stepCounter;

        //Switch for doing what the user has specified
        switch (menuChoiceDo)
        {
        //If user chosen to sort
        case 1:
        case 2:
            //Get which sorting algorithm the user wants to use
            menuAlgorithmChoice = menuObject.getSortingAlgorithm();

            //Selects what algorithm to use via a nested switch statement
            switch (menuAlgorithmChoice)
            {
            case 1:     //Use Insertion Sort
                algorithmObject.InsertionSort(data, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, menuChoiceOutput);
                break;

            case 2:     //Use QuickSort

                //Initialise the step counter
                stepCounter = 0;

                returnArrays = algorithmObject.Quicksort(data, 0, data.Length - 1, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, stepCounter);

                //Retrieve the arrays from the object array created by the quicksort function
                data        = (double[])returnArrays[0];
                yearLines   = (string[])returnArrays[1];
                monthLines  = (string[])returnArrays[2];
                stepCounter = (int)returnArrays[3];

                //If the user wants to view the data backwards then reverse the array
                if (menuChoiceDo == 2)
                {
                    Array.Reverse(data);
                    Array.Reverse(monthLines);
                    Array.Reverse(yearLines);
                }

                //output the steps the algorithm took
                Console.WriteLine("This Algorithm took {0} steps", stepCounter);

                //Call the output method
                outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);

                break;

            case 3:     //Use Bubblesort
                algorithmObject.Bubblesort(data, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, menuChoiceOutput);
                break;

            //default class
            default:
                Console.WriteLine("Error");
                break;
            }

            break; //End of outside case 1 and 2

        case 3:    //Find the Median value

            //Initialise the step counter
            stepCounter = 0;

            //Gets the sorted data
            returnArrays = algorithmObject.Quicksort(data, 0, data.Length - 1, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, stepCounter);

            //Retrieves the data from the object as needed to return 3 vairbales
            data        = (double[])returnArrays[0];
            yearLines   = (string[])returnArrays[1];
            monthLines  = (string[])returnArrays[2];
            stepCounter = (int)returnArrays[3];

            //output the steps the algorithm took
            Console.WriteLine("This Algorithm took {0} steps", stepCounter);

            //Call the output method to output the median values
            outputObject.doOutputMedian(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);

            break;

        //Max and Min
        case 4:

            //Initialise the step counter
            stepCounter = 0;

            //Retrieve sorted array
            returnArrays = algorithmObject.Quicksort(data, 0, data.Length - 1, yearLines, monthLines, menuChoiceTime, month, year, menuChoiceDo, stepCounter);

            //Retrieves and assigns individual lists
            data        = (double[])returnArrays[0];
            yearLines   = (string[])returnArrays[1];
            monthLines  = (string[])returnArrays[2];
            stepCounter = (int)returnArrays[3];

            //output the steps the algorithm took
            Console.WriteLine("This Algorithm took {0} steps", stepCounter);

            //Call the output method to output the data
            outputObject.doOutputMinMax(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);

            break;

        case 5: //Sort Chronoligcally
            //Calls the output method to output the data
            outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);
            break;

        case 6: //Sort Chronoligcally Backwards

            //Reveres the arrays to display them from old to new
            Array.Reverse(data);
            Array.Reverse(yearLines);
            Array.Reverse(monthLines);

            //use the output class and the user selected output to output the data
            outputObject.doOutput(menuChoiceOutput, data, menuChoiceTime, year, month, yearLines, monthLines);
            break;

        default:
            Console.WriteLine("Error");
            break;
        }
    }
        /* Method to query the content store for the object at the given path and populate the
         * referenced object with user name information of the owner or author
         */
        private void getUserAccount(contentManagerService1 cCMS, string searchPath, ref CogObject cog)
        {
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            userPath.Value = searchPath;

            // Same query options used for all calls
            queryOptions qo = new queryOptions();

            //users
            propEnum[] userProps = new propEnum[] { propEnum.userName, propEnum.name, propEnum.user };
            sort[] userSort = new sort[] { new sort() };
            userSort[0].order = orderEnum.ascending;
            userSort[0].propName = propEnum.userName;

            /* Run another query to retrieve the account object based on the CAMID.
            UserID is pulled from the account object. CAMID's for users who no
            longer work here will return no account objects. Author set to ""
            in this case.
            */
            baseClass[] bcUserAccount = cCMS.query(userPath, userProps, userSort, qo);
            if (bcUserAccount.Length > 0)
            {
                cognosdotnet_2_0.account account = (cognosdotnet_2_0.account)bcUserAccount[0];
                cog.AddAttribute("Author", account.userName.value);
                cog.AddAttribute("Author_Name", account.name.value[0].value);
            }
            else
            {
                string wholeName = getAuthorName(userPath.Value);
                cog.AddAttribute("Author_Name", wholeName);
            }
        }
        /// <summary>
        /// Application entry point.
        /// </summary>
        /// <param name="args">Standard command-line arguments.</param>
        public static void Main( string[] args )
        {
            // Attempt a simple CM query.

            string searchPath = "//report";
            string userName = "******";
            string userPassword = "******";
            string userNamespace = "namespaceID";

            char[] arg_separator = { '=' };
            foreach( string arg in args )
            {
                string[] command = arg.Split( arg_separator, 2 );

                switch( command[0] )
                {
                case "--search":
                    searchPath = command[1];
                    break;
                case "--uid":
                    userName = command[1];
                    break;
                case "--pwd":
                    userPassword = command[1];
                    break;
                case "--namespace":
                    userNamespace = command[1];
                    break;
                default:
                    throw new ApplicationException( "Unknown argument: " + arg );
                }
            }

            // Concatenate the read filter to the searchPath this way we
            // ask CM to only return the objects we have read acces on.
            searchPath = searchPath + "[permission('read')]";

            // Create the ReportNet connection object.
            Console.WriteLine( "Creating CognosReportNetService..." );
            CognosReportNetService crn = new CognosReportNetService();
            crn.Url = "http://localhost:8080/series8/cgi-bin/cognos.cgi";

            // Add the authentication information, if any.
            //
            // Another option would be to use the logon() methods...
            CAM cam = new CAM();
            cam.action = "logonAs";

            hdrSession header = new hdrSession();
            if( userName != null )
            {
                formFieldVar[] vars = new formFieldVar[3];

                vars[0] = new formFieldVar();
                vars[0].name = "CAMNamespace";
                vars[0].value = userNamespace;
                vars[0].format = formatEnum.not_encrypted;

                vars[1] = new formFieldVar();
                vars[1].name = "CAMUsername";
                vars[1].value = userName;
                vars[1].format = formatEnum.not_encrypted;

                vars[2] = new formFieldVar();
                vars[2].name = "CAMPassword";
                vars[2].value = userPassword;
                vars[2].format = formatEnum.not_encrypted;

                header.formFieldVars = vars;
            }
            else
            {
                cam.action = "logon";
            }

            biBusHeader bibus = new biBusHeader();
            bibus.CAM = cam;
            bibus.hdrSession = header;

            crn.biBusHeaderValue = bibus;

            try

            {

                propEnum[] props = new propEnum[] { propEnum.searchPath,
                                                      propEnum.defaultName, propEnum.policies,
                                                      propEnum.permissions, propEnum.members };

                sort[] s = new sort[]{ new sort() };

                s[0].order = orderEnum.ascending;

                s[0].propName = propEnum.defaultName;

                queryOptions qo = new queryOptions();
                // Look for all of the reports.

                Console.WriteLine( "\nReports:\n" );

                baseClass[] bc = crn.query( "/content//report", props, s, qo );

                if( bc.Length > 0 )
                {
                    foreach( baseClass report_item in bc )

                    {
                        Console.WriteLine( "  {0}", report_item.searchPath.value);
                        policy[] p = report_item.policies.value;
                        if (p.Length > 0)
                        {
                            foreach( policy pol in p )
                            {
                                Console.WriteLine( "  {0}", pol.securityObject.searchPath.value);
                                permission[] perm = pol.permissions;
                                foreach( permission prm in perm )
                                    Console.WriteLine( "  {0}   {1}",prm.name, prm.access.ToString());
                            }
                        }
                    }
                }
            }

            catch( System.Web.Services.Protocols.SoapHeaderException ex )
            {
                Console.WriteLine( "SOAP Header Exception:" );
                Console.WriteLine( "Actor  : " + ex.Actor );
                Console.WriteLine( "Code   : " + ex.Code );
                Console.WriteLine( "Detail : " + ex.Detail );
                Console.WriteLine( "Message: " + ex.Message );

                // We can access the SOAP fault information through
                // the ex.Detail property.
                System.Xml.XmlNode node = ex.Detail;
                Console.WriteLine( node.OuterXml );
            }
            catch( System.Web.Services.Protocols.SoapException ex )
            {
                Console.WriteLine( "SOAP Exception:" );
                Console.WriteLine( "Actor  : " + ex.Actor );
                Console.WriteLine( "Code   : " + ex.Code );
                Console.WriteLine( "Detail : " + ex.Detail );
                Console.WriteLine( "Message: " + ex.Message );

                // We can access the SOAP fault information through
                // the ex.Detail property.
                System.Xml.XmlNode node = ex.Detail;
                Console.WriteLine( node.OuterXml );
            }
        }
        private bool turnOffMyFolderContentDuration(int[] cellCount)
        {
            Microsoft.Office.Interop.Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel._Workbook oWB;
            Microsoft.Office.Interop.Excel._Worksheet oSheet;
            Microsoft.Office.Interop.Excel.Range oRange;

            // Create Excel Application
            oXL.Visible = true;

            //Get a new workbook.
            oWB = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
            oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;

            string camid = "//account"; //this is the search path for all user accounts
            //string camid = "CAMID(\"ADS:u:cn=miller\\, barret,ou=new,ou=groups,ou=general,ou=tyson team members\")";
            string userSearchPaths = "";
            // We will display My Folders and My Pages for all users in namespace
            propEnum[] props = new propEnum[]{propEnum.searchPath,
                    propEnum.objectClass,propEnum.defaultName,propEnum.portalPages,
                    propEnum.ancestors, propEnum.owner};

            // Same query options used for all calls
            queryOptions qo = new queryOptions();
            // Create sort object
            sort[] accountSort = new sort[] { new sort() };
            accountSort[0].order = orderEnum.ascending;
            accountSort[0].propName = propEnum.defaultName;

            //query for all accounts
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            spMulti.Value = camid;
            baseClass[] bc = cCMS.query(spMulti, props, accountSort, qo);

            if (bc != null && bc.Length > 0)
            {
                // Set different properties to grab for the reports, queries, or report views
                props = new propEnum[]{propEnum.searchPath, propEnum.defaultName,
                                       propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                       propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled, propEnum.user,
                                       propEnum.retentions };
                // Declare properties to retrieve for package object internal to report object
                refProp packageProps = new refProp();
                packageProps.refPropName = propEnum.metadataModelPackage;
                packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };
                // Properties used to get base class information if the object is a report view
                refProp reportProps = new refProp();
                reportProps.refPropName = propEnum.@base;
                reportProps.properties = new propEnum[] { propEnum.metadataModelPackage, propEnum.storeID,
                                                      propEnum.searchPath, propEnum.disabled };

                qo.refProps = new refProp[] { packageProps, reportProps };

                retentionRuleArrayProp retentionRules = new retentionRuleArrayProp();
                retentionRule[] outputRule = new retentionRule[1];
                outputRule[0] = new retentionRule();
                outputRule[0].objectClass = classEnum.reportVersion;
                outputRule[0].prop = propEnum.creationTime;
                outputRule[0].maxDuration = null;
                //outputRule[0].maxObjects = "1";
                List<baseClass> turnOffDurationList = new List<baseClass>();

                for (int i = 0; i < bc.Length; i++)
                {
                    //Query the Content Store for all objects in My Folders for user bc[i]
                    userSearchPaths = bc[i].searchPath.value + "/folder[@name='My Folders']//report"; /*+
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//query |" +
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//reportView";*/

                    spMulti.Value = userSearchPaths;
                    baseClass[] contents = cCMS.query(spMulti, props, new sort[] { }, qo);
                    if (contents != null && contents.Length > 0)
                    {
                        //Disable Duration all objects in My Folders for user bc[i]
                        for (int j = 0; j < contents.Length; j++)
                        {
                            /*
                             * Check whether object is a more specific type (e.g. query or report)
                             */
                            if (contents[j] is report)
                            {
                                cognosdotnet_2_0.report report = (cognosdotnet_2_0.report)contents[j];
                                foreach (retentionRule rule in report.retentions.value)
                                {
                                    // If the rule is for the type 'reportVersion' and has the duration set
                                    if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                                    {
                                        // Output the name
                                        oSheet.Cells[cellCount[0], cellCount[1]] = report.defaultName.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        //Output the path
                                        oSheet.Cells[cellCount[0], cellCount[1]] = report.searchPath.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        oSheet.Cells[cellCount[0], cellCount[1]] = bc[i].defaultName.value;
                                        //Reset the column count, and increment the row count
                                        cellCount[1] = 1;
                                        cellCount[0]++;
                                        report.retentions = retentionRules;
                                        turnOffDurationList.Add(contents[j]);
                                    }
                                }

                            }
                            else if (contents[j] is query)
                            {
                                cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)contents[j];
                                foreach (retentionRule rule in query.retentions.value)
                                {
                                    // If the rule is for the type 'reportVersion' and has the duration set
                                    if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                                    {
                                        // Output the name
                                        oSheet.Cells[cellCount[0], cellCount[1]] = query.defaultName.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        //Output the path
                                        oSheet.Cells[cellCount[0], cellCount[1]] = query.searchPath.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        oSheet.Cells[cellCount[0], cellCount[1]] = bc[i].defaultName.value;
                                        //Reset the column count, and increment the row count
                                        cellCount[1] = 1;
                                        cellCount[0]++;
                                        query.retentions = retentionRules;
                                        turnOffDurationList.Add(contents[j]);
                                    }
                                }
                            }
                            else if (contents[j] is reportView)
                            {
                                cognosdotnet_2_0.reportView reportView = (cognosdotnet_2_0.reportView)contents[j];
                                foreach (retentionRule rule in reportView.retentions.value)
                                {
                                    // If the rule is for the type 'reportVersion' and has the duration set
                                    if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                                    {
                                        // Output the name
                                        oSheet.Cells[cellCount[0], cellCount[1]] = reportView.defaultName.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        //Output the path
                                        oSheet.Cells[cellCount[0], cellCount[1]] = reportView.searchPath.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        oSheet.Cells[cellCount[0], cellCount[1]] = bc[i].defaultName.value;
                                        //Reset the column count, and increment the row count
                                        cellCount[1] = 1;
                                        cellCount[0]++;
                                        reportView.retentions = retentionRules;
                                        turnOffDurationList.Add(contents[j]);
                                    }
                                }
                            }
                        }
                        if (turnOffDurationList.Count > 0)
                        {
                            cCMS.update(turnOffDurationList.ToArray(), new updateOptions());
                        }
                    }
                }
            }
            return true;
        }
        private bool turnOffAndReport_QueryDuration(ref _Worksheet oSheet, int[] cellCount)
        {
            if (cCMS == null)
            {
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                      propEnum.retentions, propEnum.owner };

            // Properties used to get account class information for the owner
            refProp ownerProps = new refProp();
            ownerProps.refPropName = propEnum.owner;
            ownerProps.properties = new propEnum[] { propEnum.searchPath, propEnum.defaultName };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { ownerProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject objectsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            objectsPath.Value = "//query";
            //objectsPath.Value = "/content/package[@name='National Accounts']/report[@name='(0226) NA Ebit by Customer/Minor Line - Combined']";
            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(objectsPath, reportProps, reportSort, qo);

            retentionRuleArrayProp retentionRules = new retentionRuleArrayProp();
            retentionRule[] outputRule = new retentionRule[1];
            outputRule[0] = new retentionRule();
            outputRule[0].objectClass = classEnum.reportVersion;
            outputRule[0].prop = propEnum.creationTime;
            outputRule[0].maxDuration = null;
            //outputRule[0].maxObjects = "1";
            List<baseClass> turnOffDurationList = new List<baseClass>();

            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    retentionRules.value = outputRule;
                    // Cast base class object to more specific report object for access to more
                    // properties
                    if (report_item is query)
                    {
                        cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)report_item;
                        foreach (retentionRule rule in query.retentions.value)
                        {
                            // If the rule is for the type 'reportVersion' and has the duration set
                            if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                            {
                                // Output the name
                                oSheet.Cells[cellCount[0], cellCount[1]] = query.defaultName.value;
                                //Increment the column count
                                cellCount[1]++;
                                //Output the path
                                oSheet.Cells[cellCount[0], cellCount[1]] = query.searchPath.value;
                                //Increment the column count
                                cellCount[1]++;
                                if (query.owner.value == null)
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = "unknown";
                                }
                                else
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = query.owner.value[0].defaultName.value;
                                }
                                //Reset the column count, and increment the row count
                                cellCount[1] = 1;
                                cellCount[0]++;
                                query.retentions = retentionRules;
                                turnOffDurationList.Add(report_item);
                            }
                        }
                    }
                }
                if (turnOffDurationList.Count > 0)
                {
                    cCMS.update(turnOffDurationList.ToArray(), new updateOptions());
                }
            }
            return true;
        }
        private bool turnOffReportViewDuration(int[] cellCount)
        {
            Microsoft.Office.Interop.Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel._Workbook oWB;
            Microsoft.Office.Interop.Excel._Worksheet oSheet;
            Microsoft.Office.Interop.Excel.Range oRange;

            // Create Excel Application
            oXL.Visible = true;

            //Get a new workbook.
            oWB = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
            oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;

            if (cCMS == null)
            {
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                      propEnum.retentions, propEnum.owner };

            // Properties used to get account class information for the owner
            refProp ownerProps = new refProp();
            ownerProps.refPropName = propEnum.owner;
            ownerProps.properties = new propEnum[] { propEnum.searchPath, propEnum.defaultName };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { ownerProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject objectsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            objectsPath.Value = "//reportView";
            //objectsPath.Value = "/content/package[@name='National Accounts']/report[@name='(0226) NA Ebit by Customer/Minor Line - Combined']";
            //objectsPath.Value = "CAMID(\"ADS:u:cn=miller\\, barret,ou=new,ou=groups,ou=general,ou=tyson team members\")/folder[@name='My Folders']/reportView[@name='Report View of (0224) Combined Sales']";
            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(objectsPath, reportProps, reportSort, qo);

            retentionRuleArrayProp retentionRules = new retentionRuleArrayProp();
            retentionRule[] outputRule = new retentionRule[1];
            outputRule[0] = new retentionRule();
            outputRule[0].objectClass = classEnum.reportVersion;
            outputRule[0].prop = propEnum.creationTime;
            outputRule[0].maxDuration = null;
            //outputRule[0].maxObjects = "1";
            retentionRules.value = outputRule;
            List<baseClass> turnOffDurationList = new List<baseClass>();

            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    if (report_item is reportView)
                    {
                        cognosdotnet_2_0.reportView reportv = (cognosdotnet_2_0.reportView)report_item;
                        foreach (retentionRule rule in reportv.retentions.value)
                        {
                            // If the rule is for the type 'reportVersion' and has the duration set
                            if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                            {
                                // Output the name
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.defaultName.value;
                                //Increment the column count
                                cellCount[1]++;
                                //Output the path
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.searchPath.value;
                                //Increment the column count
                                cellCount[1]++;
                                if (reportv.owner.value == null)
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = "unknown";
                                }
                                else
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = reportv.owner.value[0].defaultName.value;
                                }
                                //Reset the column count, and increment the row count
                                cellCount[1] = 1;
                                cellCount[0]++;
                                reportv.retentions = retentionRules;
                                turnOffDurationList.Add(report_item);
                            }
                        }
                    }
                }
                if (turnOffDurationList.Count > 0)
                {
                    cCMS.update(turnOffDurationList.ToArray(), new updateOptions());
                }
            }
            return true;
        }
        private bool getObjectsForPackage(contentManagerService1 cCMS, ref List<CogObject> objects, string cogVersion, 
                                          string basePath, string pathToObjectsInPackage)
        {
            if (cCMS == null)
            {
                objects = null;
                return false;
            }
            // Declare query properties array for reports, queries and for users
            propEnum[] cogProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                propEnum.owner, propEnum.storeID, propEnum.connectionString,
                                                propEnum.metadataModelPackage, propEnum.user,propEnum.actualExecutionTime,
                                                propEnum.policies};

            // Declare sort properties for reports
            sort[] cogSort = new sort[] { new sort() };
            cogSort[0].order = orderEnum.ascending;
            cogSort[0].propName = propEnum.defaultName;

            // Same query options used for all calls
            queryOptions qo = new queryOptions();

            searchPathMultipleObject objectsPath = new searchPathMultipleObject();

            // Declare search path for reports and for a single user, based on CAMID
            objectsPath.Value = pathToObjectsInPackage;

            // Run query to get all objects in package. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(objectsPath, cogProps, cogSort, qo);
            if (bc.Length > 0)
            {
                foreach (baseClass cog_item in bc)
                {

                    CogObject cog = new CogObject();
                    cog.ID = cog_item.storeID.value.Value;
                    cog.Name = cog_item.defaultName.value;
                    cog.AddAttribute("ID", cog.ID);
                    cog.AddAttribute("Name", cog_item.defaultName.value);
                    cog.AddAttribute("Version", cogVersion);
                    cog.AddAttribute("URL", basePath + cog_item.searchPath.value);
                    addSecurityPolicies(ref cog, cog_item);

                    /* Get owner/author information for this object
                     */
                    if (cog_item.owner.value != null)
                    {
                        getUserAccount(cCMS, cog_item.owner.value[0].searchPath.value, ref cog);
                        cog.AddAttribute("Author_CAMID", cog_item.owner.value[0].searchPath.value);
                    }
                    else
                    {
                        cog.AddAttribute("Author_CAMID", "Unknown");
                    }

                    /*
                     * Check whether object is a more specific type (e.g. query or report)
                     */
                    if (cog_item is report)
                    {
                        // Cast base class object to more specific report object for access to more
                        // properties
                        cognosdotnet_2_0.report report = (cognosdotnet_2_0.report)cog_item;
                        cog.AddAttribute("Type", "Report");
                        // Make sure package or Package is not null
                        if (report.metadataModelPackage.value != null)
                        {
                            cog.AddAttribute("Package_Path", report.metadataModelPackage.value[0].searchPath.value);
                            cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                        }
                        else
                        {
                            cog.AddAttribute("Package_Path", "null");
                            cog.AddAttribute("Package_Name", "null");
                        }
                    }
                    else if (cog_item is query)
                    {
                        // Cast base class object to more specific report object for access to more
                        // properties
                        cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)cog_item;
                        cog.AddAttribute("Type", "Query");
                        // Make sure package or Package is not null
                        if (query.metadataModelPackage.value != null)
                        {
                            cog.AddAttribute("Package_Path", query.metadataModelPackage.value[0].searchPath.value);
                            cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                        }
                        else
                        {
                            cog.AddAttribute("Package_Path", "null");
                            cog.AddAttribute("Package_Name", "null");
                        }
                    }
                    else if (cog_item is reportView)
                    {
                        // Cast base class object to more specific report object for access to more
                        // properties
                        cognosdotnet_2_0.reportView reportView = (cognosdotnet_2_0.reportView)cog_item;
                        cog.AddAttribute("Type", "ReportView");
                        // Make sure package or Package is not null
                        if (reportView.packageBase != null)
                        {
                            cog.AddAttribute("Package_Path", reportView.packageBase.value);
                            cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                        }
                        else
                        {
                            cog.AddAttribute("Package_Path", "null");
                            cog.AddAttribute("Package_Name", "null");
                        }
                    }

                    getSubElements(cCMS, cog_item.searchPath.value, ref cog);

                    // Add the object to the list
                    objects.Add(cog);
                }
            }
            return true;
        }
Example #32
0
        public IActionResult Dashboard()
        {
            if (HttpContext.Session.GetString("Name") != null)
            {
                List <Plan> OldPlan = dbContext.Planes
                                      .Include(w => w.Guests)
                                      .Include(w => w.Creator)
                                      .ToList();

                List <Plan> Plans = new List <Plan>();
                List <Plan> P     = new List <Plan>();
                foreach (Plan x in OldPlan)
                {
                    if (DateTime.ParseExact(x.Date, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).Add(DateTime.ParseExact(x.Time, "hh:mm tt", System.Globalization.CultureInfo.InvariantCulture).TimeOfDay) >= DateTime.Now)
                    {
                        P.Add(x);
                    }
                }
                /////////////////
                List <sort> forsort = new List <sort>();
                foreach (Plan x in P)
                {
                    sort sort = new sort();
                    sort.PlanId    = x.PlanId;
                    sort.TotalTime = DateTime.ParseExact(x.Date, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).Add(DateTime.ParseExact(x.Time, "hh:mm tt", System.Globalization.CultureInfo.InvariantCulture).TimeOfDay);
                    forsort.Add(sort);
                    System.Console.WriteLine("id:" + sort.PlanId + "time" + sort.TotalTime);
                }
                ;

                for (int v = forsort.Count - 1; v > 0; v--)
                {
                    for (int z = forsort.Count - 1; z > 0; z--)
                    {
                        if (forsort[z].TotalTime > forsort[z - 1].TotalTime)
                        {
                            sort temp = forsort[z];
                            forsort[z]     = forsort[z - 1];
                            forsort[z - 1] = temp;
                        }
                    }
                }

                for (int o = forsort.Count - 1; o >= 0; o--)
                {
                    foreach (Plan y in P)
                    {
                        if (y.PlanId == forsort[o].PlanId)
                        {
                            Plans.Add(y);
                            System.Console.WriteLine("id:" + y.PlanId + "time" + y.Date + y.Time);
                        }
                    }
                }
                /////////////
                User user = dbContext.Useres
                            .Include(u => u.Join)
                            .FirstOrDefault(u => u.UserId == (int)HttpContext.Session.GetInt32("id"));

                Dashboard_wrapper Dashboard_wrapper = new Dashboard_wrapper
                {
                    AllPlan = Plans,
                    User    = user
                };
                return(View(Dashboard_wrapper));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        public PagingList <EmailTransferUser> GetAll(pagination pagination, sort sort, string search, string search_operator, string filter)
        {
            dynamic searchFilter = string.Empty;
            var     operater     = string.IsNullOrEmpty(search_operator) ? null : JObject.Parse(search_operator);
            IQueryable <EmailTransferUser> query = _context.Set <EmailTransferUser>();

            if (!string.IsNullOrEmpty(filter) && filter.Length > 2)
            {
                searchFilter = JObject.Parse(filter);
                foreach (var _filter in searchFilter)
                {
                    string fitlterstr = (string)_filter.Value;
                    var    result     = fitlterstr.Split(',').Where(r => !string.IsNullOrEmpty(r)).ToList();
                    if (result.Count() > 1)
                    {
                        int count = 0;
                        result.ForEach(s =>
                        {
                            string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).FirstOrDefault().Value : "eq";

                            switch ((string)_filter.Key)
                            {
                            case "":
                                //query = query.Where(a=>a.Sector == Se)
                                break;

                            default:
                                var tempQuery = query;
                                query         = count == 0 ? query.Where <EmailTransferUser>(
                                    (object)_filter.Key, (object)s,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)) :
                                                query.Concat <EmailTransferUser>(tempQuery.Where <EmailTransferUser>(
                                                                                     (object)_filter.Key, (object)s,
                                                                                     (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)));
                                count = count + 1;
                                break;
                            }
                        });
                    }

                    else if (!string.IsNullOrEmpty(_filter.Value))
                    {
                        string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _filter.Key).FirstOrDefault().Value : "eq";
                        query = query.Where <EmailTransferUser>(
                            (object)_filter.Key, (object)result.FirstOrDefault(),
                            (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                    }
                }
            }
            if (!string.IsNullOrEmpty(search) && search.Length > 2)
            {
                searchFilter = JObject.Parse(search);
                foreach (var _search in searchFilter)
                {
                    if (!string.IsNullOrEmpty(_search.Value))
                    {
                        string op = operater.Descendants().OfType <JProperty>().Where(p => p.Name == _search.Key).Count() > 0 ? (string)operater.Descendants().OfType <JProperty>().Where(p => p.Name == _search.Key).FirstOrDefault().Value : "eq";
                        string checkCurrentKey = Convert.ToString(_search.Value);
                        if (checkCurrentKey.Split(',').Count() > 1)
                        {
                            int i;
                            if (!(int.TryParse(checkCurrentKey.Split(',')[0].ToString(), out i)))
                            {
                                query = query.Where <EmailTransferUser>(
                                    (object)_search.Key, (object)_search.Value,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                            }
                            else
                            {
                                int count = 0;
                                foreach (var _tempSearchKey in checkCurrentKey.Split(',').ToList())
                                {
                                    if (!string.IsNullOrEmpty(_tempSearchKey))
                                    {
                                        var tempQuery = query;
                                        query = count == 0 ? query.Where <EmailTransferUser>(
                                            (object)_search.Key, (object)_tempSearchKey,
                                            (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)) :
                                                query.Concat <EmailTransferUser>(tempQuery.Where <EmailTransferUser>(
                                                                                     (object)_search.Key, (object)_tempSearchKey,
                                                                                     (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op)));
                                        count = count + 1;
                                    }
                                }
                            }
                        }
                        else
                        {
                            string strFk = (string)_search.Value;
                            switch ((string)_search.Key)
                            {
                            default:
                                query = query.Where <EmailTransferUser>(
                                    (object)_search.Key, (object)_search.Value,
                                    (WhereOperation)StringEnum.Parse(typeof(WhereOperation), op));
                                break;
                            }
                        }
                    }
                }
            }
            query = query.OrderBy <EmailTransferUser>(sort.predicate, !sort.reverse ? "asc" : "");
            return(new PagingList <EmailTransferUser>(query, pagination.start / 10, pagination.Count == 0 ? 10 : pagination.Count));
        }
        private bool getQueriesForPackage(contentManagerService1 cCMS, ref List<CogObject> queries, string cogVersion,
                                          string baseQueryPath, string pathToQueriesInPackage)
        {
            if (cCMS == null)
            {
                queries = null;
                return false;
            }

            // Same query options used for all calls
            queryOptions qo = new queryOptions();

            //queries
            propEnum[] queryProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                propEnum.owner, propEnum.storeID, propEnum.connectionString,
                                                propEnum.metadataModelPackage};
            //users
            propEnum[] userProps = new propEnum[] { propEnum.userName, propEnum.name, propEnum.user };

            //queries
            sort[] querySort = new sort[] { new sort() };
            querySort[0].order = orderEnum.ascending;
            querySort[0].propName = propEnum.defaultName;
            //users
            sort[] userSort = new sort[] { new sort() };
            userSort[0].order = orderEnum.ascending;
            userSort[0].propName = propEnum.userName;

            searchPathMultipleObject userPath = new searchPathMultipleObject();
            searchPathMultipleObject queriesPath = new searchPathMultipleObject();
            queriesPath.Value = pathToQueriesInPackage;

            // Make call to get all queries. Get each author for each query during this process
            // by making a separate call, based on CAMID; the same as above when pulling the reports.
            baseClass[] bcQueries = cCMS.query(queriesPath, queryProps, querySort, qo);
            if (bcQueries.Length > 0)
            {
                foreach (baseClass query_item in bcQueries)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)query_item;
                    CogObject qry = new CogObject();
                    qry.ID = query_item.storeID.value.Value;
                    qry.AddAttribute("ID", qry.ID);
                    qry.AddAttribute("Name", query_item.defaultName.value);
                    qry.AddAttribute("Type", "AdHoc");
                    qry.AddAttribute("Package_Path", query.metadataModelPackage.value[0].searchPath.value);
                    qry.AddAttribute("Package_Name", getPackageName(qry.getAttributeValue("Package_Path")));

                    if (query_item.owner.value != null)
                    {
                        getUserAccount(cCMS, query_item.owner.value[0].searchPath.value, ref qry);
                        qry.AddAttribute("Author_CAMID", query_item.owner.value[0].searchPath.value);
                    }
                    else
                    {
                        qry.AddAttribute("Author_CAMID", "Unknown");
                    }
                    qry.AddAttribute("Version", cogVersion);
                    qry.AddAttribute("URL", baseQueryPath + query_item.searchPath.value);
                    queries.Add(qry);
                }
            }
            else
            {
                queries = null;
            }
            return true;
        }
        private void getSubElements(contentManagerService1 cCMS, string objectSearchPath, ref CogObject cog)
        {
            searchPathMultipleObject subElementPath = new searchPathMultipleObject();
            subElementPath.Value = objectSearchPath + "/*";

            // Same query options used for all calls
            queryOptions qo = new queryOptions();

            //users
            propEnum[] subElementProps = new propEnum[] { propEnum.storeID, propEnum.searchPath, propEnum.defaultName,
                                                          propEnum.user, propEnum.status, propEnum.requestedExecutionTime,
                                                          propEnum.actualExecutionTime, propEnum.actualCompletionTime,
                                                          propEnum.eventID, propEnum.ownerEventID, propEnum.asOfTime,
                                                          propEnum.canBurst, propEnum.contact, propEnum.contactEMail,
                                                          propEnum.metadataModel, propEnum.metadataModelPackage,
                                                          propEnum.options, propEnum.parameters, propEnum.runOptions,
                                                          propEnum.serverGroup, propEnum.specification, propEnum.active,
                                                          propEnum.credential, propEnum.dailyPeriod, propEnum.endDate,
                                                          propEnum.endType, propEnum.everyNPeriods, propEnum.startDate,
                                                          propEnum.taskID, propEnum.timeZoneID, propEnum.triggerName, propEnum.type,
                                                          propEnum.weeklyFriday, propEnum.weeklyMonday, propEnum.weeklySaturday,
                                                          propEnum.weeklySunday, propEnum.weeklyThursday, propEnum.weeklyTuesday,
                                                          propEnum.weeklyWednesday, propEnum.yearlyAbsoluteDay, propEnum.yearlyAbsoluteMonth,
                                                          propEnum.yearlyRelativeDay, propEnum.yearlyRelativeWeek, propEnum.ancestors,
                                                          propEnum.creationTime, propEnum.modificationTime, propEnum.name, propEnum.usage,
                                                          propEnum.version};
            sort[] subElementSort = new sort[] { new sort() };
            subElementSort[0].order = orderEnum.ascending;
            subElementSort[0].propName = propEnum.defaultName;

            baseClass[] bc = cCMS.query(subElementPath, subElementProps, subElementSort, qo);
            if (bc.Length > 0)
            {
                foreach (baseClass item in bc)
                {
                    CogObject cogItem = new CogObject();

                    if (item is history)
                    {
                        cognosdotnet_2_0.history hist = (history)item;
                        addHistoryAttributes(cogItem, hist);

                    }
                    else if (item is schedule)
                    {
                        cognosdotnet_2_0.schedule sched = (schedule)item;
                        cog.AddAttribute("ActiveSchedule", sched.active.value.ToString());
                        addScheduleAttributes(ref cogItem, sched);

                    }
                    else if (item is reportVersion)

                    {
                        cognosdotnet_2_0.reportVersion rver = (reportVersion)item;
                        addReportVersionAttributes(ref cogItem, rver);
                    }

                    cog.addSubElement(cogItem);
                }
            }
        }
Example #36
0
        static void Main(string[] args)
        {
            DanhSachHangHoa DSHH = new DanhSachHangHoa();
            QuanLyHangHoa   ql   = new QuanLyHangHoa();

            while (true)
            {
                Console.Clear();
                Console.WriteLine("====================== DANH SACH CHUC NANG ======================");
                Console.WriteLine("Nhap {0} de Thoat", (int)Menu.Thoat);
                Console.WriteLine("Nhap {0} de Nhap du lieu tu file", (int)Menu.NhapTuFile);
                Console.WriteLine("Nhap {0} de Xuat file du lieu", (int)Menu.Xuat);
                Console.WriteLine("Nhap {0} de In danh sach mat hang co so luong tren 10", (int)Menu.InDSMHSLTren10);
                Console.WriteLine("Nhap {0} de In danh sach mat hang co ten la TAI NGHE", (int)Menu.XuatDSTaiNghe);
                Console.WriteLine("Nhap {0} de Tim mat hang co tong so tien cao nhat", (int)Menu.TimMatHangCoTongTienCaoNhat);
                Console.WriteLine("Nhap {0} de Mat Hang co Thanh Tien cao nhat", (int)Menu.MatHangThanhTienMax);
                Console.WriteLine("Nhap {0} de Tim gia lon nhat cua mat hang X", (int)Menu.TimMaxMatHangX);
                Console.WriteLine("Nhap {0} de Sap xep", (int)Menu.SapXep);
                Console.WriteLine("Nhap {0} de xoa hang hoa co mo ta X", (int)Menu.XoaHangHoaMoTaX);

                Menu nhap = (Menu)int.Parse(Console.ReadLine());
                switch (nhap)
                {
                case Menu.Thoat:
                    return;

                case Menu.NhapTuFile:
                {
                    Console.Clear();
                    DSHH.NhapThuFile();
                    DSHH.Xuat();
                }
                break;

                case Menu.Xuat:
                {
                    Console.Clear();
                    DSHH.Xuat();
                }
                break;

                case Menu.InDSMHSLTren10:
                {
                    Console.Clear();
                    ql.InDSHHSLMuoi(DSHH).Xuat();
                }
                break;

                case Menu.XuatDSTaiNghe:
                {
                    Console.Clear();
                    ql.TimDSTaiNghe(DSHH).Xuat();
                }
                break;

                case Menu.TimMatHangCoTongTienCaoNhat:
                {
                    Console.Clear();
                    ql.TimMHTongTienMax(DSHH);
                } break;

                case Menu.MatHangThanhTienMax:
                {
                    Console.Clear();
                    ql.TimMatHangThanhTienMax(DSHH).Xuat();
                } break;

                case Menu.TimMaxMatHangX:
                {
                    Console.Clear();
                    while (true)
                    {
                        Console.WriteLine("Xin moi nhap ten hang hoa gom (MAY TINH, QUAN AO, GIAY, TAI NGHE)");
                        string ten = Console.ReadLine();
                        try
                        {
                            ql.TimDSMatHangX(DSHH, ten).Xuat();
                            Console.WriteLine("Hang hoa Thanh tien cao nhat mat hang {0} la: ", ten + "\n");
                            ql.TimSoTienMaxMHX(DSHH, ten).Xuat();
                            break;
                        }
                        catch
                        {
                            Console.WriteLine("Mat hang vua nhap khong ton tai, xin moi nhap lai!!");
                        }
                    }
                } break;

                case Menu.SapXep:
                {
                    Console.Clear();
                    Console.WriteLine("Nhap {0} de Sap xep tang theo thanh tien!", (int)sort.TangTheoTien);
                    Console.WriteLine("Nhap {0} de Sap xep giam theo thanh tien!", (int)sort.GianTheoTien);
                    Console.WriteLine("Nhap {0} de Sap xep tang theo so luong", (int)sort.TangSL);
                    Console.WriteLine("Nhap {0} de sap xep tang theo ten", (int)sort.SapXepTangTen);
                    Console.WriteLine("Nhap {0} de Sap xep tang theo chieu dai ten", (int)sort.SapXepTangTheoChieuDaiTen);

                    sort n = (sort)int.Parse(Console.ReadLine());
                    switch (n)
                    {
                    case sort.TangTheoTien:
                    {
                        Console.Clear();
                        ql.SapXep(DSHH).Xuat();
                    }
                    break;

                    case sort.GianTheoTien:
                    {
                        Console.Clear();
                        ql.SapXepGiam(DSHH).Xuat();
                    }
                    break;

                    case sort.TangSL:
                    {
                        Console.Clear();
                        ql.SapXepTangSL(DSHH).Xuat();
                    } break;

                    case sort.SapXepTangTen:
                    {
                        Console.Clear();
                        ql.SapXepTheoTen(DSHH).Xuat();
                    } break;

                    case sort.SapXepTangTheoChieuDaiTen:
                    {
                        Console.Clear();
                        ql.SapXepTangChieuDaiTen(DSHH).Xuat();
                    } break;

                    default:
                        break;
                    }
                } break;

                case Menu.XoaHangHoaMoTaX:
                {
                    Console.Clear();
                    DSHH.Xuat();
                    string ten;
                    Console.WriteLine("Xin moi nhap ten hang hoa: ");
                    ten = Console.ReadLine();
                    ql.XoaHangHoaX(DSHH, ten);
                    DSHH.Xuat();
                } break;

                default:
                    break;
                }
                Console.ReadLine();
            }

            Console.ReadLine();
        }