public Dictionary <string, string> SendSMS(string To, string Body)
        {
            Dictionary <string, string> msgStatus = null;

            try
            {
                Data["msg"] = Body;
                Data["to"]  = To;
                var    response         = Client.UploadValues(Unifonic_base_url, "POST", Data);
                string responseInString = Encoding.UTF8.GetString(response);
                Console.WriteLine(responseInString);
                if (response != null)
                {
                    msgStatus = new Dictionary <string, string> {
                        { "To", To },
                        { "From", Config.From },
                        { "Uri", url },
                        { "Body", Body },
                        { "ErrorMessage", "" },
                        { "ConId", Config.Id.ToString() },
                        { "Result", responseInString }
                    };
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception:" + e.ToString());
                msgStatus.Add("ErrorMessage", e.ToString());
            }
            Console.WriteLine(" --- SMS msg" + EbSerializers.Json_Serialize(msgStatus));
            return(msgStatus);
        }
Beispiel #2
0
        //public object GetObjectAndPermission(string roleId, int appId)
        //{
        //	var fr = this.ServiceClient.Get<GetObjectAndPermissionResponse>(new GetObjectAndPermissionRequest { RoleId = Convert.ToInt32(roleId), AppId = appId });
        //	return JsonConvert.SerializeObject(fr);
        //}

        //GET  PERMISSION OPERATIONS AS JS
        private string GetPermissionOperationsAsJs()
        {
            Assembly assembly = Assembly.GetAssembly(typeof(EbWebForm));             //DO NOT CHANGE
            List <Eb_ObjectTypeOperations> _listObj = new List <Eb_ObjectTypeOperations>();

            foreach (var ObjectType in Enum.GetValues(typeof(EbObjectTypesUI)))
            {
                string sObjectType = ObjectType.ToString();
                int    sIntObj     = (int)ObjectType;
                var    eOperations = assembly.GetType(string.Format("ExpressBase.Objects.{0}+Operations", sObjectType));
                if (eOperations != null)
                {
                    Eb_ObjectTypeOperations _obj = new Eb_ObjectTypeOperations()
                    {
                        Op_Id = sIntObj, Op_Name = sObjectType, Operations = new List <string>()
                    };
                    foreach (var Op in Enum.GetValues(eOperations))
                    {
                        _obj.Operations.Add(Op.ToString());
                    }
                    _listObj.Add(_obj);
                }
            }
            return(EbSerializers.Json_Serialize(_listObj));
        }
        public Dictionary <string, string> SendSMS(string To, string body)
        {
            Dictionary <string, string> msgStatus = null;
            string result;

            try
            {
                body += " -" + Config.BrandName;
                var status = string.Empty;
                IEnumerable <string> matches = Regex.Matches(To, @"[1-9]").OfType <Match>()
                                               .Select(m => m.Groups[0].Value)
                                               .Distinct();
                if (matches.Count() > 0)
                {
                    string msg = HttpUtility.UrlEncode(body);
                    using (var wb = new WebClient())
                    {
                        byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
                        {
                            { "apikey", Config.ApiKey },
                            { "numbers", To },
                            { "message", msg },
                            { "sender", Config.From }
                            // {"test" , "1"}
                        });
                        result = System.Text.Encoding.UTF8.GetString(response);
                    }
                    status = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(result)["status"];
                }
                else
                {
                    status = "FAILED";
                    result = "'To' is not a Valid number.";
                }
                msgStatus = new Dictionary <string, string>
                {
                    { "ApiKey", Config.ApiKey },
                    { "To", To },
                    { "From", Config.From },
                    { "Body", body },
                    { "ConId", Config.Id.ToString() },
                    { "Status", status },
                    { "Result", result }
                };
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception:" + e.Message);
                if (!(msgStatus is null))
                {
                    msgStatus.Add("ErrorMessage", e.Message);
                }
            }
            Console.WriteLine(" --- SMS msg" + EbSerializers.Json_Serialize(msgStatus));
            return(msgStatus);
        }
Beispiel #4
0
        private string Get_EbObjTypesStr()
        {
            Dictionary <string, int> _dic = new Dictionary <string, int>();

            foreach (Structures.EbObjectType objectType in Structures.EbObjectTypes.Enumerator)
            {
                _dic.Add(objectType.Name, objectType.IntCode);
            }

            return(EbSerializers.Json_Serialize(_dic));
        }
Beispiel #5
0
        public string VersionCodes(string objid, int objtype)
        {
            var resultlist = this.ServiceClient.Get <EbObjectParticularVersionResponse>(new EbObjectParticularVersionRequest {
                RefId = objid
            });
            var dsobj = EbSerializers.Json_Deserialize(resultlist.Data[0].Json);

            dsobj.Status        = resultlist.Data[0].Status;
            dsobj.VersionNumber = resultlist.Data[0].VersionNumber;

            return(EbSerializers.Json_Serialize(dsobj));
        }
Beispiel #6
0
        private string Get_EbObjTypesStr()
        {
            Dictionary <string, int> _dic = new Dictionary <string, int>();

            foreach (string enumString in Enum.GetNames(typeof(EbObjectType)))
            {
                EbObjectType _type;
                Enum.TryParse(enumString, out _type);
                _dic.Add(enumString, (int)_type);
            }

            return(EbSerializers.Json_Serialize(_dic));
        }
Beispiel #7
0
        public string EmailTemplateCommit(string _Refid, string Htmlcode, string PropObj, string ChangeLog)
        {
            IServiceClient client   = this.ServiceClient;
            var            emailobj = EbSerializers.Json_Deserialize <EbEmailTemplate>(PropObj);
            string         refid    = "";

            if (string.IsNullOrEmpty(_Refid))
            {
                var ds = new EbObject_Create_New_ObjectRequest();
                ds.EbObjectType = (int)EbObjectType.EmailBuilder;
                ds.Name         = emailobj.Name;
                ds.Description  = emailobj.Description;

                ds.Json = EbSerializers.Json_Serialize(new EbEmailTemplate
                {
                    Body = emailobj.Body,
                    //EbObjectType = emailobj.EbObjectType,
                    Name            = emailobj.Name,
                    Subject         = emailobj.Subject,
                    DataSourceRefId = emailobj.DataSourceRefId
                });
                ds.Relations = "";
                ds.IsSave    = false;

                var res = ServiceClient.Post <EbObject_Create_New_ObjectResponse>(ds);
                refid = res.RefId;
            }
            else
            {
                var ds = new EbObject_CommitRequest();
                ds.EbObjectType = (int)EbObjectType.EmailBuilder;
                ds.Name         = emailobj.Name;
                ds.Description  = emailobj.Description;
                ds.Json         = EbSerializers.Json_Serialize(new EbEmailTemplate
                {
                    Body = emailobj.Body,
                    //EbObjectType = emailobj.EbObjectType,
                    Name            = emailobj.Name,
                    Subject         = emailobj.Subject,
                    DataSourceRefId = emailobj.DataSourceRefId
                });
                ds.Relations = "";
                ds.RefId     = _Refid;
                ds.ChangeLog = ChangeLog;
                var res = ServiceClient.Post <EbObject_CommitResponse>(ds);
                refid = res.RefId;
            }
            return(refid);
        }
Beispiel #8
0
        public string EmailTemplateSave(string _Refid, string PropObj)
        {
            var req = this.HttpContext.Request.Form;

            var    emailobj = EbSerializers.Json_Deserialize <EbEmailTemplate>(PropObj);
            string refid;

            if (string.IsNullOrEmpty(_Refid))
            {
                var ds = new EbObject_Create_New_ObjectRequest();
                ds.EbObjectType = (int)EbObjectType.EmailBuilder;
                ds.Name         = emailobj.Name;
                ds.Description  = emailobj.Description;
                ds.Json         = EbSerializers.Json_Serialize(new EbEmailTemplate
                {
                    Body = emailobj.Body,
                    //EbObjectType = emailobj.EbObjectType,
                    Name            = emailobj.Name,
                    Subject         = emailobj.Subject,
                    DataSourceRefId = emailobj.DataSourceRefId
                });
                ds.Relations = "";
                ds.IsSave    = true;

                var res = ServiceClient.Post <EbObject_Create_New_ObjectResponse>(ds);
                refid = res.RefId;
            }
            else
            {
                var ds = new EbObject_SaveRequest();
                ds.RefId        = _Refid;
                ds.Name         = emailobj.Name;
                ds.Description  = emailobj.Description;
                ds.EbObjectType = (int)EbObjectType.EmailBuilder;
                ds.Json         = EbSerializers.Json_Serialize(new EbEmailTemplate
                {
                    Body = emailobj.Body,
                    //EbObjectType = emailobj.EbObjectType,
                    Name            = emailobj.Name,
                    Subject         = emailobj.Subject,
                    DataSourceRefId = emailobj.DataSourceRefId
                });
                ds.Relations  = "";
                ViewBag.IsNew = "false";
                var res = this.ServiceClient.Post <EbObject_SaveResponse>(ds);
                refid = res.RefId;
            }
            return(refid);
        }
        public string getdv(string refid, EbObjectType objtype)
        {
            EbDataVisualization dsobj = null;

            if (refid != null)
            {
                var resultlist = this.ServiceClient.Get <EbObjectParticularVersionResponse>(new EbObjectParticularVersionRequest {
                    RefId = refid
                });
                dsobj               = EbSerializers.Json_Deserialize(resultlist.Data[0].Json);
                dsobj.Status        = resultlist.Data[0].Status;
                dsobj.VersionNumber = resultlist.Data[0].VersionNumber;
            }
            return(EbSerializers.Json_Serialize(dsobj));
        }
        public Dictionary <string, string> SendSMS(string To, string body)
        {
            Dictionary <string, string> msgStatus = null;

            try
            {
                var requestContent = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("From", Config.From),
                    new KeyValuePair <string, string>("To", To),
                    new KeyValuePair <string, string>("Body", body)
                });

                using (var httpClient = new HttpClient())
                {
                    requestContent.Headers.Clear();
                    requestContent.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
                                                                                                       System.Text.ASCIIEncoding.ASCII.GetBytes(
                                                                                                           string.Format("{0}:{1}", Config.UserName, Config.Password))));

                    HttpResponseMessage response = httpClient.PostAsync(url, requestContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        msgStatus = new Dictionary <string, string> {
                            { "To", To },
                            { "From", Config.From },
                            { "Uri", url },
                            { "Body", body },
                            { "Status", response.StatusCode.ToString() },
                            { "SentTime", response.Headers.Date.ToString() },
                            { "ErrorMessage", "" },
                            { "ConId", Config.Id.ToString() },
                            { "Result", response.ToString() }
                        };
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception:" + e.ToString());
                msgStatus.Add("ErrorMessage", e.ToString());
            }
            Console.WriteLine(" --- SMS msg" + EbSerializers.Json_Serialize(msgStatus));
            return(msgStatus);
        }
Beispiel #11
0
        public Dictionary <string, string> SendSMS(string To, string body)
        {
            Dictionary <string, string> msgStatus = null;
            string result;

            try
            {
                //string msg = HttpUtility.UrlEncode(body);
                using (var wb = new WebClient())
                {
                    byte[] response = wb.UploadValues("http://thesmsbuddy.com/api/v1/sms/send?", new NameValueCollection()
                    {
                        { "key", Config.ApiKey },
                        { "type", "1" },
                        { "to", To },
                        { "sender", Config.From },
                        { "message", body },
                        { "flash", "0" }
                    });
                    result = System.Text.Encoding.UTF8.GetString(response);
                }

                var status = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(result)["status"];

                msgStatus = new Dictionary <string, string>
                {
                    { "ApiKey", Config.ApiKey },
                    { "To", To },
                    { "From", Config.From },
                    { "Body", body },
                    { "ConId", Config.Id.ToString() },
                    { "Status", status },
                    { "Result", result }
                };
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception:" + e.ToString());
                msgStatus.Add("ErrorMessage", e.ToString());
            }
            Console.WriteLine(" --- SMS msg" + EbSerializers.Json_Serialize(msgStatus));
            return(msgStatus);
        }
Beispiel #12
0
            public string Post(SlackAuthMqRequest req)
            {
                TenantDbFactory dbFactory = new TenantDbFactory(req.TenantAccountId, this.Redis);

                if (req.IsNew)
                {
                    try
                    {
                        string sql = "UPDATE eb_users SET slackjson = @slackjson WHERE id = @id RETURNING id";

                        var id = dbFactory.DataDB.DoQuery <Int32>(sql, new DbParameter[] {
                            dbFactory.DataDB.GetNewParameter("slackjson", NpgsqlTypes.NpgsqlDbType.Json, EbSerializers.Json_Serialize(req.SlackJson)),
                            dbFactory.DataDB.GetNewParameter("id", System.Data.DbType.Int32, req.UserId)
                        });
                    }

                    catch (Exception e)
                    {
                        return(null);
                    }
                }
                else
                {
                }
                return(null);
            }
        public void InitFromDataBase(JsonServiceClient ServiceClient, IRedisClient redis)
        {
            EbChartVisualization ChartVisualization = EbFormHelper.GetEbObject <EbChartVisualization>(TVRefId, ServiceClient, redis, null);

            this.ChartVisualizationJson = EbSerializers.Json_Serialize(ChartVisualization);
        }
        public int PersistIntegrationConf(string Sol_Id, EbConnectionFactory infra, int UserId)
        {
            int    nid   = 0;
            string query = string.Empty;
            string json  = EbSerializers.Json_Serialize(this);// JsonConvert.SerializeObject(this);

            DbParameter[] parameters =
            {
                infra.DataDB.GetNewParameter("solution_id", EbDbTypes.String, Sol_Id),
                infra.DataDB.GetNewParameter("nick_name",   EbDbTypes.String, !(string.IsNullOrEmpty(this.NickName))?this.NickName:string.Empty),
                infra.DataDB.GetNewParameter("type",        EbDbTypes.String, this.Type.ToString()),
                infra.DataDB.GetNewParameter("con_obj",     EbDbTypes.Json,   json),
                infra.DataDB.GetNewParameter("uid",         EbDbTypes.Int32,  UserId),
                infra.DataDB.GetNewParameter("id",          EbDbTypes.Int32,  this.Id)
            };
            if (this.Id <= 0)
            {
                query = @"
                            INSERT INTO 
                                eb_integration_configs (solution_id, nickname, type, con_obj, created_by, created_at, eb_del) 
                            VALUES 
                                (@solution_id, @nick_name, @type, @con_obj, @uid, NOW() , 'F')
                            RETURNING 
                                id;";
                EbDataSet ds = infra.DataDB.DoQueries(query, parameters);
                nid = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }
            else
            {
                query = @"
                            UPDATE 
                                eb_integration_configs 
                            SET 
                                modified_at = NOW(), 
                                modified_by = @uid, 
                                eb_del = 'T' 
                            WHERE 
                                id = @id;
                            INSERT INTO 
                                eb_integration_configs (solution_id, nickname, type, con_obj, created_by, created_at, eb_del) 
                            VALUES 
                                (@solution_id, @nick_name, @type, @con_obj, @uid, NOW() , 'F') 
                            RETURNING 
                                id;";
                EbDataSet ds = infra.DataDB.DoQueries(query, parameters);
                nid = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                if (this.Id != 0)
                {
                    query = @"UPDATE eb_integrations 
                            SET
                                eb_integration_conf_id = @nid
                            WHERE
                                eb_integration_conf_id = @oid; ";
                    DbParameter[] parameter =
                    {
                        infra.DataDB.GetNewParameter("nid", EbDbTypes.Int32, nid),
                        infra.DataDB.GetNewParameter("oid", EbDbTypes.Int32, this.Id)
                    };
                    infra.DataDB.DoNonQuery(query, parameter);
                }
            }
            return(nid);
        }
Beispiel #15
0
        private string JsVarDecl(PropertyInfo prop, object obj)
        {
            string s     = @"this.{0} = {1};";
            string _c    = @"this.Controls = new EbControlCollection(JSON.parse('{0}'));";
            string _name = prop.Name;

            if (prop.IsDefined(typeof(JsonPropertyAttribute)))
            {
                _name = prop.GetCustomAttribute <JsonPropertyAttribute>().PropertyName;
            }
            if (prop.IsDefined(typeof(DefaultPropValue)) && (prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(string) || prop.PropertyType.IsEnum))
            {
                string DefaultVal = prop.GetCustomAttribute <DefaultPropValue>().Value;
                // For Object Selector
                if (prop.GetType().GetTypeInfo().IsDefined(typeof(PropertyEditor)) && prop.GetCustomAttribute <PropertyEditor>().PropertyEditorType == (int)PropertyEditorType.ObjectSelector)
                {
                    Attribute          EditorAttr = prop.GetCustomAttribute <PropertyEditor>();
                    PropertyEditorType EditorType = (PropertyEditorType)(EditorAttr as PropertyEditor).PropertyEditorType;

                    if (EditorType is PropertyEditorType.ObjectSelector)
                    {
                        DefaultVal = DefaultVal.SingleQuoted();
                    }
                }
                //for Others
                else if (prop.PropertyType == typeof(string) || prop.PropertyType == typeof(DateTime))
                {
                    DefaultVal = DefaultVal.SingleQuoted();
                }

                return(string.Format(s, _name, DefaultVal));
            }

            if (prop.PropertyType == typeof(string))
            {
                if (!string.IsNullOrEmpty((string)prop.GetValue(obj)))
                {
                    return(string.Format(s, _name, string.Format("'{0}'", prop.GetValue(obj))));
                }
                if (prop.Name.EndsWith("Color"))
                {
                    return(string.Format(s, _name, "'#FFFFFF'"));
                }
                else
                {
                    return(string.Format(s, _name, (prop.Name == "Name" || prop.Name == "EbSid") ? "id" : "''"));
                }
            }
            else if (prop.Name == "Controls")
            {
                return(string.Format(_c, JsonConvert.SerializeObject((obj as EbControlContainer).Controls, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.All
                })));
            }
            else if (prop.PropertyType == (typeof(int)) || prop.PropertyType == (typeof(float)))
            {
                return(string.Format(s, _name, ((prop.Name == "Id") ? "id" : "0")));
            }
            else if (prop.PropertyType == typeof(bool))
            {
                return(string.Format(s, _name, prop.GetValue(obj).ToString().ToLower()));
            }
            else if (prop.PropertyType.GetTypeInfo().IsEnum)
            {
                if (prop.IsDefined(typeof(PropertyEditor)) && prop.GetCustomAttribute <PropertyEditor>().BooleanOption)
                {
                    Type[] args     = prop.PropertyType.GetGenericArguments();
                    Type   itemType = args[0];
                    return(string.Format(s, _name, "{\"$type\":\"System.Collections.Generic.List`1[[@typeName, @nameSpace]], System.Private.CoreLib\",\"$values\":[]}".Replace("@typeName", itemType.FullName).Replace("@nameSpace", itemType.AssemblyQualifiedName.Split(",")[1])));
                }
                return(string.Format(s, _name, ((int)prop.GetValue(obj)).ToString()));
            }
            else if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition().Name == "IDictionary`2")
            {
                return(string.Format(s, _name, "{\"$type\": \"System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib\",\"$values\": {}}"));//need to recheck format
            }
            else if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(List <>))
            {
                Type[] args = prop.PropertyType.GetGenericArguments();
                if (args.Length > 0)
                {
                    Type itemType = args[0];
                    return(string.Format(s, _name, "{\"$type\":\"System.Collections.Generic.List`1[[@typeName, @nameSpace]], System.Private.CoreLib\",\"$values\":[]}".Replace("@typeName", itemType.FullName).Replace("@nameSpace", itemType.AssemblyQualifiedName.Split(",")[1])));
                }
                else
                {
                    return(string.Format(s, _name, "[]"));
                }
            }
            else if (prop.PropertyType.IsClass && !prop.PropertyType.IsPrimitive)
            {
                if (prop.PropertyType == typeof(EbFont))
                {
                    return(string.Format(s, _name, "null"));
                }
                else
                {
                    try
                    {
                        object Obj = Activator.CreateInstance(prop.PropertyType);
                        SetAllDefaultPropVals(prop, Obj);
                        return(string.Format(s, _name, EbSerializers.Json_Serialize(Obj)));
                    }
                    catch (Exception e)
                    {
                        Console.Write(e.Message);
                        return("");
                    }
                }
            }
            else
            {
                return(string.Format(s, _name, "null"));
            }
        }
Beispiel #16
0
        public bool Post(SlackAuthRequest req)
        {
            EbConnectionFactory dbFactory = new EbConnectionFactory(req.SolnId, this.Redis);

            if (req.IsNew)
            {
                try
                {
                    string sql = "UPDATE eb_users SET slackjson = @slackjson WHERE id = @id";

                    var id = dbFactory.DataDB.DoQuery <Int32>(sql, new DbParameter[] {
                        dbFactory.DataDB.GetNewParameter("slackjson", EbDbTypes.Json, EbSerializers.Json_Serialize(req.SlackJson)),
                        dbFactory.DataDB.GetNewParameter("id", EbDbTypes.Int32, req.UserId)
                    });
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception: " + e.ToString());
                    return(false);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
            return(true);
        }
Beispiel #17
0
        private string JsVarDecl(PropertyInfo prop, object obj)
        {
            string s  = @"this.{0} = {1};";
            string _c = @"this.Controls = new EbControlCollection(JSON.parse('{0}'));";

            if (prop.IsDefined(typeof(DefaultPropValue)))
            {
                string DefaultVal = prop.GetCustomAttribute <DefaultPropValue>().Value;
                // For Object Selector
                if (prop.GetType().GetTypeInfo().IsDefined(typeof(PropertyEditor)) && prop.GetCustomAttribute <PropertyEditor>().PropertyEditorType == PropertyEditorType.ObjectSelector)
                {
                    Attribute          EditorAttr = prop.GetCustomAttribute <PropertyEditor>();
                    PropertyEditorType EditorType = (EditorAttr as PropertyEditor).PropertyEditorType;

                    if (EditorType is PropertyEditorType.ObjectSelector)
                    {
                        DefaultVal = DefaultVal.SingleQuoted();
                    }
                }
                //for Others
                else if (prop.PropertyType == typeof(string) || prop.PropertyType == typeof(DateTime))
                {
                    DefaultVal = DefaultVal.SingleQuoted();
                }

                return(string.Format(s, prop.Name, DefaultVal));
            }

            if (prop.PropertyType == typeof(string))
            {
                if (prop.Name.EndsWith("Color"))
                {
                    return(string.Format(s, prop.Name, "'#FFFFFF'"));
                }
                else
                {
                    return(string.Format(s, prop.Name, (prop.Name == "Name" || prop.Name == "EbSid") ? "id" : "''"));
                }
            }
            else if (prop.Name == "Controls")
            {
                return(string.Format(_c, JsonConvert.SerializeObject((obj as EbControlContainer).Controls, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.All
                })));
            }
            else if (prop.PropertyType == (typeof(int)) || prop.PropertyType == (typeof(float)))
            {
                return(string.Format(s, prop.Name, ((prop.Name == "Id") ? "id" : "0")));
            }
            else if (prop.PropertyType == typeof(bool))
            {
                return(string.Format(s, prop.Name, "false"));
            }
            else if (prop.PropertyType.GetTypeInfo().IsEnum)
            {
                return(string.Format(s, prop.Name, "0"));
            }
            else if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(List <>))
            {
                Type[] args = prop.PropertyType.GetGenericArguments();
                if (args.Length > 1)
                {
                    Type itemType = args[0];
                    return(string.Format(s, prop.Name, "{\"$type\":\"System.Collections.Generic.List`1[[@typeName, ExpressBase.Objects]], System.Private.CoreLib\",\"$values\":[]}".Replace("@typeName", itemType.FullName)));
                }
                else
                {
                    return(string.Format(s, prop.Name, "[]"));
                }
            }
            else if (prop.PropertyType.IsClass)
            {
                object Obj = Activator.CreateInstance(prop.PropertyType);
                return(string.Format(s, prop.Name, EbSerializers.Json_Serialize(Obj)));
            }
            else
            {
                return(string.Format(s, prop.Name, "null"));
            }
        }
        public Dictionary <string, string> SendSMS(string To, string body)
        {
            Dictionary <string, string> msgStatus = null;

            try
            {
                string status = string.Empty;
                string result = string.Empty;
                string url    = string.Format(SMS_URL_BARE, Config.UserName, Config.Password, Config.ApiKey, To, body);

                IEnumerable <string> matches = Regex.Matches(To, @"[1-9]").OfType <Match>()
                                               .Select(m => m.Groups[0].Value)
                                               .Distinct();
                if (matches.Count() > 0)
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    WebResponse    resp    = request.GetResponse();

                    WebHeaderCollection header   = resp.Headers;
                    Encoding            encoding = ASCIIEncoding.ASCII;
                    string responseText;
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(resp.GetResponseStream(), encoding))
                    {
                        responseText = reader.ReadToEnd();
                    }
                    XmlDocument Doc = new XmlDocument();
                    Doc.LoadXml(responseText);
                    XmlNode node = Doc.GetElementsByTagName("ExpertTextAPI").Item(0);
                    foreach (XmlNode item in node.ChildNodes)
                    {
                        if ((item).NodeType == XmlNodeType.Element)
                        {
                            if (item.Name == "Status")
                            {
                                if (item.FirstChild.Value == "SUCCESS")
                                {
                                    status = item.FirstChild.Value;
                                }
                                else
                                {
                                    status = "FAILED";
                                    result = item.FirstChild.Value;
                                }
                            }
                        }
                    }
                }
                else
                {
                    status = "FAILED";
                    result = "'To' is not a Valid number.";
                }
                msgStatus = new Dictionary <string, string>
                {
                    { "To", To },
                    { "From", Config.From },
                    { "Uri", url },
                    { "Body", body },
                    { "Status", status.ToLower() },
                    // { "SentTime", msg.DateSent.ToString() },
                    // { "ErrorMessage", msg.ErrorMessage }
                    { "ConId", Config.Id.ToString() },
                    { "Result", result }
                };
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception:" + e.Message);
                if (!(msgStatus is null))
                {
                    msgStatus.Add("ErrorMessage", e.Message);
                }
            }
            Console.WriteLine(" --- SMS msg" + EbSerializers.Json_Serialize(msgStatus));
            return(msgStatus);
        }
        public virtual void Persist(string TenantAccountId, ITenantDbFactory dbconf, bool IsNew)
        {
            if (IsNew)
            {
                string        sql        = "INSERT INTO eb_connections (con_type, solution_id, nick_name, con_obj) VALUES (@con_type, @solution_id, @nick_name, @con_obj) RETURNING id";
                DbParameter[] parameters = { dbconf.DataDB.GetNewParameter("con_type",    System.Data.DbType.String,     EbConnectionType),
                                             dbconf.DataDB.GetNewParameter("solution_id", System.Data.DbType.String,     TenantAccountId),
                                             dbconf.DataDB.GetNewParameter("nick_name",   System.Data.DbType.String,     !(string.IsNullOrEmpty(NickName))?NickName:string.Empty),
                                             dbconf.DataDB.GetNewParameter("con_obj",     NpgsqlTypes.NpgsqlDbType.Json, EbSerializers.Json_Serialize(this)) };
                var           iCount = dbconf.DataDB.DoQuery(sql, parameters);
            }

            else if (!IsNew)
            {
                string        sql        = @"UPDATE eb_connections SET eb_del = true WHERE con_type = @con_type AND solution_id = @solution_id; 
                                      INSERT INTO eb_connections (con_type, solution_id, nick_name, con_obj) VALUES (@con_type, @solution_id, @nick_name, @con_obj)";
                DbParameter[] parameters = { dbconf.DataDB.GetNewParameter("con_type",    System.Data.DbType.String,     EbConnectionType),
                                             dbconf.DataDB.GetNewParameter("solution_id", System.Data.DbType.String,     TenantAccountId),
                                             dbconf.DataDB.GetNewParameter("nick_name",   System.Data.DbType.String,     !(string.IsNullOrEmpty(NickName))?NickName:string.Empty),
                                             dbconf.DataDB.GetNewParameter("con_obj",     NpgsqlTypes.NpgsqlDbType.Json, EbSerializers.Json_Serialize(this)) };
                var           iCount = dbconf.DataDB.DoNonQuery(sql, parameters);
            }
        }