Пример #1
0
        public ActionResult DisplayByName(string projectname)
        {
            try
            {
                Session["ReturnURL"] = System.Web.HttpContext.Current.Request.Url.PathAndQuery;

                if (!ScreenViewer.SignInHelper.ValidateSignIn())
                {
                    return(RedirectToAction("Login", "Account", new { ReturnUrl = Session["ReturnURL"].ToString() }));
                }

                ScreenViewer.API.ProjectController PC = new API.ProjectController();
                int projectId = PC.GetProjectId(projectname);
                SessionManager.ClearSessionData(HttpContext.Session);
                AddProgramParameter();
                TempData["addparams"] = true;
                return(RedirectToAction("Display", "Project", new { id = projectId }));
            }
            catch (Exception ex)
            {
                Data.Log log = ex.Save(HttpContext.Session, WorkflowHelper.BuildCallData(HttpContext.Session), ImpactLevel.High);
                ViewBag.URL = System.Web.HttpContext.Current.Request.Url;
                return(View("Error", new HandleErrorInfo(ex, "ProjectController", "DisplayByName")));
            }
        }
Пример #2
0
 public void DeleteLog(Data.Log log)
 {
     if (!_context.Logs.Local.Any(rec => rec.ID == log.ID))
     {
         _context.Logs.Attach(log);
     }
     _context.Logs.Remove(log);
     _context.SaveChanges();
 }
Пример #3
0
 public Data.Log UpdateLog(Data.Log log)
 {
     if (!_context.Logs.Local.Any(rec => rec.ID == log.ID))
     {
         _context.Logs.Attach(log);
     }
     _context.Entry(log).State = EntityState.Modified;
     _context.SaveChanges();
     return(log);
 }
Пример #4
0
        /// <summary>
        /// Logs Error for GreenPro Execptions
        /// </summary>
        /// <param name="source"></param>
        /// <param name="innerexception"></param>
        /// <param name="message"></param>
        /// <param name="stackstrace"></param>
        /// <param name="logdate"></param>
        public static void LogError(string source, string innerexception, string message, string stackstrace)
        {
            GreenPro.Data.Log logs = new Data.Log();
            logs.InnerException = innerexception;
            logs.StackStrace    = stackstrace;
            logs.Message        = logs.Message;
            logs.LogDate        = DateTime.Now;
            logs.source         = source;

            GreenPro.Data.GreenProDbEntities db = new Data.GreenProDbEntities();
            db.Logs.Add(logs);
            db.SaveChanges();
        }
Пример #5
0
 void LogCollection_LogDataChanged(object sender, EventArgs e)
 {
     Data.Log l = sender as Data.Log;
     if (l != null)
     {
         if (!string.IsNullOrEmpty(l.GeocacheCode))
         {
             Data.Geocache gc = GetGeocache(l.GeocacheCode);
             if (gc != null)
             {
                 gc.ResetCachedLogData();
             }
         }
     }
 }
Пример #6
0
        public IHttpActionResult PostErrorLog(Data.Log log)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                db.Logs.Add(log);
                db.SaveChanges();

                return(CreatedAtRoute("DefaultApi", new { id = log.LogId }, log));
            }
            catch (Exception ex)
            {
                return(StatusCode(HttpStatusCode.InternalServerError));
            }
        }
Пример #7
0
 public Data.Log AddLog(Data.Log log)
 {
     _context.Logs.Add(log);
     _context.SaveChanges();
     return(log);
 }
Пример #8
0
        public ActionResult Display(int id)
        {
            try
            {
                ScreenViewer.API.ProjectController PC = new API.ProjectController();
                var actionResult = PC.GetScriptProject(id);

                var           response      = actionResult as OkNegotiatedContentResult <ScriptProject>;
                ScriptProject scriptProject = response.Content;

                if (TempData["addparams"] == null || !(bool)TempData["addparams"])
                {
                    SessionManager.ClearSessionData(HttpContext.Session);
                    if (!ScreenViewer.SignInHelper.ValidateSignIn())
                    {
                        return(RedirectToAction("Login", "Account", new { ReturnUrl = System.Web.HttpContext.Current.Request.Url.ToString() }));
                    }
                    AddProgramParameter();
                }

                SessionControl.SessionManager.StoreProjectId(HttpContext.Session, id);
                SessionControl.SessionManager.StoreProjectName(HttpContext.Session, scriptProject.ProjectName);
                SessionControl.SessionManager.StoreProjectDescription(HttpContext.Session, scriptProject.ProjectDesc);
                SessionControl.SessionManager.StoreScreenLayout(HttpContext.Session, scriptProject.ScreenLayout);
                SessionControl.SessionManager.StoreNotificationText(HttpContext.Session, scriptProject.NotificationText);

                if (!string.IsNullOrEmpty(scriptProject.ScreenLayout))
                {
                    ScreenViewer.API.WorkflowLayoutsController WLC = new ScreenViewer.API.WorkflowLayoutsController();
                    var actionResult2 = WLC.GetWorkflowLayoutString(SessionManager.GetScreenLayout(HttpContext.Session), SessionManager.GetClientId(HttpContext.Session));

                    if (actionResult2 != null && actionResult2 != actionResult2 as System.Web.Http.Results.NotFoundResult)
                    {
                        var layoutResponse = actionResult2 as OkNegotiatedContentResult <string>;
                        SessionControl.SessionManager.StoreLayoutHTML(HttpContext.Session, layoutResponse.Content);
                    }
                }

                if (scriptProject.ScriptProjectWorkflows.Count > 0)
                {
                    if (scriptProject.RequireKey.Value)
                    {
                        string key = SessionControl.SessionManager.GetScriptParameterByKey("key", HttpContext.Session);

                        if (!string.IsNullOrEmpty(key))
                        {
                            if (!key.Equals(scriptProject.KeyText.ToString()))
                            {
                                throw new Exception(string.Format("Unable to verify the project key {0}.", key));
                            }
                        }
                        else
                        {
                            throw new Exception(string.Format("Project key is missing."));
                        }
                    }

                    // Create the contact record
                    CreateContactRecord(scriptProject.ProjectName);

                    if (scriptProject.LogoImageID != null && scriptProject.LogoImageID != 0)
                    {
                        var imageResult   = PC.GetScriptProjectImage(scriptProject.LogoImageID.Value);
                        var imageResponse = imageResult as OkNegotiatedContentResult <ScriptImage>;
                        SessionControl.SessionManager.StoreLogoImage(HttpContext.Session, ((ScriptImage)imageResponse.Content).Image);
                    }

                    if (scriptProject.ScriptMenuID != null && scriptProject.ScriptMenuID != 0)
                    {
                        var scriptMenu   = PC.GetScriptProjectMenu(scriptProject.ScriptMenuID.Value);
                        var menuResponse = scriptMenu as OkNegotiatedContentResult <ScriptMenu>;

                        ScriptUL ul;
                        using (StringReader sr = new StringReader(menuResponse.Content.MenuXML))
                        {
                            XmlSerializer xs = new XmlSerializer(typeof(ScriptUL));
                            ul = (ScriptUL)xs.Deserialize(sr);
                        }

                        StringWriter stringWriter = new StringWriter();
                        string       menuType     = "Navbar";
                        string       addClass     = "";
                        using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
                        {
                            switch (menuType)
                            {
                            case "Tabbed":
                                addClass = "nav nav-tabs";
                                break;

                            case "Pills":
                                addClass = "nav nav-pills";
                                break;

                            case "Navbar":
                                writer.AddAttribute(HtmlTextWriterAttribute.Class, "navbar navbar-default");
                                writer.RenderBeginTag("nav");

                                writer.AddAttribute(HtmlTextWriterAttribute.Class, "container");
                                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                                addClass = "nav navbar-nav";
                                break;
                            }

                            writer.AddAttribute(HtmlTextWriterAttribute.Class, addClass);
                            writer.RenderBeginTag(HtmlTextWriterTag.Ul); // Begin #1

                            foreach (ScriptLI li in ul.LIArray)
                            {
                                writer.Write(PopulateLItem(li));
                            }

                            writer.RenderEndTag();

                            if (menuType == "Navbar")
                            {
                                writer.RenderEndTag();
                            }
                        }

                        SessionControl.SessionManager.StoreMenu(HttpContext.Session, stringWriter.ToString());
                    }

                    if (scriptProject.ShowWorkflowSection.Value)
                    {
                        SessionControl.SessionManager.StoreProgramParameter("Section", "Yes", HttpContext.Session);
                    }

                    if (scriptProject.ShowWorkflowSection.Value)
                    {
                        SessionControl.SessionManager.StoreProgramParameter("Workflow", "Yes", HttpContext.Session);
                    }

                    if (scriptProject.ShowNotification.Value)
                    {
                        SessionControl.SessionManager.StoreProgramParameter("Notification", "Yes", HttpContext.Session);
                    }

                    if (scriptProject.ShowNotes.Value)
                    {
                        SessionControl.SessionManager.StoreProgramParameter("CallNotes", "Yes", HttpContext.Session);
                    }

                    if (scriptProject.ShowLead.Value)
                    {
                        SessionControl.SessionManager.StoreProgramParameter("LeadInformation", "Yes", HttpContext.Session);
                    }

                    if (scriptProject.ShowCallback.Value)
                    {
                        SessionControl.SessionManager.StoreProgramParameter("ScheduleCallback", "Yes", HttpContext.Session);
                    }

                    if (scriptProject.ShowLanguage != null && scriptProject.ShowLanguage.Value)
                    {
                        SessionControl.SessionManager.StoreProgramParameter("ShowLanguage", "Yes", HttpContext.Session);
                    }

                    ScriptProjectWorkflow workFlow = scriptProject.ScriptProjectWorkflows.Where(c => c.ScriptWorkflowActiveDate <= DateTime.Now).OrderByDescending(t => t.ScriptWorkflowActiveDate).FirstOrDefault();
                    return(RedirectToAction("Display", "Workflow", new { id = workFlow.ScriptWorkflowID }));
                }
                else
                {
                    return(View("Display"));
                }
            }
            catch (Exception ex)
            {
                Data.Log log = ex.Save(HttpContext.Session, WorkflowHelper.BuildCallData(HttpContext.Session), ImpactLevel.High);
                ViewBag.URL = SessionManager.GetScriptURL(Session);
                return(View("Error", new HandleErrorInfo(ex, "ProjectController", "DisplayByName")));
            }
        }
Пример #9
0
 public LoadFullLogEventArgs(Data.Log l)
 {
     RequestForLog = l;
 }
Пример #10
0
 public LogEventArgs(Data.Log l)
 {
     Log = l;
 }
Пример #11
0
 // Khởi tạo đối tượng
 public Log()
 {
     objLog = new Data.Log();
 }
Пример #12
0
 public LogEventArgs(Data.Log l)
 {
     Log = l;
 }