Exemple #1
0
        private static Sites ReadCsvFile(string siteListFile)
        {
            Regex regex = new Regex(@"(?<SamID>\S+),"
                + @"(?<SiteID>\S+),"
                + @"(?<SiteName>[^,]+),"
                + @"(?<Type>[^,]+),"
                + @"(?<Longitude>[+-]?\d+(\.\d*)?),"
                + @"(?<Latitude>[+-]?\d+(\.\d*)?),"
                + @"(?<BSC>\S+),"
                + @"(?<RNC>\S+)");

            Match match;
            Site site;
            Sites sites = new Sites();
            if (!File.Exists(siteListFile))
                return sites;

            try
            {
                using (FileStream fs = new FileStream(siteListFile, FileMode.Open, FileAccess.Read))
                {
                    using (StreamReader sr = new StreamReader(siteListFile, Encoding.Default))
                    {
                        fs.Seek(0, SeekOrigin.Begin);
                        sr.ReadLine();  //skip head line
                        string line = sr.ReadLine();
                        while (line != null)
                        {
                            match = regex.Match(line);
                            if (!match.Success)
                                break;

                            site = new Site();
                            site.SamID = match.Groups["SamID"].Value;
                            site.SiteID = match.Groups["SiteID"].Value;
                            site.SiteName = match.Groups["SiteName"].Value;
                            site.SiteType = match.Groups["Type"].Value;
                            site.Longitude = double.Parse(match.Groups["Longitude"].Value);
                            site.Latitude = double.Parse(match.Groups["Latitude"].Value);
                            site.BSC = match.Groups["BSC"].Value;
                            site.RNC = match.Groups["RNC"].Value;
                            sites.Add(site);

                            line = sr.ReadLine();
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                throw e;
            }
            finally
            {

            }

            return sites;
        }
Exemple #2
0
        private void SiteForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!mIsNew && !mAllowUpdate)
                return;

            if (mOKInvoked)
            {
                mOKInvoked = false;

                if (SiteIdEditor.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Please input site Id !");
                    SiteIdEditor.Focus();
                    e.Cancel = true;
                    return;
                }

                if (mSite == null)
                    mSite = new Site();

                mSite.SiteID = SiteIdEditor.Text;

                LongitudeEditor.Text = LongitudeEditor.Text.Trim();
                if (LongitudeEditor.Text.Length == 0)
                    LongitudeEditor.Text = "0.0";
                if (!Regex.IsMatch(LongitudeEditor.Text, @"^[+-]?\d+(\.\d*)?$"))
                {
                    MessageBox.Show("Longitude is invalid !");
                    LongitudeEditor.Focus();
                    e.Cancel = true;
                    return;
                }
                mSite.Longitude = double.Parse(LongitudeEditor.Text);

                LatitudeEditor.Text = LatitudeEditor.Text.Trim();
                if (LatitudeEditor.Text.Length == 0)
                    LatitudeEditor.Text = "0.0";
                if (!Regex.IsMatch(LatitudeEditor.Text, @"^[+-]?\d+(\.\d*)?$"))
                {
                    MessageBox.Show("LatitudeEditor is invalid !");
                    LatitudeEditor.Focus();
                    e.Cancel = true;
                    return;
                }
                mSite.Latitude = double.Parse(LatitudeEditor.Text);

                mSite.SiteName = SiteNameEditor.Text;
                mSite.SamID = SamIdEditor.Text;
                mSite.SiteType = SiteTypeEditor.Text;
                mSite.RNC = RNCEditor.Text;
                mSite.BSC = BSCEditor.Text;
            }
        }
Exemple #3
0
 public SiteModel(Site site)
 {
     mSite = site;
 }
Exemple #4
0
 public void Add(Site site)
 {
     Site.Add(site);
 }
Exemple #5
0
        private void LoadTask(TreeNode regionNode, long taskID)
        {
            if (!DataCenter.Instance().Tasks.ContainsKey(taskID))
            {
                MessageBox.Show("Task " + taskID + " does not exist !");
                return;
            }

            BindingTask task = DataCenter.Instance().Tasks[taskID];
            TreeNode taskNode = regionNode.Nodes.Add(task.Name);
            taskNode.Tag = new TaskModel(task);
            taskNode.SelectedImageIndex = taskNode.ImageIndex = ICON_TASK;

            TreeNode sitesNode = taskNode.Nodes.Add("Sites");
            sitesNode.SelectedImageIndex = sitesNode.ImageIndex = ICON_SITES;
            sitesNode.Tag = new SitesModel();

            Site site;
            TreeNode siteNode, analyzersNode, analyzerNode;
            foreach (string siteID in task.Site)
            {
                if (DataCenter.Instance().Sites.ContainsKey(siteID))
                    site = DataCenter.Instance().Sites[siteID];
                else
                    site = new Site(siteID);
                siteNode = sitesNode.Nodes.Add(site.ToString());
                siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_SITE;
                siteNode.Tag = new SiteModel(site);
            }

            foreach (string siteID in task.UnassignedSite)
            {
                if (DataCenter.Instance().Sites.ContainsKey(siteID))
                    site = DataCenter.Instance().Sites[siteID];
                else
                    site = new Site(siteID);
                siteNode = sitesNode.Nodes.Add(site.ToString());
                siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_UNASSIGNEDSITE;
                siteNode.Tag = new SiteModel(site);
            }

            analyzersNode = taskNode.Nodes.Add("Analyzers");
            UsersModel usersModel = new UsersModel();
            analyzersNode.Tag = usersModel;
            analyzersNode.SelectedImageIndex = analyzersNode.ImageIndex = ICON_USERS;
            if (task.Analyzer != null)
            {
                foreach (string analyzer in task.Analyzer)
                {
                    analyzerNode = analyzersNode.Nodes.Add(analyzer);
                    analyzerNode.SelectedImageIndex = analyzerNode.ImageIndex = ICON_ANALYZER;
                    usersModel.Add(analyzer);
                }
            }
        }
Exemple #6
0
        private void LoadRegion(TreeNode parentNode, SubRegion parentRegion)
        {
            TreeNode node;
            TreeNode adminNode;
            TreeNode managersNode;
            TreeNode managerNode;
            TreeNode sitesNode;
            TreeNode siteNode;
            TreeNode settingsNode;
            TreeNode channelSettingsNode;
            TreeNode linkSettingsNode;
            TreeNode equipmentSettingsNode;
            UsersModel usersModel;
            TreeNode channelSettingNode;
            TreeNode linkConfigurationNode;
            TreeNode equipmentParameterNode;
            if (parentRegion.Sub == null)
                return;
            foreach (SubRegion region in parentRegion.Sub)
            {
                node = parentNode.Nodes.Add(region.Name);
                node.Tag = region;
                node.ImageIndex = node.SelectedImageIndex = ICON_REGION;

                if (node.Parent != mGlobalNode)
                    adminNode = node.Nodes.Add("Administrator - " + region.Owner);
                else
                    adminNode = node.Nodes.Add("Administrator - [SYSTEM ADMIN]");
                adminNode.SelectedImageIndex = adminNode.ImageIndex = ICON_ADMIN;

                if (region.Manager.IndexOf(HTTPAgent.Username) >= 0
                    || region.Manager.Count == 0 && region.Owner != null && region.Owner.Equals(HTTPAgent.Username))
                {
                    managersNode = node.Nodes.Add("Managers");
                    usersModel = new UsersModel();
                    managersNode.Tag = usersModel;
                    managersNode.SelectedImageIndex = managersNode.ImageIndex = ICON_USERS;
                    if (region.Manager != null)
                    {
                        foreach (string manager in region.Manager)
                        {
                            managerNode = managersNode.Nodes.Add(manager);
                            managerNode.SelectedImageIndex = managerNode.ImageIndex = ICON_MANAGER;
                            usersModel.Add(manager);
                        }
                    }

                    sitesNode = node.Nodes.Add("Sites");
                    sitesNode.SelectedImageIndex = sitesNode.ImageIndex = ICON_SITES;
                    sitesNode.Tag = new SitesModel();
                    Site site;
                    if (region.Site != null)
                    {
                        foreach (string siteID in region.Site)
                        {
                            if (DataCenter.Instance().Sites.ContainsKey(siteID))
                                site = DataCenter.Instance().Sites[siteID];
                            else
                                site = new Site(siteID);
                            siteNode = sitesNode.Nodes.Add(site.ToString());
                            siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_SITE;
                            siteNode.Tag = new SiteModel(site);
                        }
                    }
                    SiteNodeListSorter.SortByName(sitesNode);

                    settingsNode = node.Nodes.Add("Settings");
                    settingsNode.SelectedImageIndex = settingsNode.ImageIndex = ICON_SETTINGS;

                    channelSettingsNode = settingsNode.Nodes.Add("Channel Settings");
                    channelSettingsNode.SelectedImageIndex = channelSettingsNode.ImageIndex = ICON_CHANNELSETTINGS;

                    linkSettingsNode = settingsNode.Nodes.Add("Link Configuration Settings");
                    linkSettingsNode.SelectedImageIndex = linkSettingsNode.ImageIndex = ICON_LINKSETTINGS;

                    equipmentSettingsNode = settingsNode.Nodes.Add("Equipment Parameter Settings");
                    equipmentSettingsNode.SelectedImageIndex = equipmentSettingsNode.ImageIndex = ICON_EQUIPMENTSETTINGS;

                    /*
                    channelSettingNode = settingsNode.Nodes.Add("");
                    if (region.ChannelSettingID == -1)
                        channelSettingNode.Text = "Channel setting - <Not set>";
                    else
                        channelSettingNode.Text = "Channel setting - " + DataCenter.Instance().ChannelSettingDescriptions[region.ChannelSettingID].FileName;
                    channelSettingNode.SelectedImageIndex = channelSettingNode.ImageIndex = ICON_CHANNELSETTING;
                    channelSettingNode.Tag = new ChannelModel(region.ChannelSettingID);

                    linkConfigurationNode = settingsNode.Nodes.Add("");
                    if (region.LinkConfigurationID == -1)
                        linkConfigurationNode.Text = "Link configuration - <Not set>";
                    else
                        linkConfigurationNode.Text = DataCenter.Instance().LinkConfigurationDescriptions[region.LinkConfigurationID].FileName;
                    linkConfigurationNode.SelectedImageIndex = linkConfigurationNode.ImageIndex = ICON_LINKCONFIGURATION;
                    linkConfigurationNode.Tag = new LinkModel(region.LinkConfigurationID);

                    equipmentParameterNode = settingsNode.Nodes.Add("");
                    if (region.EquipmentParameterID == -1)
                        equipmentParameterNode.Text = "Equipment parameter - <Not set>";
                    else
                        equipmentParameterNode.Text = DataCenter.Instance().EquipmentParameterDescriptions[region.EquipmentParameterID].FileName;
                    equipmentParameterNode.SelectedImageIndex = equipmentParameterNode.ImageIndex = ICON_EQUIPMENTPARAMETER;
                    equipmentParameterNode.Tag = new EquipmentModel(region.EquipmentParameterID);
                    */

                    if (region.Task != null)
                    {
                        foreach (long taskID in region.Task)
                        {
                            LoadTask(node, taskID);
                        }
                    }

                }
                else
                {
                    node.ImageIndex = node.SelectedImageIndex = ICON_REGIONUNAUTHORIZED;
                }

                LoadRegion(node, region);
            }
        }
Exemple #7
0
        public void AddAssignedTaskNode(BindingTask task)
        {
            //Task Node
            TreeNode taskNode = mAssignedTasksNode.Nodes.Add(task.Name);
            taskNode.SelectedImageIndex = taskNode.ImageIndex = ICON_TASK;
            TaskModel taskModel = new TaskModel(task);
            taskNode.Tag = taskModel;

            //All EMI Files Node
            TreeNode emiFilesNode = taskNode.Nodes.Add("All EMI Files");
            emiFilesNode.SelectedImageIndex = emiFilesNode.ImageIndex = ICON_ALLEMIFILE;

            //Assigned Sites Node
            TreeNode assignedSiteNode = emiFilesNode.Nodes.Add("Assigned Sites");
            assignedSiteNode.SelectedImageIndex = assignedSiteNode.ImageIndex = ICON_SITES;

            //Assigned Site Node
            TreeNode siteNode;
            Site site;
            EMIFileData emiFileData;
            if (task.Site != null)
            {
                foreach (string siteID in task.Site)
                {
                    if (DataCenter.Instance().Sites.ContainsKey(siteID))
                        site = DataCenter.Instance().Sites[siteID];
                    else
                        site = new Site(siteID);
                    siteNode = assignedSiteNode.Nodes.Add(site.ToString());
                    siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_SITE;
                    siteNode.Tag = new SiteModel(site);

                    foreach (KeyValuePair<long, FileDescription> pair in DataCenter.Instance().EMIDescriptions)
                    {
                        //EMI Node
                        if (siteID.Equals(pair.Value.SiteID))
                        {
                            TreeNode emiNode = siteNode.Nodes.Add(pair.Value.Title);
                            emiNode.SelectedImageIndex = emiNode.ImageIndex = ICON_EMI;
                            emiFileData = DataCenter.Instance().EMIs[pair.Value.ID];
                            emiNode.Tag = new EMIFileModel(emiFileData);
                        }
                    }
                }
            }

            //Unassigned Sites Node
            TreeNode unAssignedSiteNode = emiFilesNode.Nodes.Add("Unassigned Sites");
            unAssignedSiteNode.SelectedImageIndex = unAssignedSiteNode.ImageIndex = ICON_UNASSIGNEDSITES;

            //UnAssigned Site Node
            if (task.UnassignedSite != null)
            {
                foreach (string siteID in task.UnassignedSite)
                {
                    if (DataCenter.Instance().Sites.ContainsKey(siteID))
                        site = DataCenter.Instance().Sites[siteID];
                    else
                        site = new Site(siteID);
                    siteNode = unAssignedSiteNode.Nodes.Add(site.ToString());
                    siteNode.SelectedImageIndex = siteNode.ImageIndex = ICON_UNASSIGNEDSITE;
                    siteNode.Tag = new SiteModel(site);

                    foreach (KeyValuePair<long, FileDescription> pair in DataCenter.Instance().EMIDescriptions)
                    {
                        //EMI Node
                        if (siteID.Equals(pair.Value.SiteID))
                        {
                            TreeNode emiNode = siteNode.Nodes.Add(pair.Value.Title);
                            emiNode.SelectedImageIndex = emiNode.ImageIndex = ICON_UNASSIGNEDEMI;
                            emiFileData = DataCenter.Instance().EMIs[pair.Value.ID];
                            emiNode.Tag = new EMIFileModel(emiFileData);
                        }
                    }
                }
            }

            //All Task Analysis Node
            List<AnalysisModel> analysisModelList = new List<AnalysisModel>();
            taskModel.AnalysisModelList = analysisModelList;
            TreeNode allTaskAnalysisNode = taskNode.Nodes.Add("Task Analysis");
            allTaskAnalysisNode.ImageIndex = allTaskAnalysisNode.SelectedImageIndex = ICON_ANALYSISES;
            allTaskAnalysisNode.Tag = analysisModelList;
        }
Exemple #8
0
        private static Sites ReadXmlFile(string siteListFile)
        {
            Site site;
            Sites sites = new Sites();

            System.Globalization.CultureInfo Oldci = null;
            Excel._Application app = null;
            Excel.WorkbookClass workBook = null;
            Excel.Sheets sheets = null;
            Excel.Worksheet sheet = null;
            try
            {
                Oldci = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");

                app = new Excel.Application();
                object objOpt = System.Reflection.Missing.Value;

                workBook = (Excel.WorkbookClass)app.Workbooks.Open(
                    siteListFile, objOpt, false, objOpt, objOpt, objOpt, true,
                    objOpt, objOpt, true, objOpt, objOpt, objOpt, objOpt, objOpt);

                sheets = workBook.Worksheets;
                sheet = (Excel.Worksheet)sheets[1];

                if (!"Sam ID".Equals(((Range)sheet.Cells[1, 1]).Text.ToString(), StringComparison.OrdinalIgnoreCase)
                    || !"Site ID".Equals(((Range)sheet.Cells[1, 2]).Text.ToString(), StringComparison.OrdinalIgnoreCase)
                    || !"Site Name".Equals(((Range)sheet.Cells[1, 3]).Text.ToString(), StringComparison.OrdinalIgnoreCase)
                    || !"MEGA SITE TYPE".Equals(((Range)sheet.Cells[1, 4]).Text.ToString(), StringComparison.OrdinalIgnoreCase)
                    || !"Longitude".Equals(((Range)sheet.Cells[1, 5]).Text.ToString(), StringComparison.OrdinalIgnoreCase)
                    || !"Latitude".Equals(((Range)sheet.Cells[1, 6]).Text.ToString(), StringComparison.OrdinalIgnoreCase)
                    || !"BSC".Equals(((Range)sheet.Cells[1, 7]).Text.ToString(), StringComparison.OrdinalIgnoreCase)
                    || !"RNC".Equals(((Range)sheet.Cells[1, 8]).Text.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    return sites;
                }

                string[] strs = new string[8];
                for (int row = 2; ; row++)
                {
                    for (int i = 0; i < 8; i++)
                        strs[i] = ((Range)sheet.Cells[row, i + 1]).Text.ToString();
                    if (strs[0].Trim().Length == 0 || strs[1].Trim().Length == 0
                        || strs[2].Trim().Length == 0 || strs[3].Trim().Length == 0
                        || strs[6].Trim().Length == 0 || strs[7].Trim().Length == 0
                        || !Regex.IsMatch(strs[4], @"[+-]?[\d]+(\.\d*)?")
                        || !Regex.IsMatch(strs[5], @"[+-]?[\d]+(\.\d*)?"))
                    {
                        return sites;
                    }

                    site = new Site();
                    site.SamID = strs[0];
                    site.SiteID = strs[1];
                    site.SiteName = strs[2];
                    site.SiteType = strs[3];
                    site.Longitude = double.Parse(strs[4]);
                    site.Latitude = double.Parse(strs[5]);
                    site.BSC = strs[6];
                    site.RNC = strs[7];
                    sites.Add(site);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (Oldci != null)
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = Oldci;
                }

                if (app != null)
                    app.Quit();
                ExcelAppKiller.Kill(app);

                WatsEmiReportTool.Utility.ReleaseCom(sheet);
                WatsEmiReportTool.Utility.ReleaseCom(sheets);
                WatsEmiReportTool.Utility.ReleaseCom(workBook);
                WatsEmiReportTool.Utility.ReleaseCom(app);

                GC.Collect(System.GC.GetGeneration(sheet));
                GC.Collect(System.GC.GetGeneration(sheets));
                GC.Collect(System.GC.GetGeneration(workBook));
                GC.Collect(System.GC.GetGeneration(app));

                GC.Collect();
            }
        }