private void ConnectToTfs(CommandLineOptions options)
        {
            Log(string.Format(CultureInfo.InvariantCulture, "Connecting to Tfs at {0}...", options.TfsServerUrl));

            // Connect to Team Foundation Server
            Uri tfsUri = new Uri(options.TfsServerUrl);
            _teamProjectCollection = new TfsTeamProjectCollection(tfsUri);

            _linkService = _teamProjectCollection.GetService<TswaClientHyperlinkService>();
            _workItemStore = _teamProjectCollection.GetService<WorkItemStore>();
            _tfsProject = _workItemStore.Projects[options.TfsProject];

            if (options.TfsQuery == null)
            {
                _tfsQueryFolder = _tfsProject.QueryHierarchy[options.TfsQueryHierarchy] as QueryFolder;
                _tfsQueryItem = _tfsQueryFolder[options.TfsQueryName];
            }
            else
            {
                _tfsQueryItem = options.TfsQuery;
            }
        }
        public void IdentifyPoint(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint)
        {
            if (config.IdentifyURL == "")
            return;

              if (config.IdentifyLayerCount == 0)
            return;

              if (config.UseQueryIdentify)
              {
            _dataItems = new List<DataItem>();

            GeometryService geometryServicePointSnap = new GeometryService(config.GeometryServerUrl);
            if (geometryServicePointSnap == null)
              return;

            QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);

            geometryServicePointSnap.BufferCompleted += GeometryService_IdentifyPointBufferCompleted;
            geometryServicePointSnap.Failed += GeometryService_Failed;
            geometryServicePointSnap.CancelAsync();

            SimpleMarkerSymbol defaultSymbolMarker = new SimpleMarkerSymbol()
            {
              Color = System.Windows.Media.Brushes.Black, Size = 8,
              Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
            };

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = defaultSymbolMarker as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = clickPoint;

            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
              BufferSpatialReference = ParcelMap.SpatialReference,
              OutSpatialReference = ParcelMap.SpatialReference,
              Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(config.SnapTolerance * config.SpatialReferenceUnitsPerMeter);
            bufferParams.Features.Add(clickGraphic);
            geometryServicePointSnap.BufferAsync(bufferParams, queryItem);
              }
              else
              {
            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
              Geometry = clickPoint,
              MapExtent = ParcelMap.Extent,
              Width = (int)ParcelMap.ActualWidth,
              Height = (int)ParcelMap.ActualHeight,
              LayerOption = LayerOption.visible,
              SpatialReference = ParcelMap.SpatialReference
            };

            // For performance, we allow certain layers to be only identified.
            if (config.IdentifyLayerIDs != null)
              foreach (int id in config.IdentifyLayerIDs)
            identifyParams.LayerIds.Add(id);

            IdentifyTask identifyTask = new IdentifyTask(config.IdentifyURL);
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;

            QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);
            identifyTask.ExecuteAsync(identifyParams, queryItem);
              }
        }
 public TfsQuery(QueryItem query, string currentIteration)
 {
     Query            = query;
     CurrentIteration = currentIteration;
 }
Beispiel #4
0
        private static void V1()
        {
            //Initialize TFS Server object
            TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(ConfigurationManager.AppSettings["TfsServer"]));

            //Get the catalog of team project collections
            CatalogNode catalogNode = configurationServer.CatalogNode;
            //Get all CatalogNodes which are ProjectCollection
            ReadOnlyCollection <CatalogNode> tpcNodes = catalogNode.QueryChildren(new Guid[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            //Get InstanceId of a ProjectCollection
            Guid tpcId = Guid.Empty;

            foreach (CatalogNode tpcNode in tpcNodes)
            {
                tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
                break;
            }
            Workspace currentWorkspace = null;
            //string localPath = @"C:\LOS_DEV";
            string URL = "http://sptserver.ists.com.vn:8080/tfs/iLendingPro";

            //WriteLine($"Local Path: {localPath}");
            System.Diagnostics.Debug.WriteLine($"Project Url: {URL}");
            TfsTeamProjectCollection projectCollection = new TfsTeamProjectCollection(new Uri(URL));

            //Fill list of projects in a local variable
            //TfsTeamProjectCollection projectCollection = configurationServer.GetTeamProjectCollection(tpcId);
            projectCollection.Authenticate();

            //Get WorkItem Tracking client for workitem collection for selected ProjectCollection
            WorkItemStore workItemStore = projectCollection.GetService <WorkItemStore>();
            //Get Project from Tracking client
            Project project = workItemStore.Projects[ConfigurationManager.AppSettings["TfsProjectName"]];

            //List<int> changesetIds = new List<int>();
            //foreach (var item in File.ReadAllLines("list_item.txt"))
            //{
            //    int tmp = 0;
            //    if (int.TryParse(item, out tmp))
            //    {
            //        changesetIds.Add(tmp);
            //    }
            //}

            //
            QueryFolder     teamQueryFolder = project.QueryHierarchy[ConfigurationManager.AppSettings["TfsQueryGroup"]] as QueryFolder;
            QueryItem       queryItem       = teamQueryFolder[ConfigurationManager.AppSettings["TfsQueryName"]];
            QueryDefinition queryDefinition = workItemStore.GetQueryDefinition(queryItem.Id);

            Dictionary <string, string> variables = new Dictionary <string, string> {
                { "@project", queryItem.Project.Name }
            };

            WorkItemCollection workItemCollection = workItemStore.Query(queryDefinition.QueryText, variables);

            DataTable dt = CreateDataTable();

            //Get Source Control/Version Control repository for selected project collection
            VersionControlServer versionControlServer = projectCollection.GetService <VersionControlServer>();
            //Get Details of Version Control using artifact provider
            VersionControlArtifactProvider artifactProvider = versionControlServer.ArtifactProvider;

            //Iterate through each item to get its details
            foreach (WorkItem workItem in workItemCollection)
            {
                DataRow dr = dt.NewRow();
                dr["ID"]    = workItem.Id;
                dr["Title"] = workItem.Title;

                //use linq to get the linked changesets to a workitem
                IEnumerable <Changeset> changesets = workItem.Links.OfType <ExternalLink>().Select(link => artifactProvider.GetChangeset(new Uri(link.LinkedArtifactUri)));

                //iterate through changesets' to get each changeset details
                foreach (Changeset changeset in changesets)
                {
                    dr["ChangesetId"] = changeset.ChangesetId;
                    foreach (Change changes in changeset.Changes)
                    {
                        //ServerItem is the full path of a source control file associated to changeset
                        if (changes.Item.ServerItem.Contains(ConfigurationManager.AppSettings["DevBranchName"]))
                        {
                            dr["Fix in DevBranch"] = "Yes";
                            break;
                        }
                        else if (changes.Item.ServerItem.Contains(ConfigurationManager.AppSettings["ReleaseBranchName"]))
                        {
                            dr["Fix in ReleaseBranch"] = "Yes";
                            break;
                        }
                    }
                }

                dt.Rows.Add(dr);
            }
            //Write datable to excel file using StreamWriter
            WriteToExcel(dt);
        }
Beispiel #5
0
 /// <summary>
 /// Moves a query folder or query to another targeted folder
 /// </summary>
 /// <param name="queryItem"></param>
 /// <param name="targetFolder"></param>
 public void MoveQueryItem(QueryItem queryItem, QueryFolder targetFolder)
 {
     targetFolder.Add(queryItem);
     targetFolder.Project.QueryHierarchy.Save();
 }
Beispiel #6
0
 /// <summary>
 /// Adds an enable control state for the specified item
 /// </summary>
 /// <param name="zItem"></param>
 public void AddEnableControl(QueryItem zItem)
 {
     if (!m_listEnableControls.Contains(zItem))
     {
         m_listEnableControls.Add(zItem);
     }
 }
 internal override void TfDTEExecute(QueryItem query)
 {
 }
 public void HandleSecurityCommand(QueryItem queryItem)
 {
     _handleSecurityCommandMethod.Value.Invoke(null, new object[] { queryItem });
 }
Beispiel #9
0
 public void add(QueryItem line)
 {
     Lines.Add(line);
 }
        public void Queryable_Function_Regex()
        {
            var model = QueryItem.FromLinq("Part", q => q.Where(i => System.Text.RegularExpressions.Regex.IsMatch(i.Property("item_number").Value, @"\d{3}-\d{4}")));

            Assert.IsTrue(model.Where is LikeOperator op && op.Right is PatternList);
        }
        public void Queryable_Function_Now()
        {
            var model = QueryItem.FromLinq("Part", q => q.Where(i => i.ModifiedOn().AsDateTime() > DateTime.Now));

            Assert.IsTrue(model.Where is GreaterThanOperator op && op.Right is QueryModel.Functions.CurrentDateTime);
        }
        private static List<QueryItem> CreateQueryItems(IEnumerable<DictionaryEntry> entries, QueryObject queryObject)
        {
            var items = new List<QueryItem>();

            foreach (var entry in entries)
            {
                var item = new QueryItem();
                item.DictionaryEntry = entry;
                item.TenMostRecentAnswers = TakeTenMostRecentAnswers(entry);
                item.Ratio = CalculateRatio(item.TenMostRecentAnswers, queryObject);
                items.Add(item);
            }
            return items;
        }
Beispiel #13
0
        public static void RunQuery(string tfs_url, string project_name, string query_folder, string query_name, string log_file, int take_first = 0)
        {
            _log_file = log_file;

            WriteLine("Initialize TFS Server object");
            TfsConfigurationServer configuration_server = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(tfs_url));

            WriteLine(@"Get the catalog of team project collections");
            CatalogNode catalog_node = configuration_server.CatalogNode;

            WriteLine(@"Get all CatalogNodes which are ProjectCollection");
            ReadOnlyCollection <CatalogNode> tpc_nodes = catalog_node.QueryChildren(new Guid[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            WriteLine(@"Get InstanceId of a ProjectCollection");
            Guid tpc_id = Guid.Empty;

            foreach (CatalogNode tpc_node in tpc_nodes)
            {
                tpc_id = new Guid(tpc_node.Resource.Properties["InstanceId"]);
                break;
            }

            WriteLine(@"Fill list of projects in a local variable");
            TfsTeamProjectCollection project_collection = configuration_server.GetTeamProjectCollection(tpc_id);

            project_collection.Authenticate();

            WriteLine(@"Get WorkItem Tracking client for workitem collection for selected ProjectCollection");
            WorkItemStore work_item_store = project_collection.GetService <WorkItemStore>();

            WriteLine(@"Get Project from Tracking client");

            Project project = work_item_store.Projects[project_name];

            WriteLine(@"Run Query");
            QueryFolder     team_query_folder = project.QueryHierarchy[query_folder] as QueryFolder;
            QueryItem       query_item        = team_query_folder[query_name];
            QueryDefinition queryDefinition   = work_item_store.GetQueryDefinition(query_item.Id);

            Dictionary <string, string> variables = new Dictionary <string, string> {
                { "project", query_item.Project.Name }
            };

            WorkItemCollection work_item_collection = work_item_store.Query(queryDefinition.QueryText, variables);

            WriteLine(@"Get Source Control/Version Control repository for selected project collection");
            VersionControlServer version_control_server = project_collection.GetService <VersionControlServer>();

            WriteLine(@"Get Details of Version Control using artifact provider");
            VersionControlArtifactProvider artifact_provider = version_control_server.ArtifactProvider;

            Write_to_excel(new string[] { "WorkItemID", "WorkItemTitle", "ChangesetId", "CreationDate", "ChangeType", "File" });

            WriteLine(@"Iterate through each item to get its details");

            IEnumerable <WorkItem> work_items = take_first > 0 ? work_item_collection.OfType <WorkItem>().Take(take_first) : work_item_collection.OfType <WorkItem>();

            foreach (WorkItem work_item in work_items)
            {
                WriteLine($"    ->{work_item.Id}");
                IEnumerable <Changeset> changesets = work_item.Links.OfType <ExternalLink>().Select(link =>
                {
                    Changeset set;
                    try
                    {
                        set = artifact_provider.GetChangeset(new Uri(link.LinkedArtifactUri));
                    }
                    catch (Exception ex)
                    {
                        BackgroundColor = ConsoleColor.Red;
                        WriteLine(ex.Message);
                        BackgroundColor = ConsoleColor.Black;
                        set             = null;
                    }
                    return(set);
                })
                                                     .Where(s => s != null);

                foreach (Changeset changeset in changesets)
                {
                    WriteLine($"        {changeset.ChangesetId}");
                    foreach (Change change in changeset.Changes)
                    {
                        WriteLine($"           {change.Item.ServerItem}");

                        var data = new string[] {
                            work_item.Id.ToString(),
                            work_item.Title,
                            changeset.ChangesetId.ToString(),
                            changeset.CreationDate.ToString(),
                            change.ChangeType.ToString(),
                            change.Item.ServerItem
                        };
                        Write_to_excel(data);
                    }
                }
            }
        }
        public async Task <ApiResult> Save(ConstructionPlanImportCommon importCommon, IFormFile file)
        {
            ApiResult ret = new ApiResult();
            QueryItem qi  = new QueryItem();
            //保存每个
            List <DeptAndLine> dls = new List <DeptAndLine>();

            //ConstructionPlanImport parm = new ConstructionPlanImport();
            //parm.monthPlans = new List<DataTable>();
            //parm.yearPlans = new List<DataTable>();
            importCommon.ImportedTime = DateTime.Now;
            importCommon.ImportedBy   = _userID;
            //parm.importCommon = importCommon;

            ISheet    sheet    = null;
            IWorkbook workbook = null;
            //合并单元格时用到,有值时覆盖,无值时获取
            string code = "", eqpTypeName = "";

            bool isYear = true;
            int  query  = 0;

            try
            {
                List <ConstructionPlanImportCommon> cpics = await _repo.ListByYearAndCompany(importCommon.Year, importCommon.Company);

                List <QueryItem> allLines = await _repo.ListAllLines();

                List <QueryItem> allDepartments = await _repo.ListAllOrgByType(OrgType.Department);

                List <QueryItem> allTeams = await _repo.ListAllOrgByType(OrgType.Team);

                //List<QueryItem> allEqpTypes = await _repo.ListAllEqpTypes();
                List <QueryItem> allLocations = await _repo.ListAllLocations();

                if (file.Length > 0)
                {
                    //利用IFormFile里面的OpenReadStream()方法直接读取文件流
                    Stream stream   = file.OpenReadStream();
                    string fileType = Path.GetExtension(file.FileName);

                    #region 判断excel版本
                    //2007以上版本excel
                    if (fileType == ".xlsx")
                    {
                        workbook = new XSSFWorkbook(stream);
                    }
                    //2007以下版本excel
                    else if (fileType == ".xls")
                    {
                        workbook = new HSSFWorkbook(stream);
                    }
                    else
                    {
                        ret.code = Code.ImportError;
                        ret.msg  = "传入的不是Excel文件";
                        return(ret);
                    }
                    #endregion
                    using (TransactionScope scope = new TransactionScope())
                    {
                        for (int sheetNo = 0; sheetNo < workbook.NumberOfSheets; sheetNo++)
                        {
                            sheet = workbook.GetSheetAt(sheetNo);
                            if (sheet.GetRow(0) != null)
                            {
                                string title = sheet.GetRow(0).GetCell(0).StringCellValue.Trim().Replace(" ", "");
                                if (title.IndexOf("年表") > -1)
                                {
                                    isYear = true;
                                }
                                else if (title.IndexOf("月表") > -1)
                                {
                                    isYear = false;
                                }
                                else
                                {
                                    continue;
                                }

                                string common = sheet.GetRow(2).GetCell(0).StringCellValue.Trim()
                                                .Replace(" ", "").Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "");
                                string[] tmp = common.Split('部');
                                importCommon.LineName       = tmp[1];
                                importCommon.DepartmentName = tmp[0] + "部";

                                #region 部门和线路名称与已定义的名称匹配
                                qi = GetIDByName(allLines, tmp[1], "路线", ref ret);
                                if (ret.code != Code.Success)
                                {
                                    return(ret);
                                }
                                else
                                {
                                    importCommon.Line = qi.ID;
                                }
                                qi = GetIDByName(allDepartments, importCommon.DepartmentName, "部门", ref ret);
                                if (ret.code != Code.Success)
                                {
                                    return(ret);
                                }
                                else
                                {
                                    importCommon.Department = qi.ID;
                                }
                                #endregion
                                if (cpics.Count > 0)
                                {
                                    var tmpIds = cpics
                                                 .Where(a => a.LineName == importCommon.LineName && a.DepartmentName == importCommon.DepartmentName)
                                                 .Select(a => a.ID);
                                    if (tmpIds.Count() > 0)
                                    {
                                        List <int> ids = tmpIds.ToList();
                                        //await _repo.Delete(ids);
                                        if (isYear)
                                        {
                                            await _repo.Delete(ids, "construction_plan_year");
                                        }
                                        else
                                        {
                                            await _repo.Delete(ids, "construction_plan_month");
                                        }
                                        query = tmpIds.FirstOrDefault();
                                    }
                                }
                                else if (dls.Where(a => a.Line == importCommon.Line && a.Department == importCommon.Department).Count() == 0)
                                {
                                    query = await _repo.Save(importCommon);

                                    dls.Add(new DeptAndLine()
                                    {
                                        Department = importCommon.Department, Line = importCommon.Line
                                    });
                                }
                                DataTable dt      = GetColumnName(isYear);
                                DataRow   dataRow = null;
                                //遍历行
                                for (int j = 5; j <= sheet.LastRowNum; j++)
                                {
                                    IRow row = sheet.GetRow(j);
                                    dataRow = dt.NewRow();
                                    if (row == null || row.FirstCellNum < 0)
                                    {
                                        continue;
                                    }
                                    string str = row.GetCell(0).ToString().Trim();
                                    if (str.Replace(" ", "").Contains("总计"))
                                    {
                                        break;
                                    }
                                    string rowNo = (j + 1).ToString();
                                    code = GetMergeCell(str, code, "代码(第" + rowNo + "行)", ref ret);
                                    if (ret.code != Code.Success)
                                    {
                                        return(ret);
                                    }
                                    else
                                    {
                                        dataRow[0] = code;
                                    }
                                    #region 处所、班组匹配name
                                    //设备设施
                                    string name = row.GetCell(1).ToString().Trim();
                                    eqpTypeName = GetMergeCell(name, eqpTypeName, "设备设施(第" + rowNo + "行)", ref ret);
                                    if (ret.code != Code.Success)
                                    {
                                        return(ret);
                                    }
                                    else
                                    {
                                        dataRow[2] = eqpTypeName;
                                    }
                                    dataRow[1] = 0;//此字段已弃用,为了不修改相关代码,默认写0
                                    //qi = GetIDByName(allEqpTypes, eqpTypeName, "设备设施(第" + rowNo + "行)", ref ret);
                                    //if (ret.code != Code.Success) return ret;
                                    //else dataRow[1] = qi.ID;
                                    //dataRow[1] = 0;//目前id和name没有保持一致,先把id默认0
                                    //处所
                                    name       = row.GetCell(2).ToString().Trim();
                                    dataRow[5] = name;
                                    qi         = GetIDByName(allLocations, name, "处所(第" + rowNo + "行)", ref ret);
                                    if (ret.code != Code.Success)
                                    {
                                        return(ret);
                                    }
                                    else
                                    {
                                        dataRow[3] = qi.ID;
                                    } dataRow[4] = qi.LocationBy;
                                    //dataRow[3] = 0; dataRow[4]=0;
                                    //班组
                                    name       = row.GetCell(3).ToString().Trim();
                                    dataRow[7] = name;
                                    qi         = GetIDByName(allTeams, name, "班组(第" + rowNo + "行)", ref ret);
                                    if (ret.code != Code.Success)
                                    {
                                        return(ret);
                                    }
                                    else
                                    {
                                        dataRow[6] = qi.ID;
                                    }
                                    //dataRow[6] = 0;
                                    #endregion
                                    //遍历列
                                    for (int i = 4; i < dt.Columns.Count - 2; i++)
                                    {
                                        if (i == 9 || i == 10)
                                        {
                                            continue;
                                        }
                                        ICell cellData = row.GetCell(i);
                                        //if (cellData != null)
                                        {
                                            if (i < 9)
                                            {
                                                str = cellData.ToString().Trim();
                                                if (ValidateCell(str, "第" + rowNo + "行第" + (i + 1).ToString() + "列", ref ret))
                                                {
                                                    return(ret);
                                                }
                                                dataRow[i + 4] = str;
                                            }
                                            else if (i > 10)
                                            {
                                                dataRow[i + 2] = cellData == null || string.IsNullOrEmpty(cellData.ToString().Trim()) ? 0 : 1;
                                            }
                                        }
                                    }
                                    //最后一列common表主键
                                    dataRow[dt.Columns.Count - 1] = query;
                                    dt.Rows.Add(dataRow);
                                }
                                _repo.BulkLoad(dt);
                            }
                        }
                        scope.Complete();
                    }
                }
                return(ret);
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
                return(ret);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Adds a NumericUpDown with associated slider
        /// </summary>
        /// <param name="sLabel">Label string</param>
        /// <param name="bFloat">Flag indicating whether the values associated are floating point</param>
        /// <param name="dDefault">Default value</param>
        /// <param name="dMin">Minimum value</param>
        /// <param name="dMax">Maximum value</param>
        /// <param name="zQueryKey">The query key for requesting the value</param>
        public NumericUpDown AddNumericBoxSlider(string sLabel, bool bFloat, decimal dDefault, decimal dMin, decimal dMax, object zQueryKey)
        {
            var zLabel    = CreateLabel(sLabel);
            var zNumeric  = new NumericUpDown();
            var zTrackBar = new TrackBar();

            zNumeric.Minimum   = dMin;
            zNumeric.Maximum   = dMax;
            zNumeric.Increment = 1;
            zNumeric.Value     = dMin; // default this to a valid number...
            if (bFloat)
            {
                int nZeroDecimalPlaces = 3 - (int)Math.Log10(Math.Max(Math.Abs((double)dMin), Math.Abs((double)dMax)));
                // note the trackbar value is set below using the numeric change event
                if (0 <= nZeroDecimalPlaces)
                {
                    zNumeric.Increment     = new Decimal(float.Parse("0." + "1".PadLeft(1 + nZeroDecimalPlaces, '0')));
                    zNumeric.DecimalPlaces = nZeroDecimalPlaces + 1;
                }
                else
                {
                    zNumeric.Increment     = 1;
                    zNumeric.DecimalPlaces = 0;
                }
                zTrackBar.Minimum = 0;
                zTrackBar.Maximum = ((int)(dMax / zNumeric.Increment)) - ((int)(dMin / zNumeric.Increment));
            }
            else
            {
                zTrackBar.Minimum = (int)dMin;
                zTrackBar.Maximum = (int)dMax;
                zTrackBar.Value   = (int)dDefault;
            }

            if (dDefault >= dMin && dDefault <= dMax)
            {
                zNumeric.Value = dDefault;
            }

            zNumeric.Location      = new Point(GetLabelWidth(zLabel) + (X_CONTROL_BUFFER), GetYPosition());
            zNumeric.Size          = new Size(X_NUMERIC_WIDTH, Y_CONTROL_HEIGHT);
            zNumeric.Tag           = zTrackBar; // the tag of the numeric is the trackbar
            zNumeric.Anchor        = AnchorStyles.Left | AnchorStyles.Top;
            zNumeric.ValueChanged += numeric_ValueChanged;
            zLabel.Height          = zNumeric.Height; // adjust the height of the label to match the control to its right

            zTrackBar.Location      = new Point(zNumeric.Width + zNumeric.Location.X + X_CONTROL_BUFFER, GetYPosition());
            zTrackBar.Size          = new Size(m_zPanel.ClientSize.Width - (zTrackBar.Location.X + X_CONTROL_BUFFER), Y_CONTROL_HEIGHT);
            zTrackBar.Tag           = zNumeric; // the tag of the trackbar is the numeric (value changes will affect the numeric)
            zTrackBar.Anchor        = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            zTrackBar.ValueChanged += numericSlider_ValueChanged;

            if (bFloat)
            {
                // set the trackbar value using the change event
                numeric_ValueChanged(zNumeric, new EventArgs());
            }

            m_zCurrentLayoutControl.Controls.Add(zLabel);
            m_zCurrentLayoutControl.Controls.Add(zNumeric);
            m_zCurrentLayoutControl.Controls.Add(zTrackBar);
            AddToYPosition(zTrackBar.Size.Height + Y_CONTROL_BUFFER);
            var qItem = new QueryItem(ControlType.NumBoxSlider, zNumeric, zTrackBar, ref m_nTabIndex); // the tag of the QueryItem is the trackbar (used when disabling the QueryItem)

            m_dictionaryItems.Add(zQueryKey, qItem);
            return(zNumeric);
        }
Beispiel #16
0
 public WITQueryNodeViewModel(QueryItem queryItem)
 {
     m_queryItem = queryItem;
 }
 /// <summary>
 /// Gets the query definition from a query item.
 /// </summary>
 /// <param name="queryItem">The query item to get the definition from.</param>
 /// <returns>The query definition for the query corresponding to the query item.</returns>
 private static QueryDefinition GetQueryDefinitionFromQueryItem(QueryItem queryItem)
 {
     return(queryItem as QueryDefinition);
 }
Beispiel #18
0
        internal static ILightDataTable Select(ICustomRepository repository, Type type, QueryItem quary = null)
        {
            var sql = new StringBuilder();

            sql.Append(Querys.Select(type, repository.GetDataBaseType() == DataBaseTypes.Sqllight).Execute());
            if (quary != null && quary.HasValue())
            {
                sql.Append(quary.Execute());
            }

            return(repository.GetLightDataTable(repository.GetSqlCommand(sql.ToString())));
        }
        public void IdentifyPoint(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint)
        {
            if (config.IdentifyURL == "")
            {
                return;
            }

            if (config.IdentifyLayerCount == 0)
            {
                return;
            }

            if (config.UseQueryIdentify)
            {
                _dataItems = new List <DataItem>();

                GeometryService geometryServicePointSnap = new GeometryService(config.GeometryServerUrl);
                if (geometryServicePointSnap == null)
                {
                    return;
                }

                QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);

                geometryServicePointSnap.BufferCompleted += GeometryService_IdentifyPointBufferCompleted;
                geometryServicePointSnap.Failed          += GeometryService_Failed;
                geometryServicePointSnap.CancelAsync();

                SimpleMarkerSymbol defaultSymbolMarker = new SimpleMarkerSymbol()
                {
                    Color = System.Windows.Media.Brushes.Black, Size = 8,
                    Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
                };

                Graphic clickGraphic = new Graphic();
                clickGraphic.Symbol   = defaultSymbolMarker as ESRI.ArcGIS.Client.Symbols.Symbol;
                clickGraphic.Geometry = clickPoint;

                // Input spatial reference for buffer operation defined by first feature of input geometry array
                clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

                // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
                {
                    BufferSpatialReference = ParcelMap.SpatialReference,
                    OutSpatialReference    = ParcelMap.SpatialReference,
                    Unit = LinearUnit.Meter,
                };
                bufferParams.Distances.Add(config.SnapTolerance * config.SpatialReferenceUnitsPerMeter);
                bufferParams.Features.Add(clickGraphic);
                geometryServicePointSnap.BufferAsync(bufferParams, queryItem);
            }
            else
            {
                ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
                {
                    Geometry         = clickPoint,
                    MapExtent        = ParcelMap.Extent,
                    Width            = (int)ParcelMap.ActualWidth,
                    Height           = (int)ParcelMap.ActualHeight,
                    LayerOption      = LayerOption.visible,
                    SpatialReference = ParcelMap.SpatialReference
                };

                // For performance, we allow certain layers to be only identified.
                if (config.IdentifyLayerIDs != null)
                {
                    foreach (int id in config.IdentifyLayerIDs)
                    {
                        identifyParams.LayerIds.Add(id);
                    }
                }

                IdentifyTask identifyTask = new IdentifyTask(config.IdentifyURL);
                identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
                identifyTask.Failed           += IdentifyTask_Failed;

                QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);
                identifyTask.ExecuteAsync(identifyParams, queryItem);
            }
        }
        private void RegisterContentViews()
        {
            var templateKey = SampleUtilities.GetControlTemplateKey(typeof(Telerik.Sitefinity.Modules.News.Web.UI.MasterListView), SampleConstants.EducationNewsSummaryTemplateName);
            SampleUtilities.RegisterNewsFrontendView(SampleConstants.NewsFrontendContentViewControlName,
                templateKey,
                typeof(Telerik.Sitefinity.Modules.News.Web.UI.MasterListView),
                SampleConstants.EducationNewsSummaryContentViewName,
                6,
                false,
                new Guid(SampleConstants.NewsPageId));

            templateKey = SampleUtilities.GetControlTemplateKey(typeof(Telerik.Sitefinity.Modules.News.Web.UI.DetailsSimpleView), SampleConstants.EducationNewsFullItemTemplateName);

            SampleUtilities.RegisterNewsFrontendDetailsView("NewsFrontend", templateKey, typeof(Telerik.Sitefinity.Modules.News.Web.UI.DetailsSimpleView), SampleConstants.EducationNewsItemDetailView, true);

            templateKey = SampleUtilities.GetControlTemplateKey(typeof(Telerik.Sitefinity.Modules.Libraries.Web.UI.Videos.MasterThumbnailLightBoxView), SampleConstants.ThumbnailsOverlayLightBoxTemplateName);
            SampleUtilities.RegisterVideosFrontendView(SampleConstants.VideosFrontendContentViewControlName,
                templateKey,
                typeof(Telerik.Sitefinity.Modules.Libraries.Web.UI.Videos.MasterThumbnailLightBoxView),
                SampleConstants.VideosEducationFrontendLightBoxViewName,
                50,
                true,
                new Guid(SampleConstants.OnlineCoursesLibraryId));

            templateKey = SampleUtilities.GetControlTemplateKey(typeof(Telerik.Sitefinity.Modules.Libraries.Web.UI.Images.MasterThumbnailLightBoxView), "List of thumbnails and overlay dialog (lightbox)");

            QueryItem q = new QueryItem()
            {
                IsGroup = true,
                Ordinal = 0,
                Join = "AND",
                ItemPath = "_0",
                Value = null,
                Condition = null,
                Name = "Tags"
            };

            QueryItem q1 = new QueryItem()
            {
                IsGroup = false,
                Ordinal = 0,
                Join = "OR",
                ItemPath = "_0_0",
                Condition = new Condition()
                            {
                                FieldName = "Tags",
                                FieldType = "System.Guid",
                                Operator = "Contains",
                            },
                Name = "homepage",
                Value = "913E28AA-0DE2-470d-9C3F-000000000005"
            };

            List<QueryItem> queryItems = new List<QueryItem>();
            queryItems.Add(q);
            queryItems.Add(q1);

            QueryData additionalFilter1 = new QueryData()
            {
                QueryItems = queryItems.ToArray(),
                TypeProperties = new string[0],
                Title = null,
            };

            SampleUtilities.RegisterImagesFrontendView("ImagesFrontend", templateKey, typeof(Telerik.Sitefinity.Modules.Libraries.Web.UI.Images.MasterThumbnailLightBoxView), "ImagesFrontendEducationThumbnailsListLightBox", additionalFilter1);

            templateKey = SampleUtilities.GetControlTemplateKey(typeof(Telerik.Sitefinity.Modules.Events.Web.UI.Public.DetailsView), SampleConstants.EducationEventsSingleItemTemplateName);
            SampleUtilities.RegisterEventsFrontendDetailsView("EventsFrontend", templateKey, typeof(Telerik.Sitefinity.Modules.Events.Web.UI.Public.DetailsView), SampleConstants.EducationEventItemDetailView);
        }
 public void OpenSecurityItemDialog(QueryItem queryItem)
 {
     _querySecurityCommandHelpers.Value.HandleSecurityCommand(queryItem);
 }
Beispiel #22
0
        private void RecurseWorkItems(Dictionary<string, string> context, List<MyWorkItem> items, QueryItem queryItem)
        {
            // Skip queries that aren't of type list, there's some funny exception i dont want to deal with
            var queryDefinition = queryItem as QueryDefinition;
            if (queryDefinition == null || queryDefinition.QueryType != QueryType.List)
                return;

            foreach (WorkItem workItem in _workItemStore.Query(queryDefinition.QueryText, context))
            {
                items.Add(new MyWorkItem
                {
                    id = workItem.Id,
                    state = workItem.State,
                    title = workItem.Title,
                    type = workItem.Type.Name
                });
            }
        }
Beispiel #23
0
        /// <summary>
        /// Adds a browse component (button/textbox/label)
        /// </summary>
        /// <param name="sLabel">Label for the component</param>
        /// <param name="sDefault">Default value</param>
        /// <param name="sFilter">File filter (applies to file browsing only)</param>
        /// <param name="zQueryKey">The query key for requesting the value</param>
        private TextBox AddBrowseBox(string sLabel, string sDefault, string sFilter, object zQueryKey)
        {
            var zLabel = CreateLabel(sLabel);
            var zButton = new Button();
            var zTextLocation = new Point(GetLabelWidth(zLabel) + (X_CONTROL_BUFFER), GetYPosition());
            var zText = new TextBox
            {
                Text = sDefault,
                Location = zTextLocation,
                Size =
                    new Size(
                        m_zCurrentLayoutControl.ClientSize.Width - (zTextLocation.X + X_BUTTON_WIDTH + (X_CONTROL_BUFFER * 2)),
                        Y_CONTROL_HEIGHT),
                Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top
            };

            if (null != sFilter)
            {
                zText.Tag = 0 != sFilter.Length
                    ? sFilter
                    : "All files (*.*)|*.*";
            }
            zLabel.Height = zText.Height; // adjust the height of the label to match the control to its right

            zButton.Text = "...";
            zButton.Size = new Size(X_BUTTON_WIDTH, Y_CONTROL_HEIGHT);
            zButton.Location = new Point(m_zCurrentLayoutControl.ClientSize.Width - (zButton.Size.Width + X_CONTROL_BUFFER), GetYPosition());
            zButton.Tag = zText; // the tag of the button is the textbox
            zButton.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            zButton.Click += zButton_Click;

            m_zCurrentLayoutControl.Controls.Add(zLabel);
            m_zCurrentLayoutControl.Controls.Add(zText);
            m_zCurrentLayoutControl.Controls.Add(zButton);
            AddToYPosition(zText.Size.Height + Y_CONTROL_BUFFER);
            var qItem = new QueryItem(ControlType.BrowseBox, zText, zButton, ref m_nTabIndex); // the tag of the QueryItem is the button (used when disabling the QueryItem)
            m_dictionaryItems.Add(zQueryKey, qItem);
            return zText;
        }
Beispiel #24
0
 public TfsQuery(QueryItem query)
 {
     Query = query;
 }
 static partial void RealInstanceFactory(ref QueryItem real, string callerName)
 {
     real = new QueryFolder("TestFolder");
 }
Beispiel #26
0
        private void AddQueryItem(ComboBox comboBox, QueryItem queryItem)
        {
            // Only add definitions to the combobox
            if (queryItem is QueryDefinition)
                comboBox.Items.Add(new TfsQuery(queryItem));

            if (!(queryItem is QueryFolder))
                return;

            foreach (var subQueryItem in queryItem as QueryFolder)
                AddQueryItem(comboBox, subQueryItem);
        }
Beispiel #27
0
        public void PagingAndOrdering_NotSuported(string odata)
        {
            var item = QueryItem.FromOData(odata);

            Assert.ThrowsException <NotSupportedException>(() => item.ToAml());
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting...");
            var prefs         = SavedConnections.Load().Default;
            var conn          = Factory.GetConnection(prefs);
            var savedSearches = conn.Apply(@"<Item type='SavedSearch' action='get' select='criteria'>
        <is_email_subscription>0</is_email_subscription>
        <auto_saved>0</auto_saved>
        <criteria condition='is not null'></criteria>
      </Item>").Items().Select(i => i.Property("criteria").Value).ToArray();

            var settings = new ConnectedAmlSqlWriterSettings(conn)
            {
                PermissionOption = AmlSqlPermissionOption.None
            };
            var parser = new SimpleSearchParser()
            {
                Context = conn.AmlContext.LocalizationContext
            };

            parser.OrDelimiters.Add('\t');
            parser.OrDelimiters.Add('\r');
            parser.OrDelimiters.Add('\n');
            parser.String.DefaultSearchIsContains = true;
            parser.String.IsPercentWildcard       = false;

            var ignoreActions = new[]
            {
                "ApplySubSelect",
                "ExcelOrgChartReport",
                "Finished Goods Open Concern Qry",
                "Gcs_DesignDateReport",
                "Gcs_Report_ConcernMfgOrg",
                "Gcs_Report_CustStagnantIssue",
                "Gcs_Report_EaConcernTracking",
                "Gcs_Report_SupplierQtyToReport",
                "Gcs_Report_SupplierQualityExport",
                "Get Where Used Parts",
                "GetChargeTimeEntered",
                "GetChargeTimeRaw",
                "GetByPerson",
                "GntxPartNumberXrefRpt",
                "LinkSearch",
                "Mco_Report_CreatedToday",
                "Mdm_Report_HtsCodes",
                "PcbProgramCostReport",
                "ProtoOrder_QueryNoRouting",
                "ProtoOrder_QueryOrderBuildDates",
                "ProtoOrder_QueryShouldBeClosed",
                "ProtoOrderQueryWeek",
                "QualityGcsPriorityReport",
                "SearchLumen",
                "TimeTrack_EmployeeAssignRpt",
                "TimeTrack_EscalationsReport",
            };

            var noErrorCnt = 0;
            var errorCnt   = 0;
            var total      = 0;

            Console.WriteLine("Testing queries...");
            foreach (var search in savedSearches)
            {
                try
                {
                    if (ignoreActions.Any(a => search.IndexOf(a) > 0))
                    {
                        continue;
                    }
                    if (Regex.IsMatch(search, @"condition=""in"">\s*\(\s*SELECT", RegexOptions.IgnoreCase))
                    {
                        continue;
                    }

                    var query = QueryItem.FromXml(search);

                    var countQuery = conn.AmlContext.FromXml(search).AssertItem();
                    countQuery.Attribute("returnMode").Set("countOnly");
                    var trueCount = conn.Apply(countQuery.ToAml()).ItemMax();

                    var sql = query.ToArasSql(settings);
                    if (conn.ApplySql(sql).Items().Count() != trueCount)
                    {
                        throw new InvalidOperationException();
                    }
                    var newAml = query.ToAml();
                    if (conn.Apply(newAml).Items().Count() != trueCount)
                    {
                        throw new InvalidOperationException();
                    }
                    var oData    = query.ToOData(settings, conn.AmlContext.LocalizationContext);
                    var criteria = query.ToCriteria(parser);
                    noErrorCnt++;
                }
                catch (Exception)
                {
                    //Console.WriteLine(ex.ToString());
                    errorCnt++;
                }
                total++;

                if ((total % 20) == 0)
                {
                    Console.WriteLine($"{total} queries tested");
                }
            }

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine($"{errorCnt} errors");
            Console.WriteLine($"{noErrorCnt} successes");

            Console.ReadLine();
        }
        private void RecurseWorkItems(Dictionary <string, string> context, List <MyWorkItem> items, QueryItem queryItem)
        {
            // Skip queries that aren't of type list, there's some funny exception i dont want to deal with
            var queryDefinition = queryItem as QueryDefinition;

            if (queryDefinition == null || queryDefinition.QueryType != QueryType.List)
            {
                return;
            }

            foreach (WorkItem workItem in _workItemStore.Query(queryDefinition.QueryText, context))
            {
                items.Add(new MyWorkItem
                {
                    id    = workItem.Id,
                    state = workItem.State,
                    title = workItem.Title,
                    type  = workItem.Type.Name
                });
            }
        }
 /// <summary>Set query item.</summary>
 /// <param name="item">The query item.</param>
 /// <exception cref="ArgumentNullException">item is null</exception>
 /// <exception cref="ArgumentNullException">item.KeyName is null</exception>
 private void SetItem(QueryItem item)
 {
     Contract.Requires<ArgumentNullException>(item != null, "item cannot be null");
     Contract.Requires<ArgumentNullException>(item.KeyName != null, "item.KeyName cannot be null");
     if (item != null && item.KeyName != null)
     {
         this.RootKey = item.RootKey;
         this.KeyName = item.KeyName;
     }
 }
 public void Add(QueryItem queryItem)
 {
     Items.Add(queryItem);
 }
Beispiel #32
0
 public override void Create(QueryItem queryItem)
 {
     //throw new NotImplementedException();
 }
 protected override void Exercise(IObjectContainer db)
 {
     Assert.AreEqual(1, db.Query(typeof (QueryItem)).Count);
     var newItem = new QueryItem
         ();
     db.Store(newItem);
     db.Commit();
     db.Delete(newItem);
     db.Commit();
 }
Beispiel #34
0
 private IEnumerable<XDoc> YieldAll(int limit, int offset)
 {
     var docResults = new List<QueryItem>();
     _catalog.NewQuery(string.Format("SELECT id, revision, doc FROM {0} ORDER BY {0}.id{1}", _name, GetLimitAndOffsetClause(limit, offset)))
         .Execute(delegate(IDataReader dr) {
             while(dr.Read()) {
                 var docResult = new QueryItem {
                                                   Id = dr.GetInt32(0),
                                                   Revision = dr.GetInt32(1),
                                                   Doc = dr.GetString(2)
                                               };
                 docResults.Add(docResult);
             }
         });
     foreach(var docResult in docResults) {
         XDoc doc = XDocFactory.From(docResult.Doc, MimeType.TEXT_XML);
         Map(doc);
         doc.Attr("docstore:revision", docResult.Revision);
         doc.Attr("docstore:id", docResult.Id);
         yield return doc;
     }
 }
Beispiel #35
0
 /// <summary>
 /// Raises an event for the user selecting a query.
 /// </summary>
 /// <param name="queryItem">The selected query item.</param>
 private void UserSelectsQuery(QueryItem queryItem)
 {
     this.mockView.Raise(view => view.QuerySelected += null, new QueryItemEventArgs(queryItem));
 }
Beispiel #36
0
 public abstract void Create(QueryItem queryItem);
Beispiel #37
0
        public override void Create(QueryItem queryItem)
        {
            string sql = $"Create database {queryItem.DatabaseName}";

            Execute(sql);
        }
 public EditQueryResultItem(QueryItem queryItem)
 {
     QueryItem = queryItem;
 }
        /* ****** Identify using Query Service ****** */

        private void QueryIdentifyTask_ExecuteCompleted(object sender, QueryEventArgs args)
        {
            QueryItem queryItem = args.UserState as QueryItem;

            if (queryItem.Index == 0)
            {
                IdentifyComboBox.Items.Clear();
                _layersIdentified.Clear();
                IdentifyDetailsDataGrid.ItemsSource = null;
            }

            // display search results for this layers query.
            if (args.FeatureSet.Features.Count > 0)
            {
                foreach (Graphic feature in args.FeatureSet.Features)
                {
                    string title = queryItem.IdentifyLayerName;

                    feature.Attributes.Remove("Shape");
                    feature.Attributes.Remove("OBJECTID");
                    _dataItems.Add(new DataItem()
                    {
                        Title = title,
                        Data  = feature.Attributes
                    });
                    IdentifyComboBox.Items.Add(title);

                    if (_activeIdentifyLayer == title)
                    {
                        queryItem.ActiveLayer = _layersIdentified.Count;
                    }
                    _layersIdentified.Add(title);
                }
            }

            if (queryItem.Next()) // this increments the internal index
            {
                Query query = new ESRI.ArcGIS.Client.Tasks.Query();
                query.SpatialRelationship = SpatialRelationship.esriSpatialRelIntersects;
                query.Geometry            = queryItem.BufferedPoint;
                query.OutFields.AddRange(new string[] { "*" });

                QueryTask queryTask = new QueryTask(queryItem.IdentifyLayerUrl);
                queryTask.ExecuteCompleted += QueryIdentifyTask_ExecuteCompleted;
                queryTask.Failed           += QueryIdentifyTask_Failed;

                queryTask.ExecuteAsync(query, queryItem);
            }
            else // We are done with all our queries, display the result.
            {
                IdentifyComboBox.SelectedIndex = queryItem.ActiveLayer;
                Visibility = System.Windows.Visibility.Visible;

                if ((_dataItems == null) || (_dataItems.Count == 0))
                {
                    NoResult.Visibility = Visibility.Visible;
                    Results.Visibility  = Visibility.Collapsed;
                }
                else
                {
                    NoResult.Visibility = Visibility.Collapsed;
                    Results.Visibility  = Visibility.Visible;
                }
            }
        }
Beispiel #40
0
 /// <summary>
 /// Moves a query folder or query to another targeted folder
 /// </summary>
 /// <param name="queryItem"></param>
 /// <param name="targetFolder"></param>
 public void MoveQueryItem(QueryItem queryItem, QueryFolder targetFolder)
 {
     targetFolder.Add(queryItem);
     targetFolder.Project.QueryHierarchy.Save();
 }
Beispiel #41
0
 /// <summary>
 /// Renames a query folder or query
 /// </summary>
 /// <param name="newName"></param>
 /// <param name="folderQrQuery"></param>
 public void RenameQueryItem(string newName, QueryItem folderQrQuery)
 {
     folderQrQuery.Name = newName;
     MyProject.QueryHierarchy.Save();
 }
Beispiel #42
0
 /// <summary>
 /// select by quarry
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="repository"></param>
 /// <param name="quary"></param>
 /// <returns></returns>
 public static ISqlQueriable <T> SelectAbsence <T>(this ICustomRepository repository, QueryItem quary = null) where T : class, IDbEntity
 {
     return(new SqlQueriable <T>(DbSchema.Select <T>(repository, quary), repository));
 }
 public void HandleSecurityCommand(QueryItem queryItem)
 {
     _handleSecurityCommandMethod.Value.Invoke(null, new object[] {queryItem});
 }
Beispiel #44
0
        private void onBankFinish(QueryResult result)
        {
            AppendSumLog(result.batchCurrnum + "更新结算标志");
            List <QueryItem> jsonQueryItems = new List <QueryItem> ();
            string           nowTimeStr     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            string[] fields = new string[] {
                "status",
                "results",
                "reciveDate"
            };
            try {
                if (result.batchStatus == 2)
                {
                    //商户审核拒绝
                    QueryItem jsonItem = new QueryItem()
                    {
                        table  = "transactionSum",
                        action = DBAction.Update,
                        where  = " batchCurrnum='" + result.batchCurrnum + "'",
                        fields = fields,
                        values = new string[] { "-2", "商户审核拒绝", nowTimeStr }
                    };
                    jsonQueryItems.Add(jsonItem);
                }
                else
                {
                    if (result.batchEContent == null)
                    {
                        throw new Exception("获取明细为空");
                    }
                    string logStr = "";
                    foreach (QueryResult.DetailInfo detail in result.batchEContent)
                    {
                        QueryItem jsonItem = new QueryItem()
                        {
                            table  = "transactionSum",
                            action = DBAction.Update,
                            where  = " batchCurrnum='" + result.batchCurrnum + "'",                                   //+ "' and id=" + detail.tradeNum,
                            fields = fields,
                            values = new string[3]
                        };
                        switch (detail.status)
                        {
                        case "":
                        case "处理中":
                            jsonItem.values [0] = "1";
                            break;

                        case "成功":
                            jsonItem.values [0] = "3";
                            break;

                        case "失败":
                            jsonItem.values [0] = "-2";
                            break;

                        default:
                            throw new Exception("处理结果明细有未定义的状态值");
                        }
                        logStr += detail.faren + detail.status + "; ";
                        jsonItem.values [1] = detail.reason;
                        jsonItem.values [2] = nowTimeStr;
                        jsonQueryItems.Add(jsonItem);
                    }
                    SetBankLog(result.batchCurrnum, logStr);
                }
                string jsonStr   = Newtonsoft.Json.JsonConvert.SerializeObject(jsonQueryItems);
                string resultStr = execDb(jsonStr);
                JsonMessage <string> jsonMessage = Newtonsoft.Json.JsonConvert.DeserializeObject <JsonMessage <string> > (resultStr);
                if (jsonMessage.Message != null)
                {
                    throw new Exception(jsonMessage.Message);
                }
            } catch (Exception ex) {
                AppendSumLog(result.batchCurrnum + "更新结算标志异常:" + ex.Message);
                onError("更新结算标志异常:", ex);
            }
        }
Beispiel #45
0
        /// <summary>
        /// Adds a NumericUpDown with associated slider
        /// </summary>
        /// <param name="sLabel">Label string</param>
        /// <param name="bFloat">Flag indicating whether the values associated are floating point</param>
        /// <param name="dDefault">Default value</param>
        /// <param name="dMin">Minimum value</param>
        /// <param name="dMax">Maximum value</param>
        /// <param name="zQueryKey">The query key for requesting the value</param>
        public NumericUpDown AddNumericBoxSlider(string sLabel, bool bFloat, decimal dDefault, decimal dMin, decimal dMax, object zQueryKey)
        {
            var zLabel = CreateLabel(sLabel);
            var zNumeric = new NumericUpDown();
            var zTrackBar = new TrackBar();

            zNumeric.Minimum = dMin;
            zNumeric.Maximum = dMax;
            zNumeric.Increment = 1;
            zNumeric.Value = dMin; // default this to a valid number...
            if (bFloat)
            {
                int nZeroDecimalPlaces = 3 - (int)Math.Log10(Math.Max(Math.Abs((double)dMin), Math.Abs((double)dMax)));
                // note the trackbar value is set below using the numeric change event
                if (0 <= nZeroDecimalPlaces)
                {
                    zNumeric.Increment = new Decimal(float.Parse("0." + "1".PadLeft(1 + nZeroDecimalPlaces, '0')));
                    zNumeric.DecimalPlaces = nZeroDecimalPlaces + 1;
                }
                else
                {
                    zNumeric.Increment = 1;
                    zNumeric.DecimalPlaces = 0;
                }
                zTrackBar.Minimum = 0;
                zTrackBar.Maximum = ((int)(dMax / zNumeric.Increment)) - ((int)(dMin / zNumeric.Increment));
            }
            else
            {
                zTrackBar.Minimum = (int)dMin;
                zTrackBar.Maximum = (int)dMax;
                zTrackBar.Value = (int)dDefault;
            }

            if (dDefault >= dMin && dDefault <= dMax)
            {
                zNumeric.Value = dDefault;
            }

            zNumeric.Location = new Point(GetLabelWidth(zLabel) + (X_CONTROL_BUFFER), GetYPosition());
            zNumeric.Size = new Size(X_NUMERIC_WIDTH, Y_CONTROL_HEIGHT);
            zNumeric.Tag = zTrackBar; // the tag of the numeric is the trackbar
            zNumeric.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            zNumeric.ValueChanged += numeric_ValueChanged;
            zLabel.Height = zNumeric.Height; // adjust the height of the label to match the control to its right

            zTrackBar.Location = new Point(zNumeric.Width + zNumeric.Location.X + X_CONTROL_BUFFER, GetYPosition());
            zTrackBar.Size = new Size(m_zPanel.ClientSize.Width - (zTrackBar.Location.X + X_CONTROL_BUFFER), Y_CONTROL_HEIGHT);
            zTrackBar.Tag = zNumeric; // the tag of the trackbar is the numeric (value changes will affect the numeric)
            zTrackBar.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            zTrackBar.ValueChanged += numericSlider_ValueChanged;

            if (bFloat)
            {
                // set the trackbar value using the change event
                numeric_ValueChanged(zNumeric, new EventArgs());
            }

            m_zCurrentLayoutControl.Controls.Add(zLabel);
            m_zCurrentLayoutControl.Controls.Add(zNumeric);
            m_zCurrentLayoutControl.Controls.Add(zTrackBar);
            AddToYPosition(zTrackBar.Size.Height + Y_CONTROL_BUFFER);
            var qItem = new QueryItem(ControlType.NumBoxSlider, zNumeric, zTrackBar, ref m_nTabIndex); // the tag of the QueryItem is the trackbar (used when disabling the QueryItem)
            m_dictionaryItems.Add(zQueryKey, qItem);
            return zNumeric;
        }
        private IQueryable <Account> AddInterestsQuery(IQueryable <Account> accounts, QueryItem queryItem)
        {
            var values    = queryItem.Value.Split(",");
            var predicate = queryItem.Predicate ?? Predicate.any;

            switch (predicate)
            {
            case Predicate.any:
                return(accounts.Where(a => a.Interests != null && values.Any(v => a.Interests.Any(i => i == v))));

            case Predicate.contains:
                return(accounts.Where(a => a.Interests != null && values.All(v => a.Interests.Contains(v))));

            default:
                throw new Exception($"Unsupportend predicate {queryItem.Predicate}");
            }
        }
Beispiel #47
0
        /// <summary>
        /// Support method to setup the control location/size. This method also adds the control to the form.
        /// </summary>
        /// <param name="zControl">Control to configure</param>
        /// <param name="zLabel">Label Control associated with the Control</param>
        /// <param name="eType">ControlType</param>
        /// <param name="bApplySize">Apply size based on form flag</param>
        /// <param name="zQueryKey">The query key for requesting the value</param>
        private void SetupControl(Control zControl, Label zLabel, ControlType eType, bool bApplySize, object zQueryKey)
        {
            if (null != zLabel)
            {
                if (bApplySize)
                {
                    zControl.Size = new Size((m_zCurrentLayoutControl.ClientSize.Width - GetLabelWidth(zLabel)) - (X_CONTROL_BUFFER * 2), zControl.Size.Height);
                }

                zControl.Location = new Point(zLabel.Location.X + GetLabelWidth(zLabel), GetYPosition());
                zLabel.Height = zControl.Height;
                m_zCurrentLayoutControl.Controls.Add(zLabel);
                AddToYPosition(Math.Max(zLabel.Height, zControl.Height) + Y_CONTROL_BUFFER);
            }
            else
            {
                zControl.Location = new Point((m_zCurrentLayoutControl.ClientSize.Width - zControl.Width) - X_CONTROL_BUFFER, GetYPosition());
                AddToYPosition(zControl.Height + Y_CONTROL_BUFFER);
            }
            zControl.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            m_zCurrentLayoutControl.Controls.Add(zControl);
            var qItem = new QueryItem(eType, zControl, ref m_nTabIndex);
            m_dictionaryItems.Add(zQueryKey, qItem);
        }
Beispiel #48
0
 /// <summary>
 /// Renames a query folder or query
 /// </summary>
 /// <param name="newName"></param>
 /// <param name="folderQrQuery"></param>
 public void RenameQueryItem(string newName, QueryItem folderQrQuery)
 {
     folderQrQuery.Name = newName;
     MyProject.QueryHierarchy.Save();
 }