Exemplo n.º 1
0
        public List <Sys_Line> GetStatisticsLinesByIP(string IP)
        {
            List <Sys_Line> lst = new List <Sys_Line>();

            try
            {
                Sys_Line  line = null;
                String    sql  = "SELECT ID,LineName,IPAddress,Port,UserName ,PassWord ,DataBaseName,Description FROM dbo.sys_line WHERE IsActive=1 and [Statistics] = 1 and IPAddress = '" + IP + "'";
                DataTable dt   = GetDataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        line              = new Sys_Line();
                        line.ID           = new Guid(dt.Rows[i]["ID"].ToString());
                        line.LineName     = dt.Rows[i]["LineName"].ToString();
                        line.LineIP       = dt.Rows[i]["IPAddress"].ToString();
                        line.LinePort     = dt.Rows[i]["Port"].ToString();
                        line.UserName     = dt.Rows[i]["UserName"].ToString();
                        line.PassWord     = dt.Rows[i]["PassWord"].ToString();
                        line.DataBaseName = dt.Rows[i]["DataBaseName"].ToString();
                        line.Description  = dt.Rows[i]["Description"].ToString();
                        lst.Add(line);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("GetStatisticsLinesByIP error:" + ex.ToString());
            }

            return(lst);
        }
Exemplo n.º 2
0
 public StatisticsRunner(Sys_Line line)
 {
     LineName   = line.LineName;
     Port       = line.LinePort;
     IPAddress  = line.LineIP;
     DBAddress  = line.LineIP;
     DBUser     = line.UserName;
     DBPassword = line.PassWord;
     DBName     = line.DataBaseName;
     TimeSet    = ConfigurationManager.AppSettings["StatisticsTimeSpan"];
 }
Exemplo n.º 3
0
        public Sys_Line GetLineByID(Guid projectID)
        {
            Sys_Line  line = null;
            String    sql  = "SELECT LineName,ID,IPAddress,Port,UserName ,PassWord ,DataBaseName FROM dbo.sys_line WHERE ID='" + projectID + "'";
            DataTable dt   = GetDataTable(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                line              = new Sys_Line();
                line.ID           = new Guid(dt.Rows[0]["ID"].ToString());
                line.LineName     = dt.Rows[0]["LineName"].ToString();
                line.LineIP       = dt.Rows[0]["IPAddress"].ToString();
                line.LinePort     = dt.Rows[0]["Port"].ToString();
                line.UserName     = dt.Rows[0]["UserName"].ToString();
                line.PassWord     = dt.Rows[0]["PassWord"].ToString();
                line.DataBaseName = dt.Rows[0]["DataBaseName"].ToString();
            }
            return(line);
        }
Exemplo n.º 4
0
        public List <Sys_Line> GetMQWSLinesByIP(string IP)
        {
            List <Sys_Line> lst = new List <Sys_Line>();

            try
            {
                Sys_Line line = null;
                String   sql  = "SELECT ID,LineName,IPAddress,Port,UserName ,PassWord ,DataBaseName,Description,JSDWCode,StartUpload,TestRoomCodeMap,ModuleCodeMap,UploadAddress FROM dbo.sys_line WHERE IsActive=1 ";
                //logger.Error("GetUploadLines sql:"+sql);
                DataTable dt = GetDataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        line                 = new Sys_Line();
                        line.ID              = new Guid(dt.Rows[i]["ID"].ToString());
                        line.LineName        = dt.Rows[i]["LineName"].ToString();
                        line.LineIP          = dt.Rows[i]["IPAddress"].ToString();
                        line.LinePort        = dt.Rows[i]["Port"].ToString();
                        line.UserName        = dt.Rows[i]["UserName"].ToString();
                        line.PassWord        = dt.Rows[i]["PassWord"].ToString();
                        line.DataBaseName    = dt.Rows[i]["DataBaseName"].ToString();
                        line.Description     = dt.Rows[i]["Description"].ToString();
                        line.JSDWCode        = dt.Rows[i]["JSDWCode"].ToString();
                        line.StartUpload     = int.Parse(dt.Rows[i]["StartUpload"].ToString());
                        line.TestRoomCodeMap = dt.Rows[i]["TestRoomCodeMap"].ToString();
                        line.ModuleCodeMap   = dt.Rows[i]["ModuleCodeMap"].ToString();
                        line.UploadAddress   = dt.Rows[i]["UploadAddress"].ToString();
                        lst.Add(line);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("GetUploadLinesByIP error:" + ex.ToString());
            }

            return(lst);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新一条线的所有模板、表单、公式等信息
        /// </summary>
        /// <param name="lineID"></param>
        /// <returns></returns>
        public Boolean UpdateLine(Guid lineID, List <String> moduleIDs, Boolean isModule, Boolean isRelationSheet)
        {
            List <String> files = new List <String>();

            if (isModule)
            {
                files.Add("sys_dictionary");
                files.Add("sys_formulas");
                files.Add("sys_module");
                files.Add("sys_stadium_config");
                files.Add("sys_module_config");
                if (isRelationSheet)
                {
                    files.Add("sys_module_sheet");
                }
            }
            else
            {
                files.Add("sys_sheet");
            }
            Sys_Line line        = GetLineByID(lineID);
            Boolean  flag        = true;
            String   moduleIDStr = "'" + String.Join("','", moduleIDs.ToArray()) + "'";

            if (line != null)
            {
                try
                {
                    String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "update/" + line.LineName);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    List <String> list = new List <string>();
                    foreach (String tbName in files)
                    {
                        list.Add(Path.Combine(path, tbName + ".dat"));
                        flag = flag && OutPutFile(tbName, path, moduleIDStr, isModule);
                    }
                    String zipFile = Path.Combine(path, line.LineName + ".zip");
                    if (File.Exists(zipFile))
                    {
                        File.Delete(zipFile);
                    }
                    flag = flag && JZCommonHelper.CreateZipFile(list, zipFile);
                    if (flag)
                    {
                        FileStream stream = null;
                        JZFile     f      = new JZFile();
                        f.FileName = line.LineName + ".zip";
                        stream     = new FileInfo(zipFile).OpenRead();
                        Byte[] buffer = new Byte[stream.Length];
                        stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                        f.FileType = "all";
                        f.FileData = buffer;
                        stream.Close();
                        String lineAddress = "net.tcp://" + line.LineIP + ":" + line.LinePort + "/TransferService.svc";
                        object obj         = CallRemoteServerMethod(lineAddress, "Yqun.BO.BusinessManager.dll", "RunUpdate",
                                                                    new Object[] { f, line.LineIP, line.UserName, line.PassWord, isModule, isRelationSheet });
                        flag = Convert.ToBoolean(obj);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("generate updated file error for line " + line.LineName + ": " + ex.Message);
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }
            return(flag);
        }