Пример #1
0
        public static void ShowResult(EditResult result)
        {
            FormSearchResult formResult = new FormSearchResult();

            formResult.SetContents(result);
            formResult.Show();
        }
Пример #2
0
        internal static bool TreesAreDifferent(Block leftTree, Block rightTree, TextChange[] changes)
        {
            // Apply all the pending changes to the original tree
            // PERF: If this becomes a bottleneck, we can probably do it the other way around,
            //  i.e. visit the tree and find applicable changes for each node.
            foreach (TextChange change in changes)
            {
                Span changeOwner = leftTree.LocateOwner(change);

                // Apply the change to the tree
                if (changeOwner == null)
                {
                    return(true);
                }
                EditResult result = changeOwner.EditHandler.ApplyChange(changeOwner, change, force: true);
                changeOwner.ReplaceWith(result.EditedSpan);
            }

            // Now compare the trees
            bool treesDifferent = !leftTree.EquivalentTo(rightTree);

#if DEBUG
            if (RazorDebugHelpers.OutputDebuggingEnabled)
            {
                Debug.WriteLine(String.Format(CultureInfo.CurrentCulture, "Processed {0} changes, trees were{1} different", changes.Length, treesDifferent ? String.Empty : " not"));
            }
#endif
            return(treesDifferent);
        }
        private void StartReplaceClick(object sender, EventArgs e)
        {
            if (AreFilesSelected())
            {
                EditResult result = null;
                switch (cmbReplaceAction.SelectedIndex)
                {
                case 0:
                    result = FolderEdit.Edit.FolderEdit.INSTANCE.SearchText(
                        editableFolder, EditModes.GetModeByName(cmbEditMode.Text),
                        txtSearch.Text, chbCaseSens.Checked, chbRegex.Checked);
                    break;

                case 1:
                    result = FolderEdit.Edit.FolderEdit.INSTANCE.ReplaceText(
                        editableFolder, EditModes.GetModeByName(cmbEditMode.Text),
                        txtSearch.Text, txtReplace.Text, chbCaseSens.Checked, chbRegex.Checked);
                    break;

                case 2:
                    result = FolderEdit.Edit.FolderEdit.INSTANCE.DeleteFiles(
                        editableFolder, EditModes.GetModeByName(cmbEditMode.Text),
                        txtSearch.Text, chbCaseSens.Checked, chbRegex.Checked);
                    break;
                }

                if (result != null)
                {
                    FormSearchResult.ShowResult(result);
                }
            }
        }
Пример #4
0
 public EditOMV(float[] DATA, EditResult Res)
 {
     InitializeComponent();
     radio_check(Auto_Manual);
     if (Res == EditResult.EditData)
     {
         for (int i = 0; i < OUT_DATA.Length; i++)
         {
             OUT_DATA[i] = DATA[i];
         }
         tB341.Text = OUT_DATA[0].ToString("N3");
         tB342.Text = OUT_DATA[1].ToString("N3");
         tB343.Text = OUT_DATA[2].ToString("N3");
         tB344.Text = OUT_DATA[3].ToString("N3");
         tB345.Text = OUT_DATA[4].ToString("N3");
         tB346.Text = OUT_DATA[5].ToString("N3");
         tB347.Text = OUT_DATA[6].ToString("N3");
         tB348.Text = OUT_DATA[7].ToString("N3");
         tB349.Text = OUT_DATA[8].ToString("N3");
         tB350.Text = OUT_DATA[9].ToString("N3");
         tB351.Text = OUT_DATA[10].ToString("N3");
         tB352.Text = OUT_DATA[11].ToString("N3");
         tB353.Text = OUT_DATA[12].ToString("N3");
         tB354.Text = OUT_DATA[13].ToString("N3");
         tB355.Text = OUT_DATA[14].ToString("N3");
         tB356.Text = OUT_DATA[15].ToString("N3");
         tB357.Text = OUT_DATA[16].ToString("N3");
         tB358.Text = OUT_DATA[17].ToString("N3");
         tB359.Text = OUT_DATA[18].ToString("N3");
     }
 }
Пример #5
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();

                _serverId = Guid.NewGuid();
                var existingCruiseProjectAssociations = new[]
                {
                    new CruiseProjectAssociation {
                        ServerId = _serverId, Name = "Project Foo"
                    },
                };
                var projectToEdit = existingMasterModel.CreateProject(x =>
                {
                    x.Name = "Existing Project";
                    x.CruiseProjectAssociations = existingCruiseProjectAssociations;
                });

                _expectedId = projectToEdit.Id;

                var repository = new StubMasterModelRepository();

                repository.UseCurrentModel(existingMasterModel);

                var manager   = new ProjectManager(repository);
                var editModel = new EditProject
                {
                    ProjectId      = projectToEdit.Id,
                    Name           = "Existing Project",
                    CruiseProjects = null,
                };

                _result = manager.Update(editModel);

                _savedModel = repository.LastSaved;
            }
Пример #6
0
        public EditResult <LightGroup> Update(Guid groupId, string name)
        {
            var masterModel = _masterModelRepository.GetCurrent();
            var allGroups   = masterModel.Projects.SelectMany(x => x.Groups).ToArray();

            if (allGroups.None(x => x.Id.Equals(groupId)))
            {
                return(EditResult.Fail <LightGroup>(BadId(groupId)));
            }

            var group = allGroups.Single(x => x.Id.Equals(groupId));

            if (group.Name.Equals(name))
            {
                return(EditResult.Success(group));
            }

            var parentProject = group.ParentProject;

            if (parentProject.Groups.Any(x => x.Name.Equals(name)))
            {
                return
                    (EditResult.Fail <LightGroup>(string.Format("There is already a group named '{0}' in project '{1}'",
                                                                name, parentProject.Name)));
            }

            group.Name = name;
            _masterModelRepository.Save(masterModel);

            return(EditResult.Success(group));
        }
Пример #7
0
        public EditResult <Project> Update(EditProject editModel)
        {
            var currentModel = _masterModelRepository.GetCurrent();
            var project      = currentModel.Projects.SingleOrDefault(x => x.Id.Equals(editModel.ProjectId.Value));

            if (project == null)
            {
                return(CouldNotLocateProject(editModel.ProjectId.Value));
            }

            var existingProjectWithThisName = currentModel.Projects.SingleOrDefault(x => x.Name.Equals(editModel.Name));

            if (existingProjectWithThisName != null && existingProjectWithThisName.Id != editModel.ProjectId)
            {
                return(EditResult.Fail <Project>(NameCollisionMessage(editModel.Name)));
            }

            project.Name = editModel.Name;
            if (editModel.CruiseProjects == null)
            {
                project.CruiseProjectAssociations = new CruiseProjectAssociation[0];
            }
            else
            {
                project.CruiseProjectAssociations = editModel.CruiseProjects
                                                    .Select(
                    cp => new CruiseProjectAssociation {
                    Name = cp.Project, ServerId = cp.Server
                })
                                                    .ToArray();
            }
            _masterModelRepository.Save(currentModel);

            return(EditResult.Success(project));
        }
Пример #8
0
 private void SetContents(EditResult result)
 {
     rtbDescription.Text = result.GetResultDescription();
     foreach (string key in result.Positions.Keys)
     {
         lvResult.Items.Add(new ListViewItem(
                                new string[] { key, ListConverter.ListToString(result.Positions[key]) }));
     }
 }
Пример #9
0
        // POST api/<controller>
        public HttpResponseMessage Post([FromBody] string value)
        {
            var affectedTransactionsCount = Models.TransactionModel.ApplyEdit("sytelus", value);
            var editResult = new EditResult()
            {
                AffectedTransactionsCount = affectedTransactionsCount
            };

            return(this.Request.GetJsonResponse(CommonUtils.JsonSerializer <EditResult> .Serialize(editResult)));
        }
Пример #10
0
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            EditResult = thisOne.IsChecked == true ? EditResult.Single : EditResult.All;

            DialogResult = true;

            // If the window was not shown as a dialog, the above
            // line will not do anything.
            try { Close(); }
            catch { }
        }
Пример #11
0
        private PartialParseResult TryPartialParse(TextChange change)
        {
            PartialParseResult result = PartialParseResult.Rejected;

            // Try the last change owner
            if (
                _lastChangeOwner != null &&
                _lastChangeOwner.EditHandler.OwnsChange(_lastChangeOwner, change)
                )
            {
                EditResult editResult = _lastChangeOwner.EditHandler.ApplyChange(
                    _lastChangeOwner,
                    change
                    );
                result = editResult.Result;
                if (!editResult.Result.HasFlag(PartialParseResult.Rejected))
                {
                    _lastChangeOwner.ReplaceWith(editResult.EditedSpan);
                }

                return(result);
            }

            // Locate the span responsible for this change
            _lastChangeOwner = CurrentParseTree.LocateOwner(change);

            if (LastResultProvisional)
            {
                // Last change owner couldn't accept this, so we must do a full reparse
                result = PartialParseResult.Rejected;
            }
            else if (_lastChangeOwner != null)
            {
                EditResult editRes = _lastChangeOwner.EditHandler.ApplyChange(
                    _lastChangeOwner,
                    change
                    );
                result = editRes.Result;
                if (!editRes.Result.HasFlag(PartialParseResult.Rejected))
                {
                    _lastChangeOwner.ReplaceWith(editRes.EditedSpan);
                }
                if (result.HasFlag(PartialParseResult.AutoCompleteBlock))
                {
                    _lastAutoCompleteSpan = _lastChangeOwner;
                }
                else
                {
                    _lastAutoCompleteSpan = null;
                }
            }
            return(result);
        }
Пример #12
0
        /// <summary>
        /// Method executes when user clicks the cancel button in the SuggestionsBox view.
        ///
        /// The editing is cancelled and switch flips back to previous visiblilty of TreeView.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ctrl_CancelSuggestion_Click(object sender, RoutedEventArgs e)
        {
            if (IsSwitchOn == false)
            {
                var ev = new EditResult(EditPathResult.Cancel, string.Empty);

                if (this.SwitchCommand.CanExecute(null) == true)
                {
                    this.SwitchCommand.Execute(ev);
                }
            }
        }
Пример #13
0
        protected void saveNewRule_Click(object sender, EventArgs e)
        {
            AreaWarningRule rule = new AreaWarningRule();

            rule.EnableToAllTags = forAllTags.SelectedValue == "1";
            rule.AreaEventType   = byte.Parse(areaEventType.SelectedValue);
            rule.AreaId          = _id;
            rule.IsDisabled      = false;

            int[]     tagidarray = new int[tagSelector.SelectedUserIds.Count()];
            ArrayList alHostId   = new ArrayList();

            int[] hostIdArray = null;
            sTagID = "";
            for (int i = 0; i < tagSelector.SelectedUserIds.Count(); i++)
            {
                //根据hostid取得tagid
                HostTag ht = new HostTag();
                ht = HostTag.GetById(tagSelector.SelectedUserIds[i]);
                if (ht != null)
                {
                    alHostId.Add(ht.HostId);
                    sTagID       += ht.TagId + ",";
                    tagidarray[i] = ht.TagId;
                }
            }
            hostIdArray            = (int[])alHostId.ToArray(typeof(int));
            AreaWarningRule.sTagID = sTagID;

            if (!LocatingServiceUtil.IsAvailable())
            {
                AreaWarningRule.InsertAndReturnId(rule);
                if (rule.EnableToAllTags == false)
                {
                    //AreaWarningRuleCoverage.SetCoverage(rule.Id, hostIdArray);
                    AreaWarningRuleCoverage.SetCoverage(rule.Id, tagidarray);
                    //AreaWarningRuleCoverage.SetCoverage(rule.Id, tagSelector.SelectedTagIdArray);
                }
            }
            else
            {
                IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                EditResult  result     = serviceApi.InsertWarningRule(rule);
                rule.Id = result.Id;
                if (rule.EnableToAllTags == false)
                {
                    serviceApi.SetWarningRuleCoverage(rule.Id, tagidarray);
                    //serviceApi.SetWarningRuleCoverage(rule.Id, tagSelector.SelectedTagIdArray);
                }
            }

            Terminator.Redirect(Fetch.CurrentUrl);
        }
Пример #14
0
        public EditResult ShowDlg(IWin32Window owner)
        {
            DialogResult dr = this.ShowDialog(null);

            EditResult er = EditResult.DiscardChanges;

            if (dr == DialogResult.Yes)
            {
                er = EditResult.SaveChanges;
            }

            return(er);
        }
Пример #15
0
        public EditResult <Project> Delete(Guid id)
        {
            var currentModel = _masterModelRepository.GetCurrent();

            if (!currentModel.ProjectExists(id))
            {
                return(CouldNotLocateProject(id));
            }

            currentModel.RemoveProject(id);
            _masterModelRepository.Save(currentModel);
            return(EditResult.Success <Project>(null));
        }
        EditResult DoEdit(int address, byte[] data, byte[] oriData)
        {
            foreach (BinElement e in elements)
            {
                EditResult result = e.Write(address, data, oriData, labels);
                if (result != EditResult.NoErrors)
                {
                    return(result);
                }

                address += e.Length;
            }
            return(EditResult.NoErrors);
        }
Пример #17
0
        private PartialParseResult TryPartialParse(TextChange change)
        {
            PartialParseResult result = PartialParseResult.Rejected;

            // Try the last change owner
            if (_lastChangeOwner != null && _lastChangeOwner.EditHandler.OwnsChange(_lastChangeOwner, change))
            {
                EditResult editResult = _lastChangeOwner.EditHandler.ApplyChange(_lastChangeOwner, change);
                result = editResult.Result;
                if (!editResult.Result.HasFlag(PartialParseResult.Rejected))
                {
                    _lastChangeOwner.ReplaceWith(editResult.EditedSpan);
                }

                // If the last change was provisional, then the result of this span's attempt to parse partially goes
                // Otherwise, accept the change if this span accepted it, but if it didn't, just do the standard search.
                if (LastResultProvisional || result.HasFlag(PartialParseResult.Accepted))
                {
                    return(result);
                }
            }

            // Locate the span responsible for this change
            _lastChangeOwner = CurrentParseTree.LocateOwner(change);

            if (LastResultProvisional)
            {
                // Last change owner couldn't accept this, so we must do a full reparse
                result = PartialParseResult.Rejected;
            }
            else if (_lastChangeOwner != null)
            {
                EditResult editRes = _lastChangeOwner.EditHandler.ApplyChange(_lastChangeOwner, change);
                result = editRes.Result;
                if (!editRes.Result.HasFlag(PartialParseResult.Rejected))
                {
                    _lastChangeOwner.ReplaceWith(editRes.EditedSpan);
                }
                if (result.HasFlag(PartialParseResult.AutoCompleteBlock))
                {
                    _lastAutoCompleteSpan = _lastChangeOwner;
                }
                else
                {
                    _lastAutoCompleteSpan = null;
                }
            }
            return(result);
        }
Пример #18
0
        /// <summary>
        /// 图片编辑完成后
        /// </summary>
        /// <param name="result"></param>
        private void PhotoEdit_Complated(Task <string> value)
        {
            EditResult editResult = JsonConvert.DeserializeObject <EditResult>(value.Result);

            if (editResult == null)
            {
                System.Windows.MessageBox.Show("Edit Failed");
            }
            else
            {
                File.Copy(editResult.Paths.Replace(@"/", "\\"), UploadFile.FileFullName, true);
            }
            this.Dispatcher.Invoke(() =>
            {
                App.CurrentWindow.brMain.Child = ParentControl;
            });
        }
Пример #19
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();

                var project       = existingMasterModel.CreateProject(x => x.Name = "Existing Project");
                var existingGroup = project.CreateGroup(x => x.Name = "Existing Group");

                var repository = new StubMasterModelRepository();

                repository.UseCurrentModel(existingMasterModel);

                var creator = new LightGroupManager(repository);

                _result = creator.Update(existingGroup.Id, "Existing Group");

                _savedModel = repository.LastSaved;
            }
Пример #20
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();

                existingMasterModel.CreateProject(x => x.Name = "Existing Project");
                existingMasterModel.CreateProject(x => x.Name = "Existing Project 2");
                existingMasterModel.CreateProject(x => x.Name = "Existing Project 3");

                _repository = new StubMasterModelRepository();
                _repository.UseCurrentModel(existingMasterModel);

                var manager = new ProjectManager(_repository);

                _result = manager.Delete(_deleteId);

                _savedModel = _repository.LastSaved;
            }
Пример #21
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();
                var parentProject       = existingMasterModel.CreateProject(x => x.Name = "Existing Project");
                var existingGroup       = parentProject.CreateGroup(x => x.Name = "Existing Group");

                _idDoesNotExist = Guid.NewGuid();

                var repository = new StubMasterModelRepository();

                repository.UseCurrentModel(existingMasterModel);

                var creator = new LightGroupManager(repository);

                _result = creator.Delete(_idDoesNotExist);

                _savedModel = repository.LastSaved;
            }
Пример #22
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();

                existingMasterModel.CreateProject(x => x.Name = "Existing Project");
                existingMasterModel.CreateProject(x => x.Name = "Existing Project 2");
                existingMasterModel.CreateProject(x => x.Name = "Existing Project 3");

                _repository = new StubMasterModelRepository();
                _repository.UseCurrentModel(existingMasterModel);

                var manager = new ProjectManager(_repository);

                _result = manager.Update(new EditProject {
                    ProjectId = _deleteId, Name = "Value doesn't matter"
                });

                _savedModel = _repository.LastSaved;
            }
Пример #23
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();

                existingMasterModel.CreateProject(x => x.Name = "Existing Project");
                var projectToEdit = existingMasterModel.CreateProject(x => x.Name = "Keep This");

                existingMasterModel.CreateProject(x => x.Name = "Existing Project 3");

                var repository = new StubMasterModelRepository();

                repository.UseCurrentModel(existingMasterModel);

                var creator = new ProjectManager(repository);

                _result = creator.Update(new EditProject {
                    ProjectId = projectToEdit.Id, Name = "Keep This"
                });
            }
Пример #24
0
 public EditSVBasic(object[] DATA, EditResult Res)
 {
     InitializeComponent();
     if (DATA.Length <= OUT_DATA.Length)
     {
         for (int i = 0; i < DATA.Length; i++)
         {
             OUT_DATA[i] = DATA[i];
         }
     }
     tbNumber.Text         = (string)OUT_DATA[0];
     dtpVvoda.Value        = (DateTime)OUT_DATA[1];
     cbTypeTO.SelectedItem = OUT_DATA[2];
     dtpDateTo.Value       = (DateTime)OUT_DATA[3];
     cbXN.Checked          = (bool)OUT_DATA[4];
     tbType.Text           = (string)OUT_DATA[5];
     cbAB.SelectedItem     = (string)OUT_DATA[6].ToString();
     tbFUAB.Text           = (string)OUT_DATA[7];
     cbBlock.SelectedItem  = (string)OUT_DATA[8].ToString();
 }
Пример #25
0
        public EditResult <LightGroup> Delete(Guid groupId)
        {
            var masterModel = _masterModelRepository.GetCurrent();
            var group       = masterModel.Projects
                              .SelectMany(x => x.Groups)
                              .SingleOrDefault(x => x.Id.Equals(groupId));

            if (group == null)
            {
                return(EditResult.Fail <LightGroup>(BadId(groupId)));
            }

            group.UnassignAllLights();

            var parent = group.ParentProject;

            parent.RemoveGroup(group);

            _masterModelRepository.Save(masterModel);
            return(EditResult.Success <LightGroup>(null));
        }
Пример #26
0
 public EditOPS(float[] DATA, EditResult Res)
 {
     InitializeComponent();
     radio_check(Auto_Manual);
     if (Res == EditResult.EditData)
     {
         for (int i = 0; i < OUT_DATA.Length; i++)
         {
             OUT_DATA[i] = DATA[i];
         }
         tB321.Text = OUT_DATA[0].ToString("N3");
         tB322.Text = OUT_DATA[1].ToString("N3");
         tB323.Text = OUT_DATA[2].ToString("N3");
         tB324.Text = OUT_DATA[3].ToString("N3");
         tB325.Text = OUT_DATA[4].ToString("N3");
         tB326.Text = OUT_DATA[5].ToString("N3");
         tB327.Text = OUT_DATA[6].ToString("N3");
         tB328.Text = OUT_DATA[7].ToString("N3");
         tB330.Text = OUT_DATA[8].ToString("N3");
         tB332.Text = OUT_DATA[9].ToString("N3");
     }
 }
Пример #27
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();

                _parentProject = existingMasterModel.CreateProject(x => x.Name = "Existing Project");
                var existingGroup = _parentProject.CreateGroup(x => x.Name = "Existing Group");

                existingGroup.AddLight(new Light(new ZWaveValueIdentity(1, 1, 123)));
                existingGroup.AddLight(new Light(new ZWaveValueIdentity(1, 2, 123)));
                _remainingGroup = _parentProject.CreateGroup();
                _remainingGroup.AddLight(new Light(new ZWaveValueIdentity(1, 10, 123)));

                var repository = new StubMasterModelRepository();

                repository.UseCurrentModel(existingMasterModel);

                var creator = new LightGroupManager(repository);

                _result = creator.Delete(existingGroup.Id);

                _savedModel = repository.LastSaved;
            }
Пример #28
0
 public EditVerPO(string[] DATA, EditResult Res)
 {
     InitializeComponent();
     if (Res == EditResult.EditData)
     {
         if (DATA.Length <= OUT_DATA.Length)
         {
             for (int i = 0; i < DATA.Length; i++)
             {
                 OUT_DATA[i] = DATA[i];
             }
         }
         else
         {
             MessageBox.Show("Не верные размеры массива.");
         }
         tbARV.Text     = OUT_DATA[0];
         tbLink.Text    = OUT_DATA[1];
         tbDisplay.Text = OUT_DATA[2];
         tbLogView.Text = OUT_DATA[3];
         tbBMTZ.Text    = OUT_DATA[4];
     }
 }
Пример #29
0
        internal static bool TreesAreDifferent(Block leftTree, Block rightTree, IEnumerable <TextChange> changes, CancellationToken cancelToken)
        {
            // Apply all the pending changes to the original tree
            // PERF: If this becomes a bottleneck, we can probably do it the other way around,
            //  i.e. visit the tree and find applicable changes for each node.
            foreach (TextChange change in changes)
            {
                cancelToken.ThrowIfCancellationRequested();
                Span changeOwner = leftTree.LocateOwner(change);

                // Apply the change to the tree
                if (changeOwner == null)
                {
                    return(true);
                }
                EditResult result = changeOwner.EditHandler.ApplyChange(changeOwner, change, force: true);
                changeOwner.ReplaceWith(result.EditedSpan);
            }

            // Now compare the trees
            bool treesDifferent = !leftTree.EquivalentTo(rightTree);

            return(treesDifferent);
        }
Пример #30
0
 /// <summary>
 /// 在指定的数据集中,更新一组要素。
 /// 参数 targetFeatures 是新要素列表,其要素 ID 与数据集中待更新的要素 ID 相同,根据 ID 查找到待更新的要素, 然后将原要素更新到新的要素。
 /// </summary>
 /// <param name="datasourceName">数据源名称。</param>
 /// <param name="datasetName">数据源名称。</param>
 /// <param name="targetFeatures">新要素列表。其 ID 与要更新的要素 ID 相同。</param>
 /// <returns></returns>
 public EditResult UpdateFeatures(string datasourceName, string datasetName, List<Feature> targetFeatures)
 {
     EditResult editResult = new EditResult();
     if (string.IsNullOrEmpty(datasourceName))
     {
         editResult.Succeed = false;
         editResult.Message = string.Format(Resources.ParamIsNotNull, "datasourceName");
         return editResult;
     }
     if (string.IsNullOrEmpty(datasetName))
     {
         editResult.Succeed = false;
         editResult.Message = string.Format(Resources.ParamIsNotNull, "datasetName");
         return editResult;
     }
     if (targetFeatures == null || targetFeatures.Count <= 0)
     {
         editResult.Succeed = false;
         editResult.Message = string.Format(Resources.ParamIsNotNull, "targetFeatures");
         return editResult;
     }
     else
     {
         int featureCount = targetFeatures.Count;
         for (int i = 0; i < featureCount; i++)
         {
             if (targetFeatures[i].Id <= 0)
             {
                 editResult.Succeed = false;
                 editResult.Message = string.Format(Resources.ParamIsInvalid, "Feature.Id");
                 return editResult;
             }
             else if (targetFeatures[i].Geometry != null)
             {
                 targetFeatures[i].Geometry.Id = targetFeatures[i].Id;
             }
             if (targetFeatures[i].FieldNames == null)
             {
                 targetFeatures[i].FieldNames = new string[] { };
             }
             if (targetFeatures[i].FieldValues == null)
             {
                 targetFeatures[i].FieldValues = new string[] { };
             }
         }
     }
     string uri = string.Format("{0}/data/datasources/{1}/datasets/{2}/features.json?_method=PUT", this._serviceUrl,
         datasourceName, datasetName);
     string postData = JsonConvert.SerializeObject(targetFeatures);
     string requestResultJson = string.Empty;
     try
     {
         requestResultJson = SynchHttpRequest.GetRequestString(uri, postData);
         editResult = JsonConvert.DeserializeObject<EditResult>(requestResultJson);
     }
     catch (ServiceException e)
     {
         editResult.Succeed = false;
         editResult.Message = e.Message;
         return editResult;
     }
     return editResult;
 }
Пример #31
0
        /// <summary>
        /// 在指定的数据集中删除一组要素。
        /// </summary>
        /// <param name="datasourceName">数据源名称。</param>
        /// <param name="datasetName">数据集名称。</param>
        /// <param name="ids">待删除要素的 ID 数组。</param>
        /// <returns>编辑结果。</returns>
        public EditResult DeleteFeatures(string datasourceName, string datasetName, int[] ids)
        {
            EditResult editResult = new EditResult();
            if (string.IsNullOrEmpty(datasourceName))
            {
                editResult.Succeed = false;
                editResult.Message = string.Format(Resources.ParamIsNotNull, "datasourceName");
                return editResult;
            }
            if (string.IsNullOrEmpty(datasetName))
            {
                editResult.Succeed = false;
                editResult.Message = string.Format(Resources.ParamIsNotNull, "datasetName");
                return editResult;
            }
            if (ids == null || ids.Length <= 0)
            {
                editResult.Succeed = false;
                editResult.Message = string.Format(Resources.ParamIsNotNull, "ids");
                return editResult;
            }
            string uri = string.Format("{0}/data/datasources/{1}/datasets/{2}/features.json?_method=DELETE", this._serviceUrl,
                datasourceName, datasetName);
            string postData = JsonConvert.SerializeObject(ids);
            string requestResultJson = string.Empty;

            try
            {
                requestResultJson = SynchHttpRequest.GetRequestString(uri, postData);
                editResult = JsonConvert.DeserializeObject<EditResult>(requestResultJson);
            }
            catch (ServiceException e)
            {
                editResult.Succeed = false;
                editResult.Message = e.Message;
                return editResult;
            }
            return editResult;
        }
Пример #32
0
 private static EditResult <Project> CouldNotLocateProject(Guid id)
 {
     return(EditResult.Fail <Project>(string.Format("Could not locate a project with Id '{0}'", id)));
 }
Пример #33
0
        /// <summary>
        /// 在指定数据集中增加一组同类型的要素。
        /// </summary>
        /// <param name="datasourceName">数据源名称。</param>
        /// <param name="datasetName">数据集名称。</param>
        /// <param name="targetFeatures">待添加的要素列表,列表中的要素必须是同一种类型。</param>
        /// <returns></returns>
        public EditResult AddFeatures(string datasourceName, string datasetName, List<Feature> targetFeatures)
        {
            EditResult editResult = new EditResult();
            if (string.IsNullOrEmpty(datasourceName))
            {
                editResult.Succeed = false;
                editResult.Message = string.Format(Resources.ParamIsNotNull, "datasourceName");
                return editResult;
            }
            if (string.IsNullOrEmpty(datasetName))
            {
                editResult.Succeed = false;
                editResult.Message = string.Format(Resources.ParamIsNotNull, "datasetName");
                return editResult;
            }
            if (targetFeatures == null || targetFeatures.Count <= 0)
            {
                editResult.Succeed = false;
                editResult.Message = string.Format(Resources.ParamIsNotNull, "targetFeatures");
                return editResult;
            }

            int featureCount = targetFeatures.Count;
            for (int i = 0; i < featureCount; i++)
            {
                if (targetFeatures[i].FieldNames == null)
                {
                    targetFeatures[i].FieldNames = new string[] { };
                }
                if (targetFeatures[i].FieldValues == null)
                {
                    targetFeatures[i].FieldValues = new string[] { };
                }
            }
            string uri = string.Format("{0}/data/datasources/{1}/datasets/{2}/features.json?returnContent=true", this._serviceUrl,
                datasourceName, datasetName);
            string postData = JsonConvert.SerializeObject(targetFeatures);
            string requestResultJson = string.Empty;

            try
            {
                requestResultJson = SynchHttpRequest.GetRequestString(uri, postData);
            }
            catch (ServiceException e)
            {
                editResult.Succeed = false;
                editResult.Message = e.Message;
                return editResult;
            }
            //处理返回的ids ,[167,168] 
            string[] idsStr = requestResultJson.Replace("[", "").Replace("]", "").Trim().Split(',');
            int idsNum = idsStr.Length;
            editResult.Ids = new int[idsNum];
            for (int i = 0; i < idsNum; i++)
            {
                int.TryParse(idsStr[i].Trim(), out editResult.Ids[i]);
            }
            //判断ids的个数,小于等于0,即判定为添加要素错误
            if (idsNum > 0)
            {
                editResult.Succeed = true;
            }
            else
            {
                editResult.Succeed = false;
            }
            return editResult;
        }