Esempio n. 1
0
 public static void SetResourceFromXml(HtzMgHelper helper, MgResourceIdentifier resourceId, XmlDocument doc)
 {
     byte[] layerDef = new UTF8Encoding().GetBytes(doc.InnerXml);
     MgByteSource byteSource = new MgByteSource(layerDef, layerDef.Length);
     byteSource.SetMimeType("text/xml");
     helper.ResourceService.SetResource(resourceId, byteSource.GetReader(), null);
 }
Esempio n. 2
0
 // Methods
 public static XmlDocument GetResourceXml(HtzMgHelper helper, MgResourceIdentifier resourceId)
 {
     XmlDocument result = new XmlDocument();
     if (resourceId != null)
     {
         result.LoadXml(helper.ResourceService.GetResourceContent(resourceId).ToString());
     }
     return result;
 }
Esempio n. 3
0
 public Feature(HtzMgHelper helper, string layerName, string filter, string uidKey)
 {
     this._identityFieldName = "FeatId";
     this._uidKey = string.IsNullOrEmpty(uidKey) ? "UID" : uidKey;
     this._helper = helper;
     this.Layer = this._helper.Map.GetLayers().GetItem(layerName) as MgLayer;
     this.Properties = new Dictionary<string, FeatureProperty>();
     this.GetFeatureFields();
     this.GetAdditionalValues();
     this.GetOrderValues();
 }
Esempio n. 4
0
 // Methods
 public HtzMaintenanceHelper(HtzMgHelper helper, MgLayer parentLayer, string uidKey)
 {
     this.ModuleAllowed = true;
     this.InitDefaultInfraTypes();
     this._helper = helper;
     this._uidKey = string.IsNullOrEmpty(uidKey) ? "UID" : uidKey;
     this._parentLayer = parentLayer;
     //if (this._helper.Configuration != null)
     //{
     //    this._config = this._helper.Configuration.GetProperties("FeatureCard");
     //    Dictionary<string, string> tmp = new Dictionary<string, string>();
     //    foreach (KeyValuePair<string, string> item in this._infraTypes)
     //    {
     //        if (!this._config.ContainsKey("ShowMaintFor" + item.Key))
     //        {
     //            this._helper.Configuration.RegisterPropertyDefinition("FeatureCard", "ShowMaintFor" + item.Key, item.Value, ConfigPropertyType.Boolean, "תחזוקה - הצגת שכבות", false);
     //        }
     //        else if ((bool)this._config["ShowMaintFor" + item.Key].Value)
     //        {
     //            tmp.Add(item.Key, item.Value);
     //        }
     //    }
     //    this._infraTypes = tmp;
     //}
     string mapPath = this._helper.Map.MapDefinition.Path;
     if (mapPath.LastIndexOf("/Maps") < 0)
     {
         this.ModuleAllowed = false;
     }
     else
     {
         this._maintenancePath = mapPath.Substring(0, mapPath.IndexOf("/Maps"));
         this._sdfResId = new MgResourceIdentifier(string.Format("Library://{0}/Maintenance/Data/Maintenance.FeatureSource", this._maintenancePath));
         this._layersResId = new List<MgResourceIdentifier>();
         if (!this._helper.ResourceService.ResourceExists(this._sdfResId))
         {
             this.CreateSdf(this._sdfResId);
         }
         foreach (KeyValuePair<string, string> item in this._infraTypes)
         {
             MgResourceIdentifier resId = new MgResourceIdentifier(string.Format("Library://{0}/Maintenance/Layers/Maint_{1}.LayerDefinition", this._maintenancePath, item.Key));
             this._layersResId.Add(resId);
             if (!this._helper.ResourceService.ResourceExists(resId))
             {
                 this.CreateLayer(resId, string.Format("InfrastructureType='{0}'", item.Value));
             }
         }
         this.AttachLayers();
         this._infraTypes.Add("none", "בחר מרשימה");
     }
 }
 public void Activate(HtzMgHelper helper, string uidKey, int uid, MgLayer parentLayer)
 {
     if (helper != null)
     {
         this._helper = helper;
         this._uid = uid;
         this._parentLayer = parentLayer;
         this._maintHelper = new HtzMaintenanceHelper(this._helper, parentLayer, uidKey);
         this._activated = this._maintHelper.ModuleAllowed;
     }
     else
     {
         this._activated = false;
     }
 }
Esempio n. 6
0
 public static int GetUidFromSelection(HtzMgHelper helper, MgSelection selection, string idField)
 {
     MgLayer layer = selection.GetLayers()[0] as MgLayer;
     if (layer == null)
     {
         return 0;
     }
     MgFeatureQueryOptions opt = new MgFeatureQueryOptions();
     opt.SetFilter(selection.GenerateFilter(layer, layer.FeatureClassName));
     MgFeatureReader reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, opt);
     reader.ReadNext();
     int result = (int)helper.GetFeaturePropertyValue(reader, idField);
     reader.Close();
     reader.Dispose();
     return result;
 }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                _activated=true;
                if (!base.IsPostBack)
                {
                    this.ViewState.Add("SESSION", base.Request["SESSION"]);
                    this.ViewState.Add("ProjectName", base.Request["ProjectName"]);
                    this.ViewState.Add("MAPNAME", base.Request["MAPNAME"]);

                    if (ViewState["IdField"] == null )
                    {
                        this.ViewState.Add("IdField", string.IsNullOrEmpty(IdField) ? "FeatId" : IdField);
                    }

                }
                if (!(this._activated ))
                {
                    this.lblControlError.Text = "אין אפשרות לבצע הפעולה לשכבה זו, אנא פנה למנהל מערכת";

                    //ErrorStrings.LayerNotSupported;
                    this.panelControlError.Visible = true;
                    this.UploaderPanel.Visible = false;
                }
                else
                {
                    //this.ViewState.Add("ProjectName", base.Request["ProjectName"]);
                    this._helper = new HtzMgHelper(this.ViewState["SESSION"].ToString(), this.ViewState["MAPNAME"].ToString(), null);
                    this._featureSource = this._helper.Selection.GetLayers().GetItem(0).GetFeatureSourceId();
                    try
                    {
                        this._featureId = HtzFileManager.GetUidFromSelection(this._helper, this.ViewState["IdField"].ToString());
                        this.UploaderPanel.Visible = true;
                    }
                    catch (MgException exx)
                    {
                        this.lblControlError.Text = exx.GetExceptionMessage();// "אין אפשרות לבצע הפעולה לשכבה זו, אנא פנה למנהל מערכת";//ErrorStrings.LayerNotSupported;
                        this.panelControlError.Visible = true;
                        this.UploaderPanel.Visible = false;
                    }
                    if (!base.IsPostBack)
                    {
                        this.BindFileList();
                    }
                }
            }
            catch (MgException ex)
            {
                this.ControlError(this, new ErrorEventArgs(ex));
            }
            catch (Exception ex)
            {
                this.ControlError(this, new ErrorEventArgs(ex));
            }
        }
Esempio n. 8
0
 public void Activate(HtzMgHelper helper, ModuleConfig config)
 {
     this._helper = helper;
     this._config = config;
     this._activated = true;
 }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int mgProjectId;

            if (!base.IsPostBack)
            {
                this.ViewState.Add("SESSION", base.Request["SESSION"]);
                this.ViewState.Add("MAPNAME", base.Request["MAPNAME"]);
                this.ViewState.Add("LAYOUT", base.Request["LAYOUT"]);
                this.ViewState.Add("UIDKEY", string.IsNullOrEmpty(base.Request["UIDKEY"]) ? "FeatId" : base.Request["UIDKEY"]);
                if (!int.TryParse(GetRequestParameters()["mgProjectId"], out mgProjectId)) return;
                ViewState.Add("mgProjectId", mgProjectId);
                this.ViewState.Add("ProjectName", base.Request["ProjectName"]);

                  this.FileUploadControl.IdField ="FeatId";
                            this.ViewState.Add("UIDKEY","FeatId");
                            this.ViewState.Add("IdField", "FeatId");

            }
            else
            {
                if (Session["SESSION"] == null)
                {
                    Session["SESSION"] = ViewState["SESSION"];
                }
                mgProjectId = (int)ViewState["mgProjectId"];

            }
               // this._config = new LayoutModulesConfiguration(this.ViewState["LAYOUT"].ToString());

            SiteUtilities siteUtilities = new SiteUtilities(new MapSettings(mgProjectId));
            // get properties from the xml

             //   ModuleConfig configProperties = this._config.GetProperties("FeatureCard");
            //if (configProperties.Count == 0)
            //{
            //    DefineControlProperties.Define("FeatureCard");
            //    configProperties = this._config.GetProperties("FeatureCard");
            //}
            this._helper = new HtzMgHelper(this.ViewState["SESSION"].ToString(), this.ViewState["MAPNAME"].ToString(), this.ViewState["LAYOUT"].ToString());
            _helper._projectname = this.ViewState["ProjectName"].ToString();
               // fpCollection = new FeatPropertyCollection(siteUtilities, ViewState["LayerName"].ToString(), ViewState["Filter"].ToString());
            // this.Master.ErrorVisible = false;
            if (!base.IsPostBack)
            {
                if (this._helper.Selection.GetLayers() == null)
                {
                    // this.Master.ShowErrorMessage("לא נבחר האובייקט");
                    return;
                }
                this.ViewState.Add("LayerName", this._helper.Selection.GetLayers().GetItem(0).GetName());
            }

            MgLayer layer = (MgLayer)this._helper.Map.GetLayers().GetItem(this.ViewState["LayerName"].ToString());
            if (!base.IsPostBack)
            {
                string filter = this._helper.Selection.GenerateFilter(layer, layer.GetFeatureClassName());
                if (filter == "")
                {
                    base.Response.Write("האופציה הזו לא קיימת לפרית הזאת.");
                    base.Response.End();
                }
                this.ViewState.Add("Filter", filter);
            }
            this.featureEditorControl.Filter = this.ViewState["Filter"].ToString();
            try
            {
                Feature feature = Feature.GetSingleFeature(this._helper, this.ViewState["Filter"].ToString(), this.ViewState["LayerName"].ToString(), this.ViewState["UIDKEY"].ToString());
                this.featureEditorControl.Activate(this._helper, feature);

              //  this.featureEditorControl.Activate(this._helper, feature);
                //((bool)configProperties["MaintenanceAllowed"].Value) ||
                //if (( feature.Layer.GetFeatureSourceId().Contains("Markup")) && feature.HaveUID)
                //{
                //    this.maintenanceControl.Activate(this._helper, this.ViewState["UIDKEY"].ToString(), feature.UID, feature.Layer);
                //    if (this.maintenanceControl.Activated)
                //    {
                //        this.MaintenanceDisabledPanel.Visible = false;
                //        this.maintenanceControl.Visible = true;
                //    }
                //    else
                //    {
                //        this.MaintenanceDisabledPanel.Visible = true;
                //        this.maintenanceControl.Visible = false;
                //    }
                //}
                //else
                //{
                //    this.MaintenanceDisabledPanel.Visible = true;
                //    this.maintenanceControl.Visible = false;
                //}
                //this.MaintenanceDisabledPanel.Visible = false;
                //this.maintenanceControl.Visible = false;
               // this.FileUploadControl.Activate(this._helper, configProperties);
                // GetConfiguration From XML
                this.FileUploadControl.Visible = true;
                    //(bool)configProperties["FileUploadAllowed"].Value;
                //!((bool)configProperties["FileUploadAllowed"].Value);
                this.FileUploaderDisabled.Visible= false;
            }
            catch (Exception ex)
            {
                //   this.Master.ShowErrorMessage(ex.Message);
            }
            this.FileUploadControl.ControlError += new EventHandler<ErrorEventArgs>(this.OnControlError);
            this.lblLayerLegend.Text = this.featureEditorControl.LayerLegend;
            MgLayerGroup group = layer.GetGroup();
            this.LayerLegend = layer.GetLegendLabel();
            while (group != null)
            {
                this.LayerLegend = string.Format("{0} > {1}", group.GetLegendLabel(), this.LayerLegend);
                group = group.GetGroup();
            }
            this.lblLayerLegend.Text = this.LayerLegend;
        }
Esempio n. 10
0
 public static List<Feature> GetFeatures(HtzMgHelper helper, MgSelection selection, string layerName)
 {
     MgFeatureReader reader;
     List<Feature> result = new List<Feature>();
     MgLayer layer = (MgLayer)helper.Map.GetLayers().GetItem(layerName);
     if ((selection != null) && (selection.GetLayers() != null))
     {
         string filter = selection.GenerateFilter(layer, layer.FeatureClassName);
         MgFeatureQueryOptions opt = new MgFeatureQueryOptions();
         opt.SetFilter(filter);
         reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, opt);
     }
     else
     {
         reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, null);
     }
     if (reader.ReadNext())
     {
         Feature prototype = new Feature(helper, layerName, "");
         Feature f1 = prototype.Clone() as Feature;
         f1.FillValues(reader);
         result.Add(f1);
         while (reader.ReadNext())
         {
             Feature f = prototype.Clone() as Feature;
             f.FillValues(reader);
             result.Add(f);
         }
     }
     return result;
 }
Esempio n. 11
0
 public Feature(HtzMgHelper helper, string layerName, string filter)
     : this(helper, layerName, filter, "UID")
 {
 }
Esempio n. 12
0
 public static Feature GetSingleFeature(HtzMgHelper helper, string filter, string layerName, string uidKey)
 {
     Feature result = null;
     if (helper.Map.GetLayers().Contains(layerName))
     {
         MgLayer layer = (MgLayer)helper.Map.GetLayers().GetItem(layerName);
         if (string.IsNullOrEmpty(filter))
         {
             return result;
         }
         MgFeatureQueryOptions opt = new MgFeatureQueryOptions();
         opt.SetFilter(filter);
         MgFeatureReader reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, opt);
         if (reader.ReadNext())
         {
             result = new Feature(helper, layerName, "", uidKey);
             result.FillValues(reader);
             result.FillLookUpValues();
         }
     }
     return result;
 }
Esempio n. 13
0
 public static Feature GetSingleFeature(HtzMgHelper helper, MgSelection selection, string layerName, string uidKey)
 {
     Feature result = null;
     MgLayer layer = helper.Map.GetLayers().GetItem(layerName) as MgLayer;
     if ((selection != null) && (selection.GetLayers() != null))
     {
         string filter = selection.GenerateFilter(layer, layer.FeatureClassName);
         result = GetSingleFeature(helper, filter, layerName, uidKey);
     }
     return result;
 }
Esempio n. 14
0
 public static Feature GetSingleFeature(HtzMgHelper helper, string filter, string layerName)
 {
     return GetSingleFeature(helper, filter, layerName, "UID");
 }
Esempio n. 15
0
 public static Feature GetSingleFeature(HtzMgHelper helper, MgSelection selection, string layerName)
 {
     return GetSingleFeature(helper, selection, layerName, "UID");
 }
Esempio n. 16
0
 public static List<Feature> GetFeatures(HtzMgHelper helper, string filter, string layerName)
 {
     List<Feature> result = new List<Feature>();
     MgLayer layer = helper.Map.GetLayers().GetItem(layerName) as MgLayer;
     Feature prototype = new Feature(helper, layerName, "");
     MgFeatureQueryOptions opt = new MgFeatureQueryOptions();
     if (!string.IsNullOrEmpty(filter))
     {
         opt.SetFilter(filter);
     }
     MgFeatureReader reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, opt);
     while (reader.ReadNext())
     {
         Feature f = prototype.Clone() as Feature;
         f.FillValues(reader);
         result.Add(f);
     }
     return result;
 }
Esempio n. 17
0
 public static int GetUidFromSelection(HtzMgHelper helper, string idField)
 {
     return GetUidFromSelection(helper, helper.Selection, idField);
 }
 public void Activate(HtzMgHelper helper, Feature feature)
 {
     this._helper = helper;
     this._feature = feature;
     this._activated = true;
 }