コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string serverName = txtServerName.Text;
            string userid     = this.txtUserID.Text;
            string pass       = this.txtPass.Text;
            string connString = string.Format("Data Source={0};Initial Catalog=RSDataV2;User ID={1};Password={2}", serverName, userid, pass);

            SqlConnection sqlConn = new SqlConnection(connString);

            try
            {
                sqlConn.Open();

                string str  = ConfigurationManager.ConnectionStrings["conRsTool"].ConnectionString.Replace("(local)", txtServerName.Text).Replace("sa", txtUserID.Text).Replace("as1", txtPass.Text);;
                string str2 = ConfigurationManager.ConnectionStrings["RSFinanceToolsEntities"].ConnectionString.Replace("127.0.0.1", txtServerName.Text).Replace("sa", txtUserID.Text).Replace("as1", txtPass.Text);;

                Finance_Tools.ConnectionStringsSave("conRsTool", str);
                Finance_Tools.ConnectionStringsSave("RSFinanceToolsEntities", str2);
                hasSaved = true;

                Finance_Tools.AppSettingSave("isSqlInitialize", "true");

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("The test database connection failed! Please check the server name and database name is correct!");
                hasSaved = false;
            }
            finally
            {
                sqlConn.Close();
            }
        }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public string GetFilesCount()
 {
     if (!string.IsNullOrEmpty(RootPath))
     {
         DirectoryInfo[] fldrs = di.GetDirectories("*.*");
         filesString = "";
         for (int i = fldrs.Length; i > 0; i--)
         {
             DirectoryInfo d = fldrs[i - 1];
             if (Finance_Tools.IsAddedToGallery(d))
             {
                 try
                 {
                     FileInfo[] myfile = d.GetFiles();
                     for (int j = myfile.Length; j > 0; j--)
                     {
                         FileInfo f = myfile[j - 1];
                         if (f.Extension == ".xls" || f.Extension == ".xlsx" || f.Extension == ".xlsm" || f.Extension == ".pdf")
                         {
                             string fileName = Path.GetFileNameWithoutExtension(f.Name);
                             if (!fileName.Contains("~"))
                             {
                                 filesString += fileName;
                             }
                         }
                     }
                 }
                 catch
                 { }
             }
         }
     }
     return(filesString);
 }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void ThisAddIn_Shutdown(object sender, System.EventArgs e)
 {
     Finance_Tools.totalRunTimes++;
     if (!Finance_Tools.CompareFileCountWithConfigCount())
     {
         Finance_Tools.UpdateFolderFileXMLStructure();
     }
     ft.deleteCache(Finance_Tools.strRSDataCache);
     this.CustomTaskPanes.Dispose();
     if (Ribbon2.notifyIcon1 != null)
     {
         Ribbon2.notifyIcon1.Dispose();
     }
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        private void initializeFolder()
        {
            var           path = Finance_Tools.RootPath;
            DirectoryInfo di   = new DirectoryInfo(path);

            DirectoryInfo[] fldrs = di.GetDirectories("*.*");
            foreach (DirectoryInfo d in fldrs)
            {
                if (Finance_Tools.IsAddedToGallery(d))
                {
                    cbFolders.Items.Add(new KeyValuePair <string, string>(d.Name, d.FullName));
                }
            }
            cbFolders.DisplayMember = "Key";
            cbFolders.ValueMember   = "Value";
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            SqlConnection conn = null;

            SessionInfo.UserInfo.SunUserIP   = this.txtSunServer.Text;
            SessionInfo.UserInfo.SunUserID   = this.txtSunID.Text;
            SessionInfo.UserInfo.SunUserPass = this.txtSunPass.Text;
            try
            {
                conn = new
                       SqlConnection(ConfigurationManager.ConnectionStrings["conRsTool"].ConnectionString.ToString());
                conn.Open();
                SqlCommand cmd = new SqlCommand("rsUsers_UserSunInfo_Upd", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@SUNUserIP", SessionInfo.UserInfo.SunUserIP));
                cmd.Parameters.Add(new SqlParameter("@SUNUserID", DEncrypt.Encrypt(SessionInfo.UserInfo.SunUserID)));
                cmd.Parameters.Add(new SqlParameter("@SUNUserPass", DEncrypt.Encrypt(SessionInfo.UserInfo.SunUserPass)));
                cmd.Parameters.Add(new SqlParameter("@id", SessionInfo.UserInfo.ID));
                cmd.ExecuteNonQuery();
                this.Close();
                Finance_Tools.AppSettingSave("SuspenseAccount", this.txtSA.Text);
                Finance_Tools.AppSettingSave("BusinessUnit", this.txtBU.Text);
                SaveVisibleSetting(conn, cmd);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            ft.uPDATETemplateUpdateFlag(SessionInfo.UserInfo.ID, true);
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="cmd"></param>
        private void ImportTemplatesIntoDB(SqlConnection conn, SqlCommand cmd)
        {
            var path = string.Empty;

            getTemplateFolder(ref path);
            if (!string.IsNullOrEmpty(path))
            {
                try
                {
                    DirectoryInfo   di    = new DirectoryInfo(path);
                    DirectoryInfo[] fldrs = di.GetDirectories("*.*");
                    if (Finance_Tools.IsAddedToGallery(di))
                    {
                        try
                        {
                            FileInfo[] myfile = di.GetFiles();
                            foreach (FileInfo f in myfile)
                            {
                                int index = this.dataGridView1.Rows.Add();
                                Log("Importing " + f.Name + "...", index, "", "");
                                DirectoryInfo dir = new DirectoryInfo(di.FullName);
                                if (f.Extension == ".xls" || f.Extension == ".xlsx" || f.Extension == ".xlsm" || f.Extension == ".pdf")
                                {
                                    string Description = string.Empty;
                                    try
                                    {
                                        ShellLib.ShellLibClass sl = new ShellLib.ShellLibClass();
                                        Description = sl.getFileDetail(di.FullName, f.Name);
                                    }
                                    catch { }
                                    InsertIntoDB(f, Description, index, conn, cmd);
                                }
                                else
                                {
                                    Log("Importing " + f.Name + "...", index, "Fail!", "File format is not correct!File format must be xls , xlsx , xlsm or pdf ");
                                }
                            }
                        }
                        catch (Exception ex)
                        { MessageBox.Show(ex.Message, "Message - RSystems FinanceTools", MessageBoxButtons.OK, MessageBoxIcon.Information); }
                    }
                    foreach (DirectoryInfo d in fldrs)
                    {
                        if (Finance_Tools.IsAddedToGallery(d))
                        {
                            try
                            {
                                FileInfo[] myfile = d.GetFiles();
                                foreach (FileInfo f in myfile)
                                {
                                    int index = this.dataGridView1.Rows.Add();
                                    Log("Importing " + f.Name + "...", index, "", "");
                                    DirectoryInfo dir = new DirectoryInfo(d.FullName);
                                    if (f.Extension == ".xls" || f.Extension == ".xlsx" || f.Extension == ".xlsm" || f.Extension == ".pdf")
                                    {
                                        string Description = string.Empty;
                                        try
                                        {
                                            ShellLib.ShellLibClass sl = new ShellLib.ShellLibClass();
                                            Description = sl.getFileDetail(d.FullName, f.Name);
                                        }
                                        catch { }
                                        InsertIntoDB(f, Description, index, conn, cmd);
                                    }
                                    else
                                    {
                                        Log("Importing " + f.Name + "...", index, "Fail!", "File format is not correct!File format must be xls , xlsx , xlsm or pdf ");
                                    }
                                }
                            }
                            catch (Exception ex)
                            { MessageBox.Show(ex.Message, "Message - RSystems FinanceTools", MessageBoxButtons.OK, MessageBoxIcon.Information); }
                        }
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message, "Message - RSystems FinanceTools", MessageBoxButtons.OK, MessageBoxIcon.Information); }
            }
        }
コード例 #7
0
 /// <summary>
 /// Initialize File Structure when initia folder path or file number changes
 /// </summary>
 public void InitializeFileXMLStructure()
 {
     if (!string.IsNullOrEmpty(RootPath))
     {
         string[] sArray = Finance_Tools.FileIds.Split(new char[3] {
             ',', ',', ','
         });
         DirectoryInfo[] fldrs = di.GetDirectories("*.*");
         XmlDocument     xdoc  = new XmlDocument();
         xdoc.Load(Finance_Tools.FolderFileXMLPath + Finance_Tools.simpleID + ".xml");
         XmlNode Nodes = xdoc.SelectSingleNode("Nodes");
         Nodes.RemoveAll();
         filesString = "";
         for (int i = fldrs.Length; i > 0; i--)
         {
             DirectoryInfo d = fldrs[i - 1];
             if (Finance_Tools.IsAddedToGallery(d))
             {
                 try
                 {                                                         //add folder nodes
                     XmlElement xmlElement = xdoc.CreateElement("Folder"); //add attributes
                     xmlElement.SetAttribute("Name", d.Name);              //The node is added to the specified node
                     XmlNode    xml    = Nodes.PrependChild(xmlElement);
                     FileInfo[] myfile = d.GetFiles();
                     for (int j = myfile.Length; j > 0; j--)
                     {
                         FileInfo f = myfile[j - 1];
                         if (f.Extension == ".xls" || f.Extension == ".xlsx" || f.Extension == ".xlsm" || f.Extension == ".pdf")
                         {
                             string fileName = Path.GetFileNameWithoutExtension(f.Name);
                             //using ShellLib project(framework2.0) for current project(framework3.5),because framework3.5 cannot using SHELL32(X64) directly.
                             string fileDesc = string.Empty;
                             try
                             {
                                 ShellLib.ShellLibClass sl = new ShellLib.ShellLibClass();
                                 fileDesc = sl.getFileDetail(d.FullName, f.Name);
                             }
                             catch { }//add folder nodes
                             XmlElement xmlElementSub = xdoc.CreateElement("File");//add attributes
                             xmlElementSub.SetAttribute("Name", fileName);
                             xmlElementSub.SetAttribute("Description", fileDesc);
                             for (int x = 0; x < sArray.Length; x++)
                             {
                                 if (!string.IsNullOrEmpty(sArray[x]) && sArray[x].ToLower().Contains(f.FullName.ToLower()))
                                 {
                                     xmlElementSub.SetAttribute("ID", sArray[x].Substring(sArray[x].LastIndexOf("-") + 1));
                                 }
                             }//The node is added to the specified node
                             xml.PrependChild(xmlElementSub);
                             if (!fileName.Contains("~"))
                             {
                                 filesString += fileName;
                             }
                         }
                     }
                 }
                 catch { }
             }
         }
         xdoc.Save(Finance_Tools.FolderFileXMLPath + Finance_Tools.simpleID + ".xml");
         Finance_Tools.TemplateCount = filesString;
     }
 }
コード例 #8
0
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);

            try
            {
                //var map = new ExeConfigurationFileMap();
                ////Get app.config path
                //map.ExeConfigFilename = Context.Parameters["assemblypath"] + ".config";
                ////Get Config and AppSettings
                //var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
                //var appSettings = config.AppSettings;
                ////Get input value from setup project
                //var configValueList = new List<string>() { Context.Parameters["Config1"],
                //                                           Context.Parameters["Config2"],
                //                                           Context.Parameters["Config3"] };
                ////assign input value to appSettings
                //for (int i = 1; i <= 3; i++)
                //{
                //    appSettings.Settings["Sample.Config" + i].Value = configValueList[i - 1];
                //}
                ////save app.config
                //config.Save();
                //System.Environment.SpecialFolder.ApplicationData

                string s  = Context.Parameters["Config1"];
                string s2 = Context.Parameters["Config2"];
                string s3 = Context.Parameters["Config3"];

                string path = Context.Parameters["assemblypath"].ToString().Substring(0, Context.Parameters["assemblypath"].ToString().LastIndexOf("\\"));
                //var map = new ExeConfigurationFileMap();

                //MessageBox.Show(path + "\\Application Files\\ExcelAddIn21_1_0_0_63\\" + Path.GetFileName(Context.Parameters["assemblypath"]) +".config");
                ////Get app.config path
                //map.ExeConfigFilename = path + "\\Application Files\\ExcelAddIn21_1_0_0_63\\" + Path.GetFileName(Context.Parameters["assemblypath"]) +".config.deploy" ;

                ////Get Config and AppSettings
                //var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
                //var appSettings = config.AppSettings;

                //appSettings.Settings["IntermediateConfig"].Value = path + "\\RSDataConfig\\Server.txt";
                ////save app.config
                //config.Save();

                ////System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                ////config.AppSettings.Settings["IntermediateConfig"].Value = path + "\\RSDataConfig\\Server.txt";
                ////config.Save(ConfigurationSaveMode.Modified);
                ////ConfigurationManager.RefreshSection("appSettings");

                string s4 = Context.Parameters["Config4"];



                DirectoryInfo mypath = new DirectoryInfo("C:\\ProgramData\\RSDataV2\\RSDataConfig");
                if (mypath.Exists)
                {
                }
                else
                {
                    mypath.Create();
                }
                if (File.Exists("C:\\ProgramData\\RSDataV2\\RSDataConfig\\Server.txt"))
                {
                    File.Delete("C:\\ProgramData\\RSDataV2\\RSDataConfig\\Server.txt");
                    //File.Delete(path + "\\RSDataConfig\\Server.txt");
                }

                FileStream   aFile = new FileStream("C:\\ProgramData\\RSDataV2\\RSDataConfig\\Server.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
                StreamWriter sw    = new StreamWriter(aFile);
                sw.WriteLine("{0}", DEncrypt.Encrypt(Context.Parameters["Config1"]));
                sw.WriteLine("{0}", DEncrypt.Encrypt(Context.Parameters["Config2"]));
                sw.WriteLine("{0}", DEncrypt.Encrypt(Context.Parameters["Config3"]));
                sw.Close();

                Finance_Tools.AddDirectorySecurity("C:\\ProgramData\\RSDataV2\\RSDataConfig\\Server.txt", @"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, AccessControlType.Allow);

                if (!File.Exists("C:\\ProgramData\\RSDataV2\\RSDataConfig\\DataFieldsSetting.xml"))
                {
                    FileStream   aFile2 = new FileStream("C:\\ProgramData\\RSDataV2\\RSDataConfig\\DataFieldsSetting.xml", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
                    StreamWriter sw2    = new StreamWriter(aFile2);
                    sw2.Write("{0}", XMLCollection.xml);
                    sw2.Close();

                    Finance_Tools.AddDirectorySecurity("C:\\ProgramData\\RSDataV2\\RSDataConfig\\DataFieldsSetting.xml", @"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, AccessControlType.Allow);
                }
                if (!File.Exists("C:\\ProgramData\\RSDataV2\\RSDataConfig\\GenDescFieldsSetting.xml"))
                {
                    FileStream   aFile3 = new FileStream("C:\\ProgramData\\RSDataV2\\RSDataConfig\\GenDescFieldsSetting.xml", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
                    StreamWriter sw3    = new StreamWriter(aFile3);
                    sw3.Write("{0}", XMLCollection.xmlGen);
                    sw3.Close();

                    Finance_Tools.AddDirectorySecurity("C:\\ProgramData\\RSDataV2\\RSDataConfig\\GenDescFieldsSetting.xml", @"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, AccessControlType.Allow);
                }
                //string installFile = Context.Parameters["assemblypath"].ToString().Replace("dll", "vsto");
                //Process.Start(installFile);


                //============================================================setup3============================================
                //string s = Context.Parameters["Config1"];
                //string path = Context.Parameters["assemblypath"].ToString().Substring(0, Context.Parameters["assemblypath"].ToString().LastIndexOf("\\"));

                //DirectoryInfo mypath = new DirectoryInfo("C:\\ProgramData\\RSData\\RSDataConfig");
                //if (mypath.Exists)
                //{
                //}
                //else
                //{
                //    mypath.Create();
                //}
                //if (File.Exists("C:\\ProgramData\\RSData\\RSDataConfig\\Server.txt"))
                //{
                //    File.Delete("C:\\ProgramData\\RSData\\RSDataConfig\\Server.txt");
                //    //File.Delete(path + "\\RSDataConfig\\Server.txt");
                //}

                //FileStream aFile = new FileStream("C:\\ProgramData\\RSData\\RSDataConfig\\Server.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
                //StreamWriter sw = new StreamWriter(aFile);
                //sw.Write("{0}", Context.Parameters["Config1"]);
                //sw.Close();

                //Finance_Tools.AddDirectorySecurity("C:\\ProgramData\\RSData\\RSDataConfig\\Server.txt", @"Everyone", System.Security.AccessControl.FileSystemRights.FullControl, AccessControlType.Allow);
            }
            catch (Exception e)
            {
                string s = e.Message;
            }
        }
コード例 #9
0
 /// <summary>
 ///
 /// </summary>
 private void BindXMLEntityInfo()
 {
     this.txtSA.Text = Finance_Tools.GetAppConfig("SuspenseAccount");
     this.txtBU.Text = Finance_Tools.GetAppConfig("BusinessUnit");
 }
コード例 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            Control[]     ctlsSF = this.panel4.Controls.Find("cbsunField", true);
            Control[]     ctlsFN = this.panel4.Controls.Find("cbfriendlyName", true);
            Control[]     ctlsO  = this.panel4.Controls.Find("cbOutput", true);
            Control[]     ctlsI  = this.panel4.Controls.Find("cbinput", true);
            SqlConnection conn   = null;

            if (Tag == "Gen")
            {
                try
                {
                    conn = new
                           SqlConnection(ConfigurationManager.ConnectionStrings["conRsTool"].ConnectionString.ToString());
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("rsTemplateGenDescFields_Del", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@TemplateID", SessionInfo.UserInfo.File_ftid));
                    cmd.ExecuteNonQuery();
                    SqlCommand cmd2 = new SqlCommand("rsTemplateGenDescFields_Ins", conn);
                    cmd2.CommandType = CommandType.StoredProcedure;
                    for (int i = 0; i < ctlsSF.Length; i++)
                    {
                        string sunfield   = ((TextBox)ctlsSF[i]).Text;
                        string friendname = ((TextBox)ctlsFN[i]).Text;
                        string output     = ((ComboBox)ctlsO[i]).Text;
                        string xmlquery   = ((TextBox)ctlsI[i]).Text;
                        cmd2.Parameters.Clear();
                        cmd2.Parameters.Add(new SqlParameter("@FieldGroup", ""));
                        cmd2.Parameters.Add(new SqlParameter("@SunField", sunfield));
                        cmd2.Parameters.Add(new SqlParameter("@UserFriendlyName", friendname));
                        cmd2.Parameters.Add(new SqlParameter("@Output", output));
                        cmd2.Parameters.Add(new SqlParameter("@Input", ""));
                        cmd2.Parameters.Add(new SqlParameter("@XML_Query", xmlquery));
                        cmd2.Parameters.Add(new SqlParameter("@TemplateID", SessionInfo.UserInfo.File_ftid));
                        cmd2.Parameters.Add(new SqlParameter("@version", i));
                        cmd2.ExecuteNonQuery();
                    }
                }
                finally
                {
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
            }
            else
            {
                try
                {
                    conn = new
                           SqlConnection(ConfigurationManager.ConnectionStrings["conRsTool"].ConnectionString.ToString());
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("rsGlobalFields_Del", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.ExecuteNonQuery();
                    SqlCommand cmd2 = new SqlCommand("rsGlobalFields_Ins", conn);
                    cmd2.CommandType = CommandType.StoredProcedure;
                    for (int i = 0; i < ctlsSF.Length; i++)
                    {
                        string sunfield   = ((TextBox)ctlsSF[i]).Text;
                        string friendname = ((TextBox)ctlsFN[i]).Text;
                        string output     = ((ComboBox)ctlsO[i]).Text;
                        string xmlquery   = ((TextBox)ctlsI[i]).Text;
                        cmd2.Parameters.Clear();
                        cmd2.Parameters.Add(new SqlParameter("@FieldGroup", ""));
                        cmd2.Parameters.Add(new SqlParameter("@SunField", sunfield));
                        cmd2.Parameters.Add(new SqlParameter("@UserFriendlyName", friendname));
                        cmd2.Parameters.Add(new SqlParameter("@Output", output));
                        cmd2.Parameters.Add(new SqlParameter("@Input", ""));
                        cmd2.Parameters.Add(new SqlParameter("@XML_Query", xmlquery));
                        cmd2.Parameters.Add(new SqlParameter("@version", i));
                        cmd2.ExecuteNonQuery();
                    }
                }
                finally
                {
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
            }
            Finance_Tools.AppSettingSave("isUseFriendlyName", "true");
            this.Close();
        }