示例#1
0
        private void Xml_Reader()
        {
            if (File.Exists("dtEMail.xsd"))
            {
                DataTable dtEmail = new DataTable();
                dtEmail.ReadXmlSchema("dtEMail.xsd");

                dtEmail.ReadXml("dtEMail.xml");


                foreach (DataRow dr in dtEmail.Rows)
                {
                    tbFromMail.Text     = dr["FromEMail"].ToString();
                    tbFromMailPass.Text = EncryptionManager.Decrypt(dr["Password"].ToString());
                    tbSmtpHost.Text     = dr["SmtpHost"].ToString();
                    spnSmtpPort.Value   = Convert.ToInt32(dr["SmtpPort"].ToString());

                    if (dr["EnableSSL"].ToString() == "1")
                    {
                        cbSSL.Checked = true;
                    }
                    else
                    {
                        cbSSL.Checked = false;
                    }
                }
            }
        }
示例#2
0
        public static string DecryptAndAuthenticateContentUser(string token, string data)
        {         // should be called on content app
            string url = HttpContext.Current.Cache[GetCacheKey(token)] as string;

            if (string.IsNullOrEmpty(url))
            {
                return(null);
            }

            RPIdentity rpIdentity;

            try
            {
                string userData = EncryptionManager.Decrypt(data);
                rpIdentity = new RPIdentity(userData);
            }
            catch
            {
                return(null);
            }
            DateTime now = DateTime.Now;
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                2,
                rpIdentity.Name,
                now,
                now.Add(AuthenticationContentTimeout),
                false,
                rpIdentity.GetCookieString(),
                FormsAuthentication.FormsCookiePath
                );

            SetTicketToCookie(ticket);
            return(url);
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            var details = _userRepository.GetUserDetails(UserContext.User.Id, UserContext.User.OrganizationId, id);

            if (details.Detail == null)
            {
                return(NotFoundResult());
            }

            var viewModel = Mapper.Map <UserDetailsViewModel>(details);

            viewModel.Detail.Password = EncryptionManager.Decrypt(viewModel.Detail.Password);
            ICollection <SelectListItemCount> organizationItems = _organizationRepository.GetOrganizations(
                UserContext.User.Id,
                UserContext.User.OrganizationId
                );

            viewModel.Detail.OrganizationItems = Mapper.Map <ICollection <SelectListItem> >(organizationItems);
            ICollection <SelectListItemCount> roleItems = _roleRepository.GetRoles(
                UserContext.User.Id,
                UserContext.User.OrganizationId
                );

            viewModel.Detail.RoleItems          = Mapper.Map <ICollection <SelectListItem> >(roleItems);
            viewModel.Detail.RoleIds            = details.UserRoles.Select(m => m.RoleId).Distinct().ToList();
            viewModel.Detail.RoleOrganizationId = details.UserRoles.Select(m => m.OrganizationId).FirstOrDefault();
            viewModel.Detail.GenderItems        = InitGenderSelectListItems();
            viewModel.Detail.LanguageItems      = InitLanguageSelectListItems();

            return(View(Mvc.View.User.Edit, viewModel));
        }
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var metaDataProvider = new JsonMetaDataProvider();

            if (!request.Headers.Contains(RestfulServiceConstants.RqModelTypeHeaderKey))
            {
                return(GetMetaNotFoundResponse("required head key was missing"));
            }

            var rqType = request.Headers.GetValues(RestfulServiceConstants.RqModelTypeHeaderKey).ToList();

            if (rqType.Count == 0)
            {
                return(GetMetaNotFoundResponse("required header key was empty"));
            }

            var modelType = Type.GetType(EncryptionManager.Decrypt(rqType[0]), false);

            if (modelType == null)
            {
                return(GetMetaNotFoundResponse("requested model type was not found"));
            }

            return(Task.Factory.StartNew(() =>
                                         new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(metaDataProvider.GetMetaData(modelType))
            }));
        }
        public string GetConnectionString()
        {
            string conexionString = "";
            var    prod           = EncryptionManager.Decrypt("kPpN+ncRSXeJHLpuqqOSa97k7hobl3V8PblQZmsXuxdhKHnvI1dum+9fRxTSLvPN5IuAWy1+5fQL9TPsLKk++nV/ndwgIJ2dQjQ30I/jIrpvOBtprKpkGunNqIeMG0lagE7GzSKN4bs2I1rfI1cwWj3cQzQvsMIoFjdaojL0zrLaBlQW4O7N+jlQ9FvZeQXepWGqARzMAy8f4j8IzkP8XJiuvw5dvDZdhww0K4QsvXweKcxTt6feooANQsSVc6ktMnKTByVtGrd4XwjC9Q32LF78o3CWe/MLlqQaoimzjDE2SYL7FvMBdVTdZsBZXePTxpKJ9IgVAcr6TeZGoAYSMzBQoLHRXayeV0cuVOy8cunXh5ST2hMQiSlVgxpfWuU0XTMZzK40CEVgIqnXtm8Mpx2I9JwnC/hATVlTbvSQOG7oEvq0YCJrUbbYefxz35BGlEhmSM1u72zhh2HQssQTB4cNanuIt62agyfDaZ+4H2ktUrcjNRcA/c0jgPlFlesDAihv00lsUo4K+K/8fJ39jQ==");
            var    encrypt        = EncryptionManager.Encrypt(prod);

            conexionString = prod;

            return(conexionString);
        }
        public string GetConnectionString()
        {
            string conexionString = "";
            var    prod           = EncryptionManager.Decrypt("DnGSNiEDyELYKyAJW5l0025tuH5UdV8KhDpuMov19fi/s1sc6L51juiMAuKYrr/wjoWA5Oped33RVDppqouAUHOiFxu8MTVatm9EKhHmcVuCyi1KxKeFc7ksuNHi5T+SNa7yVysH1lbhMRwWHfRCTYbH/X58OXOVeGRZpabN4fQ5FezNIwsWgdt/CtwRUpXakflSD2K4Knv3VkuaBvL1NAYC6lQtG0P3Ycl2Im8XqeB+uzHxwVSVxvtCrrEwwkl69Bk68driwOPDDUYi86pzKCvCh+s3tpoxPWxZTbf5ymsx/+RUa94dcYsZY+aYxbv+FgTdy8lMSC0GkJuD4Afrm4vvAyFkFDgwhjcO97aaIipOVTB1VyRiht8AE0nRYvPQgj8tHEA5yQ9G9MCv7nkCcy925oX35HNOo9IDepcEfY5JvEnEMPEmc1tctCZp8vvk8/WxKGAgxotgoQrNeHE84PcCpHUY9UV6BiKJe3TBWuwFW2MIAmv3nfewKqeXliX4r5EvgNjzSztAo+wyqHB/7ZdW/qngDdmREKvoCPyVArzUTtBjGEdFmeDs9gP1yEAX");
            var    encrypt        = EncryptionManager.Encrypt(prod);

            conexionString = prod;

            return(conexionString);
        }
示例#7
0
        public autosgrsm_SIGRES consulta(string CAI)
        {
            autosgrsm_SIGRES objetoSigres = new autosgrsm_SIGRES();

            autosgrsm_Parametros parametros = new autosgrsm_Parametros();

            //string a = EncryptionManager.Encrypt(@"Server=10.80.3.147\SQLINSTPROY;Database=E2E_Salvalineas_base_dev;User Id=E2E_Salvalineas_base;Password=7SrD2TA$;");
            parametros.cadena      = EncryptionManager.Decrypt(ConfigurationManager.ConnectionStrings["DB_CONNECTION_" + cadena].ToString());
            parametros.querySelect = "WHERE Nombre_Parametro = @Nombre_Parametro";
            dicParameter           = new Dictionary <string, string>();
            dicParameter.Add("@Nombre_Parametro", "SQL_SELECT_SIGRES");
            DataTable tbParametros   = parametros.select(dicParameter).Tables[0];
            string    consultaSigres = tbParametros.Rows[0]["Valor_Parametro"].ToString();

            string    db_sigres = EncryptionManager.Decrypt(ConfigurationManager.ConnectionStrings["DB_CONNECTION_SIGRES_" + cadena].ToString());
            DataTable query     = new DataTable();

            using (OracleConnection conn = new OracleConnection(db_sigres))
            {
                try
                {
                    OracleCommand cmd = new OracleCommand();

                    cmd.CommandText = consultaSigres;
                    cmd.Connection  = conn;
                    cmd.Parameters.Add("CAI", CAI);
                    conn.Open();
                    OracleDataReader queryOracle = cmd.ExecuteReader();

                    query.Load(queryOracle);
                    conn.Close();
                }
                catch (Exception ex)
                {
                    objetoSigres        = new autosgrsm_SIGRES();
                    objetoSigres.ESTADO = ex.Message;
                    return(objetoSigres);
                }
            }

            if (query.Rows.Count > 0)
            {
                objetoSigres = new autosgrsm_SIGRES()
                {
                    SERVICESID = query.Rows[0]["SERVICESID"].ToString(),
                    ESTADO     = query.Rows[0]["ESTADO"].ToString()
                };
            }
            else
            {
                objetoSigres = new autosgrsm_SIGRES();
            }

            return(objetoSigres);
        }
    public static string GetString(string key, string defaultValue = "")
    {
        string text  = defaultValue;
        string value = PlayerPrefs.GetString(EncryptionManager.GetHash(key), defaultValue.ToString());

        if (!text.Equals(value))
        {
            text = EncryptionManager.Decrypt(value);
        }
        return(text);
    }
示例#9
0
        public void insertLogGeneral(int estado, string descripcion)
        {
            autosgrsm_Log logger = new autosgrsm_Log();

            logger.cadena      = EncryptionManager.Decrypt(ConfigurationManager.ConnectionStrings["DB_CONNECTION_" + cadena].ToString());
            logger.fecha       = DateTime.Now;
            logger.estado      = estado;
            logger.descripcion = descripcion;
            logger.insert();

            Console.WriteLine("Se agregó al log general: " + descripcion);
        }
示例#10
0
        public autosgrsm_SOM getSomDataByCRMNO(string connection, string parametro)
        {
            Log log = new Log();

            autosgrsm_SOM dataSOM = new autosgrsm_SOM();

            try
            {
                dataSOM.cadena      = EncryptionManager.Decrypt(connection);
                dataSOM.querySelect = "WHERE CRMNO = @CRMNO";
                dicParameter        = new Dictionary <string, string>();
                dicParameter.Add("@CRMNO", parametro);
                DataTable tbSOM = dataSOM.select(dicParameter).Tables[0];

                dataSOM.Id                  = Convert.ToInt32(tbSOM.Rows[0]["Id"].ToString());
                dataSOM.FLOWID              = tbSOM.Rows[0]["FLOWID"].ToString();
                dataSOM.TECNOLOGIA          = tbSOM.Rows[0]["TECNOLOGIA"].ToString();
                dataSOM.OPERACION_COMERCIAL = tbSOM.Rows[0]["OPERACION_COMERCIAL"].ToString();
                dataSOM.ESTADO_DE_LA_ORDEN  = tbSOM.Rows[0]["ESTADO_DE_LA_ORDEN"].ToString();
                dataSOM.APPOINTMENT_ID      = tbSOM.Rows[0]["APPOINTMENT_ID"].ToString();
                dataSOM.FLOWNO              = tbSOM.Rows[0]["FLOWNO"].ToString();
                dataSOM.ORDERCREATETIME     = Convert.ToDateTime(tbSOM.Rows[0]["ORDERCREATETIME"].ToString());
                dataSOM.WORKCREATETIME      = Convert.ToDateTime(tbSOM.Rows[0]["WORKCREATETIME"].ToString());
                dataSOM.DATE_ERROR          = Convert.ToDateTime(tbSOM.Rows[0]["DATE_ERROR"].ToString());
                dataSOM.FLOWTYPE            = tbSOM.Rows[0]["FLOWTYPE"].ToString();
                dataSOM.FLOWTYPEID          = tbSOM.Rows[0]["FLOWTYPEID"].ToString();
                dataSOM.PROCESSINSTNAME     = tbSOM.Rows[0]["PROCESSINSTNAME"].ToString();
                dataSOM.ACTIVITYDEFID       = tbSOM.Rows[0]["ACTIVITYDEFID"].ToString();
                dataSOM.ACTIVITYINSTNAME    = tbSOM.Rows[0]["ACTIVITYINSTNAME"].ToString();
                dataSOM.CRMNO               = tbSOM.Rows[0]["CRMNO"].ToString();
                dataSOM.CUSTOMNAME          = tbSOM.Rows[0]["CUSTOMNAME"].ToString();
                dataSOM.PRODUCT             = tbSOM.Rows[0]["PRODUCT"].ToString();
                dataSOM.OPERATION           = tbSOM.Rows[0]["OPERATION"].ToString();
                dataSOM.ACCESSACCOUNT       = tbSOM.Rows[0]["ACCESSACCOUNT"].ToString();
                dataSOM.INSTALL_ADDRESS     = tbSOM.Rows[0]["INSTALL_ADDRESS"].ToString();
                dataSOM.CODIGO_LOCALIDAD    = tbSOM.Rows[0]["CODIGO_LOCALIDAD"].ToString();
                dataSOM.ERROR_CODE          = tbSOM.Rows[0]["ERROR_CODE"].ToString();
                dataSOM.ERROR_DESC          = tbSOM.Rows[0]["ERROR_DESC"].ToString();
                dataSOM.CREATED             = Convert.ToDateTime(tbSOM.Rows[0]["CREATED"].ToString());
                dataSOM.STATUS_FLOW         = Convert.ToInt32(tbSOM.Rows[0]["STATUS_FLOW"].ToString());
                dataSOM.STATUS_CAI          = Convert.ToInt32(tbSOM.Rows[0]["STATUS_CAI"].ToString());
            }
            catch (Exception ex)
            {
                log.insertLogGeneral(4, "No se pueden consultar los parámetros: " + ex.Message);
            }

            return(dataSOM);
        }
示例#11
0
        public ActionResult ProfileEdit()
        {
            var userProfile = _userRepository.GetUserProfile(UserContext.User.Id);
            UserProfileViewModel viewModel = Mapper.Map <UserProfileViewModel>(userProfile);

            viewModel.Password        = EncryptionManager.Decrypt(viewModel.Password);
            viewModel.ConfirmPassword = viewModel.Password;
            viewModel.FormattedName   = Format.FormattedFullName(viewModel.LastName, viewModel.FirstName, viewModel.MiddleName);
            viewModel.Gender          = GetGenderName(viewModel.GenderId);
            viewModel.Language        = GetLanguageName(viewModel.LanguageId);
            viewModel.GenderItems     = InitGenderSelectListItems();
            viewModel.LanguageItems   = InitLanguageSelectListItems();

            return(View(Mvc.View.User.ProfileEdit, viewModel));
        }
    public static void Init(string _sKEY = null, string _sIV = null)
    {
        sKEY = _sKEY ?? sKEY;
        sIV  = _sIV ?? sIV;
        string key = PlayerPrefs.GetString(EncryptionManager.GetHashEx(publicKey), "");

        if (key != "")
        {
            publicKeyStr = EncryptionManager.Decrypt(key);
        }
        else
        {
            publicKeyStr = Utils.GetRandomString(16) + SystemInfo.deviceUniqueIdentifier;
            PlayerPrefs.SetString(EncryptionManager.GetHashEx(publicKey), EncryptionManager.Encrypt(publicKeyStr));
        }
    }
示例#13
0
        private void LoadFromLocalSettings()
        {
            //Module 13 - Securing Windows 8 App Data
            var travelerIdString = EncryptionManager.Decrypt(_settings.Get(Constants.TravelerId));
            int travelerId;

            int.TryParse(travelerIdString, out travelerId);

            var firstName      = EncryptionManager.Decrypt(_settings.Get(Constants.FirstName));
            var lastName       = EncryptionManager.Decrypt(_settings.Get(Constants.LastName));
            var passportNumber = EncryptionManager.Decrypt(_settings.Get(Constants.Passport));
            var mobileNumber   = EncryptionManager.Decrypt(_settings.Get(Constants.MobilePhone));
            var homeAddress    = EncryptionManager.Decrypt(_settings.Get(Constants.HomeAddress));
            var email          = EncryptionManager.Decrypt(_settings.Get(Constants.Email));

            LoadTravelerInfo(travelerId, firstName, lastName, passportNumber, mobileNumber, homeAddress, email);
        }
示例#14
0
        private void Xml_Reader()
        {
            if (File.Exists("dtSetting.xsd"))
            {
                DataTable dtSetting = new DataTable();
                dtSetting.ReadXmlSchema("dtSetting.xsd");

                dtSetting.ReadXml("dtSetting.xml");


                foreach (DataRow dr in dtSetting.Rows)
                {
                    ConnectionManager.ServerName = dr["Server"].ToString();
                    ConnectionManager.User       = dr["User"].ToString();
                    ConnectionManager.Password   = EncryptionManager.Decrypt(dr["Password"].ToString());
                    ConnectionManager.IsWindowsAuthentication = Convert.ToInt32(dr["IsWindowsAuth"].ToString());
                }
            }
        }
示例#15
0
        public List <CAIs> SearchSOMDataInitial(string connection)
        {
            Log log = new Log();

            log.insertLogGeneral(1, "Consulta de SOM pendientes: Estado Cargue Inicial");

            List <CAIs> listado     = new List <CAIs>();
            string      STATUS_FLOW = "2";

            try
            {
                autosgrsm_SOM dataSom = new autosgrsm_SOM();
                dataSom.cadena      = EncryptionManager.Decrypt(connection);
                dataSom.querySelect = "WHERE STATUS_FLOW = @STATUS_FLOW";
                dicParameter        = new Dictionary <string, string>();
                dicParameter.Add("@STATUS_FLOW", STATUS_FLOW);
                DataTable somDatatable = dataSom.select(dicParameter).Tables[0];

                if (somDatatable.Rows.Count > 0)
                {
                    foreach (DataRow item in somDatatable.Rows)
                    {
                        CAIs cai = new CAIs()
                        {
                            CRMNO = item["CRMNO"].ToString(),
                            CAI   = item["ERROR_DESC"].ToString().Replace("Service", "").Replace("already exists", "").Trim()
                        };

                        listado.Add(cai);
                    }
                }
                else
                {
                    log.insertLogGeneral(1, "No se encontraron datos de SOM pendientes. Proceso finalizado.");
                }
            }
            catch (Exception ex)
            {
                log.insertLogGeneral(4, "Error en la consulta de datos de SOM pendientes: " + ex.Message);
            }

            return(listado);
        }
示例#16
0
        public void getParameters(string connection, string parametro, ref string valorParametro)
        {
            Log log = new Log();

            try
            {
                autosgrsm_Parametros parametros = new autosgrsm_Parametros();
                parametros.cadena      = EncryptionManager.Decrypt(connection);
                parametros.querySelect = "WHERE Nombre_Parametro = @Nombre_Parametro";
                dicParameter           = new Dictionary <string, string>();
                dicParameter.Add("@Nombre_Parametro", parametro);
                DataTable tbParametros = parametros.select(dicParameter).Tables[0];
                valorParametro = tbParametros.Rows[0]["Valor_Parametro"].ToString();
            }
            catch (Exception ex)
            {
                log.insertLogGeneral(4, "No se pueden consultar los parámetros: " + ex.Message);
            }
        }
示例#17
0
        private void Xml_Reader()
        {
            if (File.Exists("dtSetting.xsd"))
            {
                DataTable dtSetting = new DataTable();
                dtSetting.ReadXmlSchema("dtSetting.xsd");

                dtSetting.ReadXml("dtSetting.xml");


                foreach (DataRow dr in dtSetting.Rows)
                {
                    tb_Server.Text = dr["Server"].ToString();

                    radioGroup1.SelectedIndex = Convert.ToInt32(dr["IsWindowsAuth"].ToString());
                    tb_DbUser.Text            = dr["User"].ToString();
                    tb_DbPass.Text            = EncryptionManager.Decrypt(dr["Password"].ToString());
                }
            }
        }
        private string getConnectionStringCurrent()
        {
            string cadena  = "";
            string entorno = System.Configuration.ConfigurationManager.AppSettings["Entorno"].ToString();

            if (entorno == "0")
            {
                cadena = "DB_CONNECTION_DEV";
            }
            else if (entorno == "1")
            {
                cadena = "DB_CONNECTION_TEST";
            }
            else if (entorno == "2")
            {
                cadena = "DB_CONNECTION_PROD";
            }

            cadena = EncryptionManager.Decrypt(ConfigurationManager.ConnectionStrings[cadena].ToString());

            return(cadena);
        }
示例#19
0
        //When trying to decrypt your data, you will need your public key (iv) and optionally a second public key (time in ticks)
        public static string DecryptMySecret(string encryptedData, string iv, long ticks)
        {
            //this is your 64-bit key string
            string myKeyString = AESEncryptor.CreateNewKey();

            string decryptedSecretInfo = null;

            using (var manager = new EncryptionManager(myKeyString))
            {
                //This is how you decrypt with your keyString (private key) and iv (public key)
                decryptedSecretInfo = manager.Decrypt(encryptedData, iv);
            }


            //you can also decrypt with private keys of int a, b and c
            using (var manager = new EncryptionManager(100, 50, 10))
            {
                //This is how you decrypt with your specified keys, iv and ticks
                decryptedSecretInfo = manager.Decrypt(encryptedData, iv, ticks);
            }

            return(decryptedSecretInfo);
        }
示例#20
0
        public ActionResult Login(UserAccount user)
        {
            var usersCollection       = Context.Database.GetCollection <UserAccount>("Users");
            var consultantsCollection = Context.Database.GetCollection <ConsultantsAccount>("Consultants");

            usersQuery = Query <UserAccount> .Where(s => s.UserName == user.UserName);

            consulQuery = Query <ConsultantsAccount> .Where(s => s.UserName == user.UserName);

            var model1 = usersCollection.FindOne(usersQuery);
            var model2 = consultantsCollection.FindOne(consulQuery);

            if (model1 != null)
            {
                var decriptionismodel1 = EncryptionManager.Decrypt((string)model1.Password, c_passwordKey);
                if (user.Password == decriptionismodel1)
                {
                    Session["UserName"] = model1.UserName.ToString();
                    Session["Type"]     = "user";
                    return(RedirectToAction("SearchConsultants"));
                }
            }
            else if (model2 != null)
            {
                var decriptionismodel2 = EncryptionManager.Decrypt((string)model2.Password, c_passwordKey);
                if (user.Password == decriptionismodel2)
                {
                    Session["Type"]     = "consultant";
                    Session["UserName"] = model2.UserName.ToString();
                    return(RedirectToAction("SearchConsultants"));
                }
            }

            TempData["Message"] = "שם משתמש או סיסמא שגויים";
            return(View());
        }
示例#21
0
 public void DecryptTest()
 {
     EncryptionManager.Decrypt("dKPADax8LSyF2XuJaAMt6Q==");
     Assert.Fail();
 }
示例#22
0
        public List <autosgrsm_SOM> consulta()
        {
            List <autosgrsm_SOM> objetoSOM = new List <autosgrsm_SOM>();

            autosgrsm_Parametros parametros = new autosgrsm_Parametros();

            //string a = EncryptionManager.Encrypt(@"Server=10.80.3.147\SQLINSTPROY;Database=E2E_Salvalineas_base_dev;User Id=E2E_Salvalineas_base;Password=7SrD2TA$;");
            parametros.cadena      = EncryptionManager.Decrypt(ConfigurationManager.ConnectionStrings["DB_CONNECTION_" + cadena].ToString());
            parametros.querySelect = "WHERE Nombre_Parametro = @Nombre_Parametro";
            dicParameter           = new Dictionary <string, string>();
            dicParameter.Add("@Nombre_Parametro", "SQL_SELECT_SOM");
            DataTable tbParametros = parametros.select(dicParameter).Tables[0];
            string    consultaSOM  = tbParametros.Rows[0]["Valor_Parametro"].ToString();


            //string oradb = "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.203.109.84)(PORT = 1526))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = somdb)));User Id=SQL_AUTOMAT;Password=Kiweth3ns4sx;Connection Timeout=600;";
            //string oradb = oradb = "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.203.109.84)(PORT = 1526))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = somdb)));User Id=GMOVISTAR;Password=Tele2020*!Gvist#; Connection Timeout=600;";
            //string oradb = oradb = "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.203.109.84)(PORT = 1526))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = somdb)));User Id=SQL_LSANABRIAHO;Password=Tele2020*!Nov#; Connection Timeout=600;";
            //string encriptado = EncryptionManager.Encrypt(oradb);

            string    db_som = EncryptionManager.Decrypt(ConfigurationManager.ConnectionStrings["DB_CONNECTION_SOM_" + cadena].ToString());
            DataTable query  = new DataTable();

            if (entorno == "2")
            {
                using (OracleConnection conn = new OracleConnection(db_som))
                {
                    try
                    {
                        OracleCommand cmd = new OracleCommand();

                        cmd.CommandText = consultaSOM;
                        cmd.Connection  = conn;
                        conn.Open();
                        OracleDataReader queryOracle = cmd.ExecuteReader();

                        query.Load(queryOracle);
                        conn.Close();
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
            }
            else
            {
                query = new DataTable();
                DataColumn column = new DataColumn();
                column.ColumnName = "FLOWID";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "TECNOLOGIA";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "OPERACION_COMERCIAL";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "ESTADO_DE_LA_ORDEN";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "APPOINTMENT_ID";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "FLOWNO";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "ORDERCREATETIME";
                column.DataType   = Type.GetType("System.DateTime");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "WORKCREATETIME";
                column.DataType   = Type.GetType("System.DateTime");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "DATE_ERROR";
                column.DataType   = Type.GetType("System.DateTime");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "FLOWTYPE";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "FLOWTYPEID";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "PROCESSINSTNAME";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "ACTIVITYDEFID";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "ACTIVITYINSTNAME";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "CRMNO";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "CUSTOMNAME";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "PRODUCT";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "OPERATION";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "ACCESSACCOUNT";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "INSTALL_ADDRESS";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "CODIGO_LOCALIDAD";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "ERROR_CODE";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);
                column            = new DataColumn();
                column.ColumnName = "ERROR_DESC";
                column.DataType   = Type.GetType("System.String");
                query.Columns.Add(column);

                for (int i = 0; i < 10; i++)
                {
                    DataRow myNewRow;
                    myNewRow = query.NewRow();

                    myNewRow["FLOWID"]              = "16065051850190100-" + i;
                    myNewRow["TECNOLOGIA"]          = "";
                    myNewRow["OPERACION_COMERCIAL"] = "Posventa";
                    myNewRow["ESTADO_DE_LA_ORDEN"]  = "Executing";
                    myNewRow["APPOINTMENT_ID"]      = "FS202011271424130143";
                    myNewRow["FLOWNO"]              = "4531008";
                    myNewRow["ORDERCREATETIME"]     = "27/11/2020 14:26";
                    myNewRow["WORKCREATETIME"]      = "27/11/2020 14:26";
                    myNewRow["DATE_ERROR"]          = "27/11/2020 14:37";
                    myNewRow["FLOWTYPE"]            = "OM";
                    myNewRow["FLOWTYPEID"]          = "OM";
                    myNewRow["PROCESSINSTNAME"]     = "FMC Process-GOMEZ GOMEZ MORALES DEISY GOMEZ MORALES";
                    myNewRow["ACTIVITYDEFID"]       = "InvokeIM";
                    myNewRow["ACTIVITYINSTNAME"]    = "InvokeIM";
                    myNewRow["CRMNO"]            = "20000474329533";
                    myNewRow["CUSTOMNAME"]       = "GOMEZ GOMEZ MORALES DEISY GOMEZ MORALES";
                    myNewRow["PRODUCT"]          = "Broadband Service+Fixed Line Voice+IPTV+TV";
                    myNewRow["OPERATION"]        = "Keep+Keep+Install+Uninstall";
                    myNewRow["ACCESSACCOUNT"]    = "IPTV:640000181711+DTH:651340443462+LB:82692349+BB:2582692349";
                    myNewRow["INSTALL_ADDRESS"]  = "CL 4 KR 4-54 LA POLA";
                    myNewRow["CODIGO_LOCALIDAD"] = "73001000";
                    myNewRow["ERROR_CODE"]       = "INV-SIGRES-00010001";
                    myNewRow["ERROR_DESC"]       = "Service CIP_00000000000000000000000004531008 already exists";
                    query.Rows.Add(myNewRow);
                }
            }

            if (query.Rows.Count > 0)
            {
                foreach (DataRow item in query.Rows)
                {
                    autosgrsm_SOM itemSom = new autosgrsm_SOM()
                    {
                        FLOWID              = item["FLOWID"].ToString(),
                        TECNOLOGIA          = item["TECNOLOGIA"].ToString(),
                        OPERACION_COMERCIAL = item["OPERACION_COMERCIAL"].ToString(),
                        ESTADO_DE_LA_ORDEN  = item["ESTADO_DE_LA_ORDEN"].ToString(),
                        APPOINTMENT_ID      = item["APPOINTMENT_ID"].ToString(),
                        FLOWNO              = item["FLOWNO"].ToString(),
                        ORDERCREATETIME     = Convert.ToDateTime(item["ORDERCREATETIME"].ToString()),
                        WORKCREATETIME      = Convert.ToDateTime(item["WORKCREATETIME"].ToString()),
                        DATE_ERROR          = Convert.ToDateTime(item["DATE_ERROR"].ToString()),
                        FLOWTYPE            = item["FLOWTYPE"].ToString(),
                        FLOWTYPEID          = item["FLOWTYPEID"].ToString(),
                        PROCESSINSTNAME     = item["PROCESSINSTNAME"].ToString(),
                        ACTIVITYDEFID       = item["ACTIVITYDEFID"].ToString(),
                        ACTIVITYINSTNAME    = item["ACTIVITYINSTNAME"].ToString(),
                        CRMNO            = item["CRMNO"].ToString(),
                        CUSTOMNAME       = item["CUSTOMNAME"].ToString(),
                        PRODUCT          = item["PRODUCT"].ToString(),
                        OPERATION        = item["OPERATION"].ToString(),
                        ACCESSACCOUNT    = item["ACCESSACCOUNT"].ToString(),
                        INSTALL_ADDRESS  = item["INSTALL_ADDRESS"].ToString(),
                        CODIGO_LOCALIDAD = item["CODIGO_LOCALIDAD"].ToString(),
                        ERROR_CODE       = item["ERROR_CODE"].ToString(),
                        ERROR_DESC       = item["ERROR_DESC"].ToString()
                    };

                    objetoSOM.Add(itemSom);
                }
            }
            else
            {
                objetoSOM = new List <autosgrsm_SOM>();
            }

            return(objetoSOM);
        }
示例#23
0
        public void ReadEntity(IDictionary <string, EntityProperty> properties, OperationContext operationContext)
        {
#if RT
            IEnumerable <PropertyInfo> myProperties = entity.GetType().GetRuntimeProperties();
            var classAttributes = System.Attribute.GetCustomAttributes(entity.GetType());
#else
            IEnumerable <PropertyInfo> myProperties = this.GetType().GetProperties();
            var classAttributes = System.Attribute.GetCustomAttributes(this.GetType());
#endif
            EncryptionTicks = properties["EncryptionTicks"]?.Int64Value ?? -1;
            EncryptionKey keyAttribute = (EncryptionKey)classAttributes.FirstOrDefault(x => !((x as EncryptionKey)?.IsDefaultValue ?? true));
            if (keyAttribute == null)
            {
                keyAttribute = (EncryptionKey)classAttributes.First(x => (x as EncryptionKey) != null);
                keyAttribute = keyAttribute ?? new EncryptionKey(24, 8, 3);
            }

            foreach (PropertyInfo property in myProperties)
            {
                // reserved properties
                if (property.Name == "PartitionKey" ||
                    property.Name == "RowKey" ||
                    property.Name == "Timestamp" ||
                    property.Name == "ETag" || property.Name == "EncryptionTicks")
                {
                    continue;
                }

                // Enforce public getter / setter
#if RT
                if (property.SetMethod == null || !property.SetMethod.IsPublic || property.GetMethod == null || !property.GetMethod.IsPublic)
#else
                if (property.GetSetMethod() == null || !property.GetSetMethod().IsPublic || property.GetGetMethod() == null || !property.GetGetMethod().IsPublic)
#endif
                {
                    continue;
                }

                // only proceed with properties that have a corresponding entry in the dictionary
                if (!properties.ContainsKey(property.Name))
                {
                    continue;
                }

                EntityProperty entityProperty = properties[property.Name];



                if (IsPropertyNull(entityProperty))
                {
                    property.SetValue(this, null, null);
                }
                else if (property.GetCustomAttribute(typeof(EncryptedProperty)) is EncryptedProperty encryptedAttribute)
                {
                    object propValue = null;
                    try
                    {
                        if (entityProperty.PropertyType == EdmType.String)
                        {
                            if (keyAttribute.isSingleKey)
                            {
                                using (var manager = new EncryptionManager(keyAttribute.Key))
                                {
                                    propValue = JsonConvert.DeserializeObject(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue), property.PropertyType);
                                }
                            }
                            else
                            {
                                using (var manager = new EncryptionManager(keyAttribute.A, keyAttribute.B, keyAttribute.C))
                                {
                                    propValue = JsonConvert.DeserializeObject(manager.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue, EncryptionTicks), property.PropertyType);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                    }

                    if (propValue != null)
                    {
                        property.SetValue(this, propValue, null);
                    }

                    else
                    {
                        switch (entityProperty.PropertyType)
                        {
                        case EdmType.String:
                            if (property.PropertyType != typeof(string) && property.PropertyType != typeof(String))
                            {
                                continue;
                            }
                            var propertyValue = AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue);
                            property.SetValue(this, propertyValue, null);
                            break;

                        case EdmType.Binary:
                            if (property.PropertyType != typeof(byte[]))
                            {
                                continue;
                            }

                            var binaryValue = JsonConvert.DeserializeObject <byte[]>(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue));
                            property.SetValue(this, binaryValue, null);
                            break;

                        case EdmType.Boolean:
                            if (property.PropertyType != typeof(bool) && property.PropertyType != typeof(Boolean) && property.PropertyType != typeof(Boolean?) && property.PropertyType != typeof(bool?))
                            {
                                continue;
                            }

                            property.SetValue(this, entityProperty.BooleanValue, null);
                            break;

                        case EdmType.DateTime:
                            if (property.PropertyType == typeof(DateTimeOffset))
                            {
                                var dateValue = JsonConvert.DeserializeObject <DateTimeOffset>(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue));
                                property.SetValue(this, dateValue.UtcDateTime, null);
                            }
                            else if (property.PropertyType == typeof(DateTimeOffset))
                            {
                                var dateValue = JsonConvert.DeserializeObject <DateTime>(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue));
                                property.SetValue(this, dateValue.ToUniversalTime(), null);
                            }


                            break;

                        case EdmType.Double:
                            if (property.PropertyType != typeof(double) && property.PropertyType != typeof(Double) && property.PropertyType != typeof(Double?) && property.PropertyType != typeof(double?))
                            {
                                continue;
                            }

                            var doubleValue = JsonConvert.DeserializeObject <double>(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue));
                            property.SetValue(this, doubleValue, null);
                            break;

                        case EdmType.Guid:
                            if (property.PropertyType != typeof(Guid) && property.PropertyType != typeof(Guid?))
                            {
                                continue;
                            }

                            var guidValue = JsonConvert.DeserializeObject <Guid>(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue));
                            property.SetValue(this, guidValue, null);
                            break;

                        case EdmType.Int32:
                            if (property.PropertyType != typeof(int) && property.PropertyType != typeof(Int32) && property.PropertyType != typeof(Int32?) && property.PropertyType != typeof(int?))
                            {
                                continue;
                            }

                            var intValue = JsonConvert.DeserializeObject <int>(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue));
                            property.SetValue(this, intValue, null);
                            break;

                        case EdmType.Int64:
                            if (property.PropertyType != typeof(long) && property.PropertyType != typeof(Int64) && property.PropertyType != typeof(long?) && property.PropertyType != typeof(Int64?))
                            {
                                continue;
                            }
                            var intValue2 = JsonConvert.DeserializeObject <int>(AESEncryptor.Decrypt(entityProperty.StringValue, properties[property.Name + "IV"].StringValue));
                            property.SetValue(this, intValue2, null);
                            break;
                        }
                    }
                }
                else
                {
                    switch (entityProperty.PropertyType)
                    {
                    case EdmType.String:
                        if (property.PropertyType != typeof(string) && property.PropertyType != typeof(String))
                        {
                            continue;
                        }

                        property.SetValue(this, entityProperty.StringValue, null);
                        break;

                    case EdmType.Binary:
                        if (property.PropertyType != typeof(byte[]))
                        {
                            continue;
                        }

                        property.SetValue(this, entityProperty.BinaryValue, null);
                        break;

                    case EdmType.Boolean:
                        if (property.PropertyType != typeof(bool) && property.PropertyType != typeof(Boolean) && property.PropertyType != typeof(Boolean?) && property.PropertyType != typeof(bool?))
                        {
                            continue;
                        }

                        property.SetValue(this, entityProperty.BooleanValue, null);
                        break;

                    case EdmType.DateTime:
                        if (property.PropertyType == typeof(DateTime))
                        {
                            property.SetValue(this, entityProperty.DateTimeOffsetValue.Value.UtcDateTime, null);
                        }
                        else if (property.PropertyType == typeof(DateTime?))
                        {
                            property.SetValue(this, entityProperty.DateTimeOffsetValue.HasValue ? entityProperty.DateTimeOffsetValue.Value.UtcDateTime : (DateTime?)null, null);
                        }
                        else if (property.PropertyType == typeof(DateTimeOffset))
                        {
                            property.SetValue(this, entityProperty.DateTimeOffsetValue.Value, null);
                        }
                        else if (property.PropertyType == typeof(DateTimeOffset?))
                        {
                            property.SetValue(this, entityProperty.DateTimeOffsetValue, null);
                        }

                        break;

                    case EdmType.Double:
                        if (property.PropertyType != typeof(double) && property.PropertyType != typeof(Double) && property.PropertyType != typeof(Double?) && property.PropertyType != typeof(double?))
                        {
                            continue;
                        }

                        property.SetValue(this, entityProperty.DoubleValue, null);
                        break;

                    case EdmType.Guid:
                        if (property.PropertyType != typeof(Guid) && property.PropertyType != typeof(Guid?))
                        {
                            continue;
                        }

                        property.SetValue(this, entityProperty.GuidValue, null);
                        break;

                    case EdmType.Int32:
                        if (property.PropertyType != typeof(int) && property.PropertyType != typeof(Int32) && property.PropertyType != typeof(Int32?) && property.PropertyType != typeof(int?))
                        {
                            continue;
                        }

                        property.SetValue(this, entityProperty.Int32Value, null);
                        break;

                    case EdmType.Int64:
                        if (property.PropertyType != typeof(long) && property.PropertyType != typeof(Int64) && property.PropertyType != typeof(long?) && property.PropertyType != typeof(Int64?))
                        {
                            continue;
                        }

                        property.SetValue(this, entityProperty.Int64Value, null);
                        break;
                    }
                }
            }
        }
示例#24
0
        private byte[] BuildPdf()
        {
            reportXLAT = SQMBasePage.SelectXLATList(new string[5] {
                "HS_5PHASE", "TRUEFALSE", "SHIFT", "INJURY_TENURE", "INJURY_CAUSE"
            }, 1);

            AlertData pageData;

            baseApplicationUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/");

            if (Request.QueryString["iid"] != null)
            {
                string query = Request.QueryString["iid"];
                query = query.Replace(" ", "+");
                string iid = EncryptionManager.Decrypt(query);
                pageData = PopulateByIncidentId(Convert.ToDecimal(iid));
            }
            else
            {
                return(null);
            }

            string customerLogo = "";

            if (System.Configuration.ConfigurationManager.AppSettings["CustomerLogoLarge"] != null)
            {
                customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogoLarge"].ToString();
            }
            if (string.IsNullOrEmpty(customerLogo))
            {
                if (System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"] != null)
                {
                    customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"].ToString();
                }
            }
            if (string.IsNullOrEmpty(customerLogo))
            {
                customerLogo = "MetricsoftLogo.png";
            }

            string logoUrl = baseApplicationUrl + "images/company/" + customerLogo;

            BaseColor darkGrayColor  = new BaseColor(0.25f, 0.25f, 0.25f);
            BaseColor lightGrayColor = new BaseColor(0.5f, 0.5f, 0.5f);
            BaseColor whiteColor     = new BaseColor(1.0f, 1.0f, 1.0f);
            BaseColor blackColor     = new BaseColor(0.0f, 0.0f, 0.0f);

            Font textFont       = GetTextFont();
            Font headerFont     = GetHeaderFont();
            Font labelFont      = GetLabelFont();
            Font colHeaderFont  = GetTextFont();
            Font textItalicFont = GetTextFont();

            detailHdrFont       = new Font(headerFont.BaseFont, 13, 0, lightGrayColor);
            detailTxtFont       = new Font(textFont.BaseFont, 10, 0, blackColor);
            labelTxtFont        = new Font(labelFont.BaseFont, 12, 0, blackColor);
            colHdrFont          = new Font(colHeaderFont.BaseFont, 10, iTextSharp.text.Font.UNDERLINE, blackColor);
            detailTxtItalicFont = new Font(colHeaderFont.BaseFont, 10, iTextSharp.text.Font.ITALIC, blackColor);
            detailTxtBoldFont   = new Font(colHeaderFont.BaseFont, 10, iTextSharp.text.Font.BOLD, blackColor);

            // Create new PDF document
            Document document = new Document(PageSize.A4, 35f, 35f, 35f, 35f);

            using (MemoryStream output = new MemoryStream())
            {
                PdfWriter.GetInstance(document, output);

                try
                {
                    document.Open();

                    //
                    // Table 1 - Header
                    //

                    var table1 = new PdfPTable(new float[] { 162f, 378f });
                    table1.TotalWidth         = 540f;
                    table1.LockedWidth        = true;
                    table1.DefaultCell.Border = 0;
                    table1.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                    table1.DefaultCell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                    table1.SpacingAfter = 10f;

                    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(logoUrl);
                    img.ScaleToFit(102f, 51f);
                    var imgCell = new PdfPCell()
                    {
                        Border = 0
                    };
                    imgCell.AddElement(img);
                    table1.AddCell(imgCell);

                    var hdrFont = new Font(headerFont.BaseFont, 24, 0, darkGrayColor);
                    table1.AddCell(new PdfPCell(new Phrase(SQMBasePage.GetXLAT(reportXLAT, "HS_5PHASE", "TITLE").DESCRIPTION, hdrFont))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT,
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        Border = 0
                    });


                    //
                    // Table 4 - Photos
                    //

                    var table4 = new PdfPTable(new float[] { 540f, });                     //new PdfPTable(new float[] { 180f, 180f, 180f });
                    table4.TotalWidth  = 540f;
                    table4.LockedWidth = true;

                    try
                    {
                        if (pageData.photoData != null && pageData.photoData.Count() > 0)
                        {
                            table4.AddCell(new PdfPCell(new Phrase("Photos", detailHdrFont))
                            {
                                Padding = 5f, Border = 0, Colspan = 3
                            });
                            table4.SpacingBefore = 5f;
                            var captionFont = new Font(textFont.BaseFont, 11, 0, darkGrayColor);

                            int i = 0;
                            for (i = 0; i < pageData.photoData.Count; i++)
                            {
                                var photoCell = new PdfPCell()
                                {
                                    PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                                };

                                iTextSharp.text.Image photo = iTextSharp.text.Image.GetInstance(pageData.photoData[i]);
                                //photo.ScaleToFit(176f, 132f);
                                //photo.ScaleToFit(264f, 198f);
                                photoCell.AddElement(photo);

                                photoCell.AddElement(new Phrase(pageData.photoCaptions[i], captionFont));

                                table4.AddCell(photoCell);
                            }
                            // pad remaining cells in row or else table will be corrupt
                            int currentCol = i % 3;
                            for (int j = 0; j < 3 - currentCol; j++)
                            {
                                table4.AddCell(new PdfPCell()
                                {
                                    PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                                });
                            }
                        }
                    }
                    catch { }

                    document.Add(table1);
                    document.Add(IDSection(pageData));
                    document.Add(HeaderSection(pageData));
                    document.Add(IncidentSection(pageData));
                    document.Add(ContainmentSection(pageData));
                    document.Add(CauseSection(pageData));
                    document.Add(ActionSection(pageData));
                    document.Add(ReviewSection(pageData));
                    document.Add(table4);

                    document.Close();
                }
                catch
                {
                }

                return(output.ToArray());
            }
        }
 public void DecryptReturnsClearValue()
 {
     EncryptionManager
     .Decrypt(Arg.Any <string>(), Arg.Any <byte[]>(), Arg.Any <byte[]>(), Arg.Any <byte[]>())
     .Returns(BaseSecretStore.SecretEncoding.GetBytes(clearSecret.Value));
 }
示例#26
0
        private byte[] BuildPdf()
        {
            AlertData pageData;

            baseApplicationUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/");

            if (Request.QueryString["pcid"] != null)
            {
                string query = Request.QueryString["pcid"];
                query = query.Replace(" ", "+");
                string pcid = EncryptionManager.Decrypt(query);
                pageData = PopulateByProblemCaseId(Convert.ToDecimal(pcid));
            }
            else if (Request.QueryString["iid"] != null)
            {
                string query = Request.QueryString["iid"];
                query = query.Replace(" ", "+");
                string iid = EncryptionManager.Decrypt(query);
                pageData = PopulateByIncidentId(Convert.ToDecimal(iid));
            }
            else
            {
                pageData = PopulateAlertDataTest();
            }

            string customerLogo = "";

            customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogoLarge"].ToString();
            if (string.IsNullOrEmpty(customerLogo))
            {
                customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"].ToString();
            }
            if (string.IsNullOrEmpty(customerLogo))
            {
                customerLogo = "MetricsoftLogo.png";
            }

            string logoUrl = baseApplicationUrl + "images/company/" + customerLogo;

            Font textFont   = GetTextFont();
            Font headerFont = GetHeaderFont();

            BaseColor darkGrayColor  = new BaseColor(0.25f, 0.25f, 0.25f);
            BaseColor lightGrayColor = new BaseColor(0.5f, 0.5f, 0.5f);
            BaseColor whiteColor     = new BaseColor(1.0f, 1.0f, 1.0f);
            BaseColor blackColor     = new BaseColor(0.0f, 0.0f, 0.0f);

            // Create new PDF document
            Document document = new Document(PageSize.A4, 35f, 35f, 35f, 35f);

            using (MemoryStream output = new MemoryStream())
            {
                PdfWriter.GetInstance(document, output);

                document.Open();

                //
                // Table 1 - Header
                //

                var table1 = new PdfPTable(new float[] { 162f, 378f });
                table1.TotalWidth         = 540f;
                table1.LockedWidth        = true;
                table1.DefaultCell.Border = 0;
                table1.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                table1.DefaultCell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                table1.SpacingAfter = 12f;

                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(logoUrl);
                img.ScaleToFit(162f, 81f);
                var imgCell = new PdfPCell()
                {
                    Border = 0
                };
                imgCell.AddElement(img);
                table1.AddCell(imgCell);

                var hdrFont = new Font(headerFont.BaseFont, 38, 0, darkGrayColor);
                table1.AddCell(new PdfPCell(new Phrase("EH&S INCIDENT ALERT", hdrFont))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    VerticalAlignment   = Element.ALIGN_MIDDLE,
                    Border = 0
                });


                //
                // Table 2 - Information block
                //

                var infoFont = new Font(headerFont.BaseFont, 14, 0, whiteColor);

                var table2 = new PdfPTable(new float[] { 240f, 300f });
                table2.TotalWidth   = 540f;
                table2.LockedWidth  = true;
                table2.SpacingAfter = 12f;

                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentDateTime, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, Border = 0
                });
                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentNumber, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, HorizontalAlignment = Element.ALIGN_RIGHT, Border = 0
                });
                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentLocation, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, PaddingTop = 0, Border = 0
                });
                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentType, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, PaddingTop = 0, HorizontalAlignment = Element.ALIGN_RIGHT, Border = 0
                });
                table2.Complete = true;

                //
                // Table 3 - Description and details
                //

                var detailHdrFont = new Font(headerFont.BaseFont, 14, 0, lightGrayColor);
                var detailTxtFont = new Font(textFont.BaseFont, 12, 0, blackColor);

                var table3 = new PdfPTable(new float[] { 135f, 405f });
                table3.TotalWidth  = 540f;
                table3.LockedWidth = true;
                table3.DefaultCell.SetLeading(40f, 40f);
                table3.SpacingAfter = 12f;
                PdfPCell cell;

                cell = new PdfPCell(new Paragraph("DESCRIPTION", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Phrase(pageData.incidentDescription, detailTxtFont))
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Paragraph("ROOT CAUSE", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                foreach (var lineItem in pageData.incidentRootCause)
                {
                    cell.AddElement(new Paragraph(lineItem, detailTxtFont));
                }
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Paragraph("CONTAINMENT", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                foreach (var lineItem in pageData.incidentContainment)
                {
                    cell.AddElement(new Paragraph(lineItem, detailTxtFont));
                }
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Paragraph("CORRECTIVE ACTIONS", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                foreach (var lineItem in pageData.incidentCorrectiveActions)
                {
                    cell.AddElement(new Paragraph(lineItem, detailTxtFont));
                }
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);


                //
                // Table 4 - Photos
                //

                var table4 = new PdfPTable(new float[] { 180f, 180f, 180f });
                table4.TotalWidth  = 540f;
                table4.LockedWidth = true;

                if (pageData.photoData != null && pageData.photoData.Count() > 0)
                {
                    table4.AddCell(new PdfPCell(new Phrase("Photos", infoFont))
                    {
                        BackgroundColor = darkGrayColor, Padding = 10f, Border = 0, Colspan = 3
                    });

                    var captionFont = new Font(textFont.BaseFont, 11, 0, darkGrayColor);

                    int i = 0;
                    for (i = 0; i < pageData.photoData.Count; i++)
                    {
                        var photoCell = new PdfPCell()
                        {
                            PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                        };

                        iTextSharp.text.Image photo = iTextSharp.text.Image.GetInstance(pageData.photoData[i]);
                        photo.ScaleToFit(176f, 132f);
                        photoCell.AddElement(photo);

                        photoCell.AddElement(new Phrase(pageData.photoCaptions[i], captionFont));

                        table4.AddCell(photoCell);
                    }
                    // pad remaining cells in row or else table will be corrupt
                    int currentCol = i % 3;
                    for (int j = 0; j < 3 - currentCol; j++)
                    {
                        table4.AddCell(new PdfPCell()
                        {
                            PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                        });
                    }
                }

                document.Add(table1);
                document.Add(table2);
                document.Add(table3);
                document.Add(table4);

                document.Close();

                return(output.ToArray());
            }
        }
        private byte[] BuildPdf()
        {
            reportXLAT = SQMBasePage.SelectXLATList(new string[5] {
                "HS_ALERT", "TRUEFALSE", "SHIFT", "INJURY_TENURE", "INJURY_CAUSE"
            }, 1);

            AlertData pageData = new AlertData()
            {
                incidentDate        = "N/A",
                incidentTime        = "N/A",
                incidentLocation    = "N/A",
                locationNLS         = "en",
                incidentDept        = "N/A",
                incidentNumber      = "N/A",
                incidentType        = "N/A",
                incidentDescription = "N/A",
                detectPerson        = null,
                involvedPerson      = null,
                supervisorPerson    = null,
                incident            = null,
                answerList          = new List <INCIDENT_ANSWER>(),
                containList         = new List <INCFORM_CONTAIN>(),
                root5YList          = new List <INCFORM_ROOT5Y>(),
                causation           = null,
                actionList          = new List <TASK_STATUS>(),
                approvalList        = new List <EHSIncidentApproval>()
            };

            baseApplicationUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/");

            if (Request.QueryString["iid"] != null)
            {
                string query = Request.QueryString["iid"];
                query = query.Replace(" ", "+");
                iid   = EncryptionManager.Decrypt(query);

                if (Request.QueryString["opt"] != null)
                {
                    exportOption = Request.QueryString["opt"];
                }

                pageData = PopulateByIncidentId(Convert.ToDecimal(iid));
            }
            else
            {
                return(null);
            }

            string customerLogo = "";

            if (System.Configuration.ConfigurationManager.AppSettings["CustomerLogoLarge"] != null)
            {
                customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogoLarge"].ToString();
            }
            if (string.IsNullOrEmpty(customerLogo))
            {
                if (System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"] != null)
                {
                    customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"].ToString();
                }
            }
            if (string.IsNullOrEmpty(customerLogo))
            {
                customerLogo = "MetricsoftLogo.png";
            }

            string logoUrl = baseApplicationUrl + "images/company/" + customerLogo;

            BaseColor darkGrayColor  = new BaseColor(0.25f, 0.25f, 0.25f);
            BaseColor lightGrayColor = new BaseColor(0.5f, 0.5f, 0.5f);
            BaseColor whiteColor     = new BaseColor(1.0f, 1.0f, 1.0f);
            BaseColor blackColor     = new BaseColor(0.0f, 0.0f, 0.0f);

            iTextSharp.text.Font textFont       = GetTextFont();
            iTextSharp.text.Font headerFont     = GetHeaderFont();
            iTextSharp.text.Font labelFont      = GetLabelFont();
            iTextSharp.text.Font colHeaderFont  = GetTextFont();
            iTextSharp.text.Font textItalicFont = GetTextFont();

            // Chinese text font
            iTextSharp.text.Font textFontZH = GetZHFont();

            detailHdrFont = new iTextSharp.text.Font(headerFont.BaseFont, 13, 0, lightGrayColor);
            detailLblFont = new iTextSharp.text.Font(textFont.BaseFont, 10, 0, blackColor);
            labelTxtFont  = new iTextSharp.text.Font(labelFont.BaseFont, 12, 0, blackColor);
            colHdrFont    = new iTextSharp.text.Font(colHeaderFont.BaseFont, 10, iTextSharp.text.Font.UNDERLINE, blackColor);

            detailTxtBoldFont = new iTextSharp.text.Font(colHeaderFont.BaseFont, 10, iTextSharp.text.Font.BOLD, blackColor);

            switch (pageData.locationNLS)
            {
            case "zh":
                detailTxtFont       = new iTextSharp.text.Font(textFontZH.BaseFont, 10, 0, blackColor);
                detailTxtItalicFont = new iTextSharp.text.Font(textFontZH.BaseFont, 10, iTextSharp.text.Font.ITALIC, blackColor);
                break;

            default:
                detailTxtFont       = new iTextSharp.text.Font(textFont.BaseFont, 10, 0, blackColor);
                detailTxtItalicFont = new iTextSharp.text.Font(colHeaderFont.BaseFont, 10, iTextSharp.text.Font.ITALIC, blackColor);
                break;
            }

            // Create new PDF document
            Document document = new Document(PageSize.A4, 35f, 35f, 35f, 35f);

            using (MemoryStream output = new MemoryStream())
            {
                PdfWriter.GetInstance(document, output);

                try
                {
                    document.Open();

                    //
                    // Table 1 - Header
                    //

                    var table1 = new PdfPTable(new float[] { 162f, 378f });
                    table1.TotalWidth         = 540f;
                    table1.LockedWidth        = true;
                    table1.DefaultCell.Border = 0;
                    table1.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                    table1.DefaultCell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                    table1.SpacingAfter = 10f;

                    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(logoUrl);
                    img.ScaleToFit(102f, 51f);
                    var imgCell = new PdfPCell()
                    {
                        Border = 0
                    };
                    imgCell.AddElement(img);
                    table1.AddCell(imgCell);

                    var hdrFont = new iTextSharp.text.Font(headerFont.BaseFont, 24, 0, darkGrayColor);
                    table1.AddCell(new PdfPCell(new Phrase(SQMBasePage.GetXLAT(reportXLAT, "HS_ALERT", "TITLE").DESCRIPTION, hdrFont))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT,
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        Border = 0
                    });


                    // export to Excel
                    if (exportOption == "xls")
                    {
                        exportList = new List <ReportCell>();
                        exportRow  = 1;
                        exportList.Add(new ReportCell()
                        {
                            Row = 1, Col = 1, Text = SQMBasePage.GetXLAT(reportXLAT, "HS_ALERT", "TITLE").DESCRIPTION
                        });
                    }

                    document.Add(table1);
                    document.Add(IDSection(pageData));
                    document.Add(HeaderSection(pageData));
                    document.Add(IncidentSection(pageData));
                    document.Add(ContainmentSection(pageData));
                    document.Add(CauseSection(pageData));
                    document.Add(ActionSection(pageData));

                    //
                    // Table 4 - Photos
                    //
                    var table4 = new PdfPTable(new float[] { 220f, 220f });
                    table4.TotalWidth    = 540f;
                    table4.LockedWidth   = true;
                    table4.SpacingBefore = 15f;

                    try
                    {
                        if (pageData.photoData != null && pageData.photoData.Count() > 0)
                        {
                            PdfPCell cell = new PdfPCell(new Phrase("Photos", detailHdrFont))
                            {
                                Padding = 5f, Border = 0, Colspan = 2
                            };
                            cell.BorderWidthTop = .25f;
                            table4.AddCell(cell);
                            table4.SpacingBefore = 5f;
                            var captionFont = new iTextSharp.text.Font(textFont.BaseFont, 11, 0, darkGrayColor);

                            if (exportOption == "xls")
                            {
                                exportList.Add(new ReportCell()
                                {
                                    Row = ++exportRow, Col = 1, Text = ""
                                });
                                exportList.Add(new ReportCell()
                                {
                                    Row = ++exportRow, Col = 1, Text = "Photos"
                                });
                            }

                            int i = 0;
                            for (i = 0; i < pageData.photoData.Count; i++)
                            {
                                var photoCell = new PdfPCell()
                                {
                                    PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                                };

                                iTextSharp.text.Image photo = iTextSharp.text.Image.GetInstance(pageData.photoData[i]);
                                photo.ScaleToFit(176f, 132f);
                                //photo.ScaleToFit(264f, 198f);
                                photoCell.AddElement(photo);

                                photoCell.AddElement(new Phrase(pageData.photoCaptions[i], captionFont));
                                table4.AddCell(photoCell);

                                if (exportOption == "xls")
                                {
                                    MemoryStream ms = new MemoryStream(pageData.photoData[i]);
                                    exportList.Add(new ReportCell()
                                    {
                                        Row = ++exportRow, Col = 1, Type = "img", Text = pageData.photoCaptions[i], Obj = ms
                                    });
                                }
                            }
                            // pad remaining cells in row or else table will be corrupt
                            int currentCol = i % 3;
                            for (int j = 0; j < 3 - currentCol; j++)
                            {
                                table4.AddCell(new PdfPCell()
                                {
                                    PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                                });
                            }
                        }
                    }
                    catch { }

                    document.Add(table4);

                    document.Close();
                }
                catch
                {
                }

                return(output.ToArray());
            }
        }
 public string Decrypt(string encryptedContent, string salt)
 {
     return(EncryptionManager.Decrypt(encryptedContent, salt));
 }
示例#29
0
        public void loadSOMData(string connection, string consultaApi)
        {
            Log log = new Log();
            List <autosgrsm_SOM> jsonSOM = null;

            if (consultaApi != "")
            {
                var request = (HttpWebRequest)WebRequest.Create(consultaApi);
                request.Method      = "GET";
                request.ContentType = "application/json";
                request.Accept      = "application/json";

                try
                {
                    using (WebResponse response = request.GetResponse())
                    {
                        using (Stream strReader = response.GetResponseStream())
                        {
                            if (strReader == null)
                            {
                                return;
                            }
                            using (StreamReader objReader = new StreamReader(strReader))
                            {
                                string json             = objReader.ReadToEnd();
                                JavaScriptSerializer js = new JavaScriptSerializer();
                                jsonSOM = js.Deserialize <List <autosgrsm_SOM> >(json);
                            }
                        }
                    }
                }
                catch (WebException ex)
                {
                    log.insertLogGeneral(3, "Falló Api SOM: " + ex.Message);
                }

                if (jsonSOM.Count > 0)
                {
                    try
                    {
                        foreach (autosgrsm_SOM item in jsonSOM)
                        {
                            item.cadena      = EncryptionManager.Decrypt(connection);
                            item.CREATED     = DateTime.Now;
                            item.STATUS_FLOW = 2;
                            item.insert();

                            log.insertLog(item.CRMNO, item.STATUS_FLOW, "Cargue Tabla SOM");
                        }
                    }
                    catch (Exception ex)
                    {
                        log.insertLogGeneral(4, "Falló Inserción en tabla SOM: " + ex.Message);
                    }
                }
                else
                {
                    log.insertLogGeneral(1, "La consulta SOM no trajo resultados");
                    Console.WriteLine("La consulta SOM no trajo resultados");
                }
            }
        }
示例#30
0
        public void loadSIGRESData(string connection, string consultaApi, CAIs CAI)
        {
            Log log = new Log();
            List <autosgrsm_SIGRES> jsonSigres = null;

            if (consultaApi != "")
            {
                var request = (HttpWebRequest)WebRequest.Create(consultaApi + CAI.CAI);
                request.Method      = "GET";
                request.ContentType = "application/json";
                request.Accept      = "application/json";

                try
                {
                    using (WebResponse response = request.GetResponse())
                    {
                        using (Stream strReader = response.GetResponseStream())
                        {
                            if (strReader == null)
                            {
                                return;
                            }
                            using (StreamReader objReader = new StreamReader(strReader))
                            {
                                string json             = objReader.ReadToEnd();
                                JavaScriptSerializer js = new JavaScriptSerializer();
                                jsonSigres = js.Deserialize <List <autosgrsm_SIGRES> >(json);
                            }
                        }
                    }
                }
                catch (WebException ex)
                {
                    log.insertLogGeneral(3, "Falló Api Sigres: " + ex.Message);
                }

                if (jsonSigres.Count > 0)
                {
                    try
                    {
                        foreach (autosgrsm_SIGRES item in jsonSigres)
                        {
                            autosgrsm_SOM som = getSomDataByCRMNO(connection, CAI.CRMNO);
                            som.cadena      = EncryptionManager.Decrypt(connection);
                            som.STATUS_CAI  = item.ESTADO;
                            som.STATUS_FLOW = 5;
                            som.queryUpdate = "WHERE CRMNO = @CRMNO";
                            dicParameter    = new Dictionary <string, string>();
                            dicParameter.Add("@CRMNO", CAI.CRMNO);
                            som.update(dicParameter);

                            log.insertLog(CAI.CRMNO, som.STATUS_FLOW, "Actualización del Estado CAI");
                        }
                    }
                    catch (Exception ex)
                    {
                        log.insertLogGeneral(4, "Falló Actualziación en tabla SOM (Estado CAI): " + ex.Message);
                    }
                }
                else
                {
                    log.insertLog(CAI.CRMNO, 3, "No se encontró data para el CAI: " + CAI.CAI);
                    Console.WriteLine("No se encontró data para el CAI: " + CAI.CAI);
                }
            }
        }