Hi I have the following code below for zooming into an arcGIS object based on the attribute now all I need is to be able to highlight that area with a select feature (The feature where you right-click on the area on the map and do select feature).
Currently I have an event which will do the zoom.I want to add this select to the same attribute as well.
Thank you in advance!!!
ESRI.ArcGIS.Carto.ILayer layer = GetLayersClass.GetFieldBoundaryLayer;
if (layer is ESRI.ArcGIS.Carto.IGroupLayer)
{
ESRI.ArcGIS.Carto.IGroupLayer groupLayer = layer as ESRI.ArcGIS.Carto.IGroupLayer;
ICompositeLayer pCompositeLayer = layer as ICompositeLayer;
int layers = pCompositeLayer.Count;
ILayer pLayer = pCompositeLayer.Layer[0];
IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IQueryFilter pFilter = new QueryFilterClass();
pFilter.WhereClause = "RightID = '" + selectedRightID.ToString() + "'";
IFeatureCursor pFeatureCursor = pFeatureClass.Search(pFilter, false);
IFeature pFeature = pFeatureCursor.NextFeature();
if (pFeature == null)
{
System.Windows.Forms.MessageBox.Show("This section doesn't exist");
return;
}
IApplication m_application = ArcMap.Application;
IMxDocument pMxDoc = (IMxDocument)m_application.Document;
IActiveView pActiveView = (IActiveView)pMxDoc.FocusMap;
IEnvelope pEnv = pFeature.Shape.Envelope;
pEnv.Expand(1.1, 1.1, true);
pActiveView.Extent = pEnv;
pActiveView.Refresh();
I tried by adding this code which I think will add the particular feature to the selection.
but no luck with that as well.
IFeatureSelection pfeatSelect = pFeatureLayer as IFeatureSelection;
pfeatSelect.Add(pFeature);
If I understand you correctly, all you need is this:
IFeatureSelection featSelect = pFeatureLayer as IFeatureSelection;
featSelect.SelectFeatures(pFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
This will select all Features that match your filter.
This solution is working for me
IFeatureLayer PFeaLayer = (IFeatureLayer)pLayer;
IFeatureSelection PFeaSel = (IFeatureSelection)PFeaLayer;
int OIDIndex = PFeature.Fields.FindField("OBJECTID");
PFeaSel.SelectionSet.Add(Convert.ToInt32(PFeature.get_Value(OIDIndex)));
ISelectionSet PFeaSelSet = PFeaSel.SelectionSet;
IEnumGeometry pEnumGeom = new EnumFeatureGeometryClass();
IEnumGeometryBind pEnumGeomBind = (IEnumGeometryBind)pEnumGeom;
pEnumGeomBind.BindGeometrySource(null, PFeaSelSet);
IGeometryFactory pGeomFactory = new GeometryEnvironmentClass();
IGeometry pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom);
IMxDocument pMxDoc = ArcMap.Document as IMxDocument;
IActiveView activeView = pMxDoc.ActiveView;
double midX = (pGeom.Envelope.XMax + pGeom.Envelope.XMin) / 2;
double midY = (pGeom.Envelope.YMax + pGeom.Envelope.YMin) / 2;
IPoint pPoint = new PointClass();
pPoint.SpatialReference = pGeom.Envelope.SpatialReference;
pPoint.PutCoords(midX, midY);
pPoint.Project(activeView.Extent.SpatialReference);
IEnvelope pCurrentEnvelope = activeView.Extent;
pCurrentEnvelope.CenterAt(pPoint);
activeView.Extent = pCurrentEnvelope;
activeView.Refresh();
Related
I'm trying to download a MapProvider to use offline map but i dont know how to download.
it works when i use ServerOnly.
This is my code:
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
_map = new GMapControl();
Map.MapProvider = GMap.NET.MapProviders.BingHybridMapProvider.Instance;
Map.DragButton = MouseButton.Left;
Map.MinZoom = 2;
Map.MaxZoom = 18;
Map.Zoom = 5;
Map.CanDragMap = true;
Map.Position = new GMap.NET.PointLatLng(48.8589507, 2.2775175);
Map.ShowCenter = false;
Thank you everyone
You can cache the map in the local storage using the ServerAndCache found in GMap.NET.AccessMode
The following function will do the work:
private void gMapStoreOffline(int lat, int lng)
{
gMapControl1.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
GMap.NET.MapProviders.OpenStreetMapProvider.UserAgent = "IE";
gMapControl1.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;
GMaps.Instance.OptimizeMapDb(null);
// Define the location to cache the file
gMapControl1.CacheLocation = #"C:\Users\<username>\..";
gMapControl1.Zoom = 14;
gMapControl1.Size = new Size(this.Width, this.Height);
gMapControl1.ShowCenter = false;
gMapControl1.Position = new GMap.NET.PointLatLng(lat, lng)
}
I am working on creating a team in TFS using C# and the dll's provided. I'm having a hard time setting the default Area and could use some help.
VssCredentials vc = new VssCredentials(true);
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(TFS_CONNECTION_URL), vc);
tpc.Authenticate();
TfsTeamService teamService = tpc.GetService<TfsTeamService>();
ProjectInfo projectInfo = cssService.GetProjectFromName(TEAM_PROJECT_NAME);
TeamFoundationTeam team = teamService.CreateTeam(projectInfo.Uri, teamName, teamDescription, null);
ICommonStructureService css = tpc.GetService<ICommonStructureService>();
foreach (NodeInfo ni in css.ListStructures(projectInfo.Uri))
{
//ProjectModelHierarchy is for areas
if (ni.StructureType.Equals("ProjectModelHierarchy"))
{
string n0Uri = ni.Uri;
//creates the team name area under the top level team project area.
string n1Uri = css.CreateNode(teamName, n0Uri);
}
}
//AND HERE'S WHERE I WANT TO SET THE DEFAULT AREA
//I have tried the following but it doesn't work
//team.SetProperty("defaultArea", "\\" + teamName);
I have tried many combinations of the property name but to no avail. And I assure you, this code above does create a team in my team project in TFS.
var tfv = new TeamFieldValue();
var ts = team.TeamSettings;
tfv.IncludeChildren = true;
tfv.Value = "\\" + teamName;
ts.TeamFieldValues = new []{tfv};
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri("tfsuri"));
TfsTeamService teamService = ttpc.GetService<TfsTeamService>();
ICommonStructureService icss = ttpc.GetService<ICommonStructureService>();
ProjectInfo projectInfo = icss.GetProjectFromName("ProjectName");
var newteam = teamService.CreateTeam(projectInfo.Uri, "TeamName", null, null);
TeamSettingsConfigurationService tscs = ttpc.GetService<TeamSettingsConfigurationService>();
IEnumerable<Guid> teamsid = new Guid[] {newteam.Identity.TeamFoundationId };
var teamsconfig = tscs.GetTeamConfigurations(teamsid);
TeamConfiguration tc = teamsconfig.First();
TeamFieldValue tfv = new TeamFieldValue();
tfv.IncludeChildren = true;
tfv.Value = "AreaPath";
tc.TeamSettings.TeamFieldValues = new TeamFieldValue[] {tfv};
tc.TeamSettings.BacklogIterationPath = "IterationPath";
tscs.SetTeamSettings(tc.TeamId,tc.TeamSettings);
I have an Amazon EC2 instance and I need to be able to create an AMI (image) from it programmatically. I'm trying the following:
CreateImageRequest rq = new CreateImageRequest();
rq.InstanceId = myInstanceID;
rq.Name = instance.KeyName;
rq.Description = "stam";
rq.NoReboot = true;
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
try
{
imageResp = ec2.CreateImage(rq);
}
catch (AmazonServiceException ase)
{
MessageBox.Show(ase.Message);
}
The result is always an AmazonServiceException saying that there is a NameResolutionFailure.
How do I overcome this? I tried different possible "name" possibilities but cannot find the right one.
string amiID = ConfigurationManager.AppSettings[AmazonConstants.AwsImageId];
string keyPairName = ConfigurationManager.AppSettings[AmazonConstants.AwsKeyPair];
List<string> groups = new List<string>() { ConfigurationManager.AppSettings[AmazonConstants.AwsSecurityGroupId] };
var launchRequest = new RunInstancesRequest()
{
ImageId = amiID,
InstanceType = ConfigurationManager.AppSettings[AmazonConstants.AwsInstanceType],
MinCount = 1,
MaxCount = 1,
KeyName = keyPairName,
SecurityGroupIds = groups,
SubnetId = ConfigurationManager.AppSettings[AmazonConstants.AwsSubnetId]
};
RunInstancesResponse runInstancesResponse = amazonEc2client.RunInstances(launchRequest);
RunInstancesResult runInstancesResult = runInstancesResponse.RunInstancesResult;
Reservation reservation = runInstancesResult.Reservation;
Problem eventually solved!
it turned out thyat some codelines were doing things which were already done already and removing this part:
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
Made things clearer and no wrong repetitions happened! Now it works!
From my WCF Service, I need to create a purchase order in SAP system and it's creating. But when I tried to commit the transaction it's not effecting in SAP system.
I am getting PONumber from SAP and it's not committing.
Can any one help me on this issue.
Here is my code:
NFCLMasters.ZMASTERDATA zmobj = new NFCLMasters.ZMASTERDATA();
NFCLMasters.ZMASTERDATAResponse zmresponse = new NFCLMasters.ZMASTERDATAResponse();
NFCLMasters.ZSM_WH_MST[] zmwarehousemaster = new NFCLMasters.ZSM_WH_MST[10];
NFCLMasters.zws_mst mst = new NFCLMasters.zws_mst();
zmobj.IWHMST = "X";
zmobj.WHMST_LINES = zmwarehousemaster;
zmresponse = mst.ZMASTERDATA(zmobj);
NFCLTransactions.BAPI_PO_CREATE1 Zpo = new NFCLTransactions.BAPI_PO_CREATE1();
NFCLTransactions.BAPI_PO_CREATE1Response Zporesponse = new NFCLTransactions.BAPI_PO_CREATE1Response();
NFCLTransactions.zws_lo SapTrasactions = new NFCLTransactions.zws_lo ();
// Data objects
NFCLTransactions.BAPIMEPOHEADER poheader = new NFCLTransactions.BAPIMEPOHEADER();
NFCLTransactions.BAPIMEPOHEADERX poheaderx = new NFCLTransactions.BAPIMEPOHEADERX();
NFCLTransactions.BAPIMEPOITEM[] poitem = new NFCLTransactions.BAPIMEPOITEM[1];
NFCLTransactions.BAPIMEPOITEMX[] poitemx = new NFCLTransactions.BAPIMEPOITEMX[1];
NFCLTransactions.BAPIMEPOSCHEDULE[] poschedule = new NFCLTransactions.BAPIMEPOSCHEDULE[1];
NFCLTransactions.BAPIMEPOSCHEDULX[] poschedulex = new NFCLTransactions.BAPIMEPOSCHEDULX[1];
NFCLTransactions.BAPIITEMSHIP[] poitemship = new NFCLTransactions.BAPIITEMSHIP[1];
NFCLTransactions.BAPIITEMSHIPX[] poitemshipx = new NFCLTransactions.BAPIITEMSHIPX[1];
NFCLTransactions.BAPIRET2[] Bapireturn = new NFCLTransactions.BAPIRET2[100];
// ASSIGNING VALUES TO EACH OBJECT AND ADDING MAIN BAPI
poheader.COMP_CODE = "NFCL"; poheader.DOC_TYPE = "ZPPS"; poheader.PURCH_ORG = "MKTG"; poheader.PUR_GROUP = "M13"; poheader.DOC_DATE = "2015-02-06";
poheader.SUPPL_PLNT = "1311"; poheader.OUR_REF = "R006";
Zpo.POHEADER = poheader;
poheaderx.COMP_CODE = "X"; poheaderx.DOC_TYPE = "X"; poheaderx.PMNTTRMS = "X"; poheaderx.PURCH_ORG = "X"; poheaderx.PUR_GROUP = "X";
poheaderx.SUPPL_PLNT = "X"; poheaderx.OUR_REF = "X";
Zpo.POHEADERX = poheaderx;
poitem[0] = new NFCLTransactions.BAPIMEPOITEM();
poitem[0].PO_ITEM = "00001"; poitem[0].MATERIAL = "U01016501F"; poitem[0].PLANT = "1311"; poitem[0].STGE_LOC = "K038"; poitem[0].QUANTITY = 10;
poitem[0].PERIOD_IND_EXPIRATION_DATE = "D";
Zpo.POITEM = poitem;
poitemx[0] = new NFCLTransactions.BAPIMEPOITEMX();
poitemx[0].PO_ITEM = "00001"; poitemx[0].MATERIAL = "X"; poitemx[0].PLANT = "X"; poitemx[0].STGE_LOC = "X"; poitemx[0].QUANTITY = "X";
poitemx[0].VAL_TYPE = "X"; poitemx[0].BATCH = "X";
Zpo.POITEMX = poitemx;
poschedule[0] = new NFCLTransactions.BAPIMEPOSCHEDULE();
poschedule[0].PO_ITEM = "00001"; poschedule[0].DELIVERY_DATE = "06.02.2015"; poschedule[0].QUANTITY = 10;
//poschedule[0].DELIV_TIME = 'X';
// poschedule[0].GR_END_TIME
Zpo.POSCHEDULE = poschedule;
poschedulex[0] = new NFCLTransactions.BAPIMEPOSCHEDULX();
poschedulex[0].PO_ITEM = "00001"; poschedulex[0].PO_ITEMX = "X"; poschedulex[0].DELIVERY_DATE = "X"; poschedulex[0].QUANTITY = "X";
Zpo.POSCHEDULEX = poschedulex;
poitemship[0] = new NFCLTransactions.BAPIITEMSHIP();
poitemship[0].PO_ITEM = "00001"; poitemship[0].SHIP_POINT = "R006";
Zpo.POSHIPPING = poitemship;
poitemshipx[0] = new NFCLTransactions.BAPIITEMSHIPX();
poitemshipx[0].PO_ITEM = "00001"; poitemshipx[0].SHIP_POINT = "X";
Zpo.POSHIPPINGX = poitemshipx;
Zpo.RETURN = Bapireturn;
NFCLTransactions.BAPI_TRANSACTION_COMMIT transcommit = new NFCLTransactions.BAPI_TRANSACTION_COMMIT();
transcommit.WAIT = "X";
Zporesponse = SapTrasactions.BAPI_PO_CREATE1(Zpo);
response = Zporesponse.EXPPURCHASEORDER;
NFCLTransactions.BAPI_TRANSACTION_COMMITResponse resp = SapTrasactions.BAPI_TRANSACTION_COMMIT(transcommit);
Your two BAPI calls are currently executed in individual contexts. Therefore the second call to BAPI_TRANSACTION_COMMIT won't work because the second call context doesn't know anything about the results from the first call. You need to execute both calls within the same context. I don't know how to do that with the old, deprecated SAP .Net Connector, but with the current SAP Nco 3 you can achive it by using the methods RfcSessionManager.BeginContext() and RfcSessionManager.EndContext().
If the BAPIs are only exposed as web services, a commit probably won't succeed because all calls to those web services are executed in their own context, so you have the same problem again. A workaround for using web services and BAPI_TRANSACTION_COMMIT would be to create a custom function module in the SAP system that first calls your BAPI and if that call succeeds, calls BAPI_TRANSACTION_COMMIT. That function module would have to be RFC capable and could be exposed as a web service for you. The parameters for that custom function module would (at least) be the same as for the BAPI you need, maybe an additional "COMMIT" parameter to allow you calling it without committing anything. Creating such a function module is relatively easy and shouldn't be a problem for a company familiar with SAP ERP.
ORU_R01_OBSERVATION observation = orderObservation.GetOBSERVATION(0);
OBX obx = observation.OBX;
obx.ValueType.Value = "AD";
obx.ObservationIdentifier.Identifier.Value = "Report";
obx.ObservResultStatus.Value = "F";
Here i want to add the OBX-5 Observation Value. How can i add this ?
I know this is a very late answer but I hope it can help someone in future. This is how I set my OBX segment value.
ORU_R01 oru = new ORU_R01();
ORU_R01_ORDER_OBSERVATION orderObservation = oru.GetRESPONSE().GetORDER_OBSERVATION();
OBX obx = orderObservation.GetOBSERVATION(0).OBX;
obx.ValueType.Value = "AD";
obx.ObservationIdentifier.Identifier.Value = "Report";
obx.ObservResultStatus.Value = "F";
CE ce = new CE(oru);
ce.Identifier.Value = obv.ObservationValue;
Varies value = obx.GetObservationValue(0);
value.Data = ce;
Hope this helps.
This is the code that originally pointed to by #hardrada :
this is a late answer because i've been trying to find something like this myself recently, and I feel there aren't enough HL7 examples about
it was found via the wayback machine here :
http://web.archive.org/web/20130318202508/http://www.ecomb.ch/nhapi-example-for-creating-a-hl7-message-with-msh-pid-pv1-obr-and-obx-segment/
private string createHL7()
{
ORU_R01 oruR01 = new ORU_R01();
ORU_R01_ORDER_OBSERVATION orderObservation = oruR01.GetRESPONSE().GetORDER_OBSERVATION();
ORU_R01_PATIENT patient = oruR01.GetRESPONSE().PATIENT;
ORU_R01_VISIT visit = patient.VISIT;
PV1 pv1 = visit.PV1;
OBR obr = orderObservation.OBR;
ORU_R01_OBSERVATION observation = orderObservation.GetOBSERVATION(0);
OBX obx = observation.OBX;
oruR01.MSH.FieldSeparator.Value = "|";
oruR01.MSH.EncodingCharacters.Value = #"^~\&";
oruR01.MSH.SendingApplication.NamespaceID.Value = "SP";
oruR01.MSH.SendingFacility.NamespaceID.Value = "SPZH";
oruR01.MSH.ReceivingApplication.NamespaceID.Value = "MF";
oruR01.MSH.ReceivingFacility.NamespaceID.Value = "INTRA";
oruR01.MSH.DateTimeOfMessage.TimeOfAnEvent.SetLongDate(DateTime.Now);
oruR01.MSH.ProcessingID.ProcessingID.Value = "P";
oruR01.MSH.VersionID.Value = "2.3";
PID pid = oruR01.GetRESPONSE().PATIENT.PID;
pid.SetIDPatientID.Value = "12345";
pid.PatientName.FamilyName.Value = "Joe";
pid.PatientName.GivenName.Value = "Bloggs";
pid.DateOfBirth.TimeOfAnEvent.SetLongDate(DateTime.MinValue);
pid.Sex.Value = "M";
pv1.SetIDPatientVisit.Value = "1";
pv1.VisitNumber.ID.Value = "3333333";
obr.FillerOrderNumber.UniversalID.Value = "123456";
obr.UniversalServiceIdentifier.Text.Value = "Document";
obr.ObservationEndDateTime.TimeOfAnEvent.SetLongDate(DateTime.Now);
obr.ResultStatus.Value = "F";
obx.SetIDOBX.Value = "0";
obx.ValueType.Value = "RP";
obx.ObservationIdentifier.Identifier.Value = "Report";
PipeParser parser = new PipeParser();
string encodedMessage = parser.Encode(oruR01);
return encodedMessage;
}