コード例 #1
0
    static public List <DM_Factory> GetFactoryArray(ServerConnection conn, ref string strError)
    {
        if (conn == null)
        {
            conn = new ServerConnection();
        }
        //查询工厂信息
        PacketTable[] arrSendTable = new PacketTable[0];
        Packet        recvPacket   = conn.ExecuteCommand(4, arrSendTable);

        PacketTable[] arrRecvTable = conn.ReadTable(recvPacket);
        if (arrRecvTable == null)
        {
            strError = conn.ErrorMessage;
            return(null);
        }

        List <DM_Factory> arrFactory = new List <DM_Factory>();
        PacketTable       recvTable  = arrRecvTable[0];
        int nIndexFactoryName        = recvTable.GetFieldIndex("FactoryName");
        int nIndexDatabaseID         = recvTable.GetFieldIndex("DatabaseID");
        int nIndexServerID           = recvTable.GetFieldIndex("ServerID");

        for (int nRow = 0; nRow < recvTable.Rows; nRow++)
        {
            DM_Factory factory = new DM_Factory();
            factory.ServerID    = (int)recvTable.GetValue(nRow, nIndexServerID);
            factory.DatabaseID  = (int)recvTable.GetValue(nRow, nIndexDatabaseID);
            factory.FactoryName = (string)recvTable.GetValue(nRow, nIndexFactoryName);
            arrFactory.Add(factory);
        }

        return(arrFactory);
    }
コード例 #2
0
    public string GetSettingInfo(HttpContext context, ref string strError)
    {
        try
        {
            Export            handler           = new Export();
            SystemSettingInfo systemSettingInfo = new SystemSettingInfo();

            Period period = GlobalSession.Period;
            systemSettingInfo.LastNum  = period.LastNum;
            systemSettingInfo.DateFrom = period.DateFrom.ToString("yyyy-MM-dd");
            systemSettingInfo.DateTo   = period.DateTo.ToString("yyyy-MM-dd");

            systemSettingInfo.ArrayFactory = GetFactoryList();
            if (systemSettingInfo.ArrayFactory == null)
            {
                return(handler.Error("无法获取所有工厂信息"));
            }
            DM_Factory factory = GetFactory();

            if (factory == null)
            {
                return(handler.Error("无法获取工厂信息"));
            }
            systemSettingInfo.SelectFactory = factory.FactoryName;
            return(handler.Success(systemSettingInfo));
        }
        catch (Exception ex)
        {
            Export handler = new Export();
            return(handler.Error("错误:" + ex.Message));
        }
    }
コード例 #3
0
    //绑定零件ID信息
    protected void BindPartID(DM_Factory factory, List <ProjectInfo> arrProjectInfo)
    {
        string                 strError   = "";
        ServerConnection       conn       = new ServerConnection(factory.ServerID, factory.DatabaseID);
        List <DM_ModelProject> arrProject = CmdQuery.GetProjectArray(conn, ref strError);

        if (arrProject == null || arrProject.Count == 0)
        {
            return;
        }

        foreach (DM_ModelProject project in arrProject)
        {
            ProjectInfo curProject = null;
            foreach (ProjectInfo projectInfo in arrProjectInfo)
            {
                if (projectInfo.ProjectName == project.ProjectName)
                {
                    projectInfo.ProjectID = project.ProjectID;
                    curProject            = projectInfo;
                    break;
                }
            }

            //绑定所有标签中的零件ID
            if (curProject != null)
            {
                List <DM_ModelPart> arrPart = CmdQuery.GetPartArray(conn, project.ProjectID, ref strError);

                foreach (DM_ModelPart part in arrPart)
                {
                    for (int i = 0; i < curProject.Tags.Length; i++)
                    {
                        if (curProject.Tags[i].GetPartInfo() != null) //标签需要零件信息
                        {
                            PartInfo partInfo = curProject.Tags[i].GetPartInfo();
                            if (partInfo.PartName == part.PartName)
                            {
                                partInfo.PartID = part.PartID;
                            }
                        }
                        else if (curProject.Tags[i].GetPartArray() != null)  //标签需要零件数组信息
                        {
                            PartInfo[] arrPartInfo = curProject.Tags[i].GetPartArray();
                            for (int j = 0; j < arrPartInfo.Length; j++)
                            {
                                if (arrPartInfo[j].PartName == part.PartName)
                                {
                                    arrPartInfo[j].PartID = part.PartID;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #4
0
    //统计合格率和CII
    protected ProjectStatInfo Stat(DM_Factory factory, ProjectInfo projectInfo)
    {
        projectInfo.ClearData(); //清除旧的数据

        ProjectStatInfo statInfo = new ProjectStatInfo();

        statInfo.Tags = projectInfo.Tags;
        statInfo.URL  = GetImagURL(projectInfo.ImageURL);
        if (projectInfo.ProjectID == 0)
        {
            return(statInfo);
        }

        string           strError = "";
        ServerConnection conn     = new ServerConnection(factory.ServerID, factory.DatabaseID);

        for (int i = 0; i < statInfo.Tags.Length; i++)
        {
            if (statInfo.Tags[i].TagName == "PassrateChart")
            {
                StatPassrate(conn, projectInfo, (PassrateChartTag)statInfo.Tags[i], ref strError);
            }
            else if (statInfo.Tags[i].TagName == "CIIChart")
            {
                StatCII(conn, projectInfo, (CIIChartTag)statInfo.Tags[i], ref strError);
            }
            else if (statInfo.Tags[i].TagName == "KeyPartPassrateChart")
            {
                StatKeyPartPassrate(conn, projectInfo, (KeyPartPassrateChartTag)statInfo.Tags[i], ref strError);
            }
            else if (statInfo.Tags[i].TagName == "KeyPartCIIChart")
            {
                StatKeyPartCII(conn, projectInfo, (KeyPartCIIChartTag)statInfo.Tags[i], ref strError);
            }
            else if (statInfo.Tags[i].TagName == "SortChart")
            {
                StatSortClass(conn, projectInfo, (SortChartTag)statInfo.Tags[i], ref strError);
            }
            else if (statInfo.Tags[i].TagName == "Image")
            {
                SetImage((ImageTag)statInfo.Tags[i]);
            }
        }

        for (int i = 0; i < statInfo.Tags.Length; i++)
        {
            if (statInfo.Tags[i].TagName == "Label")
            {
                StatLabel(conn, projectInfo, (LabelTag)statInfo.Tags[i], ref strError);
            }
        }

        return(statInfo);
    }
コード例 #5
0
    public string GetAllProjectInfo(HttpContext context, ref string strError)
    {
        Export             handler     = new Export();
        ExportDataEx       export      = new ExportDataEx();
        DM_Factory         factory     = GetFactory();
        List <ProjectInfo> arrPartInfo = LoadProjectInfo(factory);

        export.Data = arrPartInfo;
        if (arrPartInfo == null)
        {
            return(handler.Error("零件信息为空"));
        }
        return(handler.Success(export));
    }
コード例 #6
0
    public string GetProjectInfo(HttpContext context, ref string strError)
    {
        int nProjectIndex = CommandTool.ReqInt(context, "ProjectIndex", 0);

        try
        {
            Export     handler = new Export();
            DM_Factory factory = GetFactory();
            if (factory == null)
            {
                return(handler.Error("无法获取工厂信息"));
            }

            List <ProjectInfo> arrProject = LoadProjectInfo(factory);
            if (arrProject == null || arrProject.Count == 0)
            {
                return(handler.Error("无法获取该工厂车型信息"));
            }

            if (nProjectIndex < 0)
            {
                nProjectIndex = -1;
            }
            if (nProjectIndex > arrProject.Count - 1)
            {
                nProjectIndex = arrProject.Count - 1;
            }

            int nPrevIndex = nProjectIndex > 0 ? nProjectIndex - 1 : -1;
            int nNextIndex = nProjectIndex < arrProject.Count - 1 ? nProjectIndex + 1 : -1;

            ProjectStatInfo statInfo = Stat(factory, arrProject[nProjectIndex]);
            statInfo.ProjectIndex     = nProjectIndex;
            statInfo.PrevProjectIndex = nPrevIndex;
            statInfo.NextProjectIndex = nNextIndex;

            string strInfo = handler.Success(statInfo);
            return(strInfo);
        }
        catch (System.Exception ex)
        {
            Export handler = new Export();
            return(handler.Error("错误:" + ex.Message));
        }
    }
コード例 #7
0
    //配置文件(或Session)中读取要显示的零件信息,并存储到Session中
    protected List <ProjectInfo> LoadProjectInfo(DM_Factory facrtory)
    {
        if (GlobalSession.ProjectInfo != null)
        {
            return(GlobalSession.ProjectInfo);
        }

        string             strFile        = HttpContext.Current.Server.MapPath("~\\Config\\ProjectConfig.xml");
        ProjectConfig      config         = new ProjectConfig();
        List <ProjectInfo> arrProjectInfo = config.ReadFile(strFile, facrtory.FactoryName);

        if (arrProjectInfo != null && arrProjectInfo.Count > 0)
        {
            BindPartID(facrtory, arrProjectInfo);

            GlobalSession.ProjectInfo = arrProjectInfo;
        }
        return(arrProjectInfo);
    }