Esempio n. 1
0
        public async static Task <bool> AddOrEdit(string query, List <SqlParameter> parms, GlobalProperties db, string type)
        {
            using (db = new GlobalProperties())
            {
                using (var command = db.Database.GetDbConnection().CreateCommand())
                {
                    command.CommandText = query;
                    if (type == "Query")
                    {
                        command.CommandType = CommandType.Text;
                    }
                    else
                    {
                        command.CommandType = CommandType.StoredProcedure;
                    }
                    if (parms.Count > 0)
                    {
                        command.Parameters.AddRange(parms.ToArray());
                    }
                    db.Database.OpenConnection();
                    int value = await command.ExecuteNonQueryAsync();

                    if (value > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
Esempio n. 2
0
    private void showRoles()
    {
        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.Roles";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);

                if (ds.Tables.Count > 0)
                {
                    ddRole.DataSource     = ds;
                    ddRole.DataTextField  = "RoleName";
                    ddRole.DataValueField = "RoleId";
                    ddRole.DataBind();
                }
            }
        }

        ddRole.Items.Insert(0, new ListItem("", "0"));
    }
Esempio n. 3
0
        /// <summary>
        /// Helper method to create a project with predictions rooted at the test root
        /// </summary>
        /// <returns></returns>
        public ProjectWithPredictions CreateProjectWithPredictions(
            string projectName = null,
            IReadOnlyCollection <AbsolutePath> inputs       = null,
            IReadOnlyCollection <AbsolutePath> outputs      = null,
            IEnumerable <ProjectWithPredictions> references = null,
            GlobalProperties globalProperties = null,
            PredictedTargetsToExecute predictedTargetsToExecute = null,
            bool implementsTargetProtocol = true)
        {
            var projectNameRelative = RelativePath.Create(StringTable, projectName ?? "testProj.proj");

            // We need to simulate the project comes from MSBuild with /graph
            var properties = new Dictionary <string, string>(globalProperties ?? GlobalProperties.Empty);

            properties[PipConstructor.s_isGraphBuildProperty] = "true";

            var projectWithPredictions = new ProjectWithPredictions(
                TestPath.Combine(PathTable, projectNameRelative),
                implementsTargetProtocol,
                new GlobalProperties(properties),
                inputs ?? CollectionUtilities.EmptyArray <AbsolutePath>(),
                outputs ?? CollectionUtilities.EmptyArray <AbsolutePath>(),
                projectReferences: references?.ToArray() ?? CollectionUtilities.EmptyArray <ProjectWithPredictions>(),
                predictedTargetsToExecute: predictedTargetsToExecute ?? PredictedTargetsToExecute.Create(new[] { "Build" }));

            return(projectWithPredictions);
        }
Esempio n. 4
0
        public async Task Command([Remainder] string text)
        {
            Server server = await DatabaseQueries.GetOrCreateServerAsync(Context.Guild.Id);

            IEnumerable <Quote> quotes = server.Quotes;
            int quoteCount             = quotes?.Count() ?? 0;

            if (quoteCount > 0)
            {
                if (server.Quotes.Any(x => x.Text.Equals(text)))
                {
                    var cEmbed = new KaguyaEmbedBuilder(EmbedColor.YELLOW)
                    {
                        Description = "A quote with the same text already exists. Do you want to create this one anyway?"
                    };

                    var data = new ReactionCallbackData("", cEmbed.Build(), true, true, TimeSpan.FromSeconds(120));
                    data.AddCallBack(GlobalProperties.CheckMarkEmoji(), async(c, r) => { await InsertQuote(Context, server, text); });

                    data.AddCallBack(GlobalProperties.NoEntryEmoji(),
                                     async(c, r) => { await SendBasicErrorEmbedAsync("Okay, no action will be taken."); });

                    await InlineReactionReplyAsync(data);

                    return;
                }
            }

            await InsertQuote(Context, server, text);
        }
Esempio n. 5
0
    protected void DownloadFile(object sender, EventArgs e)
    {
        int id = int.Parse((sender as LinkButton).CommandArgument);

        byte[] bytes;
        string fileName, contentType;

        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.DownloadIncidentFile";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Id", id);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    reader.Read();
                    bytes       = (byte[])reader["DocumentFile"];
                    contentType = reader["DocumentContent"].ToString();
                    fileName    = reader["DocumentFileName"].ToString();
                }
                conn.Close();
            }
        }
        Response.Clear();
        Response.Buffer  = true;
        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = contentType;
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
        Response.BinaryWrite(bytes);
        Response.Flush();
        Response.End();
    }
Esempio n. 6
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string filename    = Path.GetFileName(fuUpload.PostedFile.FileName);
        string contentType = fuUpload.PostedFile.ContentType;

        using (Stream fs = fuUpload.PostedFile.InputStream)
        {
            using (BinaryReader br = new BinaryReader(fs))
            {
                byte[] bytes = br.ReadBytes((Int32)fs.Length);

                using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
                {
                    string cmdText = "dbo.InsertIncidentFile";
                    using (SqlCommand cmd = new SqlCommand(cmdText, conn))
                    {
                        conn.Open();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@ProjectNumber", this.txtReqNo.Text);
                        cmd.Parameters.AddWithValue("@DocumentFileName", filename);
                        cmd.Parameters.AddWithValue("@DocumentDescription", this.txtUpload.Text);
                        cmd.Parameters.AddWithValue("@DocumentOwner", hfUserId.Value);
                        cmd.Parameters.AddWithValue("@DocumentContent", contentType);
                        cmd.Parameters.AddWithValue("@DocumentFile", bytes);
                        cmd.Parameters.AddWithValue("@UserId", hfUserId.Value);
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
            }
        }
        Response.Redirect(Request.Url.AbsoluteUri);
    }
Esempio n. 7
0
    protected void ShowDetails(string ReqNo)
    {
        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.SelectIncident";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ReqNo", ReqNo);

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    this.txtReqNo.Text              = reader[0].ToString();
                    this.txtRaisedBy.Text           = reader[1].ToString();
                    this.txtOffice.Text             = reader[2].ToString();
                    this.txtProject.Text            = reader[3].ToString();
                    this.txtArea.Text               = reader[4].ToString();
                    this.txtDate.Text               = reader[5].ToString();
                    this.txtTime.Text               = reader[6].ToString();
                    this.txtIssue.Text              = reader[7].ToString();
                    this.ddPolCwx.SelectedItem.Text = reader[8].ToString();
                    this.ddStatus.SelectedItem.Text = reader[9].ToString();
                    this.txtAssignedTo.Text         = reader[10].ToString();
                    this.txtSolution.Text           = reader[11].ToString();
                    this.txtDateCompleted.Text      = reader[12].ToString();
                    this.txtTimeCompleted.Text      = reader[13].ToString();
                    this.txtCompletedBy.Text        = reader[14].ToString();
                }
                reader.Close();
            }
        }
    }
Esempio n. 8
0
        private async Task ReactionReply(SocketGuildUser user,
                                         IReadOnlyCollection <WarnedUser> warnings,
                                         Embed embed,
                                         int warnCount,
                                         Server server,
                                         string reason)
        {
            Emoji[] emojis = GlobalProperties.EmojisOneThroughNine();

            var data      = new ReactionCallbackData("", embed, false, false, TimeSpan.FromSeconds(300));
            var callbacks = new List <(IEmote, Func <SocketCommandContext, SocketReaction, Task>)>();

            for (int j = 0; j < warnCount; j++)
            {
                int j1 = j;
                callbacks.Add((emojis[j], async(c, r) =>
                {
                    var uwArgs = new ModeratorEventArgs(server, Context.Guild, user, (SocketGuildUser)Context.User, reason, null);
                    KaguyaEvents.TriggerUnwarn(uwArgs);

                    await DatabaseQueries.DeleteAsync(warnings.ElementAt(j1));
                    await c.Channel.SendMessageAsync($"{r.User.Value.Mention} " +
                                                     $"`Successfully removed warning #{j1 + 1}`");
                }));
            }

            data.SetCallbacks(callbacks);
            await InlineReactionReplyAsync(data);
        }
Esempio n. 9
0
    protected void btnSaveAdd_Click(object sender, EventArgs e)
    {
        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.InsertIncident";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@RaisedBy", this.txtRaisedBy.Text);
                cmd.Parameters.AddWithValue("@Office", this.txtOffice.Text);
                cmd.Parameters.AddWithValue("@Project", this.txtProject.Text);
                cmd.Parameters.AddWithValue("@Area", this.txtArea.Text);
                if (this.txtDate.Text == string.Empty)
                {
                    cmd.Parameters.AddWithValue("@Date", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@Date", this.txtDate.Text);
                }
                if (this.txtTime.Text == string.Empty)
                {
                    cmd.Parameters.AddWithValue("@Time", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@Time", this.txtTime.Text);
                }
                cmd.Parameters.AddWithValue("@Detailed_Issue", this.txtIssue.Text);
                cmd.Parameters.AddWithValue("@POL_Coreworx", this.ddPolCwx.SelectedItem.Text);
                cmd.Parameters.AddWithValue("@Status", this.ddStatus.SelectedItem.Text);
                cmd.Parameters.AddWithValue("@AssignedTo", this.txtAssignedTo.Text);
                cmd.Parameters.AddWithValue("@Solution", this.txtSolution.Text);
                if (this.txtDate.Text == string.Empty)
                {
                    cmd.Parameters.AddWithValue("@DateCompleted", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@DateCompleted", this.txtDateCompleted.Text);
                }
                if (this.txtTime.Text == string.Empty)
                {
                    cmd.Parameters.AddWithValue("@TimeCompleted", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@TimeCompleted", this.txtTimeCompleted.Text);
                }
                cmd.Parameters.AddWithValue("@CompletedBy", this.txtCompletedBy.Text);
                cmd.Parameters.AddWithValue("@UserId", hfUserId.Value);

                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }

        Response.Redirect("IssuesSummary.aspx");
    }
Esempio n. 10
0
        public ProjectBuildInfo(ProjectStartedEventArgs projectStartedEventArgs, IReadOnlyDictionary <int, ProjectBuildInfo> otherProjects, Dictionary <string, SortedSet <GlobalPropertyValue> > globalPropertySubsets)
        {
            StartedEventArgs        = projectStartedEventArgs;
            ParentProjectInstanceId = projectStartedEventArgs.ParentProjectBuildEventContext.ProjectInstanceId;
            ProjectInstanceId       = projectStartedEventArgs.BuildEventContext.ProjectInstanceId;
            GlobalProperties        = projectStartedEventArgs.GlobalProperties ?? new Dictionary <string, string>();

            _globalPropertySubsets = globalPropertySubsets;

            if (GlobalProperties == null)
            {
                return;
            }

            if (otherProjects.TryGetValue(ParentProjectInstanceId, out ProjectBuildInfo other))
            {
                foreach (var propertyName in other.GlobalProperties.Keys)
                {
                    if (!GlobalProperties.TryGetValue(propertyName, out _))
                    {
                        RemovedProperties[propertyName] = other.GlobalProperties[propertyName];
                    }
                }
            }
        }
Esempio n. 11
0
        public int SubtractMaintenanceCostsDecreasesMoneyBalance(int cost)
        {
            var globalProperties = new GlobalProperties();

            globalProperties.SubtractMaintenanceCosts(cost);
            return(globalProperties.Money);
        }
Esempio n. 12
0
    protected void ShowGrid(string id)
    {
        this.gvSummary.DataSource = null;

        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.Summary4";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Id", id);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);

                if (ds.Tables.Count > 0)
                {
                    this.gvSummary.DataSource = ds;
                    this.gvSummary.DataBind();
                }
            }
        }
    }
Esempio n. 13
0
    protected string getDefaultPage(string username)
    {
        string defaultPage = string.Empty;

        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.GetUserDefaultPage";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@UserName", username);
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows == true)
                {
                    while (reader.Read())
                    {
                        defaultPage = reader[0].ToString().ToUpper();
                    }
                }
                else
                {
                    defaultPage = string.Empty;
                }
                conn.Close();
            }
        }

        return(defaultPage);
    }
Esempio n. 14
0
    protected bool getUserDB(string username)
    {
        bool valid = false;

        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.GetUser";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@username", username);
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows == true)
                {
                    valid = true;
                }
                else
                {
                    valid = false;
                }
                conn.Close();
            }
        }

        return(valid);
    }
Esempio n. 15
0
    protected void gvUserList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Select")
        {
            int index = Convert.ToInt32(e.CommandArgument);

            GridViewRow selectedRow = this.gvUserList.Rows[index];
            TableCell   username    = selectedRow.Cells[1];

            using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
            {
                string cmdText = "dbo.DeleteUser";
                using (SqlCommand cmd = new SqlCommand(cmdText, conn))
                {
                    conn.Open();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserName", username);
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }

            //Response.Redirect("Users.aspx");
        }
    }
Esempio n. 16
0
 public async static Task <List <T> > RawSqlQuery <T>(string query, List <SqlParameter> parms, Func <DbDataReader, T> map, GlobalProperties db, string type)
 {
     using (db = new GlobalProperties())
     {
         using (var command = db.Database.GetDbConnection().CreateCommand())
         {
             command.CommandText = query;
             if (type == "Query")
             {
                 command.CommandType = CommandType.Text;
             }
             else
             {
                 command.CommandType = CommandType.StoredProcedure;
             }
             if (parms.Count > 0)
             {
                 command.Parameters.AddRange(parms.ToArray());
             }
             db.Database.OpenConnection();
             using (var result = await command.ExecuteReaderAsync())
             {
                 var entities = new List <T>();
                 if (result.HasRows)
                 {
                     while (result.Read())
                     {
                         entities.Add(map(result));
                     }
                 }
                 return(entities);
             }
         }
     }
 }
Esempio n. 17
0
    private DataTable ExecuteQuery(SqlCommand cmd, string action)
    {
        using (SqlConnection con = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            cmd.Connection = con;
            switch (action)
            {
            case "SELECT":
                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    sda.SelectCommand = cmd;
                    using (DataTable dt = new DataTable())
                    {
                        sda.Fill(dt);
                        return(dt);
                    }
                }

            case "UPDATE":
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                break;
            }
            return(null);
        }
    }
Esempio n. 18
0
 private void LoadEditorSettings(GlobalProperties settings)
 {
     codebox.ShowScrollBars       = settings.ScrollBars;
     codebox.AutoCompleteBrackets = settings.AutoCompleteBrackets;
     if (settings.TabSize != 0)
     {
         codebox.TabLength = settings.TabSize;
     }
     if (!string.IsNullOrEmpty(settings.FontFamily) && settings.FontSize != 0.0)
     {
         codebox.Font = new Font(settings.FontFamily, settings.FontSize);
     }
     codebox.ShowFoldingLines              = settings.ShowFoldingLines;
     codebox.ShowLineNumbers               = settings.ShowLineNumbers;
     codebox.HighlightFoldingIndicator     = settings.HighlightFolding;
     codebox.FindEndOfFoldingBlockStrategy = settings.FoldingStrategy;
     codebox.BracketsHighlightStrategy     = settings.BracketsStrategy;
     codebox.CaretVisible     = settings.ShowCaret;
     codebox.ShowFoldingLines = settings.ShowFoldingLines;
     codebox.LeftPadding      = settings.PaddingWidth;
     codebox.VirtualSpace     = settings.EnableVirtualSpace;
     codebox.WideCaret        = settings.BlockCaret;
     codebox.WordWrap         = settings.WordWrap;
     if (settings.ImeMode)
     {
         codebox.ImeMode = ImeMode.On;
     }
     if (settings.ShowChangedLine)
     {
         codebox.ChangedLineColor = ControlPaint.LightLight(codebox.CurrentLineColor);
     }
 }
Esempio n. 19
0
        private IDictionary <string, string> GetGlobalProperties()
        {
            IDictionary <string, string> globalProperties;

            if (InheritGlobalProperties && _projectInstanceLazy.Value != null)
            {
                // Clone the properties since they will be modified
                globalProperties = new Dictionary <string, string>(_projectInstanceLazy.Value.GlobalProperties, StringComparer.OrdinalIgnoreCase);

                foreach (string propertyToRemove in GlobalPropertiesToRemove.SplitSemicolonDelimitedList().Where(i => globalProperties.ContainsKey(i)))
                {
                    globalProperties.Remove(propertyToRemove);
                }
            }
            else
            {
                globalProperties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            }

            foreach (KeyValuePair <string, string> globalProperty in GlobalProperties.SplitProperties())
            {
                globalProperties[globalProperty.Key] = globalProperty.Value;
            }

            return(globalProperties);
        }
Esempio n. 20
0
        public int AddIncomeIncreasesMoneyBalance(int profits)
        {
            var globalProperties = new GlobalProperties();

            globalProperties.AddIncome(profits);
            return(globalProperties.Money);
        }
Esempio n. 21
0
        public void QualifiersAndGlobalPropertiesAreMergedPerQualifier()
        {
            var entryPointPath = m_builder.WriteProjectsWithReferences(("A", "<Project/>"));

            // let's 'build' for debug and release
            var requestedQualifiers = new GlobalProperties[] {
                new GlobalProperties(new Dictionary <string, string> {
                    ["configuration"] = "debug"
                }),
                new GlobalProperties(new Dictionary <string, string> {
                    ["configuration"] = "release"
                }),
            };

            var globalProperties = new GlobalProperties(new Dictionary <string, string> {
                ["platform"] = "x86"
            });

            var arguments = CreateBuilderArguments(entryPointPath, requestedQualifiers, globalProperties);

            var projectGraphWithPredictionsResult = BuildGraphAndDeserialize(arguments);

            Assert.True(projectGraphWithPredictionsResult.Succeeded);
            var nodes = projectGraphWithPredictionsResult.Result.ProjectNodes;

            // There should be two nodes, one per qualifier
            Assert.Equal(2, nodes.Count());
            var debugNode   = nodes.First(node => node.GlobalProperties["configuration"] == "debug");
            var releaseNode = nodes.First(node => node.GlobalProperties["configuration"] == "release");

            // Both nodes should have the same platform, since that's part of the global properties
            XAssert.All(nodes, node => Assert.Equal("x86", node.GlobalProperties["platform"]));
        }
Esempio n. 22
0
        private Task <bool> EvaluateAllFilesAsync(IReadOnlySet <AbsolutePath> evaluationGoals, QualifierId qualifierId)
        {
            Contract.Assert(m_msBuildWorkspaceResolver.ComputedProjectGraph.Succeeded);

            ProjectGraphResult result = m_msBuildWorkspaceResolver.ComputedProjectGraph.Result;

            GlobalProperties qualifier = MsBuildResolverUtils.CreateQualifierAsGlobalProperties(qualifierId, m_context);

            IReadOnlySet <ProjectWithPredictions> filteredBuildFiles = result.ProjectGraph.ProjectNodes
                                                                       .Where(project => evaluationGoals.Contains(project.FullPath))
                                                                       .Where(project => ProjectMatchesQualifier(project, qualifier))
                                                                       .ToReadOnlySet();

            var graphConstructor = new PipGraphConstructor(
                m_context,
                m_host,
                result.ModuleDefinition,
                m_msBuildResolverSettings,
                result.MsBuildLocation,
                result.DotNetExeLocation,
                m_frontEndName,
                m_msBuildWorkspaceResolver.UserDefinedEnvironment,
                m_msBuildWorkspaceResolver.UserDefinedPassthroughVariables);

            return(graphConstructor.TrySchedulePipsForFilesAsync(filteredBuildFiles, qualifierId));
        }
Esempio n. 23
0
        public T GetPropertyValue <T>(Guid id, out bool validId)
        {
            T val;

            validId = GlobalProperties <T> .TryGetValue(id, out val);

            return(val);
        }
Esempio n. 24
0
 private bool ProjectMatchesQualifier(ProjectWithPredictions project, GlobalProperties qualifier)
 {
     return(qualifier.All(kvp =>
                          // The project properties should contain all qualifier keys
                          project.GlobalProperties.TryGetValue(kvp.Key, out string value) &&
                          // The values should be the same. Not that values are case sensitive.
                          kvp.Value.Equals(value, StringComparison.Ordinal)));
 }
Esempio n. 25
0
        private T GetValue()
        {
            T val;

            GlobalProperties <T> .TryGetValue(m_PropertyReference, out val);

            return(val);
        }
Esempio n. 26
0
    private void uploadCLS()
    {
        string csvPath = Server.MapPath("~/Files/") + Path.GetFileName(fuUpload.PostedFile.FileName);

        fuUpload.SaveAs(csvPath);

        DataTable dt = new DataTable();

        dt.Columns.AddRange(new DataColumn[8] {
            new DataColumn("Project_Location", typeof(string)),
            new DataColumn("Project_Count", typeof(string)),
            new DataColumn("Project_No", typeof(string)),
            new DataColumn("Project_Name", typeof(string)),
            new DataColumn("Project_Request_Date", typeof(string)),
            new DataColumn("Project_Close_Date", typeof(string)),
            new DataColumn("Project_Type", typeof(string)),
            new DataColumn("Project_Duration_Years", typeof(string))
        });

        string csvData = File.ReadAllText(csvPath);

        foreach (string row in csvData.Split('\n'))
        {
            if (!string.IsNullOrEmpty(row))
            {
                dt.Rows.Add();
                int i = 0;
                foreach (string cell in row.Split(','))
                {
                    dt.Rows[dt.Rows.Count - 1][i] = cell;
                    i++;
                }
            }
        }

        using (SqlConnection con = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con))
            {
                sqlBulkCopy.DestinationTableName = "dbo.tblStageClose";
                con.Open();
                sqlBulkCopy.WriteToServer(dt);
                con.Close();
            }
        }

        using (SqlConnection conn = new SqlConnection(GlobalProperties.SqlConnectionString()))
        {
            string cmdText = "dbo.Bulk_Upload3";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn))
            {
                conn.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
    }
Esempio n. 27
0
        //FIXME: add a test for null @toolsVersion
        public bool BuildProjectFile(string projectFile,
                                     string[] targetNames,
                                     BuildPropertyGroup globalProperties,
                                     IDictionary targetOutputs,
                                     BuildSettings buildFlags, string toolsVersion)
        {
            Project project;

            if (projects.ContainsKey(projectFile))
            {
                project = (Project)projects [projectFile];
            }
            else
            {
                project = CreateNewProject();
                project.Load(projectFile);
            }

            BuildPropertyGroup engine_old_grp  = null;
            BuildPropertyGroup project_old_grp = null;

            if (globalProperties != null)
            {
                engine_old_grp  = GlobalProperties.Clone(true);
                project_old_grp = project.GlobalProperties.Clone(true);

                // Override project's global properties with the
                // ones explicitlcur_y specified here
                foreach (BuildProperty bp in globalProperties)
                {
                    project.GlobalProperties.AddProperty(bp);
                }
                project.NeedToReevaluate();
            }

            try {
                if (String.IsNullOrEmpty(toolsVersion) && defaultToolsVersion != null)
                {
                    // it has been explicitly set, xbuild does this..
                    //FIXME: should this be cleared after building?
                    project.ToolsVersion = defaultToolsVersion;
                }
                else
                {
                    project.ToolsVersion = toolsVersion;
                }

                return(project.Build(targetNames, targetOutputs, buildFlags));
            } finally {
                if (globalProperties != null)
                {
                    GlobalProperties         = engine_old_grp;
                    project.GlobalProperties = project_old_grp;
                }
            }
        }
Esempio n. 28
0
        public BuildParameters Clone()
        {
            var ret = (BuildParameters)MemberwiseClone();

            ret.ForwardingLoggers      = ForwardingLoggers == null ? null : ForwardingLoggers.ToArray();
            ret.GlobalProperties       = GlobalProperties == null ? null : GlobalProperties.ToDictionary(p => p.Key, p => p.Value);
            ret.Loggers                = Loggers == null ? null : new List <ILogger> (Loggers);
            ret.environment_properties = new Dictionary <string, string> (environment_properties);
            return(ret);
        }
Esempio n. 29
0
        public void SetDefaultConfiguration(string platform, string config)
        {
            var cfg = GlobalProperties.GetProperty("Configuration");

            cfg.Condition = " '$(Configuration)' == '' ";
            cfg.Value     = config;
            var plat = GlobalProperties.GetProperty("Platform");

            plat.Condition = " '$(Platform)' == '' ";
            plat.Value     = platform;
        }
Esempio n. 30
0
        private void CopyGlobalProperties(IDictionary <string, string> globalProperties)
        {
            if (globalProperties == null)
            {
                return;
            }

            foreach (var globalProperty in globalProperties)
            {
                GlobalProperties.Set(globalProperty.Key, globalProperty.Value);
            }
        }
Esempio n. 31
0
        public MainForm()
        {
            InitializeComponent();

            SetLocaleEnglish();

            ///////////////////////
            // Keep this at the top:
            SetupDirectories();
            GlobalProps = new GlobalProperties( this );
            ///////////////////////

            CryptoRand = new RNGCryptoServiceProvider();

            NetStats = new NetIPStatus( this );
            NetStats.ReadFromFile();

            FactorDictionary1 = new FactorDictionary( this );

            LaPlataData1 = new LaPlataData( this );
            WebFData = new WebFilesData( this );
            X509Data = new DomainX509Data( this, GetDataDirectory() + "Certificates.txt" );

            if( !CheckSingleInstance())
              return;

            IsSingleInstance = true;

            WebListenForm = new WebListenerForm( this );
            TLSListenForm = new TLSListenerForm( this );
            CustomerMsgForm = new CustomerMessageForm( this );
            QuadResForm = new QuadResSearchForm( this );

            CheckTimer.Interval = 5 * 60 * 1000;
            CheckTimer.Start();

            StartTimer.Interval = 1000;
            StartTimer.Start();
        }
Esempio n. 32
0
 /// <summary>
 /// Restore Default Properties
 /// </summary>
 /// <param name="file"></param>
 private static void RestoreDefault(string file)
 {
     var prop = new GlobalProperties();
     prop.AutoCompleteBrackets = true;
     prop.EnableVirtualSpace = false;
     prop.FontFamily = "Consolas";
     prop.FontSize = 9.75f;
     prop.DefaultEncoding = 1251;
     prop.DocumentStyle = DocumentStyle.DockingMdi;
     prop.TabLocation = DocumentTabStripLocation.Top;
     prop.FoldingStrategy = FindEndOfFoldingBlockStrategy.Strategy1;
     prop.BracketsStrategy = BracketsHighlightStrategy.Strategy2;
     prop.MinimizeToTray = false;
     prop.ShowChangedLine = false;
     prop.BlockCaret = false;
     prop.ImeMode = false;
     prop.HiddenChars = false;
     prop.LineInterval = 0;
     prop.ShowToolBar = false;
     prop.ShowStatusBar = true;
     prop.ShowMenuBar = true;
     prop.ThemeFile = "User\\Themes\\Default.ynotetheme";
     prop.HighlightFolding = true;
     prop.ShowFoldingLines = true;
     prop.ShowCaret = true;
     prop.UseTabs = false;
     prop.Zoom = 100;
     prop.WordWrap = false;
     prop.ShowRuler = false;
     prop.ShowDocumentMap = true;
     prop.PaddingWidth = 17;
     prop.RecentFileNumber = 15;
     prop.ScrollBars = true;
     prop.ShowLineNumbers = true;
     prop.TabSize = 4;
     File.WriteAllText(file, SerializeProperties(prop));
 }
Esempio n. 33
0
 public static void Save(GlobalProperties properties, string file)
 {
     string serialized = SerializeProperties(properties);
     File.WriteAllText(file, serialized);
 }
Esempio n. 34
0
 private static string SerializeProperties(GlobalProperties properties)
 {
     return JsonConvert.SerializeObject(properties, Formatting.Indented);
 }