예제 #1
0
        public ActionResult EditarTemplate(TemplateViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Campanhas = new SelectList(camApp.GetAllItens(idAss), "CAMP_CD_ID", "CAMP_NM_NOME");
            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    USUARIO  usuarioLogado = (USUARIO)Session["UserCredentials"];
                    TEMPLATE item          = Mapper.Map <TemplateViewModel, TEMPLATE>(vm);
                    Int32    volta         = baseApp.ValidateEdit(item, objetoAntes, usuarioLogado, idAss);

                    // Sucesso
                    listaMaster = new List <TEMPLATE>();
                    Session["ListaTemplate"] = null;
                    Session["MensTemplate"]  = 0;
                    return(RedirectToAction("MontarTelaTemplate"));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View(vm));
                }
            }
            else
            {
                return(View(vm));
            }
        }
예제 #2
0
        private static (string templateStr, bool oldTemplate) CmdJSONString(string pluginUUID, string miningLocation, string username, params string[] uuids)
        {
            var templatePath          = CmdConfig.CommandFileTemplatePath(pluginUUID);
            var miningServiceLocation = GetServiceLocation(miningLocation);
            var str = CmdConfig.CreateCommandFileWithTemplate(miningServiceLocation, username, uuids, templatePath);

            if (str != null)
            {
                return(str, false);
            }
            const string DEVICE         = @"		{""id"":3,""method"":""worker.add"",""params"":[""daggerhashimoto"",""_DEV_ID_""]}";
            const string TEMPLATE       = @"
[
	{""time"":0,""commands"":[
		{""id"":1,""method"":""subscribe"",""params"":[""_MINING_SERVICE_LOCATION_"",""_PUT_YOUR_BTC_HERE_""]}
	]},
	{""time"":1,""commands"":[
        {""id"":1,""method"":""algorithm.add"",""params"":[""daggerhashimoto""]}
    ]},
	{""time"":2,""commands"":[
_DEVICES_
	]}
]";
            var          devices        = string.Join(",\n", uuids.Select(uuid => DEVICE.Replace("_DEV_ID_", uuid)));
            var          oldTemplateStr = TEMPLATE
                                          .Replace("_MINING_SERVICE_LOCATION_", miningServiceLocation)
                                          .Replace("_PUT_YOUR_BTC_HERE_", username)
                                          .Replace("_DEVICES_", devices);

            return(oldTemplateStr, true);
        }
        public TEMPLATE ConvertToTemplate(string cabinetID)
        {
            var template = new TEMPLATE();

            template.TEMPLATENAME = this.TemplateName;
            template.IDXCNT       = (short)this.TemplateDefinitions.Count();
            if (cabinetID != null && cabinetID.Length > 0)
            {
                template.TEMPLATENAME = cabinetID + "template";
            }
            template.TemplateDefinitions = new List <TEMPLATE_DEFINITION>();
            this.TemplateDefinitions.ToList().ForEach(t =>
            {
                template.TemplateDefinitions.Add(new TEMPLATE_DEFINITION()
                {
                    INDEXNUM      = t.INDEXNUM,
                    INDEXNAME     = t.INDEXNAME,
                    DATATYPE      = t.DATATYPE,
                    BARCODETYPE   = t.BARCODETYPE,
                    HIDECOLUMN    = t.HIDECOLUMN,
                    MAXLENGTH     = t.MAXLENGTH,
                    MUSTFILL      = t.MUSTFILL,
                    MUSTENTER     = t.MUSTENTER,
                    LINKEDFIELDID = t.LINKEDFIELDID,
                    LOOKUP        = t.LOOKUP,
                    OCRACTIVE     = t.OCRACTIVE,
                    SEARCHINDEX   = t.SEARCHINDEX,
                    TEMPLATENAME  = this.TemplateName
                });
            });

            return(template);
        }
예제 #4
0
        public ActionResult ExcluirTemplate(TemplateViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            try
            {
                // Executa a operação
                USUARIO  usuarioLogado = (USUARIO)Session["UserCredentials"];
                TEMPLATE item          = Mapper.Map <TemplateViewModel, TEMPLATE>(vm);
                Int32    volta         = baseApp.ValidateDelete(item, usuarioLogado, idAss);

                // Verifica retorno
                if (volta == 1)
                {
                    Session["MensTemplate"] = 2;
                    ModelState.AddModelError("", SMS_Resource.ResourceManager.GetString("M0036", CultureInfo.CurrentCulture));
                    return(View(vm));
                }

                // Sucesso
                listaMaster = new List <TEMPLATE>();
                Session["ListaTemplate"] = null;
                Session["MensTemplate"]  = 0;
                return(RedirectToAction("MontarTelaTemplate"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(View(vm));
            }
        }
        public ActionResult FiltrarTemplate(TEMPLATE item)
        {
            try
            {
                // Executa a operação
                if ((String)Session["Ativa"] == null)
                {
                    return(RedirectToAction("Login", "ControleAcesso"));
                }
                List <TEMPLATE> listaObj = new List <TEMPLATE>();
                Int32           idAss    = (Int32)Session["IdAssinante"];
                Int32           volta    = baseApp.ExecuteFilter(item.TEMP_NM_NOME, item.TEMP_TX_CORPO, item.TEMP_SG_SIGLA, idAss, out listaObj);

                // Verifica retorno
                if (volta == 1)
                {
                    Session["MensTemplate"] = 1;
                    ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
                    return(RedirectToAction("MontarTelaTemplate"));
                }

                // Sucesso
                Session["MensTemplate"]  = 0;
                listaMaster              = listaObj;
                Session["ListaTemplate"] = listaObj;
                return(RedirectToAction("MontarTelaTemplate"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(RedirectToAction("MontarTelaTemplate"));
            }
        }
        public ActionResult ReativarTemplate(TemplateViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            try
            {
                // Executa a operação
                USUARIO  usuarioLogado = (USUARIO)Session["UserCredentials"];
                TEMPLATE item          = Mapper.Map <TemplateViewModel, TEMPLATE>(vm);
                Int32    volta         = baseApp.ValidateReativar(item, usuarioLogado);

                // Sucesso
                listaMaster = new List <TEMPLATE>();
                Session["ListaTemplate"] = null;
                Session["MensTemplate"]  = 0;
                return(RedirectToAction("MontarTelaTemplate"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(View(vm));
            }
        }
예제 #7
0
        private static string CmdJSONString(string miningLocation, string username, params string[] uuids)
        {
            const string DEVICE   = @"		{""id"":3,""method"":""worker.add"",""params"":[""daggerhashimoto"",""_DEV_ID_""]}";
            const string TEMPLATE = @"
[
	{""time"":0,""commands"":[
		{""id"":1,""method"":""subscribe"",""params"":[""nhmp._MINING_LOCATION_.nicehash.com:3200"",""_PUT_YOUR_BTC_HERE_""]}
	]},
	{""time"":1,""commands"":[
        {""id"":1,""method"":""algorithm.add"",""params"":[""daggerhashimoto""]}
    ]},
	{""time"":2,""commands"":[
_DEVICES_
	]},
	{""time"":10,""commands"":[
		{""id"":1,""method"":""worker.reset"",""params"":[""0""]}
	]},
	{""time"":15,""loop"":15,""commands"":[
		{""id"":1,""method"":""algorithm.print.speeds"",""params"":[]},
		{""id"":1,""method"":""worker.reset"",""params"":[""0""]}
	]}
]";
            var          devices  = string.Join(",\n", uuids.Select(uuid => DEVICE.Replace("_DEV_ID_", uuid)));

            return(TEMPLATE
                   .Replace("_MINING_LOCATION_", miningLocation)
                   .Replace("_PUT_YOUR_BTC_HERE_", username)
                   .Replace("_DEVICES_", devices));
        }
        public void TestSecureRQLFormat()
        {
            const string TEMPLATE = "{0}a{1}b{2}";
            var          guid     = Guid.NewGuid();
            var          result   = TEMPLATE.SecureRQLFormat("<q", new RedDotObjectHandle(guid, ""), "&");

            Assert.AreEqual("&lt;qa" + guid.ToRQLString() + "b&amp;", result);
        }
 public void ConvertFromTEMPLATE(TEMPLATE t)
 {
     this.TemplateName        = t.TEMPLATENAME;
     this.TemplateDefinitions = new List <FileItTemplateDefinition>();
     t.TemplateDefinitions.ForEach(td =>
     {
         this.TemplateDefinitions.Add(ConvertFromTEMPLATEDEFINITION(td));
     });
 }
예제 #10
0
        public override string ToString()
        {
            var          code     = String.Concat(Labels.Select(x => x.Name));
            float        conf     = Confidence;
            const String TEMPLATE = "{\"code\":\"{{CODE}}\",\"time\":{{TIME}},\"confidence\":{{CONFIDENCE}}}";

            return(TEMPLATE.Replace("{{CODE}}", code)
                   .Replace("{{TIME}}", Time.ToString("F3"))
                   .Replace("{{CONFIDENCE}}", conf.ToString("F3")));
        }
예제 #11
0
        public ActionResult DeleteAllTemplateSelected()
        {
            Guid userSession = new Guid(HttpContext.User.Identity.Name);


            try
            {
                bool unique = true;
                if (Session["ListTemplateToDelete"] != null)
                {
                    string      hash           = Session["ListTemplateToDelete"].ToString();
                    List <Guid> listIdTemplate = new List <Guid>();
                    if (!string.IsNullOrEmpty(hash))
                    {
                        if (!hash.Contains(','))
                        {
                            listIdTemplate.Add(Guid.Parse(hash));
                        }
                        else
                        {
                            foreach (var id in (hash).Split(','))
                            {
                                listIdTemplate.Add(Guid.Parse(id));
                            }
                            unique = false;
                        }
                    }
                    if (listIdTemplate.Count != 0)
                    {
                        redactapplicationEntities db = new Models.redactapplicationEntities();
                        foreach (var templateId in listIdTemplate)
                        {
                            //suppression des commandes
                            TEMPLATE template = db.TEMPLATEs.SingleOrDefault(x => x.templateId == templateId);
                            if (template != null)
                            {
                                db.TEMPLATEs.Remove(template);
                            }
                        }
                        db.SaveChanges();

                        return(View(unique ? "DeleteTemplateConfirmation" : "DeteleAllTemplateConfirmation"));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return(RedirectToRoute("Home", new RouteValueDictionary {
                { "controller", "Template" },
                { "action", "ListTemplate" }
            }));
        }
        public ActionResult ReativarTemplate(Int32 id)
        {
            // Prepara view
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            TEMPLATE          item = baseApp.GetItemById(id);
            TemplateViewModel vm   = Mapper.Map <TEMPLATE, TemplateViewModel>(item);

            return(View(vm));
        }
예제 #13
0
        /// <summary>
        /// Creates the snippet XML and saves it to file
        /// </summary>
        private bool SaveSnippetToFile(string title,
                                       string shortcut,
                                       string description,
                                       string code,
                                       out string fullpath,
                                       string useThisPath = "")
        {
            fullpath = "";

            var fileName = title;
            var counter  = 2;

            if (useThisPath == "")
            {
                // Add a numeric tag to the filename if it already exists
                while (File.Exists(Path.Combine(UserSnippetPath, fileName + ".snippet")) == true)
                {
                    fileName = "{0} {1}".FormatWith(title, counter++);
                }
            }

            var snippetXml = TEMPLATE.FormatWith(title.Escape(),
                                                 description.Escape(),
                                                 shortcut.Escape(),
                                                 code);
            var xmlDocument = new XmlDocument();

            try
            {
                xmlDocument.LoadXml(snippetXml);
            }
            catch (XmlException ex)
            {
                Box.Error("Error creating XML snippet, exception:", ex.Message);
                return(false);
            }

            try
            {
                fullpath = Path.Combine(UserSnippetPath, fileName + ".snippet");

                xmlDocument.Save((useThisPath == "")? fullpath : useThisPath);
            }
            catch (XmlException ex)
            {
                Box.Error("Error saving XML snippet, exception:", ex.Message);
                return(false);
            }

            return(true);
        }
        public ActionResult MontarTelaTemplate()
        {
            // Verifica se tem usuario logado
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if ((USUARIO)Session["UserCredentials"] != null)
            {
                usuario = (USUARIO)Session["UserCredentials"];

                // Verfifica permissão
                if (usuario.PERFIL.PERF_SG_SIGLA != "ADM")
                {
                    Session["MensTemplate"] = 2;
                    return(RedirectToAction("CarregarBase", "BaseAdmin"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }

            // Carrega listas
            Int32 idAss = (Int32)Session["IdAssinante"];

            if ((List <TEMPLATE>)Session["ListaTemplate"] == null)
            {
                listaMaster = baseApp.GetAllItens(idAss);
                Session["ListaTemplate"] = listaMaster;
            }
            ViewBag.Listas = (List <TEMPLATE>)Session["ListaTemplate"];
            ViewBag.Title  = "Templates";

            // Indicadores
            ViewBag.Templates = ((List <TEMPLATE>)Session["ListaTemplate"]).Count;

            // Mensagem
            if ((Int32)Session["MensTemplate"] == 1)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
            }

            // Abre view
            Session["MensTemplate"] = 0;
            objeto = new TEMPLATE();
            return(View(objeto));
        }
예제 #15
0
        public void TestSimpleTemplate()
        {
            /* Given: Ein einfacher String mit einem Platzhalter */
            const string TEMPLATE           = "Das ist ein {value} Template";
            const string PLACE_HOLDER_VALUE = "einfaches";
            string       expectedString     = TEMPLATE.Replace("{value}", PLACE_HOLDER_VALUE);
            ModelMap     model = new ModelMap();

            model.Add("value", PLACE_HOLDER_VALUE);
            /* When: Das Template mit dem Platzhalter gefüllt werden soll */
            string result = new Templater().FormatTemplate(TEMPLATE, model);

            /* Then: Muss der Platzhalter korrekt ersetzt werden. */
            Assert.AreEqual(expectedString, result);
        }
예제 #16
0
        public void TestFormat()
        {
            /* Given: Ein Template, in welches ein Datum eingefügt werden soll. */
            const string TEMPLATE = "Heute ist der {today:d}";
            DateTime     now      = DateTime.Now;
            string       expected = TEMPLATE.Replace("{today:d}", now.ToString("d"));
            ModelMap     model    = new ModelMap();

            model.Add("today", now);
            /* When: Die Platzhalter ersetzt werden sollen */
            string result = new Templater().FormatTemplate(TEMPLATE, model);

            /* Then: Muss das korrekte Datum im richtigen Format eingefügt wurden sein. */
            Assert.AreEqual(expected, result);
        }
예제 #17
0
        public void TestFormatPathNotFoundDefaultNull()
        {
            /* Given: Ein Template mit zwei Platzhaltern, von denen im Model nur ein Pfad gefunden werden kann. */
            const string TEMPLATE = "Heute ist der {today:d}. Weltuntergang ist am {doomsday:d}";
            DateTime     now      = DateTime.Now;
            string       expected = TEMPLATE.Replace("{today:d}", now.ToString("d"));
            ModelMap     model    = new ModelMap();

            model.Add("today", now);
            /* When: Das Template ersetzt werden soll */
            string result = new Templater().FormatTemplate(TEMPLATE, model);

            /* Then: Muss das gefundene ersetzt werden und das andere so belassen werden. */
            Assert.AreEqual(expected, result);
        }
예제 #18
0
        public void TestFormatCulture()
        {
            /* Given: Eine Zeichenfolge, in welches ein Datum im englischen Format eingefügt werden soll. */
            const string TEMPLATE       = "Heute ist der {today:d}";
            DateTime     now            = DateTime.Now;
            CultureInfo  englishCulture = CultureInfo.GetCultureInfo("en");
            string       expected       = TEMPLATE.Replace("{today:d}", now.ToString("d", englishCulture));
            ModelMap     model          = new ModelMap();

            model.Add("today", now);
            /* When: Die Platzhalter ersetzt werden sollen */
            string result = new Templater(englishCulture).FormatTemplate(TEMPLATE, model);

            /* Then: Muss das Datum korrekt im englischen Datumsformat eingefügt sein. */
            Assert.AreEqual(expected, result);
        }
예제 #19
0
        public void TestReplaceTwice()
        {
            /* Given: Ein Template in dem ein Platzhalter mehrfach vorkommt. */
            const string TEMPLATE    = "{hello}, {hello}, {hello}. Wie geht's?";
            const string HELLO_VALUE = "Hi";

            string   expected = TEMPLATE.Replace("{hello}", HELLO_VALUE);
            ModelMap model    = new ModelMap();

            model.Add("hello", HELLO_VALUE);
            /* When: Die Platzhalter ersetzt werden sollen */
            string result = new Templater().FormatTemplate(TEMPLATE, model);

            /* Then: Müssen alle Platzhalter ersetzt werden. */
            Assert.AreEqual(expected, result);
        }
예제 #20
0
        public ActionResult IncluirTemplate(TemplateViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Campanhas = new SelectList(camApp.GetAllItens(idAss), "CAMP_CD_ID", "CAMP_NM_NOME");
            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    TEMPLATE item          = Mapper.Map <TemplateViewModel, TEMPLATE>(vm);
                    USUARIO  usuarioLogado = (USUARIO)Session["UserCredentials"];
                    Int32    volta         = baseApp.ValidateCreate(item, usuarioLogado, idAss);

                    // Verifica retorno
                    if (volta == 1)
                    {
                        Session["MensTemplate"] = 1;
                        ModelState.AddModelError("", SMS_Resource.ResourceManager.GetString("M0035", CultureInfo.CurrentCulture));
                        return(View(vm));
                    }

                    // Sucesso
                    listaMaster = new List <TEMPLATE>();
                    Session["ListaTemplate"]    = null;
                    Session["VoltaTemplate"]    = 1;
                    Session["IdAssinanteVolta"] = item.ASSI_CD_ID;
                    Session["Template"]         = item;
                    Session["MensTemplate"]     = 0;
                    Session["IdVolta"]          = item.TEMP_CD_ID;
                    return(RedirectToAction("MontarTelaTemplate"));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View(vm));
                }
            }
            else
            {
                return(View(vm));
            }
        }
        public ActionResult EditarTemplate(Int32 id)
        {
            // Prepara view
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            TEMPLATE item = baseApp.GetItemById(id);

            objetoAntes             = item;
            Session["Template"]     = item;
            Session["IdVolta"]      = id;
            Session["MensTemplate"] = 0;
            TemplateViewModel vm = Mapper.Map <TEMPLATE, TemplateViewModel>(item);

            return(View(vm));
        }
        public ActionResult IncluirTemplate()
        {
            // Prepara listas
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            // Prepara view
            USUARIO           usuario = (USUARIO)Session["UserCredentials"];
            TEMPLATE          item    = new TEMPLATE();
            TemplateViewModel vm      = Mapper.Map <TEMPLATE, TemplateViewModel>(item);

            vm.TEMP_IN_ATIVO   = 1;
            vm.ASSI_CD_ID      = idAss;
            vm.TEMP_DT_CRIACAO = DateTime.Today.Date;
            return(View(vm));
        }
예제 #23
0
        public void TestDeepPathTemplate()
        {
            /* Given: Ein Template mit einem 3-teiligen Platzhalter-Pfad */
            const string TEMPLATE           = "Das ist ein {user.name.firstname} Template";
            const string PLACE_HOLDER_VALUE = "Tobias";
            string       expectedString     = TEMPLATE.Replace("{user.name.firstname}", PLACE_HOLDER_VALUE);

            /* When: Das Template gefüllt werden soll */
            var name = new { firstname = PLACE_HOLDER_VALUE };
            // ReSharper disable once RedundantAnonymousTypePropertyName : Readability
            var user = new { name = name };

            ModelMap model = new ModelMap();

            model.Add("user", user);
            string result = new Templater().FormatTemplate(TEMPLATE, model);

            /* Then: Müssen die Platzhalter korrekt ersetzt werden. */
            Assert.AreEqual(expectedString, result);
        }
예제 #24
0
        public ActionResult MontarTelaTemplate()
        {
            // Verifica se tem usuario logado
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            usuario = (USUARIO)Session["UserCredentials"];
            Int32 idAss = (Int32)Session["IdAssinante"];

            // Carrega listas
            if ((List <TEMPLATE>)Session["ListaTemplate"] == null)
            {
                listaMaster = baseApp.GetAllItens(idAss);
                Session["ListaTemplate"] = listaMaster;
            }
            ViewBag.Listas = (List <TEMPLATE>)Session["ListaTemplate"];
            ViewBag.Title  = "Templates";

            ViewBag.Campanhas = new SelectList(camApp.GetAllItens(idAss), "CAMP_CD_ID", "CAMP_NM_NOME");

            // Indicadores
            ViewBag.Templates = ((List <TEMPLATE>)Session["ListaTemplate"]).Count;

            // Mensagem
            if ((Int32)Session["MensTemplate"] == 1)
            {
                ModelState.AddModelError("", SMS_Resource.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
            }
            if ((Int32)Session["MensTemplate"] == 2)
            {
                ModelState.AddModelError("", SMS_Resource.ResourceManager.GetString("M0036", CultureInfo.CurrentCulture));
            }

            // Abre view
            Session["MensTemplate"] = 0;
            objeto = new TEMPLATE();
            return(View(objeto));
        }
예제 #25
0
        public ActionResult EditarTemplate(Int32 id)
        {
            // Prepara view
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Campanhas = new SelectList(camApp.GetAllItens(idAss), "CAMP_CD_ID", "CAMP_NM_NOME");

            TEMPLATE item = baseApp.GetItemById(id);

            objetoAntes             = item;
            Session["Template"]     = item;
            Session["IdVolta"]      = id;
            Session["MensTemplate"] = 0;
            TemplateViewModel vm = Mapper.Map <TEMPLATE, TemplateViewModel>(item);

            return(View(vm));
        }
예제 #26
0
        public ActionResult SaveEditTemplate(Guid idTemplate, TEMPLATEViewModel model, FormCollection collection)
        {
            var      hash     = idTemplate;
            TEMPLATE template = db.TEMPLATEs.Find(hash);

            template.MODELE.site_url = model.MODELE.site_url;
            template.url             = model.url;
            template.ftpUser         = model.ftpUser;
            template.ftpPassword     = model.ftpPassword;
            template.ip = model.ip;

            int result = db.SaveChanges();

            if (result > 0)
            {
                return(View("EditTemplateConfirmation"));
            }
            else
            {
                return(View("ErrorException"));
            }
        }
예제 #27
0
        private void GrabarHuella(int vNro, byte[] blob1)
        {
            using (Model1 Bd = new Model1())
            {
                TEMPLATE user = new TEMPLATE();

                user.USERID     = vUserId;
                user.FINGERID   = vNro;
                user.USETYPE    = 0;
                user.Flag       = 1;
                user.DivisionFP = 10;
                user.status     = 0;
                user.Valid      = 1;
                user.Fpversion  = "10";
                user.bio_type   = 0;
                user.SN         = 0;

                user.TEMPLATE3 = blob1;
                user.TEMPLATE4 = blob1;

                Bd.TEMPLATE.Add(user);
                Bd.SaveChanges();
            }
        }
예제 #28
0
        public Int32 ValidateCreate(USUARIO usuario, USUARIO usuarioLogado)
        {
            try
            {
                // Verifica senhas
                if (usuario.USUA_NM_SENHA != usuario.USUA_NM_SENHA_CONFIRMA)
                {
                    return(1);
                }

                // Verifica Email
                if (!ValidarItensDiversos.IsValidEmail(usuario.USUA_NM_EMAIL))
                {
                    return(2);
                }

                // Verifica existencia prévia
                if (_usuarioService.GetByEmail(usuario.USUA_NM_EMAIL) != null)
                {
                    return(3);
                }
                if (_usuarioService.GetByLogin(usuario.USUA_NM_LOGIN) != null)
                {
                    return(4);
                }

                // Verifica admissão e demissão
                if (usuario.USUA_DT_ENTRADA != null)
                {
                    if (usuario.USUA_DT_ENTRADA.Value > DateTime.Today.Date)
                    {
                        return(5);
                    }
                }
                if (usuario.USUA_DT_SAIDA != null)
                {
                    if (usuario.USUA_DT_SAIDA.Value > DateTime.Today.Date)
                    {
                        return(6);
                    }
                    if (usuario.USUA_DS_MOTIVO_SAIDA == null)
                    {
                        return(7);
                    }
                }
                if (usuario.USUA_IN_RESPONSAVEL == 1)
                {
                    if (_usuarioService.GetResponsavel(usuario) != null)
                    {
                        return(8);
                    }
                }

                //Completa campos de usuários
                String senha = Cryptography.GenerateRandomPassword(6);
                usuario.USUA_NM_SENHA = senha;
                usuario.USUA_NM_LOGIN = usuario.USUA_NM_NOME.Substring(0, 4);
                //usuario.USUA_NM_SENHA = Cryptography.Encode(usuario.USUA_NM_SENHA);
                usuario.USUA_IN_BLOQUEADO        = 0;
                usuario.USUA_IN_PROVISORIO       = 0;
                usuario.USUA_IN_LOGIN_PROVISORIO = 0;
                usuario.USUA_NR_ACESSOS          = 0;
                usuario.USUA_NR_FALHAS           = 0;
                usuario.USUA_DT_ALTERACAO        = null;
                usuario.USUA_DT_BLOQUEADO        = null;
                usuario.USUA_DT_TROCA_SENHA      = null;
                usuario.USUA_DT_ACESSO           = DateTime.Now;
                usuario.USUA_DT_CADASTRO         = DateTime.Today.Date;
                usuario.USUA_IN_ATIVO            = 1;
                usuario.USUA_DT_ULTIMA_FALHA     = DateTime.Now;
                usuario.ASSI_CD_ID           = usuarioLogado.ASSI_CD_ID;
                usuario.USUA_DS_MOTIVO_SAIDA = null;
                usuario.USUA_IN_LOGADO       = 0;
                usuario.USUA_NR_MATRICULA    = null;

                // Monta Log
                LOG log = new LOG
                {
                    LOG_DT_DATA     = DateTime.Now,
                    USUA_CD_ID      = usuarioLogado.USUA_CD_ID,
                    ASSI_CD_ID      = usuarioLogado.ASSI_CD_ID,
                    LOG_NM_OPERACAO = "AddUSUA",
                    LOG_TX_REGISTRO = Serialization.SerializeJSON <USUARIO>(usuario),
                    LOG_IN_ATIVO    = 1
                };

                // Persiste
                Int32 volta = _usuarioService.CreateUser(usuario, log);

                // Gerar Notificação
                NOTIFICACAO noti = new NOTIFICACAO();
                noti.CANO_CD_ID       = 1;
                noti.ASSI_CD_ID       = usuario.ASSI_CD_ID;
                noti.NOTI_DT_EMISSAO  = DateTime.Today;
                noti.NOTI_DT_VALIDADE = DateTime.Today.Date.AddDays(30);
                noti.NOTI_IN_VISTA    = 0;
                noti.NOTI_NM_TITULO   = "Criação de Usuário";
                noti.NOTI_IN_ATIVO    = 1;
                noti.NOTI_IN_NIVEL    = 1;
                noti.NOTI_TX_TEXTO    = "ATENÇÃO: Usuário" + usuario.USUA_NM_NOME + " criado em " + DateTime.Today.Date.ToLongDateString() + ". Perfil: " + usuario.PERFIL.PERF_NM_NOME + ". Login: "******". Senha: " + usuario.USUA_NM_SENHA + ". Essa senha é provisória e poderá ser usada apenas uma vez, devendo ser alterada após o primeiro login.";
                noti.USUA_CD_ID       = usuario.USUA_CD_ID;
                noti.NOTI_IN_STATUS   = 1;
                Int32 volta1 = _notiService.Create(noti);

                // Recupera template e-mail
                TEMPLATE template = _usuarioService.GetTemplate("NEWUSR");
                String   header   = template.TEMP_TX_CABECALHO;
                String   body     = template.TEMP_TX_CORPO;
                String   data     = template.TEMP_TX_DADOS;

                // Prepara dados do e-mail
                data = data.Replace("{Nome}", usuario.USUA_NM_NOME);
                data = data.Replace("{Unidade}", usuario.UNIDADE.UNID_NM_EXIBE);
                data = data.Replace("{Perfil}", usuario.PERFIL.PERF_NM_NOME);
                data = data.Replace("{Data}", usuario.USUA_DT_CADASTRO.Value.ToLongDateString());
                data = data.Replace("{Login}", usuario.USUA_NM_LOGIN);
                data = data.Replace("{Senha}", usuario.USUA_NM_SENHA);

                // Concatena
                String emailBody = header + body + data;

                // Prepara e-mail e enviar
                CONFIGURACAO conf     = _usuarioService.CarregaConfiguracao(usuario.ASSI_CD_ID);
                Email        mensagem = new Email();
                mensagem.ASSUNTO             = "Inclusão de Usuário";
                mensagem.CORPO               = emailBody;
                mensagem.DEFAULT_CREDENTIALS = false;
                mensagem.EMAIL_DESTINO       = usuario.USUA_NM_EMAIL;
                mensagem.EMAIL_EMISSOR       = conf.CONF_NM_EMAIL_EMISSOO;
                mensagem.ENABLE_SSL          = true;
                mensagem.NOME_EMISSOR        = "Sistema";
                mensagem.PORTA               = conf.CONF_NM_PORTA_SMTP;
                mensagem.PRIORIDADE          = System.Net.Mail.MailPriority.High;
                mensagem.SENHA_EMISSOR       = conf.CONF_NM_SENHA_EMISSOR;
                mensagem.SMTP = conf.CONF_NM_HOST_SMTP;

                // Envia e-mail
                Int32 voltaMail = CommunicationPackage.SendEmail(mensagem);
                return(volta);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #29
0
        UUIRequest Load(string _name, bool _preloading, EOpenMode _openMode)
        {
            UUIWorker outWorker;

            //LOADING_AGAIN:
            if (TryGetWoker(_name, out outWorker))
            {
                //> 已经加载完毕了
                if (outWorker.State == EWorkerState.Loading || outWorker.State == EWorkerState.Working)
                {
                    return(outWorker.Request);
                }
                else
                {
                    //> 这段代码是不会发生的

                    /*if (null == outWorker.Script)
                     * {
                     *  RemoveFromContainer(outWorker);
                     *  UnloadResourceByInfo(outWorker.Info);
                     *  goto LOADING_AGAIN;
                     * }*/

                    if (_preloading)
                    {
                        outWorker.SetRest();
                    }
                    else
                    {
                        WorkLine.Add(outWorker);
                        if (WorkLine.Count > 1)
                        {
                            WorkLine[WorkLine.Count - 2].SetDownward();
                        }
                        outWorker.SetOpen();
                        outWorker.SetUpward();
                    }
                    return(outWorker.Request);
                }
            }
            else
            {
                UUIInfo outUIInfo;
                if (Manager.TryGetUIInfo(_name, out outUIInfo) == false)
                {
                    Output.Error("没有找到 {0} 的信息,加载UI失败!", _name);
                    return(null);
                }

                var worker = LoadUI(outUIInfo, _preloading ? EWorkerState.Resting : EWorkerState.Working, (WORKER, TEMPLATE) =>
                {
                    //> 加载完成,但是资源不存在
                    if (TEMPLATE == null)
                    {
                        RemoveFromContainer(WORKER);
                        UnloadResourceByInfo(WORKER.Info);
                        Output.Error("UI对象为空:{0}", outUIInfo.GetName());
                        return;
                    }

                    //> 在加载期间调用了Dispose
                    if (Container.Contains(WORKER) == false)
                    {
                        if (false == WORKER.Info.IsSceneObject)
                        {
                            GameObject.Destroy(TEMPLATE);
                        }
                        UnloadResourceByInfo(WORKER.Info);
                        Output.Warning("不存在的容器实例:{0}", WORKER.Info.GetName());
                        return;
                    }

                    if (false == WORKER.Info.IsSceneObject)
                    {
                        GameObject.DontDestroyOnLoad(TEMPLATE);
                    }

                    //> 对象身上没有挂在UUI脚本
                    if (false == WORKER.SetLoaded(Manager, TEMPLATE))
                    {
                        Output.Error("在UI对象{0}身上没有发现UUI脚本对象", _name);
                        UnloadWorker(WORKER, TEMPLATE);
                        return;
                    }

                    WORKER.Request.InitScript(TEMPLATE.GetComponent <UUIView>());

                    //> 处理下一个环节的工作
                    if (WORKER.NextState == EWorkerState.Working)
                    {
                        WORKER.SetOpen();
                        if (WorkLine[WorkLine.Count - 1] != WORKER)
                        {
                            WORKER.SetDownward();
                        }
                        else
                        {
                            WORKER.SetUpward();
                        }
                    }

                    //> 加载期间被设置了退出
                    else if (WORKER.NextState == EWorkerState.Exiting)
                    {
                        WORKER.SetClose(WORKER.NextExitState);
                    }
                });

                if (_preloading == false && WorkLine.Count > 1)
                {
                    WorkLine[WorkLine.Count - 2].SetDownward();
                }

                //> 根据工作模式,清理工作队列
                if (_preloading == false && _openMode == EOpenMode.Single)
                {
                    int idx = WorkLine.FindIndex((v) => worker == v);

                    if (idx > 0)
                    {
                        List <UUIWorker> temp = new List <UUIWorker>();
                        for (int i = 0; i < idx; i++)
                        {
                            temp.Insert(0, WorkLine[i]);
                        }
                        WorkLine.RemoveRange(0, idx);

                        //> 处理需要下岗的工人
                        foreach (var v in temp)
                        {
                            v.SetClose(false);
                        }
                        temp.Clear();
                    }
                }
                return(worker?.Request);
            }
        }
예제 #30
0
        public ActionResult SaveTemplate(TEMPLATEViewModel model, FormCollection collection)
        {
            int res = 0;

            var    selectedProjetId = model.listprojetId;
            var    selectedThemeId  = model.listThemeId;
            string ftpdir           = "";

            if (!string.IsNullOrEmpty(collection["ftpdirs"]))
            {
                ftpdir = collection["ftpdirs"];
            }

            if (!string.IsNullOrEmpty(Request.QueryString["currentid"]))
            {
                _userId = Guid.Parse(Request.QueryString["currentid"]);
                Session["currentid"] = Request.QueryString["currentid"];
            }
            else if (!string.IsNullOrEmpty(HttpContext.User.Identity.Name))
            {
                _userId = Guid.Parse(HttpContext.User.Identity.Name);
            }

            MODELEViewModel modelVm = new MODELEViewModel();

            modelVm         = new Modeles().GetDetailsModele((Guid)Session["modeleId"]);
            Session["Menu"] = "1";
            var html = RenderViewAsString("Home", modelVm);

            TEMPLATE newtemplate = new TEMPLATE();

            newtemplate.dateCreation = DateTime.Now;
            newtemplate.url          = model.url;
            newtemplate.ftpUser      = model.ftpUser;
            newtemplate.ftpPassword  = model.ftpPassword;
            newtemplate.modeleId     = (Guid)Session["modeleId"];
            newtemplate.ip           = model.ip;
            newtemplate.userId       = _userId;
            newtemplate.PROJET       = db.PROJETS.Find(selectedProjetId);
            newtemplate.projetId     = selectedProjetId;
            var   selectedTheme = model.THEME.theme_name;
            THEME currentTheme  = db.THEMES.FirstOrDefault(x => x.theme_name.Contains(selectedTheme.TrimEnd()));

            if (currentTheme == null)
            {
                currentTheme = new THEME {
                    themeId = Guid.NewGuid(), theme_name = selectedTheme
                };
                db.THEMES.Add(currentTheme);
                db.SaveChanges();
            }

            newtemplate.THEME   = currentTheme;
            newtemplate.themeId = currentTheme.themeId;

            newtemplate.html = html;


            var results =
                newtemplate.templateId = Guid.NewGuid();

            db.TEMPLATEs.Add(newtemplate);
            try
            {
                res = db.SaveChanges();
                if (res > 0)
                {
                    var templateName = Session["TemplateName"].ToString();

                    int nb_menu = (Session["nbmenu"] == null) ? 1 : int.Parse(Session["nbmenu"].ToString());

                    CreateFiles(nb_menu, html);

                    //Send Ftp
                    string pathParent = Server.MapPath("~/Themes/" + templateName);
                    string pathCss    = pathParent + "/css/";
                    string pathImg    = pathParent + "/img";
                    string pathJs     = pathParent + "/js";
                    int    result     = SendToFtp(ftpdir, model.url, model.ftpUser, model.ftpPassword, pathCss, pathParent, pathImg, pathJs);

                    //return new FilePathResult(path, "text/html");
                    if (result == 0)
                    {
                        return(View("CreateTemplateConfirmation"));
                    }
                    else
                    {
                        return(View("ErrorException"));
                    }
                }
                else
                {
                    return(View("ErrorException"));
                }
            }
            catch (Exception ex)
            {
                return(View("ErrorException"));
            }
        }