예제 #1
0
        void CreateTabSheets(GlobalVars.SettingsBaseListClass CurrB)
        {
            string SettingsName = CurrB.SettingsName;

            foreach (TabPage CurTab in tabControl1.TabPages)
            {
                if (CurTab.Text == SettingsName)
                {
                    return;
                }
            }
            //"tab"+tabControl1.TabPages.Count.ToString();;
            string  tabName = "tab" + tabControl1.TabPages.Count.ToString();
            TabPage NewTab  = new TabPage(tabName);

            NewTab.Text = SettingsName;
            tabControl1.TabPages.Add(NewTab);
            CurrB.TabPage = NewTab;

            SetupDataGridView(NewTab, CurrB);


            CurrB.StatusThr = new StatusThread();
            CurrB.StatusThr.SettingsBase = CurrB;
            CurrB.StatusThr.EditDGV     += EditDGVEvent;
            //CurrB.StatusThr.EditTabPageText += EditTabPageTextEvent;
            CurrB.StatusThr.Start();
        }
예제 #2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string SettingsName = BaseList.SelectedItem.ToString();

            this.Text = BaseList.SelectedItem.ToString().Trim();
            // bool NotFound = true;
            if (SettingsName != "")
            {
                if (GlobalVars.SettingsBaseList != null)
                {
                    foreach (GlobalVars.SettingsBaseListClass CurrS in GlobalVars.SettingsBaseList)
                    {
                        if (CurrS.SettingsName == SettingsName)
                        {
                            SettingsBase = CurrS;
                            //NotFound = true;
                            break;
                        }
                    }
                }
                //if (NotFound)
                //{
                //    SettingsBase = new GlobalVars.SettingsBaseListClass();
                //    SettingsBase.Settings = new GlobalVars.Settings();
                //    SettingsBase.Settings.SettingsName = SettingsName;
                //    SettingsBase.NodesLists.SettingsName = SettingsName;
                //    if (GlobalVars.SettingsBaseList == null)
                //        GlobalVars.SettingsBaseList = new System.Collections.Generic.List<GlobalVars.SettingsBaseListClass>();

                //    GlobalVars.SettingsBaseList.Add(SettingsBase);
                //}
                FillControlsFromGlobalVars();
            }
        }
예제 #3
0
        private void NewSettings(String NewSettingsName, String SourceSettingsName = "")
        {
            GlobalVars.SettingsBaseListClass NewSettingsBase = new GlobalVars.SettingsBaseListClass();
            GlobalVars.Settings   NewSettings = new GlobalVars.Settings();
            GlobalVars.NodesLists NewBN       = new GlobalVars.NodesLists();

            BaseList.Items.Add(NewSettingsName);

            NewSettingsBase.SettingsName = NewSettingsName;
            NewBN.SettingsName           = NewSettingsName;
            NewSettings.SettingsName     = NewSettingsName;

            NewBN.Nodes = InitalizeNodes();

            NewSettingsBase.NodesLists = NewBN;
            NewSettingsBase.Settings   = NewSettings;



            if (SourceSettingsName != "")
            {
                if (GlobalVars.SettingsBaseList == null)
                {
                    GlobalVars.SettingsBaseList = new System.Collections.Generic.List <GlobalVars.SettingsBaseListClass>();
                }
                foreach (GlobalVars.SettingsBaseListClass CurrS in GlobalVars.SettingsBaseList)
                {
                    if (CurrS.SettingsName == SourceSettingsName)
                    {
                        NewSettingsBase.Settings.AutoExchange                   = CurrS.Settings.AutoExchange;
                        NewSettingsBase.Settings.Base                           = CurrS.Settings.Base;
                        NewSettingsBase.Settings.Cluster                        = CurrS.Settings.Cluster;
                        NewSettingsBase.Settings.DirUpd                         = CurrS.Settings.DirUpd;
                        NewSettingsBase.Settings.ExchangeDir                    = CurrS.Settings.ExchangeDir;
                        NewSettingsBase.Settings.ExchangeTemporaryDir1C         = CurrS.Settings.ExchangeTemporaryDir1C;
                        NewSettingsBase.Settings.Password                       = CurrS.Settings.Password;
                        NewSettingsBase.Settings.StartAutoExchangeAfterStarting = CurrS.Settings.StartAutoExchangeAfterStarting;
                        NewSettingsBase.Settings.ThisNodeCode                   = "";
                        NewSettingsBase.Settings.TimeExchange                   = CurrS.Settings.TimeExchange;
                        NewSettingsBase.Settings.TimeKillUsers                  = CurrS.Settings.TimeKillUsers;
                        NewSettingsBase.Settings.TimeOut                        = CurrS.Settings.TimeOut;
                        NewSettingsBase.Settings.TimePause                      = CurrS.Settings.TimePause;
                        NewSettingsBase.Settings.TimePauseDnUp                  = CurrS.Settings.TimePauseDnUp;
                        NewSettingsBase.Settings.TimePauseStatus                = CurrS.Settings.TimePauseStatus;
                        NewSettingsBase.Settings.TimeUpLoading                  = CurrS.Settings.TimeUpLoading;
                        NewSettingsBase.Settings.User                           = CurrS.Settings.User;
                        NewSettingsBase.Settings.Version1C                      = CurrS.Settings.Version1C;
                        NewSettingsBase.Settings.TranElCount                    = CurrS.Settings.TranElCount;
                        break;
                    }
                }
            }
            GlobalVars.SettingsBaseList.Add(NewSettingsBase);
            SettingsBase           = NewSettingsBase;
            BaseList.SelectedIndex = BaseList.Items.Count - 1;
            //FillControlsFromGlobalVars();
        }
예제 #4
0
 void AutoExchangeThreadStart(GlobalVars.SettingsBaseListClass SettingsBase)
 {
     SettingsBase.AutoThr                  = new AutoExchangeThread();
     SettingsBase.AutoThr.ThreadName       = "AUTO";
     SettingsBase.AutoThr.ClosingThread   += ClosingThreadDelegate;
     SettingsBase.AutoThr.SettingsBase     = SettingsBase;
     SettingsBase.AutoThr.AddLog          += AddLogEvent;
     SettingsBase.AutoThr.EditDGV         += EditDGVEvent;
     SettingsBase.AutoThr.EditTabPageText += EditTabPageTextEvent;
     SettingsBase.AutoThr.Start();
 }
예제 #5
0
 private void CheckedOnOff(GlobalVars.SettingsBaseListClass CurrentSettingsBase, bool checkedMode = true)
 {
     lock (this)
     {
         if (CurrentSettingsBase.DGV != null)
         {
             foreach (DataGridViewRow element in CurrentSettingsBase.DGV.Rows)
             {
                 element.Cells["Checked"].Value = checkedMode;
             }
         }
     }
 }
예제 #6
0
        void ClosingThread(GlobalVars.SettingsBaseListClass SettingsBase, int Mode, string ThreadName)
        {
            SettingsBase.Settings.Exchange_launched = false;
            if (ThreadName == "AUTO")
            {
                SettingsBase.AutoThr.ClosingThread   -= ClosingThreadDelegate;
                SettingsBase.AutoThr.AddLog          -= AddLogEvent;
                SettingsBase.AutoThr.EditDGV         -= EditDGVEvent;
                SettingsBase.AutoThr.EditTabPageText -= EditTabPageTextEvent;
            }
            else
            {
                UnsubscribeThreadEvents(ThreadName);
            }

            EditTabPageText(SettingsBase);


            switch (Mode)
            {
            case 1:
                break;  // загрузка

            case 11:    // после загрузки надо включить автообмен
                SettingsBase.Settings.Exchange_launched = true;
                SettingsBase.Settings.AutoExchange      = true;
                AutoExchangeThreadStart(SettingsBase);

                break;

            case 2:
                break;  // выгрузка

            case 22:    // после выгрузки надо включить автообмен
                SettingsBase.Settings.Exchange_launched = true;
                SettingsBase.Settings.AutoExchange      = true;
                AutoExchangeThreadStart(SettingsBase);
                break;

            case 0:
            default:
                break;
            }
            SetTabText();
        }
예제 #7
0
        void EditTabPageText(GlobalVars.SettingsBaseListClass SettingsBase)
        {
            try
            {
                string Data;
                if (SettingsBase.Settings.AutoExchange)
                {
                    Data = SettingsBase.SettingsName + " Автообмен";
                }
                else
                {
                    Data = SettingsBase.SettingsName;
                }

                if (SettingsBase.TabPage.Text.Trim() != Data.Trim())
                {
                    SettingsBase.TabPage.Text = Data;
                }
            }
            catch (Exception) { }
        }
예제 #8
0
        public void FillGlobalVarsFromControls()
        {
            bool NotOk = true;

            string SettingsName = BaseList.SelectedItem.ToString().Trim();

            //SettingsBase = new GlobalVars.SettingsBaseListClass();
            SettingsBase.SettingsName = SettingsName;
            //SettingsBase.Settings = new GlobalVars.Settings();
            //SettingsBase.NodesLists = new GlobalVars.NodesLists();

            SettingsBase.Settings.Cluster     = Cluster.Text;
            SettingsBase.Settings.Base        = Base.Text;
            SettingsBase.Settings.User        = User.Text;
            SettingsBase.Settings.Password    = Password.Text;
            SettingsBase.Settings.Version1C   = Version1C.Text;
            SettingsBase.Settings.TranElCount = Convert.ToInt16(TranElCount.Text);
            SettingsBase.Settings.DirUpd      = DirUpd.Text;

            SettingsBase.Settings.StartAutoExchangeAfterStarting    = StartAutoExchangeAfterStarting.Checked;
            SettingsBase.Settings.KillUserSessionBeforeAutoExchange = KillUserSessionBeforeAutoExchange.Checked;

            SettingsBase.Settings.ExchangeDir            = ExchangeDir.Text;
            SettingsBase.Settings.ExchangeTemporaryDir1C = ExchangeTemporaryDir1C.Text;
            SettingsBase.Settings.UploadingAutoExchange  = UploadingAutoExchange.Checked;

            SettingsBase.Settings.ExchangePlan = ExchangePlan.Text;
            SettingsBase.Settings.ThisNodeCode = ThisNodeCode.Text;

            SettingsBase.Settings.TimeExchange  = TimeExchange.Text;
            SettingsBase.Settings.TimeKillUsers = TimeKillUsers.Text;
            SettingsBase.Settings.TimeUpLoading = TimeUpLoading.Text;

            SettingsBase.Settings.TimeOut         = Convert.ToInt16(TimeOut.Text);
            SettingsBase.Settings.TimePause       = Convert.ToInt16(TimePause.Text) * 1000;
            SettingsBase.Settings.TimePauseDnUp   = Convert.ToInt16(TimePauseDnUp.Text) * 1000;
            SettingsBase.Settings.TimePauseStatus = Convert.ToInt16(TimePauseStatus.Text) * 1000;

            if (GlobalVars.SettingsBaseList == null)
            {
                GlobalVars.SettingsBaseList = new System.Collections.Generic.List <GlobalVars.SettingsBaseListClass>();
            }

            foreach (GlobalVars.SettingsBaseListClass CurrS in GlobalVars.SettingsBaseList)
            {
                if (CurrS.SettingsName == SettingsName)
                {
                    CurrS.Settings   = SettingsBase.Settings;
                    CurrS.NodesLists = SettingsBase.NodesLists;
                    NotOk            = false;
                    break;
                }
            }

            if (NotOk)
            {
                GlobalVars.SettingsBaseListClass NewS = new GlobalVars.SettingsBaseListClass();
                NewS.SettingsName = SettingsBase.SettingsName;
                NewS.Settings     = SettingsBase.Settings;
                NewS.NodesLists   = SettingsBase.NodesLists;

                GlobalVars.SettingsBaseList.Add(NewS);
            }
        }
예제 #9
0
        void StatusWatch(GlobalVars.SettingsBaseListClass CurrentSettingsBase)
        {
            //return;
            foreach (FileSystemWatcher FSW in statusWatchers)
            {
                FSW.EnableRaisingEvents = false;
                FSW.Changed            -= OnChanged;
                FSW.Created            -= OnChanged;
                FSW.Deleted            -= OnChanged;
                FSW.Renamed            -= OnChanged;
            }
            Array.Resize(ref statusWatchers, 0);
            Array.Resize(ref statusWatchersDir, 0);

            string FileFlag, FileFlagR, StatusFlag, FileFlagRZ, FileFlagZ, ExchangeDir;

            if (CurrentSettingsBase == null)
            {
                return;
            }

            foreach (DataGridViewRow Row in CurrentSettingsBase.DGV.Rows)
            {
                if (Row.Cells["Code"].Value == null)
                {
                    continue;
                }
                if (Row.Cells["Code"].Value.ToString().Trim() == "")
                {
                    continue;
                }
                ExchangeDir = Row.Cells["Dir"].Value.ToString().Trim();
                if (ExchangeDir == "")
                {
                    ExchangeDir = CurrentSettingsBase.Settings.ExchangeDir;
                }

                FileFlag  = ExchangeDir + CurrentSettingsBase.Settings.ThisNodeCode + "-" + Row.Cells["Code"].Value.ToString() + ".txt";
                FileFlagZ = FileFlag.Replace(".txt", ".zip");

                FileFlagR  = ExchangeDir + Row.Cells["Code"].Value.ToString() + "-" + CurrentSettingsBase.Settings.ThisNodeCode + ".txt";
                FileFlagRZ = FileFlagR.Replace(".txt", ".zip");

                StatusFlag = "";
                if (File.Exists(FileFlag))
                {
                    if (File.Exists(FileFlagZ))
                    {
                        StatusFlag = "Выгружено";
                    }
                    else
                    {
                        StatusFlag = "Загрузка в приемнике";
                    }
                }
                if (File.Exists(FileFlagR))
                {
                    if (StatusFlag != "")
                    {
                        StatusFlag = "куча мала";
                    }
                    else
                    {
                        StatusFlag = "Можно загружать";
                    }
                }
                //EditDGV(Row.Index, "Status", StatusFlag, SettingsBase.DGV); //Row.Cells["StatusFlag"].Value = StatusFlag;
                EditDGV(Row.Index, "StatusFlag", StatusFlag, CurrentSettingsBase.DGV, CurrentSettingsBase);

                bool NoFSW = true;
                foreach (string FSWD in statusWatchersDir)
                {
                    if (FSWD == ExchangeDir)
                    {
                        NoFSW = false;
                        break;
                    }
                }
                if (NoFSW)
                {
                    try
                    {
                        FileSystemWatcher StatusWatcher = new FileSystemWatcher();


                        StatusWatcher.Path = ExchangeDir;

                        /* Watch for changes in LastAccess and LastWrite times, and
                         * the renaming of files or directories. */
                        StatusWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
                                                     | NotifyFilters.FileName | NotifyFilters.DirectoryName;
                        //// Only watch text files.
                        //StatusWatcher.Filter = "*.txt";

                        // Add event handlers.
                        StatusWatcher.Changed += new FileSystemEventHandler(OnChanged);
                        StatusWatcher.Created += new FileSystemEventHandler(OnChanged);
                        StatusWatcher.Deleted += new FileSystemEventHandler(OnChanged);
                        StatusWatcher.Renamed += new RenamedEventHandler(OnChanged);



                        Array.Resize(ref statusWatchers, statusWatchers.Length + 1);
                        Array.Resize(ref statusWatchersDir, statusWatchersDir.Length + 1);

                        statusWatchersDir[statusWatchersDir.Length - 1] = ExchangeDir;
                        statusWatchers[statusWatchers.Length - 1]       = StatusWatcher;
                    }
                    catch (Exception ee)
                    {
                    }
                }
            }

            foreach (FileSystemWatcher FSW in statusWatchers)
            {
                FSW.EnableRaisingEvents = true;
            }
        }
예제 #10
0
 void EditTabPageTextEvent(GlobalVars.SettingsBaseListClass SettingsBase)
 {
     this.BeginInvoke(new EditTabPageTextDelegate(EditTabPageText), new object[] { SettingsBase });
 }
예제 #11
0
 void EditDGVEvent(int row, string column, string Data, DataGridView DGV, GlobalVars.SettingsBaseListClass SettingsBase)
 {
     this.BeginInvoke(new EditDGVDelegate(EditDGV), new object[] { row, column, Data, DGV, SettingsBase });
 }
예제 #12
0
        void EditDGV(int row, string column, string Data, DataGridView DGV, GlobalVars.SettingsBaseListClass SettingsBase)
        {
            //GlobalVars.CurrentSettingsBase.DGV
            try
            {
                if (row > -1)
                {
                    string CompoundState = "";
                    string Status        = "";
                    string StatusFlag    = "";
                    if (DGV.Rows[row].Cells[column].Value == null)
                    {
                        lock (this) DGV.Rows[row].Cells[column].Value = Data;
                    }
                    else
                    {
                        if (!(DGV.Rows[row].Cells[column].Value.ToString().Trim() == Data))
                        {
                            lock (this) DGV.Rows[row].Cells[column].Value = Data;
                        }
                    }
                    if (DGV.Rows[row].Cells["StatusFlag"].Value != null)
                    {
                        StatusFlag = DGV.Rows[row].Cells["StatusFlag"].Value.ToString().Trim();
                    }
                    if (DGV.Rows[row].Cells["Status"].Value != null)
                    {
                        Status = DGV.Rows[row].Cells["Status"].Value.ToString().Trim();
                    }
                    if ((Status != "") && (StatusFlag != ""))
                    {
                        CompoundState = Status + " - " + StatusFlag;
                    }
                    else
                    {
                        CompoundState = Status != "" ? Status : "" + StatusFlag != "" ? StatusFlag : "";
                    }

                    //TabPage.Text
                    try
                    {
                        if (Status == "Загрузка" || Status == "Выгрузка")
                        {
                            string TabPageText;
                            if (SettingsBase.Settings.AutoExchange)
                            {
                                TabPageText = SettingsBase.SettingsName + " Автообмен";
                            }
                            else
                            {
                                TabPageText = SettingsBase.SettingsName;
                            }
                            TabPageText = TabPageText + " - " + Status;
                            if (SettingsBase.TabPage.Text.Trim() != TabPageText)
                            {
                                SettingsBase.TabPage.Text = TabPageText;
                            }
                        }
                    }
                    catch (Exception) { }
                    //TabPage.Text

                    if (DGV.Rows[row].Cells["CompoundState"].Value != null)
                    {
                        if (DGV.Rows[row].Cells["CompoundState"].Value.ToString().Trim() != CompoundState)
                        {
                            lock (this) DGV.Rows[row].Cells["CompoundState"].Value = CompoundState;
                        }
                    }
                }
            }
            catch (ArgumentException) { }
            catch (Exception) { }
        }
예제 #13
0
 void ClosingThreadDelegate(GlobalVars.SettingsBaseListClass SettingsBase, int Mode, string ThreadName)
 {
     this.BeginInvoke(new TheadCloseDelegate(ClosingThread), new object[] { SettingsBase, Mode, ThreadName });
 }
예제 #14
0
        //private void DataGridV_MouseDoubleClick(object sender, MouseEventArgs e)
        //{
        //    if (DataGridV.Columns[DataGridV.CurrentCell.ColumnIndex].Name == "StatusFlag")
        //    {
        //        string dir = DataGridV.Rows[DataGridV.CurrentCell.RowIndex].Cells["Dir"].Value.ToString();
        //        if (dir == "") dir = GlobalVars.ExchangeDir;
        //        System.Diagnostics.Process.Start("explorer", @dir);
        //    }
        //}


        private void SetupDataGridView(TabPage NewTab, GlobalVars.SettingsBaseListClass CurrB)
        {
            DataGridView DGV = new DataGridView();

            DGV.Name               = NewTab + "_DGV";
            DGV.Dock               = System.Windows.Forms.DockStyle.Top;
            DGV.Location           = new System.Drawing.Point(3, 3);
            DGV.Size               = new System.Drawing.Size(499, 343);
            DGV.TabIndex           = 0;
            DGV.RowTemplate.Height = 18;

            Splitter Spl = new Splitter();

            Spl.Name      = NewTab + "_Spl";
            Spl.BackColor = System.Drawing.SystemColors.MenuHighlight;
            Spl.Dock      = System.Windows.Forms.DockStyle.Top;
            Spl.Location  = new System.Drawing.Point(3, 346);
            Spl.Size      = new System.Drawing.Size(499, 12);
            Spl.TabIndex  = 1;
            Spl.TabStop   = false;

            RichTextBox RTB = new RichTextBox();

            RTB.Name = NewTab + "_RTB";

            RTB.Dock     = System.Windows.Forms.DockStyle.Fill;
            RTB.Location = new System.Drawing.Point(3, 358);
            RTB.Size     = new System.Drawing.Size(499, 29);
            RTB.TabIndex = 2;
            RTB.Text     = "";

            NewTab.Controls.Add(RTB);
            NewTab.Controls.Add(Spl);
            NewTab.Controls.Add(DGV);

            NewTab.Location = new System.Drawing.Point(4, 22);
            NewTab.Padding  = new System.Windows.Forms.Padding(3);
            NewTab.Size     = new System.Drawing.Size(505, 532);
            NewTab.TabIndex = 0;
            NewTab.UseVisualStyleBackColor = true;

            CurrB.DGV = DGV;
            CurrB.RTB = RTB;

            DGV.MouseDoubleClick             += new System.Windows.Forms.MouseEventHandler(DataGrid_MouseDoubleClick);
            DGV.CurrentCellDirtyStateChanged += new System.EventHandler(DataGrid_CurrentCellDirtyStateChanged);
            DGV.ShowEditingIcon    = false;
            DGV.AllowUserToAddRows = false;

            GlobalVars.SettingsBaseListClass CurrSet = GM.GetSettings(CurrB.SettingsName);
            if (CurrSet.SettingsName == "")
            {
                return;
            }

            if (CurrSet.NodesLists != null)
            {
                if (CurrSet.NodesLists.Nodes != null)
                {
                    lock (this)
                    {
                        DGV.Columns.Clear();
                        DGV.DataSource = CurrSet.NodesLists.Nodes;

                        DGV.MultiSelect = false;
                        GM.SetHeaderDGV(DGV);
                    }
                }
            }
        }