Example #1
0
        private static void ProcessFile_1()
        {
            var file = File.ReadAllText("xmlFile.txt");

            var url = "http://sandbox.w3sghana.com:8500/dr3/dataexchange/main/partner/index.cfc";

            var respXMLTag = "GetStatusReturn";

            var nameSpace = "dr.ecobank.com";

            var obj = new SOAPService <GetStatusReturn>(url, file, respXMLTag, nameSpace);

            obj.ConvertXMLStringToObject(file);

            //SYNC CALL
            var result = obj.Execute();

            //ASYNC CALL
            var result2 = obj.ExecuteAsync().Result;

            if (!result.Status)
            {
                Console.WriteLine(result.Message);
                Console.ReadLine();
                return;
            }

            Console.WriteLine("The status is " + result.Data);


            Console.ReadLine();
        }
Example #2
0
        public void Tune(HttpContext httpContext, object serviceInstance, OperationDescription operation)
        {
            SOAPService service = serviceInstance as SOAPService;

            if (httpContext.Request.Headers.TryGetValue("User", out var paramValue))
            {
                service.SetUsername(paramValue[0]);
            }
        }
Example #3
0
 void writePolygon(SOAPService.Polygon rgn)
 {
     if (rgn.Rings.Count > 0) {
         writeKeyis("Polygon",rgn.Rings.Count,rgn.Status);
         foreach(var ring in rgn.Rings)
         writePoints(ring.Points);
     }
 }
Example #4
0
 void writePoint(SOAPService.Point pt)
 {
     string v = String.Format("{0:0.0000000000} {1:0.0000000000}",pt.Y,pt.X);
     writeKeyss("Point",v,pt.Status);
 }
Example #5
0
        void writeMetaData(sodb db, SOAPService.Metadata m, string tab)
        {
            string s = tab + "\"" + m.Akronim + "\" \"" + m.Metadata_Cl_Id + "\"";

            if (m.Status != SOAPService.EditableStatus.Unchanged)
            s += " " + fdb.EditableStatusStr(m.Status);

            if (m.IsCompositeAttribute)
            {
                if (db.MetadataExists(m.CompositeMetadata))
                {
                    file.WriteLine(s);
                    file.WriteLine(tab + "{");

                    if (m.CompositeMetadata != null)
                    if (m.CompositeMetadata.Count > 0)
                    foreach (var m1 in m.CompositeMetadata)
                    writeMetaData(db,m1, tab + "\t");

                    file.WriteLine(tab + "}");
                }
            }
            else
            {
                string t = "";
                if (m.Values != null)
                    foreach (var v in m.Values)
                    {
                        if (t.Length > 0) t += " ";

                        if (v.Status != SOAPService.EditableStatus.Unchanged)
                        t += "/" + fdb.EditableStatusStr(v.Status) + "/ ";

                        t+="\"" + v.Value + "\"";
                    }

                if (t.Length > 0)
                file.WriteLine(s+" "+t);
            }
        }
Example #6
0
        void writeKeyss(string Key, string Value, SOAPService.EditableStatus status)
        {
            if (Value == null)
                file.WriteLine(Key);
            else
            {
                string s = Key + " \"" + Value + "\"";

                if (status != SOAPService.EditableStatus.Unchanged)
                    s += " " + fdb.EditableStatusStr(status);

                file.WriteLine(s);
            }
        }
Example #7
0
        void writeKeyis(string Key, int Value, SOAPService.EditableStatus status)
        {
            string v = String.Format(" {0:0}", Value);

            if (status != SOAPService.EditableStatus.Unchanged)
            v += " " + fdb.EditableStatusStr(status);

            file.WriteLine(Key + v);
        }
Example #8
0
        void writeFeature(sodb db,  List<SOAPService.Feature> list, SOAPService.Feature fe)
        {
            fdb = db;

            file.WriteLine("{");

            writeKey("Key", fe.Key);
            writeKey("Acronym", fe.Cl_Id);

            writeMetadatas(db,fe.Metadata, "object");

            SOAPService.Point pt = fe.BaseShapePoint;
            SOAPService.Polyline ln = fe.BaseShapePolyline;
            SOAPService.Polygon rgn = fe.BaseShapePolygon;

            if (pt != null)
            {
                writePoint(pt);
                writeMetadatas(db,pt.Metadata, "point");
            }

            if (ln != null)
            {
                writePolyline(ln);
                writeMetadatas(db,ln.Metadata, "polyline");
            }

            if (rgn != null)
            {
                writePolygon(rgn);
                writeMetadatas(db,rgn.Metadata, "polygon");
            }

            List<string> datatypes = new List<string>();
            writeAttributes(db, fe, datatypes);

            List<SOAPService.Relation> relations = fe.Relations;

            if (relations != null)
            foreach (var relation in relations)
            {
                string s;

                s = String.Format("relation {0} role={1}", relation.Key, relation.Role);
                if (relation.Status != SOAPService.EditableStatus.Unchanged)
                s += " " + fdb.EditableStatusStr(relation.Status);

                file.WriteLine(s);

                SOAPService.RelationRule rule = relation.RelationRule;
                if (rule != null)
                {
                    s = String.Format("rule {0} {1} {2} {3} // {4}",
                        rule.Cl_Id, rule.Source.Cl_Id, rule.Target.Cl_Id,
                        rule.Type,rule.Name);
                    file.WriteLine(s);
                }
            }

            file.WriteLine("}");
            file.WriteLine("");

            writeDatatypes(db, list,datatypes);
        }
Example #9
0
        /// <summary>
        ///     Reads a config file, parses it, and populates itself with the data it reads.
        ///     Returns a SOAPViewerConfig with all the details from the config file.
        /// </summary>
        /// <param name="file">filename to parse data from</param>
        /// <returns></returns>
        public static SOAPViewerConfig LoadFromFile(string file)
        {
            SOAPViewerConfig Config = new SOAPViewerConfig();

            Config.Services = new List <SOAPService>();
            XDocument ConfigContents = XDocument.Load(file);

            // for each service node
            List <XElement> services = ConfigContents.Descendants("services").Elements("service").ToList();

            for (int s = 0; s < services.Count; s++)
            {
                // read the service details
                SOAPService Service = new SOAPService();
                Service.Name      = services[s].Element("name").Value;
                Service.URL       = services[s].Element("url").Value;
                Service.NameSpace = services[s].Element("namespace").Value;
                Service.Actions   = new List <SOAPAction>();
                // for each action node in this service
                List <XElement> Actions = services[s].Elements("action").ToList();
                for (int a = 0; a < Actions.Count; a++)
                {
                    // read the action details
                    SOAPAction Action = new SOAPAction();
                    Action.Name = Actions[a].Element("name").Value;
                    Action.DisplayProperties =
                        Actions[a].Elements("resultproperties")
                        .Select(z =>
                    {
                        SOAPAction.ResultDisplayProperties displayProperties = new SOAPAction.ResultDisplayProperties();
                        if (z.Element("add_line_breaks_on_all_elements") != null)
                        {
                            displayProperties.AddSpacingOnAllElements = bool.Parse(z.Element("add_line_breaks_on_all_elements").Value);
                        }
                        if (z.Element("trim_all_spacing") != null)
                        {
                            displayProperties.TrimAllWhitespace = bool.Parse(z.Element("trim_all_spacing").Value);
                        }
                        if (z.Element("ignore_elements") != null)
                        {
                            displayProperties.IgnoreElementList = z.Element("ignore_elements").Value.Split(',').ToList();
                        }
                        if (z.Element("add_prefix_for_elements") != null)
                        {
                            Dictionary <string, string> addPrefixForElementList = new Dictionary <string, string>();
                            var prefixList = z.Element("add_prefix_for_elements").Value.Split('|').ToList();
                            foreach (var prefixCombo in prefixList)
                            {
                                string value = prefixCombo.Split(',')[0];
                                string key   = prefixCombo.Split(',')[1];
                                addPrefixForElementList.Add(key, value);
                            }
                            displayProperties.AddPrefixForElementList = addPrefixForElementList;
                        }

                        return(displayProperties);
                    }).FirstOrDefault();
                    if (Action.DisplayProperties == null)
                    {
                        Action.DisplayProperties = new SOAPAction.ResultDisplayProperties();
                    }
                    Action.Parameters = new List <SOAPParameter>();

                    // for each parameter node in this action
                    List <XElement> Parameters = Actions[a].Elements("parameter").ToList();
                    for (int p = 0; p < Parameters.Count; p++)
                    {
                        // read the parameter details
                        SOAPParameter Parameter = new SOAPParameter();
                        Parameter.DataName = Parameters[p].Element("dataName").Value;
                        Parameter.UIName   = Parameters[p].Element("uiName").Value;
                        Parameter.DataType = Parameters[p].Element("type").Value;

                        Parameter.ListSource = null;
                        if (Parameter.DataType == "list")
                        {
                            XElement ListSource = Parameters[p].Element("listsource");
                            Parameter.ListSource               = new SOAPParameter.ArgumentListSource();
                            Parameter.ListSource.ServiceName   = ListSource.Element("servicename").Value;
                            Parameter.ListSource.DisplayMember = ListSource.Element("displaymember").Value;
                            Parameter.ListSource.DataMember    = ListSource.Element("datamember").Value;
                        }

                        Parameter.CustomValidationExpressions =
                            Parameters[p].Elements()
                            .Where(f => f.Name == "custom_validation")
                            .Any()
                            ?
                            Parameters[p].Element("custom_validation").Elements()
                            .Select(b => string.Format("{0},{1}", b.Name.ToString(), b.Value))
                            .ToList()
                            :
                            new List <string>();
                        // add the parameter details to the Action
                        Action.Parameters.Add(Parameter);
                    }
                    // Add the action to the service
                    Service.Actions.Add(Action);
                }
                // add the ervice to the list of supported services
                Config.Services.Add(Service);
            }

            //return the populated object
            return(Config);
        }
Example #10
0
        void log_fe(SOAPService.Feature fe, string msg)
        {
            if (flog != null)
            {
                if (msg != null) flog.Error(msg);

                var features = new List<Feature>();
                features.Add(fe);
                flog.Features(fdb, features);
            }
        }
Example #11
0
        void compMsg(int offset, SOAPService.Attribute a, AttrValue v)
        {
            if (IsCompare)
            {
                string s = a.Attr_Id + "=" +
                           fdb.ValueString(v.Value) + " " +
                           fdb.EditableStatusStr(v.Status);

                Error1(offset, s);
            }
        }
Example #12
0
        void __editRelations(SOAPService.Feature fe, SOAPService.Feature _fe)
        {
            if (fe.Relations != null)
            foreach (var r1 in fe.Relations)
            if (r1.RelationRule != null)
            {
                r1.Status=SOAPService.EditableStatus.Added;

                if (_fe.Relations != null)
                foreach(var r2 in _fe.Relations)
                if (r2.RelationRule != null)
                if (r2.RelationRule.Cl_Id == r1.RelationRule.Cl_Id)
                if (r2.Role == r1.Role) {

                    r1.Status = SOAPService.EditableStatus.Modified;
                    if (r1.Shape == null)
                    r1.Status = SOAPService.EditableStatus.Unchanged;

                    _fe.Relations.Remove(r2); break;
                }
            }

            if (_fe.Relations != null)
            foreach(var r2 in _fe.Relations) {

                r2.Status = SOAPService.EditableStatus.Deleted;

                if (fe.Relations == null)
                fe.Relations = new List<SOAPService.Relation>();

                fe.Relations.Add(r2);
            }
        }
Example #13
0
        void __editBaseShapes(SOAPService.Feature fe, SOAPService.Feature _fe)
        {
            if (fe.BaseShapePoint == null) {
                if (_fe.BaseShapePoint != null) {
                    fe.BaseShapePoint = _fe.BaseShapePoint;
                    fe.BaseShapePoint.Status = SOAPService.EditableStatus.Deleted;
                }
            }
            else
            if (_fe.BaseShapePoint == null)
                fe.BaseShapePoint.Status = SOAPService.EditableStatus.Added;
            else  {
                fe.BaseShapePoint.Key = _fe.BaseShapePoint.Key;
                fe.BaseShapePoint.Status = SOAPService.EditableStatus.Modified;
                bool rc = __syncPoint(fe.BaseShapePoint,_fe.BaseShapePoint);
                if (rc) fe.BaseShapePoint.Status = SOAPService.EditableStatus.Unchanged;
                __editMetadata(fe.BaseShapePoint.Metadata, _fe.BaseShapePoint.Metadata, "point");
            }

            if (fe.BaseShapePolyline == null)
            {
                if (_fe.BaseShapePolyline != null)
                {
                    fe.BaseShapePolyline = _fe.BaseShapePolyline;
                    fe.BaseShapePolyline.Status = SOAPService.EditableStatus.Deleted;
                }
            }
            else
                if (_fe.BaseShapePolyline == null)
                    fe.BaseShapePolyline.Status = SOAPService.EditableStatus.Added;
                else
                {
                    fe.BaseShapePolyline.Key = _fe.BaseShapePolyline.Key;
                    fe.BaseShapePolyline.Status = SOAPService.EditableStatus.Modified;
                    bool rc = _PolylineToPolyline(fe.BaseShapePolyline, _fe.BaseShapePolyline);
                    if (rc) fe.BaseShapePolyline.Status = SOAPService.EditableStatus.Unchanged;
                    __editMetadata(fe.BaseShapePolyline.Metadata, _fe.BaseShapePolyline.Metadata, "polyline");
                }

            if (fe.BaseShapePolygon == null)
            {
                if (_fe.BaseShapePolygon != null)
                {
                    fe.BaseShapePolygon = _fe.BaseShapePolygon;
                    fe.BaseShapePolygon.Status = SOAPService.EditableStatus.Deleted;
                }
            }
            else
                if (_fe.BaseShapePolygon == null)
                    fe.BaseShapePolygon.Status = SOAPService.EditableStatus.Added;
                else
                {
                    fe.BaseShapePolygon.Key = _fe.BaseShapePolygon.Key;
                    fe.BaseShapePolygon.Status = SOAPService.EditableStatus.Modified;
                    bool rc = _PolygonToPolygon(fe.BaseShapePolygon, _fe.BaseShapePolygon);
                    if (rc) fe.BaseShapePolygon.Status = SOAPService.EditableStatus.Unchanged;
                    __editMetadata(fe.BaseShapePolygon.Metadata, _fe.BaseShapePolygon.Metadata, "polygon");
                }
        }
Example #14
0
        SOAPService.AttrValue __datatype(int code, int loc, SOAPService.Attribute a)
        {
            SOAPService.AttrValue v = null;

            string acronym = a.CompositAttrCl_Id;
            var fe = new SOAPService.Feature() { Cl_Id = acronym, IsRealFeature = false };

            int offs = obj.Offset;

            if (loc == 0)
             fe.Metadata = __metadata(offs, 2, "");

            if ((loc >= 1) && (loc <= 3))
            {
                __baseShape(fe,obj,loc);
                if (!frst_Datatype(code)) return null;
            }

            int uc = 0;    // add feature
            if (IsUpdate) uc = obj.UpdateCode;

            fe.Key = obj.guid;

            var attrs = new List<SOAPService.Attribute>();
            addAttrs(acronym,attrs);

            if (attrs.Count > 0) {
                fe.Attributes = attrs;

                string key = db_fe(fe, offs, uc);

                if (key != null)
                if (key.Length > 0)
                {
                    v = new SOAPService.AttrValue();
                    var vv = new SOAPService.StringValue();
                    vv.Text = key; v.Value = vv;

                    if (a.Values == null)
                    a.Values = new List<SOAPService.AttrValue>();

                    a.Values.Add(v);
                }
            }

            return v;
        }
Example #15
0
        void __baseShape(SOAPService.Feature fe,
                         xmap.IFeature obj, int loc)
        {
            if ((loc >= 1) && (loc <= 3))
            {
                int offs = obj.Offset;
                xmap.IPoly mf = obj.mf;
                mf.IsWGS = 1;

                if (mf.PartCount > 0)
                switch (loc)
                {
                    case 1:
                        if (fe.BaseShapePoint == null)
                        {
                            fe.BaseShapePoint = __point(mf);
                            if (fe.BaseShapePoint != null)
                            fe.BaseShapePoint.Metadata = __metadata(offs,1,"");
                        }
                        break;
                    case 2:
                        if (fe.BaseShapePolyline == null)
                        {
                            fe.BaseShapePolyline = __polyline(mf);
                            if (fe.BaseShapePolyline != null)
                            fe.BaseShapePolyline.Metadata = __metadata(offs,1,"");
                        }
                        break;
                    case 3:
                        if (fe.BaseShapePolygon == null)
                        {
                            fe.BaseShapePolygon = __polygon(mf);
                            if (fe.BaseShapePolygon != null)
                            fe.BaseShapePolygon.Metadata = __metadata(offs,1,"");
                        }
                        break;
                }
            }
        }
Example #16
0
 void writePolyline(SOAPService.Polyline pl)
 {
     if (pl.Paths.Count > 0) {
         writeKeyis("Polyline",pl.Paths.Count,pl.Status);
         foreach(var path in pl.Paths)
         writePoints(path.Points);
     }
 }
Example #17
0
        void writeAttributes(sodb db, SOAPService.Feature fe, List<string> datatypes)
        {
            List<SOAPService.Attribute> Attributes = fe.Attributes;

            if (Attributes != null)
            foreach (var a in Attributes)

            if (a.Values != null)
            foreach (var v in a.Values)
            if (v.Value != null)
            {

                SOAPService.NumberStringAttrValue vv = v.Value;

                string s = "", t = "";
                if (vv is SOAPService.NumberValue)
                {
                    s = db.NumberToStr(vv as SOAPService.NumberValue);
                    t = "N";
                }
                else if (vv is SOAPService.StringValue)
                {
                    s = (vv as SOAPService.StringValue).Text;
                    t = "S";

                    if (a.IsCompositeAttribute) datatypes.Add(s);
                }

                string typ = a.Type.ToString();

                string k = String.Format("attribute {0}[{1}][{2}]", a.Attr_Id, typ, t);

                if (a.IsCompositeAttribute) k += "[C]";

                writeKeyss(k,s,v.Status);

                SOAPService.Geometry shp = v.Shape;
                if (shp != null)
                {
                    writeKey("Geometry", shp.Key);

                    if (shp.Type == SOAPService.GeometryType.Point)
                    {
                        SOAPService.Point pt = (SOAPService.Point)shp;
                        writePoint(pt);
                    }
                    else
                    if (shp.Type == SOAPService.GeometryType.Polyline)
                    {
                        SOAPService.Polyline ln = (SOAPService.Polyline)shp;
                        writePolyline(ln);
                    }
                    else
                    if (shp.Type == SOAPService.GeometryType.Polygon)
                    {
                        SOAPService.Polygon rgn = (SOAPService.Polygon)shp;
                        writePolygon(rgn);
                    }
                }

                writeMetadatas(db,v.Metadata,a.Attr_Id);
               }
        }
Example #18
0
        SOAPService.AttrValue __attrValue(SOAPService.Attribute a, string str, double v1, double v2, int op)
        {
            if (a != null)
            if (convert.IsString(str))
            {
                var v = new SOAPService.AttrValue();

                if ((a.Type == DataType.String) ||
                    (a.Type == DataType.Text) ||
                    (a.Type == DataType.Domain)) {
                    var vv = new SOAPService.StringValue();
                    vv.Text = str; v.Value = vv;
                } else
                if ((a.Type == DataType.Float) ||
                    (a.Type == DataType.Integer)) {
                    if (op > 0) {
                        var vv = new SOAPService.NumberValue();

                        if ((op == 1) || (op == 3)) {   // > >=
                            vv.Lower = (decimal)v1;
                            vv.IncludeLower = (op == 3);
                        } else

                        if ((op == 2) || (op == 4)) {   // < <=
                            vv.Upper = (decimal)v1;
                            vv.IncludeUpper = (op == 4);
                        }
                        else {
                            vv.Lower = (decimal)v1;
                            vv.Upper = (decimal)v2;
                            vv.IncludeLower = (op == 5) || (op == 8);
                            vv.IncludeUpper = (op == 5) || (op == 9);
                            vv.Inverval = (v1 < v2);
                        }

                        vv.Text = str;
                        v.Value = vv;
                    }
                    else {
                        decimal f;
                        if (decimal.TryParse(str, out f)) {
                            var vv = new SOAPService.NumberValue();
                            vv.Lower = f;
                            vv.Upper = f;
                            vv.IncludeLower = true;
                            vv.IncludeUpper = true;
                            vv.Inverval = false;

                            vv.Text = str;
                            v.Value = vv;
                        }
                    }
                }

                if (v.Value != null) {

                    v.Metadata = __metadata(obj.Offset, 2, a.Attr_Id);

                    if (a.Values == null)
                    a.Values = new List<AttrValue>();

                    a.Values.Add(v);
                    return v;
                }
            }

            return null;
        }