예제 #1
0
 /// <summary>
 /// Uruchamia formularz mastera
 /// </summary>
 private void StartMaster()
 {
     currentForm             = masterController.GetForm();
     currentForm.Switch     += SwitchToSlave;
     currentForm.FormClosed += ExitApp;
     currentForm.Show();
 }
예제 #2
0
 /// <summary>
 /// Uruchamia formularz slave'a
 /// </summary>
 private void StartSlave()
 {
     currentForm             = slaveController.GetForm();
     currentForm.Switch     += SwitchToMaster;
     currentForm.FormClosed += ExitApp;
     currentForm.Show();
 }
예제 #3
0
        private static XElement ToTable(CommonForm input)
        {
            // The template will wrap this element in a table to allow for the template to use it's own attributes for the table.
            // The span tag will (should be) ignored since it is inside a table.
            XElement returnElement = new XElement("span");

            string html = "";

            // Add first List<string> as table headers
            html += "<tr>";
            foreach (string columnHeader in input.Headers)
            {
                html += "<th>" + columnHeader + "</th>";
            }
            html += "</tr>";

            // Add rest of List<strings> as table cell values
            foreach (List <string> row in input.Body)
            {
                html += "<tr>";
                foreach (string value in row)
                {
                    html += "<td>" + value + "</td>";
                }
                html += "</tr>";
            }

            returnElement.Value = html;

            return(returnElement);
        }
    public MyTopScreen(bool first_param, string second_param)
    {
        CommonForm   commonGridForm = new CommonForm(this);
        DataGridView dataGridView1  = commonGridForm.dataGridView1;

        _commonAttributForm = commonAttributForm;
        InitializeComponent();
        this.TabPage1.Controls.Add(dataGridView1);
    }
예제 #5
0
        private static CommonForm FromCsv(string input, string[] returnHeaders, string[] returnHeaderNames)
        {
            CommonForm commonForm = new CommonForm();

            input = input.Trim();

            string[]   rows                = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            string[]   receivedHeaders     = rows[0].Split(',');
            List <int> returnHeaderIndexes = new List <int>();

            int latitudeIndex  = Array.IndexOf(receivedHeaders, receivedHeaders.Where(header => header.ToLower() == "latitude").FirstOrDefault());
            int longitudeIndex = Array.IndexOf(receivedHeaders, receivedHeaders.Where(header => header.ToLower() == "longitude").FirstOrDefault());

            // Add column names as first List<string> in returnValue
            for (int i = 0; i < returnHeaders.Length; i++)
            {
                int indexOfReturnHeader = Array.IndexOf(receivedHeaders, returnHeaders[i]);
                returnHeaderIndexes.Add(indexOfReturnHeader);
                commonForm.Headers.Add(returnHeaderNames[i]);
            }

            // Add each row of data as a new List<string> in result
            for (int row = 1; row < rows.Length; row++)
            {
                string[]      rowValues = rows[row].Split(',');
                List <string> newRow    = new List <string>();
                if (rowValues.Length == receivedHeaders.Length)
                {
                    foreach (int index in returnHeaderIndexes)
                    {
                        if (index != -1)
                        {
                            newRow.Add(rowValues[index]);
                        }
                        else
                        {
                            newRow.Add("field not found");
                        }
                    }
                    commonForm.Body.Add(newRow);

                    if (latitudeIndex != -1 && longitudeIndex != -1)
                    {
                        double latitude;
                        double.TryParse(rowValues[latitudeIndex], out latitude);
                        commonForm.Latitudes.Add(latitude);

                        double longitude;
                        double.TryParse(rowValues[longitudeIndex], out longitude);
                        commonForm.Longitudes.Add(longitude);
                    }
                }
            }

            commonForm.Body = commonForm.Body.Where(list => list.Count > 0).ToList();
            return(commonForm);
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            projGuid = Request["ProjGuid"] ?? "";
            CommonForm form = new CommonForm();

            //费用类型
            form.SetDropDownListValue(CostType, "BBD8C56C-87E1-4C34-9B01-D5A79FA794F9", true);
            Json       = ef.getData(projGuid, true);
            EarlyJson  = ef.getEarInvestData(projGuid, true);
            EstOutJson = ef.getOutsideData(projGuid);
        }
예제 #7
0
        public static XElement GetStructureLocationInformation(XElement element)
        {
            try
            {
                string url = element.Value.Trim();
                Log.Debug(url);
                string userName           = (string)element.Attribute("userName");
                string password           = (string)element.Attribute("password");
                string domain             = (string)element.Attribute("domain");
                string authenticationType = (string)element.Attribute("authenticationType");

                string queryResultType = (string)element.Attribute("queryResultType") ?? "htmlcsv";
                string elementType     = (string)element.Attribute("returnElementType") ?? "span";

                string[] returnHeaders     = ((string)element.Attribute("returnFields") ?? "").Split(',');
                string[] returnHeaderNames = ((string)element.Attribute("returnFieldNames") ?? "").Split(',');

                string makeGoogleMapsLinkString = (string)element.Attribute("makeGoogleMapsLink") ?? "false";
                bool   makeGoogleMapsLink;
                if (!bool.TryParse(makeGoogleMapsLinkString, out makeGoogleMapsLink))
                {
                    makeGoogleMapsLink = false;
                }

                ICredentials credential = null;
                if (userName != null && password != null && domain != null && authenticationType != null)
                {
                    NetworkCredential networkCredential = new NetworkCredential(userName, password, domain);

                    Log.Debug($"userName: {userName}, password: {password}, domain: {domain}");

                    CredentialCache cache = new CredentialCache();
                    cache.Add(new Uri(url), authenticationType, networkCredential);
                    credential = cache;
                }

                // If queryResult is formatted in html, we should decode that to a regular string
                bool   decode        = queryResultType.ToLower().Contains("html");
                string structureInfo = GetStructureInfo(url, decode, credential);

                CommonForm intermediateResult = queryResultType.Contains("csv") ? FromCsv(structureInfo, returnHeaders, returnHeaderNames) : new CommonForm();


                return(elementType == "table" ? ToTable(intermediateResult) : elementType == "span" ? ToSpan(intermediateResult, makeGoogleMapsLink) : element);
            }
            catch (Exception e)
            {
                Log.Debug(e.Message + "\nStackTrace\n" + e.StackTrace);
                return(element);
            }
        }
예제 #8
0
        private static string ToFormat(CommonForm input, string headerFormat, string rowFormat)
        {
            object[] headerData = input.Headers.AsEnumerable <object>().ToArray();
            string   header     = string.Format(headerFormat, headerData);

            List <string> rows = input.Body
                                 .Select(rowData => rowData.AsEnumerable <object>().ToArray())
                                 .Select(rowData => string.Format(rowFormat, rowData))
                                 .ToList();

            List <string> lines = new[] { header }.Concat(rows).ToList();

            return(string.Join(Environment.NewLine, lines));
        }
예제 #9
0
 private void ShowAbout()
 {
     aboutInfo.Copyright   = ProgramSettings.Default.Copyright;
     aboutInfo.ProductName = ProgramSettings.Default.ProductName;
     aboutInfo.Version     = ProgramSettings.Default.Version;
     aboutInfo.Website     = ProgramSettings.Default.WebSite;
     using (CommonForm fm = new CommonForm())
     {
         UCAbout ucAbout = new UCAbout();
         ucAbout.SetDeviceId("Device ID: " + settings.DeviceAddress);
         ucAbout.SetAboutInfo(aboutInfo);
         fm.AddControlForDialog(ucAbout, "About");
         fm.ShowDialog();
     }
 }
예제 #10
0
        private static XElement ToSpan(CommonForm input, bool makeGoogleMapsLink)
        {
            XElement returnElement = new XElement("span");

            string html = "";

            if (makeGoogleMapsLink)
            {
                string latitude  = input.Latitudes.FirstOrDefault().ToString("###.######");
                string longitude = input.Longitudes.FirstOrDefault().ToString("###.######");
                html = "<a href = 'https://www.google.com/maps/@?api=1&map_action=map&center=" + latitude + "," + longitude + "&zoom=21&basemap=satellite'>" + input.Body.FirstOrDefault()?.FirstOrDefault() + "</a>";
            }
            else
            {
                html = input.Body.FirstOrDefault()?.FirstOrDefault();
            }

            returnElement.Value = html;
            return(returnElement);
        }
예제 #11
0
        private string ObtainPasswordFromSettingsOrUx()
        {
            if (!String.IsNullOrEmpty(syncSettings.Password))
            {
                return(syncSettings.Password);
            }

            using (CommonForm fm = new CommonForm())
            {
                UCPassword ucPassword = new UCPassword();
                fm.AddControlForDialog(ucPassword, "Password");
                if (fm.ShowDialog() == DialogResult.OK)
                {
                    return(ucPassword.Password);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #12
0
        public static bool ShowModal(ApplicationSettingsBase settings)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            using (CommonForm fm = new CommonForm())
            {
                UcOptions ucOptions = new UcOptions(settings);
                fm.AddControlForDialog(ucOptions, "Options");
                if (fm.ShowDialog() == DialogResult.OK)
                {
                    settings.Save();
                    return true;
                }
                else
                {
                    settings.Reload();
                    return false;
                }
            }

        }
예제 #13
0
        /// <summary>
        /// Create a form for application containing UcMultiSyncMain.
        /// And this form can remember its own location in multiscreen.
        /// </summary>
        /// <returns></returns>
        public static Form CreateMainForm(SyncSettingsBase settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings", "How could settings be null?");
            }
            CommonForm form = new CommonForm();

            form.ShowInTaskbar = true;
            //  form.AutoSize = true;/// Because this form is used as main form.
            // AutoSize can not work properly probably the autosize takes effects
            // before UcMultiSyncMain is loaded.
            //   form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            form.Icon  = Properties.Resources.syncIcon;
            form.Load += delegate(object sender, EventArgs e)
            {
                try
                {
                    UcMultiSyncMain uc = new UcMultiSyncMain(settings);
                    form.AddControl(uc, ProgramSettings.Default.ProductName);
                    // form.AutoSize = true;//not working either
                }
                catch (System.Configuration.ConfigurationErrorsException exception)
                {
                    MessageBox.Show("Configuration has problem: " + e.ToString() + "~" + exception.Message);
                }
            };

            MultiScreenHelper.RefineLocation(form, ProgramSettings.Default.Location, ProgramSettings.Default.ScreenDeviceName);
            form.FormClosing += delegate(object sender, System.Windows.Forms.FormClosingEventArgs e)
            {
                ProgramSettings.Default.Location         = form.Location;
                ProgramSettings.Default.ScreenDeviceName = System.Windows.Forms.Screen.FromControl(form).DeviceName;
                ProgramSettings.Default.Save();
            };
            return(form);
        }
예제 #14
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FileConfig.ReadFile();
            try
            {
                try
                {
                    if (FileConfig.config.updateapi != "")
                    {
                        Updater.checkversion();
                        if (Updater.ready.Count() > 0)
                        {
                            DialogResult dlr = MessageBox.Show("Sẵn sàng cho cật nhập", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                            if (dlr == DialogResult.OK)
                            {
                                UpdaterForm upd = new UpdaterForm();
                                upd.ShowDialog();
                                return;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }

                if (!FileConfig.config.connectsuccess)
                {
                    CommonForm cf = new CommonForm();
                    cf.signal = 0;
                    Application.Run(cf);
                }
                else if (FileConfig.config.connectsuccess)
                {
                    using (var context = new ControllerModel())
                    {
                        if (context.Database.Exists())
                        {
                            if (!UserController.countUser())
                            {
                                CommonForm cf = new CommonForm();
                                cf.signal = 1;
                                Application.Run(cf);
                            }
                        }
                        else
                        {
                            BackupFile buf = new BackupFile();
                            buf.ShowDialog();
                        }
                    }

                    Application.Run(new LoginForm());
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                BackupFile buf = new BackupFile();
                buf.ShowDialog();
            }
        }