Esempio n. 1
0
 public static InstruccionEjecucion Fetch()
 {
     IP.EnableLectura(true);
     bool[] Instruccion = CPU.Memoria.Leer(IP.Get());
     IP.EnableLectura(false);
     return(new InstruccionEjecucion(Instruccion));
 }
Esempio n. 2
0
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <param name="typeId">类型</param>
        public static void InsertData(string keyword, int typeId)
        {
            SqlConnection conn = new SqlConnection(Connection.ConnString());

            try
            {
                conn.Open();
                string     sql  = "insert into Site_Search(Keyword,IPAddress,Browser,TypeID,Counts,Remark,CreateDate) values (@Keyword,@IPAddress,@Browser,@TypeID,@Counts,@Remark,@CreateDate)";
                SqlCommand comm = new SqlCommand(sql, conn);
                comm.Parameters.Add(new SqlParameter("@Keyword", SqlDbType.NVarChar, 500));
                comm.Parameters["@Keyword"].Value = keyword;
                comm.Parameters.Add(new SqlParameter("@IPAddress", SqlDbType.VarChar, 20));
                comm.Parameters["@IPAddress"].Value = IP.Get();
                comm.Parameters.Add(new SqlParameter("@Browser", SqlDbType.VarChar, 20));
                comm.Parameters["@Browser"].Value = String.GetBrowserInfo();
                comm.Parameters.Add(new SqlParameter("@TypeID", SqlDbType.Int));
                comm.Parameters["@TypeID"].Value = typeId;
                comm.Parameters.Add(new SqlParameter("@Counts", SqlDbType.Int));
                comm.Parameters["@Counts"].Value = 0;
                comm.Parameters.Add(new SqlParameter("@Remark", SqlDbType.NVarChar, 500));
                comm.Parameters["@Remark"].Value = string.Empty;
                comm.Parameters.Add(new SqlParameter("@CreateDate", SqlDbType.DateTime));
                comm.Parameters["@CreateDate"].Value = DateTime.Now;
                comm.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 记录日志信息
        /// </summary>
        /// <returns></returns>
        /// <param name="language">Language</param>
        public static void InsertData(string language)
        {
            SqlConnection conn = new SqlConnection(Connection.ConnString());

            try
            {
                conn.Open();
                string     sql  = "insert into Site_Log(IPAddress,Url,MemberID,Browser,TypeID,LogTime,Language) values (@IPAddress,@Url,@MemberID,@Browser,@TypeID,@LogTime,@Language)";
                SqlCommand comm = new SqlCommand(sql, conn);
                comm.Parameters.Add(new SqlParameter("@IPAddress", SqlDbType.VarChar, 20));
                comm.Parameters["@IPAddress"].Value = IP.Get();
                comm.Parameters.Add(new SqlParameter("@Url", SqlDbType.NVarChar, 100));
                comm.Parameters["@Url"].Value = System.Web.HttpContext.Current.Request.Path.ToString();
                comm.Parameters.Add(new SqlParameter("@MemberID", SqlDbType.Int));
                comm.Parameters["@MemberID"].Value = 0;
                comm.Parameters.Add(new SqlParameter("@Browser", SqlDbType.NVarChar, 50));
                comm.Parameters["@Browser"].Value = String.GetBrowserInfo();
                comm.Parameters.Add(new SqlParameter("@TypeID", SqlDbType.Int));
                comm.Parameters["@TypeID"].Value = 0;
                comm.Parameters.Add(new SqlParameter("@LogTime", SqlDbType.DateTime));
                comm.Parameters["@LogTime"].Value = DateTime.Now;
                comm.Parameters.Add(new SqlParameter("@Language", SqlDbType.VarChar, 10));
                comm.Parameters["@Language"].Value = language;
                comm.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 4
0
        public static void HasLogin()
        {
            if (HttpContext.Current != null && HttpContext.Current.Session["UserID"] != null && HttpContext.Current.Session["UserName"] != null)
            {
                SqlConnection conn = new SqlConnection(Connection.ConnString());
                try
                {
                    conn.Open();
                    string     sql  = "select pk_User,UserName,LastLoginIP from User_List where pk_User=@pk_User and UserName=@UserName";
                    SqlCommand comm = new SqlCommand(sql, conn);

                    comm.Parameters.Add(new SqlParameter("@pk_User", SqlDbType.Int));
                    comm.Parameters["@pk_User"].Value = int.Parse(HttpContext.Current.Session["UserID"].ToString());
                    comm.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 100));
                    comm.Parameters["@UserName"].Value = HttpContext.Current.Session["UserName"].ToString();

                    SqlDataReader dr = comm.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr["LastLoginIP"].ToString() == IP.Get()) //验证登陆IP是否为最后登陆(也就是防止使用账号在别处登陆)
                        {
                            return;
                        }
                        else
                        {
                            HttpContext.Current.Response.Redirect("~/Admin/Login.aspx");
                            HttpContext.Current.Response.End();
                        }
                        return;
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect("~/Admin/Login.aspx");
                        HttpContext.Current.Response.End();
                    }
                }
                catch
                {
                    HttpContext.Current.Response.Redirect("~/Admin/Login.aspx");
                    HttpContext.Current.Response.End();
                }
                finally
                {
                    conn.Close();
                }
            }
            else
            {
                HttpContext.Current.Response.Redirect("~/Admin/Login.aspx");
                HttpContext.Current.Response.End();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 浏览记录
        /// </summary>
        /// <param name="title"></param>
        public static void AddLog(string title)
        {
            SqlConnection conn = new SqlConnection(Connection.ConnString());

            try
            {
                conn.Open();
                string     sql  = "insert into User_Log(IPAddress,Url,fk_User,Browser,TypeID,LogTime,Title,Description,SessionID,fk_Company) values (@IPAddress,@Url,@fk_User,@Browser,@TypeID,@LogTime,@Title,@Description,@SessionID,@fk_Company)";
                SqlCommand comm = new SqlCommand(sql, conn);
                comm.Parameters.Add(new SqlParameter("@IPAddress", SqlDbType.NVarChar, 50));
                comm.Parameters["@IPAddress"].Value = IP.Get();
                comm.Parameters.Add(new SqlParameter("@Url", SqlDbType.NVarChar, 200));
                comm.Parameters["@Url"].Value = String.GetUrl(0);
                comm.Parameters.Add(new SqlParameter("@fk_User", SqlDbType.Int));
                if (HttpContext.Current.Session["UserID"] != null)
                {
                    comm.Parameters["@fk_User"].Value = int.Parse(HttpContext.Current.Session["UserID"].ToString());
                }
                else
                {
                    comm.Parameters["@fk_User"].Value = 0;
                }
                comm.Parameters.Add(new SqlParameter("@Browser", SqlDbType.NVarChar, 50));
                comm.Parameters["@Browser"].Value = String.GetBrowserInfo();
                comm.Parameters.Add(new SqlParameter("@TypeID", SqlDbType.Int));
                comm.Parameters["@TypeID"].Value = 0;
                comm.Parameters.Add(new SqlParameter("@LogTime", SqlDbType.DateTime));
                comm.Parameters["@LogTime"].Value = DateTime.Now;;
                comm.Parameters.Add(new SqlParameter("@Title", SqlDbType.NVarChar, 100));
                comm.Parameters["@Title"].Value = title;
                comm.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, -1));
                comm.Parameters["@Description"].Value = HttpContext.Current.Request.ServerVariables.Get("HTTP_USER_AGENT");
                comm.Parameters.Add(new SqlParameter("@SessionID", SqlDbType.NVarChar, 50));
                comm.Parameters["@SessionID"].Value = HttpContext.Current.Session.SessionID;
                comm.Parameters.Add(new SqlParameter("@fk_Company", SqlDbType.Int));
                comm.Parameters["@fk_Company"].Value = 0;
                comm.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 6
0
        protected override System.Drawing.Image Execute(CodeActivityContext context)
        {
            try
            {
                string ip         = IP.Get <string>(context);
                string port       = Port.Get <string>(context);
                string db         = dbName.Get <string>(context);
                string version    = Version.Get <string>(context);
                string group      = Group.Get <string>(context);
                string entity     = Entity.Get <string>(context);
                string function   = Function.Get <string>(context);
                int    merchId    = MerchId.Get <int>(context);
                int    fpid       = FPId.Get <int>(context);
                int    sysId      = SysId.Get <int>(context);
                int    formId     = FormId.Get <int>(context);
                string serviceKey = ServiceKey.Get <string>(context);
                int    imageId    = ImageId.Get <int>(context);

                string url = string.Format("http://{0}:{1}/{2}/{3}/{4}/{5}/{6}?MerchId={7}&SysId={8}&FormId={9}&FPId={10}&key={11}&ImageId={12}",
                                           ip, port, db, version, group, entity, function, merchId, sysId, formId, fpid, serviceKey, imageId);

                HttpClient client = new HttpClient();
                Task <HttpResponseMessage> message = client.GetAsync(url);
                message.Wait();
                Task <string> messageResult = message.Result.Content.ReadAsStringAsync();
                messageResult.Wait();

                System.Drawing.Image result = null;
                byte[] imageByteArray       = Convert.FromBase64String(messageResult.Result.Replace("\"", ""));
                using (MemoryStream stream = new MemoryStream(imageByteArray))
                {
                    result = System.Drawing.Image.FromStream(stream);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 加入在线
        /// </summary>
        /// <param name="type">0位手动登录,1位自动登录</param>
        public static void AddOnline(int type)
        {
            SqlConnection conn = new SqlConnection(Connection.ConnString());

            try
            {
                conn.Open();
                string     sql  = "insert into User_Online(fk_User,SessionID,IPAddress,Browser,TypeID,LoginTime,fk_Company) values (@fk_User,@SessionID,@IPAddress,@Browser,@TypeID,@LoginTime,@fk_Company)";
                SqlCommand comm = new SqlCommand(sql, conn);
                comm.Parameters.Add(new SqlParameter("@fk_User", SqlDbType.Int));
                if (HttpContext.Current.Session["UserID"] != null)
                {
                    comm.Parameters["@fk_User"].Value = int.Parse(HttpContext.Current.Session["UserID"].ToString());
                }
                else
                {
                    comm.Parameters["@fk_User"].Value = 0;
                }
                comm.Parameters.Add(new SqlParameter("@SessionID", SqlDbType.NVarChar, 50));
                comm.Parameters["@SessionID"].Value = HttpContext.Current.Session.SessionID;
                comm.Parameters.Add(new SqlParameter("@IPAddress", SqlDbType.NVarChar, 50));
                comm.Parameters["@IPAddress"].Value = IP.Get();
                comm.Parameters.Add(new SqlParameter("@Browser", SqlDbType.NVarChar, 50));
                comm.Parameters["@Browser"].Value = String.GetBrowserInfo();
                comm.Parameters.Add(new SqlParameter("@TypeID", SqlDbType.Int));
                comm.Parameters["@TypeID"].Value = type;
                comm.Parameters.Add(new SqlParameter("@LoginTime", SqlDbType.DateTime));
                comm.Parameters["@LoginTime"].Value = DateTime.Now;
                comm.Parameters.Add(new SqlParameter("@fk_Company", SqlDbType.Int));
                comm.Parameters["@fk_Company"].Value = 0;
                comm.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 8
0
        public static void UpdateLastLogin(string id)
        {
            SqlConnection conn = new SqlConnection(Connection.ConnString());

            try
            {
                conn.Open();
                string     sql  = "update User_List set LastLoginIP=@LastLoginIP,LastLoginTime=@LastLoginTime where pk_User=@pk_User";
                SqlCommand comm = new SqlCommand(sql, conn);

                comm.Parameters.Add(new SqlParameter("@LastLoginIP", SqlDbType.VarChar, 50));
                comm.Parameters["@LastLoginIP"].Value = IP.Get();
                comm.Parameters.Add(new SqlParameter("@LastLoginTime", SqlDbType.DateTime));
                comm.Parameters["@LastLoginTime"].Value = DateTime.Now;
                comm.Parameters.Add(new SqlParameter("@pk_User", SqlDbType.Int));
                comm.Parameters["@pk_User"].Value = int.Parse(id);

                comm.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 9
0
        // =====================================================

        protected override string Execute(CodeActivityContext context)
        {
            ip         = IP.Get(context);
            port       = Port.Get(context);
            database   = Database.Get(context);
            version    = Version.Get(context);
            userId     = UserId.Get(context);
            fpId       = FPId.Get(context);
            serviceKey = ServiceKey.Get(context);

            customerIdList = getCustomerId();
            if (customerIdList != null && customerIdList.Count != 0)
            {
                for (int i = 0; i < customerIdList.Count; i++)
                {
                    var customer = getCustomerById(customerIdList[i][0]);
                    customerList.Add(customer);

                    if (customer.AccId != "0")
                    {
                        var account = getAccountById(customer.AccId);
                        accountList.Add(account);
                    }

                    if (customer.FAccId != 0)
                    {
                        var detailAcc = getDetailAccById(customer.FAccId);
                        detailAccList.Add(detailAcc);
                    }

                    if (customer.CCId != 0)
                    {
                        var costCenter = getCostCenterById(customer.CCId);
                        costCenterList.Add(costCenter);
                    }

                    if (customer.PrjId != 0)
                    {
                        var project = getProjectById(customer.PrjId);
                        projectList.Add(project);
                    }

                    if (customer.AccId != "0" && customer.FAccId != 0)
                    {
                        var detailAcc   = detailAccList[detailAccList.Count - 1];
                        var accVsDetail = getAccVsDetailByFullId(customer.AccId, customer.FAccId, getDetFullId(detailAcc));
                        accVsDetailList.Add(accVsDetail);
                    }

                    if (customer.AccId != "0" && customer.CCId != 0)
                    {
                        var accVsCC = getAccVsCCByFullId(customer.AccId, customer.CCId);
                        accVsCCList.Add(accVsCC);
                    }

                    if (customer.AccId != "0" && customer.PrjId != 0)
                    {
                        var accVsPrj = getAccVsPrjByFullId(customer.AccId, customer.PrjId);
                        accVsPrjList.Add(accVsPrj);
                    }
                }
            }
            string resutl = SerializeResult();

            return(resutl);
        }