Exemple #1
0
        private void txtClh_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                return;
            }

            if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z)
            {
                txtClh.Text           = txtClh.Text.ToUpper();
                txtClh.SelectionStart = txtClh.Text.Length;
            }

            if (e.KeyCode == Keys.Enter)
            {
                if (txtClh.Text.Length > 4)
                {
                    addCL(txtClh.Text);
                }
            }

            if (txtClh.Text.Length == 5)
            {
                string sql = "select B.CLH2 from ExportStorageOrder A,ExportStorageAcceptOrder B where A.ZFH=B.ZFH and (B.WCFlag is null or B.WCFlag<>2) and B.KW<>'' ";
                sql += " and B.CLH2 like '%" + txtClh.Text + "' and B.CKB='" + Global.sKb + "' and (A.JHH like '7%' or A.JHH like '8%' or A.JHH like '9%') ";
                sql += "and A.JHH='" + m_jhh + "' ";
                switch (m_cltype)
                {
                case 0:
                    sql += "and A.ZFH='" + m_zfh + "'";
                    break;

                case 1:
                    sql += "and B.LH='" + m_lh + "'";
                    break;

                case 2:
                    sql += "and A.HTH='" + m_hth + "'";
                    break;

                case 3:
                    sql += "and substring(B.CLH,1,6)='" + m_zph + "'";
                    break;

                default:
                    break;
                }


                DataTable dt = SqlCe.ExecuteQuery(sql);
                if (dt.Rows.Count == 1)
                {
                    txtClh.Text           = dt.Rows[0]["CLH2"].ToString();
                    txtClh.SelectionStart = txtClh.Text.Length;
                }
                else if (dt.Rows.Count > 1)
                {
                    lstCLH.Items.Clear();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        lstCLH.Items.Add(dt.Rows[i]["CLH2"].ToString());
                    }
                    lstCLH.Visible = true;
                }
                dt.Dispose();
            }
        }
Exemple #2
0
        private void CheckForApps()
        {
            try
            {
                if (SqlCe.GetAutoEnforceFlag())
                {
                    return;
                }

                var rApps = CcmUtils.RequiredApps;

                var allRequiredAppsApps = rApps.Where(x => !x.InstallState.Equals("Installed") && x.Deadline > DateTime.Now.AddMinutes(15)).ToList();

                if (allRequiredAppsApps.Count < 1)
                {
                    Globals.Log.Information($"Wmi didn't return any required applications at this time.");
                    return;
                }

                var appDeadline         = allRequiredAppsApps.OrderBy(x => x.Deadline).First().Deadline;
                var allSchedules        = SqlCe.GetAllSchedules();
                var showToast           = false;
                var featureUpdateExists = false;
                var dtNextServiceCycle  = CommonUtils.GetNextServiceCycleAsDateTime();

                foreach (var app in allRequiredAppsApps)
                {
                    if (allSchedules.Where(x => x.ObjectId.Trim().Equals(app.Id.Trim()) && x.Revision.Trim().Equals(app.Revision.Trim())).Any())
                    {
                        Globals.Log.Information($"Skipping toast for already scheduled application: '{app.Name}'");
                        continue;
                    }

                    if (dtNextServiceCycle < app.Deadline)
                    {
                        Globals.Log.Information($"Skipping toast for application covered by service cycle: '{app.Name}'");
                        continue;
                    }

                    if (app.EvaluationState == 12)
                    {
                        Globals.Log.Information($"Skipping toast for currently installing (possibly long-running) app '{app.Name}'");
                        continue;
                    }

                    if (app.IsIpuApplication)
                    {
                        featureUpdateExists = true;
                    }

                    showToast = true;
                }

                if (dtNextServiceCycle != null)
                {
                    if (dtNextServiceCycle <= appDeadline)
                    {
                        Globals.Log.Information($"Detected an upcoming service cycle, a Toast notification was suppressed.");
                        return;
                    }
                }

                if (showToast && UnsafeNativeMethods.IsUserLoggedOn() && !RegistryMethods.GetIpuIsRunning())
                {
                    if (!UnsafeNativeMethods.IsSessionLocked())
                    {
                        var arg = featureUpdateExists ? "/ToastIpu" : "/ToastApp";
                        UnsafeNativeMethods.Run(_userApp, $"{arg}", false);
                    }
                    else
                    {
                        Globals.Log.Information($"Detected a locked or non existing user session, a Toast notification was suppressed.");
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.Log.Error(ex.Message);
            }
        }
Exemple #3
0
        private void loadFrameLayout20(string sFrameID, string kz)
        {
            string sql = "";

            if (kz == "重")
            {
                sql = "select Location,CLH,Relative_X,Relative_Y,CLH,RKB,SteelWide,SteelDiameter from FrameLayout where FrameID='" + sFrameID + "' and Mold='20' order by Relative_X";
            }
            else
            {
                sql = "select Location,CLH,Relative_X,Relative_Y,CLH,CKB,SteelWide,SteelDiameter from FrameLayoutExp where FrameID='" + sFrameID + "' order by Relative_X";
            }

            DataTable dt = SqlCe.ExecuteQuery(sql);

            if (kz == "重")
            {
                int[] colIndex = new int[Global.curFrame.MaxRow];
                for (int i = 0; i < Global.curFrame.MaxRow; i++)
                {
                    colIndex[i] = 0;
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int X   = Convert.ToInt32(dt.Rows[i]["Relative_X"]);
                    int Y   = Convert.ToInt32(dt.Rows[i]["Relative_Y"]);
                    int row = Y / Global.curFrame.Space;
                    int col = colIndex[row] + 1;
                    if (col <= 2)
                    {
                        CoilPoint p = new CoilPoint(sFrameID, row, col);
                        if (Global.coils.ContainsKey(p))
                        {
                            Global.coils[p].X        = X;
                            Global.coils[p].Y        = Y;
                            Global.coils[p].diameter = dt.Rows[i]["SteelDiameter"].ToString();
                            Global.coils[p].wide     = dt.Rows[i]["SteelWide"].ToString();
                        }
                        else
                        {
                            Coil coil = new Coil(p, "");
                            coil.X        = X;
                            coil.Y        = Y;
                            coil.diameter = dt.Rows[i]["SteelDiameter"].ToString();
                            coil.wide     = dt.Rows[i]["SteelWide"].ToString();
                            Global.coils.Add(p, coil);
                        }
                        colIndex[row] = col;
                    }
                }
            }
            else if (kz == "空" || kz == "拼")
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int       X        = Convert.ToInt32(dt.Rows[i]["Relative_X"]);
                    int       Y        = Convert.ToInt32(dt.Rows[i]["Relative_Y"]);
                    string    Location = dt.Rows[i]["Location"].ToString();
                    string    clh      = dt.Rows[i]["CLH"].ToString();
                    string    kb       = dt.Rows[i]["CKB"].ToString();
                    CoilPoint p        = new CoilPoint(sFrameID, Location);
                    if (clh.Length > 8)
                    {
                        dtFrame.Rows[p.row][p.col] = clh.Substring(clh.Length - 8, 8);
                    }
                    else
                    {
                        dtFrame.Rows[p.row][p.col] = clh;
                    }
                    //if (Global.coils.ContainsKey(p))
                    //{
                    //    Global.coils[p].X = X;
                    //    Global.coils[p].Y = Y;
                    //    Global.coils[p].clh = clh;
                    //    Global.coils[p].kb = kb;
                    //    Global.coils[p].diameter = dt.Rows[i]["SteelDiameter"].ToString();
                    //    Global.coils[p].wide = dt.Rows[i]["SteelWide"].ToString();
                    //}
                    //else
                    if (Global.coils.ContainsKey(p) == false)
                    {
                        Coil coil = new Coil(p, "");
                        coil.X        = X;
                        coil.Y        = Y;
                        coil.clh      = clh;
                        coil.kb       = kb;
                        coil.diameter = dt.Rows[i]["SteelDiameter"].ToString();
                        coil.wide     = dt.Rows[i]["SteelWide"].ToString();
                        Global.coils.Add(p, coil);
                    }
                }
            }
            dt.Dispose();
        }
Exemple #4
0
        private bool RestartRequired()
        {
            if (CcmUtils.IsUpdatesEnforcing() || CcmUtils.IsAppsEnforcing())
            {
                Globals.Log.Information("Detected ongoing installation, suppressing reboot checks.");
                return(false);
            }

            var checks = _settings.RestartChecks;

            var updatesStatus = _rebootServicingCheck && !SqlCe.GetUpdatesInstallStatusFlag();

            if (!updatesStatus)
            {
                checks.ComponentBasedServicing = updatesStatus;
                checks.PendingFileOperations   = updatesStatus;
                checks.WindowsUpdate           = updatesStatus;
            }

            var result = RebootChecker.RebootRequired(checks);
            var rs     = SqlCe.GetRestartSchedule();

            if (!result.Any)
            {
                SqlCe.DeleteRestartSchedule();
            }
            else if (rs != null)
            {
                if (rs.IsAcknowledged)
                {
                    return(false);
                }
            }

            if (result.ConfigMgrClient && (_allowFastReboot || !UnsafeNativeMethods.IsUserLoggedOn()))
            {
                SqlCe.DeleteRestartSchedule();

                SqlCe.SetRestartSchedule(new RestartSchedule
                {
                    DeadLine       = DateTime.Now.MinutePrecission().AddMinutes(5),
                    RestartTime    = DateTime.Now.MinutePrecission().AddMinutes(5),
                    IsAcknowledged = true,
                    IsExpress      = true,
                });

                return(result.Any);
            }

            if (result.Any && _rebootToastDelay-- <= 1)
            {
                if (rs == null)
                {
                    SqlCe.SetRestartSchedule(new RestartSchedule
                    {
                        DeadLine       = DateTime.Today.AddDays(_serviceSettings.RestartDeadlineAfterInstall.InDays).AddHours(_serviceSettings.RestartDeadlineAfterInstall.AtHour),
                        RestartTime    = DateTime.Today.AddDays(_serviceSettings.RestartDeadlineAfterInstall.InDays).AddHours(_serviceSettings.RestartDeadlineAfterInstall.AtHour),
                        IsAcknowledged = false,
                        IsExpress      = false,
                    });
                }

                if (SqlCe.GetAutoEnforceFlag())
                {
                    Globals.Log.Information($"Detected auto enforce flag 'true', skipping reboot toast.");
                }
                else if (!UnsafeNativeMethods.IsSessionLocked())
                {
                    UnsafeNativeMethods.Run(_userApp, $"/ToastReboot", false);
                }
                else
                {
                    Globals.Log.Information($"Detected a locked or non existing user session, a Toast notification was suppressed.");
                }

                _rebootToastDelay = _fiveMinuteIntervalsPerDay / _serviceSettings.NumberOfRestartToastsPerDay;
            }

            return(result.Any);
        }
Exemple #5
0
        private void CheckForSups()
        {
            if (_supCheckBlocked || SqlCe.GetAutoEnforceFlag())
            {
                return;
            }

            try
            {
                var sups = CcmUtils.Updates;

                if (sups.Count() == 0)
                {
                    _lastFoundSups = null;
                    Globals.Log.Information("No updates available at this time");
                    return;
                }

                _lastFoundSups = _lastFoundSups ?? DateTime.Now;

                if (_lastFoundSups > DateTime.Now.AddMinutes(-5))
                {
                    return;
                }

                var jsonSups = JsonConvert.SerializeObject(sups);
                SqlCe.UpdateSupData("STD", jsonSups);

                Globals.Log.Information($"Found {sups.Count()} updates available for scheduling");

                var nextSchedule     = SqlCe.GetNextSupSchedule();
                var supdeadline      = sups.OrderBy(y => y.Deadline).First().Deadline;
                var nextServiceCycle = SqlCe.GetServiceSchedule();

                if (nextSchedule.Id != 0)
                {
                    Globals.Log.Information($"Next update enforcement time '{nextSchedule.EnforcementTime}' deadline for available updates = '{supdeadline}', 'toasting' user - reschedule necessary");

                    if (nextSchedule.EnforcementTime <= supdeadline)
                    {
                        Globals.Log.Information($"Next update enforcement time '{nextSchedule.EnforcementTime}' deadline for available updates = '{supdeadline}', skipping 'toast'");
                        return;
                    }
                    else
                    {
                        SqlCe.SetEnforcedFlag(nextSchedule.Id);
                    }
                }

                var dtNextServiceCycle = CommonUtils.GetNextServiceCycleAsDateTime();

                if (dtNextServiceCycle != null)
                {
                    if (dtNextServiceCycle <= supdeadline)
                    {
                        Globals.Log.Information($"Detected an upcoming service cycle, a Toast notification was suppressed.");
                        return;
                    }
                }

                if (UnsafeNativeMethods.IsUserLoggedOn() && !RegistryMethods.GetIpuIsRunning())
                {
                    if (!UnsafeNativeMethods.IsSessionLocked())
                    {
                        UnsafeNativeMethods.Run(_userApp, $"/ToastSup", false);
                    }
                    else
                    {
                        Globals.Log.Information($"Detected a locked or non existing user session, a Toast notification was suppressed.");
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.Log.Error(ex.Message);
            }
        }
Exemple #6
0
        private void EnforcementTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            _enforcementTimer.Stop();
            _enforcementTimer.Interval = AutoInterval();
            _enforcementTimer.Start();

            SaveAssignmentsToDB();

            if (SqlCe.GetAutoEnforceFlag())
            {
                Globals.Log.Information("Checking Service cycle status.");

                var reqApps        = CcmUtils.RequiredApps.Where(x => !x.InstallState.Equals("Installed") && x.EvaluationState == 3 && !x.IsIpuApplication).ToList();
                var pendingUpdates = CcmUtils.Updates.ToList();

                if (reqApps.Count() == 0 && pendingUpdates.Count() == 0 && !(CcmUtils.IsUpdatesEnforcing() || CcmUtils.IsAppsEnforcing()) && !RebootChecker.RebootRequired(new RestartChecks()
                {
                    PendingFileOperations = true
                }).Any)
                {
                    Globals.Log.Information("Service cycle - Resetting Auto Enforce Flag, nothing left to enforce and no reboot pending.");
                    SqlCe.SetAutoEnforceFlag(false);
                    _pipeClient.Send("SetBlue", "01DB94E3-90F1-43F4-8DDA-8AEAF6C08A8E");
                    _iEnforcementInterval = 5;

                    if (UnsafeNativeMethods.IsUserLoggedOn())
                    {
                        UnsafeNativeMethods.Run(_userApp, $"/ToastServiceEndNotification", false);
                    }

                    if (_settings.LegalNotice.UseLegalNotice)
                    {
                        Reg.RemoveLegalNotice();
                    }

                    return;
                }
                else if (CcmUtils.IsRebootPending().HardRebootPending&& !(CcmUtils.IsUpdatesEnforcing() || CcmUtils.IsAppsEnforcing()))
                {
                    Globals.Log.Information("Service cycle - Pending hard reboot detected - restarting computer.");

                    if (UnsafeNativeMethods.IsUserLoggedOn())
                    {
                        UnsafeNativeMethods.Run(_userApp, $"/ToastServiceRestartNotification", false);
                        RestartComputer();
                    }
                    else
                    {
                        RestartComputer(true);
                    }

                    return;
                }
                else if (!(CcmUtils.IsUpdatesEnforcing() || CcmUtils.IsAppsEnforcing()) && (reqApps.Count() != 0 || pendingUpdates.Count() != 0))
                {
                    Globals.Log.Information("Service cycle - Cycle running but required installations not enforcing - pushing enforcement.");
                    CcmUtils.InstallAllAppsAndUpdates();
                    return;
                }
                else if (reqApps.Count() == 0 && pendingUpdates.Count() == 0 && !(CcmUtils.IsUpdatesEnforcing() || CcmUtils.IsAppsEnforcing()) && RebootChecker.RebootRequired(new RestartChecks()
                {
                    PendingFileOperations = true
                }).Any)
                {
                    Globals.Log.Information("Service cycle - nothing left to enforce but a pending reboot (Any) was detected - restarting computer.");

                    if (UnsafeNativeMethods.IsUserLoggedOn())
                    {
                        UnsafeNativeMethods.Run(_userApp, $"/ToastServiceRestartNotification", false);
                        RestartComputer();
                    }
                    else
                    {
                        RestartComputer(true);
                    }

                    return;
                }

                Globals.Log.Information("Service cycle not yet finished.");

                return;
            }

            if (CcmUtils.IsUpdatesEnforcing())
            {
                return;
            }

            var rs = SqlCe.GetRestartSchedule();

            if (rs != null)
            {
                if (rs.RestartTime <= DateTime.Now)
                {
                    SqlCe.DeleteRestartSchedule();

                    if (UnsafeNativeMethods.IsUserLoggedOn())
                    {
                        UnsafeNativeMethods.Run(_userApp, $"/ShowRestartWindow", false);
                        Globals.Log.Information($"Launched Restart Window.");
                    }
                    else
                    {
                        RestartComputer(true);
                    }

                    return;
                }
            }

            RestartRequired();

            if (CcmUtils.IsRebootPending().HardRebootPending)
            {
                Globals.Log.Warning($"Detected pending hard reboot - postponing further enforcement(s)");
                return;
            }

            try
            {
                var serviceSchedule = CommonUtils.GetNextServiceCycleAsDateTime();

                if (serviceSchedule != null)
                {
                    if (serviceSchedule <= DateTime.Now)
                    {
                        SqlCe.SetAutoEnforceFlag(true);
                        _pipeClient.Send("SetRed", "01DB94E3-90F1-43F4-8DDA-8AEAF6C08A8E");
                        CcmUtils.InstallAllAppsAndUpdates();
                        _iEnforcementInterval = 1;
                        _enforcementTimer.Stop();
                        _enforcementTimer.Interval = AutoInterval();
                        _enforcementTimer.Start();

                        if (_settings.LegalNotice.UseLegalNotice)
                        {
                            Reg.SetLegalNotice(_settings.LegalNotice);
                        }

                        SqlCe.DeleteServiceSchedule();
                        SqlCe.UpdateSupData("STD", string.Empty);

                        if (UnsafeNativeMethods.IsUserLoggedOn())
                        {
                            UnsafeNativeMethods.Run(_userApp, $"/ToastServiceInitNotification", false);
                        }

                        Globals.Log.Information($"Found and triggered a Service Schedule (Install All)");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.Log.Error(ex.Message);
            }

            try
            {
                var sch = SqlCe.GetDueSchedules();

                if (sch.Count() > 0)
                {
                    Globals.Log.Information($"Found {sch.Count()} objects due for enforcement.");
                    sch.ForEach(x => _objectsToEnforce.Add(x));
                }
                else
                {
                    Globals.Log.Information($"No scheduled enforcements found at this time");
                }
            }
            catch (Exception ex)
            {
                Globals.Log.Error(ex.Message);
            }

            try
            {
                if (CcmUtils.IsApplicationEvaluationRequired())
                {
                    CcmUtils.EvaluateAllPolicies();
                }
            }
            catch (Exception ex)
            {
                Globals.Log.Error(ex.Message);
            }
        }
Exemple #7
0
        protected override void OnStart(string[] args)
        {
            Globals.Log.Information("Service is starting");
            WaitForCcmExec();
            WaitForCmClientOperational();
            SqlCe.MaintainDatabase();
            _pipeServer = new PipeServer();
            _pipeServer.Listen("3A2CD127-D069-4CD5-994D-C481F4760748");
            _pipeServer.PipeMessage += PipeServer_PipeMessage;

            _settings = SettingsUtils.Settings;

            if (_settings.IsDefault)
            {
                SettingsUtils.WriteSettingsToFile();
                Globals.Log.Warning("Failed to load settings from file, created new 'Settings.xml'. If this is the first start after installation, it's expected.");
            }

            _serviceSettings = _settings.ServiceConfig;

            if (SqlCe.GetAutoEnforceFlag())
            {
                Globals.Log.Information("Auto Enforce Flag is true, enforcing all.");

                _iEnforcementInterval = 1;
                CcmUtils.InstallAllAppsAndUpdates();

                if (_settings.LegalNotice.UseLegalNotice)
                {
                    Reg.SetLegalNotice(_settings.LegalNotice);
                }
            }

            SqlCe.SetUpdatesInstallStatusFlag(false);
            SaveAssignmentsToDB();

            _enforcementTimer.AutoReset = false;
            _enforcementTimer.Elapsed  += EnforcementTimer_Elapsed;
            _enforcementTimer.Interval  = AutoInterval();
            _enforcementTimer.Start();

            _ccmWmiEventListener = new CcmWmiEventListener();
            _ccmWmiEventListener.OnNewApplication += CcmWmiEventListener_OnNewApplication;
            _ccmWmiEventListener.OnNewUpdate      += CcmWmiEventListener_OnNewUpdate;

            FeedEnforcementsPump();
            EnforcePump();
            ConfirmPump();

            if (_serviceSettings.HardSuppressSCNotifications)
            {
                RenameSCNotification();
            }

            if (UnsafeNativeMethods.IsUserLoggedOn())
            {
                UnsafeNativeMethods.Run(_trayApp, null, false);
            }

            Globals.Log.Information("Service sucessfully started.");
        }
Exemple #8
0
        private void SaveAssignmentsToDB()
        {
            var assignments = CcmUtils.GetAssignments();

            SqlCe.SaveAssignmentsToDB(assignments);
        }
Exemple #9
0
        private void EnforcePump()
        {
            Task.Run(() =>
            {
                while (true)
                {
                    try
                    {
                        var scheduledobject = _objectsToEnforce.Take();
                        _allowFastReboot    = scheduledobject.IsAutoSchedule;

                        SqlCe.SetEnforcedFlag(scheduledobject.Id);

                        if (scheduledobject.EnforcementType.Equals("APP"))
                        {
                            var cmapp = CcmUtils.GetSpecificApp(scheduledobject);

                            if (cmapp == null)
                            {
                                Globals.Log.Warning($"A scheduled enforcement '{scheduledobject.ObjectId}/{scheduledobject.Revision}' could not be performed. Deployment has been removed or changed?");
                                continue;
                            }

                            if (scheduledobject.Action.Equals("I"))
                            {
                                if (cmapp.IsIpuApplication && _settings.IpuApplication.ShowDialog1 && UnsafeNativeMethods.IsUserLoggedOn())
                                {
                                    if (UnsafeNativeMethods.Run(_userApp, "/ShowIpuDialog1", true) == 0)
                                    {
                                        //RegistryMethods.SetIpuIsRunning();
                                        //CcmUtils.InstallApplication(cmapp);
                                        InstallIpuApplication(cmapp);
                                        Globals.Log.Information($"User pressed 'Install' feature updated '{cmapp.Name}'");
                                    }
                                    else
                                    {
                                        SqlCe.DeleteAppSchedule(cmapp.Id, cmapp.Revision);
                                        Globals.Log.Warning($"User aborted a scheduled Windows feature upgrade '{cmapp.Name}'");
                                    }
                                }
                                else if (cmapp.IsIpuApplication)
                                {
                                    //RegistryMethods.SetIpuIsRunning();
                                    InstallIpuApplication(cmapp);
                                    //CcmUtils.InstallApplication(cmapp);
                                }
                                else
                                {
                                    CcmUtils.InstallApplication(cmapp);
                                }
                            }
                            else if (scheduledobject.Action.Equals("R"))
                            {
                                CcmUtils.RepairApplication(cmapp);
                            }
                            else
                            {
                                CcmUtils.UninstallApplication(cmapp);
                            }
                        }
                        else if (scheduledobject.EnforcementType.Equals("SUP"))
                        {
                            Globals.Log.Information("Installing updates, disabling component servicing reboot detection until rebooted.");
                            _rebootServicingCheck = false;
                            Set_SupCheckBlocked();
                            SqlCe.UpdateSupData("STD", string.Empty);
                            CcmUtils.ExecuteInstallUpdates(true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Globals.Log.Error(ex.Message);
                    }
                }
            });
        }
Exemple #10
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            frmMessage frmMessage = new frmMessage();

            frmMessage.ShowDialog("是否需要发送出库消帐电文?", "提示", "是", "否");
            bool ret = frmMessage.ret;

            frmMessage.Dispose();

            if (ret)
            {
                lblInfo.Text    = "发送中...";
                btnSend.Enabled = false;
                Global.sKjh     = txtKjh.Text;
                Global.sDq      = cboDq.SelectedIndex;

                string data = System.DateTime.Now.ToString("yyyyMMddHHmmss") + ";";
                data += Global.sBb + ";";
                data += Global.sKb + ";";
                data += Global.sUserId + ";";
                data += txtJxh.Text + ";";
                data += cboDq.Text + txtKjh.Text + ";";
                data += txtYb1.Text + ";";
                data += txtYb2.Text + ";";
                if (cboPcbj.SelectedIndex == 0)
                {
                    data += "N;";
                }
                else
                {
                    data += "Y;";
                }
                data += Global.sZyq + ";";
                data += ";";//直装标志 0,1

                string    sql  = "select * from ExportStorageAcceptOrder where CLH in (" + clhs + ") order by ZFH ";
                DataTable dt   = SqlCe.ExecuteQuery(sql);
                string    gram = "";
                string    zfh  = "";
                if (dt.Rows.Count > 0)
                {
                    zfh = dt.Rows[0]["ZFH"].ToString();
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (zfh != dt.Rows[i]["ZFH"].ToString())
                    {
                        gram = gram.Substring(0, gram.Length - 1);
                        Business.SendText(Business.msg.Package("ZDWX56", data + gram));
                        gram = "";
                        zfh  = dt.Rows[i]["ZFH"].ToString();
                    }
                    gram += dt.Rows[i]["CLH"].ToString() + ";" + dt.Rows[i]["SCANTIME"].ToString() + ";";
                }

                if (dt.Rows.Count > 0)
                {
                    gram = gram.Substring(0, gram.Length - 1);
                    Business.SendText(Business.msg.Package("ZDWX56", data + gram));
                }
                dt.Dispose();

                Business.InvokeMethod(this.Owner, "OutStore", new object[] { });
                lblInfo.Text = "发送成功!";

                Global.frmCurrent = this.Owner;
                this.Owner.Show();
                this.Owner = null;
                this.Close();
            }
        }
Exemple #11
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = Globals.Settings.PlannerSettings;

            var hours = _is24HourEnvironement ? _l24hours : _l12hours;

            HourMo.ItemsSource = hours;
            HourTu.ItemsSource = hours;
            HourWe.ItemsSource = hours;
            HourTh.ItemsSource = hours;
            HourFr.ItemsSource = hours;
            HourSa.ItemsSource = hours;
            HourSu.ItemsSource = hours;

            MinuteMo.ItemsSource = _minutes;
            MinuteTu.ItemsSource = _minutes;
            MinuteWe.ItemsSource = _minutes;
            MinuteTh.ItemsSource = _minutes;
            MinuteFr.ItemsSource = _minutes;
            MinuteSa.ItemsSource = _minutes;
            MinuteSu.ItemsSource = _minutes;

            AmPmMo.ItemsSource = _ampm;
            AmPmTu.ItemsSource = _ampm;
            AmPmWe.ItemsSource = _ampm;
            AmPmTh.ItemsSource = _ampm;
            AmPmFr.ItemsSource = _ampm;
            AmPmSa.ItemsSource = _ampm;
            AmPmSu.ItemsSource = _ampm;

            HourMo.SelectedIndex = 0;
            HourTu.SelectedIndex = 0;
            HourWe.SelectedIndex = 0;
            HourTh.SelectedIndex = 0;
            HourFr.SelectedIndex = 0;
            HourSa.SelectedIndex = 0;
            HourSu.SelectedIndex = 0;

            MinuteMo.SelectedIndex = 0;
            MinuteTu.SelectedIndex = 0;
            MinuteWe.SelectedIndex = 0;
            MinuteTh.SelectedIndex = 0;
            MinuteFr.SelectedIndex = 0;
            MinuteSa.SelectedIndex = 0;
            MinuteSu.SelectedIndex = 0;

            AmPmMo.SelectedIndex = 0;
            AmPmTu.SelectedIndex = 0;
            AmPmWe.SelectedIndex = 0;
            AmPmTh.SelectedIndex = 0;
            AmPmFr.SelectedIndex = 0;
            AmPmSa.SelectedIndex = 0;
            AmPmSu.SelectedIndex = 0;

            AmPmMo.Visibility = _is24HourEnvironement ? Visibility.Hidden : Visibility.Visible;
            AmPmTu.Visibility = _is24HourEnvironement ? Visibility.Hidden : Visibility.Visible;
            AmPmWe.Visibility = _is24HourEnvironement ? Visibility.Hidden : Visibility.Visible;
            AmPmTh.Visibility = _is24HourEnvironement ? Visibility.Hidden : Visibility.Visible;
            AmPmFr.Visibility = _is24HourEnvironement ? Visibility.Hidden : Visibility.Visible;
            AmPmSa.Visibility = _is24HourEnvironement ? Visibility.Hidden : Visibility.Visible;
            AmPmSu.Visibility = _is24HourEnvironement ? Visibility.Hidden : Visibility.Visible;

            var json = SqlCe.GetAutoEnforceSchedules();

            if (!string.IsNullOrEmpty(json))
            {
                SetSchedules(json);
            }
        }
Exemple #12
0
        private void btnQd_Click(object sender, EventArgs e)
        {
            if (Global.sUserId != "")
            {
                frmMain frmMain = new frmMain();
                Global.frmCurrent = frmMain;
                frmMain.Owner     = this;
                frmMain.Show();
                this.Hide();
                return;
            }

            if (txtGh.Text == "")
            {
                new frmMessage().ShowDialog("请输入工号!", "提示");
                return;
            }

            if (txtGh.Text != "BS")
            {
                if (txtMm.Text == "")
                {
                    new frmMessage().ShowDialog("请输入密码!", "提示");
                    return;
                }
            }

            if (cboBb.SelectedIndex == -1)
            {
                new frmMessage().ShowDialog("请选择班别!", "提示");
                return;
            }
            if (cboZyq.SelectedIndex == -1)
            {
                new frmMessage().ShowDialog("请选择作业区!", "提示");
                return;
            }

            string sGh = txtGh.Text;
            string sMm = txtMm.Text;
            string sBb = "";

            if (cboBb.Text == "白")
            {
                sBb = "22";
            }
            else if (cboBb.Text == "夜")
            {
                sBb = "21";
            }
            string sZyq = cboZyq.Text;

            if (cboZyq.Text == "甲")
            {
                sZyq = "1";
            }
            else if (cboZyq.Text == "乙")
            {
                sZyq = "2";
            }
            else if (cboZyq.Text == "丙")
            {
                sZyq = "3";
            }
            else if (cboZyq.Text == "丁")
            {
                sZyq = "4";
            }

            if (sGh != "BS")
            {
                string    sql = "select PWD from UserInf where UserID='" + sGh + "'";
                DataTable dt  = SqlCe.ExecuteQuery(sql);
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["PWD"].ToString() == sMm)
                    {
                        Global.sUserId   = sGh;
                        Global.sPassword = sMm;
                        Global.sBb       = sBb;
                        Global.sZyq      = sZyq;
                    }
                }
                dt.Dispose();

                if (Global.sUserId != "")//登陆成功
                {
                    sql  = "insert into UserLogin (UserID,Class,StartTime) values (";
                    sql += "'" + sGh + "',";
                    sql += "'" + sBb + "',";
                    //sql += "'" + sHch + "',";
                    sql += "'" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    sql += ")";
                    SqlCe.ExecuteNonQuery(sql);

                    //Business.SaveConfig(Global.appPath + @"\config.xml", sHch);
                    //Global.sHch = sHch;
                }
                else
                {
                    new frmMessage().ShowDialog("工号或者密码错误!", "提示");
                }

                if (Global.sUserId != "")
                {
                    if (Global.sDebug == "False")
                    {
                        Business.SendText(Business.msg.Package("ZDUA09", System.DateTime.Today.ToString("yyyyMMdd") + ";" + sBb + ";" + sGh + ";" + sZyq + ";" + System.DateTime.Now.ToString("yyyyMMddHHmmss")));
                    }

                    frmMain frmMain = new frmMain();
                    Global.frmCurrent = frmMain;
                    frmMain.Owner     = this;
                    frmMain.Show();
                    this.Hide();
                }
            }
            else
            {
                Global.sUserId   = sGh;
                Global.sPassword = sMm;
                Global.sBb       = sBb;
                Global.sZyq      = sZyq;

                frmMain frmMain = new frmMain();
                Global.frmCurrent = frmMain;
                frmMain.Owner     = this;
                frmMain.Show();
                this.Hide();
            }
        }