private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //添加你初始化的代码
            res = new LanguageResources();
            CommonModel commonModel = ReadIhasFileData.getInstance();

            if (!isCanLogin)
            {
                sessionContextHandler = new SessionContextHeandler(null, this);
            }
            sessionValidationStruct = new IMSApiSessionValidationStruct();
            sessionValidationStruct.stationNumber    = commonModel.Station;
            sessionValidationStruct.stationPassword  = "";
            sessionValidationStruct.user             = this.txtUserName.Text.Trim();
            sessionValidationStruct.password         = this.txtPassword.Text.Trim();
            sessionValidationStruct.client           = commonModel.Client;
            sessionValidationStruct.registrationType = commonModel.RegisterType;
            sessionValidationStruct.systemIdentifier = commonModel.Station;
            UserName = this.txtUserName.Text.Trim();

            LoginResult = imsapi.regLogin(sessionValidationStruct, out sessionContext);
            if (LoginResult == 0)
            {
                LogHelper.Info("api regLogin.(error code=" + LoginResult + ")");
            }
            else
            {
                LogHelper.Error("api regLogin.(error code=" + LoginResult + ")");
            }
            LogHelper.Info("Login end...");
            if (LoginResult != IMSApiDotNetConstants.RES_OK)
            {
                this.Invoke(new MethodInvoker(delegate
                {
                    SetStatusLabelText("api regLogin error.(error code=" + LoginResult + ")", 1);
                    SetControlStatus(true);
                }));
                return;
            }
            else
            {
                //add by qy 160614
                if (!VerifyUserTeam())
                {
                    this.Invoke(new MethodInvoker(delegate
                    {
                        SetControlStatus(true);
                    }));
                    return;
                }
                this.Invoke(new MethodInvoker(delegate
                {
                    this.Hide();
                    CloseSP();                                                                                //add by qy
                    MainView view = new MainView(this.txtUserName.Text.Trim(), DateTime.Now, sessionContext); //edit by qy
                    view.ShowDialog();
                }));
            }
        }
Exemple #2
0
        static LogHelper()
        {
            XDocument   config        = XDocument.Load("ApplicationConfig.xml");
            CommonModel commonModel   = ReadIhasFileData.getInstance();
            string      stationNumber = commonModel.Station;
            string      filePath      = Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
            string      _appDir       = Path.GetDirectoryName(filePath);

            log4net.GlobalContext.Properties["LogPath"] = @"C:\DMS_Log";//_appDir + @"\log";
            log4net.GlobalContext.Properties["LogName"] = stationNumber + "_1.log";
            log4net.Config.XmlConfigurator.Configure();
            localLog = log4net.LogManager.GetLogger("loggerLog4Net");
            Info("Application start...");
            Info(config);
        }
        public List <ParameterEntity> GetApplicationEntity()
        {
            entityList = new List <ParameterEntity>();
            string      filePath    = Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
            string      _appDir     = Path.GetDirectoryName(filePath);
            XDocument   config      = XDocument.Load(_appDir + @"\ApplicationConfig.xml");
            CommonModel commonModel = ReadIhasFileData.getInstance();
            XElement    xRoot       = config.Root;
            string      rootName    = commonModel.APPTYPE; //xRoot.Name.ToString();

            scope = commonModel.APPTYPE;
            ParameterEntity entityRoot = new ParameterEntity();

            entityRoot.PARAMETER_DESCRIPTION = rootName;
            entityRoot.PARAMETER_DISPLAYNAME = rootName;
            entityRoot.PARAMETER_DIMPATH     = "{CLUSTER,APPTYPE,APPID,STATION}";
            entityRoot.PARAMETER_NAME        = rootName;
            entityRoot.PARAMETER_PARENT_NAME = "Customer";
            entityRoot.PARAMETER_SCOPE       = scope;
            entityRoot.PARAMETER_TYPE_NAME   = "STRING";
            entityRoot.PARAMETER_VALUE       = "";
            entityList.Add(entityRoot);
            var firstLevelElts = xRoot.Elements();

            if (firstLevelElts.Count() > 0)
            {
                foreach (var item in firstLevelElts)
                {
                    string          subName = item.Name.ToString();
                    ParameterEntity entity  = new ParameterEntity();
                    entity.PARAMETER_DESCRIPTION = subName;
                    entity.PARAMETER_DISPLAYNAME = subName;
                    entity.PARAMETER_DIMPATH     = "{CLUSTER,APPTYPE,APPID,STATION}";
                    entity.PARAMETER_NAME        = rootName + "." + subName;
                    entity.PARAMETER_PARENT_NAME = rootName;
                    entity.PARAMETER_SCOPE       = scope;
                    entity.PARAMETER_TYPE_NAME   = "STRING";
                    entity.PARAMETER_VALUE       = "";
                    entityList.Add(entity);
                    GetDescendantEntity(item, rootName + "." + subName);
                }
                int count = entityList.Count();
            }
            return(entityList);
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //添加你初始化的代码
            res = new LanguageResources();
            CommonModel commonModel = ReadIhasFileData.getInstance();

            if (!isCanLogin)
            {
                if (logintype == 0)
                {
                    sessionContextHandler = new SessionContextHeandler(null, this);
                }
            }
            sessionValidationStruct = new IMSApiSessionValidationStruct();
            sessionValidationStruct.stationNumber    = commonModel.Station;
            sessionValidationStruct.stationPassword  = "";
            sessionValidationStruct.user             = this.txtUserName.Text.Trim();
            sessionValidationStruct.password         = this.txtPassword.Text.Trim();
            sessionValidationStruct.client           = commonModel.Client;
            sessionValidationStruct.registrationType = commonModel.RegisterType;
            sessionValidationStruct.systemIdentifier = commonModel.Station;
            UserName = this.txtUserName.Text.Trim();

            LoginResult = imsapi.regLogin(sessionValidationStruct, out sessionContext);
            if (LoginResult == 0)
            {
                LogHelper.Info("api regLogin.(error code=" + LoginResult + ")");
            }
            else
            {
                LogHelper.Error("api regLogin.(error code=" + LoginResult + ")");
            }
            LogHelper.Info("Login end...");
            if (LoginResult != IMSApiDotNetConstants.RES_OK)
            {
                this.Invoke(new MethodInvoker(delegate
                {
                    SetStatusLabelText("api regLogin error.(error code=" + LoginResult + ")", 1);
                    SetControlStatus(true);
                }));
                return;
            }
            else
            {
                if (logintype == 0)
                {
                    //add by qy 160614
                    if (!VerifyUserTeam())
                    {
                        this.Invoke(new MethodInvoker(delegate
                        {
                            SetControlStatus(true);
                        }));
                        return;
                    }
                    this.Invoke(new MethodInvoker(delegate
                    {
                        this.Hide();
                        if (config.LogInType == "COM" && serialPort.IsOpen)
                        {
                            serialPort.Close();
                        }
                        MainView view = new MainView(this.txtUserName.Text.Trim(), DateTime.Now, sessionContext);
                        view.ShowDialog();
                    }));
                }
                else
                {
                    if (!VerifyUserTeam())
                    {
                        this.Invoke(new MethodInvoker(delegate
                        {
                            SetControlStatus(true);
                        }));
                        return;
                    }
                    this.Invoke(new MethodInvoker(delegate
                    {
                        this.Hide();
                        if (logintype == 1)
                        {
                            if (!form.AddTransWO())
                            {
                                return;
                            }
                            form.errorHandler(0, form.Message("msg_add trans wo success"), "");
                        }
                        else if (logintype == 2)
                        {
                            if (!form.RemoveTransWO(RemoveWO))
                            {
                                return;
                            }
                            form.InitGetHasTransWO();
                            form.errorHandler(0, form.Message("msg_remove trans wo success"), "");
                        }
                        else if (logintype == 3)
                        {
                            form.ResetIPIStatus();
                        }
                        else if (logintype == 4) //班长确认
                        {
                            form.SupervisorConfirm(this.txtUserName.Text.Trim());
                        }
                        else if (logintype == 5) //IPQC确认
                        {
                            form.IPQCConfirm(this.txtUserName.Text.Trim());
                        }
                        if (config.LogInType == "COM" && serialPort.IsOpen)
                        {
                            serialPort.Close();
                            form.OpenScanPort();
                        }
                    }));
                }
            }
        }