Esempio n. 1
0
        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, 127);

            ViewBag.Permission = permission;
            var varSpartan_WorkFlow_State = new Spartan_WorkFlow_StateModel();

            ViewBag.ObjectId  = "127";
            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_WorkFlow_StateApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_WorkFlow_StateData = _ISpartan_WorkFlow_StateApiConsumer.GetByKeyComplete(Id).Resource.Spartan_WorkFlow_States[0];
                if (Spartan_WorkFlow_StateData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_WorkFlow_State = new Spartan_WorkFlow_StateModel
                {
                    StateId                 = (int)Spartan_WorkFlow_StateData.StateId
                    , Phase                 = Spartan_WorkFlow_StateData.Phase
                    , PhaseName             = (string)Spartan_WorkFlow_StateData.Phase_Spartan_WorkFlow_Phases.Name
                    , Attribute             = Spartan_WorkFlow_StateData.Attribute
                    , AttributeLogical_Name = (string)Spartan_WorkFlow_StateData.Attribute_Spartan_Metadata.Logical_Name
                    , State_Code            = Spartan_WorkFlow_StateData.State_Code
                    , Name  = Spartan_WorkFlow_StateData.Name
                    , Value = Spartan_WorkFlow_StateData.Value
                    , Text  = Spartan_WorkFlow_StateData.Text
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_WorkFlow_PhasesApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_WorkFlow_Phasess_Phase = _ISpartan_WorkFlow_PhasesApiConsumer.SelAll(true);

            if (Spartan_WorkFlow_Phasess_Phase != null && Spartan_WorkFlow_Phasess_Phase.Resource != null)
            {
                ViewBag.Spartan_WorkFlow_Phasess_Phase = Spartan_WorkFlow_Phasess_Phase.Resource.OrderBy(m => m.Name).Select(m => new SelectListItem
                {
                    Text = m.Name.ToString(), Value = Convert.ToString(m.PhasesId)
                }).ToList();
            }
            _ISpartan_MetadataApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Metadatas_Attribute = _ISpartan_MetadataApiConsumer.SelAll(true);

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


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_WorkFlow_State));
        }
        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, 34558);

            ViewBag.Permission = permission;
            var varSpartan_Report_Filter = new Spartan_Report_FilterModel();

            ViewBag.ObjectId  = "34558";
            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_Report_FilterApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_Report_FilterData = _ISpartan_Report_FilterApiConsumer.GetByKeyComplete(Id).Resource.Spartan_Report_Filters[0];
                if (Spartan_Report_FilterData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_Report_Filter = new Spartan_Report_FilterModel
                {
                    ReportFilterId      = (int)Spartan_Report_FilterData.ReportFilterId
                    , Field             = Spartan_Report_FilterData.Field
                    , FieldLogical_Name = (string)Spartan_Report_FilterData.Field_Spartan_Metadata.Logical_Name
                    , QuickFilter       = Spartan_Report_FilterData.QuickFilter.GetValueOrDefault()
                    , AdvanceFilter     = Spartan_Report_FilterData.AdvanceFilter.GetValueOrDefault()
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_MetadataApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Metadatas_Field = _ISpartan_MetadataApiConsumer.SelAll(true);

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


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_Report_Filter));
        }
        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, 34553);

            ViewBag.Permission = permission;
            var varSpartan_Report_Fields_Detail = new Spartan_Report_Fields_DetailModel();

            ViewBag.ObjectId  = "34553";
            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_Report_Fields_DetailApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_Report_Fields_DetailData = _ISpartan_Report_Fields_DetailApiConsumer.GetByKeyComplete(Id).Resource.Spartan_Report_Fields_Details[0];
                if (Spartan_Report_Fields_DetailData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_Report_Fields_Detail = new Spartan_Report_Fields_DetailModel
                {
                    DesignDetailId            = (int)Spartan_Report_Fields_DetailData.DesignDetailId
                    , PathField               = Spartan_Report_Fields_DetailData.PathField
                    , Physical_Name           = Spartan_Report_Fields_DetailData.Physical_Name
                    , Title                   = Spartan_Report_Fields_DetailData.Title
                    , Function                = Spartan_Report_Fields_DetailData.Function
                    , FunctionDescription     = (string)Spartan_Report_Fields_DetailData.Function_Spartan_Report_Function.Description
                    , Format                  = Spartan_Report_Fields_DetailData.Format
                    , FormatDescription       = (string)Spartan_Report_Fields_DetailData.Format_Spartan_Report_Format.Description
                    , Order_Type              = Spartan_Report_Fields_DetailData.Order_Type
                    , Order_TypeDescription   = (string)Spartan_Report_Fields_DetailData.Order_Type_Spartan_Report_Order_Type.Description
                    , Field_Type              = Spartan_Report_Fields_DetailData.Field_Type
                    , Field_TypeDescription   = (string)Spartan_Report_Fields_DetailData.Field_Type_Spartan_Report_Field_Type.Description
                    , Order_Number            = Spartan_Report_Fields_DetailData.Order_Number
                    , AttributeId             = Spartan_Report_Fields_DetailData.AttributeId
                    , AttributeIdLogical_Name = (string)Spartan_Report_Fields_DetailData.AttributeId_Spartan_Metadata.Logical_Name
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_Report_FunctionApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Report_Functions_Function = _ISpartan_Report_FunctionApiConsumer.SelAll(true);

            if (Spartan_Report_Functions_Function != null && Spartan_Report_Functions_Function.Resource != null)
            {
                ViewBag.Spartan_Report_Functions_Function = Spartan_Report_Functions_Function.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.FunctionId)
                }).ToList();
            }
            _ISpartan_Report_FormatApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Report_Formats_Format = _ISpartan_Report_FormatApiConsumer.SelAll(true);

            if (Spartan_Report_Formats_Format != null && Spartan_Report_Formats_Format.Resource != null)
            {
                ViewBag.Spartan_Report_Formats_Format = Spartan_Report_Formats_Format.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.FormatId)
                }).ToList();
            }
            _ISpartan_Report_Order_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Report_Order_Types_Order_Type = _ISpartan_Report_Order_TypeApiConsumer.SelAll(true);

            if (Spartan_Report_Order_Types_Order_Type != null && Spartan_Report_Order_Types_Order_Type.Resource != null)
            {
                ViewBag.Spartan_Report_Order_Types_Order_Type = Spartan_Report_Order_Types_Order_Type.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.OrderTypeId)
                }).ToList();
            }
            _ISpartan_Report_Field_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Report_Field_Types_Field_Type = _ISpartan_Report_Field_TypeApiConsumer.SelAll(true);

            if (Spartan_Report_Field_Types_Field_Type != null && Spartan_Report_Field_Types_Field_Type.Resource != null)
            {
                ViewBag.Spartan_Report_Field_Types_Field_Type = Spartan_Report_Field_Types_Field_Type.Resource.OrderBy(m => m.Description).Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.FieldTypeId)
                }).ToList();
            }
            _ISpartan_MetadataApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Metadatas_AttributeId = _ISpartan_MetadataApiConsumer.SelAll(true);

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


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