Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string ftrNm = cmbSampleFeatureClass.Text;

            if (ftrNm == "" || ftrNm == null)
            {
                MessageBox.Show("You must have a sampling layer selected");
                return;
            }
            if (!System.IO.File.Exists(plrR.SasOutputFile))
            {
                MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int paramLength = plrR.OutParameters.Length;
            int rsBndsCnt   = lstRasterBands.Items.Count;
            int bCnt        = 0;

            for (int i = 0; i < rsBndsCnt; i++)
            {
                bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count;
            }
            if (bCnt < 1 || (paramLength - 1) != bCnt)
            {
                MessageBox.Show("Param = " + (paramLength - 1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnViewOrder.PerformClick();
                return;
            }
            IRasterBandCollection rsBc = new RasterClass();

            for (int i = 0; i < rsBndsCnt; i++)
            {
                IRaster rs = rstDic[lstRasterBands.Items[i].ToString()];
                rsBc.AppendBands((IRasterBandCollection)rs);
            }
            this.Visible  = false;
            plrR.InRaster = (IRaster)rsBc;

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false);
            System.DateTime dt1 = System.DateTime.Now;
            rp.addMessage("Creating PLR Classification Raster.");
            rp.addMessage("Bands are organized as follows:\n\tBand1=MLC\n\tBand2=BaseCategory");
            int bcCnt = 3;

            foreach (string c in plrR.Categories)
            {
                rp.addMessage("\tBand" + bcCnt.ToString() + "=" + c);
                bcCnt += 1;
            }
            rp.addMessage("This may take some time...");
            rp.Show();
            rp.TopMost = true;
            rp.stepPGBar(20);
            rp.Refresh();
            IRaster rst = plrR.createModelRaster(seed);

            if (mp != null)
            {
                rp.addMessage("Adding Raster to map");
                rp.Refresh();
                IRasterLayer rsLyr1 = new RasterLayerClass();
                rsLyr1.CreateFromRaster(rst);
                rsLyr1.Name    = "PLR_OUT";
                rsLyr1.Visible = false;
                mp.AddLayer(rsLyr1);
            }
            rp.stepPGBar(50);
            rp.addMessage("Finished creating raster");
            rp.Refresh();
            System.DateTime dt2     = System.DateTime.Now;
            System.TimeSpan ts      = dt2.Subtract(dt1);
            string          prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";

            rp.addMessage(prcTime);
            rp.stepPGBar(100);
            rp.Refresh();
            rp.enableClose();
            this.Close();
            return;
        }
Exemplo n.º 2
0
        public void runAnalysis()
        {
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outCSV))
            {
                string hd = "ROI,DIR,NAME,Year,Month,Day,Time,Red,Green,Blue,GCC,ExG,VIgreen,RCC,RGB,Area";//add RCC, RGB, Area
                sw.WriteLine(hd);
                IFeatureClass  ftrCls = geoUtil.getFeatureClass(polyPath);
                IFeatureCursor fCur   = ftrCls.Search(null, true);
                IFeature       ftr    = fCur.NextFeature();
                int            cnt    = 1;
                while (ftr != null)
                {
                    IGeometry geo   = ftr.Shape;
                    string[]  lnArr = new string[16];
                    lnArr[0] = cnt.ToString();
                    lnArr[1] = photoDir.Split(new char[] { '\\' }).Last();
                    foreach (string flPath in System.IO.Directory.GetFiles(photoDir, "*." + ext))
                    {
                        string nm = System.IO.Path.GetFileNameWithoutExtension(flPath);
                        if (frmRpd != null)
                        {
                            frmRpd.addMessage("Working On " + nm);
                            frmRpd.stepPGBar(1);
                            frmRpd.Refresh();
                        }

                        lnArr[2] = nm;
                        //Console.WriteLine(flPath);

                        System.IO.FileStream fs  = new System.IO.FileStream(flPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
                        BitmapSource         img = BitmapFrame.Create(fs);
                        BitmapMetadata       md  = (BitmapMetadata)img.Metadata;
                        string timeStamp         = "";
                        if (md != null)
                        {
                            timeStamp = md.DateTaken;
                            DateTime dt = Convert.ToDateTime(timeStamp);
                            lnArr[3] = dt.Year.ToString();
                            lnArr[4] = dt.Month.ToString();
                            lnArr[5] = dt.Day.ToString();
                            lnArr[6] = dt.TimeOfDay.ToString();



                            //Console.WriteLine(date);
                        }
                        else
                        {
                            //Console.WriteLine("md=null");
                        }
                        IFunctionRasterDataset rsDset = rsUtil.clipRasterFunction(flPath, geo, esriRasterClippingType.esriRasterClippingOutside);
                        double r, g, b;
                        bool   cntCheck = getRGB(rsDset, out r, out g, out b);
                        lnArr[7] = r.ToString();
                        lnArr[8] = g.ToString();
                        lnArr[9] = b.ToString();
                        double GCC = 0;
                        double ExG = 0;
                        double VIgreen = 0;
                        double RCC = 0;
                        double RGB = 0;
                        double Area = ((IArea)geo).Area;
                        if (!cntCheck)
                        {
                            RGB     = r + g + b;
                            GCC     = g / RGB;
                            ExG     = 2 * g - (r + b);
                            VIgreen = (g - r) / (g + r);
                            RCC     = r / RGB;
                        }
                        lnArr[10] = GCC.ToString();
                        lnArr[11] = ExG.ToString();
                        lnArr[12] = VIgreen.ToString();
                        lnArr[13] = RCC.ToString();
                        lnArr[14] = RGB.ToString();
                        lnArr[15] = Area.ToString();
                        sw.WriteLine(String.Join(",", lnArr));
                    }
                    ftr = fCur.NextFeature();
                }
                sw.Close();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(fCur);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string ftrNm = cmbSampleFeatureClass.Text;
            if (ftrNm == "" || ftrNm == null)
            {
                MessageBox.Show("You must have a sampling layer selected");
                return;
            }
            if (!System.IO.File.Exists(plrR.SasOutputFile))
            {
                MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int paramLength = plrR.OutParameters.Length;
            int rsBndsCnt = lstRasterBands.Items.Count;
            int bCnt = 0;
            for (int i = 0; i < rsBndsCnt; i++)
            {
                bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count;
            }
            if (bCnt < 1||(paramLength-1)!=bCnt)
            {
                MessageBox.Show("Param = " + (paramLength-1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnViewOrder.PerformClick();
                return;

            }
            IRasterBandCollection rsBc = new RasterClass();
            for (int i = 0; i < rsBndsCnt; i++)
            {
                IRaster rs = rstDic[lstRasterBands.Items[i].ToString()];
                rsBc.AppendBands((IRasterBandCollection)rs);
            }
            this.Visible = false;
            plrR.InRaster = (IRaster)rsBc;

            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false);
            System.DateTime dt1 = System.DateTime.Now;
            rp.addMessage("Creating PLR Classification Raster.");
            rp.addMessage("Bands are organized as follows:\n\tBand1=MLC\n\tBand2=BaseCategory");
            int bcCnt = 3;
            foreach (string c in plrR.Categories)
            {
                rp.addMessage("\tBand" + bcCnt.ToString() + "=" + c);
                bcCnt += 1;
            }
            rp.addMessage("This may take some time...");
            rp.Show();
            rp.TopMost = true;
            rp.stepPGBar(20);
            rp.Refresh();
            IRaster rst = plrR.createModelRaster(seed);
            if (mp != null)
            {
                rp.addMessage("Adding Raster to map");
                rp.Refresh();
                IRasterLayer rsLyr1 = new RasterLayerClass();
                rsLyr1.CreateFromRaster(rst);
                rsLyr1.Name = "PLR_OUT";
                rsLyr1.Visible = false;
                mp.AddLayer(rsLyr1);
            }
            rp.stepPGBar(50);
            rp.addMessage("Finished creating raster");
            rp.Refresh();
            System.DateTime dt2 = System.DateTime.Now;
            System.TimeSpan ts = dt2.Subtract(dt1);
            string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
            rp.addMessage(prcTime);
            rp.stepPGBar(100);
            rp.Refresh();
            rp.enableClose();
            this.Close();
            return;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string ftrNm = cmbSampleFeatureClass.Text;
            string sasDir = cmbModelDir.Text;
            if (ftrNm == "" || ftrNm == null)
            {
                MessageBox.Show("You must have a Workspace selected");
                return;
            }
            if (sasDir == "" || sasDir == null)
            {
                MessageBox.Show("You must have a SAS modeled directory selected");
                return;
            }
            if (!System.IO.File.Exists(rR.SasOutputFile))
            {
                MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int paramLength = rR.OutParameters.Length;
            int rsBndsCnt = lstRasterBands.Items.Count;
            int bCnt = 0;
            for (int i = 0; i < rsBndsCnt; i++)
            {
                bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count;
            }
            if (bCnt < 1 || (paramLength - 1) != bCnt)
            {
                MessageBox.Show("Param = " + (paramLength - 1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnViewOrder.PerformClick();
                return;

            }
            IRasterBandCollection rsBc = new RasterClass();
            for (int i = 0; i < rsBndsCnt; i++)
            {
                IRaster rs = rstDic[lstRasterBands.Items[i].ToString()];
                rsBc.AppendBands((IRasterBandCollection)rs);
            }
            this.Visible = false;
            rR.InRaster = (IRaster)rsBc;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false);
            System.DateTime dt1 = System.DateTime.Now;
            rp.addMessage("Creating Regression Raster.");
            rp.addMessage("Name of the out raster = " + sasDir + ". Bands are in the order of dependent variables");
            int bcnt = 1;
            foreach (string s in rR.Categories)
            {
                rp.addMessage("\tBand_" + bcnt.ToString() + " = " + s);
                bcnt++;
            }
            rp.addMessage("This may take some time...");
            rp.Show();
            rp.TopMost = true;
            rp.stepPGBar(20);
            rp.Refresh();
            try
            {
                outraster = rR.createModelRaster();
                outrastername = sasDir;
                if (mp != null && addToMap)
                {
                    rp.addMessage("Adding Rasters to map");
                    rp.Refresh();
                    IRasterLayer rsLyr1 = new RasterLayerClass();
                    rsLyr1.Name = outrastername;
                    rsLyr1.CreateFromRaster(outraster);
                    rsLyr1.Visible = false;
                    mp.AddLayer(rsLyr1);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exc)
            {
                rp.addMessage(exc.ToString());
            }
            finally
            {
                rp.stepPGBar(50);
                rp.addMessage("Finished creating raster");
                rp.Refresh();
                System.DateTime dt2 = System.DateTime.Now;
                System.TimeSpan ts = dt2.Subtract(dt1);
                string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
                rp.stepPGBar(100);
                rp.Refresh();
                rp.enableClose();
                this.Close();
            }
            return;
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string ftrNm  = cmbSampleFeatureClass.Text;
            string sasDir = cmbModelDir.Text;

            if (ftrNm == "" || ftrNm == null)
            {
                MessageBox.Show("You must have a Workspace selected");
                return;
            }
            if (sasDir == "" || sasDir == null)
            {
                MessageBox.Show("You must have a SAS modeled directory selected");
                return;
            }
            if (!System.IO.File.Exists(rR.SasOutputFile))
            {
                MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int paramLength = rR.OutParameters.Length;
            int rsBndsCnt   = lstRasterBands.Items.Count;
            int bCnt        = 0;

            for (int i = 0; i < rsBndsCnt; i++)
            {
                bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count;
            }
            if (bCnt < 1 || (paramLength - 1) != bCnt)
            {
                MessageBox.Show("Param = " + (paramLength - 1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnViewOrder.PerformClick();
                return;
            }
            IRasterBandCollection rsBc = new RasterClass();

            for (int i = 0; i < rsBndsCnt; i++)
            {
                IRaster rs = rstDic[lstRasterBands.Items[i].ToString()];
                rsBc.AppendBands((IRasterBandCollection)rs);
            }
            this.Visible = false;
            rR.InRaster  = (IRaster)rsBc;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false);
            System.DateTime dt1 = System.DateTime.Now;
            rp.addMessage("Creating Regression Raster.");
            rp.addMessage("Name of the out raster = " + sasDir + ". Bands are in the order of dependent variables");
            int bcnt = 1;

            foreach (string s in rR.Categories)
            {
                rp.addMessage("\tBand_" + bcnt.ToString() + " = " + s);
                bcnt++;
            }
            rp.addMessage("This may take some time...");
            rp.Show();
            rp.TopMost = true;
            rp.stepPGBar(20);
            rp.Refresh();
            try
            {
                outraster     = rR.createModelRaster();
                outrastername = sasDir;
                if (mp != null && addToMap)
                {
                    rp.addMessage("Adding Rasters to map");
                    rp.Refresh();
                    IRasterLayer rsLyr1 = new RasterLayerClass();
                    rsLyr1.Name = outrastername;
                    rsLyr1.CreateFromRaster(outraster);
                    rsLyr1.Visible = false;
                    mp.AddLayer(rsLyr1);
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exc)
            {
                rp.addMessage(exc.ToString());
            }
            finally
            {
                rp.stepPGBar(50);
                rp.addMessage("Finished creating raster");
                rp.Refresh();
                System.DateTime dt2     = System.DateTime.Now;
                System.TimeSpan ts      = dt2.Subtract(dt1);
                string          prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds ";
                rp.addMessage(prcTime);
                rp.stepPGBar(100);
                rp.Refresh();
                rp.enableClose();
                this.Close();
            }
            return;
        }
        /// <summary>
        /// Fills in the features that need updating
        /// </summary>
        /// <param name="sFlt">filter</param>
        /// <param name="serviceConnection">connection</param>
        /// <param name="service">service</param>
        /// <param name="lyrID">layerid</param>
        /// <returns>any messages from the updating processes</returns>
        public string fillDbFtrClasses(ISpatialFilter sFlt, string serviceConnection, string service, Dictionary<string,int> lyrID)
        {
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rpd = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(true);
            rpd.showInSepperateProcess();
            rpd.Show();
            //rpd.addMessage("Downloading data for " + service + " Map Service");
            bool lyrTblNeedsUpdating = false;
            StringBuilder msg = new StringBuilder();
            IWorkspace2 wks2 = (IWorkspace2)servWks;

            string svID = getServiceOID(serviceConnection,service);
            IAGSServerConnection2 conn = getServiceConnection(serviceConnection);
            IAGSServerObjectName3 sobj3 = getServiceObject(conn,service,"MapServer");
            IMapServer2 ms2 = getMapService(sobj3);
            if (ms2 == null)
            {
                msg.AppendLine("Could not get map service "+service);
                rpd.addMessage("Could not get map service "+service);
                updateServiceTable(serviceConnection);
                rpd.enableClose();
                return msg.ToString();
            }
            IQueryFilter qryFl = new QueryFilterClass();
            string mName = ms2.DefaultMapName;
            IWorkspaceEdit wksE = (IWorkspaceEdit)servWks;
            bool weEdit = false;
            if (!wksE.IsBeingEdited())
            {
                wksE.StartEditing(false);
                weEdit = true;
            }
            wksE.StartEditOperation();
            IFeatureClass ftrCls;
            try
            {
                int stp = 100 / lyrID.Count;
                foreach (KeyValuePair<string, int> kvp in lyrID)
                {
                    string lyrName = kvp.Key;
                    int lyrId = kvp.Value;
                    if (!checkServerLayer(ms2, lyrId, lyrName))
                    {
                        lyrTblNeedsUpdating = true;
                        msg.AppendLine("Could not find " + lyrName + ". Moving to the next Layer and updating tables.");
                        continue;

                    }
                    else
                    {
                        string x = "Updating records for " + lyrName;
                        rpd.addMessage(x);
                        rpd.stepPGBar(stp);
                        msg.AppendLine(x);
                    }
                    string ftrClassName = lyrName + "_" + svID + "_" + lyrId.ToString();
                    string fFtrClassName = geoDatabaseUtility.parsName(ftrClassName);

                    int drcd = 1;
                    bool ftrExists = wks2.get_NameExists(esriDatasetType.esriDTFeatureClass, fFtrClassName);
                    if (!ftrExists)
                    {
                        ftrCls = createFtrClass(ms2, lyrId, fFtrClassName);
                        ISchemaLock sLock = (ISchemaLock)ftrCls;
                        try
                        {
                            sLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                            IClassSchemaEdit3 cSchEdit3 = (IClassSchemaEdit3)ftrCls;
                            cSchEdit3.AlterAliasName(lyrName);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                        finally
                        {
                            sLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                        }

                    }
                    else
                    {
                        ftrCls = fWks.OpenFeatureClass(fFtrClassName);
                    }
                    IGeoDataset geoDSet = (IGeoDataset)ftrCls;
                    ISpatialReference spRf = geoDSet.SpatialReference;
                    ISpatialReference filtSpRf = sFlt.Geometry.SpatialReference;
                    if (spRf.FactoryCode != filtSpRf.FactoryCode)
                    {
                        rpd.addMessage("Transforming extent from " + filtSpRf.Name + " to " + spRf.Name);
                        sFlt = transformCoordinates(sFlt, spRf);
                    }

                    string oidName = ftrCls.OIDFieldName;
                    int maxRecords = getMaxRecords(ms2);
                    List<string> fIdLst = new List<string>();
                    IFIDSet2 idSet = (IFIDSet2)ms2.QueryFeatureIDs(mName, lyrId, sFlt);
                    rpd.addMessage("Attempting to download " + idSet.Count().ToString() + " records...");
                    rpd.Refresh();
                    idSet.Reset();
                    IFeatureCursor fCur = ftrCls.Search(sFlt, false);
                    IFeature ftr = fCur.NextFeature();
                    while (ftr != null)
                    {
                        ftr.Delete();
                        ftr = fCur.NextFeature();
                    }

                    int fId;
                    int rc = 1;
                    idSet.Next(out fId);
                    while (fId > -1)
                    {
                        if (drcd > maxRecords)
                        {
                            rpd.addMessage("\tDownloading Index " + rc.ToString());
                            rc+=1;
                            qryFl.WhereClause = String.Join(" or ", fIdLst.ToArray());
                            IRecordSet rSet = ms2.QueryFeatureData(mName, lyrId, qryFl);
                            IFields rFlds = rSet.Fields;
                            ICursor sCur = rSet.get_Cursor(false);
                            IRow sRow = sCur.NextRow();
                            while (sRow != null)
                            {
                                fCur = ftrCls.Insert(true);
                                IFeatureBuffer ftrBuff = ftrCls.CreateFeatureBuffer();
                                for (int f = 0; f < rFlds.FieldCount; f++)
                                {
                                    IField rFld = rFlds.get_Field(f);
                                    int fIndex = ftrBuff.Fields.FindField(rFld.Name);
                                    if (fIndex > -1)
                                    {
                                        try
                                        {
                                            ftrBuff.set_Value(fIndex, sRow.get_Value(f));
                                        }
                                        catch (Exception e)
                                        {
                                            Console.WriteLine(e.ToString());
                                        }
                                    }
                                }

                                fCur.InsertFeature(ftrBuff);
                                fCur.Flush();
                                sRow = sCur.NextRow();
                            }

                            drcd = 1;
                            fIdLst.Clear();
                        }
                        else
                        {
                            fIdLst.Add(oidName + " = '" + fId.ToString() + "'");
                            drcd += 1;
                        }
                        idSet.Next(out fId);
                    }
                    if (fIdLst.Count > 0)
                    {
                        rpd.addMessage("\tDownloading Index " + rc.ToString());
                        qryFl.WhereClause = String.Join(" or ", fIdLst.ToArray());
                        IRecordSet rSet = ms2.QueryFeatureData(mName, lyrId, qryFl);
                        IFields rFlds = rSet.Fields;
                        ICursor sCur = rSet.get_Cursor(false);
                        IRow sRow = sCur.NextRow();
                        while (sRow != null)
                        {
                            fCur = ftrCls.Insert(true);
                            IFeatureBuffer ftrBuff = ftrCls.CreateFeatureBuffer();
                            for (int f = 0; f < rFlds.FieldCount; f++)
                            {
                                IField rFld = rFlds.get_Field(f);
                                if (rFld.Editable)
                                {
                                    int fIndex = ftrBuff.Fields.FindField(rFld.Name);
                                    if (fIndex > -1)
                                    {
                                        try
                                        {
                                            ftrBuff.set_Value(fIndex, sRow.get_Value(f));
                                        }
                                        catch (Exception e)
                                        {
                                            Console.WriteLine(e.ToString());
                                        }
                                    }
                                }
                            }

                            fCur.InsertFeature(ftrBuff);
                            fCur.Flush();
                            sRow = sCur.NextRow();
                        }
                    }
                    drcd = 1;
                    fIdLst.Clear();
                }
                if (lyrTblNeedsUpdating)
                {
                    Dictionary<string,int> dic = getLayers(ms2);
                    updateLayerTable(dic,serviceConnection, service);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {

                wksE.StopEditOperation();
                if (weEdit)
                {
                    wksE.StopEditing(true);
                }
                rpd.stepPGBar(100);
                rpd.TopMost = false;
                rpd.enableClose();
            }
            return msg.ToString();
        }