Exemple #1
0
        public bool Post(RefreshSolutionConnectionsMqRequest req)
        {
            using (var con = new TenantDbFactory("expressbase", this.Redis).DataDB.GetNewConnection() as Npgsql.NpgsqlConnection)
            {
                try
                {
                    con.Open();
                    string    sql = @"SELECT con_type, con_obj FROM eb_connections WHERE solution_id = @solution_id AND eb_del = false";
                    DataTable dt  = new DataTable();
                    var       ada = new Npgsql.NpgsqlDataAdapter(sql, con);
                    ada.SelectCommand.Parameters.Add(new Npgsql.NpgsqlParameter("solution_id", NpgsqlTypes.NpgsqlDbType.Text)
                    {
                        Value = req.TenantAccountId
                    });
                    ada.Fill(dt);

                    EbSolutionConnections cons = new EbSolutionConnections();
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr["con_type"].ToString() == EbConnectionTypes.EbDATA.ToString())
                        {
                            cons.DataDbConnection = EbSerializers.Json_Deserialize <EbDataDbConnection>(dr["con_obj"].ToString());
                        }
                        else if (dr["con_type"].ToString() == EbConnectionTypes.EbDATA_RO.ToString())
                        {
                            cons.DataDbConnection = EbSerializers.Json_Deserialize <EbDataDbConnection>(dr["con_obj"].ToString());
                        }
                        else if (dr["con_type"].ToString() == EbConnectionTypes.EbOBJECTS.ToString())
                        {
                            cons.ObjectsDbConnection = EbSerializers.Json_Deserialize <EbObjectsDbConnection>(dr["con_obj"].ToString());
                        }
                        else if (dr["con_type"].ToString() == EbConnectionTypes.EbFILES.ToString())
                        {
                            cons.FilesDbConnection = EbSerializers.Json_Deserialize <EbFilesDbConnection>(dr["con_obj"].ToString());
                        }
                        else if (dr["con_type"].ToString() == EbConnectionTypes.EbLOGS.ToString())
                        {
                            cons.LogsDbConnection = EbSerializers.Json_Deserialize <EbLogsDbConnection>(dr["con_obj"].ToString());
                        }
                        else if (dr["con_type"].ToString() == EbConnectionTypes.SMTP.ToString())
                        {
                            cons.SMTPConnection = EbSerializers.Json_Deserialize <SMTPConnection>(dr["con_obj"].ToString());
                        }

                        // ... More to come
                    }

                    Redis.Set <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId), cons);

                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
        public GetConnectionsResponse Post(GetConnectionsRequest req)
        {
            GetConnectionsResponse resp = new GetConnectionsResponse();

            resp.EBSolutionConnections = new EbSolutionConnections();

            if (req.ConnectionType == 0)
            {
                EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId));

                resp.EBSolutionConnections = dummy;

                if (resp.EBSolutionConnections.DataDbConnection != null)
                {
                    resp.EBSolutionConnections.DataDbConnection.Password = "******";
                }

                if (resp.EBSolutionConnections.ObjectsDbConnection != null)
                {
                    resp.EBSolutionConnections.ObjectsDbConnection.Password = "******";
                }

                if (resp.EBSolutionConnections.SMTPConnection != null)
                {
                    resp.EBSolutionConnections.SMTPConnection.Password = "******";
                }
            }

            else if (req.ConnectionType == (int)EbConnectionTypes.SMTP)
            {
                EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId));

                resp.EBSolutionConnections.SMTPConnection = new SMTPConnection();
                resp.EBSolutionConnections.SMTPConnection = dummy.SMTPConnection;

                if (resp.EBSolutionConnections.SMTPConnection != null)
                {
                    resp.EBSolutionConnections.SMTPConnection.Password = "******";
                }
            }

            else if (req.ConnectionType == (int)EbConnectionTypes.EbDATA)
            {
                EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId));

                resp.EBSolutionConnections.DataDbConnection = new EbDataDbConnection();
                resp.EBSolutionConnections.DataDbConnection = dummy.DataDbConnection;

                if (resp.EBSolutionConnections.DataDbConnection != null)
                {
                    resp.EBSolutionConnections.DataDbConnection.Password = "******";
                }
            }

            else if (req.ConnectionType == (int)EbConnectionTypes.SMS)
            {
                EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId));

                resp.EBSolutionConnections.SMSConnection = new SMSConnection();
                resp.EBSolutionConnections.SMSConnection = dummy.SMSConnection;

                if (resp.EBSolutionConnections.DataDbConnection != null)
                {
                    resp.EBSolutionConnections.SMSConnection.Password = "******";
                }
            }

            return(resp);
        }
Exemple #3
0
        public string Any(UploadImageRequest request)
        {
            string bucketName = "images_original";

            if (request.ImageInfo.FileName.StartsWith("dp"))
            {
                bucketName = "dp_images";
            }

            EbSolutionConnections SolutionConnections = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", request.TenantAccountId));

            if (request.IsAsync)
            {
                try
                {
                    this.MessageProducer3.Publish(new UploadFileMqRequest
                    {
                        FileDetails = new FileMeta
                        {
                            FileName           = request.ImageInfo.FileName,
                            MetaDataDictionary = (request.ImageInfo.MetaDataDictionary != null) ?
                                                 request.ImageInfo.MetaDataDictionary :
                                                 new Dictionary <String, List <string> >()
                            {
                            },
                        },
                        FileByte        = request.ImageByte,
                        BucketName      = bucketName,
                        TenantAccountId = request.TenantAccountId,
                        UserId          = request.UserId
                    });
                    return("Successfully Uploaded to MQ");
                }
                catch (Exception e)
                {
                    return("Failed to Uplaod to MQ");
                }
            }
            else if (!request.IsAsync)
            {
                string Id = (new TenantDbFactory(request.TenantAccountId, this.Redis)).FilesDB.UploadFile(
                    request.ImageInfo.FileName,
                    request.ImageInfo.MetaDataDictionary,
                    request.ImageByte,
                    bucketName
                    ).ToString();

                this.MessageProducer3.Publish(new FileMetaPersistMqRequest
                {
                    FileDetails = new FileMeta
                    {
                        ObjectId           = Id,
                        FileName           = request.ImageInfo.FileName,
                        MetaDataDictionary = (request.ImageInfo.MetaDataDictionary != null) ?
                                             request.ImageInfo.MetaDataDictionary :
                                             new Dictionary <String, List <string> >()
                        {
                        },
                        Length   = request.ImageByte.Length,
                        FileType = request.ImageInfo.FileType
                    },
                    BucketName      = bucketName,
                    TenantAccountId = request.TenantAccountId,
                    UserId          = request.UserId
                });
                this.MessageProducer3.Publish(new ImageResizeMqRequest
                {
                    ImageInfo = new FileMeta
                    {
                        ObjectId           = Id,
                        FileName           = request.ImageInfo.FileName,
                        MetaDataDictionary = (request.ImageInfo.MetaDataDictionary != null) ?
                                             request.ImageInfo.MetaDataDictionary :
                                             new Dictionary <String, List <string> >()
                        {
                        }
                    },
                    ImageByte       = request.ImageByte,
                    TenantAccountId = request.TenantAccountId,
                    UserId          = request.UserId
                });
                return(Id);
            }

            return("Uploading Failed check the data");
        }