Пример #1
0
 private static void ProcessDataControlParticular(string url, int object_id, int process, string culture)
 {
     try
     {
         XDocument fullFile = XDocument.Load(url);
         _spartan_Traduction_Process_DataApiConsumer.SetAuthHeader(_tokenManager.Token);
         Spartan_Traduction_Process_DataPagingModel traduction_Processes_Data = _spartan_Traduction_Process_DataApiConsumer.ListaSelAll(object_id, process).Resource;
         if (traduction_Processes_Data.Spartan_Traduction_Process_Datas.Count > 0)
         {
             string traductionDescription = "";
             foreach (var traductionDetail in traduction_Processes_Data.Spartan_Traduction_Process_Datas)
             {
                 traductionDescription = traductionDetail.Translated_Text;
                 var nodeToChange =
                     (from p in fullFile.Descendants("resource")
                      where p.Attribute("name").Value == traductionDetail.Original_Text && p.Attribute("control").Value == traductionDetail.Name_of_Control
                      select p).FirstOrDefault();
                 if (nodeToChange != null)
                 {
                     nodeToChange.Attribute("value").Value = traductionDescription;
                 }
                 else
                 {
                     var characters = fullFile.Descendants("resources").FirstOrDefault();
                     if (characters != null)
                     {
                         XElement newNode = new XElement("resource");
                         newNode.SetAttributeValue("name", traductionDetail.Original_Text);
                         newNode.SetAttributeValue("control", traductionDetail.Name_of_Control);
                         newNode.SetAttributeValue("value", traductionDescription);
                         newNode.SetAttributeValue("culture", culture);
                         characters.Add(newNode);
                         fullFile.Save(url);
                     }
                 }
             }
             fullFile.Save(url);
         }
     }
     catch (Exception ex)
     {
         string error = ex.ToString();
     }
 }
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            int ModuleId   = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 35162);

            ViewBag.Permission = permission;
            var varSpartan_Traduction_Process_Data = new Spartan_Traduction_Process_DataModel();

            ViewBag.ObjectId  = "35162";
            ViewBag.Operation = "New";

            ViewBag.IsNew = true;



            if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0"))
            {
                ViewBag.IsNew     = false;
                ViewBag.Operation = "Update";
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_Traduction_Process_DataApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_Traduction_Process_DataData = _ISpartan_Traduction_Process_DataApiConsumer.GetByKeyComplete(Id).Resource.Spartan_Traduction_Process_Datas[0];
                if (Spartan_Traduction_Process_DataData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_Traduction_Process_Data = new Spartan_Traduction_Process_DataModel
                {
                    Clave     = (int)Spartan_Traduction_Process_DataData.Clave
                    , Concept = Spartan_Traduction_Process_DataData.Concept
                    , ConceptConcept_Description = (string)Spartan_Traduction_Process_DataData.Concept_Spartan_Traduction_Concept_Type.Concept_Description
                    , Name_of_Control            = Spartan_Traduction_Process_DataData.Name_of_Control
                    , Original_Text   = Spartan_Traduction_Process_DataData.Original_Text
                    , Translated_Text = Spartan_Traduction_Process_DataData.Translated_Text
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_Traduction_Concept_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Traduction_Concept_Types_Concept = _ISpartan_Traduction_Concept_TypeApiConsumer.SelAll(true);

            if (Spartan_Traduction_Concept_Types_Concept != null && Spartan_Traduction_Concept_Types_Concept.Resource != null)
            {
                ViewBag.Spartan_Traduction_Concept_Types_Concept = Spartan_Traduction_Concept_Types_Concept.Resource.OrderBy(m => m.Concept_Description).Select(m => new SelectListItem
                {
                    Text = m.Concept_Description.ToString(), Value = Convert.ToString(m.IdConcept)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_Traduction_Process_Data));
        }